daily pastebin goal
67%
SHARE
TWEET

TFT SCREEN

DJJASPER21 Dec 10th, 2017 492 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SPFD5408_Adafruit_GFX.h>    // Core graphics library
  2. #include <SPFD5408_Adafruit_TFTLCD.h> // Hardware-specific library
  3. #include <SPFD5408_TouchScreen.h>
  4. #define LCD_CS A3 // Chip Select goes to Analog 3
  5. #define LCD_CD A2 // Command/Data goes to Analog 2
  6. #define LCD_WR A1 // LCD Write goes to Analog 1
  7. #define LCD_RD A0 // LCD Read goes to Analog 0
  8. #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
  9. #define BLACK   0x0000
  10. #define BLUE    0x001F
  11. #define RED     0xF800
  12. #define GREEN   0x07E0
  13. #define CYAN    0x07FF
  14. #define MAGENTA 0xF81F
  15. #define YELLOW  0xFFE0
  16. #define WHITE   0xFFFF
  17.  
  18. Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
  19. void setup(void) {
  20.  
  21.   Serial.begin(9600);
  22.  
  23.   progmemPrintln(PSTR("TFT LCD test"));
  24.  
  25. #ifdef USE_ADAFRUIT_SHIELD_PINOUT
  26.   progmemPrintln(PSTR("Using Adafruit 2.8\" TFT Arduino Shield Pinout"));
  27. #else
  28.   progmemPrintln(PSTR("Using Adafruit 2.8\" TFT Breakout Board Pinout"));
  29. #endif
  30.  
  31.   tft.reset(); //Do not change
  32.   tft.begin(0x9341); //Do not change!
  33.   tft.setRotation(0); //Change the rotation of the screen.
  34.   progmemPrintln(PSTR("Benchmark                Time (microseconds)"));
  35.   progmemPrintln(PSTR("Done!"));
  36. }
  37.  
  38. void loop(void) {
  39.   // Colorcheck start
  40.   tft.fillScreen(BLACK);
  41.   tft.fillScreen(RED);
  42.   tft.fillScreen(GREEN);
  43.   tft.fillScreen(BLUE);
  44.   tft.fillScreen(BLACK);
  45.   // Colorcheck stop
  46.  tft.setCursor(0, 0);
  47.  tft.setTextColor(BLUE);
  48.  tft.setTextSize(2);
  49.  tft.print("Hello world !!");
  50.   tft.setTextColor(GREEN);
  51.  tft.setTextSize(2);
  52.  tft.print("      Waiting 7 seconds ..");
  53.  delay(7000);
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. // don't change !!!!
  67. void progmemPrint(const char *str) {
  68.   char c;
  69.   while(c = pgm_read_byte(str++)) Serial.print(c);
  70. }
  71.  
  72. // Same as above, with trailing newline
  73. void progmemPrintln(const char *str) {
  74.   progmemPrint(str);
  75.   Serial.println();
  76. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top