acidportal- 😈 Worlds smallest Evil Portal on a LilyGo T-QT |
git clone git://git.acid.vegas/acidportal.git |
Log | Files | Refs | Archive | README | LICENSE |
TFT_Flash_Bitmap.ino (2287B)
1 // Icon images are stored in tabs ^ e.g. Alert.h etc above this line 2 // more than one icon can be in a header file 3 4 // Arrays containing FLASH images can be created with UTFT library tool: 5 // (libraries\UTFT\Tools\ImageConverter565.exe) 6 // Convert to .c format then copy into a new tab 7 8 /* 9 This sketch demonstrates loading images from arrays stored in program (FLASH) memory. 10 11 Works with TFT_eSPI library here: 12 https://github.com/Bodmer/TFT_eSPI 13 14 This sketch does not use/need any fonts at all... 15 16 Code derived from ILI9341_due library example 17 18 Make sure all the display driver and pin connections are correct by 19 editing the User_Setup.h file in the TFT_eSPI library folder. 20 21 ######################################################################### 22 ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 23 ######################################################################### 24 */ 25 26 #include <TFT_eSPI.h> // Hardware-specific library 27 28 TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 29 30 // Include the header files that contain the icons 31 #include "Alert.h" 32 #include "Close.h" 33 #include "Info.h" 34 35 long count = 0; // Loop count 36 37 void setup() 38 { 39 Serial.begin(115200); 40 tft.begin(); 41 tft.setRotation(1); // landscape 42 43 tft.fillScreen(TFT_BLACK); 44 45 // Swap the colour byte order when rendering 46 tft.setSwapBytes(true); 47 48 // Draw the icons 49 tft.pushImage(100, 100, infoWidth, infoHeight, info); 50 tft.pushImage(140, 100, alertWidth, alertHeight, alert); 51 tft.pushImage(180, 100, closeWidth, closeHeight, closeX); 52 53 // Pause here to admire the icons! 54 delay(2000); 55 56 } 57 58 void loop() 59 { 60 // Loop filling and clearing screen 61 tft.pushImage(random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight, info); 62 tft.pushImage(random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight, alert); 63 tft.pushImage(random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight, closeX); 64 65 // Clear screen after 100 x 3 = 300 icons drawn 66 if (1000 == count++) { 67 count = 1; 68 tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony! 69 tft.fillScreen(TFT_BLACK); 70 tft.setRotation(1); 71 } 72 }