This has me at wits end.
This sample code works fine in LANDSCAPE mode but not in PORTRAIT mode. Portrait is needed for the next project. Before running the program I do a LCD calibration in the portrait mode. The touch butttons are displayed fine but they done operate. - they don't even change color from BLUE to ORANGE to indicate the button has been pressed. Hardware CTE70 GLCD, Arduino Mega 2560, Arduino Mega Shield
Thanks
CODE
#include <UTFT.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>
#include <TFT_Extension.h>
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
UTFT myGLCD(CTE70CPLD,38,39,40,41);
UTouch myTouch(6, 5, 4, 3, 2);
UTFT_Buttons myButtons(&myGLCD, &myTouch);
TFT_Extension myTFT(&myGLCD, &myTouch);
#define convert(x) {myTFT.ConvertRGB(x)}
//#define TOUCH_ORIENTATION PORTRAIT
int panLeftRelay = 8; // Pan Left Touch Button to Relay on pin 8 (D8)
int panRightRelay = 9;
void setup()
{
// setup LCD
myGLCD.InitLCD(PORTRAIT);
myGLCD.setFont(BigFont);
myGLCD.clrScr();
myTouch.InitTouch(PORTRAIT);
// Setup Touch Buttons
myTouch.InitTouch(PORTRAIT);
myTouch.setPrecision(PREC_MEDIUM);
myButtons.setTextFont(BigFont);
//TFT setup commands
myTFT.ExtSetup();
startup();
}
void loop()
{
getButton();
}
void startup()
{
myTFT.SetTouchButtonColors(0, ORANGE, BLUE, FILL, ROUNDED); // (ID number, Pressed Color, Released Color, FILL/NOFILL) Page 1
myTFT.SetTouchButtonColors(1, ORANGE, GREEN, FILL, ROUNDED); // ID number, Pressed Color, Released Color, FILL/NOFILL) Page 2
myTFT.SetTouchButtonText(0, "Page 1", Big, BLUE); // (Text, Font, Color)
myTFT.SetTouchButtonText(1, "Page 2", Big, BLUE); // (Text, Font, Color)
}
void getButton()
{
if (myTFT.TouchButton_Draw(60,80,220,120, 0)) //Draw Pan Left Button, ID = 0
{
digitalWrite(panLeftRelay, HIGH); //High when button is pressed
}
else
{
digitalWrite(panLeftRelay, LOW); // Low when button is not pressed
}
if (myTFT.TouchButton_Draw(260, 80, 420, 120, 1)) //Draw Pan Right Button, ID = 1
{
digitalWrite(panRightRelay, HIGH); // iHigh when button is pressed
}
else
{
digitalWrite(panRightRelay, LOW);
}
}