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_Print_Test.ino (2858B)
1 /* 2 Test the tft.print() viz the libraries embedded write() function 3 4 This sketch used font 2, 4, 7 5 6 Make sure all the required fonts are loaded by editing the 7 User_Setup.h file in the TFT_eSPI library folder. 8 9 ######################################################################### 10 ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 11 ######################################################################### 12 */ 13 14 #include <SPI.h> 15 16 #include <TFT_eSPI.h> // Hardware-specific library 17 18 TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 19 20 #define TFT_GREY 0x5AEB // New colour 21 22 23 void setup(void) { 24 tft.init(); 25 tft.setRotation(2); 26 } 27 28 void loop() { 29 30 // Fill screen with random colour so we can see the effect of printing with and without 31 // a background colour defined 32 tft.fillScreen(random(0xFFFF)); 33 34 // Set "cursor" at top left corner of display (0,0) and select font 2 35 // (cursor will move to next line automatically during printing with 'tft.println' 36 // or stay on the line is there is room for the text with tft.print) 37 tft.setCursor(0, 0, 2); 38 // Set the font colour to be white with a black background, set text size multiplier to 1 39 tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1); 40 // We can now plot text on screen using the "print" class 41 tft.println("Hello World!"); 42 43 // Set the font colour to be yellow with no background, set to font 7 44 tft.setTextColor(TFT_YELLOW); tft.setTextFont(7); 45 tft.println(1234.56); 46 47 // Set the font colour to be red with black background, set to font 4 48 tft.setTextColor(TFT_RED,TFT_BLACK); tft.setTextFont(4); 49 tft.println((long)3735928559, HEX); // Should print DEADBEEF 50 51 // Set the font colour to be green with black background, set to font 4 52 tft.setTextColor(TFT_GREEN,TFT_BLACK); 53 tft.setTextFont(4); 54 tft.println("Groop"); 55 tft.println("I implore thee,"); 56 57 // Change to font 2 58 tft.setTextFont(2); 59 tft.println(F("my foonting turlingdromes.")); // Can store strings in FLASH to save RAM 60 tft.println("And hooptiously drangle me"); 61 tft.println("with crinkly bindlewurdles,"); 62 // This next line is deliberately made too long for the display width to test 63 // automatic text wrapping onto the next line 64 tft.println("Or I will rend thee in the gobberwarts with my blurglecruncheon, see if I don't!"); 65 66 // Test some print formatting functions 67 float fnumber = 123.45; 68 // Set the font colour to be blue with no background, set to font 4 69 tft.setTextColor(TFT_BLUE); tft.setTextFont(4); 70 tft.print("Float = "); tft.println(fnumber); // Print floating point number 71 tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary 72 tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal 73 delay(10000); 74 } 75 76 77