mc_workshop

tft 3.5 shield

Apr 16th, 2021
398
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Adafruit_GFX.h>
  2. #include <MCUFRIEND_kbv.h>
  3. MCUFRIEND_kbv tft;
  4. #include <Fonts/FreeSans9pt7b.h>
  5. #include <Fonts/FreeSans12pt7b.h>
  6. #include <Fonts/FreeSerif12pt7b.h>
  7. #include <FreeDefaultFonts.h>
  8. #define TFT_BLACK   0x0000
  9. #define TFT_RED     0xF800
  10.  
  11. Per altri modelli fate riferimento alla tabella sottostante
  12.  
  13. 0x7575  HX8347G ADAfruit “TFTLCD”
  14. Samuraijap “TFTLCD-Library”
  15. Joao Lopes SPFD5408
  16.  
  17. 0x8357  HX8357D ADAfruit “TFTLCD”
  18. Samuraijap “TFTLCD-Library”
  19. Joao Lopes SPFD5408
  20.  
  21. 0x9325  ILI9325 ADAfruit “TFTLCD”
  22. Samuraijap “TFTLCD-Library”
  23. Joao Lopes SPFD5408
  24.  
  25. 0x9328  ILI9328 ADAfruit “TFTLCD”
  26. Samuraijap “TFTLCD-Library”
  27. Joao Lopes SPFD5408
  28.  
  29. 0x9341  ILI9341 ADAfruit “TFTLCD”
  30. Samuraijap “TFTLCD-Library”
  31. Joao Lopes SPFD5408
  32.  
  33. 0x0154  S6D0154 Samuraijap “TFTLCD-Library”
  34. 0x9327  ILI9327 Samuraijap “TFTLCD-Library”
  35. 0x7781  ST7781  Smoke and Wires “SWTFT-Library”
  36. 0x7783  ST7783  Smoke and Wires “SWTFT-Library”
  37.  
  38. /*
  39. Scritta ON AIR lampeggiante
  40. mcworkshop aprile 2021
  41. This example code is in the public domain.
  42. */
  43. #include <Adafruit_GFX.h>
  44. #include <MCUFRIEND_kbv.h>
  45. MCUFRIEND_kbv tft;
  46. #include <Fonts/FreeSans9pt7b.h>
  47. #include <Fonts/FreeSans12pt7b.h>
  48. #include <Fonts/FreeSerif12pt7b.h>
  49. #include <FreeDefaultFonts.h>
  50. #define TFT_BLACK   0x0000
  51. #define TFT_RED     0xF800
  52. void setup(void)
  53. {
  54.  Serial.begin(9600);
  55.  uint16_t ID = tft.readID();
  56.  if (ID == 0xD3) ID = 0x9481;
  57.  tft.begin(ID);
  58.  tft.setRotation(45); //rotazione della scritta 45°
  59. }
  60. void loop(void)
  61. {
  62.  tft.fillScreen(TFT_BLACK); //colore di sfondo
  63.  tft.setTextColor(TFT_RED); // colore del testo
  64.  tft.setTextSize(10);// dimensione del carattere
  65.  tft.setCursor(70, 100); // la prima cifra sposta la scritta verso sinistra (orizzontale); la seconda dall'alto al basso (verticale); il connettore USB si trova in alto a sinistra
  66.  tft.print("ON AIR");
  67.  tft.setTextColor(TFT_RED); // colore del testo
  68.  tft.setTextSize(4);// dimensione del carattere
  69.  tft.setCursor(70, 200); // la prima cifra sposta la scritta verso sinistra (orizzontale); la seconda dall'alto al basso (verticale); il connettore USB si trova in alto a sinistra
  70.  tft.print("VIETATO ENTRARE");
  71.  delay (800);
  72.  }
  73. /*
  74. #define TFT_BLACK                0x0000
  75. #define TFT_NAVY                 0x000F
  76. #define TFT_DARKGREEN            0x03E0
  77. #define TFT_DARKCYAN             0x03EF
  78. #define TFT_MAROON               0x7800
  79. #define TFT_PURPLE               0x780F
  80. #define TFT_OLIVE                0x7BE0
  81. #define TFT_LIGHTGREY            0xC618
  82. #define TFT_DARKGREY             0x7BEF
  83. #define TFT_BLUE                 0x001F
  84. #define TFT_GREEN                0x07E0
  85. #define TFT_CYAN                 0x07FF
  86. #define TFT_RED                  0xF800
  87. #define TFT_MAGENTA              0xF81F
  88. #define TFT_YELLOW               0xFFE0
  89. #define TFT_WHITE                0xFFFF
  90. #define TFT_ORANGE               0xFDA0
  91. #define TFT_PINK                 0xFC9F
  92. */
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×