Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPFD5408_Adafruit_GFX.h>
- #include <SPFD5408_Adafruit_TFTLCD.h>
- #include <SPFD5408_TouchScreen.h>
- #define SENSIBILITY 300
- #define MINPRESSURE 10
- #define MAXPRESSURE 1000
- #define YP A2
- #define XM A3
- #define YM 8
- #define XP 9
- TouchScreen ts = TouchScreen(XP, YP, XM, YM, SENSIBILITY);
- TSPoint p;
- #define LCD_CS A3
- #define LCD_CD A2
- #define LCD_WR A1
- #define LCD_RD A0
- #define LCD_RESET A4
- #define BLACK 0x0000
- #define BLUE 0x001F
- #define RED 0xF800
- #define GREEN 0x07E0
- #define CYAN 0x07FF
- #define MAGENTA 0xF81F
- #define YELLOW 0xFFE0
- #define WHITE 0xFFFF
- Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
- void setup() {
- tft.reset();
- tft.begin(0x9341);
- tft.setRotation(1);
- tft.setTextSize (2);
- tft.setTextColor(WHITE);
- tft.fillScreen(BLACK);
- Serial.begin(9600);
- }
- void loop() {
- drawMainMenu(14,56,1); // temperatura, umidità, menu
- p = waitOneTouch();
- if(p.x < 600){
- Serial.print("prog1");
- } else Serial.print("prog2");
- }
- void drawMainMenu(float temp,int hum, int menu) {
- tft.setCursor (10, 15);
- tft.print("Temperatura: ");tft.print(temp);tft.print(" C");
- tft.setCursor (10, 40);
- tft.print("Umidita: ");tft.print(hum);tft.print(" %");
- if(menu==0) {
- tft.drawRect(5, 130, 150, 100, BLUE);
- tft.drawRect(160, 130, 150, 100, GREEN);
- tft.setCursor (40, 170);
- tft.print("Prog. 1");
- tft.setCursor (190, 170);
- tft.print("Prog. 2");
- }
- if(menu==1) {
- tft.drawRect(5, 130, 150, 100, BLUE);
- tft.drawRect(160, 130, 150, 100, GREEN);
- tft.setCursor (50, 170);
- tft.print("STOP");
- tft.setCursor (200, 170);
- tft.print("RESET");
- }
- if(menu==2) {
- tft.drawRect(5, 130, 150, 100, BLUE);
- tft.drawRect(160, 130, 150, 100, GREEN);
- tft.setCursor (50, 170);
- tft.print("START");
- tft.setCursor (200, 170);
- tft.print("RESET");
- }
- }
- TSPoint waitOneTouch() {
- TSPoint p;
- do {
- p= ts.getPoint();
- pinMode(XM, OUTPUT); //Pins configures again for TFT control
- pinMode(YP, OUTPUT);
- } while((p.z < MINPRESSURE )|| (p.z > MAXPRESSURE));
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement