acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

TFT_graphicstest_PDQ.ino (22882B)

      1 /*
      2  Adapted from the Adafruit and Xark's PDQ graphicstest sketch.
      3 
      4  See end of file for original header text and MIT license info.
      5  
      6  This sketch uses the GLCD font only.
      7 
      8  Make sure all the display driver and pin connections are correct by
      9  editing the User_Setup.h file in the TFT_eSPI library folder.
     10 
     11  #########################################################################
     12  ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
     13  #########################################################################
     14  */
     15 
     16 #include "SPI.h"
     17 #include "TFT_eSPI.h"
     18 
     19 // Use hardware SPI
     20 TFT_eSPI tft = TFT_eSPI();
     21 
     22 unsigned long total = 0;
     23 unsigned long tn = 0;
     24 void setup() {
     25   Serial.begin(115200);
     26   while (!Serial);
     27   Serial.println(""); Serial.println("");
     28   Serial.println("Bodmer's TFT_eSPI library Test!"); 
     29  
     30   tft.init();
     31 }
     32 
     33 void loop(void)
     34 {
     35 
     36 	Serial.println(F("Benchmark                Time (microseconds)"));
     37 
     38 	uint32_t usecHaD = testHaD();
     39 	Serial.print(F("HaD pushColor            "));
     40 	Serial.println(usecHaD);
     41 	delay(100);
     42 
     43 	uint32_t usecFillScreen = testFillScreen();
     44 	Serial.print(F("Screen fill              "));
     45 	Serial.println(usecFillScreen);
     46 	delay(100);
     47 
     48 	uint32_t usecText = testText();
     49 	Serial.print(F("Text                     "));
     50 	Serial.println(usecText);
     51 	delay(100);
     52 
     53 	uint32_t usecPixels = testPixels();
     54 	Serial.print(F("Pixels                   "));
     55 	Serial.println(usecPixels);
     56 	delay(100);
     57 
     58 	uint32_t usecLines = testLines(TFT_BLUE);
     59 	Serial.print(F("Lines                    "));
     60 	Serial.println(usecLines);
     61 	delay(100);
     62 
     63 	uint32_t usecFastLines = testFastLines(TFT_RED, TFT_BLUE);
     64 	Serial.print(F("Horiz/Vert Lines         "));
     65 	Serial.println(usecFastLines);
     66 	delay(100);
     67 
     68 	uint32_t usecRects = testRects(TFT_GREEN);
     69 	Serial.print(F("Rectangles (outline)     "));
     70 	Serial.println(usecRects);
     71 	delay(100);
     72 
     73 	uint32_t usecFilledRects = testFilledRects(TFT_YELLOW, TFT_MAGENTA);
     74 	Serial.print(F("Rectangles (filled)      "));
     75 	Serial.println(usecFilledRects);
     76 	delay(100);
     77 
     78 	uint32_t usecFilledCircles = testFilledCircles(10, TFT_MAGENTA);
     79 	Serial.print(F("Circles (filled)         "));
     80 	Serial.println(usecFilledCircles);
     81 	delay(100);
     82 
     83 	uint32_t usecCircles = testCircles(10, TFT_WHITE);
     84 	Serial.print(F("Circles (outline)        "));
     85 	Serial.println(usecCircles);
     86 	delay(100);
     87 
     88 	uint32_t usecTriangles = testTriangles();
     89 	Serial.print(F("Triangles (outline)      "));
     90 	Serial.println(usecTriangles);
     91 	delay(100);
     92 
     93 	uint32_t usecFilledTrangles = testFilledTriangles();
     94 	Serial.print(F("Triangles (filled)       "));
     95 	Serial.println(usecFilledTrangles);
     96 	delay(100);
     97 
     98 	uint32_t usecRoundRects = testRoundRects();
     99 	Serial.print(F("Rounded rects (outline)  "));
    100 	Serial.println(usecRoundRects);
    101 	delay(100);
    102 
    103 	uint32_t usedFilledRoundRects = testFilledRoundRects();
    104 	Serial.print(F("Rounded rects (filled)   "));
    105 	Serial.println(usedFilledRoundRects);
    106 	delay(100);
    107 
    108 	Serial.println(F("Done!"));
    109 
    110 	uint16_t c = 4;
    111 	int8_t d = 1;
    112 	for (int32_t i = 0; i < tft.height(); i++)
    113 	{
    114 		tft.drawFastHLine(0, i, tft.width(), c);
    115 		c += d;
    116 		if (c <= 4 || c >= 11)
    117 			d = -d;
    118 	}
    119 	
    120 	tft.setCursor(0, 0);
    121 	tft.setTextColor(TFT_MAGENTA);
    122 	tft.setTextSize(2);
    123 
    124  	tft.println(F("   TFT_eSPI test"));
    125 
    126 	tft.setTextSize(1);
    127 	tft.setTextColor(TFT_WHITE);
    128 	tft.println(F(""));
    129 	tft.setTextSize(1);
    130 	tft.println(F(""));
    131 	tft.setTextColor(tft.color565(0x80, 0x80, 0x80));
    132 
    133 	tft.println(F(""));
    134 
    135 
    136 	tft.setTextColor(TFT_GREEN);
    137 	tft.println(F(" Benchmark               microseconds"));
    138 	tft.println(F(""));
    139 	tft.setTextColor(TFT_YELLOW);
    140 
    141 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    142 	tft.print(F("HaD pushColor      "));
    143 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    144 	printnice(usecHaD);
    145 
    146 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    147 	tft.print(F("Screen fill        "));
    148 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    149 	printnice(usecFillScreen);
    150 
    151 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    152 	tft.print(F("Text               "));
    153 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    154 	printnice(usecText);
    155 
    156 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    157 	tft.print(F("Pixels             "));
    158 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    159 	printnice(usecPixels);
    160 
    161 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    162 	tft.print(F("Lines              "));
    163 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    164 	printnice(usecLines);
    165 
    166 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    167 	tft.print(F("Horiz/Vert Lines   "));
    168 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    169 	printnice(usecFastLines);
    170 
    171 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    172 	tft.print(F("Rectangles         "));
    173 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    174 	printnice(usecRects);
    175 
    176 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    177 	tft.print(F("Rectangles-filled  "));
    178 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    179 	printnice(usecFilledRects);
    180 
    181 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    182 	tft.print(F("Circles            "));
    183 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    184 	printnice(usecCircles);
    185 
    186 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    187 	tft.print(F("Circles-filled     "));
    188 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    189 	printnice(usecFilledCircles);
    190 
    191 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    192 	tft.print(F("Triangles          "));
    193 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    194 	printnice(usecTriangles);
    195 
    196 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    197 	tft.print(F("Triangles-filled   "));
    198 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    199 	printnice(usecFilledTrangles);
    200 
    201 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    202 	tft.print(F("Rounded rects      "));
    203 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    204 	printnice(usecRoundRects);
    205 
    206 	tft.setTextColor(TFT_CYAN); tft.setTextSize(1);
    207 	tft.print(F("Rounded rects-fill "));
    208 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    209 	printnice(usedFilledRoundRects);
    210 
    211 	tft.setTextSize(1);
    212 	tft.println(F(""));
    213 	tft.setTextColor(TFT_GREEN); tft.setTextSize(2);
    214 	tft.print(F("Benchmark Complete!"));
    215 
    216 	delay(60 * 1000L);
    217 }
    218 
    219 void printnice(int32_t v)
    220 {
    221 	char	str[32] = { 0 };
    222 	sprintf(str, "%d", v);
    223 	for (char *p = (str+strlen(str))-3; p > str; p -= 3)
    224 	{
    225 		memmove(p+1, p, strlen(p)+1);
    226 		*p = ',';
    227 		
    228 	}
    229 	while (strlen(str) < 10)
    230 	{
    231 		memmove(str+1, str, strlen(str)+1);
    232 		*str = ' ';
    233 	}
    234 	tft.println(str);
    235 }
    236 
    237 static inline uint32_t micros_start() __attribute__ ((always_inline));
    238 static inline uint32_t micros_start()
    239 {
    240 	uint8_t oms = millis();
    241 	while ((uint8_t)millis() == oms)
    242 		;
    243 	return micros();
    244 }
    245 
    246 uint32_t testHaD()
    247 {
    248 	// pseudo-code for cheesy RLE
    249 	// start with color1
    250 	// while more input data remaining
    251 	// 	count =  0nnnnnnn = 1 byte or 1nnnnnnn nnnnnnnn 2 bytes (0 - 32767)
    252 	// 	repeat color count times
    253 	// 	toggle color1/color2
    254 	static const uint8_t HaD_240x320[] PROGMEM =
    255 	{
    256 		0xb9, 0x50, 0x0e, 0x80, 0x93, 0x0e, 0x41, 0x11, 0x80, 0x8d, 0x11, 0x42, 0x12, 0x80, 0x89, 0x12, 
    257 		0x45, 0x12, 0x80, 0x85, 0x12, 0x48, 0x12, 0x80, 0x83, 0x12, 0x4a, 0x13, 0x7f, 0x13, 0x4c, 0x13, 
    258 		0x7d, 0x13, 0x4e, 0x13, 0x7b, 0x13, 0x50, 0x13, 0x79, 0x13, 0x52, 0x13, 0x77, 0x13, 0x54, 0x13, 
    259 		0x75, 0x13, 0x57, 0x11, 0x75, 0x11, 0x5a, 0x11, 0x73, 0x11, 0x5c, 0x11, 0x71, 0x11, 0x5e, 0x10, 
    260 		0x71, 0x10, 0x60, 0x10, 0x6f, 0x10, 0x61, 0x10, 0x6f, 0x10, 0x60, 0x11, 0x6f, 0x11, 0x5e, 0x13, 
    261 		0x6d, 0x13, 0x5c, 0x14, 0x6d, 0x14, 0x5a, 0x15, 0x6d, 0x15, 0x58, 0x17, 0x6b, 0x17, 0x37, 0x01, 
    262 		0x1f, 0x17, 0x6b, 0x17, 0x1f, 0x01, 0x17, 0x02, 0x1d, 0x18, 0x6b, 0x18, 0x1d, 0x02, 0x17, 0x03, 
    263 		0x1b, 0x19, 0x6b, 0x19, 0x1b, 0x03, 0x17, 0x05, 0x18, 0x1a, 0x6b, 0x1a, 0x18, 0x05, 0x17, 0x06, 
    264 		0x16, 0x1b, 0x6b, 0x1b, 0x16, 0x06, 0x17, 0x07, 0x14, 0x1c, 0x6b, 0x1c, 0x14, 0x07, 0x17, 0x08, 
    265 		0x12, 0x1d, 0x6b, 0x1d, 0x12, 0x08, 0x17, 0x09, 0x10, 0x1e, 0x6b, 0x1e, 0x10, 0x09, 0x17, 0x0a, 
    266 		0x0e, 0x1f, 0x6b, 0x1f, 0x0e, 0x0a, 0x17, 0x0b, 0x0c, 0x20, 0x6b, 0x20, 0x0c, 0x0b, 0x17, 0x0c, 
    267 		0x0b, 0x21, 0x69, 0x21, 0x0b, 0x0c, 0x18, 0x0d, 0x08, 0x23, 0x67, 0x23, 0x08, 0x0d, 0x19, 0x0e, 
    268 		0x06, 0x26, 0x63, 0x26, 0x06, 0x0e, 0x19, 0x0f, 0x04, 0x28, 0x61, 0x28, 0x04, 0x0f, 0x19, 0x10, 
    269 		0x02, 0x2a, 0x5f, 0x2a, 0x02, 0x10, 0x1a, 0x3c, 0x5d, 0x3c, 0x1b, 0x3d, 0x5b, 0x3d, 0x1c, 0x3d, 
    270 		0x59, 0x3d, 0x1d, 0x3e, 0x57, 0x3e, 0x1e, 0x3e, 0x55, 0x3e, 0x1f, 0x40, 0x51, 0x40, 0x20, 0x40, 
    271 		0x4f, 0x40, 0x22, 0x40, 0x22, 0x09, 0x22, 0x40, 0x24, 0x40, 0x1a, 0x17, 0x1a, 0x40, 0x26, 0x40, 
    272 		0x16, 0x1d, 0x16, 0x40, 0x28, 0x40, 0x12, 0x23, 0x12, 0x40, 0x2a, 0x40, 0x0f, 0x27, 0x0f, 0x40, 
    273 		0x2c, 0x41, 0x0b, 0x2b, 0x0b, 0x41, 0x2f, 0x3f, 0x09, 0x2f, 0x09, 0x3f, 0x32, 0x3d, 0x08, 0x33, 
    274 		0x08, 0x3d, 0x35, 0x3a, 0x08, 0x35, 0x08, 0x3a, 0x3a, 0x36, 0x07, 0x39, 0x07, 0x36, 0x41, 0x09, 
    275 		0x05, 0x23, 0x07, 0x3b, 0x07, 0x23, 0x05, 0x09, 0x54, 0x21, 0x07, 0x3d, 0x07, 0x21, 0x64, 0x1f, 
    276 		0x06, 0x41, 0x06, 0x1f, 0x66, 0x1d, 0x06, 0x43, 0x06, 0x1d, 0x68, 0x1b, 0x06, 0x45, 0x06, 0x1b, 
    277 		0x6b, 0x18, 0x06, 0x47, 0x06, 0x18, 0x6e, 0x16, 0x06, 0x49, 0x06, 0x16, 0x70, 0x14, 0x06, 0x4b, 
    278 		0x06, 0x14, 0x72, 0x13, 0x06, 0x4b, 0x06, 0x13, 0x74, 0x11, 0x06, 0x4d, 0x06, 0x11, 0x76, 0x0f, 
    279 		0x06, 0x4f, 0x06, 0x0f, 0x78, 0x0e, 0x05, 0x51, 0x05, 0x0e, 0x7a, 0x0c, 0x06, 0x51, 0x06, 0x0c, 
    280 		0x7d, 0x09, 0x06, 0x53, 0x06, 0x09, 0x80, 0x80, 0x08, 0x05, 0x55, 0x05, 0x08, 0x80, 0x82, 0x06, 
    281 		0x05, 0x57, 0x05, 0x06, 0x80, 0x84, 0x05, 0x05, 0x57, 0x05, 0x05, 0x80, 0x86, 0x03, 0x05, 0x59, 
    282 		0x05, 0x03, 0x80, 0x88, 0x02, 0x05, 0x59, 0x05, 0x02, 0x80, 0x8f, 0x5b, 0x80, 0x95, 0x5b, 0x80, 
    283 		0x94, 0x5d, 0x80, 0x93, 0x5d, 0x80, 0x92, 0x5e, 0x80, 0x92, 0x5f, 0x80, 0x91, 0x5f, 0x80, 0x90, 
    284 		0x61, 0x80, 0x8f, 0x61, 0x80, 0x8f, 0x61, 0x80, 0x8e, 0x63, 0x80, 0x8d, 0x63, 0x80, 0x8d, 0x63, 
    285 		0x80, 0x8d, 0x63, 0x80, 0x8c, 0x19, 0x07, 0x25, 0x07, 0x19, 0x80, 0x8b, 0x16, 0x0d, 0x1f, 0x0d, 
    286 		0x16, 0x80, 0x8b, 0x14, 0x11, 0x1b, 0x11, 0x14, 0x80, 0x8b, 0x13, 0x13, 0x19, 0x13, 0x13, 0x80, 
    287 		0x8b, 0x12, 0x15, 0x17, 0x15, 0x12, 0x80, 0x8a, 0x12, 0x17, 0x15, 0x17, 0x12, 0x80, 0x89, 0x11, 
    288 		0x19, 0x13, 0x19, 0x11, 0x80, 0x89, 0x11, 0x19, 0x13, 0x19, 0x11, 0x80, 0x89, 0x10, 0x1b, 0x11, 
    289 		0x1b, 0x10, 0x80, 0x89, 0x0f, 0x1c, 0x11, 0x1c, 0x0f, 0x80, 0x89, 0x0f, 0x1c, 0x11, 0x1c, 0x0f, 
    290 		0x80, 0x89, 0x0f, 0x1c, 0x11, 0x1c, 0x0f, 0x80, 0x89, 0x0e, 0x1d, 0x11, 0x1d, 0x0e, 0x80, 0x89, 
    291 		0x0e, 0x1c, 0x13, 0x1c, 0x0e, 0x80, 0x89, 0x0e, 0x1b, 0x15, 0x1b, 0x0e, 0x80, 0x89, 0x0e, 0x1b, 
    292 		0x15, 0x1b, 0x0e, 0x80, 0x89, 0x0e, 0x1a, 0x17, 0x1a, 0x0e, 0x80, 0x89, 0x0e, 0x18, 0x1b, 0x18, 
    293 		0x0e, 0x80, 0x89, 0x0e, 0x16, 0x1f, 0x16, 0x0e, 0x80, 0x89, 0x0e, 0x14, 0x23, 0x14, 0x0e, 0x80, 
    294 		0x89, 0x0f, 0x11, 0x27, 0x11, 0x0f, 0x80, 0x89, 0x0f, 0x0e, 0x2d, 0x0e, 0x0f, 0x80, 0x89, 0x0f, 
    295 		0x0c, 0x31, 0x0c, 0x0f, 0x80, 0x89, 0x0f, 0x0b, 0x33, 0x0b, 0x0f, 0x80, 0x8a, 0x0f, 0x09, 0x35, 
    296 		0x09, 0x0f, 0x80, 0x8b, 0x10, 0x08, 0x35, 0x08, 0x10, 0x80, 0x8b, 0x10, 0x07, 0x37, 0x07, 0x10, 
    297 		0x80, 0x8b, 0x11, 0x06, 0x37, 0x06, 0x11, 0x80, 0x8b, 0x12, 0x05, 0x37, 0x05, 0x12, 0x80, 0x8c, 
    298 		0x13, 0x03, 0x1b, 0x01, 0x1b, 0x03, 0x13, 0x80, 0x8d, 0x30, 0x03, 0x30, 0x80, 0x8d, 0x30, 0x04, 
    299 		0x2f, 0x80, 0x8d, 0x2f, 0x05, 0x2f, 0x80, 0x8e, 0x2e, 0x06, 0x2d, 0x80, 0x8f, 0x2d, 0x07, 0x2d, 
    300 		0x80, 0x8f, 0x2d, 0x07, 0x2d, 0x80, 0x90, 0x2c, 0x08, 0x2b, 0x80, 0x91, 0x2b, 0x09, 0x2b, 0x80, 
    301 		0x8c, 0x01, 0x05, 0x2a, 0x09, 0x2a, 0x05, 0x01, 0x80, 0x85, 0x03, 0x05, 0x2a, 0x09, 0x2a, 0x05, 
    302 		0x03, 0x80, 0x82, 0x04, 0x05, 0x2a, 0x09, 0x2a, 0x04, 0x05, 0x80, 0x80, 0x06, 0x05, 0x29, 0x04, 
    303 		0x02, 0x03, 0x29, 0x05, 0x06, 0x7e, 0x07, 0x05, 0x29, 0x03, 0x03, 0x03, 0x29, 0x05, 0x07, 0x7c, 
    304 		0x09, 0x05, 0x28, 0x02, 0x05, 0x02, 0x28, 0x05, 0x09, 0x7a, 0x0a, 0x05, 0x28, 0x02, 0x05, 0x02, 
    305 		0x28, 0x05, 0x0a, 0x78, 0x0c, 0x05, 0x27, 0x02, 0x05, 0x02, 0x27, 0x05, 0x0c, 0x76, 0x0d, 0x06, 
    306 		0x26, 0x01, 0x07, 0x01, 0x26, 0x06, 0x0d, 0x73, 0x10, 0x05, 0x55, 0x05, 0x10, 0x70, 0x12, 0x05, 
    307 		0x53, 0x05, 0x12, 0x6e, 0x13, 0x06, 0x51, 0x06, 0x13, 0x6c, 0x15, 0x05, 0x51, 0x05, 0x15, 0x6a, 
    308 		0x16, 0x06, 0x4f, 0x06, 0x16, 0x68, 0x18, 0x06, 0x4d, 0x06, 0x18, 0x66, 0x1a, 0x06, 0x4b, 0x06, 
    309 		0x1a, 0x64, 0x1c, 0x06, 0x49, 0x06, 0x1c, 0x55, 0x07, 0x05, 0x1e, 0x06, 0x49, 0x06, 0x1e, 0x05, 
    310 		0x07, 0x42, 0x30, 0x06, 0x47, 0x06, 0x30, 0x3a, 0x34, 0x06, 0x45, 0x06, 0x34, 0x35, 0x37, 0x06, 
    311 		0x43, 0x06, 0x37, 0x32, 0x39, 0x07, 0x3f, 0x07, 0x39, 0x2f, 0x3c, 0x07, 0x3d, 0x07, 0x3c, 0x2c, 
    312 		0x3e, 0x07, 0x3b, 0x07, 0x3e, 0x2a, 0x40, 0x06, 0x3b, 0x06, 0x40, 0x28, 0x40, 0x06, 0x3c, 0x07, 
    313 		0x40, 0x26, 0x3f, 0x08, 0x3d, 0x08, 0x3f, 0x24, 0x3f, 0x09, 0x3d, 0x09, 0x3f, 0x22, 0x3f, 0x0a, 
    314 		0x14, 0x01, 0x13, 0x02, 0x13, 0x0a, 0x3f, 0x20, 0x3f, 0x0b, 0x14, 0x01, 0x13, 0x02, 0x13, 0x0b, 
    315 		0x3f, 0x1f, 0x3e, 0x0c, 0x14, 0x01, 0x13, 0x02, 0x13, 0x0c, 0x3e, 0x1e, 0x3e, 0x0d, 0x13, 0x02, 
    316 		0x13, 0x02, 0x13, 0x0d, 0x3e, 0x1d, 0x3d, 0x0e, 0x13, 0x02, 0x13, 0x02, 0x13, 0x0e, 0x3d, 0x1c, 
    317 		0x3c, 0x11, 0x11, 0x04, 0x11, 0x04, 0x11, 0x11, 0x3c, 0x1b, 0x10, 0x01, 0x2a, 0x12, 0x11, 0x04, 
    318 		0x11, 0x04, 0x11, 0x12, 0x2a, 0x01, 0x10, 0x1a, 0x0f, 0x04, 0x28, 0x14, 0x0f, 0x06, 0x0f, 0x06, 
    319 		0x0f, 0x14, 0x28, 0x04, 0x0f, 0x19, 0x0e, 0x06, 0x26, 0x16, 0x0d, 0x08, 0x0d, 0x08, 0x0d, 0x16, 
    320 		0x26, 0x06, 0x0e, 0x19, 0x0d, 0x07, 0x25, 0x18, 0x0b, 0x0a, 0x0b, 0x0a, 0x0b, 0x18, 0x25, 0x07, 
    321 		0x0d, 0x19, 0x0c, 0x09, 0x23, 0x1c, 0x06, 0x0f, 0x05, 0x10, 0x05, 0x1c, 0x23, 0x09, 0x0c, 0x18, 
    322 		0x0c, 0x0b, 0x21, 0x69, 0x21, 0x0b, 0x0c, 0x17, 0x0b, 0x0d, 0x1f, 0x6b, 0x1f, 0x0d, 0x0b, 0x17, 
    323 		0x0a, 0x0f, 0x1e, 0x6b, 0x1e, 0x0f, 0x0a, 0x17, 0x09, 0x11, 0x1d, 0x6b, 0x1d, 0x11, 0x09, 0x17, 
    324 		0x07, 0x14, 0x1c, 0x6b, 0x1c, 0x14, 0x07, 0x17, 0x06, 0x16, 0x1b, 0x6b, 0x1b, 0x16, 0x06, 0x17, 
    325 		0x05, 0x18, 0x1a, 0x6b, 0x1a, 0x18, 0x05, 0x17, 0x04, 0x1a, 0x19, 0x6b, 0x19, 0x1a, 0x04, 0x17, 
    326 		0x03, 0x1b, 0x19, 0x6b, 0x19, 0x1b, 0x03, 0x17, 0x02, 0x1d, 0x18, 0x6b, 0x18, 0x1d, 0x02, 0x37, 
    327 		0x17, 0x6b, 0x17, 0x58, 0x16, 0x6b, 0x16, 0x5a, 0x14, 0x6d, 0x14, 0x5c, 0x13, 0x6d, 0x13, 0x5e, 
    328 		0x12, 0x6d, 0x12, 0x60, 0x10, 0x6f, 0x10, 0x61, 0x10, 0x6f, 0x10, 0x60, 0x11, 0x6f, 0x11, 0x5e, 
    329 		0x11, 0x71, 0x11, 0x5c, 0x12, 0x71, 0x12, 0x5a, 0x12, 0x73, 0x12, 0x58, 0x12, 0x75, 0x12, 0x56, 
    330 		0x13, 0x75, 0x13, 0x54, 0x13, 0x77, 0x13, 0x51, 0x14, 0x79, 0x14, 0x4e, 0x14, 0x7b, 0x14, 0x4c, 
    331 		0x14, 0x7d, 0x14, 0x4a, 0x14, 0x7f, 0x14, 0x48, 0x13, 0x80, 0x83, 0x13, 0x46, 0x13, 0x80, 0x85, 
    332 		0x13, 0x44, 0x12, 0x80, 0x89, 0x12, 0x42, 0x11, 0x80, 0x8d, 0x11, 0x40, 0x0f, 0x80, 0x93, 0x0f, 
    333 		0x45, 0x04, 0x80, 0x9d, 0x04, 0xb9, 0x56, 
    334 	};
    335 	
    336 	tft.fillScreen(TFT_BLACK);
    337 
    338 	uint32_t start = micros_start();
    339 
    340 	for (int i = 0; i < 0x10; i++)
    341 	{
    342 		tft.setAddrWindow(0, 0, 240, 320);
    343 
    344 		uint16_t cnt = 0;
    345 		uint16_t color = tft.color565((i << 4) | i, (i << 4) | i, (i << 4) | i);
    346 		uint16_t curcolor = 0;
    347 
    348 		const uint8_t *cmp = &HaD_240x320[0];
    349 
    350 		tft.startWrite();
    351 		while (cmp < &HaD_240x320[sizeof(HaD_240x320)])
    352 		{
    353 			cnt = pgm_read_byte(cmp++);
    354 			if (cnt & 0x80) cnt = ((cnt & 0x7f) << 8) | pgm_read_byte(cmp++);
    355 			tft.pushColor(curcolor, cnt);	// PDQ_GFX has count
    356 			curcolor ^= color;
    357 		}
    358 		tft.endWrite();
    359 	}
    360 
    361 	uint32_t t = micros() - start;
    362 
    363 	tft.setTextColor(TFT_YELLOW);
    364 	tft.setTextSize(2);
    365 	tft.setCursor(8, 285);
    366 	tft.print(F("http://hackaday.io/"));
    367 	tft.setCursor(96, 302);
    368 	tft.print(F("Xark"));
    369 
    370 	delay(3 * 1000L);
    371 	
    372 	return t;
    373 }
    374 
    375 uint32_t testFillScreen()
    376 {
    377 	uint32_t start = micros_start();
    378     // Shortened this tedious test!
    379 		tft.fillScreen(TFT_WHITE);
    380 		tft.fillScreen(TFT_RED);
    381 		tft.fillScreen(TFT_GREEN);
    382 		tft.fillScreen(TFT_BLUE);
    383 		tft.fillScreen(TFT_BLACK);
    384 
    385 	return (micros() - start)/5;
    386 }
    387 
    388 uint32_t testText()
    389 {
    390 	tft.fillScreen(TFT_BLACK);
    391 	uint32_t start = micros_start();
    392 	tft.setCursor(0, 0);
    393 	tft.setTextColor(TFT_WHITE,TFT_BLACK);	tft.setTextSize(1);
    394 	tft.println(F("Hello World!"));
    395 	tft.setTextSize(2);
    396 	tft.setTextColor(tft.color565(0xff, 0x00, 0x00));
    397 	tft.print(F("RED "));
    398 	tft.setTextColor(tft.color565(0x00, 0xff, 0x00));
    399 	tft.print(F("GREEN "));
    400 	tft.setTextColor(tft.color565(0x00, 0x00, 0xff));
    401 	tft.println(F("BLUE"));
    402 	tft.setTextColor(TFT_YELLOW); tft.setTextSize(2);
    403 	tft.println(1234.56);
    404 	tft.setTextColor(TFT_RED);		tft.setTextSize(3);
    405 	tft.println(0xDEADBEEF, HEX);
    406 	tft.println();
    407 	tft.setTextColor(TFT_GREEN);
    408 	tft.setTextSize(5);
    409 	tft.println(F("Groop"));
    410 	tft.setTextSize(2);
    411 	tft.println(F("I implore thee,"));
    412   tft.setTextColor(TFT_GREEN);
    413 	tft.setTextSize(1);
    414 	tft.println(F("my foonting turlingdromes."));
    415 	tft.println(F("And hooptiously drangle me"));
    416 	tft.println(F("with crinkly bindlewurdles,"));
    417 	tft.println(F("Or I will rend thee"));
    418 	tft.println(F("in the gobberwarts"));
    419 	tft.println(F("with my blurglecruncheon,"));
    420 	tft.println(F("see if I don't!"));
    421 	tft.println(F(""));
    422 	tft.println(F(""));
    423 	tft.setTextColor(TFT_MAGENTA);
    424 	tft.setTextSize(6);
    425 	tft.println(F("Woot!"));
    426 	uint32_t t = micros() - start;
    427 	delay(1000);
    428 	return t;
    429 }
    430 
    431 uint32_t testPixels()
    432 {
    433 	int32_t	w = tft.width();
    434 	int32_t	h = tft.height();
    435 
    436 	uint32_t start = micros_start();
    437 	tft.startWrite();
    438 	for (uint16_t y = 0; y < h; y++)
    439 	{
    440 		for (uint16_t x = 0; x < w; x++)
    441 		{
    442 			tft.drawPixel(x, y, tft.color565(x<<3, y<<3, x*y));
    443 		}
    444 	}
    445 	tft.endWrite();
    446 	return micros() - start;
    447 }
    448 
    449 
    450 uint32_t testLines(uint16_t color)
    451 {
    452 	uint32_t start, t;
    453 	int32_t	x1, y1, x2, y2;
    454 	int32_t	w = tft.width();
    455 	int32_t	h = tft.height();
    456 
    457 	tft.fillScreen(TFT_BLACK);
    458 
    459 	x1 = y1 = 0;
    460 	y2 = h - 1;
    461 
    462 	start = micros_start();
    463 
    464 	for (x2 = 0; x2 < w; x2 += 6)
    465 	{
    466 		tft.drawLine(x1, y1, x2, y2, color);
    467 	}
    468 
    469 	x2 = w - 1;
    470 
    471 	for (y2 = 0; y2 < h; y2 += 6)
    472 	{
    473 		tft.drawLine(x1, y1, x2, y2, color);
    474 	}
    475 
    476 	t = micros() - start; // fillScreen doesn't count against timing
    477 
    478 	tft.fillScreen(TFT_BLACK);
    479 
    480 	x1 = w - 1;
    481 	y1 = 0;
    482 	y2 = h - 1;
    483 
    484 	start = micros_start();
    485 
    486 	for (x2 = 0; x2 < w; x2 += 6)
    487 	{
    488 		tft.drawLine(x1, y1, x2, y2, color);
    489 	}
    490 
    491 	x2 = 0;
    492 	for (y2 = 0; y2 < h; y2 += 6)
    493 	{
    494 		tft.drawLine(x1, y1, x2, y2, color);
    495 	}
    496 
    497 	t += micros() - start;
    498 
    499 	tft.fillScreen(TFT_BLACK);
    500 
    501 	x1 = 0;
    502 	y1 = h - 1;
    503 	y2 = 0;
    504 
    505 	start = micros_start();
    506 
    507 	for (x2 = 0; x2 < w; x2 += 6)
    508 	{
    509 		tft.drawLine(x1, y1, x2, y2, color);
    510 	}
    511 	x2 = w - 1;
    512 	for (y2 = 0; y2 < h; y2 += 6)
    513 	{
    514 		tft.drawLine(x1, y1, x2, y2, color);
    515 	}
    516 	t += micros() - start;
    517 
    518 	tft.fillScreen(TFT_BLACK);
    519 
    520 	x1 = w - 1;
    521 	y1 = h - 1;
    522 	y2 = 0;
    523 
    524 	start = micros_start();
    525 
    526 	for (x2 = 0; x2 < w; x2 += 6)
    527 	{
    528 		tft.drawLine(x1, y1, x2, y2, color);
    529 	}
    530 
    531 	x2 = 0;
    532 	for (y2 = 0; y2 < h; y2 += 6)
    533 	{
    534 		tft.drawLine(x1, y1, x2, y2, color);
    535 	}
    536 
    537 	t += micros() - start;
    538 
    539 	return t;
    540 }
    541 
    542 uint32_t testFastLines(uint16_t color1, uint16_t color2)
    543 {
    544 	uint32_t start;
    545 	int32_t x, y;
    546 	int32_t w = tft.width();
    547 	int32_t h = tft.height();
    548 
    549 	tft.fillScreen(TFT_BLACK);
    550 
    551 	start = micros_start();
    552 
    553 	for (y = 0; y < h; y += 5)
    554 		tft.drawFastHLine(0, y, w, color1);
    555 	for (x = 0; x < w; x += 5)
    556 		tft.drawFastVLine(x, 0, h, color2);
    557 
    558 	return micros() - start;
    559 }
    560 
    561 uint32_t testRects(uint16_t color)
    562 {
    563 	uint32_t start;
    564 	int32_t n, i, i2;
    565 	int32_t cx = tft.width() / 2;
    566 	int32_t cy = tft.height() / 2;
    567 
    568 	tft.fillScreen(TFT_BLACK);
    569 	n = min(tft.width(), tft.height());
    570 	start = micros_start();
    571 	for (i = 2; i < n; i += 6)
    572 	{
    573 		i2 = i / 2;
    574 		tft.drawRect(cx-i2, cy-i2, i, i, color);
    575 	}
    576 
    577 	return micros() - start;
    578 }
    579 
    580 uint32_t testFilledRects(uint16_t color1, uint16_t color2)
    581 {
    582 	uint32_t start, t = 0;
    583 	int32_t n, i, i2;
    584 	int32_t cx = tft.width() / 2 - 1;
    585 	int32_t cy = tft.height() / 2 - 1;
    586 
    587 	tft.fillScreen(TFT_BLACK);
    588 	n = min(tft.width(), tft.height());
    589 	for (i = n; i > 0; i -= 6)
    590 	{
    591 		i2 = i / 2;
    592 
    593 		start = micros_start();
    594 
    595 		tft.fillRect(cx-i2, cy-i2, i, i, color1);
    596 
    597 		t += micros() - start;
    598 
    599 		// Outlines are not included in timing results
    600 		tft.drawRect(cx-i2, cy-i2, i, i, color2);
    601 	}
    602 
    603 	return t;
    604 }
    605 
    606 uint32_t testFilledCircles(uint8_t radius, uint16_t color)
    607 {
    608 	uint32_t start;
    609 	int32_t x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
    610 
    611 	tft.fillScreen(TFT_BLACK);
    612 
    613 	start = micros_start();
    614 
    615 	for (x = radius; x < w; x += r2)
    616 	{
    617 		for (y = radius; y < h; y += r2)
    618 		{
    619 			tft.fillCircle(x, y, radius, color);
    620 		}
    621 	}
    622 
    623 	return micros() - start;
    624 }
    625 
    626 uint32_t testCircles(uint8_t radius, uint16_t color)
    627 {
    628 	uint32_t start;
    629 	int32_t x, y, r2 = radius * 2;
    630 	int32_t w = tft.width() + radius;
    631 	int32_t h = tft.height() + radius;
    632 
    633 	// Screen is not cleared for this one -- this is
    634 	// intentional and does not affect the reported time.
    635 	start = micros_start();
    636 
    637 	for (x = 0; x < w; x += r2)
    638 	{
    639 		for (y = 0; y < h; y += r2)
    640 		{
    641 			tft.drawCircle(x, y, radius, color);
    642 		}
    643 	}
    644 
    645 	return micros() - start;
    646 }
    647 
    648 uint32_t testTriangles()
    649 {
    650 	uint32_t start;
    651 	int32_t n, i;
    652 	int32_t cx = tft.width()/ 2 - 1;
    653 	int32_t cy = tft.height() / 2 - 1;
    654 
    655 	tft.fillScreen(TFT_BLACK);
    656 	n = min(cx, cy);
    657 
    658 	start = micros_start();
    659 
    660 	for (i = 0; i < n; i += 5)
    661 	{
    662 		tft.drawTriangle(
    663 			cx		, cy - i, // peak
    664 			cx - i, cy + i, // bottom left
    665 			cx + i, cy + i, // bottom right
    666 			tft.color565(0, 0, i));
    667 	}
    668 
    669 	return micros() - start;
    670 }
    671 
    672 uint32_t testFilledTriangles()
    673 {
    674 	uint32_t start, t = 0;
    675 	int32_t i;
    676 	int32_t cx = tft.width() / 2 - 1;
    677 	int32_t cy = tft.height() / 2 - 1;
    678 
    679 	tft.fillScreen(TFT_BLACK);
    680 
    681 	start = micros_start();
    682 
    683 	for (i = min(cx,cy); i > 10; i -= 5) {
    684 		start = micros_start();
    685 		tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
    686 			tft.color565(0, i, i));
    687 		t += micros() - start;
    688 		tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
    689 			tft.color565(i, i, 0));
    690 	}
    691 
    692 	return t;
    693 }
    694 
    695 uint32_t testRoundRects()
    696  {
    697 	uint32_t start;
    698 	int32_t w, i, i2;
    699 	int32_t cx = tft.width() / 2 - 1;
    700 	int32_t cy = tft.height() / 2 - 1;
    701 
    702 	tft.fillScreen(TFT_BLACK);
    703 	
    704 	w = min(tft.width(), tft.height());
    705 	
    706 	start = micros_start();
    707 
    708 	for (i = 0; i < w; i += 6)
    709 	{
    710 		i2 = i / 2;
    711 		tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
    712 	}
    713 
    714 	return micros() - start;
    715 }
    716 
    717 uint32_t testFilledRoundRects()
    718 {
    719 	uint32_t start;
    720 	int32_t i, i2;
    721 	int32_t cx = tft.width() / 2 - 1;
    722 	int32_t cy = tft.height() / 2 - 1;
    723 
    724 	tft.fillScreen(TFT_BLACK);
    725 
    726 	start = micros_start();
    727 
    728 	for (i = min(tft.width(), tft.height()); i > 20; i -= 6)
    729 	{
    730 		i2 = i / 2;
    731 		tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
    732 	}
    733 
    734 	return micros() - start;
    735 }
    736 
    737 /***************************************************
    738   Original sketch text:
    739 
    740   This is an example sketch for the Adafruit 2.2" SPI display.
    741   This library works with the Adafruit 2.2" TFT Breakout w/SD card
    742   ----> http://www.adafruit.com/products/1480
    743  
    744   Check out the links above for our tutorials and wiring diagrams
    745   These displays use SPI to communicate, 4 or 5 pins are required to
    746   interface (RST is optional)
    747   Adafruit invests time and resources providing this open source code,
    748   please support Adafruit and open-source hardware by purchasing
    749   products from Adafruit!
    750 
    751   Written by Limor Fried/Ladyada for Adafruit Industries.
    752   MIT license, all text above must be included in any redistribution
    753  ****************************************************/
    754