Hello I’m trying to program my SEEED TFT touch shield V2.0 so far I got it so theirs different options and depending on what option you press a LED turns on, off, or blinks, what I want to do is have it so if you press option 1 for example it would go into a sub menu and have different options in that sub menu. My question is how would I 1. clear the screen 2. reassign the areas that you press and 3. if I wanted to go back how would I bring up the main menu with out it refreshing a bunch? Here’s my code so far:
#include <stdint.h>
#include <SeeedTouchScreen.h>
#include <TFTv2.h>
#include <SPI.h>
TouchScreen ts = TouchScreen(XP, YP, XM, YM);
int led = 53;
void setup()
{
TFT_BL_ON;
Tft.TFTinit();
Tft.fillRectangle(50,100,150,50,RED);
Tft.fillRectangle(50,170,150,50, YELLOW);
Tft.fillRectangle(0,0,500,70,GREEN);
Tft.fillRectangle(50,240,150,50, BLUE);
Tft.drawString(“MAIN MENU”,0,20,3,WHITE);
Tft.drawString(“OPTION 1”, 50,120,3,WHITE);
Tft.drawString(“OPTION 2”,50,180,3, WHITE);
Tft.drawString(“OPTION 3” ,50,250,3,WHITE);
pinMode(led, OUTPUT);
}
void loop()
{
Point p = ts.getPoint();
p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);
p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);
if (p.z > __PRESURE) {
if(p.x > 50){
if(p.x < 200){
if(p.y > 80){
if( p.y < 130){
digitalWrite(led, HIGH);
}}}}
} if (p.z > __PRESURE) {
if(p.x > 50){
if(p.x < 200){
if(p.y > 150){
if( p.y < 220){
digitalWrite(led, LOW);
}}}}}
if (p.z > __PRESURE) {
if(p.x > 50){
if(p.x < 200){
if(p.y > 250){
if( p.y < 300){
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
}}}}}}