to use ui without TOUCH_SCREEN_CALIBRATION
This commit is contained in:
parent
715502172f
commit
2f4b85568a
3 changed files with 19 additions and 10 deletions
|
|
@ -53,7 +53,7 @@ TouchControlType Touch::touch_control_type = NONE;
|
|||
#endif
|
||||
|
||||
void Touch::init() {
|
||||
touch_calibration.calibration_reset();
|
||||
TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset());
|
||||
reset();
|
||||
io.Init();
|
||||
enable();
|
||||
|
|
@ -248,12 +248,18 @@ void Touch::hold(touch_control_t *control, millis_t delay) {
|
|||
}
|
||||
|
||||
bool Touch::get_point(int16_t *x, int16_t *y) {
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
bool is_touched = (touch_calibration.calibration.orientation == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));
|
||||
|
||||
if (is_touched && touch_calibration.calibration.orientation != TOUCH_ORIENTATION_NONE) {
|
||||
*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
|
||||
bool is_touched = (TOUCH_ORIENTATION == TOUCH_PORTRAIT ? io.getRawPoint(y, x) : io.getRawPoint(x, y));
|
||||
*x = uint16_t((uint32_t(*x) * XPT2046_X_CALIBRATION) >> 16) + XPT2046_X_OFFSET;
|
||||
*y = uint16_t((uint32_t(*y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET;
|
||||
#endif
|
||||
return is_touched;
|
||||
}
|
||||
Touch touch;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
|
||||
#ifndef TOUCH_SCREEN_CALIBRATION_PRECISION
|
||||
#define TOUCH_SCREEN_CALIBRATION_PRECISION 80
|
||||
#endif
|
||||
|
|
@ -50,6 +48,8 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
|
|
|
|||
|
|
@ -57,10 +57,13 @@ uint8_t TouchButtons::read_buttons() {
|
|||
if (touch_calibration.handleTouch(x, y)) ui.refresh();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
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) * XPT2046_X_CALIBRATION) >> 16) + XPT2046_X_OFFSET;
|
||||
y = uint16_t((uint32_t(y) * XPT2046_Y_CALIBRATION) >> 16) + XPT2046_Y_OFFSET;
|
||||
#endif
|
||||
|
||||
|
||||
// Touch within the button area simulates an encoder button
|
||||
if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue