Hi HazardsMind,
Heres the code. The only things that i should have changed is for my controller and touch, button sizes and the on screen data.
Dizzwold.
#include <UTFT.h>
#include <UTouch.h>
#include <TFT_Extension.h>
UTFT myGLCD(ILI9327, 38, 39, 40, 41);
UTouch myTouch( 6, 5, 4, 3, 2);
TFT_Extension myTFT(&myGLCD, &myTouch);
#include <VirtualWire.h>
char remote[4] = {'X', 'Y', 'Z', '\0'};
byte Data = 0;
extern uint8_t SmallFont[];
void setup()
{
//Serial.begin(57600);
// Initialise the IO and ISR
vw_setup(2000); // Bits per sec, must match receiver.
vw_set_tx_pin(51); // Data Pin, change for your needs
myGLCD.InitLCD(LANDSCAPE);
myGLCD.clrScr();
myGLCD.setFont(SmallFont);
myTouch.InitTouch(LANDSCAPE);
myTouch.setPrecision(PREC_MEDIUM);
//pinMode(53, OUTPUT); // for my purposes
//digitalWrite(53, HIGH); // for my purposes
myTFT.ExtSetup();
myTFT.SetLatchButtonColors(0, GREEN, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(0, "Menu 2", "Menu 1", Small, WHITE);
myGLCD.fillScr(BLACK);
}
void loop()
{
static byte last = 255, lastMenu = 255;
byte MenuButton = myTFT.LatchButton_Draw(110, 190, 290, 220, 0);
if (MenuButton != lastMenu) // set button colors
{
lastMenu = MenuButton;
if (MenuButton == 0)
Menu_1();
else
Menu_2();
myTFT.ResetAllLatchButton();
}
bitWrite(Data, 0, myTFT.LatchButton_Draw(10, 10, 90, 80, 1 + (MenuButton ? 8 : 0)));
bitWrite(Data, 1, myTFT.LatchButton_Draw(110, 10, 190, 80, 2 + (MenuButton ? 8 : 0)));
bitWrite(Data, 2, myTFT.LatchButton_Draw(210, 10, 290, 80, 3 + (MenuButton ? 8 : 0)));
bitWrite(Data, 3, myTFT.LatchButton_Draw(310, 10, 390, 80, 4 + (MenuButton ? 8 : 0)));
bitWrite(Data, 4, myTFT.LatchButton_Draw(10, 100, 90, 170, 5 + (MenuButton ? 8 : 0)));
bitWrite(Data, 5, myTFT.LatchButton_Draw(110, 100, 190, 170, 6 + (MenuButton ? 8 : 0)));
bitWrite(Data, 6, myTFT.LatchButton_Draw(210, 100, 290, 170, 7 + (MenuButton ? 8 : 0)));
bitWrite(Data, 7, myTFT.LatchButton_Draw(310, 100, 390, 170, 8 + (MenuButton ? 8 : 0)));
if (MenuButton == 0)
remote[1] = Data;
else
remote[2] = Data;
if (Data != last) // Debug and see what the value is
/*{
myGLCD.setColor(BLACK);
myGLCD.print(" ", 0, 220);
myGLCD.printNumI(int(Data), 0, 220);
last = Data;
}*/
if (Data == 0)
{
remote[0] = 'X';
remote[1] = 0xFF;
remote[2] = 0xFF;
}
else
remote[0] = 'A';
//myGLCD.printChar(remote[0], 0, 200);
vw_send((uint8_t *)remote, strlen(remote));
}
void Menu_1()
{
myGLCD.clrScr();
myTFT.SetLatchButtonColors(1, PURPLE, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(1, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(2, PURPLE, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(2, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(3, PURPLE, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(3, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(4, PURPLE, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(4, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(5, PURPLE, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(5, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(6, PURPLE, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(6, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(7, PURPLE, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(7, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(8, PURPLE, BLUE, FILL, ROUNDED);
myTFT.SetLatchButtonText(8, "ON", "OFF", Small, WHITE);
//myTFT.SetLatchButtonColors(0, GREEN, BLUE, FILL, ROUNDED);
//myTFT.SetLatchButtonText(0, "Menu 2", "Menu 1", Small, WHITE);
}
void Menu_2()
{
// myGLCD.clrScr();
myTFT.SetLatchButtonColors(1 + 8, PURPLE, GREEN, FILL, ROUNDED);
myTFT.SetLatchButtonText(1 + 8, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(2 + 8, PURPLE, GREEN, FILL, ROUNDED);
myTFT.SetLatchButtonText(2 + 8, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(3 + 8, PURPLE, GREEN, FILL, ROUNDED);
myTFT.SetLatchButtonText(3 + 8, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(4 + 8, PURPLE, GREEN, FILL, ROUNDED);
myTFT.SetLatchButtonText(4 + 8, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(5 + 8, PURPLE, GREEN, FILL, ROUNDED);
myTFT.SetLatchButtonText(5 + 8, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(6 + 8, PURPLE, GREEN, FILL, ROUNDED);
myTFT.SetLatchButtonText(6 + 8, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(7 + 8, PURPLE, GREEN, FILL, ROUNDED);
myTFT.SetLatchButtonText(7 + 8, "ON", "OFF", Small, WHITE);
myTFT.SetLatchButtonColors(8 + 8, PURPLE, GREEN, FILL, ROUNDED);
myTFT.SetLatchButtonText(8 + 8, "ON", "OFF", Small, WHITE);
//myTFT.SetLatchButtonColors(0, GREEN, BLUE, FILL, ROUNDED);
//myTFT.SetLatchButtonText(0, "Menu 2", "Menu 1", Small, WHITE);
}/code]