User | Revision | Line number | New contents of line |
apm_litoral |
0:d0e2979d7ed6
|
1
|
#include "touch_tft.h"
|
apm_litoral |
0:d0e2979d7ed6
|
2
|
#include "mbed.h"
|
apm_litoral |
0:d0e2979d7ed6
|
3
|
#include "Arial12x12.h"
|
apm_litoral |
0:d0e2979d7ed6
|
4
|
|
apm_litoral |
0:d0e2979d7ed6
|
5
|
#define threshold 10000
|
apm_litoral |
0:d0e2979d7ed6
|
6
|
|
apm_litoral |
0:d0e2979d7ed6
|
7
|
touch_tft::touch_tft(PinName xp, PinName xm, PinName yp, PinName ym, PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName bk, const char *name)
|
apm_litoral |
0:d0e2979d7ed6
|
8
|
:_xp(xp),_xm(xm),_yp(yp),_ym(ym),_ax(xp),_ay(yp), SPI_TFT(mosi,miso,sclk,cs,reset,bk,name) {
|
apm_litoral |
0:d0e2979d7ed6
|
9
|
xa = xp;
|
apm_litoral |
0:d0e2979d7ed6
|
10
|
ya = yp;
|
apm_litoral |
0:d0e2979d7ed6
|
11
|
|
apm_litoral |
0:d0e2979d7ed6
|
12
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
13
|
|
apm_litoral |
0:d0e2979d7ed6
|
14
|
/* Esta clase trae el valor de p, siendo "p" un puntero
|
apm_litoral |
0:d0e2979d7ed6
|
15
|
*
|
apm_litoral |
0:d0e2979d7ed6
|
16
|
*/
|
apm_litoral |
0:d0e2979d7ed6
|
17
|
point touch_tft::get_touch() { //puntero a touch clase get_touch
|
apm_litoral |
0:d0e2979d7ed6
|
18
|
unsigned short x1 = 0,x2 = 0, y1 = 0, y2 = 0;
|
apm_litoral |
0:d0e2979d7ed6
|
19
|
unsigned int s1 = 0,s2 = 0,d1 = 0 , d2 = 0;
|
apm_litoral |
0:d0e2979d7ed6
|
20
|
point p;
|
apm_litoral |
0:d0e2979d7ed6
|
21
|
|
apm_litoral |
0:d0e2979d7ed6
|
22
|
do {
|
apm_litoral |
0:d0e2979d7ed6
|
23
|
/******************************************************************************************/
|
apm_litoral |
0:d0e2979d7ed6
|
24
|
// lee el voltaje en Y
|
apm_litoral |
0:d0e2979d7ed6
|
25
|
_xp.output(); //define salidas para x+ y x-
|
apm_litoral |
0:d0e2979d7ed6
|
26
|
_xm.output();
|
apm_litoral |
0:d0e2979d7ed6
|
27
|
switch (orientation) {
|
apm_litoral |
0:d0e2979d7ed6
|
28
|
case(0): //En casos de orientacion 0 y 3
|
apm_litoral |
0:d0e2979d7ed6
|
29
|
case(3): //pone en alto el x+
|
apm_litoral |
0:d0e2979d7ed6
|
30
|
_xp = 1; //pone en bajo el x-
|
apm_litoral |
0:d0e2979d7ed6
|
31
|
_xm = 0;
|
apm_litoral |
0:d0e2979d7ed6
|
32
|
break;
|
apm_litoral |
0:d0e2979d7ed6
|
33
|
case(1): //sino lo contrario
|
apm_litoral |
0:d0e2979d7ed6
|
34
|
case(2):
|
apm_litoral |
0:d0e2979d7ed6
|
35
|
_xp = 0;
|
apm_litoral |
0:d0e2979d7ed6
|
36
|
_xm = 1;
|
apm_litoral |
0:d0e2979d7ed6
|
37
|
break;
|
apm_litoral |
0:d0e2979d7ed6
|
38
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
39
|
_ym.input(); // define y- como entrada para q sea "pasivo"
|
apm_litoral |
0:d0e2979d7ed6
|
40
|
AnalogIn Ay(ya); // define constructor analogico como Ay para el pin y+
|
apm_litoral |
0:d0e2979d7ed6
|
41
|
// wait_us(10);
|
apm_litoral |
0:d0e2979d7ed6
|
42
|
y1 = Ay.read_u16(); // trae el voltaje en y1 desde y+ en el rango de 0 a 65535
|
apm_litoral |
0:d0e2979d7ed6
|
43
|
d1 = (y1 > y2)? (y1-y2) : (y2-y1); // //condiciona si y1 es mayor q y2 entonces opera d1=y1-y2 y si no es correcto entonces opera d1=y2-y1
|
apm_litoral |
0:d0e2979d7ed6
|
44
|
if (((y1 < 8000) && (d1 < 2000)) || ((y1 > 8000) && (d1 < 150))) s1 ++; // si (y1<8000 Y d1<2000) O (y1>8000 Y d1<150)
|
apm_litoral |
0:d0e2979d7ed6
|
45
|
// 32768 8192 32768 336
|
apm_litoral |
0:d0e2979d7ed6
|
46
|
else {
|
apm_litoral |
0:d0e2979d7ed6
|
47
|
if (s1 > 0) s1=0; //entonces s1 = s1+1, sino pregunta si s1>0 entonces s1 = s1-1
|
apm_litoral |
0:d0e2979d7ed6
|
48
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
49
|
y2 = y1; //y2 es ahora igual a y1
|
apm_litoral |
0:d0e2979d7ed6
|
50
|
//debug
|
apm_litoral |
0:d0e2979d7ed6
|
51
|
//locate(1,7);
|
apm_litoral |
0:d0e2979d7ed6
|
52
|
//printf("d: %4d y: %5d s1: %4d",d1,y1,s1);
|
apm_litoral |
0:d0e2979d7ed6
|
53
|
/******************************************************************************************/
|
apm_litoral |
0:d0e2979d7ed6
|
54
|
// // lee el voltaje en X
|
apm_litoral |
0:d0e2979d7ed6
|
55
|
_yp.output(); //define salidas para y+ y y-
|
apm_litoral |
0:d0e2979d7ed6
|
56
|
_ym.output();
|
apm_litoral |
0:d0e2979d7ed6
|
57
|
switch (orientation) {
|
apm_litoral |
0:d0e2979d7ed6
|
58
|
case(0): //En casos de orientacion 0 y 3
|
apm_litoral |
0:d0e2979d7ed6
|
59
|
case(1): //pone en alto el x+
|
apm_litoral |
0:d0e2979d7ed6
|
60
|
_yp = 1; //pone en bajo el x-
|
apm_litoral |
0:d0e2979d7ed6
|
61
|
_ym = 0;
|
apm_litoral |
0:d0e2979d7ed6
|
62
|
break;
|
apm_litoral |
0:d0e2979d7ed6
|
63
|
case(2):
|
apm_litoral |
0:d0e2979d7ed6
|
64
|
case(3):
|
apm_litoral |
0:d0e2979d7ed6
|
65
|
_yp = 0; //sino lo contrario
|
apm_litoral |
0:d0e2979d7ed6
|
66
|
_ym = 1;
|
apm_litoral |
0:d0e2979d7ed6
|
67
|
break;
|
apm_litoral |
0:d0e2979d7ed6
|
68
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
69
|
_xm.input(); // define x- como entrada para q sea "pasivo"
|
apm_litoral |
0:d0e2979d7ed6
|
70
|
AnalogIn Ax(xa); // define constructor analogico como Ax para el pin x+
|
apm_litoral |
0:d0e2979d7ed6
|
71
|
// wait_us(0);
|
apm_litoral |
0:d0e2979d7ed6
|
72
|
x1 = Ax.read_u16(); // trae el voltaje en x1 desde x+ en el rango de 0 a 65535
|
apm_litoral |
0:d0e2979d7ed6
|
73
|
d2 = (x1 > x2)? (x1-x2) : (x2-x1); //condiciona si x1 es mayor q x2 entonces opera d2=x1-x2 y si no es correcto entonces opera d2=x2-x1
|
apm_litoral |
0:d0e2979d7ed6
|
74
|
if (((x1 < 8000) && (d2 < 2000)) || ((x1 > 8000) && (d2 < 150))) s2 ++; // si (x1<8000 Y d2<2000) O (x1>8000 Y d2<150) //si(1+1)-> s2++
|
apm_litoral |
0:d0e2979d7ed6
|
75
|
// 32768 8192 32768 336
|
apm_litoral |
0:d0e2979d7ed6
|
76
|
else {
|
apm_litoral |
0:d0e2979d7ed6
|
77
|
if (s2 > 0) s2=0; //entonces s2 = s2+1, sino pregunta si s2>0 entonces s2 = s2-1
|
apm_litoral |
0:d0e2979d7ed6
|
78
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
79
|
x2 = x1; //y2 es ahora igual a y1
|
apm_litoral |
0:d0e2979d7ed6
|
80
|
// debug
|
apm_litoral |
0:d0e2979d7ed6
|
81
|
//locate(1,18);
|
apm_litoral |
0:d0e2979d7ed6
|
82
|
//printf("d: %4d x: %5d s2: %4d",d2,x1,s2);
|
apm_litoral |
0:d0e2979d7ed6
|
83
|
|
apm_litoral |
0:d0e2979d7ed6
|
84
|
|
apm_litoral |
0:d0e2979d7ed6
|
85
|
//wait_us(20);
|
apm_litoral |
0:d0e2979d7ed6
|
86
|
|
apm_litoral |
0:d0e2979d7ed6
|
87
|
} while (s1 < 5 || s2 < 5); // read until we have three samples close together
|
apm_litoral |
0:d0e2979d7ed6
|
88
|
|
apm_litoral |
0:d0e2979d7ed6
|
89
|
|
apm_litoral |
0:d0e2979d7ed6
|
90
|
|
apm_litoral |
0:d0e2979d7ed6
|
91
|
|
apm_litoral |
0:d0e2979d7ed6
|
92
|
switch (orientation) {
|
apm_litoral |
0:d0e2979d7ed6
|
93
|
case(0):
|
apm_litoral |
0:d0e2979d7ed6
|
94
|
case(2):
|
apm_litoral |
0:d0e2979d7ed6
|
95
|
p.y = (x1+x2) / 2; // promedio de dos muestras
|
apm_litoral |
0:d0e2979d7ed6
|
96
|
p.x = (y1+y2) / 2;
|
apm_litoral |
0:d0e2979d7ed6
|
97
|
break;
|
apm_litoral |
0:d0e2979d7ed6
|
98
|
case(1):
|
apm_litoral |
0:d0e2979d7ed6
|
99
|
case(3):
|
apm_litoral |
0:d0e2979d7ed6
|
100
|
p.x = (x1+x2) / 2; // promedio de dos muestras
|
apm_litoral |
0:d0e2979d7ed6
|
101
|
p.y = (y1+y2) / 2;
|
apm_litoral |
0:d0e2979d7ed6
|
102
|
break;
|
apm_litoral |
0:d0e2979d7ed6
|
103
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
104
|
|
apm_litoral |
0:d0e2979d7ed6
|
105
|
return(p);
|
apm_litoral |
0:d0e2979d7ed6
|
106
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
107
|
|
apm_litoral |
0:d0e2979d7ed6
|
108
|
void touch_tft::calibrate(void) {
|
apm_litoral |
0:d0e2979d7ed6
|
109
|
int i;
|
apm_litoral |
0:d0e2979d7ed6
|
110
|
int a = 0,b = 0,c = 0, d = 0;
|
apm_litoral |
0:d0e2979d7ed6
|
111
|
|
apm_litoral |
0:d0e2979d7ed6
|
112
|
//desde aki ocultar despues
|
apm_litoral |
0:d0e2979d7ed6
|
113
|
/*
|
apm_litoral |
0:d0e2979d7ed6
|
114
|
int pos_x, pos_y;
|
apm_litoral |
0:d0e2979d7ed6
|
115
|
point p;
|
apm_litoral |
0:d0e2979d7ed6
|
116
|
|
apm_litoral |
0:d0e2979d7ed6
|
117
|
set_font((unsigned char*)Arial12x12); // select the font
|
apm_litoral |
0:d0e2979d7ed6
|
118
|
// get the center of the screen
|
apm_litoral |
0:d0e2979d7ed6
|
119
|
pos_x = (columns() / 2) + 2;
|
apm_litoral |
0:d0e2979d7ed6
|
120
|
pos_x = pos_x * font[1];
|
apm_litoral |
0:d0e2979d7ed6
|
121
|
pos_y = (rows() / 2) - 1;
|
apm_litoral |
0:d0e2979d7ed6
|
122
|
pos_y = pos_y * font[2];
|
apm_litoral |
0:d0e2979d7ed6
|
123
|
|
apm_litoral |
0:d0e2979d7ed6
|
124
|
|
apm_litoral |
0:d0e2979d7ed6
|
125
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
apm_litoral |
0:d0e2979d7ed6
|
126
|
|
apm_litoral |
0:d0e2979d7ed6
|
127
|
//calcula primera posicion en extremo superior derecho
|
apm_litoral |
0:d0e2979d7ed6
|
128
|
cls();
|
apm_litoral |
0:d0e2979d7ed6
|
129
|
line(0,3,3,3,Orange);
|
apm_litoral |
0:d0e2979d7ed6
|
130
|
line(3,0,3,3,Orange);
|
apm_litoral |
0:d0e2979d7ed6
|
131
|
locate(pos_x- font[2]*3,pos_y);
|
apm_litoral |
0:d0e2979d7ed6
|
132
|
printf(" top ");
|
apm_litoral |
0:d0e2979d7ed6
|
133
|
locate(pos_x - font[2]*3 ,pos_y + font[2]);
|
apm_litoral |
0:d0e2979d7ed6
|
134
|
printf("right");
|
apm_litoral |
0:d0e2979d7ed6
|
135
|
|
apm_litoral |
0:d0e2979d7ed6
|
136
|
for (i=0; i<5; i++) {
|
apm_litoral |
0:d0e2979d7ed6
|
137
|
while (p.y < threshold | p.x < threshold) // wait for TRUE touch 8192
|
apm_litoral |
0:d0e2979d7ed6
|
138
|
{
|
apm_litoral |
0:d0e2979d7ed6
|
139
|
p = get_touch();
|
apm_litoral |
0:d0e2979d7ed6
|
140
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
141
|
a += p.x;
|
apm_litoral |
0:d0e2979d7ed6
|
142
|
b += p.y;
|
apm_litoral |
0:d0e2979d7ed6
|
143
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
144
|
|
apm_litoral |
0:d0e2979d7ed6
|
145
|
a = a/5;//55025;//a / 5;
|
apm_litoral |
0:d0e2979d7ed6
|
146
|
b = b/5;//9566;//b / 5;
|
apm_litoral |
0:d0e2979d7ed6
|
147
|
locate(1,36);
|
apm_litoral |
0:d0e2979d7ed6
|
148
|
printf("a: %4d b: %5d p.x: %4d p.y: %4d",a,b,p.x,p.y);//55405 9202 54669 9394 55069 9602 54957 10066 promedio a:55025
|
apm_litoral |
0:d0e2979d7ed6
|
149
|
wait(10);
|
apm_litoral |
0:d0e2979d7ed6
|
150
|
cls();
|
apm_litoral |
0:d0e2979d7ed6
|
151
|
locate(pos_x - font[2]*2,pos_y);
|
apm_litoral |
0:d0e2979d7ed6
|
152
|
printf("Good!");
|
apm_litoral |
0:d0e2979d7ed6
|
153
|
wait(0.5);
|
apm_litoral |
0:d0e2979d7ed6
|
154
|
|
apm_litoral |
0:d0e2979d7ed6
|
155
|
while (p.y > 10000 | p.x > 10000) // wait for no touch
|
apm_litoral |
0:d0e2979d7ed6
|
156
|
{
|
apm_litoral |
0:d0e2979d7ed6
|
157
|
p = get_touch();
|
apm_litoral |
0:d0e2979d7ed6
|
158
|
locate(1,36);
|
apm_litoral |
0:d0e2979d7ed6
|
159
|
printf("p.x: %4d p.y: %4d",p.x,p.y);//55405 9202 54669 9394 55069 9602 54957 10066 promedio a:55025
|
apm_litoral |
0:d0e2979d7ed6
|
160
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
161
|
|
apm_litoral |
0:d0e2979d7ed6
|
162
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
apm_litoral |
0:d0e2979d7ed6
|
163
|
//calcula segunda posicion en extremo inferior izquierdo
|
apm_litoral |
0:d0e2979d7ed6
|
164
|
cls();
|
apm_litoral |
0:d0e2979d7ed6
|
165
|
line(317,237,320,237,Orange); // paint cross
|
apm_litoral |
0:d0e2979d7ed6
|
166
|
line(317,237,317,240,Orange);
|
apm_litoral |
0:d0e2979d7ed6
|
167
|
locate(pos_x- font[2]*3,pos_y);
|
apm_litoral |
0:d0e2979d7ed6
|
168
|
printf("booton");
|
apm_litoral |
0:d0e2979d7ed6
|
169
|
locate(pos_x- font[2]*3,pos_y + font[2]);
|
apm_litoral |
0:d0e2979d7ed6
|
170
|
printf(" left ");
|
apm_litoral |
0:d0e2979d7ed6
|
171
|
for (i=0; i<5; i++) {
|
apm_litoral |
0:d0e2979d7ed6
|
172
|
while (p.y < threshold | p.x < threshold) // wait for TRUE touch
|
apm_litoral |
0:d0e2979d7ed6
|
173
|
{
|
apm_litoral |
0:d0e2979d7ed6
|
174
|
p = get_touch();
|
apm_litoral |
0:d0e2979d7ed6
|
175
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
176
|
c+= p.x;
|
apm_litoral |
0:d0e2979d7ed6
|
177
|
d+= p.y;
|
apm_litoral |
0:d0e2979d7ed6
|
178
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
179
|
c = c/5;//9786;// c / 5;
|
apm_litoral |
0:d0e2979d7ed6
|
180
|
d = d/5;//55933;// d / 5;
|
apm_litoral |
0:d0e2979d7ed6
|
181
|
locate(1,66);
|
apm_litoral |
0:d0e2979d7ed6
|
182
|
printf("c: %4d d: %5d p.x: %4d p.y: %4d",c,d,p.x,p.y);// 9842 55965 9122 55901 9730 56541
|
apm_litoral |
0:d0e2979d7ed6
|
183
|
wait(10);
|
apm_litoral |
0:d0e2979d7ed6
|
184
|
cls();
|
apm_litoral |
0:d0e2979d7ed6
|
185
|
locate(pos_x - font[2]*2,pos_y);
|
apm_litoral |
0:d0e2979d7ed6
|
186
|
printf("Good!");
|
apm_litoral |
0:d0e2979d7ed6
|
187
|
wait(0.5);
|
apm_litoral |
0:d0e2979d7ed6
|
188
|
|
apm_litoral |
0:d0e2979d7ed6
|
189
|
while (p.y > 10000 | p.x > 10000) // wait for no touch
|
apm_litoral |
0:d0e2979d7ed6
|
190
|
{
|
apm_litoral |
0:d0e2979d7ed6
|
191
|
p = get_touch();
|
apm_litoral |
0:d0e2979d7ed6
|
192
|
locate(1,36);
|
apm_litoral |
0:d0e2979d7ed6
|
193
|
printf("p.x: %4d p.y: %4d",p.x,p.y);//55405 9202 54669 9394 55069 9602 54957 10066 promedio a:55025
|
apm_litoral |
0:d0e2979d7ed6
|
194
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
195
|
|
apm_litoral |
0:d0e2979d7ed6
|
196
|
*/
|
apm_litoral |
0:d0e2979d7ed6
|
197
|
///////////////////////////////////////////////////HASTA AKI LAS OPERACIONES////////////////////////////////////////////////////////
|
apm_litoral |
0:d0e2979d7ed6
|
198
|
//Constantes para orientaciones 1 y 3:
|
apm_litoral |
0:d0e2979d7ed6
|
199
|
/*
|
apm_litoral |
0:d0e2979d7ed6
|
200
|
a = 9850;
|
apm_litoral |
0:d0e2979d7ed6
|
201
|
b = 9314;//11650
|
apm_litoral |
0:d0e2979d7ed6
|
202
|
c = 55250;
|
apm_litoral |
0:d0e2979d7ed6
|
203
|
d = 54821;//55313
|
apm_litoral |
0:d0e2979d7ed6
|
204
|
*/
|
apm_litoral |
0:d0e2979d7ed6
|
205
|
//Constantes para orientaciones 0 y 2:
|
apm_litoral |
0:d0e2979d7ed6
|
206
|
|
apm_litoral |
0:d0e2979d7ed6
|
207
|
a = 9750;
|
apm_litoral |
0:d0e2979d7ed6
|
208
|
b = 8550;//11650
|
apm_litoral |
0:d0e2979d7ed6
|
209
|
c = 55250;
|
apm_litoral |
0:d0e2979d7ed6
|
210
|
d = 54521;//55313
|
apm_litoral |
0:d0e2979d7ed6
|
211
|
|
apm_litoral |
0:d0e2979d7ed6
|
212
|
|
apm_litoral |
0:d0e2979d7ed6
|
213
|
x_off = a;
|
apm_litoral |
0:d0e2979d7ed6
|
214
|
y_off = b;
|
apm_litoral |
0:d0e2979d7ed6
|
215
|
|
apm_litoral |
0:d0e2979d7ed6
|
216
|
i = c-a; // delta x pp_tx = (c-a)/(w-6) = (54450-11600)/(320-6) = 42850/(314) = 136.46
|
apm_litoral |
0:d0e2979d7ed6
|
217
|
pp_tx = abs(i) / (width() - 6);
|
apm_litoral |
0:d0e2979d7ed6
|
218
|
|
apm_litoral |
0:d0e2979d7ed6
|
219
|
i = d-b; // delta y
|
apm_litoral |
0:d0e2979d7ed6
|
220
|
pp_ty = abs(i) / (height() - 4);
|
apm_litoral |
0:d0e2979d7ed6
|
221
|
//cls();
|
apm_litoral |
0:d0e2979d7ed6
|
222
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
223
|
|
apm_litoral |
0:d0e2979d7ed6
|
224
|
|
apm_litoral |
0:d0e2979d7ed6
|
225
|
point touch_tft::to_pixel(point a_point) {
|
apm_litoral |
0:d0e2979d7ed6
|
226
|
point p;
|
apm_litoral |
0:d0e2979d7ed6
|
227
|
|
apm_litoral |
0:d0e2979d7ed6
|
228
|
|
apm_litoral |
0:d0e2979d7ed6
|
229
|
p.x = ((a_point.x - x_off) / pp_tx)+4;
|
apm_litoral |
0:d0e2979d7ed6
|
230
|
if (p.x > width()) p.x = width();
|
apm_litoral |
0:d0e2979d7ed6
|
231
|
p.y = (a_point.y - y_off) / pp_ty;
|
apm_litoral |
0:d0e2979d7ed6
|
232
|
if (p.y > height()) p.y = height();
|
apm_litoral |
0:d0e2979d7ed6
|
233
|
return (p);
|
apm_litoral |
0:d0e2979d7ed6
|
234
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
235
|
|
apm_litoral |
0:d0e2979d7ed6
|
236
|
bool touch_tft::is_touched(point a) {
|
apm_litoral |
0:d0e2979d7ed6
|
237
|
if (a.x > threshold & a.y > threshold) return(true);
|
apm_litoral |
0:d0e2979d7ed6
|
238
|
else return(false);
|
apm_litoral |
0:d0e2979d7ed6
|
239
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
240
|
|
apm_litoral |
0:d0e2979d7ed6
|
241
|
point touch_tft::shared_pointer(unsigned int xo,unsigned int xf, unsigned int speed, unsigned repetitions) {
|
apm_litoral |
0:d0e2979d7ed6
|
242
|
int Delta_X;
|
apm_litoral |
0:d0e2979d7ed6
|
243
|
point p;
|
apm_litoral |
0:d0e2979d7ed6
|
244
|
Delta_X = (xf-xo);
|
apm_litoral |
0:d0e2979d7ed6
|
245
|
windows (xo,0,xf,240);
|
apm_litoral |
0:d0e2979d7ed6
|
246
|
p = get_touch();
|
apm_litoral |
0:d0e2979d7ed6
|
247
|
if (is_touched(p)) {
|
apm_litoral |
0:d0e2979d7ed6
|
248
|
p = to_pixel(p);
|
apm_litoral |
0:d0e2979d7ed6
|
249
|
if (p.x <= xf && p.x >= xo){
|
apm_litoral |
0:d0e2979d7ed6
|
250
|
//if (p.x <= Delta_X)
|
apm_litoral |
0:d0e2979d7ed6
|
251
|
sharepoint(xo,320-xf,Delta_X,abs(Delta_X-p.x-1),speed,repetitions);
|
apm_litoral |
0:d0e2979d7ed6
|
252
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
253
|
wait(0.125);
|
apm_litoral |
0:d0e2979d7ed6
|
254
|
}
|
apm_litoral |
0:d0e2979d7ed6
|
255
|
return (p);
|
apm_litoral |
0:d0e2979d7ed6
|
256
|
|
apm_litoral |
0:d0e2979d7ed6
|
257
|
} |