can anyone help me, I have tried both of the following
void loop() {
// Check for button presses
int touchX, touchY;
if (tft.getTouchRaw(&touchX, &touchY)) {
int btnIndex = touchX / (TFT_WIDTH / NUM_BUTTONS);
if (btnIndex >= 0 && btnIndex < NUM_BUTTONS) {
btnClickHandlers[btnIndex]();
}
}
and also
void loop() {
// Check for button presses
if (tft.getTouch(&touchX, &touchY)) {
int btnIndex = touchX / (TFT_WIDTH / NUM_BUTTONS);
if (btnIndex >= 0 && btnIndex < NUM_BUTTONS) {
btnClickHandlers[btnIndex]();
}
}
}
and get the following error when compiling
no matching function for call to 'TFT_eSPI: :getTouch (int, int)
and this one
no matching function for call to 'TFT_eSPI: :getTouchRaw (int, int)
BTW the code is being written by ChatGPT and is as follows
include
include
include
define TFT_WIDTH 800
define TFT_HEIGHT 480
TFT_eSPI tft = TFT_eSPI(); // Initialize the display
can anyone help me, I have tried both of the following void loop() { // Check for button presses int touchX, touchY; if (tft.getTouchRaw(&touchX, &touchY)) { int btnIndex = touchX / (TFT_WIDTH / NUM_BUTTONS); if (btnIndex >= 0 && btnIndex < NUM_BUTTONS) { btnClickHandlers[btnIndex](); } } and also void loop() { // Check for button presses if (tft.getTouch(&touchX, &touchY)) { int btnIndex = touchX / (TFT_WIDTH / NUM_BUTTONS); if (btnIndex >= 0 && btnIndex < NUM_BUTTONS) { btnClickHandlers[btnIndex](); } } } and get the following error when compiling
no matching function for call to 'TFT_eSPI: :getTouch (int, int)
and this one no matching function for call to 'TFT_eSPI: :getTouchRaw (int, int)
BTW the code is being written by ChatGPT and is as follows
include
include
include
define TFT_WIDTH 800
define TFT_HEIGHT 480
TFT_eSPI tft = TFT_eSPI(); // Initialize the display
// Button positions
define BTN_WIDTH 150
define BTN_HEIGHT 50
define BTN_MARGIN 20
define BTN_START_X 50
define BTN_START_Y 50
// Button colors
define BTN_COLOR 0x7E0 // Green
define BTN_TEXT_COLOR TFT_WHITE
// Button variables
define NUM_BUTTONS 4
const char *buttonLabels[NUM_BUTTONS] = {"Homing", "Speed +", "Speed -", "Start"}; const uint16_t buttonColors[NUM_BUTTONS] = {TFT_RED, TFT_BLUE, TFT_BLUE, TFT_GREEN}; const uint16_t buttonTextColor[NUM_BUTTONS] = {TFT_WHITE, TFT_WHITE, TFT_WHITE, TFT_BLACK};
// WiFi credentials const char ssid = "YourWiFiSSID"; const char password = "YourWiFiPassword";
WiFiServer server(80);
// Button click handlers void btnHomingClicked() { // Handle homing button click Serial.println("Homing button clicked"); }
void btnSpeedIncClicked() { // Handle speed increase button click Serial.println("Speed increase button clicked"); }
void btnSpeedDecClicked() { // Handle speed decrease button click Serial.println("Speed decrease button clicked"); }
void btnStartClicked() { // Handle start button click Serial.println("Start button clicked"); }
// Button click handlers array void (*btnClickHandlers[NUM_BUTTONS])() = {btnHomingClicked, btnSpeedIncClicked, btnSpeedDecClicked, btnStartClicked};
void setup() { Serial.begin(115200);
}
void loop() { // Check for button presses int touchX, touchY; if (tft.getTouchRaw(&touchX, &touchY)) { int btnIndex = touchX / (TFT_WIDTH / NUM_BUTTONS); if (btnIndex >= 0 && btnIndex < NUM_BUTTONS) { btnClickHandlers[btnIndex](); } } }