Advertisement
NapsterMP3

Serial to LCD 2.4 TFT

Jun 20th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. #include <Adafruit_GFX.h> // Core graphics library
  2. #include <Adafruit_TFTLCD.h> // Hardware-specific library
  3. #include <TouchScreen.h>
  4.  
  5. #define YP A3 // Y+ is on Analog1
  6. #define XM A2 // X- is on Analog2
  7. #define YM 9 // Y- is on Digital7
  8. #define XP 8 // X+ is on Digital6
  9.  
  10. #define TS_MINX 150
  11. #define TS_MINY 120
  12. #define TS_MAXX 920
  13. #define TS_MAXY 940
  14.  
  15. TouchScreen ts = TouchScreen(XP, YP, XM, YM, 100);
  16.  
  17. //Definicao de cores
  18. #define BLACK 0x0000
  19. #define BLUE 0x001F
  20. #define RED 0xF800
  21. #define GREEN 0x07E0
  22. #define CYAN 0x07FF
  23. #define MAGENTA 0xF81F
  24. #define YELLOW 0xFFE0
  25. #define WHITE 0xFFFF
  26.  
  27. //PP_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
  28. Adafruit_TFTLCD tft(A3, A2, A1, A0, A4);
  29.  
  30. char tecla;
  31. boolean a = 1;
  32.  
  33. int rotacao = 1; //// rotação pode ser 1 ou 3
  34. int ymenor = 0;
  35. int ymaior = 0;
  36. int xmenor = 0;
  37. int xmaior = 0;
  38. int control = 0;
  39.  
  40. #define MINPRESSURE 10
  41. #define MAXPRESSURE 1000
  42.  
  43. void setup(void)
  44. {
  45. Serial.begin(9600);
  46. tft.reset();
  47. delay(500);
  48. tft.begin(0x9341);
  49. tft.setRotation(rotacao);
  50. tft.fillScreen(BLACK);
  51. }
  52.  
  53. void loop()
  54. {
  55. //size 1 ---- 6
  56. //size 2 ---- 12
  57. //size 3 ---- 18
  58. //size 4 ---- 24
  59. //size 5 ---- 30
  60. //size 6 ---- 36
  61. int mudar=12;
  62.  
  63. if (Serial.available()){
  64. tft.fillScreen(BLACK);
  65.  
  66. while (Serial.available())
  67. {
  68. tecla = Serial.read();
  69. //tft.drawRoundRect(158, 24, 68, 29, 5, WHITE);///botao girar
  70. tft.setTextColor(WHITE);
  71. tft.setTextSize(2);
  72. tft.setCursor(60+control, 30);
  73. tft.println(tecla);
  74. control=control+mudar;
  75. }
  76. control = 0;
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement