Guest User

Untitled

a guest
Jan 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. // IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY
  2. // CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.
  3. // SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP.
  4. //Technical support:goodtft@163.com
  5.  
  6. #include <Adafruit_GFX.h> // Core graphics library
  7. #include <Adafruit_TFTLCD.h> // Hardware-specific library
  8.  
  9. // The control pins for the LCD can be assigned to any digital or
  10. // analog pins...but we'll use the analog pins as this allows us to
  11. // double up the pins with the touch screen (see the TFT paint example).
  12. #define LCD_CS A3 // Chip Select goes to Analog 3
  13. #define LCD_CD A2 // Command/Data goes to Analog 2
  14. #define LCD_WR A1 // LCD Write goes to Analog 1
  15. #define LCD_RD A0 // LCD Read goes to Analog 0
  16.  
  17. #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
  18.  
  19. // When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
  20. // For the Arduino Uno, Duemilanove, Diecimila, etc.:
  21. // D0 connects to digital pin 8 (Notice these are
  22. // D1 connects to digital pin 9 NOT in order!)
  23. // D2 connects to digital pin 2
  24. // D3 connects to digital pin 3
  25. // D4 connects to digital pin 4
  26. // D5 connects to digital pin 5
  27. // D6 connects to digital pin 6
  28. // D7 connects to digital pin 7
  29. // For the Arduino Mega, use digital pins 22 through 29
  30. // (on the 2-row header at the end of the board).
  31.  
  32. // Assign human-readable names to some common 16-bit color values:
  33. #define BLACK 0x0000
  34. #define BLUE 0x001F
  35. #define RED 0xF800
  36. #define GREEN 0x07E0
  37. #define CYAN 0x07FF
  38. #define MAGENTA 0xF81F
  39. #define YELLOW 0xFFE0
  40. #define WHITE 0xFFFF
  41.  
  42. Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
  43. // If using the shield, all control and data lines are fixed, and
  44. // a simpler declaration can optionally be used:
  45. // Adafruit_TFTLCD tft;
  46.  
  47. void setup(void) {
  48. Serial.begin(9600);
  49. Serial.println(F("TFT LCD test"));
  50.  
  51. #ifdef USE_ADAFRUIT_SHIELD_PINOUT
  52. Serial.println(F("Using Adafruit 2.4\" TFT Arduino Shield Pinout"));
  53. #else
  54. Serial.println(F("Using Adafruit 2.4\" TFT Breakout Board Pinout"));
  55. #endif
  56.  
  57. Serial.print("TFT size is "); Serial.print(tft.width()); Serial.print("x"); Serial.println(tft.height());
  58.  
  59. tft.reset();
  60.  
  61. uint16_t identifier = tft.readID();
  62. if(identifier == 0x9325) {
  63. Serial.println(F("Found ILI9325 LCD driver"));
  64. } else if(identifier == 0x9328) {
  65. Serial.println(F("Found ILI9328 LCD driver"));
  66. } else if(identifier == 0x4535) {
  67. Serial.println(F("Found LGDP4535 LCD driver"));
  68. }else if(identifier == 0x7575) {
  69. Serial.println(F("Found HX8347G LCD driver"));
  70. } else if(identifier == 0x9341) {
  71. Serial.println(F("Found ILI9341 LCD driver"));
  72. } else if(identifier == 0x8357) {
  73. Serial.println(F("Found HX8357D LCD driver"));
  74. } else if(identifier==0x0101)
  75. {
  76. identifier=0x9341;
  77. Serial.println(F("Found 0x9341 LCD driver"));
  78. }
  79. else if(identifier==0x1111)
  80. {
  81. identifier=0x9328;
  82. Serial.println(F("Found 0x9328 LCD driver"));
  83. }
  84. else {
  85. Serial.print(F("Unknown LCD driver chip: "));
  86. Serial.println(identifier, HEX);
  87. Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
  88. Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
  89. Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
  90. Serial.println(F("If using the breakout board, it should NOT be #defined!"));
  91. Serial.println(F("Also if using the breakout, double-check that all wiring"));
  92. Serial.println(F("matches the tutorial."));
  93. identifier=0x9328;
  94.  
  95. }
  96. tft.begin(identifier);
  97.  
  98.  
  99. }
  100.  
  101. void loop(void) {
  102. tft.fillScreen(BLACK);
  103. unsigned long start = micros();
  104. tft.setCursor(0, 0);
  105.  
  106. tft.setTextColor(RED); tft.setTextSize(1);
  107. tft.println("Hello World!");
  108. tft.println(01234.56789);
  109. tft.println(0xDEADBEEF, HEX);
  110. tft.println();
  111. tft.println();
  112. tft.setTextColor(GREEN); tft.setTextSize(2);
  113. tft.println("Hello World!");
  114. tft.println(01234.56789);
  115. tft.println(0xDEADBEEF, HEX);
  116. tft.println();
  117. tft.println();
  118.  
  119. tft.setTextColor(BLUE); tft.setTextSize(3);
  120. tft.println("Hello World!");
  121. tft.println(01234.56789);
  122. tft.println(0xDEADBEEF, HEX);
  123.  
  124. tft.setTextColor(WHITE); tft.setTextSize(4);
  125. tft.println("Hello!");
  126. tft.setTextColor(YELLOW); tft.setTextSize(5);
  127. tft.println("Hello!");
  128. tft.setTextColor(RED); tft.setTextSize(6);
  129. tft.println("Hello!");
  130. tft.println();
  131. tft.println();
  132. /*
  133. tft.println();
  134. tft.setTextColor(GREEN);
  135. tft.setTextSize(5);
  136. tft.println("Groop");
  137. tft.setTextSize(2);
  138. tft.println("I implore thee,");
  139. tft.setTextSize(1);
  140. tft.println("my foonting turlingdromes.");
  141. tft.println("And hooptiously drangle me");
  142. tft.println("with crinkly bindlewurdles,");
  143. tft.println("Or I will rend thee");
  144. tft.println("in the gobberwarts");
  145. tft.println("with my blurglecruncheon,");
  146. tft.println("see if I don't!");*/
  147. delay(1000);delay(1000);delay(1000);delay(1000);delay(1000);
  148. }
Add Comment
Please, Sign In to add comment