|
|
@ -264,9 +264,7 @@ unsigned int getTickDiff(unsigned int curTick, unsigned int lastTick) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool get_point(int16_t *x, int16_t *y) {
|
|
|
|
static bool get_point(int16_t *x, int16_t *y) {
|
|
|
|
bool is_touched = touch.getRawPoint(x, y);
|
|
|
|
if (!touch.getRawPoint(x, y)) return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_touched) return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
|
|
|
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
|
|
|
const calibrationState state = touch_calibration.get_calibration_state();
|
|
|
|
const calibrationState state = touch_calibration.get_calibration_state();
|
|
|
@ -286,34 +284,26 @@ static bool get_point(int16_t *x, int16_t *y) {
|
|
|
|
|
|
|
|
|
|
|
|
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
|
|
|
|
bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data) {
|
|
|
|
static int16_t last_x = 0, last_y = 0;
|
|
|
|
static int16_t last_x = 0, last_y = 0;
|
|
|
|
static uint8_t last_touch_state = LV_INDEV_STATE_REL;
|
|
|
|
if (get_point(&last_x, &last_y)) {
|
|
|
|
static int32_t touch_time1 = 0;
|
|
|
|
#if TFT_ROTATION == TFT_ROTATE_180
|
|
|
|
uint32_t tmpTime, diffTime = 0;
|
|
|
|
data->point.x = TFT_WIDTH - last_x;
|
|
|
|
|
|
|
|
data->point.y = TFT_HEIGHT - last_y;
|
|
|
|
tmpTime = millis();
|
|
|
|
#else
|
|
|
|
diffTime = getTickDiff(tmpTime, touch_time1);
|
|
|
|
|
|
|
|
if (diffTime > 20) {
|
|
|
|
|
|
|
|
if (get_point(&last_x, &last_y)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (last_touch_state == LV_INDEV_STATE_PR) return false;
|
|
|
|
|
|
|
|
data->state = LV_INDEV_STATE_PR;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set the coordinates (if released use the last-pressed coordinates)
|
|
|
|
|
|
|
|
data->point.x = last_x;
|
|
|
|
data->point.x = last_x;
|
|
|
|
data->point.y = last_y;
|
|
|
|
data->point.y = last_y;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
last_x = last_y = 0;
|
|
|
|
data->state = LV_INDEV_STATE_PR;
|
|
|
|
last_touch_state = LV_INDEV_STATE_PR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
#if TFT_ROTATION == TFT_ROTATE_180
|
|
|
|
if (last_touch_state == LV_INDEV_STATE_PR)
|
|
|
|
data->point.x = TFT_WIDTH - last_x;
|
|
|
|
data->state = LV_INDEV_STATE_REL;
|
|
|
|
data->point.y = TFT_HEIGHT - last_y;
|
|
|
|
last_touch_state = LV_INDEV_STATE_REL;
|
|
|
|
#else
|
|
|
|
}
|
|
|
|
data->point.x = last_x;
|
|
|
|
|
|
|
|
data->point.y = last_y;
|
|
|
|
touch_time1 = tmpTime;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
data->state = LV_INDEV_STATE_REL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false; // Return `false` since no data is buffering or left to read
|
|
|
|
return false; // Return `false` since no data is buffering or left to read
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|