My problem statement is given below with TFT touch screen code-
#define TS_MINX 204
#define TS_MINY 195
#define TS_MAXX 948
#define TS_MAXY 910
How can i find out this calibrated value if i am using 3.5 TFT touch display?
Which libraries required for my TFT screen touch display?
where i have to put Top calibration and bottom calibration value in above code?
Note- For this code i am using Arduino Uno board .
@kunal112233, although your choice of Project Guidance wan't bad, I have moved your topic to the Display section.
It might help if you can provide the exact details of the display and your code (using code tags).
Install MCUFRIEND_kbv and Adafruit_GFX via the IDE Library Manager.
Run all the library examples.
If you have a problem quote example by name.
David.
Here i am going to attached my GUI button for LED ON/OFF along with my code.
1.But i do not understand which calibrated value i have to insert in my calibration code?
2. How to get this calibration value as given below-
#define MINPRESSURE 200------- How to set this value in my code?
#define MAXPRESSURE 1000
#define TS_MINX 204
#define TS_MINY 195
#define TS_MAXX 948
#define TS_MAXY 910
Note- Also i am going to attached my GUI Picture as given below-
#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TouchScreen.h>
//#include <Fonts/FreeMonoOblique9pt7b.h>
#define MINPRESSURE 200
#define MAXPRESSURE 1000
const int XP = 8, XM = A2, YP = A3, YM = 9; //ID=0x7789
const int TS_LEFT = 128, TS_RT = 916, TS_TOP = 921, TS_BOT = 88;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
#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 myLED 53
int pixel_x, pixel_y; //Touch_getXY() updates global vars
bool Touch_getXY(void) {
TSPoint p = ts.getPoint();
pinMode(YP, OUTPUT); //restore shared pins
pinMode(XM, OUTPUT);
digitalWrite(YP, HIGH); //because TFT control pins
digitalWrite(XM, HIGH);
bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
if (pressed) {
pixel_x = map(p.y, TS_TOP, TS_BOT, 0, 320); //.kbv makes sense to me
pixel_y = map(p.x, TS_RT, TS_LEFT, 0, 480);
}
return pressed;
}
void setup() {
Serial.begin(9600);
pinMode(myLED, OUTPUT);
tft.reset();
tft.begin(0x9486);
tft.setRotation(1); //0-Portrait 1-Landscape
page1();
delay(3000);
//page2();
}
void page1() {
tft.fillRect(30, 90, 190, 150, BLUE);
tft.drawRect(30, 90, 190, 150, WHITE);
tft.setCursor(50, 160);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print("ON/OFF");
tft.setCursor(50, 200);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.print("LIGHTS");
----- How can i get this touch calibration as given below so that my LED ON/OFF gui button work Properly?-------
bool down = Touch_getXY();
while (!down) {
down = Touch_getXY();
if (pixel_x > 30 && pixel_x < 300 && pixel_y > 190 && pixel_y < 130) { //LED on
//digitalWrite(myLED, HIGH);
//down = false;
}
else if (pixel_x > 180 && pixel_x < 280 && pixel_y > 180 && pixel_y < 220) { //LED off
digitalWrite(myLED, LOW);
down = false;
}
else{
down = false;
}
How can i design GUI Button on MCUFRIEND TFT Screen 3.5?
How to calibrate Top-axis and Bottom-axis ?
How can i make GUI button for my TFT Screen ?
How can i resolve my LED ON/OFF Touch calibration issue?
issues- whenever i press LED ON/OFF Gui button it can not calibrate , How can i make my calibration correctly?
First off. Please Run all the library examples.
They will show you how to calibrate your 3.5 inch screen.
Then you can use the calibrated values in your sketch.
And yes, readers will help you.
However, you get off to a bad start when you say:
const int XP = 8, XM = A2, YP = A3, YM = 9; //ID=0x7789
const int TS_LEFT = 128, TS_RT = 916, TS_TOP = 921, TS_BOT = 88;
I know that 3.5 inch screens do not have a ST7789 controller.
Which suggests that you have not followed the advice.
Likewise, you have not posted code in a proper code window.
Which implies that you have not read the Forum guidelines.
I am quite happy to spend time with beginners. And help to get your project working.
It is these little acts of politeness that makes the Forum operate nicely.
I wash my car before it goes to the garage for its annual MOT test.
A clean car makes a happier mechanic. Less chance that it fails !!
David.
This topic also LOCKED as the OP has too many posts about the same display.
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.
Continued cross posting could result in a time out from the forum.
Could you also take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.