better offsets for touch calibration

This commit is contained in:
Victor Mateus Oliveira 2020-11-10 00:48:49 -03:00
parent dc335041d4
commit 2806669fda
3 changed files with 26 additions and 18 deletions

View file

@ -585,7 +585,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
void MarlinUI::touch_calibration_screen() {
static uint16_t x, y;
uint16_t x, y;
calibrationState calibration_stage = touch_calibration.get_calibration_state();
@ -595,22 +595,26 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
calibration_stage = touch_calibration.calibration_start();
}
else {
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
}
x = 20; y = 20;
touch.clear();
if (calibration_stage < CALIBRATION_SUCCESS) {
switch (calibration_stage) {
case CALIBRATION_TOP_LEFT: tft_string.set("Top Left"); break;
case CALIBRATION_BOTTOM_LEFT: y = TFT_HEIGHT - 21; tft_string.set("Bottom Left"); break;
case CALIBRATION_TOP_RIGHT: x = TFT_WIDTH - 21; tft_string.set("Top Right"); break;
case CALIBRATION_BOTTOM_RIGHT: x = TFT_WIDTH - 21; y = TFT_HEIGHT - 21; tft_string.set("Bottom Right"); break;
case CALIBRATION_BOTTOM_LEFT: tft_string.set("Bottom Left"); break;
case CALIBRATION_TOP_RIGHT: tft_string.set("Top Right"); break;
case CALIBRATION_BOTTOM_RIGHT: tft_string.set("Bottom Right"); break;
default: break;
}
x = touch_calibration.calibration_points[calibration_stage].x;
y = touch_calibration.calibration_points[calibration_stage].y;
tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
tft.add_bar(0, 15, 31, 1, COLOR_TOUCH_CALIBRATION);

View file

@ -590,7 +590,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
void MarlinUI::touch_calibration_screen() {
static uint16_t x, y;
uint16_t x, y;
calibrationState calibration_stage = touch_calibration.get_calibration_state();
@ -600,22 +600,26 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
calibration_stage = touch_calibration.calibration_start();
}
else {
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
}
x = 20; y = 20;
touch.clear();
if (calibration_stage < CALIBRATION_SUCCESS) {
switch (calibration_stage) {
case CALIBRATION_TOP_LEFT: tft_string.set("Top Left"); break;
case CALIBRATION_BOTTOM_LEFT: y = TFT_HEIGHT - 21; tft_string.set("Bottom Left"); break;
case CALIBRATION_TOP_RIGHT: x = TFT_WIDTH - 21; tft_string.set("Top Right"); break;
case CALIBRATION_BOTTOM_RIGHT: x = TFT_WIDTH - 21; y = TFT_HEIGHT - 21; tft_string.set("Bottom Right"); break;
case CALIBRATION_BOTTOM_LEFT: tft_string.set("Bottom Left"); break;
case CALIBRATION_TOP_RIGHT: tft_string.set("Top Right"); break;
case CALIBRATION_BOTTOM_RIGHT: tft_string.set("Bottom Right"); break;
default: break;
}
x = touch_calibration.calibration_points[calibration_stage].x;
y = touch_calibration.calibration_points[calibration_stage].y;
tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
tft.add_bar(0, 15, 31, 1, COLOR_TOUCH_CALIBRATION);

View file

@ -80,14 +80,14 @@ public:
static calibrationState calibration_start() {
calibration = {0, 0, 0, 0, TOUCH_ORIENTATION_NONE};
calibration_state = CALIBRATION_TOP_LEFT;
calibration_points[CALIBRATION_TOP_LEFT].x = 20;
calibration_points[CALIBRATION_TOP_LEFT].y = 20;
calibration_points[CALIBRATION_BOTTOM_LEFT].x = 20;
calibration_points[CALIBRATION_BOTTOM_LEFT].y = TFT_HEIGHT - 21;
calibration_points[CALIBRATION_TOP_RIGHT].x = TFT_WIDTH - 21;
calibration_points[CALIBRATION_TOP_RIGHT].y = 20;
calibration_points[CALIBRATION_BOTTOM_RIGHT].x = TFT_WIDTH - 21;
calibration_points[CALIBRATION_BOTTOM_RIGHT].y = TFT_HEIGHT - 21;
calibration_points[CALIBRATION_TOP_LEFT].x = 30;
calibration_points[CALIBRATION_TOP_LEFT].y = 30;
calibration_points[CALIBRATION_BOTTOM_LEFT].x = 30;
calibration_points[CALIBRATION_BOTTOM_LEFT].y = TFT_HEIGHT - 31;
calibration_points[CALIBRATION_TOP_RIGHT].x = TFT_WIDTH - 31;
calibration_points[CALIBRATION_TOP_RIGHT].y = 30;
calibration_points[CALIBRATION_BOTTOM_RIGHT].x = TFT_WIDTH - 31;
calibration_points[CALIBRATION_BOTTOM_RIGHT].y = TFT_HEIGHT - 31;
return calibration_state;
}
static void calibration_end() { calibration_state = CALIBRATION_NONE; }