|
|
@ -68,26 +68,31 @@ uint8_t TouchButtons::read_buttons() { |
|
|
|
#ifdef HAS_WIRED_LCD |
|
|
|
int16_t x, y; |
|
|
|
|
|
|
|
const bool is_touched = (TERN(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration.orientation, TOUCH_ORIENTATION) == TOUCH_PORTRAIT ? touchIO.getRawPoint(&y, &x) : touchIO.getRawPoint(&x, &y)); |
|
|
|
#if HAS_TOUCH_SLEEP |
|
|
|
if (is_touched) |
|
|
|
wakeUp(); |
|
|
|
else if (!isSleeping() && ELAPSED(millis(), next_sleep_ms) && ui.on_status_screen()) |
|
|
|
sleepTimeout(); |
|
|
|
#endif |
|
|
|
if (!is_touched) return 0; |
|
|
|
|
|
|
|
#if ENABLED(TOUCH_SCREEN_CALIBRATION) |
|
|
|
const calibrationState state = touch_calibration.get_calibration_state(); |
|
|
|
if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_RIGHT)) { |
|
|
|
if (touch_calibration.handleTouch(x, y)) ui.refresh(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
x = int16_t((int32_t(x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x; |
|
|
|
y = int16_t((int32_t(y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y; |
|
|
|
#else |
|
|
|
x = uint16_t((uint32_t(x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X; |
|
|
|
y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y; |
|
|
|
#if ENABLED(TFT_TOUCH_DEVICE_XPT2046) |
|
|
|
const bool is_touched = (TERN(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration.orientation, TOUCH_ORIENTATION) == TOUCH_PORTRAIT ? touchIO.getRawPoint(&y, &x) : touchIO.getRawPoint(&x, &y)); |
|
|
|
#if HAS_TOUCH_SLEEP |
|
|
|
if (is_touched) |
|
|
|
wakeUp(); |
|
|
|
else if (!isSleeping() && ELAPSED(millis(), next_sleep_ms) && ui.on_status_screen()) |
|
|
|
sleepTimeout(); |
|
|
|
#endif |
|
|
|
if (!is_touched) return 0; |
|
|
|
|
|
|
|
#if ENABLED(TOUCH_SCREEN_CALIBRATION) |
|
|
|
const calibrationState state = touch_calibration.get_calibration_state(); |
|
|
|
if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_RIGHT)) { |
|
|
|
if (touch_calibration.handleTouch(x, y)) ui.refresh(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
x = int16_t((int32_t(x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x; |
|
|
|
y = int16_t((int32_t(y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y; |
|
|
|
#else |
|
|
|
x = uint16_t((uint32_t(x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X; |
|
|
|
y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y; |
|
|
|
#endif |
|
|
|
#elif ENABLED(TFT_TOUCH_DEVICE_GT911) |
|
|
|
bool is_touched = (TOUCH_ORIENTATION == TOUCH_PORTRAIT ? touchIO.getPoint(&y, &x) : touchIO.getPoint(&x, &y)); |
|
|
|
if (!is_touched) return 0; |
|
|
|
#endif |
|
|
|
|
|
|
|
// Touch within the button area simulates an encoder button
|
|
|
|