summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/tcc780x/cowond2/touchscreen-cowond2.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/firmware/target/arm/tcc780x/cowond2/touchscreen-cowond2.c b/firmware/target/arm/tcc780x/cowond2/touchscreen-cowond2.c
index d7edae6dbe..6f56df529b 100644
--- a/firmware/target/arm/tcc780x/cowond2/touchscreen-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/touchscreen-cowond2.c
@@ -39,30 +39,13 @@ static int short_cmp(const void *a, const void *b)
39 return *(short*)a - *(short*)b; 39 return *(short*)a - *(short*)b;
40} 40}
41 41
42struct touch_calibration_point {
43 short px_x; /* known pixel value */
44 short px_y;
45 short val_x; /* touchscreen value at the known pixel */
46 short val_y;
47};
48
49static struct touch_calibration_point topleft, bottomright;
50
51static int touch_to_pixels(short val_x, short val_y) 42static int touch_to_pixels(short val_x, short val_y)
52{ 43{
53 short x, y; 44 int x = (val_x * LCD_WIDTH) >> 10;
54 45 int y = (val_y * LCD_HEIGHT) >> 10;
55 x = val_x;
56 y = val_y;
57
58 x = (x - topleft.val_x) * (bottomright.px_x - topleft.px_x)
59 / (bottomright.val_x - topleft.val_x) + topleft.px_x;
60
61 y = (y - topleft.val_y) * (bottomright.px_y - topleft.px_y)
62 / (bottomright.val_y - topleft.val_y) + topleft.px_y;
63 46
64 if (x < 0) 47 if (x < 0)
65 x = 0; 48 x = 0;
66 else if (x >= LCD_WIDTH) 49 else if (x >= LCD_WIDTH)
67 x = LCD_WIDTH - 1; 50 x = LCD_WIDTH - 1;
68 51
@@ -161,19 +144,6 @@ static int touchscreen_read_tsc200x(int *data, int *old_data)
161void touchscreen_init_device(void) 144void touchscreen_init_device(void)
162{ 145{
163 touch_available = false; 146 touch_available = false;
164
165 /* Arbitrary touchscreen calibration */
166 topleft.px_x = 0;
167 topleft.px_y = 0;
168
169 bottomright.px_x = LCD_WIDTH;
170 bottomright.px_y = LCD_HEIGHT;
171
172 topleft.val_x = 50;
173 topleft.val_y = 50;
174
175 bottomright.val_x = 980;
176 bottomright.val_y = 980;
177 147
178 if (get_pmu_type() != PCF50606) 148 if (get_pmu_type() != PCF50606)
179 { 149 {