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_String_Align.ino (2625B)

      1 /*
      2 Tests string alignment
      3 
      4 Normally strings are printed relative to the top left corner but this can be
      5 changed with the setTextDatum() function. The library has #defines for:
      6 
      7 TL_DATUM = Top left
      8 TC_DATUM = Top centre
      9 TR_DATUM = Top right
     10 ML_DATUM = Middle left
     11 MC_DATUM = Middle centre
     12 MR_DATUM = Middle right
     13 BL_DATUM = Bottom left
     14 BC_DATUM = Bottom centre
     15 BR_DATUM = Bottom right
     16 
     17  
     18  Needs fonts 2, 4, 6, 7 and 8
     19 
     20  Make sure all the display driver and pin connections are correct by
     21  editing the User_Setup.h file in the TFT_eSPI library folder.
     22 
     23  #########################################################################
     24  ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
     25  #########################################################################
     26  */
     27 
     28 
     29 #include <TFT_eSPI.h> // Hardware-specific library
     30 #include <SPI.h>
     31 
     32 TFT_eSPI tft = TFT_eSPI();       // Invoke custom library
     33 
     34 unsigned long drawTime = 0;
     35 
     36 void setup(void) {
     37   Serial.begin(115200);
     38   tft.init();
     39   tft.setRotation(1);
     40 }
     41 
     42 void loop() {
     43 
     44   tft.fillScreen(TFT_BLACK);
     45   
     46   for(byte datum = 0; datum < 9; datum++) {
     47     tft.setTextColor(TFT_WHITE, TFT_BLACK);
     48     
     49     tft.setTextDatum(datum);
     50     
     51     tft.drawNumber(88,160,120,8);
     52     tft.fillCircle(160,120,5,TFT_RED);
     53     
     54     tft.setTextDatum(MC_DATUM);
     55     
     56     tft.setTextColor(TFT_BLACK);
     57     tft.drawString("X",160,120,2);
     58     delay(1000);
     59     tft.fillScreen(TFT_BLACK);
     60   }
     61 
     62   tft.setTextColor(TFT_BLUE, TFT_BLACK);
     63   tft.drawCentreString("69",160,120,8);
     64   tft.fillCircle(160,120,5,TFT_YELLOW);
     65   
     66   tft.setTextDatum(MC_DATUM);
     67   
     68   tft.setTextColor(TFT_BLACK);
     69   tft.drawString("X",160,120,2);
     70   delay(1000);
     71   tft.fillScreen(TFT_BLACK);
     72   
     73   tft.setTextColor(TFT_RED, TFT_BLACK);
     74   tft.drawRightString("88",160,120,8);
     75   tft.fillCircle(160,120,5,TFT_YELLOW);
     76   
     77   tft.setTextDatum(MC_DATUM);
     78   
     79   tft.setTextColor(TFT_BLACK);
     80   tft.drawString("X",160,120,2);
     81   delay(1000);
     82   tft.fillScreen(TFT_BLACK);
     83 
     84   tft.setTextColor(TFT_WHITE, TFT_BLUE);
     85 
     86   tft.setTextDatum(MC_DATUM);
     87 
     88   //Test floating point drawing function
     89   float test = 67.125;
     90   tft.drawFloat(test, 4, 160, 180, 4);
     91   delay(1000);
     92   tft.fillScreen(TFT_BLACK);
     93   test = -0.555555;
     94   tft.drawFloat(test, 3, 160, 180, 4);
     95   delay(1000);
     96   tft.fillScreen(TFT_BLACK);
     97   test = 0.1;
     98   tft.drawFloat(test, 4, 160, 180, 4);
     99   delay(1000);
    100   tft.fillScreen(TFT_BLACK);
    101   test = 9999999;
    102   tft.drawFloat(test, 1, 160, 180, 4);
    103   delay(1000);
    104   
    105   tft.fillCircle(160,180,5,TFT_YELLOW);
    106   
    107   tft.setTextDatum(MC_DATUM);
    108   
    109   tft.setTextColor(TFT_BLACK);
    110   tft.drawString("X",160,180,2);
    111  
    112   delay(4000);
    113 }
    114 
    115 
    116 
    117 
    118 
    119 
    120 
    121