93 Commits
Author SHA1 Message Date
Phillip Burgess 167e9364be Trying to get CCL working, not there yet 2018-06-21 22:29:18 -07:00
Phillip Burgess bdcfb20734 Tweak pushColors() for SAMD51, add non-DMA option to wobble example 2018-06-21 18:40:57 -07:00
Phillip Burgess c542e168f3 Added 'wobble' example -- better example of pushColorsDMA() 2018-06-21 18:22:10 -07:00
Phillip Burgess d5390a973a Add pushColorsDMA() and example use in tftbmp.pde 2018-06-21 17:42:36 -07:00
Phillip Burgess aef2d6d469 DMA working, BUT with gotchas, see comments in examples! 2018-06-21 13:43:51 -07:00
Phillip Burgess c69ffb9866 DMA working for flood() function if hi & lo bytes match 2018-06-20 17:38:11 -07:00
Phillip Burgess b0debeeeef Initial SAMD51 work
Breakout only (no shield), data pins are hardcoded, works on ItsyBitsy M4.
2018-06-19 22:10:25 -07:00
ladyada 8ad1ede59f change init to retry ILI9341 checks a few times 2018-02-22 17:03:41 -05:00
Tony DiCola d73bbf1866 Add GitHub issue template 2016-05-27 13:43:05 -07:00
Tony DiCola 9535fbf889 Add GitHub pull request template 2016-05-27 13:37:54 -07:00
driverblock 97a82854c8 Fixed 3.5" TFT text rotation issue
Fixed MADCTL values for HX8357B
2014-11-13 10:38:59 -05:00
driverblock ecf4cf17b0 add HX8357 driver check 2014-10-31 13:40:29 -04:00
driverblock 6c236e25fa Add HX8357 driver check 2014-10-31 13:39:28 -04:00
ladyada 40266af7ab add HX8357 check 2014-08-15 17:52:54 -04:00
ladyada 6c41da9750 fixes 2014-08-13 18:15:49 -04:00
ladyada 9323b5cdb5 Merge branch 'master' of github.com:adafruit/TFTLCD-Library
Conflicts:
	Adafruit_TFTLCD.cpp
2014-08-13 17:43:31 -04:00
ladyada 87479c7442 Add HX8357D 3.5" tft support 2014-08-13 17:42:46 -04:00
Tony DiCola 7a983dcbc5 Fix #11 by adding SPI.h to tftbmp example. 2014-07-25 18:40:41 -07:00
Tony DiCola 7d70af32ff Update tftbmp example note to mention Arduino mega hardware SPI. 2014-07-22 22:35:12 -07:00
Tony DiCola d9b13dbda0 Fix #12 by sending rotated with/height limits to setAddrWindow instead of hardcoded values. 2014-07-22 16:57:31 -07:00
ladyada 318bb8356e fix for pushcolor 2014-04-30 12:56:09 -04:00
ladyada 162103b583 Merge branch 'master' of github.com:adafruit/TFTLCD-Library 2014-04-30 12:54:08 -04:00
ladyada 879c387a08 added ILI9341 check to tftbmp! 2014-04-30 12:53:37 -04:00
driverblock f775b97d86 Change Point to TSPoint
Someone changed the TouchScreen l;ibrary to define TSPoint instead of Point, but didn't update this example sketch
2014-03-24 17:05:10 -04:00
ladyada 286f81f96e TFTpaint for ili9341 fixed! 2014-03-18 14:35:33 -04:00
ladyada 391f1a503f rotation for ili9341 fixed and also now default 'upright' 2014-03-18 14:33:29 -04:00
ladyada 7fc3d6fb0a fix merge for readreg() and also, add ili9341 to graphicstest 2014-03-18 13:59:34 -04:00
ladyada 6bc43d3e67 Merge branch 'master' of github.com:adafruit/TFTLCD-Library
Conflicts:
	Adafruit_TFTLCD.cpp
	Adafruit_TFTLCD.h
