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 |
drawXBitmap.ino (1818B)
1 // Example sketch to demonstrate the drawing of X BitMap (XBM) 2 // format image onto the display. 3 4 // Information on the X BitMap (XBM) format can be found here: 5 // https://en.wikipedia.org/wiki/X_BitMap 6 7 // This example is part of the TFT_eSPI library: 8 // https://github.com/Bodmer/TFT_eSPI 9 10 // Created by Bodmer 23/04/18 11 12 #include "xbm.h" // Sketch tab header for xbm images 13 14 #include <TFT_eSPI.h> // Hardware-specific library 15 16 TFT_eSPI tft = TFT_eSPI(); // Invoke library 17 18 19 void setup() 20 { 21 tft.begin(); // Initialise the display 22 tft.fillScreen(TFT_BLACK); // Black screen fill 23 } 24 25 void loop() 26 { 27 28 // Example 1 29 // ========= 30 // Random x and y coordinates 31 int x = random(tft.width() - logoWidth); 32 int y = random(tft.height() - logoHeight); 33 34 // Draw bitmap with top left corner at x,y with foreground only color 35 // Bits set to 1 plot as the defined color, bits set to 0 are not plotted 36 // x y xbm xbm width xbm height color 37 tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE); 38 39 delay(500); 40 41 // Erase old one by drawing over with background colour 42 tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK); 43 44 45 // Example 2 46 // ========= 47 // New random x and y coordinates 48 x = random(tft.width() - logoWidth); 49 y = random(tft.height() - logoHeight); 50 51 // Draw bitmap with top left corner at x,y with foreground and background colors 52 // Bits set to 1 plot as the defined fg color, bits set to 0 are plotted as bg color 53 // x y xbm xbm width xbm height fg color bg color 54 tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE, TFT_RED); 55 56 delay(500); 57 58 // Erase old one by drawing over with background colour 59 tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK, TFT_BLACK); 60 61 }