#include "Arduino_GigaDisplay_GFX.h"
#include "Arduino_GigaDisplayTouch.h"
GigaDisplay_GFX display;
Arduino_GigaDisplayTouch touchDetector;
#define BLACK 0x0000
#define RED 0xD105
#define WHITE 0xffff
#define GREEN 0x67E0
#define BLUE 0x001F
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define WHITE 0xFFFF
#define YELLOW 0xFFE0
#define ORANGE 0XFDC0
bool RecMode = false;
// Button Dimensions
void setup() {
display.begin();
touchDetector.begin();
display.setRotation(1);
// Draw the button
display.fillScreen(BLACK); // White background
display.fillRoundRect(655, 5, 140, 70, 7, GREEN); // x, y, width, height, color
display.setCursor(680, 30);
display.setTextColor(BLACK);
display.setTextSize(4);
display.print("STBY");
}
void loop() {
uint8_t contacts;
GDTpoint_t points[5];
// Read the touch screen
contacts = touchDetector.getTouchPoints(points);
if (contacts > 0) {
// Serial.print ("TouchX" + String(points[0].x));
//Serial.print (" touchY= ");
//Serial.println (points[0].y);
if (points[0].x >= 410 && points[0].x <= 500 && points[0].y >= 660 && points[0].y <= 800) {
if (!RecMode) {
display.fillRoundRect(655, 5, 140, 70, 7, RED); // x, y, width, height, color
display.setCursor(680, 30);
display.setTextColor(BLACK);
display.setTextSize(4);
display.print("REC");
RecMode = true;
} else {
display.fillRoundRect(655, 5, 140, 70, 7, GREEN); // x, y, width, height, color
display.setCursor(680, 30);
display.setTextColor(BLACK);
display.setTextSize(4);
display.print("STBY");
RecMode = false;
}
Serial.println(RecMode);
delay(100); // Simple debounce
}
}
}
when I touch it gives me multiple 01010
I tried various delays….
By the way what’s the correct way to debounce without delay?
Thanks a lot
Mitch