2014-03-17 21:23:22 -04:00
ladyada b9d06458f5 add ILI9341 support - shield is no longer default (new shield has new library) 2014-03-17 21:20:57 -04:00
driverblock 1cf75baa9b Restored
Restored files mistakenly deleted
2013-09-07 17:47:22 -04:00
driverblock 4ccd1148b0 merge follies 2013-09-07 17:44:31 -04:00
driverblock c596e1aa7f Merge branch 'Due' 2013-09-07 17:43:26 -04:00
Phillip Burgess ffce7315b6 readPixel() working, more robust readID() 2013-07-15 13:51:42 -07:00
Phillip Burgess 2926bacdbc Fix for recent Adafruit_GFX change and PROGMEM kludges 2013-07-05 11:40:09 -07:00
Phillip Burgess b229812d29 Fix(?) for readID returning 0 2013-03-17 21:10:48 -07:00
Phillip Burgess e4b0fa892d Fixed PROGMEM string-printing issues 2012-11-21 16:51:07 -08:00
Phillip Burgess f74dd70f2c Partial Leonardo support, BMP examples working on Mega 2012-09-17 16:58:20 -07:00
Phillip Burgess 4e398c8eef Restored goTo() function for now 2012-09-03 11:54:10 -07:00
Phillip Burgess a857c4960f BMP fixes w/TFT breakout 2012-08-31 18:14:25 -07:00
ladyada d44a453e17 BMP drawing working with HX chipset 2012-07-04 13:11:27 -04:00
ladyada 2938be3d5a adjusted examples to check for HX type 2012-07-03 13:41:56 -04:00
ladyada 5cb1161bf8 Fixed HX rotation 2012-07-03 13:22:22 -04:00
ladyada 73f030d62e read it 2012-04-20 12:20:00 -04:00
ladyada 10e5109e61 added header #ifndef 2012-04-17 15:06:58 -04:00
ladyada 936e71a5f0 little typo for UNO's fixed. should be mega + uno ready now 2012-04-16 12:57:07 -04:00
ladyada 450a1929d9 updated shield Mega hardcoded pins - still working on the touchscreen 2012-04-16 12:50:24 -04:00
Paint Your Dragon ca4b16ac34 Tweaks for Adafruit_GFX 2012-04-09 20:53:28 -07:00
Paint Your Dragon ce39dff490 Removed glcdfont.c; now handled by GFX library 2012-04-05 19:57:20 -07:00
ladyada 7167fc5a02 init with id 2012-04-05 22:42:08 -04:00
ladyada df86262987 typo! 2012-04-05 22:34:20 -04:00
ladyada f891b23d38 should be all ready to go now 2012-04-05 22:32:35 -04:00
ladyada 33ad503675 now with basic HX8347G support (need to do optimized fillRect) 2012-04-04 22:56:14 -04:00
Ladyada 418ae2f913 last example to fix 2012-04-04 18:06:44 -04:00
Ladyada 7838b6dad8 more updates 2012-04-04 18:05:27 -04:00
Ladyada 949444204d fixed two more examples for new library name 2012-04-04 17:58:00 -04:00
Ladyada 115fc817ef refactored to use GFX, & 4 times faster for the fixed shield pinout! 2012-04-04 17:53:38 -04:00
Ladyada 8566cff258 Merge branch 'master' of github.com:adafruit/TFTLCD-Library 2012-03-30 10:38:52 -04:00
Ladyada 41f69a0d66 typo fixes 2012-03-30 10:38:37 -04:00
Paint Your Dragon 164456f6f5 Arduino 1.0 compliant 2011-12-02 23:46:39 -08:00
Ladyada 59e176c21a argh #ifdef typo. all good now 2011-08-24 14:04:49 -04:00
Ladyada 3bc51273a2 Added Mega support for the TFT shield 2011-08-23 19:32:30 -04:00
Ladyada 934226e5d2 recommented the TFT pinout changer 2011-07-20 18:37:10 -04:00
Ladyada afe10512ab fixed circles, added tests to example 2011-07-20 18:06:15 -04:00
Ladyada 18f10bb713 filled round rects, and color pickin' helper 2011-07-20 18:01:35 -04:00
Ladyada b20c0ea119 added round rectangle drawing 2011-07-20 16:54:52 -04:00
Ladyada c97a399067 triangles, filled and outlined 2011-07-13 15:47:42 -04:00
Ladyada 3090da8b2f fixed new width/height calls instead of const 2011-06-10 12:04:32 -04:00
Ladyada d0854b30db oops. misnamed! 2011-06-08 17:08:50 -04:00
Ladyada d723ae0eb9 Sorta adding roundrects 2011-06-08 16:38:28 -04:00
Ladyada 8ed1df7bea Kinda started on roundrects 2011-06-08 16:38:10 -04:00
Ladyada 23f92b31a1 Load a bitmap example 2011-06-08 16:37:29 -04:00
Ladyada d06df75d29 Does check for correct shield config! 2011-06-07 17:47:31 -04:00
Ladyada 409ee5e8c4 now with better text and rotation handling! 2011-06-07 17:47:00 -04:00
Ladyada c792899657 TFT paint with correct touch pads for shield 2011-06-07 17:39:49 -04:00
Ladyada ae8c502f61 Demo better text handling and rotation in graphics test 2011-06-07 17:26:10 -04:00
Ladyada f6d0a609e2 Added rotation of all objects, this sketch tests it! 2011-06-07 17:18:47 -04:00
Ladyada 8fb4cda17b Updated touchscreen & tspaint 2011-03-23 14:31:47 -04:00
Ladyada 9f29d4fc3e lines now properly drawn, graphicstest updated with full 4 quadrant test 2011-03-23 13:33:53 -04:00
Ladyada 301e179fde optimized 'away' digitalWrite calls 2011-03-23 13:28:45 -04:00
Ladyada e068240057 Use masking instead of hardcoded pins 2011-03-23 13:19:22 -04:00
Ladyada f9a3d8c3f0 fixed line drawing bug with unsigned ints 2011-03-15 17:18:52 -04:00
Ladyada f56b15bede Clarified BMP format 2011-03-11 16:32:25 -05:00
Ladyada d62573ff58 Added BMP drawing sketch and example BMPs 2011-03-11 16:31:29 -05:00
Ladyada d47f6ec8d0 Added sync code to reset() and a variable for the rotation 2011-03-10 14:04:47 -05:00
Ladyada 6499cc904b Bitmap images for testing purposes 2011-03-09 16:43:04 -05:00
Ladyada ff3d3c7d39 Optimized pin twiddling for much faster drawing (50%!) and a goto(x,y) function 2011-03-09 16:42:44 -05:00
Ladyada 706b8f2882 Added Mega support on portA 2011-02-23 11:46:15 -05:00
Ladyada d81eb3cade line drawin fix 2011-02-23 11:13:48 -05:00
Ladyada 20c0851274 Added a 5x8 generic font 2011-02-11 18:14:03 -05:00
Ladyada 2eb12095df added string drawing and test. doesn't inherit the printing library (yet) 2011-02-11 16:52:16 -05:00
Ladyada 6e8edf0202 license header 2011-02-11 15:10:07 -05:00
Ladyada adbdc7b8db Two examples - a touchscreen painting program and a graphics test party 2011-02-11 15:09:52 -05:00
Ladyada 68a8afecd3 initial working code 2011-01-13 20:42:43 -05:00
14 changed files with 3141 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
something isn't working as expected. In many cases the problem is a common issue
that you will more quickly receive help from the forum community. GitHub issues
are meant for known defects in the code. If you don't know if there is a defect
in the code then start with troubleshooting on the forum first.
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
check all of the steps and commands to run have been followed. Consult the
forum if you're unsure or have questions about steps in a guide/tutorial.
- **For Arduino projects check these very common issues to ensure they don't apply**:
- For uploading sketches or communicating with the board make sure you're using
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
very hard to tell the difference between a data and charge cable! Try using the
cable with other devices or swapping to another cable to confirm it is not
the problem.
- **Be sure you are supplying adequate power to the board.** Check the specs of
your board and plug in an external power supply. In many cases just
plugging a board into your computer is not enough to power it and other
peripherals.
- **Double check all soldering joints and connections.** Flakey connections
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
- **Ensure you are using an official Arduino or Adafruit board.** We can't
guarantee a clone board will have the same functionality and work as expected
with this code and don't support them.
If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
VERSION HERE**
- List the steps to reproduce the problem below (if possible attach a sketch or
copy the sketch code in too): **LIST REPRO STEPS BELOW**
+26
View File
@@ -0,0 +1,26 @@
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
Before you open the request please review the following guidelines and tips to
help it be more easily integrated:
- **Describe the scope of your change--i.e. what the change does and what parts
of the code were modified.** This will help us understand any risks of integrating
the code.
- **Describe any known limitations with your change.** For example if the change
doesn't apply to a supported platform of the library please mention it.
- **Please run any tests or examples that can exercise your modified code.** We
strive to not break users of the code and running tests/examples helps with this
process.
Thank you again for contributing! We will try to test and integrate the change
as soon as we can, but be aware we have many GitHub repositories to manage and
can't immediately respond to every request. There is no need to bump or check in
on a pull request (it will clutter the discussion of the request).
Also don't be worried if the request is closed or not integrated--sometimes the
priorities of Adafruit's GitHub code (education, ease of use) might not match the
priorities of the pull request. Don't fret, the open source community thrives on
forks and GitHub makes it easy to keep your changes in a forked repo.
After reviewing the guidelines above you can delete this text from the pull request.
+1375
View File
File diff suppressed because it is too large Load Diff
+118
View File
@@ -0,0 +1,118 @@
// IMPORTANT: SEE COMMENTS @ LINE 15 REGARDING SHIELD VS BREAKOUT BOARD USAGE.
// Graphics library by ladyada/adafruit with init code from Rossum
// MIT license
#ifndef _ADAFRUIT_TFTLCD_H_
#define _ADAFRUIT_TFTLCD_H_
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Adafruit_GFX.h>
// **** IF USING THE LCD BREAKOUT BOARD, COMMENT OUT THIS NEXT LINE. ****
// **** IF USING THE LCD SHIELD, LEAVE THE LINE ENABLED: ****
//#define USE_ADAFRUIT_SHIELD_PINOUT 1
class Adafruit_TFTLCD : public Adafruit_GFX {
public:
Adafruit_TFTLCD(uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t rst);
Adafruit_TFTLCD(void);
void begin(uint16_t id = 0x9325);
void drawPixel(int16_t x, int16_t y, uint16_t color);
void drawFastHLine(int16_t x0, int16_t y0, int16_t w, uint16_t color);
void drawFastVLine(int16_t x0, int16_t y0, int16_t h, uint16_t color);
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t c);
void fillScreen(uint16_t color);
void reset(void);
void setRegisters8(uint8_t *ptr, uint8_t n);
void setRegisters16(uint16_t *ptr, uint8_t n);
void setRotation(uint8_t x);
// These methods are public in order for BMP examples to work:
void setAddrWindow(int x1, int y1, int x2, int y2);
#if defined(__SAMD51__)
void pushColors(uint16_t *data, uint16_t len, boolean first);
#else
void pushColors(uint16_t *data, uint8_t len, boolean first);
#endif
void pushColorsDMA(uint32_t totalBytes, uint8_t *buffer,
uint16_t bufSize, void (*callback)(uint8_t *dest, uint16_t len));
uint16_t color565(uint8_t r, uint8_t g, uint8_t b),
readPixel(int16_t x, int16_t y),
readID(void);
uint32_t readReg(uint8_t r);
private:
void init(),
// These items may have previously been defined as macros
// in pin_magic.h. If not, function versions are declared:
#ifndef write8
write8(uint8_t value),
#endif
#ifndef setWriteDir
setWriteDir(void),
#endif
#ifndef setReadDir
setReadDir(void),
#endif
#ifndef writeRegister8
writeRegister8(uint8_t a, uint8_t d),
#endif
#ifndef writeRegister16
writeRegister16(uint16_t a, uint16_t d),
#endif
writeRegister24(uint8_t a, uint32_t d),
writeRegister32(uint8_t a, uint32_t d),
#ifndef writeRegisterPair
writeRegisterPair(uint8_t aH, uint8_t aL, uint16_t d),
#endif
setLR(void),
flood(uint16_t color, uint32_t len);
uint8_t driver;
#ifndef read8
uint8_t read8fn(void);
#define read8isFunctionalized
#endif
#ifndef USE_ADAFRUIT_SHIELD_PINOUT
#ifdef __AVR__
volatile uint8_t *csPort , *cdPort , *wrPort , *rdPort;
uint8_t csPinSet , cdPinSet , wrPinSet , rdPinSet ,
csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset,
_reset;
#elif defined(__SAM3X8E__)
Pio *csPort , *cdPort , *wrPort , *rdPort;
uint32_t csPinSet , cdPinSet , wrPinSet , rdPinSet ,
csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset,
_reset;
#elif defined(__SAMD51__)
volatile uint32_t *csPortSet , *cdPortSet , *wrPortSet , *rdPortSet,
*csPortClr , *cdPortClr , *wrPortClr , *rdPortClr;
uint32_t csPinMask , cdPinMask , wrPinMask , rdPinMask,
_reset;
volatile uint8_t *writePort, *readPort, *dirSet, *dirClr;
#endif
#endif
};
// For compatibility with sketches written for older versions of library.
// Color function name was changed to 'color565' for parity with 2.2" LCD
// library.
#define Color565 color565
#endif
-1
View File
@@ -1 +0,0 @@
My gh-pages branch
+21
View File
@@ -0,0 +1,21 @@
This is a library for the Adafruit 2.8" TFT display.
This library works with the Adafruit 2.8" TFT Breakout w/SD card
----> http://www.adafruit.com/products/335
as well as Adafruit TFT Touch Shield
----> http://www.adafruit.com/products/376
Check out the links above for our tutorials and wiring diagrams.
These displays use 8-bit parallel to communicate, 12 or 13 pins are required
to interface (RST is optional).
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_TFTLCD. Check that the Adafruit_TFTLCD folder contains Adafruit_TFTLCD.cpp and Adafruit_TFTLCD.
Place the Adafruit_TFT library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE
Also requires the Adafruit_GFX library for Arduino. https://github.com/adafruit/Adafruit-GFX-Library
Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

