From ff068df920e28885b1ddd02856a104a12d1818c0 Mon Sep 17 00:00:00 2001 From: hans-jurgen Date: Sun, 15 Dec 2024 23:51:23 +0100 Subject: [PATCH] 2024-12-1500 Display gedreht. --- src/main.cpp | 145 ++++++++++++++++++++++++++++----------------------- 1 file changed, 81 insertions(+), 64 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7c2d9d4..116fb9d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -67,6 +67,8 @@ void zeigeZeit(tm localTime, int x, int y); void drawMenue(int32_t xs, int32_t sy); void Menue(); void zeige_IP(int x, int y); +void NoTouchScreen(TouchPoint touch_1); + void listDir(fs::FS &fs, const char * dirname, uint8_t levels) { Serial.printf("Listing directory: %s\n", dirname); @@ -241,7 +243,7 @@ void setup() { // Start the tft display and set it to black tft.init(); - tft.setRotation(1); //This is the display in landscape + tft.setRotation(3); //This is the display in landscape // Clear the screen before writing to it tft.fillScreen(TFT_BLACK); @@ -413,9 +415,12 @@ void loop() { if (touch.zRaw != 0){ printTouchToSerial2(touch.x, touch.y, touch.xRaw); - if((touch.x >= 275) && (touch.y >= 210)){ - Serial.printf(" Gefunden bei: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); - Menue(); + if((touch.y >= 15) && (touch.y <= 30)){ + if((touch.x >= 15) && (touch.x <= 30)){ + //Serial.printf(" Gefunden bei: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); + NoTouchScreen(touch); + Menue(); + } } } @@ -519,68 +524,73 @@ void Menue(){ tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.println("Interval der Messwert-\nspeicherung in Minuten."); if (touch.zRaw != 0){ - //printTouchToSerial2(touch.x, touch.y, touch.xRaw); - - if(((touch.x >= 15) && (touch.x <= 55)) && ((touch.y >= 95) && (touch.y <= 125))){ - Serial.printf(" Gefunden bei 1: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); - tft.drawRoundRect(11,91,38,38,5,TFT_GOLD); - tft.drawRoundRect(12,92,36,36,5,TFT_GOLD); - tft.drawRoundRect(13,93,34,34,5,TFT_GOLD); - delay(1000); - tft.drawRoundRect(11,91,38,38,5,TFT_BLACK); - tft.drawRoundRect(12,92,36,36,5,TFT_BLACK); - tft.drawRoundRect(13,93,34,34,5,TFT_BLACK); - interval = 1; - } + printTouchToSerial2(touch.x, touch.y, touch.xRaw); + if ((touch.y >= 110) && (touch.y <= 145)){ + if((touch.x >= 245) && (touch.x <= 280)){ + Serial.printf(" Gefunden bei 1: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); + tft.drawRoundRect(11,91,38,38,5,TFT_GOLD); + tft.drawRoundRect(12,92,36,36,5,TFT_GOLD); + tft.drawRoundRect(13,93,34,34,5,TFT_GOLD); + delay(1000); + tft.drawRoundRect(11,91,38,38,5,TFT_BLACK); + tft.drawRoundRect(12,92,36,36,5,TFT_BLACK); + tft.drawRoundRect(13,93,34,34,5,TFT_BLACK); + interval = 1; + } - if(((touch.x >= 65) && (touch.x <= 95)) && ((touch.y >= 95) && (touch.y <= 125))){ - Serial.printf(" Gefunden bei 2: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); - tft.drawRoundRect(61,91,38,38,5,TFT_GOLD); - tft.drawRoundRect(62,92,36,36,5,TFT_GOLD); - tft.drawRoundRect(63,93,34,34,5,TFT_GOLD); - delay(1000); - tft.drawRoundRect(61,91,38,38,5,TFT_BLACK); - tft.drawRoundRect(62,92,36,36,5,TFT_BLACK); - tft.drawRoundRect(63,93,34,34,5,TFT_BLACK); - interval = 5; - } - if(((touch.x >= 110) && (touch.x <= 140)) && ((touch.y >= 95) && (touch.y <= 125))){ - Serial.printf(" Gefunden bei 3: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); - tft.drawRoundRect(111,91,38,38,5,TFT_GOLD); - tft.drawRoundRect(112,92,36,36,5,TFT_GOLD); - tft.drawRoundRect(113,93,34,34,5,TFT_GOLD); - delay(1000); - tft.drawRoundRect(111,91,38,38,5,TFT_BLACK); - tft.drawRoundRect(112,92,36,36,5,TFT_BLACK); - tft.drawRoundRect(113,93,34,34,5,TFT_BLACK); - interval = 10; - } - if(((touch.x >= 150) && (touch.x <= 195)) && ((touch.y >= 95) && (touch.y <= 125))){ - Serial.printf(" Gefunden bei 4: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); - tft.drawRoundRect(161,91,38,38,5,TFT_GOLD); - tft.drawRoundRect(162,92,36,36,5,TFT_GOLD); - tft.drawRoundRect(163,93,34,34,5,TFT_GOLD); - delay(1000); - tft.drawRoundRect(161,91,38,38,5,TFT_BLACK); - tft.drawRoundRect(162,92,36,36,5,TFT_BLACK); - tft.drawRoundRect(163,93,34,34,5,TFT_BLACK); - interval = 30; - } - if(((touch.x >= 200) && (touch.x <= 230)) && ((touch.y >= 95) && (touch.y <= 125))){ - Serial.printf(" Gefunden bei 5: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); - tft.drawRoundRect(211,91,38,38,5,TFT_GOLD); - tft.drawRoundRect(212,92,36,36,5,TFT_GOLD); - tft.drawRoundRect(213,93,34,34,5,TFT_GOLD); - delay(1000); - tft.drawRoundRect(211,91,38,38,5,TFT_BLACK); - tft.drawRoundRect(212,92,36,36,5,TFT_BLACK); - tft.drawRoundRect(213,93,34,34,5,TFT_BLACK); - interval = 60; - } - if((touch.x >= 275) && (touch.y >= 210)){ - Serial.printf(" Gefunden bei: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); + if((touch.x >= 200) && (touch.x <= 245)){ + Serial.printf(" Gefunden bei 2: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); + tft.drawRoundRect(61,91,38,38,5,TFT_GOLD); + tft.drawRoundRect(62,92,36,36,5,TFT_GOLD); + tft.drawRoundRect(63,93,34,34,5,TFT_GOLD); + delay(1000); + tft.drawRoundRect(61,91,38,38,5,TFT_BLACK); + tft.drawRoundRect(62,92,36,36,5,TFT_BLACK); + tft.drawRoundRect(63,93,34,34,5,TFT_BLACK); + interval = 5; + } + if((touch.x >= 165) && (touch.x <= 195)){ + Serial.printf(" Gefunden bei 3: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); + tft.drawRoundRect(111,91,38,38,5,TFT_GOLD); + tft.drawRoundRect(112,92,36,36,5,TFT_GOLD); + tft.drawRoundRect(113,93,34,34,5,TFT_GOLD); + delay(1000); + tft.drawRoundRect(111,91,38,38,5,TFT_BLACK); + tft.drawRoundRect(112,92,36,36,5,TFT_BLACK); + tft.drawRoundRect(113,93,34,34,5,TFT_BLACK); + interval = 10; + } + if((touch.x >= 120) && (touch.x <= 150)){ + Serial.printf(" Gefunden bei 4: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); + tft.drawRoundRect(161,91,38,38,5,TFT_GOLD); + tft.drawRoundRect(162,92,36,36,5,TFT_GOLD); + tft.drawRoundRect(163,93,34,34,5,TFT_GOLD); + delay(1000); + tft.drawRoundRect(161,91,38,38,5,TFT_BLACK); + tft.drawRoundRect(162,92,36,36,5,TFT_BLACK); + tft.drawRoundRect(163,93,34,34,5,TFT_BLACK); + interval = 30; + } + if((touch.x >= 75) && (touch.x <= 100)){ + Serial.printf(" Gefunden bei 5: %i : %i : %i \n", touch.y, touch.x, touch.zRaw); + tft.drawRoundRect(211,91,38,38,5,TFT_GOLD); + tft.drawRoundRect(212,92,36,36,5,TFT_GOLD); + tft.drawRoundRect(213,93,34,34,5,TFT_GOLD); + delay(1000); + tft.drawRoundRect(211,91,38,38,5,TFT_BLACK); + tft.drawRoundRect(212,92,36,36,5,TFT_BLACK); + tft.drawRoundRect(213,93,34,34,5,TFT_BLACK); + interval = 60; + } + } + + + if((touch.y >= 15) && (touch.y <= 30)){ + if((touch.x >= 15) && (touch.x <= 30)){ + NoTouchScreen(touch); zurueck = false; - } + } + } } tft.drawRoundRect(10,90,40,40,5,TFT_GREEN); tft.drawRoundRect(60,90,40,40,5,TFT_GREEN); @@ -608,4 +618,11 @@ void Menue(){ tft.setTextSize(2); tft.println(WiFi.localIP()); tft.setTextSize(1); + } + void NoTouchScreen(TouchPoint touch_1){ + do{ + delay(50); + //Serial.printf(" Gefunden bei --------->: %i : %i : %i \n", touch_1.y, touch_1.x, touch_1.zRaw); + touch_1 = touchscreen.getTouch(); + } while(touch_1.zRaw > 0); } \ No newline at end of file