LusoRobótica - Robótica em Português
Discussão Geral => Ideias => Tópico iniciado por: delphi em 15 de Maio de 2009, 14:32
-
Olá,
Nas minhas pesquisas por touch screens, encontrei este http://www.dealextreme.com/details.dx/sku.3259 (http://www.dealextreme.com/details.dx/sku.3259) (além deste, lá tem muitos mais para telemóveis, pdas, ...).
Fazer um projecto em que o arduino "comunique" com estes touchscreens é relativamente fácil:
- geralmente estes paineis tem 4 pins (designamos por pin 1, 2, 3 e 4, independentemente de que lado se comece a contar);
- no pin 1 "damos" 5V e no pin 3 0V. Lemos o valor do pin 2, ou 4, e obtemos a posição de uma das coordenadas. Para obter a outra coordenada, fazemos o mesmo para os pins 2 e 4 e lemos o valor do 1 ou do 3.
(Assim que os receber coloco aqui o tutorial. Isto porque depois de conseguir que funcionasse, o touch que eu tinha, de 7", levou um aperto maior do que a sua capacidade de resistência e ... partiu-se).
Penso que desta forma conseguimos assim dar mais "inputs" ao nosso arduino (ou outro qualquer micro).
Por ex.: em vez de termos um teclado, podemos ter o desenho de um teclado impresso e colar por trás do touch, e sabendo em que posição se encontra cada "tecla", sabemos o que foi pressionado. O mesmo pode ser para simular botões, para simular barras de deslizamento, como estou a fazer para controlar os meus leds RGBs. Neste caso, tenho desenhadas várias barras e botões, onde sei que ao pressionar em determinado "botão" coloco o led a azul, se pressionar no outro "botão" fica apenas a vermelho (ou encarnado :) ), noutro ainda a verde, se deslizar o dedo sobre a barra de deslizamento (scroll bar) sei que é para aumentar ou diminuir a intensidade.
Sem qualquer código ou imagens, é apenas teoria, mas em breve coloco um exemplo a "mexer".
-
Muito baratinho e ainda por cima "free shipping" segundo eles!
Dá o teu melhor e partilha os teus resultados connosco! :D Força com os teus projectos!
ps: chegaste a conseguir controlar o ecra de uma moldura digital com o arduino?
-
realmente...mesmo barato! :o
fico a espera desse tutorial entao :D
-
Isto para mim é bom demais para ser verdade, mas se correr tudo bem com a encomenda diz que eu tambem mando vir um :D :D
-
Já comprei dessa loja antes e correu tudo bem ;)
-
Fico à espera desse tutorial também.
Ainda fazemos uma touchshield Lusorobótica. :-D
-
Boas! Como faço para conectar entre o Nintendo DS Touch Screen e o arduino?
Uso algum destes conectores?
http://shop.ebay.co.uk/?_from=R40&_trksid=p3907.m38.l1313&_nkw=Nintendo+DS+Touch+Screen+Connector&_sacat=See-All-Categories (http://shop.ebay.co.uk/?_from=R40&_trksid=p3907.m38.l1313&_nkw=Nintendo+DS+Touch+Screen+Connector&_sacat=See-All-Categories)
http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector-breakout.html (http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector-breakout.html)
http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector.html (http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector.html)
Agradeço resposta
obrigado
-
Este aqui:
http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector-breakout.html (http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector-breakout.html)
Pois já está num pedacinho de pcb soldado, facil de usar, é só meter uns fios ou uns headers, agora código deves ter de fazer tu o teu.
-
Exte conector dá para este touch screen que comprei na Dealxtreme???, eu comprei dois
Tipo na Sparkfun os portes são um bocado caros, como faço para serem mais baratos?
E naquele link acima dakela loja não sei os portes, e não sei se e confiavel pois não vi ninguem comprar por la!
http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector-breakout.html (http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector-breakout.html)
Cumps
-
A unica maneira de ficares com portes mais baratos é comprares a meias com alguem ou comprar logo muita coisa para nem se notar o valor dos portes, podes sempre falar com o tigpt, pois a loja da lusorobótica é representante da sparkfun.
Para saberes os portes manda para lá um mail e pergunta.
-
A unica maneira de ficares com portes mais baratos é comprares a meias com alguem ou comprar logo muita coisa para nem se notar o valor dos portes, podes sempre falar com o tigpt, pois a loja da lusorobótica é representante da sparkfun.
Para saberes os portes manda para lá um mail e pergunta.
Não te preocupes, se pagares com paypal, eles protejem o comprador, caso for burla.
-
A unica maneira de ficares com portes mais baratos é comprares a meias com alguem ou comprar logo muita coisa para nem se notar o valor dos portes, podes sempre falar com o tigpt, pois a loja da lusorobótica é representante da sparkfun.
Para saberes os portes manda para lá um mail e pergunta.
Obrigado! Mas já alguem aqui comprou pela loja http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector-breakout.html (http://www.nkcelectronics.com/nintendo-ds-touch-screen-connector-breakout.html) ?
Algum deste produtos do ebay e também um conector compativel? http://shop.ebay.co.uk/?_from=R40&_trksid=p3907.m38.l1313&_nkw=Nintendo+DS+Touch+Screen+Connector&_sacat=See-All-Categories (http://shop.ebay.co.uk/?_from=R40&_trksid=p3907.m38.l1313&_nkw=Nintendo+DS+Touch+Screen+Connector&_sacat=See-All-Categories)
Obrigado a todos
-
Quase todos são, é só ver a fotografia, mas não sei se consegues soldar isso...
Eu comprava daqui:
http://cgi.ebay.co.uk/nintendo-ds-lite-replacement-touch-screen-connector-P6_W0QQitemZ260566234101QQcmdZViewItemQQptZUK_VideoGames_VideoGameAccessories_VideoGameAccessories_JN?hash=item3caaf533f5 (http://cgi.ebay.co.uk/nintendo-ds-lite-replacement-touch-screen-connector-P6_W0QQitemZ260566234101QQcmdZViewItemQQptZUK_VideoGames_VideoGameAccessories_VideoGameAccessories_JN?hash=item3caaf533f5)
Já vendeu 14 e tem um bom feedback.
E este ainda melhor é:
http://cgi.ebay.co.uk/DS-lite-P6-touch-screen-connector-clip-for-motherboard_W0QQitemZ220413951265QQcmdZViewItemQQptZUK_VideoGames_VideoGameAccessories_VideoGameAccessories_JN?hash=item3351b1fd21 (http://cgi.ebay.co.uk/DS-lite-P6-touch-screen-connector-clip-for-motherboard_W0QQitemZ220413951265QQcmdZViewItemQQptZUK_VideoGames_VideoGameAccessories_VideoGameAccessories_JN?hash=item3351b1fd21)
-
Quase todos são, é só ver a fotografia, mas não sei se consegues soldar isso...
Eu comprava daqui:
http://cgi.ebay.co.uk/nintendo-ds-lite-replacement-touch-screen-connector-P6_W0QQitemZ260566234101QQcmdZViewItemQQptZUK_VideoGames_VideoGameAccessories_VideoGameAccessories_JN?hash=item3caaf533f5 (http://cgi.ebay.co.uk/nintendo-ds-lite-replacement-touch-screen-connector-P6_W0QQitemZ260566234101QQcmdZViewItemQQptZUK_VideoGames_VideoGameAccessories_VideoGameAccessories_JN?hash=item3caaf533f5)
Já vendeu 14 e tem um bom feedback.
E este ainda melhor é:
http://cgi.ebay.co.uk/DS-lite-P6-touch-screen-connector-clip-for-motherboard_W0QQitemZ220413951265QQcmdZViewItemQQptZUK_VideoGames_VideoGameAccessories_VideoGameAccessories_JN?hash=item3351b1fd21 (http://cgi.ebay.co.uk/DS-lite-P6-touch-screen-connector-clip-for-motherboard_W0QQitemZ220413951265QQcmdZViewItemQQptZUK_VideoGames_VideoGameAccessories_VideoGameAccessories_JN?hash=item3351b1fd21)
tens a certeza que esses conectores são compatíveis com este touch screen?
-
Olha, eles dizem que sim, por isso devem ser.
-
Olá,
Há uns tempos numas brincadeiras com o arduino e um touchscreen nintendo (penso que o princípio aplica-se a todos touchscreens) resultou o seguinte código.
A ideia era de fazer do touchscreen um "interruptor" para controlar as luzes (nesta experiência com LEDs RGBs) e assim podia mudar de cor como pretendesse (era para um bar).
Comprei na sparkfun o BOB-09170 Nintendo DS Touch Screen Connector Breakout, e na dealxtreme comprei estes touchscreens http://www.dealextreme.com/details.dx/sku.3259 (http://www.dealextreme.com/details.dx/sku.3259)
A imagem que coloquei no touchscreen não tenho aqui, mas facilmente se altera o código para outra imagem qualquer.
O código não é o último que tenho e por isso não está acabado (por ex. em vez de utilizar delay, pode utilizar interrupts,..., mas penso que serve para mostrar como se pode controlar um touchscreen com o arduino. Por ex. o código está começado para ser possível definir e utilizar vários skins mas não está finalizado, falta tambem uma função para calibrar,...
Espero que ajude.
#define XLOW 10
#define YLOW 10
//initial skin selected
int skinNum = 0;
//total skins
int maxSkins = 1;
boolean toprint = true;
// Output
int redPin = 11; // Red LED, connected to digital pin 9
int greenPin = 10; // Green LED, connected to digital pin 10
int bluePin = 9; // Blue LED, connected to digital pin 11
// Program variables
int redVal = 0; // Variables to store the values to send to the pins
int greenVal = 0; // Initial values are Red full, Green and Blue off
int blueVal = 0;
int activeColor = -1;
int maxX = 960;
int maxY = 870;
// variables for input pin and control LED
int Xplus = 0;//x1
int Xminus = 3; //y2
int Yplus = 1; //
int Yminus = 2; //
int nowTouching = 0;
boolean sendNoTouch = true;
int xval = 0;
int yval = 0;
int stepX = 5;
int oldxval = 0;
void setup(){
xval = measureX();
yval = measureY();
checkTouch();
pinMode(redPin, OUTPUT); // sets the pins as output
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
Serial.begin(9600);
Serial.println("Setup Ok");
}
int measureX()
{
PORTC = (0<<Yplus)|(0<<Yminus)|(1<<Xplus)|(0<<Xminus);
DDRC = (0<<Yplus)|(0<<Yminus)|(1<<Xplus)|(1<<Xminus);
delay(10);
int aux = analogRead(Yminus);
if (aux > maxX) { return 0; }
else { return maxX - aux; }
}
int measureY()
{
PORTC = (1<<Yplus)|(0<<Yminus)|(0<<Xplus)|(0<<Xminus);
DDRC = (1<<Yplus)|(1<<Yminus)|(0<<Xplus)|(0<<Xminus);
delay(10);
int aux = analogRead(Xplus);
if (aux > maxY) { return 0; }
else { return maxY - aux; }
}
int checkTouch()
{
PORTC = B0010;
DDRC = B0001;
return digitalRead(Xminus);
}
void loop()
{
//-leitura das coordenadas
xval = measureX();
yval = measureY();
checkTouch();
nowTouching = !(xval < XLOW | yval < YLOW);
//-se não está a tocar, verifica se antes tambem não estava
if (!nowTouching)
{
if (sendNoTouch)
{
checkTouch();
Serial.print("0,0,0");
Serial.println();
};
sendNoTouch = false;
delay(10);
} else
{
Serial.print("X=");
Serial.print(xval, DEC);
Serial.print("; Y=");
Serial.print(yval, DEC);
int button = getPlace(xval, yval);
if (button != -1)
{
executeAction (button);
Paint();
Serial.print(" botao: ");
Serial.print(button);
}
Serial.println();
sendNoTouch = true;
oldxval = xval;
}
}
//-onPanelClick
void executeAction(int button)
{
if (skinNum == 0)
{
executeSkin0(button);
};
}
void nextSkin()
{
if (skinNum == (maxSkins -1 )) skinNum = -1;
skinNum = skinNum + 1;
}
void executeSkin0(int button)
{
if (button == 11 )//-all off
{
activeColor = -1;
redVal = 0;
greenVal = 0;
blueVal = 0;
}else if (button == 12 )//all on
{
activeColor = -1;
redVal = 255;
greenVal = 255;
blueVal = 255;
}else if (button == 5 )//red full
{
activeColor = 1;
redVal = 255;
}else if (button == 6 )//red off
{
activeColor = 1;
redVal = 0;
}else if (button == 7 )//green full
{
activeColor = 2;
greenVal = 255;
}else if (button == 8 )//green off
{
activeColor = 2;
greenVal = 0;
}else if (button == 9 )//blue full
{
activeColor = 3;
blueVal = 255;
}else if (button == 10 )//blue off
{
activeColor = 3;
blueVal = 0;
}else if (button == 3 )//up active color
{
fadeDown(true);
}else if (button == 4 )//down active color
{
fadeDown(false);
}
}
void fadeDown(boolean up)
{
if (!up)
{
if (activeColor == 1) { redVal = goodColor(redVal - stepX);}
else if (activeColor == 2) { greenVal = goodColor(greenVal - stepX);}
else if (activeColor == 3) { blueVal = goodColor(blueVal - stepX);}
} else
{
if (activeColor == 1) { redVal = goodColor(redVal + stepX);}
else if (activeColor == 2) { greenVal = goodColor(greenVal + stepX);}
else if (activeColor == 3) { blueVal = goodColor(blueVal + stepX);}
}
}
void nextColor()
{
activeColor = activeColor + 1;
if (activeColor == 4 ) {activeColor = 1;};
}
void Paint()
{
analogWrite(redPin, redVal);
analogWrite(greenPin, greenVal);
analogWrite(bluePin, blueVal);
Serial.print("redVal: ");
Serial.print(redVal);
Serial.print("greenVal: ");
Serial.print(greenVal);
Serial.print("blueVal:");
Serial.print(blueVal);
}
int goodColor(int value){
if (value<0) {return 0;}
else if (value>255) {value = 255;}
return value;
}
int getPlace(int x, int y)
{
if (skinNum == 0) {
if (b1() ) {return 1;}
if (b2() ) {return 2;}
if (b3() ) {return 3;}
/*
if (b4() ) {return 4;}
if (b5() ) {return 5;}
if (b6() ) {return 6;}
if (b7() ) {return 7;}
if (b8() ) {return 8;}
if (b9() ) {return 9;}
if (b10() ) {return 10;}
if (b11() ) {return 11;}
if (b12() ) {return 12;}
*/
}
return -1;
}
/////////////////////////////////////////////////////////////////////////////
//skin 1 begin
boolean b1()
{
return YouClickedMe(1, 140, 718, 30 ) ;
}
boolean b2()
{
return YouClickedMe(1, 84, 600, 30 ) ;
}
boolean b3()
{
return YouClickedMe(1, 25, 560, 30 ) ;
}
boolean b4()
{
return YouClickedMe(2, 180, 750, 100 ) ;
}
boolean b5()
{
return YouClickedMe(3, 726, 195, 100 ) ;
}
boolean b6()
{
return YouClickedMe(4, 726, 465, 100 ) ;
}
boolean b7()
{
return YouClickedMe(5, 505, 60, 100 ) ;
}
boolean b8()
{
return YouClickedMe(6, 505, 635, 100 ) ;
}
boolean b9()
{
return YouClickedMe(7, 325, 70, 100 ) ;
}
boolean b10()
{
return YouClickedMe(8, 325, 635, 100 ) ;
}
boolean b11()
{
return YouClickedMe(9, 150, 55, 100 ) ;
}
boolean b12()
{
return YouClickedMe(10, 150, 635, 100 ) ;
}
//skin 1 end
/////////////////////////////////////////////////////////////////////////////
boolean YouClickedMe(int index, int myX, int myY, int myR )//or not
{
//cálculo para saber se clicou no botao redondo x
//-formula (x-xa)(x-xa) + (y-xa)(y-xa) < R*R
int difX = (xval-myX);
int difY = (yval-myY);
double difXx2 = pow(difX, 2) ;
double difYx2 = pow(difY, 2);
long val = difXx2 + difYx2;
long raio2 = myR*myR;
if (val > 0 ) { return (val < raio2 ); }
return false;
}
-
Olá,
Há uns tempos numas brincadeiras com o arduino e um touchscreen nintendo (penso que o princípio aplica-se a todos touchscreens) resultou o seguinte código.
A ideia era de fazer do touchscreen um "interruptor" para controlar as luzes (nesta experiência com LEDs RGBs) e assim podia mudar de cor como pretendesse (era para um bar).
Comprei na sparkfun o BOB-09170 Nintendo DS Touch Screen Connector Breakout, e na dealxtreme comprei estes touchscreens http://www.dealextreme.com/details.dx/sku.3259 (http://www.dealextreme.com/details.dx/sku.3259)
A imagem que coloquei no touchscreen não tenho aqui, mas facilmente se altera o código para outra imagem qualquer.
O código não é o último que tenho e por isso não está acabado (por ex. em vez de utilizar delay, pode utilizar interrupts,..., mas penso que serve para mostrar como se pode controlar um touchscreen com o arduino. Por ex. o código está começado para ser possível definir e utilizar vários skins mas não está finalizado, falta tambem uma função para calibrar,...
Espero que ajude.
#define XLOW 10
#define YLOW 10
//initial skin selected
int skinNum = 0;
//total skins
int maxSkins = 1;
boolean toprint = true;
// Output
int redPin = 11; // Red LED, connected to digital pin 9
int greenPin = 10; // Green LED, connected to digital pin 10
int bluePin = 9; // Blue LED, connected to digital pin 11
// Program variables
int redVal = 0; // Variables to store the values to send to the pins
int greenVal = 0; // Initial values are Red full, Green and Blue off
int blueVal = 0;
int activeColor = -1;
int maxX = 960;
int maxY = 870;
// variables for input pin and control LED
int Xplus = 0;//x1
int Xminus = 3; //y2
int Yplus = 1; //
int Yminus = 2; //
int nowTouching = 0;
boolean sendNoTouch = true;
int xval = 0;
int yval = 0;
int stepX = 5;
int oldxval = 0;
void setup(){
xval = measureX();
yval = measureY();
checkTouch();
pinMode(redPin, OUTPUT); // sets the pins as output
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
Serial.begin(9600);
Serial.println("Setup Ok");
}
int measureX()
{
PORTC = (0<<Yplus)|(0<<Yminus)|(1<<Xplus)|(0<<Xminus);
DDRC = (0<<Yplus)|(0<<Yminus)|(1<<Xplus)|(1<<Xminus);
delay(10);
int aux = analogRead(Yminus);
if (aux > maxX) { return 0; }
else { return maxX - aux; }
}
int measureY()
{
PORTC = (1<<Yplus)|(0<<Yminus)|(0<<Xplus)|(0<<Xminus);
DDRC = (1<<Yplus)|(1<<Yminus)|(0<<Xplus)|(0<<Xminus);
delay(10);
int aux = analogRead(Xplus);
if (aux > maxY) { return 0; }
else { return maxY - aux; }
}
int checkTouch()
{
PORTC = B0010;
DDRC = B0001;
return digitalRead(Xminus);
}
void loop()
{
//-leitura das coordenadas
xval = measureX();
yval = measureY();
checkTouch();
nowTouching = !(xval < XLOW | yval < YLOW);
//-se não está a tocar, verifica se antes tambem não estava
if (!nowTouching)
{
if (sendNoTouch)
{
checkTouch();
Serial.print("0,0,0");
Serial.println();
};
sendNoTouch = false;
delay(10);
} else
{
Serial.print("X=");
Serial.print(xval, DEC);
Serial.print("; Y=");
Serial.print(yval, DEC);
int button = getPlace(xval, yval);
if (button != -1)
{
executeAction (button);
Paint();
Serial.print(" botao: ");
Serial.print(button);
}
Serial.println();
sendNoTouch = true;
oldxval = xval;
}
}
//-onPanelClick
void executeAction(int button)
{
if (skinNum == 0)
{
executeSkin0(button);
};
}
void nextSkin()
{
if (skinNum == (maxSkins -1 )) skinNum = -1;
skinNum = skinNum + 1;
}
void executeSkin0(int button)
{
if (button == 11 )//-all off
{
activeColor = -1;
redVal = 0;
greenVal = 0;
blueVal = 0;
}else if (button == 12 )//all on
{
activeColor = -1;
redVal = 255;
greenVal = 255;
blueVal = 255;
}else if (button == 5 )//red full
{
activeColor = 1;
redVal = 255;
}else if (button == 6 )//red off
{
activeColor = 1;
redVal = 0;
}else if (button == 7 )//green full
{
activeColor = 2;
greenVal = 255;
}else if (button == 8 )//green off
{
activeColor = 2;
greenVal = 0;
}else if (button == 9 )//blue full
{
activeColor = 3;
blueVal = 255;
}else if (button == 10 )//blue off
{
activeColor = 3;
blueVal = 0;
}else if (button == 3 )//up active color
{
fadeDown(true);
}else if (button == 4 )//down active color
{
fadeDown(false);
}
}
void fadeDown(boolean up)
{
if (!up)
{
if (activeColor == 1) { redVal = goodColor(redVal - stepX);}
else if (activeColor == 2) { greenVal = goodColor(greenVal - stepX);}
else if (activeColor == 3) { blueVal = goodColor(blueVal - stepX);}
} else
{
if (activeColor == 1) { redVal = goodColor(redVal + stepX);}
else if (activeColor == 2) { greenVal = goodColor(greenVal + stepX);}
else if (activeColor == 3) { blueVal = goodColor(blueVal + stepX);}
}
}
void nextColor()
{
activeColor = activeColor + 1;
if (activeColor == 4 ) {activeColor = 1;};
}
void Paint()
{
analogWrite(redPin, redVal);
analogWrite(greenPin, greenVal);
analogWrite(bluePin, blueVal);
Serial.print("redVal: ");
Serial.print(redVal);
Serial.print("greenVal: ");
Serial.print(greenVal);
Serial.print("blueVal:");
Serial.print(blueVal);
}
int goodColor(int value){
if (value<0) {return 0;}
else if (value>255) {value = 255;}
return value;
}
int getPlace(int x, int y)
{
if (skinNum == 0) {
if (b1() ) {return 1;}
if (b2() ) {return 2;}
if (b3() ) {return 3;}
/*
if (b4() ) {return 4;}
if (b5() ) {return 5;}
if (b6() ) {return 6;}
if (b7() ) {return 7;}
if (b8() ) {return 8;}
if (b9() ) {return 9;}
if (b10() ) {return 10;}
if (b11() ) {return 11;}
if (b12() ) {return 12;}
*/
}
return -1;
}
/////////////////////////////////////////////////////////////////////////////
//skin 1 begin
boolean b1()
{
return YouClickedMe(1, 140, 718, 30 ) ;
}
boolean b2()
{
return YouClickedMe(1, 84, 600, 30 ) ;
}
boolean b3()
{
return YouClickedMe(1, 25, 560, 30 ) ;
}
boolean b4()
{
return YouClickedMe(2, 180, 750, 100 ) ;
}
boolean b5()
{
return YouClickedMe(3, 726, 195, 100 ) ;
}
boolean b6()
{
return YouClickedMe(4, 726, 465, 100 ) ;
}
boolean b7()
{
return YouClickedMe(5, 505, 60, 100 ) ;
}
boolean b8()
{
return YouClickedMe(6, 505, 635, 100 ) ;
}
boolean b9()
{
return YouClickedMe(7, 325, 70, 100 ) ;
}
boolean b10()
{
return YouClickedMe(8, 325, 635, 100 ) ;
}
boolean b11()
{
return YouClickedMe(9, 150, 55, 100 ) ;
}
boolean b12()
{
return YouClickedMe(10, 150, 635, 100 ) ;
}
//skin 1 end
/////////////////////////////////////////////////////////////////////////////
boolean YouClickedMe(int index, int myX, int myY, int myR )//or not
{
//cálculo para saber se clicou no botao redondo x
//-formula (x-xa)(x-xa) + (y-xa)(y-xa) < R*R
int difX = (xval-myX);
int difY = (yval-myY);
double difXx2 = pow(difX, 2) ;
double difYx2 = pow(difY, 2);
long val = difXx2 + difYx2;
long raio2 = myR*myR;
if (val > 0 ) { return (val < raio2 ); }
return false;
}
Muito obrigado
-
(https://lusorobotica.com/proxy.php?request=http%3A%2F%2Fwww.micro-examples.com%2Fpics%2F079-TOUCHCLOCK-touchscreen.png&hash=2ba683d947b4b9233aac174a07f7032183daf5ee)
This is how the library reads the X raw coordinate of a touch :
X+ and X- are in high Z : RA0 and RA2 are inputs
Y+ is set to +5V : RA3 is output high
Y- is set to 0V : RA1 is output low
X+ voltage is read by ADC
Y+ is set to 0V : RA3 is output low
Y- is set to 5V: RA1 is output high
X- voltage is read by ADC and averaged with X+ value, the result is the raw X coordinate.
The same is then done to read the Y coordinate, please see TSlib.c file in .ZIP file above.
X and Y raw coordinates are then adjusted using calibration coordinates to get X and Y coordinates in pixel.
O essencial para ler xy do touchscreen