+411
View File
@@ -0,0 +1,411 @@
// Graphics test rigged specifically for the SAMD21 branch
// of TFTLCD and the ItsyBitsy M4 board. TFTLCD lib MUST be
// configured for the breakout board option, plus there's
// some wiring shenanigans...
// LCD_WR MUST go to pin D4, because we're using a specific
// timer/counter for PWM output. The pin # could be changed
// IF a corresponding timer change is made in the SAMD21 TFTLIB.
// One of two additional wiring changes MUST be made. Either:
// LCD_WR MUST go through an inverter (e.g. 74HC04)
// -or-
// The TFT 'CS' pin MUST be tied HIGH (ignoring LCD_CS setting)
// If you opt for this latter arrangement, you CANNOT read the
// device ID from the display (or anything else) -- see setup()
// where 'identifier' is hardcoded;
// Data pins are as follows:
// D0 connects to digital pin 0 (Notice these are
// D1 connects to digital pin 1 NOT in order!)
// D2 connects to digital pin 7
// D3 connects to digital pin 9
// D4 connects to digital pin 10
// D5 connects to digital pin 11
// D6 connects to digital pin 13
// D7 connects to digital pin 12
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#define LCD_CS A3 // Chip Select (see notes above)
#define LCD_CD A2 // Command/Data
#define LCD_RD A0 // LCD Read strobe
#define LCD_WR 4 // LCD Write strobe (see notes above)
#define LCD_RESET A4 // Alternately just connect to Arduino's reset pin
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
void setup(void) {
Serial.begin(9600);
Serial.println(F("TFT LCD test"));
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
Serial.println(F("Using Adafruit 2.8\" TFT Arduino Shield Pinout"));
#else
Serial.println(F("Using Adafruit 2.8\" TFT Breakout Board Pinout"));
#endif
Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
tft.reset();
uint16_t identifier = tft.readID();
// SEE NOTES ABOVE - this is necessary IF using the
// hard-wired CS (and no inverter) option.
identifier = 0x9341;
if(identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
} else if(identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
} else if(identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
} else if(identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
} else if(identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
} else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
}
tft.begin(identifier);
#if 0
// Test frame rate:
uint32_t startTime = millis();
uint32_t frames = 0;
for(;;) {
tft.fillScreen(0x0000);
frames++;
// delay(500);
tft.fillScreen(0xFFFF);
frames++;
// delay(500);
if(!(frames & 0xFF)) {
uint32_t elapsed = (millis() - startTime) / 1000;
if(elapsed > 0) {
Serial.println(frames / elapsed);
}
}
}
#endif
Serial.println(F("Benchmark Time (microseconds)"));
Serial.print(F("Screen fill "));
Serial.println(testFillScreen());
delay(500);
Serial.print(F("Text "));
Serial.println(testText());
delay(3000);
Serial.print(F("Lines "));
Serial.println(testLines(CYAN));
delay(500);
Serial.print(F("Horiz/Vert Lines "));
Serial.println(testFastLines(RED, BLUE));
delay(500);
Serial.print(F("Rectangles (outline) "));
Serial.println(testRects(GREEN));
delay(500);
Serial.print(F("Rectangles (filled) "));
Serial.println(testFilledRects(YELLOW, MAGENTA));
delay(500);
Serial.print(F("Circles (filled) "));
Serial.println(testFilledCircles(10, MAGENTA));
Serial.print(F("Circles (outline) "));
Serial.println(testCircles(10, WHITE));
delay(500);
Serial.print(F("Triangles (outline) "));
Serial.println(testTriangles());
delay(500);
Serial.print(F("Triangles (filled) "));
Serial.println(testFilledTriangles());
delay(500);
Serial.print(F("Rounded rects (outline) "));
Serial.println(testRoundRects());
delay(500);
Serial.print(F("Rounded rects (filled) "));
Serial.println(testFilledRoundRects());
delay(500);
Serial.println(F("Done!"));
}
void loop(void) {
for(uint8_t rotation=0; rotation<4; rotation++) {
tft.setRotation(rotation);
testText();
delay(2000);
}
}
unsigned long testFillScreen() {
unsigned long start = micros();
tft.fillScreen(BLACK);
tft.fillScreen(RED);
tft.fillScreen(GREEN);
tft.fillScreen(BLUE);
tft.fillScreen(BLACK);
return micros() - start;
}
unsigned long testText() {
tft.fillScreen(BLACK);
unsigned long start = micros();
tft.setCursor(0, 0);
tft.setTextColor(WHITE); tft.setTextSize(1);
tft.println("Hello World!");
tft.setTextColor(YELLOW); tft.setTextSize(2);
tft.println(1234.56);
tft.setTextColor(RED); tft.setTextSize(3);
tft.println(0xDEADBEEF, HEX);
tft.println();
tft.setTextColor(GREEN);
tft.setTextSize(5);
tft.println("Groop");
tft.setTextSize(2);
tft.println("I implore thee,");
tft.setTextSize(1);
tft.println("my foonting turlingdromes.");
tft.println("And hooptiously drangle me");
tft.println("with crinkly bindlewurdles,");
tft.println("Or I will rend thee");
tft.println("in the gobberwarts");
tft.println("with my blurglecruncheon,");
tft.println("see if I don't!");
return micros() - start;
}
unsigned long testLines(uint16_t color) {
unsigned long start, t;
int x1, y1, x2, y2,
w = tft.width(),
h = tft.height();
tft.fillScreen(BLACK);
x1 = y1 = 0;
y2 = h - 1;
start = micros();
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
x2 = w - 1;
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
t = micros() - start; // fillScreen doesn't count against timing
tft.fillScreen(BLACK);
x1 = w - 1;
y1 = 0;
y2 = h - 1;
start = micros();
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
x2 = 0;
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
t += micros() - start;
tft.fillScreen(BLACK);
x1 = 0;
y1 = h - 1;
y2 = 0;
start = micros();
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
x2 = w - 1;
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
t += micros() - start;
tft.fillScreen(BLACK);
x1 = w - 1;
y1 = h - 1;
y2 = 0;
start = micros();
for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
x2 = 0;
for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
return micros() - start;
}
unsigned long testFastLines(uint16_t color1, uint16_t color2) {
unsigned long start;
int x, y, w = tft.width(), h = tft.height();
tft.fillScreen(BLACK);
start = micros();
for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
return micros() - start;
}
unsigned long testRects(uint16_t color) {
unsigned long start;
int n, i, i2,
cx = tft.width() / 2,
cy = tft.height() / 2;
tft.fillScreen(BLACK);
n = min(tft.width(), tft.height());
start = micros();
for(i=2; i<n; i+=6) {
i2 = i / 2;
tft.drawRect(cx-i2, cy-i2, i, i, color);
}
return micros() - start;
}
unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
unsigned long start, t = 0;
int n, i, i2,
cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
n = min(tft.width(), tft.height());
for(i=n; i>0; i-=6) {
i2 = i / 2;
start = micros();
tft.fillRect(cx-i2, cy-i2, i, i, color1);
t += micros() - start;
// Outlines are not included in timing results
tft.drawRect(cx-i2, cy-i2, i, i, color2);
}
return t;
}
unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
unsigned long start;
int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
tft.fillScreen(BLACK);
start = micros();
for(x=radius; x<w; x+=r2) {
for(y=radius; y<h; y+=r2) {
tft.fillCircle(x, y, radius, color);
}
}
return micros() - start;
}
unsigned long testCircles(uint8_t radius, uint16_t color) {
unsigned long start;
int x, y, r2 = radius * 2,
w = tft.width() + radius,
h = tft.height() + radius;
// Screen is not cleared for this one -- this is
// intentional and does not affect the reported time.
start = micros();
for(x=0; x<w; x+=r2) {
for(y=0; y<h; y+=r2) {
tft.drawCircle(x, y, radius, color);
}
}
return micros() - start;
}
unsigned long testTriangles() {
unsigned long start;
int n, i, cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
n = min(cx, cy);
start = micros();
for(i=0; i<n; i+=5) {
tft.drawTriangle(
cx , cy - i, // peak
cx - i, cy + i, // bottom left
cx + i, cy + i, // bottom right
tft.color565(0, 0, i));
}
return micros() - start;
}
unsigned long testFilledTriangles() {
unsigned long start, t = 0;
int i, cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
start = micros();
for(i=min(cx,cy); i>10; i-=5) {
start = micros();
tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
tft.color565(0, i, i));
t += micros() - start;
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
tft.color565(i, i, 0));
}
return t;
}
unsigned long testRoundRects() {
unsigned long start;
int w, i, i2,
cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
w = min(tft.width(), tft.height());
start = micros();
for(i=0; i<w; i+=6) {
i2 = i / 2;
tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
}
return micros() - start;
}
unsigned long testFilledRoundRects() {
unsigned long start;
int i, i2,
cx = tft.width() / 2 - 1,
cy = tft.height() / 2 - 1;
tft.fillScreen(BLACK);
start = micros();
for(i=min(tft.width(), tft.height()); i>20; i-=6) {
i2 = i / 2;
tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
}
return micros() - start;
}
+419
View File
@@ -0,0 +1,419 @@
// BMP-loading demo rigged specifically for the SAMD21 branch
// of TFTLCD and the ItsyBitsy M4 board. TFTLCD lib MUST be
// configured for the breakout board option, plus there's
// some wiring shenanigans...
// LCD_WR MUST go to pin D4, because we're using a specific
// timer/counter for PWM output. The pin # could be changed
// IF a corresponding timer change is made in the SAMD21 TFTLIB.
// One of two additional wiring changes MUST be made. Either:
// LCD_WR MUST go through an inverter (e.g. 74HC04)
// -or-
// The TFT 'CS' pin MUST be tied HIGH (ignoring LCD_CS setting)
// If you opt for this latter arrangement, you CANNOT read the
// device ID from the display (or anything else) -- see setup()
// where 'identifier' is hardcoded;
// Data pins are as follows:
// D0 connects to digital pin 0 (Notice these are
// D1 connects to digital pin 1 NOT in order!)
// D2 connects to digital pin 7
// D3 connects to digital pin 9
// D4 connects to digital pin 10
// D5 connects to digital pin 11
// D6 connects to digital pin 13
// D7 connects to digital pin 12
#include <SD.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#define LCD_CS A3 // Chip Select (see notes above)
#define LCD_CD A2 // Command/Data
#define LCD_RD A0 // LCD Read strobe
#define LCD_WR 4 // LCD Write strobe (see notes above)
#define LCD_RESET A4 // Alternately just connect to Arduino's reset pin
// DO NOT use the SD card slot on the TFT breakout -- it doesn't
// appear to work when using the parallel interface. Instead, a
// separate SD breakout is needed.
#define SD_CS A5 // SD card delect
// A switch or jumper on A1 selects DMA vs non-DMA BMP loading.
// There's really not a huge performance difference in this case
// just because the bottleneck is in the SD card access and color
// conversion operations...BUT...it does demonstrate how the
// pushColorsDMA() function works, and how to use a callback to
// load the next block of data while the current block is sent.
#define DMA_SELECT A1 // Hi/lo chooses DMA vs non-DMA DMA loader
// In the SD card, place 24 bit color BMP files (be sure they are 24-bit!)
// There are examples in the sketch folder
// our TFT wiring
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
void setup()
{
Serial.begin(9600);
while(!Serial);
pinMode(DMA_SELECT, INPUT_PULLUP);
tft.reset();
uint16_t identifier = tft.readID();
// SEE NOTES ABOVE - this is necessary IF using the
// hard-wired CS (and no inverter) option.
identifier = 0x9341;
if(identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
} else if(identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
} else if(identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
} else if(identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
} else if(identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
} else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
return;
}
tft.begin(identifier);
tft.fillScreen(0);
Serial.print(F("Initializing SD card..."));
if (!SD.begin(SD_CS)) {
Serial.println(F("failed!"));
tft.fillScreen(0xF800);
for(;;);
}
Serial.println(F("OK!"));
tft.fillScreen(0x001F);
if(digitalRead(DMA_SELECT))
bmpDrawDMA("woof.bmp", 0, 0);
else
bmpDraw("woof.bmp", 0, 0);
// delay(1000);
}
void loop()
{
for(int i = 0; i<4; i++) {
tft.setRotation(i);
tft.fillScreen(0);
for(int j=0; j <= 200; j += 50) {
if(digitalRead(DMA_SELECT))
bmpDrawDMA("miniwoof.bmp", j, j);
else
bmpDraw("miniwoof.bmp", j, j);
}
// delay(1000);
}
}
// Common functions/vars for both BMP loaders ------------------------------
// These read 16- and 32-bit types from the SD card file.
// BMP data is stored little-endian, Arduino is little-endian too.
// May need to reverse subscript order if porting elsewhere.
uint16_t read16(File f) {
uint16_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read(); // MSB
return result;
}
uint32_t read32(File f) {
uint32_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read();
((uint8_t *)&result)[2] = f.read();
((uint8_t *)&result)[3] = f.read(); // MSB
return result;
}
// "Vanilla" (non-DMA) BMP Loader ------------------------------------------
// This function opens a Windows Bitmap (BMP) file and
// displays it at the given coordinates. It's sped up
// by reading many pixels worth of data at a time
// (rather than pixel by pixel). Increasing the buffer
// size takes more of the Arduino's precious RAM but
// makes loading a little faster. 20 pixels seems a
// good balance.
#define BUFFPIXEL 64
void bmpDraw(char *filename, int x, int y) {
File bmpFile;
int bmpWidth, bmpHeight; // W+H in pixels
uint8_t bmpDepth; // Bit depth (currently must be 24)
uint32_t bmpImageoffset; // Start of image data in file
uint32_t rowSize; // Not always = bmpWidth; may have padding
uint8_t sdbuffer[3*BUFFPIXEL]; // pixel in buffer (R+G+B per pixel)
uint16_t lcdbuffer[BUFFPIXEL]; // pixel out buffer (16-bit per pixel)
uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer
boolean goodBmp = false; // Set to true on valid header parse
boolean flip = true; // BMP is stored bottom-to-top
int w, h, row, col;
uint8_t r, g, b;
uint32_t pos = 0, startTime = millis();
uint8_t lcdidx = 0;
boolean first = true;
uint16_t col16;
if((x >= tft.width()) || (y >= tft.height())) return;
Serial.println();
Serial.print(F("Loading image '"));
Serial.print(filename);
Serial.println('\'');
// Open requested file on SD card
if ((bmpFile = SD.open(filename)) == NULL) {
Serial.println(F("File not found"));
return;
}
// Parse BMP header
if(read16(bmpFile) == 0x4D42) { // BMP signature
Serial.println(F("File size: ")); Serial.println(read32(bmpFile));
(void)read32(bmpFile); // Read & ignore creator bytes
bmpImageoffset = read32(bmpFile); // Start of image data
Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
// Read DIB header
Serial.print(F("Header size: ")); Serial.println(read32(bmpFile));
bmpWidth = read32(bmpFile);
bmpHeight = read32(bmpFile);
if(read16(bmpFile) == 1) { // # planes -- must be '1'
bmpDepth = read16(bmpFile); // bits per pixel
Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed
goodBmp = true; // Supported BMP format -- proceed!
Serial.print(F("Image size: "));
Serial.print(bmpWidth);
Serial.print('x');
Serial.println(bmpHeight);
// BMP rows are padded (if needed) to 4-byte boundary
rowSize = (bmpWidth * 3 + 3) & ~3;
// If bmpHeight is negative, image is in top-down order.
// This is not canon but has been observed in the wild.
if(bmpHeight < 0) {
bmpHeight = -bmpHeight;
flip = false;
}
// Crop area to be loaded
w = bmpWidth;
h = bmpHeight;
if((x+w-1) >= tft.width()) w = tft.width() - x;
if((y+h-1) >= tft.height()) h = tft.height() - y;
// Set TFT address window to clipped image bounds
tft.setAddrWindow(x, y, x+w-1, y+h-1);
for (row=0; row<h; row++) { // For each scanline...
// Seek to start of scan line. It might seem labor-
// intensive to be doing this on every line, but this
// method covers a lot of gritty details like cropping
// and scanline padding. Also, the seek only takes
// place if the file position actually needs to change
// (avoids a lot of cluster math in SD library).
if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
else // Bitmap is stored top-to-bottom
pos = bmpImageoffset + row * rowSize;
if(bmpFile.position() != pos) { // Need seek?
bmpFile.seek(pos);
buffidx = sizeof(sdbuffer); // Force buffer reload
}
for (col=0; col<w; col++) { // For each column...
// Time to read more pixel data?
if (buffidx >= sizeof(sdbuffer)) { // Indeed
// Push LCD buffer to the display first
if(lcdidx > 0) {
tft.pushColors(lcdbuffer, lcdidx, first);
lcdidx = 0;
first = false;
}
bmpFile.read(sdbuffer, sizeof(sdbuffer));
buffidx = 0; // Set index to beginning
}
// Convert pixel from BMP to TFT format
b = sdbuffer[buffidx++];
g = sdbuffer[buffidx++];
r = sdbuffer[buffidx++];
col16 = tft.color565(r,g,b);
lcdbuffer[lcdidx++] = (col16 * 0x00010001) >> 8; // Flip hi/lo bytes
} // end pixel
} // end scanline
// Write any remaining data to LCD
if(lcdidx > 0) {
tft.pushColors(lcdbuffer, lcdidx, first);
}
Serial.print(F("Loaded in "));
Serial.print(millis() - startTime);
Serial.println(" ms");
} // end goodBmp
}
}
tft.setAddrWindow(0, 0, tft.width() - 1, tft.height() - 1);
bmpFile.close();
if(!goodBmp) Serial.println(F("BMP format not recognized."));
}
// DMA BMP Loader ----------------------------------------------------------
// DMA buffer: 320 pixels max width, DMALINES height, 2 bytes/pixel, 2 bufs
// SD buffer: 320 pixels max width, one scanline
#define DMALINES 16
uint8_t dmabuf[DMALINES * 320 * 2 * 2];
uint8_t sdbuf[320 * 3];
File bmpFile;
uint32_t bmpImageoffset; // Start of image data in file
int lineNum, linesToGo; // Current, remaining lines to load
boolean flip; // BMP is stored bottom-to-top
int bmpHeight; // Uncropped height in pixels
int croppedWidth; // Cropped width in pixels
uint32_t rowSize; // Not always bmpWidth; may have padding
void bmpCallback(uint8_t *dest, uint16_t len) {
int row, col, linesThisPass;
uint8_t r, g, b, *ptr;
uint16_t col16;
uint32_t pos;
linesThisPass = (linesToGo > DMALINES) ? DMALINES : linesToGo;
for(row=0; row<linesThisPass; row++, lineNum++) { // For each scanline...
// Seek to start of scan line. It might seem labor-
// intensive to be doing this on every line, but this
// method covers a lot of gritty details like cropping
// and scanline padding. Also, the seek only takes
// place if the file position actually needs to change
// (avoids a lot of cluster math in SD library).
if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
pos = bmpImageoffset + (bmpHeight - 1 - lineNum) * rowSize;
else // Bitmap is stored top-to-bottom
pos = bmpImageoffset + lineNum * rowSize;
if(bmpFile.position() != pos) { // Need seek?
bmpFile.seek(pos);
}
bmpFile.read(sdbuf, croppedWidth * 3); // Read scanline
ptr = sdbuf;
for(col=0; col<croppedWidth; col++) { // For each column...
// Convert pixel from BMP to TFT format
b = *ptr++;
g = *ptr++;
r = *ptr++;
col16 = tft.color565(r,g,b);
*dest++ = col16 >> 8; // High byte
*dest++ = col16; // Low byte
} // end pixel
} // end scanline
linesToGo -= linesThisPass;
}
void bmpDrawDMA(char *filename, int x, int y) {
int bmpWidth; // Image width in pixels
uint8_t bmpDepth; // Bit depth (currently must be 24)
boolean goodBmp = false; // Set to true on valid header parse
int w, h;
uint32_t startTime = millis();
if((x >= tft.width()) || (y >= tft.height())) return;
Serial.println();
Serial.print(F("Loading image '"));
Serial.print(filename);
Serial.println('\'');
// Open requested file on SD card
if ((bmpFile = SD.open(filename)) == NULL) {
Serial.println(F("File not found"));
return;
}
// Parse BMP header
if(read16(bmpFile) == 0x4D42) { // BMP signature
Serial.println(F("File size: ")); Serial.println(read32(bmpFile));
(void)read32(bmpFile); // Read & ignore creator bytes
bmpImageoffset = read32(bmpFile); // Start of image data
Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
// Read DIB header
Serial.print(F("Header size: ")); Serial.println(read32(bmpFile));
bmpWidth = read32(bmpFile);
bmpHeight = read32(bmpFile);
if(read16(bmpFile) == 1) { // # planes -- must be '1'
bmpDepth = read16(bmpFile); // bits per pixel
Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed
goodBmp = true; // Supported BMP format -- proceed!
Serial.print(F("Image size: "));
Serial.print(bmpWidth);
Serial.print('x');
Serial.println(bmpHeight);
// BMP rows are padded (if needed) to 4-byte boundary
rowSize = (bmpWidth * 3 + 3) & ~3;
// If bmpHeight is negative, image is in top-down order.
// This is not canon but has been observed in the wild.
if(bmpHeight < 0) {
bmpHeight = -bmpHeight;
flip = false;
} else {
flip = true;
}
// Crop area to be loaded
w = bmpWidth;
h = bmpHeight;
if((x+w-1) >= tft.width()) w = tft.width() - x;
if((y+h-1) >= tft.height()) h = tft.height() - y;
// Set TFT address window to clipped image bounds
tft.setAddrWindow(x, y, x+w-1, y+h-1);
croppedWidth = w;
lineNum = 0;
linesToGo = h;
tft.pushColorsDMA(w * h * 2, dmabuf, w * DMALINES * 2, bmpCallback);
Serial.print(F("Loaded in "));
Serial.print(millis() - startTime);
Serial.println(" ms");
} // end goodBmp
}
}
tft.setAddrWindow(0, 0, tft.width() - 1, tft.height() - 1);
bmpFile.close();
if(!goodBmp) Serial.println(F("BMP format not recognized."));
}
+105
View File
@@ -0,0 +1,105 @@
#include <SD.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#define LCD_CS A3 // Chip Select (see notes above)
#define LCD_CD A2 // Command/Data
#define LCD_RD A0 // LCD Read strobe
#define LCD_WR 4 // LCD Write strobe (see notes above)
#define LCD_RESET A4 // Alternately just connect to Arduino's reset pin
#define DMA_SELECT A1 // Hi/lo chooses DMA vs non-DMA effect
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
#define DMALINES 16
// DMA buffer is 320 pixels * DMALINES * 2 bytes/pixel * 2 buffers
uint8_t dmabuf[320 * DMALINES * 2 * 2];
// Pixel buffer is slightly wider than screen, for X-scrolling
uint16_t pixels[320 + 64];
uint32_t startTime;
void setup()
{
Serial.begin(9600);
while(!Serial);
pinMode(DMA_SELECT, INPUT_PULLUP);
// Initialize pixel buffer with alternating red and white bands,
// 32 pixels wide. 0x00F8 is 16-bit red (0xF800) endian-swapped
// so bytes can be copied directly to screen.
for(int i=0; i<320+64; i++)
pixels[i] = (i & 32) ? 0x00F8 : 0xFFFF;
tft.reset();
uint16_t identifier = tft.readID();
// SEE NOTES ABOVE - this is necessary IF using the
// hard-wired CS (and no inverter) option.
identifier = 0x9341;
if(identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
} else if(identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
} else if(identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
} else if(identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
} else if(identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
} else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
return;
}
tft.begin(identifier);
tft.setRotation(1);
tft.fillScreen(0);
startTime = millis();
}
int lineNum;
int frame = 0;
// pushColorsDMA() callback function -- fills DMALINES scanlines with
// data from pixels[] array.
void myCallback(uint8_t *dest, uint16_t len) {
for(int i=0; i<DMALINES; i++) {
// Wave up to 64 pixels horizontally (extra width in pixels[] array)
int offset = (int)((sin((float)(lineNum + frame) / 40.0) + 1.0) * 31.5);
// Change offset every 32 lines for checkerboard effect
if((lineNum + frame/8) & 32) offset = (offset + 32) % 63;
memcpy(dest, &pixels[offset], len / DMALINES);
lineNum++;
dest += 320 * 2; // Offset to next scanline (2 bytes/pixel)
}
}
void loop() {
tft.setAddrWindow(0, 0, tft.width() - 1, tft.height() - 1);
lineNum = 0;
if(digitalRead(DMA_SELECT)) {
tft.pushColorsDMA(tft.width() * tft.height() * 2, dmabuf, tft.width() * DMALINES * 2, myCallback);
} else {
bool first = true;
while(lineNum < tft.height()) {
// Fill the DMA buffer, but don't issue it
myCallback(dmabuf, tft.width() * DMALINES * 2);
// Then send it using non-DMA function:
tft.pushColors((uint16_t *)dmabuf, tft.width() * DMALINES, first);
first = false;
}
}
frame++;
uint32_t elapsed = (millis() - startTime) / 1000;
if(elapsed > 0) {
Serial.print(frame / elapsed);
Serial.println(" fps");
}
}
+448
View File
@@ -0,0 +1,448 @@
#ifndef _pin_magic_
#define _pin_magic_
// This header file serves two purposes:
//
// 1) Isolate non-portable MCU port- and pin-specific identifiers and
// operations so the library code itself remains somewhat agnostic
// (PORTs and pin numbers are always referenced through macros).
//
// 2) GCC doesn't always respect the "inline" keyword, so this is a
// ham-fisted manner of forcing the issue to minimize function calls.
// This sometimes makes the library a bit bigger than before, but fast++.
// However, because they're macros, we need to be SUPER CAREFUL about
// parameters -- for example, write8(x) may expand to multiple PORT
// writes that all refer to x, so it needs to be a constant or fixed
// variable and not something like *ptr++ (which, after macro
// expansion, may increment the pointer repeatedly and run off into
// la-la land). Macros also give us fine-grained control over which
// operations are inlined on which boards (balancing speed against
// available program space).
// When using the TFT shield, control and data pins exist in set physical
// locations, but the ports and bitmasks corresponding to each vary among
// boards. A separate set of pin definitions is given for each supported
// board type.
// When using the TFT breakout board, control pins are configurable but
// the data pins are still fixed -- making every data pin configurable
// would be much too slow. The data pin layouts are not the same between
// the shield and breakout configurations -- for the latter, pins were
// chosen to keep the tutorial wiring manageable more than making optimal
// use of ports and bitmasks. So there's a second set of pin definitions
// given for each supported board.
// Shield pin usage:
// LCD Data Bit : 7 6 5 4 3 2 1 0
// Digital pin #: 7 6 13 4 11 10 9 8
// Uno port/pin : PD7 PD6 PB5 PD4 PB3 PB2 PB1 PB0
// Mega port/pin: PH4 PH3 PB7 PG5 PB5 PB4 PH6 PH5
// Leo port/pin : PE6 PD7 PC7 PD4 PB7 PB6 PB5 PB4
// Due port/pin : PC23 PC24 PB27 PC26 PD7 PC29 PC21 PC22
// Breakout pin usage:
// LCD Data Bit : 7 6 5 4 3 2 1 0
// Uno dig. pin : 7 6 5 4 3 2 9 8
// Uno port/pin : PD7 PD6 PD5 PD4 PD3 PD2 PB1 PB0
// Mega dig. pin: 29 28 27 26 25 24 23 22
// Mega port/pin: PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 (one contiguous PORT)
// Leo dig. pin : 7 6 5 4 3 2 9 8
// Leo port/pin : PE6 PD7 PC6 PD4 PD0 PD1 PB5 PB4
// Due dig. pin : 40 39 38 37 36 35 34 33
// Due port/pin : PC8 PC7 PC6 PC5 PC4 PC3 PC2 PC1 (one contiguous PORT. -ish…)
// Pixel read operations require a minimum 400 nS delay from RD_ACTIVE
// to polling the input pins. At 16 MHz, one machine cycle is 62.5 nS.
// This code burns 7 cycles (437.5 nS) doing nothing; the RJMPs are
// equivalent to two NOPs each, final NOP burns the 7th cycle, and the
// last line is a radioactive mutant emoticon.
#define DELAY7 \
asm volatile( \
"rjmp .+0" "\n\t" \
"rjmp .+0" "\n\t" \
"rjmp .+0" "\n\t" \
"nop" "\n" \
::);
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined (__AVR_ATmega328__) || defined(__AVR_ATmega8__)
// Arduino Uno, Duemilanove, etc.
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
// LCD control lines:
// RD (read), WR (write), CD (command/data), CS (chip select)
#define RD_PORT PORTC /*pin A0 */
#define WR_PORT PORTC /*pin A1 */
#define CD_PORT PORTC /*pin A2 */
#define CS_PORT PORTC /*pin A3 */
#define RD_MASK B00000001
#define WR_MASK B00000010
#define CD_MASK B00000100
#define CS_MASK B00001000
// These are macros for I/O operations...
// Write 8-bit value to LCD data lines
#define write8inline(d) { \
PORTD = (PORTD & B00101111) | ((d) & B11010000); \
PORTB = (PORTB & B11010000) | ((d) & B00101111); \
WR_STROBE; } // STROBEs are defined later
// Read 8-bit value from LCD data lines. The signle argument
// is a destination variable; this isn't a function and doesn't
// return a value in the conventional sense.
#define read8inline(result) { \
RD_ACTIVE; \
DELAY7; \
result = (PIND & B11010000) | (PINB & B00101111); \
RD_IDLE; }
// These set the PORT directions as required before the write and read
// operations. Because write operations are much more common than reads,
// the data-reading functions in the library code set the PORT(s) to
// input before a read, and restore them back to the write state before
// returning. This avoids having to set it for output inside every
// drawing method. The default state has them initialized for writes.
#define setWriteDirInline() { DDRD |= B11010000; DDRB |= B00101111; }
#define setReadDirInline() { DDRD &= ~B11010000; DDRB &= ~B00101111; }
#else // Uno w/Breakout board
#define write8inline(d) { \
PORTD = (PORTD & B00000011) | ((d) & B11111100); \
PORTB = (PORTB & B11111100) | ((d) & B00000011); \
WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
DELAY7; \
result = (PIND & B11111100) | (PINB & B00000011); \
RD_IDLE; }
#define setWriteDirInline() { DDRD |= B11111100; DDRB |= B00000011; }
#define setReadDirInline() { DDRD &= ~B11111100; DDRB &= ~B00000011; }
#endif
// As part of the inline control, macros reference other macros...if any
// of these are left undefined, an equivalent function version (non-inline)
// is declared later. The Uno has a moderate amount of program space, so
// only write8() is inlined -- that one provides the most performance
// benefit, but unfortunately also generates the most bloat. This is
// why only certain cases are inlined for each board.
#define write8 write8inline
#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
// Arduino Mega, ADK, etc.
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
#define RD_PORT PORTF
#define WR_PORT PORTF
#define CD_PORT PORTF
#define CS_PORT PORTF
#define RD_MASK B00000001
#define WR_MASK B00000010
#define CD_MASK B00000100
#define CS_MASK B00001000
#define write8inline(d) { \
PORTH = (PORTH&B10000111)|(((d)&B11000000)>>3)|(((d)&B00000011)<<5); \
PORTB = (PORTB&B01001111)|(((d)&B00101100)<<2); \
PORTG = (PORTG&B11011111)|(((d)&B00010000)<<1); \
WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
DELAY7; \
result = ((PINH & B00011000) << 3) | ((PINB & B10110000) >> 2) | \
((PING & B00100000) >> 1) | ((PINH & B01100000) >> 5); \
RD_IDLE; }
#define setWriteDirInline() { \
DDRH |= B01111000; DDRB |= B10110000; DDRG |= B00100000; }
#define setReadDirInline() { \
DDRH &= ~B01111000; DDRB &= ~B10110000; DDRG &= ~B00100000; }
#else // Mega w/Breakout board
#define write8inline(d) { PORTA = (d); WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
DELAY7; \
result = PINA; \
RD_IDLE; }
#define setWriteDirInline() DDRA = 0xff
#define setReadDirInline() DDRA = 0
#endif
// All of the functions are inlined on the Arduino Mega. When using the
// breakout board, the macro versions aren't appreciably larger than the
// function equivalents, and they're super simple and fast. When using
// the shield, the macros become pretty complicated...but this board has
// so much code space, the macros are used anyway. If you need to free
// up program space, some macros can be removed, at a minor cost in speed.
#define write8 write8inline
#define read8 read8inline
#define setWriteDir setWriteDirInline
#define setReadDir setReadDirInline
#define writeRegister8 writeRegister8inline
#define writeRegister16 writeRegister16inline
#define writeRegisterPair writeRegisterPairInline
#elif defined(__AVR_ATmega32U4__)
// Arduino Leonardo
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
#define RD_PORT PORTF
#define WR_PORT PORTF
#define CD_PORT PORTF
#define CS_PORT PORTF
#define RD_MASK B10000000
#define WR_MASK B01000000
#define CD_MASK B00100000
#define CS_MASK B00010000
#define write8inline(d) { \
PORTE = (PORTE & B10111111) | (((d) & B10000000)>>1); \
PORTD = (PORTD & B01101111) | (((d) & B01000000)<<1) | ((d) & B00010000); \
PORTC = (PORTC & B01111111) | (((d) & B00100000)<<2); \
PORTB = (PORTB & B00001111) | (((d) & B00001111)<<4); \
WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
DELAY7; \
result = ((PINE & B01000000) << 1) | ((PIND & B10000000) >> 1) | \
((PINC & B10000000) >> 2) | ((PINB & B11110000) >> 4) | \
(PIND & B00010000); \
RD_IDLE; }
#define setWriteDirInline() { \
DDRE |= B01000000; DDRD |= B10010000; \
DDRC |= B10000000; DDRB |= B11110000; }
#define setReadDirInline() { \
DDRE &= ~B01000000; DDRD &= ~B10010000; \
DDRC &= ~B10000000; DDRB &= ~B11110000; }
#else // Leonardo w/Breakout board
#define write8inline(d) { \
uint8_t dr1 = (d) >> 1, dl1 = (d) << 1; \
PORTE = (PORTE & B10111111) | (dr1 & B01000000); \
PORTD = (PORTD & B01101100) | (dl1 & B10000000) | (((d) & B00001000)>>3) |\
(dr1 & B00000010) | ((d) & B00010000); \
PORTC = (PORTC & B10111111) | (dl1 & B01000000); \
PORTB = (PORTB & B11001111) |(((d) & B00000011)<<4); \
WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
DELAY7; \
result = (((PINE & B01000000) | (PIND & B00000010)) << 1) | \
(((PINC & B01000000) | (PIND & B10000000)) >> 1) | \
((PIND & B00000001) << 3) | ((PINB & B00110000) >> 4) | \
(PIND & B00010000); \
RD_IDLE; }
#define setWriteDirInline() { \
DDRE |= B01000000; DDRD |= B10010011; \
DDRC |= B01000000; DDRB |= B00110000; }
#define setReadDirInline() { \
DDRE &= ~B01000000; DDRD &= ~B10010011; \
DDRC &= ~B01000000; DDRB &= ~B00110000; }
#endif
// On the Leonardo, only the write8() macro is used -- though even that
// might be excessive given the code size and available program space
// on this board. You may need to disable this to get any sizable
// program to compile.
#define write8 write8inline
#elif defined(__SAM3X8E__)
// Arduino Due
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
#define RD_PORT PIOA /*pin A0 */
#define WR_PORT PIOA /*pin A1 */
#define CD_PORT PIOA /*pin A2 */
#define CS_PORT PIOA /*pin A3 */
#define RD_MASK 0x00010000
#define WR_MASK 0x01000000
#define CD_MASK 0x00800000
#define CS_MASK 0x00400000
#define write8inline(d) { \
PIO_Set(PIOD, (((d) & 0x08)<<(7-3))); \
PIO_Clear(PIOD, (((~d) & 0x08)<<(7-3))); \
PIO_Set(PIOC, (((d) & 0x01)<<(22-0)) | (((d) & 0x02)<<(21-1))| (((d) & 0x04)<<(29-2))| (((d) & 0x10)<<(26-4))| (((d) & 0x40)<<(24-6))| (((d) & 0x80)<<(23-7))); \
PIO_Clear(PIOC, (((~d) & 0x01)<<(22-0)) | (((~d) & 0x02)<<(21-1))| (((~d) & 0x04)<<(29-2))| (((~d) & 0x10)<<(26-4))| (((~d) & 0x40)<<(24-6))| (((~d) & 0x80)<<(23-7))); \
PIO_Set(PIOB, (((d) & 0x20)<<(27-5))); \
PIO_Clear(PIOB, (((~d) & 0x20)<<(27-5))); \
WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
delayMicroseconds(1); \
result = (((PIOC->PIO_PDSR & (1<<23)) >> (23-7)) | ((PIOC->PIO_PDSR & (1<<24)) >> (24-6)) | \
((PIOB->PIO_PDSR & (1<<27)) >> (27-5)) | ((PIOC->PIO_PDSR & (1<<26)) >> (26-4)) | \
((PIOD->PIO_PDSR & (1<< 7)) >> ( 7-3)) | ((PIOC->PIO_PDSR & (1<<29)) >> (29-2)) | \
((PIOC->PIO_PDSR & (1<<21)) >> (21-1)) | ((PIOC->PIO_PDSR & (1<<22)) >> (22-0))); \
RD_IDLE;}
#define setWriteDirInline() { \
PIOD->PIO_MDDR |= 0x00000080; /*PIOD->PIO_SODR = 0x00000080;*/ PIOD->PIO_OER |= 0x00000080; PIOD->PIO_PER |= 0x00000080; \
PIOC->PIO_MDDR |= 0x25E00000; /*PIOC->PIO_SODR = 0x25E00000;*/ PIOC->PIO_OER |= 0x25E00000; PIOC->PIO_PER |= 0x25E00000; \
PIOB->PIO_MDDR |= 0x08000000; /*PIOB->PIO_SODR = 0x08000000;*/ PIOB->PIO_OER |= 0x08000000; PIOB->PIO_PER |= 0x08000000; }
#define setReadDirInline() { \
pmc_enable_periph_clk(ID_PIOD); pmc_enable_periph_clk(ID_PIOC); pmc_enable_periph_clk(ID_PIOB) ; \
PI OD->PIO_PUDR |= 0x00000080; PIOD->PIO_IFDR |= 0x00000080; PIOD->PIO_ODR |= 0x00000080; PIOD->PIO_PER |= 0x00000080; \
PIOC->PIO_PUDR |= 0x25E00000; PIOC->PIO_IFDR |= 0x25E00000; PIOC->PIO_ODR |= 0x25E00000; PIOC->PIO_PER |= 0x25E00000; \
PIOB->PIO_PUDR |= 0x08000000; PIOB->PIO_IFDR |= 0x08000000; PIOB->PIO_ODR |= 0x08000000; PIOB->PIO_PER |= 0x08000000; }
// Control signals are ACTIVE LOW (idle is HIGH)
// Command/Data: LOW = command, HIGH = data
// These are single-instruction operations and always inline
#define RD_ACTIVE RD_PORT->PIO_CODR |= RD_MASK
#define RD_IDLE RD_PORT->PIO_SODR |= RD_MASK
#define WR_ACTIVE WR_PORT->PIO_CODR |= WR_MASK
#define WR_IDLE WR_PORT->PIO_SODR |= WR_MASK
#define CD_COMMAND CD_PORT->PIO_CODR |= CD_MASK
#define CD_DATA CD_PORT->PIO_SODR |= CD_MASK
#define CS_ACTIVE CS_PORT->PIO_CODR |= CS_MASK
#define CS_IDLE CS_PORT->PIO_SODR |= CS_MASK
#else // Due w/Breakout board
#define write8inline(d) { \
PIO_Set(PIOC, (((d) & 0xFF)<<1)); \
PIO_Clear(PIOC, (((~d) & 0xFF)<<1)); \
WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
delayMicroseconds(1); \
result = ((PIOC->PIO_PDSR & 0x1FE) >> 1); \
RD_IDLE;}
#define setWriteDirInline() { \
PIOC->PIO_MDDR |= 0x000001FE; \
PIOC->PIO_OER |= 0x000001FE; \
PIOC->PIO_PER |= 0x000001FE; }
#define setReadDirInline() { \
pmc_enable_periph_clk( ID_PIOC ) ; \
PIOC->PIO_PUDR |= 0x000001FE; \
PIOC->PIO_IFDR |= 0x000001FE; \
PIOC->PIO_ODR |= 0x000001FE; \
PIOC->PIO_PER |= 0x000001FE; }
// When using the TFT breakout board, control pins are configurable.
#define RD_ACTIVE rdPort->PIO_CODR |= rdPinSet //PIO_Clear(rdPort, rdPinSet)
#define RD_IDLE rdPort->PIO_SODR |= rdPinSet //PIO_Set(rdPort, rdPinSet)
#define WR_ACTIVE wrPort->PIO_CODR |= wrPinSet //PIO_Clear(wrPort, wrPinSet)
#define WR_IDLE wrPort->PIO_SODR |= wrPinSet //PIO_Set(wrPort, wrPinSet)
#define CD_COMMAND cdPort->PIO_CODR |= cdPinSet //PIO_Clear(cdPort, cdPinSet)
#define CD_DATA cdPort->PIO_SODR |= cdPinSet //PIO_Set(cdPort, cdPinSet)
#define CS_ACTIVE csPort->PIO_CODR |= csPinSet //PIO_Clear(csPort, csPinSet)
#define CS_IDLE csPort->PIO_SODR |= csPinSet //PIO_Set(csPort, csPinSet)
#endif
#elif defined(__SAMD51__) // Metro / Feather / ItsyBitsy M4
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
// M4 w/shield: TBD
#else // M4 w/breakout
#define write8inline(d) { \
*writePort = d; \
WR_STROBE; }
#define read8inline(result) { \
RD_ACTIVE; \
delayMicroseconds(1); \
result = *readPort; \
RD_IDLE; }
#define setWriteDirInline() { *dirSet = 0xFF; }
#define setReadDirInline() { *dirClr = 0xFF; }
#define RD_ACTIVE *rdPortClr = rdPinMask
#define RD_IDLE *rdPortSet = rdPinMask
/*
#define WR_ACTIVE *wrPortClr = wrPinMask
#define WR_IDLE *wrPortSet = wrPinMask
*/
#define WR_ACTIVE *wrPortSet = wrPinMask
#define WR_IDLE *wrPortClr = wrPinMask
#define CD_COMMAND *cdPortClr = cdPinMask
#define CD_DATA *cdPortSet = cdPinMask
#define CS_ACTIVE *csPortClr = csPinMask
#define CS_IDLE *csPortSet = csPinMask
#endif
#else
#error "Board type unsupported / not recognized"
#endif
#if defined(__AVR__)
// Stuff common to all Arduino AVR board types:
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
// Control signals are ACTIVE LOW (idle is HIGH)
// Command/Data: LOW = command, HIGH = data
// These are single-instruction operations and always inline
#define RD_ACTIVE RD_PORT &= ~RD_MASK
#define RD_IDLE RD_PORT |= RD_MASK
#define WR_ACTIVE WR_PORT &= ~WR_MASK
#define WR_IDLE WR_PORT |= WR_MASK
#define CD_COMMAND CD_PORT &= ~CD_MASK
#define CD_DATA CD_PORT |= CD_MASK
#define CS_ACTIVE CS_PORT &= ~CS_MASK
#define CS_IDLE CS_PORT |= CS_MASK
#else // Breakout board
// When using the TFT breakout board, control pins are configurable.
#define RD_ACTIVE *rdPort &= rdPinUnset
#define RD_IDLE *rdPort |= rdPinSet
#define WR_ACTIVE *wrPort &= wrPinUnset
#define WR_IDLE *wrPort |= wrPinSet
#define CD_COMMAND *cdPort &= cdPinUnset
#define CD_DATA *cdPort |= cdPinSet
#define CS_ACTIVE *csPort &= csPinUnset
#define CS_IDLE *csPort |= csPinSet
#endif
#endif
// Data write strobe, ~2 instructions and always inline
#define WR_STROBE { WR_ACTIVE; WR_IDLE; }
// These higher-level operations are usually functionalized,
// except on Mega where's there's gobs and gobs of program space.
// Set value of TFT register: 8-bit address, 8-bit value
#define writeRegister8inline(a, d) { \
CD_COMMAND; write8(a); CD_DATA; write8(d); }
// Set value of TFT register: 16-bit address, 16-bit value
// See notes at top about macro expansion, hence hi & lo temp vars
#define writeRegister16inline(a, d) { \
uint8_t hi, lo; \
hi = (a) >> 8; lo = (a); CD_COMMAND; write8(hi); write8(lo); \
hi = (d) >> 8; lo = (d); CD_DATA ; write8(hi); write8(lo); }
// Set value of 2 TFT registers: Two 8-bit addresses (hi & lo), 16-bit value
#define writeRegisterPairInline(aH, aL, d) { \
uint8_t hi = (d) >> 8, lo = (d); \
CD_COMMAND; write8(aH); CD_DATA; write8(hi); \
CD_COMMAND; write8(aL); CD_DATA; write8(lo); }
#endif // _pin_magic_
+172
View File
@@ -0,0 +1,172 @@
// Register names from Peter Barrett's Microtouch code
#define ILI932X_START_OSC 0x00
#define ILI932X_DRIV_OUT_CTRL 0x01
#define ILI932X_DRIV_WAV_CTRL 0x02
#define ILI932X_ENTRY_MOD 0x03
#define ILI932X_RESIZE_CTRL 0x04
#define ILI932X_DISP_CTRL1 0x07
#define ILI932X_DISP_CTRL2 0x08
#define ILI932X_DISP_CTRL3 0x09
#define ILI932X_DISP_CTRL4 0x0A
#define ILI932X_RGB_DISP_IF_CTRL1 0x0C
#define ILI932X_FRM_MARKER_POS 0x0D
#define ILI932X_RGB_DISP_IF_CTRL2 0x0F
#define ILI932X_POW_CTRL1 0x10
#define ILI932X_POW_CTRL2 0x11
#define ILI932X_POW_CTRL3 0x12
#define ILI932X_POW_CTRL4 0x13
#define ILI932X_GRAM_HOR_AD 0x20
#define ILI932X_GRAM_VER_AD 0x21
#define ILI932X_RW_GRAM 0x22
#define ILI932X_POW_CTRL7 0x29
#define ILI932X_FRM_RATE_COL_CTRL 0x2B
#define ILI932X_GAMMA_CTRL1 0x30
#define ILI932X_GAMMA_CTRL2 0x31
#define ILI932X_GAMMA_CTRL3 0x32
#define ILI932X_GAMMA_CTRL4 0x35
#define ILI932X_GAMMA_CTRL5 0x36
#define ILI932X_GAMMA_CTRL6 0x37
#define ILI932X_GAMMA_CTRL7 0x38
#define ILI932X_GAMMA_CTRL8 0x39
#define ILI932X_GAMMA_CTRL9 0x3C
#define ILI932X_GAMMA_CTRL10 0x3D
#define ILI932X_HOR_START_AD 0x50
#define ILI932X_HOR_END_AD 0x51
#define ILI932X_VER_START_AD 0x52
#define ILI932X_VER_END_AD 0x53
#define ILI932X_GATE_SCAN_CTRL1 0x60
#define ILI932X_GATE_SCAN_CTRL2 0x61
#define ILI932X_GATE_SCAN_CTRL3 0x6A
#define ILI932X_PART_IMG1_DISP_POS 0x80
#define ILI932X_PART_IMG1_START_AD 0x81
#define ILI932X_PART_IMG1_END_AD 0x82
#define ILI932X_PART_IMG2_DISP_POS 0x83
#define ILI932X_PART_IMG2_START_AD 0x84
#define ILI932X_PART_IMG2_END_AD 0x85
#define ILI932X_PANEL_IF_CTRL1 0x90
#define ILI932X_PANEL_IF_CTRL2 0x92
#define ILI932X_PANEL_IF_CTRL3 0x93
#define ILI932X_PANEL_IF_CTRL4 0x95
#define ILI932X_PANEL_IF_CTRL5 0x97
#define ILI932X_PANEL_IF_CTRL6 0x98
#define HX8347G_COLADDRSTART_HI 0x02
#define HX8347G_COLADDRSTART_LO 0x03
#define HX8347G_COLADDREND_HI 0x04
#define HX8347G_COLADDREND_LO 0x05
#define HX8347G_ROWADDRSTART_HI 0x06
#define HX8347G_ROWADDRSTART_LO 0x07
#define HX8347G_ROWADDREND_HI 0x08
#define HX8347G_ROWADDREND_LO 0x09
#define HX8347G_MEMACCESS 0x16
#define ILI9341_SOFTRESET 0x01
#define ILI9341_SLEEPIN 0x10
#define ILI9341_SLEEPOUT 0x11
#define ILI9341_NORMALDISP 0x13
#define ILI9341_INVERTOFF 0x20
#define ILI9341_INVERTON 0x21
#define ILI9341_GAMMASET 0x26
#define ILI9341_DISPLAYOFF 0x28
#define ILI9341_DISPLAYON 0x29
#define ILI9341_COLADDRSET 0x2A
#define ILI9341_PAGEADDRSET 0x2B
#define ILI9341_MEMORYWRITE 0x2C
#define ILI9341_PIXELFORMAT 0x3A
#define ILI9341_FRAMECONTROL 0xB1
#define ILI9341_DISPLAYFUNC 0xB6
#define ILI9341_ENTRYMODE 0xB7
#define ILI9341_POWERCONTROL1 0xC0
#define ILI9341_POWERCONTROL2 0xC1
#define ILI9341_VCOMCONTROL1 0xC5
#define ILI9341_VCOMCONTROL2 0xC7
#define ILI9341_MEMCONTROL 0x36
#define ILI9341_MADCTL 0x36
#define ILI9341_MADCTL_MY 0x80
#define ILI9341_MADCTL_MX 0x40
#define ILI9341_MADCTL_MV 0x20
#define ILI9341_MADCTL_ML 0x10
#define ILI9341_MADCTL_RGB 0x00
#define ILI9341_MADCTL_BGR 0x08
#define ILI9341_MADCTL_MH 0x04
#define HX8357_NOP 0x00
#define HX8357_SWRESET 0x01
#define HX8357_RDDID 0x04
#define HX8357_RDDST 0x09
#define HX8357B_RDPOWMODE 0x0A
#define HX8357B_RDMADCTL 0x0B
#define HX8357B_RDCOLMOD 0x0C
#define HX8357B_RDDIM 0x0D
#define HX8357B_RDDSDR 0x0F
#define HX8357_SLPIN 0x10
#define HX8357_SLPOUT 0x11
#define HX8357B_PTLON 0x12
#define HX8357B_NORON 0x13
#define HX8357_INVOFF 0x20
#define HX8357_INVON 0x21
#define HX8357_DISPOFF 0x28
#define HX8357_DISPON 0x29
#define HX8357_CASET 0x2A
#define HX8357_PASET 0x2B
#define HX8357_RAMWR 0x2C
#define HX8357_RAMRD 0x2E
#define HX8357B_PTLAR 0x30
#define HX8357_TEON 0x35
#define HX8357_TEARLINE 0x44
#define HX8357_MADCTL 0x36
#define HX8357_COLMOD 0x3A
#define HX8357_SETOSC 0xB0
#define HX8357_SETPWR1 0xB1
#define HX8357B_SETDISPLAY 0xB2
#define HX8357_SETRGB 0xB3
#define HX8357D_SETCOM 0xB6
#define HX8357B_SETDISPMODE 0xB4
#define HX8357D_SETCYC 0xB4
#define HX8357B_SETOTP 0xB7
#define HX8357D_SETC 0xB9
#define HX8357B_SET_PANEL_DRIVING 0xC0
#define HX8357D_SETSTBA 0xC0
#define HX8357B_SETDGC 0xC1
#define HX8357B_SETID 0xC3
#define HX8357B_SETDDB 0xC4
#define HX8357B_SETDISPLAYFRAME 0xC5
#define HX8357B_GAMMASET 0xC8
#define HX8357B_SETCABC 0xC9
#define HX8357_SETPANEL 0xCC
#define HX8357B_SETPOWER 0xD0
#define HX8357B_SETVCOM 0xD1
#define HX8357B_SETPWRNORMAL 0xD2
#define HX8357B_RDID1 0xDA
#define HX8357B_RDID2 0xDB
#define HX8357B_RDID3 0xDC
#define HX8357B_RDID4 0xDD
#define HX8357D_SETGAMMA 0xE0
#define HX8357B_SETGAMMA 0xC8
#define HX8357B_SETPANELRELATED 0xE9
#define HX8357B_MADCTL_MY 0x80
#define HX8357B_MADCTL_MX 0x40
#define HX8357B_MADCTL_MV 0x20
#define HX8357B_MADCTL_ML 0x10
#define HX8357B_MADCTL_RGB 0x00
#define HX8357B_MADCTL_BGR 0x08
#define HX8357B_MADCTL_MH 0x04