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_Print_Test.ino (2576B)

      1 /*  
      2  Test the tft.print() viz embedded tft.write() function
      3 
      4  This sketch used font 2, 4, 7
      5  
      6  Make sure all the display driver and pin connections are correct by
      7  editing the User_Setup.h file in the TFT_eSPI library folder.
      8 
      9  Note that yield() or delay(0) must be called in long duration for/while
     10  loops to stop the ESP8266 watchdog triggering.
     11 
     12  #########################################################################
     13  ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
     14  #########################################################################
     15  */
     16 
     17 
     18 #include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
     19 #include <SPI.h>
     20 
     21 TFT_eSPI tft = TFT_eSPI();  // Invoke library, pins defined in User_Setup.h
     22 
     23 #define TFT_GREY 0x5AEB // New colour
     24 
     25 void setup(void) {
     26   tft.init();
     27   tft.setRotation(1);
     28 }
     29 
     30 void loop() {
     31   
     32   // Fill screen with grey so we can see the effect of printing with and without 
     33   // a background colour defined
     34   tft.fillScreen(TFT_GREY);
     35   
     36   // Set "cursor" at top left corner of display (0,0) and select font 2
     37   // (cursor will move to next line automatically during printing with 'tft.println'
     38   //  or stay on the line is there is room for the text with tft.print)
     39   tft.setCursor(0, 0, 2);
     40   // Set the font colour to be white with a black background, set text size multiplier to 1
     41   tft.setTextColor(TFT_WHITE,TFT_BLACK);  tft.setTextSize(1);
     42   // We can now plot text on screen using the "print" class
     43   tft.println("Hello World!");
     44   
     45   // Set the font colour to be yellow with no background, set to font 7
     46   tft.setTextColor(TFT_YELLOW); tft.setTextFont(2);
     47   tft.println(1234.56);
     48   
     49   // Set the font colour to be red with black background, set to font 4
     50   tft.setTextColor(TFT_RED,TFT_BLACK);    tft.setTextFont(4);
     51   tft.println((long)3735928559, HEX); // Should print DEADBEEF
     52 
     53   // Set the font colour to be green with black background, set to font 2
     54   tft.setTextColor(TFT_GREEN,TFT_BLACK);
     55   tft.setTextFont(2);
     56   tft.println("Groop");
     57 
     58   // Test some print formatting functions
     59   float fnumber = 123.45;
     60    // Set the font colour to be blue with no background, set to font 2
     61   tft.setTextColor(TFT_BLUE);    tft.setTextFont(2);
     62   tft.print("Float = "); tft.println(fnumber);           // Print floating point number
     63   tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary
     64   tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal
     65 
     66   while(1) yield(); // We must yield() to stop a watchdog timeout.
     67 }
     68 
     69 
     70