Hello,
I have a touch screen problem. Normally, point 0.0 is located in one of the corners. I find myself around the middle of the display. In the upper half I have negative values and in the bottom positive to about 700.
How can I start the coordinates in one of the corners.
I use pro mini 328 3.3V
#include <ILI9341_due.h>
#include <ILI9341_due_config.h>
#include <SystemFont5x7.h>#include "fonts/allFonts.h"
//#include <SPI.h>
//#include "Adafruit_GFX.h"
//#include "Adafruit_ILI9341.h"
#include "URTouch.h"#define ILI9341_ALICEBLUE 0xF7DF
#define ILI9341_ANTIQUEWHITE 0xFF5A
#define ILI9341_AQUA 0x07FF
#define ILI9341_AQUAMARINE 0x7FFA
#define ILI9341_AZURE 0xF7FF
#define ILI9341_BEIGE 0xF7BB
#define ILI9341_BISQUE 0xFF38//#define ILI9341_SPI_CLKDIVIDER SPI_CLOCK_DIV2
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 8
//#define TFT_MISO 12
//#define TFT_MOSI 11
//#define TFT_CLK 13ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, TFT_RST);
#define t_SCK 3
#define t_CS 4
#define t_MOSI 5
#define t_MISO 6
#define t_IRQ 7URTouch ts(t_SCK, t_CS, t_MOSI, t_MISO, t_IRQ);
int x, y,pos_x,pos_y;
void setup(){
tft.begin();
// tft.getDisplayStatus();SPI_CLOCK_DIV8 ;
tft.setRotation(iliRotation90);
tft.fillScreen(ILI9341_BLACK);ts.InitTouch();
ts.setPrecision(PREC_EXTREME);Ecran(110,30,100,60,ILI9341_ALICEBLUE,ILI9341_RED);
Button1(20,120,ILI9341_BLUE,ILI9341_WHITE,'<');
Ecran(120,120,80,40,ILI9341_CYAN,ILI9341_BLUE);
Button1(220,120,ILI9341_BLUE,ILI9341_WHITE,' >');
Button2(20,180,ILI9341_GREEN,ILI9341_WHITE,"Start");
Button2(200,180,ILI9341_RED,ILI9341_WHITE," Stop");
}void loop(){
// put your main code here, to run repeatedly:
waitfortouch(&pos_x,&pos_y);
tft.cursorToXY(0,0);tft.print("x=");tft.print(pos_x);
tft.cursorToXY(0,30);tft.print("y=");tft.print(pos_y);
// if (pos_x > 20 && pos_x < 100 && pos_y > 120 && pos_y < 160){tft.cursorToXY(135,145);tft.print('+');}}
void Button1(int16_t x, int16_t y, uint16_t color_bn, uint16_t color_bd,char ime ){
tft.fillRoundRect(x,y,80,40,20,color_bn);
tft.drawRoundRect(x,y,80,40,20,color_bd);
tft.setFont(SystemFont5x7);
tft.setTextColor(color_bd, color_bn);
tft.setTextScale(2);
tft.cursorToXY(x+33,y+13);
tft.print(ime);
}void Button2(int16_t x, int16_t y, uint16_t color_bn, uint16_t color_bd,char *ime ){
tft.fillRoundRect(x,y,100,40,20,color_bn);
tft.drawRoundRect(x,y,100,40,20,color_bd);
tft.setFont(SystemFont5x7);
tft.setTextColor(color_bd, color_bn);
tft.setTextScale(2);
tft.cursorToXY(x+13,y+13);
tft.print(ime);
}void Ecran(int16_t x, int16_t y,int16_t w, int16_t h, uint16_t color_bn, uint16_t color_bd){
tft.fillRoundRect(x,y,w,h,10,color_bn);
tft.drawRoundRect(x,y,w,h,10,color_bd);
}void waitfortouch(unsigned short int *pos_x,unsigned short int *pos_y){
do
{
delay(10);
if (ts.dataAvailable() == true)
{
ts.read();
*pos_x = ts.getX(); //Get touch point
*pos_y = ts.getY();
return;
}
}while(ts.dataAvailable()==false);
}