TFT_Extension Problem ?

Not sure if TFT_Extension is the problem. Using a 7" TFT, the portrait mode displays text and pushbuttons correctly but the pushbuttton touch areas are inverted. If the buttons are displayed side by side near the top the actual touch area is at the bottom and the bottom sides are swapped - in other words top = bottom and left = right. The usual portrait calibration was done and works fine as far as displaying in portrait.
The libraries are #include <UTFT.h>
#include <UTouch.h>
#include <UTFT_Buttons.h>
#include <TFT_Extension.h>

Also this line is shown in the “radio buttons” example as TFT_Extension myTFT(&myGLCD, &myTouch,PORTRAIT);
but it won’t compile unless PORTRAIT is deleted : TFT_Extension myTFT(&myGLCD, &myTouch); In addition its the same if LANDSCAPE is used instead of PORTRAIT.

Hardware is CTE70 CPLD 7" TFT and Mega2560 with shield. It works fine for an older sketch that uses the same libraries with landscape.

Touchtest.ino (1.84 KB)

Your file appears to be corrupted. Can you post the code here and put it in code tags? look for the <> at the top.

Earlier this morning I uninstalled Arduino and deleted the libraries, then downloaded arduino and all the libraries but it works just like before.

#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 0 //portrait - from calibration file
int panLeftRelay = 8; // Pan Left Touch Button
int panRightRelay = 9;

void setup()
{
pinMode(panLeftRelay, OUTPUT);
pinMode(panRightRelay, OUTPUT);

// setup LCD
myGLCD.InitLCD(0); //portrait
myGLCD.setFont(BigFont);
myGLCD.clrScr();

// Setup Touch Buttons
myTouch.InitTouch(0); //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(20,20,180,60,0)) //Draw Pan Left Button, ID = 0
{
digitalWrite(panLeftRelay, HIGH); //High when button is pressed
myGLCD.print(“Button 0”, 60, 200);

}
else
{
digitalWrite(panLeftRelay, LOW); // Low when button is not pressed
}

if (myTFT.TouchButton_Draw(220,20,380,60,1)) //Draw Pan Right Button, ID = 1

{
digitalWrite(panRightRelay, HIGH); // High when button is pressed
myGLCD.print(“Button 1”, 260, 200);
}
else
{
digitalWrite(panRightRelay, LOW);
}
}

Touchtest.ino (1.84 KB)

Ill take a look when I get home tonight.

This fixed it!! Its probably not the right way to do it but it works so far! Swapped X and Y values for the LANDSCAPE values in UTouchCD.h.Lines 20,21,22.

It's for the display calibration sketch.

define CAL_X 0x00568F45UL //landscape SWAPPED WITH Y

define CAL_Y 0x03E44044UL //landscape SWAPPED WITH X

define CAL_S 0x8031F1DFUL //landscape

There is a line in my library you can comment out and see if that solves the problem.

void TFT_Extension::DisplaySize()
{
DispX = _Disp->disp_x_size; // Global variable will be set to X
DispY = _Disp->disp_y_size; // ------------------------------ Y

if(_Disp->orient == LANDSCAPE) // comment out this line and fix your TouchCD file
Swap(DispX, DispY);
}

It didn't work. Commented it out and changed the calibration file back to normal (portrait). The touch buttons looked the same but didn't work. Changed it back to make sure it still works - it does.

That is strange, well atleast it works now.