commit f871cd690cdedb57c95725da932742784d7fd4b1 Author: Eric Date: Thu Jul 4 01:17:27 2019 -0700 First Commit diff --git a/Esp32_jpeg/fileTest/fileTest.ino b/Esp32_jpeg/fileTest/fileTest.ino new file mode 100644 index 0000000..4ffa8cc --- /dev/null +++ b/Esp32_jpeg/fileTest/fileTest.ino @@ -0,0 +1,33 @@ +#include "SPIFFS.h" + +void setup(void) { + Serial.begin(115200); + Serial.println("File Test!"); + + if (!SPIFFS.begin()) { + Serial.println("SPIFFS initialisation failed!"); + while (1) yield(); // Stay here twiddling thumbs waiting + } + Serial.println("\r\nInitialisation done."); + Serial.println("\n----DIR: /:"); + listDir("/"); + +} + + +void loop(void) { + +} + + +void listDir(char * dir){ + + File root = SPIFFS.open(dir); + File file = root.openNextFile(); + while(file){ + + Serial.print("FILE: "); + Serial.println(file.name()); + file = root.openNextFile(); + } +} diff --git a/Esp32_jpeg/final/final.ino b/Esp32_jpeg/final/final.ino new file mode 100644 index 0000000..2bd87f6 --- /dev/null +++ b/Esp32_jpeg/final/final.ino @@ -0,0 +1,245 @@ +#include "SPIFFS.h" + +// JPEG decoder library +#include +#include +#include "Adafruit_GFX.h" +#include "Adafruit_ILI9341.h" + +// For the Adafruit shield, these are the default. +#define TFT_DC 17 +#define TFT_CS 5 +#define TFT_RST 4 + +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); + +boolean SPIFFSInited = false; +int imageIndex = 0; + +void setup(void) { + + long unsigned debug_start = millis (); + while (!Serial && ((millis () - debug_start) <= 5000)) ; + + tft.begin(); + tft.setRotation(3); + tft.fillScreen(ILI9341_RED); + + Serial.println("INIT!"); + + if (!SPIFFS.begin()) { + Serial.println("SPIFFS initialisation failed!"); + while (1) yield(); // Stay here twiddling thumbs waiting + } + SPIFFSInited = true; + +} + +void loop(){ + if(SPIFFSInited){ + + if(imageIndex > 45){ + imageIndex = 0; + } + + String fileIndex = "/0"; + if(imageIndex < 10){ + fileIndex += "0" + String(imageIndex); + }else{ + fileIndex += "" + String(imageIndex); + } + + fileIndex += ".jpg"; + Serial.println("fileIndex : " + fileIndex); + drawFSJpeg(fileIndex.c_str(), 0, 0); + + imageIndex++; + } +} + + +/*==================================================================================== + This sketch contains support functions to render the Jpeg images. + + Created by Bodmer 15th Jan 2017 + ==================================================================================*/ + +// Return the minimum of two values a and b +#define minimum(a,b) (((a) < (b)) ? (a) : (b)) + +//==================================================================================== +// This function opens the Filing System Jpeg image file and primes the decoder +//==================================================================================== +void drawFSJpeg(const char *filename, int xpos, int ypos) { + + Serial.println("====================================="); + Serial.print("Drawing file: "); Serial.println(filename); + Serial.println("====================================="); + + // Open the file (the Jpeg decoder library will close it) + fs::File jpgFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS + // File jpgFile = SD.open( filename, FILE_READ); // or, file handle reference for SD library + + if ( !jpgFile ) { + Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!"); + return; + } + + // To initialise the decoder and provide the file, we can use one of the three following methods: + //boolean decoded = JpegDec.decodeFsFile(jpgFile); // We can pass the SPIFFS file handle to the decoder, + //boolean decoded = JpegDec.decodeSdFile(jpgFile); // or we can pass the SD file handle to the decoder, + boolean decoded = JpegDec.decodeFsFile(filename); // or we can pass the filename (leading / distinguishes SPIFFS files) + // The filename can be a String or character array + if (decoded) { + // print information about the image to the serial port + jpegInfo(); + + // render the image onto the screen at given coordinates + jpegRender(xpos, ypos); + } + else { + Serial.println("Jpeg file format not supported!"); + } +} + +//==================================================================================== +// Decode and paint onto the TFT screen +//==================================================================================== +void jpegRender(int xpos, int ypos) { + + // retrieve infomration about the image + uint16_t *pImg; + uint16_t mcu_w = JpegDec.MCUWidth; + uint16_t mcu_h = JpegDec.MCUHeight; + uint32_t max_x = JpegDec.width; + uint32_t max_y = JpegDec.height; + + // Jpeg images are draw as a set of image block (tiles) called Minimum Coding Units (MCUs) + // Typically these MCUs are 16x16 pixel blocks + // Determine the width and height of the right and bottom edge image blocks + uint32_t min_w = minimum(mcu_w, max_x % mcu_w); + uint32_t min_h = minimum(mcu_h, max_y % mcu_h); + + // save the current image block size + uint32_t win_w = mcu_w; + uint32_t win_h = mcu_h; + + // record the current time so we can measure how long it takes to draw an image + uint32_t drawTime = millis(); + + // save the coordinate of the right and bottom edges to assist image cropping + // to the screen size + max_x += xpos; + max_y += ypos; + + // read each MCU block until there are no more + while ( JpegDec.read()) { + + // save a pointer to the image block + pImg = JpegDec.pImage; + + // calculate where the image block should be drawn on the screen + int mcu_x = JpegDec.MCUx * mcu_w + xpos; + int mcu_y = JpegDec.MCUy * mcu_h + ypos; + + // check if the image block size needs to be changed for the right edge + if (mcu_x + mcu_w <= max_x) win_w = mcu_w; + else win_w = min_w; + + // check if the image block size needs to be changed for the bottom edge + if (mcu_y + mcu_h <= max_y) win_h = mcu_h; + else win_h = min_h; + + // copy pixels into a contiguous block + if (win_w != mcu_w) + { + for (int h = 1; h < win_h-1; h++) + { + memcpy(pImg + h * win_w, pImg + (h + 1) * mcu_w, win_w << 1); + } + } + + + // draw image MCU block only if it will fit on the screen + if ( ( mcu_x + win_w) <= tft.width() && ( mcu_y + win_h) <= tft.height()) + { + tft.drawRGBBitmap(mcu_x, mcu_y, pImg, win_w, win_h); + } + + // Stop drawing blocks if the bottom of the screen has been reached, + // the abort function will close the file + else if ( ( mcu_y + win_h) >= tft.height()) JpegDec.abort(); + + } + + // calculate how long it took to draw the image + drawTime = millis() - drawTime; + + // print the results to the serial port + Serial.print ("Total render time was : "); Serial.print(drawTime); Serial.println(" ms"); + Serial.println("====================================="); + +} + +//==================================================================================== +// Send time taken to Serial port +//==================================================================================== +void jpegInfo() { + Serial.println(F("===============")); + Serial.println(F("JPEG image info")); + Serial.println(F("===============")); + Serial.print(F( "Width :")); Serial.println(JpegDec.width); + Serial.print(F( "Height :")); Serial.println(JpegDec.height); + Serial.print(F( "Components :")); Serial.println(JpegDec.comps); + Serial.print(F( "MCU / row :")); Serial.println(JpegDec.MCUSPerRow); + Serial.print(F( "MCU / col :")); Serial.println(JpegDec.MCUSPerCol); + Serial.print(F( "Scan type :")); Serial.println(JpegDec.scanType); + Serial.print(F( "MCU width :")); Serial.println(JpegDec.MCUWidth); + Serial.print(F( "MCU height :")); Serial.println(JpegDec.MCUHeight); + Serial.println(F("===============")); +} + +//==================================================================================== +// Open a Jpeg file and dump it to the Serial port as a C array +//==================================================================================== +void createArray(const char *filename) { + + fs::File jpgFile; // File handle reference for SPIFFS + // File jpgFile; // File handle reference For SD library + + if ( !( jpgFile = SPIFFS.open( filename, "r"))) { + Serial.println(F("JPEG file not found")); + return; + } + + uint8_t data; + byte line_len = 0; + Serial.println("// Generated by a JPEGDecoder library example sketch:"); + Serial.println("// https://github.com/Bodmer/JPEGDecoder"); + Serial.println(""); + Serial.println("#if defined(__AVR__)"); + Serial.println(" #include "); + Serial.println("#endif"); + Serial.println(""); + Serial.print("const uint8_t "); + while (*filename != '.') Serial.print(*filename++); + Serial.println("[] PROGMEM = {"); // PROGMEM added for AVR processors, it is ignored by Due + + while ( jpgFile.available()) { + + data = jpgFile.read(); + Serial.print("0x"); if (abs(data) < 16) Serial.print("0"); + Serial.print(data, HEX); Serial.print(",");// Add value and comma + line_len++; + if ( line_len >= 32) { + line_len = 0; + Serial.println(); + } + + } + + Serial.println("};\r\n"); + // jpgFile.seek( 0, SeekEnd); + jpgFile.close(); +} +//==================================================================================== diff --git a/Esp32_jpeg/test/data/00.jpg b/Esp32_jpeg/test/data/00.jpg new file mode 100644 index 0000000..83b5010 Binary files /dev/null and b/Esp32_jpeg/test/data/00.jpg differ diff --git a/Esp32_jpeg/test/data/01.jpg b/Esp32_jpeg/test/data/01.jpg new file mode 100644 index 0000000..aada854 Binary files /dev/null and b/Esp32_jpeg/test/data/01.jpg differ diff --git a/Esp32_jpeg/test/data/010.jpg b/Esp32_jpeg/test/data/010.jpg new file mode 100644 index 0000000..5b8476b Binary files /dev/null and b/Esp32_jpeg/test/data/010.jpg differ diff --git a/Esp32_jpeg/test/data/011.jpg b/Esp32_jpeg/test/data/011.jpg new file mode 100644 index 0000000..30b622d Binary files /dev/null and b/Esp32_jpeg/test/data/011.jpg differ diff --git a/Esp32_jpeg/test/data/012.jpg b/Esp32_jpeg/test/data/012.jpg new file mode 100644 index 0000000..a59074b Binary files /dev/null and b/Esp32_jpeg/test/data/012.jpg differ diff --git a/Esp32_jpeg/test/data/013.jpg b/Esp32_jpeg/test/data/013.jpg new file mode 100644 index 0000000..c0edc22 Binary files /dev/null and b/Esp32_jpeg/test/data/013.jpg differ diff --git a/Esp32_jpeg/test/data/014.jpg b/Esp32_jpeg/test/data/014.jpg new file mode 100644 index 0000000..fb68c61 Binary files /dev/null and b/Esp32_jpeg/test/data/014.jpg differ diff --git a/Esp32_jpeg/test/data/015.jpg b/Esp32_jpeg/test/data/015.jpg new file mode 100644 index 0000000..4fdf1a4 Binary files /dev/null and b/Esp32_jpeg/test/data/015.jpg differ diff --git a/Esp32_jpeg/test/data/016.jpg b/Esp32_jpeg/test/data/016.jpg new file mode 100644 index 0000000..3976335 Binary files /dev/null and b/Esp32_jpeg/test/data/016.jpg differ diff --git a/Esp32_jpeg/test/data/017.jpg b/Esp32_jpeg/test/data/017.jpg new file mode 100644 index 0000000..74863a9 Binary files /dev/null and b/Esp32_jpeg/test/data/017.jpg differ diff --git a/Esp32_jpeg/test/data/018.jpg b/Esp32_jpeg/test/data/018.jpg new file mode 100644 index 0000000..9796a63 Binary files /dev/null and b/Esp32_jpeg/test/data/018.jpg differ diff --git a/Esp32_jpeg/test/data/019.jpg b/Esp32_jpeg/test/data/019.jpg new file mode 100644 index 0000000..bcfe146 Binary files /dev/null and b/Esp32_jpeg/test/data/019.jpg differ diff --git a/Esp32_jpeg/test/data/02.jpg b/Esp32_jpeg/test/data/02.jpg new file mode 100644 index 0000000..f91007b Binary files /dev/null and b/Esp32_jpeg/test/data/02.jpg differ diff --git a/Esp32_jpeg/test/data/020.jpg b/Esp32_jpeg/test/data/020.jpg new file mode 100644 index 0000000..528ef68 Binary files /dev/null and b/Esp32_jpeg/test/data/020.jpg differ diff --git a/Esp32_jpeg/test/data/021.jpg b/Esp32_jpeg/test/data/021.jpg new file mode 100644 index 0000000..fa1e4df Binary files /dev/null and b/Esp32_jpeg/test/data/021.jpg differ diff --git a/Esp32_jpeg/test/data/022.jpg b/Esp32_jpeg/test/data/022.jpg new file mode 100644 index 0000000..216777d Binary files /dev/null and b/Esp32_jpeg/test/data/022.jpg differ diff --git a/Esp32_jpeg/test/data/023.jpg b/Esp32_jpeg/test/data/023.jpg new file mode 100644 index 0000000..a9eddde Binary files /dev/null and b/Esp32_jpeg/test/data/023.jpg differ diff --git a/Esp32_jpeg/test/data/024.jpg b/Esp32_jpeg/test/data/024.jpg new file mode 100644 index 0000000..290e505 Binary files /dev/null and b/Esp32_jpeg/test/data/024.jpg differ diff --git a/Esp32_jpeg/test/data/025.jpg b/Esp32_jpeg/test/data/025.jpg new file mode 100644 index 0000000..45c89b3 Binary files /dev/null and b/Esp32_jpeg/test/data/025.jpg differ diff --git a/Esp32_jpeg/test/data/026.jpg b/Esp32_jpeg/test/data/026.jpg new file mode 100644 index 0000000..7730ac1 Binary files /dev/null and b/Esp32_jpeg/test/data/026.jpg differ diff --git a/Esp32_jpeg/test/data/027.jpg b/Esp32_jpeg/test/data/027.jpg new file mode 100644 index 0000000..ad8a606 Binary files /dev/null and b/Esp32_jpeg/test/data/027.jpg differ diff --git a/Esp32_jpeg/test/data/028.jpg b/Esp32_jpeg/test/data/028.jpg new file mode 100644 index 0000000..9ade411 Binary files /dev/null and b/Esp32_jpeg/test/data/028.jpg differ diff --git a/Esp32_jpeg/test/data/029.jpg b/Esp32_jpeg/test/data/029.jpg new file mode 100644 index 0000000..bf1fef2 Binary files /dev/null and b/Esp32_jpeg/test/data/029.jpg differ diff --git a/Esp32_jpeg/test/data/03.jpg b/Esp32_jpeg/test/data/03.jpg new file mode 100644 index 0000000..0802682 Binary files /dev/null and b/Esp32_jpeg/test/data/03.jpg differ diff --git a/Esp32_jpeg/test/data/030.jpg b/Esp32_jpeg/test/data/030.jpg new file mode 100644 index 0000000..9a5a2ed Binary files /dev/null and b/Esp32_jpeg/test/data/030.jpg differ diff --git a/Esp32_jpeg/test/data/031.jpg b/Esp32_jpeg/test/data/031.jpg new file mode 100644 index 0000000..4055e9d Binary files /dev/null and b/Esp32_jpeg/test/data/031.jpg differ diff --git a/Esp32_jpeg/test/data/032.jpg b/Esp32_jpeg/test/data/032.jpg new file mode 100644 index 0000000..a197e43 Binary files /dev/null and b/Esp32_jpeg/test/data/032.jpg differ diff --git a/Esp32_jpeg/test/data/033.jpg b/Esp32_jpeg/test/data/033.jpg new file mode 100644 index 0000000..12e2545 Binary files /dev/null and b/Esp32_jpeg/test/data/033.jpg differ diff --git a/Esp32_jpeg/test/data/034.jpg b/Esp32_jpeg/test/data/034.jpg new file mode 100644 index 0000000..4df47be Binary files /dev/null and b/Esp32_jpeg/test/data/034.jpg differ diff --git a/Esp32_jpeg/test/data/035.jpg b/Esp32_jpeg/test/data/035.jpg new file mode 100644 index 0000000..1539857 Binary files /dev/null and b/Esp32_jpeg/test/data/035.jpg differ diff --git a/Esp32_jpeg/test/data/036.jpg b/Esp32_jpeg/test/data/036.jpg new file mode 100644 index 0000000..fcdcdee Binary files /dev/null and b/Esp32_jpeg/test/data/036.jpg differ diff --git a/Esp32_jpeg/test/data/037.jpg b/Esp32_jpeg/test/data/037.jpg new file mode 100644 index 0000000..6921916 Binary files /dev/null and b/Esp32_jpeg/test/data/037.jpg differ diff --git a/Esp32_jpeg/test/data/038.jpg b/Esp32_jpeg/test/data/038.jpg new file mode 100644 index 0000000..d8e4397 Binary files /dev/null and b/Esp32_jpeg/test/data/038.jpg differ diff --git a/Esp32_jpeg/test/data/039.jpg b/Esp32_jpeg/test/data/039.jpg new file mode 100644 index 0000000..aa16140 Binary files /dev/null and b/Esp32_jpeg/test/data/039.jpg differ diff --git a/Esp32_jpeg/test/data/04.jpg b/Esp32_jpeg/test/data/04.jpg new file mode 100644 index 0000000..f2ca3cd Binary files /dev/null and b/Esp32_jpeg/test/data/04.jpg differ diff --git a/Esp32_jpeg/test/data/040.jpg b/Esp32_jpeg/test/data/040.jpg new file mode 100644 index 0000000..474a290 Binary files /dev/null and b/Esp32_jpeg/test/data/040.jpg differ diff --git a/Esp32_jpeg/test/data/041.jpg b/Esp32_jpeg/test/data/041.jpg new file mode 100644 index 0000000..2f67972 Binary files /dev/null and b/Esp32_jpeg/test/data/041.jpg differ diff --git a/Esp32_jpeg/test/data/042.jpg b/Esp32_jpeg/test/data/042.jpg new file mode 100644 index 0000000..b7a2fa7 Binary files /dev/null and b/Esp32_jpeg/test/data/042.jpg differ diff --git a/Esp32_jpeg/test/data/043.jpg b/Esp32_jpeg/test/data/043.jpg new file mode 100644 index 0000000..3548fd2 Binary files /dev/null and b/Esp32_jpeg/test/data/043.jpg differ diff --git a/Esp32_jpeg/test/data/044.jpg b/Esp32_jpeg/test/data/044.jpg new file mode 100644 index 0000000..e77c86b Binary files /dev/null and b/Esp32_jpeg/test/data/044.jpg differ diff --git a/Esp32_jpeg/test/data/045.jpg b/Esp32_jpeg/test/data/045.jpg new file mode 100644 index 0000000..dbae137 Binary files /dev/null and b/Esp32_jpeg/test/data/045.jpg differ diff --git a/Esp32_jpeg/test/data/05.jpg b/Esp32_jpeg/test/data/05.jpg new file mode 100644 index 0000000..8267bf2 Binary files /dev/null and b/Esp32_jpeg/test/data/05.jpg differ diff --git a/Esp32_jpeg/test/data/06.jpg b/Esp32_jpeg/test/data/06.jpg new file mode 100644 index 0000000..373d4d6 Binary files /dev/null and b/Esp32_jpeg/test/data/06.jpg differ diff --git a/Esp32_jpeg/test/data/07.jpg b/Esp32_jpeg/test/data/07.jpg new file mode 100644 index 0000000..9dd9fef Binary files /dev/null and b/Esp32_jpeg/test/data/07.jpg differ diff --git a/Esp32_jpeg/test/data/08.jpg b/Esp32_jpeg/test/data/08.jpg new file mode 100644 index 0000000..c60ca39 Binary files /dev/null and b/Esp32_jpeg/test/data/08.jpg differ diff --git a/Esp32_jpeg/test/data/09.jpg b/Esp32_jpeg/test/data/09.jpg new file mode 100644 index 0000000..0ce0086 Binary files /dev/null and b/Esp32_jpeg/test/data/09.jpg differ diff --git a/Esp32_jpeg/test/test.ino b/Esp32_jpeg/test/test.ino new file mode 100644 index 0000000..2f66910 --- /dev/null +++ b/Esp32_jpeg/test/test.ino @@ -0,0 +1,366 @@ +/*************************************************** + This is our GFX example for the Adafruit ILI9341 Breakout and Shield + ----> http://www.adafruit.com/products/1651 + + Check out the links above for our tutorials and wiring diagrams + These displays use SPI to communicate, 4 or 5 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 + ****************************************************/ + + +#include "SPI.h" +#include "Adafruit_GFX.h" +#include "Adafruit_ILI9341.h" + +// For the Adafruit shield, these are the default. +#define TFT_DC 17 +#define TFT_CS 5 +#define TFT_RST 4 + +// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC +Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); +// If using the breakout, change pins as desired +//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO); + +void setup() { + Serial.begin(115200); + Serial.println("ILI9341 Test!"); + + tft.begin(); + + // read diagnostics (optional but can help debug problems) + uint8_t x = tft.readcommand8(ILI9341_RDMODE); + Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX); + x = tft.readcommand8(ILI9341_RDMADCTL); + Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX); + x = tft.readcommand8(ILI9341_RDPIXFMT); + Serial.print("Pixel Format: 0x"); Serial.println(x, HEX); + x = tft.readcommand8(ILI9341_RDIMGFMT); + Serial.print("Image Format: 0x"); Serial.println(x, HEX); + x = tft.readcommand8(ILI9341_RDSELFDIAG); + Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX); + + Serial.println(F("Benchmark Time (microseconds)")); + delay(10); + 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(ILI9341_CYAN)); + delay(500); + + Serial.print(F("Horiz/Vert Lines ")); + Serial.println(testFastLines(ILI9341_RED, ILI9341_BLUE)); + delay(500); + + Serial.print(F("Rectangles (outline) ")); + Serial.println(testRects(ILI9341_GREEN)); + delay(500); + + Serial.print(F("Rectangles (filled) ")); + Serial.println(testFilledRects(ILI9341_YELLOW, ILI9341_MAGENTA)); + delay(500); + + Serial.print(F("Circles (filled) ")); + Serial.println(testFilledCircles(10, ILI9341_MAGENTA)); + + Serial.print(F("Circles (outline) ")); + Serial.println(testCircles(10, ILI9341_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(1000); + } +} + +unsigned long testFillScreen() { + unsigned long start = micros(); + tft.fillScreen(ILI9341_BLACK); + yield(); + tft.fillScreen(ILI9341_RED); + yield(); + tft.fillScreen(ILI9341_GREEN); + yield(); + tft.fillScreen(ILI9341_BLUE); + yield(); + tft.fillScreen(ILI9341_BLACK); + yield(); + return micros() - start; +} + +unsigned long testText() { + tft.fillScreen(ILI9341_BLACK); + unsigned long start = micros(); + tft.setCursor(0, 0); + tft.setTextColor(ILI9341_WHITE); tft.setTextSize(1); + tft.println("Hello World!"); + tft.setTextColor(ILI9341_YELLOW); tft.setTextSize(2); + tft.println(1234.56); + tft.setTextColor(ILI9341_RED); tft.setTextSize(3); + tft.println(0xDEADBEEF, HEX); + tft.println(); + tft.setTextColor(ILI9341_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(ILI9341_BLACK); + yield(); + + x1 = y1 = 0; + y2 = h - 1; + start = micros(); + for(x2=0; x20; 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); + yield(); + } + + 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(ILI9341_BLACK); + start = micros(); + for(x=radius; x10; i-=5) { + start = micros(); + tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, + tft.color565(0, i*10, i*10)); + t += micros() - start; + tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i, + tft.color565(i*10, i*10, 0)); + yield(); + } + + return t; +} + +unsigned long testRoundRects() { + unsigned long start; + int w, i, i2, + cx = tft.width() / 2 - 1, + cy = tft.height() / 2 - 1; + + tft.fillScreen(ILI9341_BLACK); + w = min(tft.width(), tft.height()); + start = micros(); + for(i=0; i20; i-=6) { + i2 = i / 2; + tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0)); + yield(); + } + + return micros() - start; +}