|
@@ -264,9 +264,7 @@ unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) {
|
264
|
264
|
}
|
265
|
265
|
|
266
|
266
|
static bool get_point(int16_t *x, int16_t *y) {
|
267
|
|
- bool is_touched = touch.getRawPoint(x, y);
|
268
|
|
-
|
269
|
|
- if (!is_touched) return false;
|
|
267
|
+ if (!touch.getRawPoint(x, y)) return false;
|
270
|
268
|
|
271
|
269
|
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
272
|
270
|
const calibrationState state = touch_calibration.get_calibration_state();
|
|
@@ -286,34 +284,26 @@ static bool get_point(int16_t *x, int16_t *y) {
|
286
|
284
|
|
287
|
285
|
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
|
288
|
286
|
static int16_t last_x = 0, last_y = 0;
|
289
|
|
- static uint8_t last_touch_state = LV_INDEV_STATE_REL;
|
290
|
|
- static int32_t touch_time1 = 0;
|
291
|
|
- uint32_t tmpTime, diffTime = 0;
|
292
|
|
-
|
293
|
|
- tmpTime = millis();
|
294
|
|
- diffTime = getTickDiff(tmpTime, touch_time1);
|
295
|
|
- if (diffTime > 20) {
|
296
|
|
- if (get_point(&last_x, &last_y)) {
|
297
|
|
-
|
298
|
|
- if (last_touch_state == LV_INDEV_STATE_PR) return false;
|
299
|
|
- data->state = LV_INDEV_STATE_PR;
|
300
|
|
-
|
301
|
|
- // Set the coordinates (if released use the last-pressed coordinates)
|
|
287
|
+ if (get_point(&last_x, &last_y)) {
|
|
288
|
+ #if TFT_ROTATION == TFT_ROTATE_180
|
|
289
|
+ data->point.x = TFT_WIDTH - last_x;
|
|
290
|
+ data->point.y = TFT_HEIGHT - last_y;
|
|
291
|
+ #else
|
302
|
292
|
data->point.x = last_x;
|
303
|
293
|
data->point.y = last_y;
|
304
|
|
-
|
305
|
|
- last_x = last_y = 0;
|
306
|
|
- last_touch_state = LV_INDEV_STATE_PR;
|
307
|
|
- }
|
308
|
|
- else {
|
309
|
|
- if (last_touch_state == LV_INDEV_STATE_PR)
|
310
|
|
- data->state = LV_INDEV_STATE_REL;
|
311
|
|
- last_touch_state = LV_INDEV_STATE_REL;
|
312
|
|
- }
|
313
|
|
-
|
314
|
|
- touch_time1 = tmpTime;
|
|
294
|
+ #endif
|
|
295
|
+ data->state = LV_INDEV_STATE_PR;
|
|
296
|
+ }
|
|
297
|
+ else {
|
|
298
|
+ #if TFT_ROTATION == TFT_ROTATE_180
|
|
299
|
+ data->point.x = TFT_WIDTH - last_x;
|
|
300
|
+ data->point.y = TFT_HEIGHT - last_y;
|
|
301
|
+ #else
|
|
302
|
+ data->point.x = last_x;
|
|
303
|
+ data->point.y = last_y;
|
|
304
|
+ #endif
|
|
305
|
+ data->state = LV_INDEV_STATE_REL;
|
315
|
306
|
}
|
316
|
|
-
|
317
|
307
|
return false; // Return `false` since no data is buffering or left to read
|
318
|
308
|
}
|
319
|
309
|
|