What could been some issues with this code? Everytime we fix certain issues, as the compiler tells us, another issue will pop up.
#include <TftSpfd5408.h>
#include <pin_magic.h>
#include <registers.h>
#include <RH_ASK.h>
#include <SPI.h>
#include <SPFD5408_Adafruit_GFX.h>
#include <SPFD5408_Adafruit_TFTLCD.h>
#include <SPFD5408_TouchScreen.h>
RH_ASK driver;
#define TS_MINX 125
#define TS_MINY 85
#define TS_MAXX 965
#define TS_MAXY 905
#define YP A3
#define XM A2
#define YM 9
#define XP 8
// Define touch screen pressure thresholds
#define MINPRESSURE 10
#define MAXPRESSURE 1000
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define GOLD 0xFEA0
#define LIME 0xAFE5
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 364);
TftSpfd5408 tft; // declare an object of type TftSpfd5408
class TftSpfd5408 {
public:
TftSpfd5408();
// other member functions
uint8_t textsize; // add this line to declare the textsize variable
};
void TftSpfd5408::init() {
// other code
textsize = 1; // initialize the textsize variable
}
void setup() {
tft.setRotation(1); // adjust the screen orientation as needed
}
void loop() {
tft.fillScreen(WHITE);
tft.drawRoundRect(0, 0, 319, 240, 8, WHITE); //Page border
tft.fillRoundRect(30, 40, 100, 40, 8, GOLD);
tft.drawRoundRect(30, 40, 100, 40, 8, WHITE); //Dish1
tft.fillRoundRect(30, 90, 100, 40, 8, GOLD);
tft.drawRoundRect(30, 90, 100, 40, 8, WHITE); //Dish2
tft.fillRoundRect(30, 140, 100, 40, 8, GOLD); //Dish3
tft.drawRoundRect(30, 140, 100, 40, 8, WHITE);
tft.setCursor(60, 0);
tft.setTextSize(3);
tft.setTextColor(LIME);
tft.print(" Menu");
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(37, 47);
tft.print(" Dish1");
TSPoint p = ts.getPoint();
p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
p.y = map(p.y, TS_MAXY, TS_MINY, 0, 240);
if (p.x > 180 && p.x < 280 && p.y > 190 && p.y < 230 && p.z > MINPRESSURE && p.z < MAXPRESSURE)
{
Serial.println("Dish1");
char* msg = "Dish1"; // declare and initialize the msg variable
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(1000);
tft.fillRoundRect(30, 40, 100, 40, 8, WHITE);
delay(70);
tft.fillRoundRect(30, 40, 100, 40, 8, GOLD);
tft.drawRoundRect(30, 40, 100, 40, 8, WHITE);
tft.setCursor(37, 47);
tft.print(" Dish1");
delay(70);
}
}