diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index ecfa094787..eb08cb2704 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -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); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 0e8ed4eb57..e0e0e01bb7 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -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); diff --git a/Marlin/src/lcd/tft_io/touch_calibration.h b/Marlin/src/lcd/tft_io/touch_calibration.h index 58d09fdf12..fdc03e3d18 100644 --- a/Marlin/src/lcd/tft_io/touch_calibration.h +++ b/Marlin/src/lcd/tft_io/touch_calibration.h @@ -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; }