🎨 calibration_stage => stage

This commit is contained in:
Scott Lahteine 2023-03-23 17:19:20 -05:00
parent 724ba4b4e6
commit 17b43d6b3d
3 changed files with 31 additions and 31 deletions

View file

@ -501,26 +501,26 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT,
void MarlinUI::touch_calibration_screen() { void MarlinUI::touch_calibration_screen() {
uint16_t x, y; uint16_t x, y;
calibrationState calibration_stage = touch_calibration.get_calibration_state(); calibrationState stage = touch_calibration.get_calibration_state();
if (calibration_stage == CALIBRATION_NONE) { if (stage == CALIBRATION_NONE) {
// start and clear screen // start and clear screen
defer_status_screen(true); defer_status_screen(true);
calibration_stage = touch_calibration.calibration_start(); stage = touch_calibration.calibration_start();
tftio.set_window(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1); tftio.set_window(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1);
tftio.WriteMultiple(TFT_MARLINBG_COLOR, uint32_t(TFT_WIDTH) * (TFT_HEIGHT)); tftio.WriteMultiple(TFT_MARLINBG_COLOR, uint32_t(TFT_WIDTH) * (TFT_HEIGHT));
} }
else { else {
// clear last cross // clear last cross
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
drawCross(x, y, TFT_MARLINBG_COLOR); drawCross(x, y, TFT_MARLINBG_COLOR);
} }
FSTR_P str = nullptr; FSTR_P str = nullptr;
if (calibration_stage < CALIBRATION_SUCCESS) { if (stage < CALIBRATION_SUCCESS) {
// handle current state // handle current state
switch (calibration_stage) { switch (stage) {
case CALIBRATION_TOP_LEFT: str = GET_TEXT_F(MSG_TOP_LEFT); break; case CALIBRATION_TOP_LEFT: str = GET_TEXT_F(MSG_TOP_LEFT); break;
case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT_F(MSG_BOTTOM_LEFT); break; case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT_F(MSG_BOTTOM_LEFT); break;
case CALIBRATION_TOP_RIGHT: str = GET_TEXT_F(MSG_TOP_RIGHT); break; case CALIBRATION_TOP_RIGHT: str = GET_TEXT_F(MSG_TOP_RIGHT); break;
@ -528,13 +528,13 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT,
default: break; default: break;
} }
x = touch_calibration.calibration_points[calibration_stage].x; x = touch_calibration.calibration_points[stage].x;
y = touch_calibration.calibration_points[calibration_stage].y; y = touch_calibration.calibration_points[stage].y;
drawCross(x, y, TFT_MARLINUI_COLOR); drawCross(x, y, TFT_MARLINUI_COLOR);
} }
else { else {
// end calibration // end calibration
str = calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT_F(MSG_CALIBRATION_COMPLETED) : GET_TEXT_F(MSG_CALIBRATION_FAILED); str = stage == CALIBRATION_SUCCESS ? GET_TEXT_F(MSG_CALIBRATION_COMPLETED) : GET_TEXT_F(MSG_CALIBRATION_FAILED);
defer_status_screen(false); defer_status_screen(false);
touch_calibration.calibration_end(); touch_calibration.calibration_end();
TERN_(HAS_TOUCH_BUTTONS, redrawTouchButtons = true); TERN_(HAS_TOUCH_BUTTONS, redrawTouchButtons = true);
@ -548,7 +548,7 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT,
} while (u8g.nextPage()); } while (u8g.nextPage());
drawing_screen = false; drawing_screen = false;
safe_delay(250); safe_delay(250);
if (calibration_stage == CALIBRATION_SUCCESS) { if (stage == CALIBRATION_SUCCESS) {
safe_delay(500); safe_delay(500);
ui.goto_previous_screen(); ui.goto_previous_screen();
} }

View file

@ -55,22 +55,22 @@ static void drawCross(uint16_t x, uint16_t y, uint16_t color) {
void lv_update_touch_calibration_screen() { void lv_update_touch_calibration_screen() {
uint16_t x, y; uint16_t x, y;
calibrationState calibration_stage = touch_calibration.get_calibration_state(); calibrationState stage = touch_calibration.get_calibration_state();
if (calibration_stage == CALIBRATION_NONE) { if (stage == CALIBRATION_NONE) {
// start and clear screen // start and clear screen
calibration_stage = touch_calibration.calibration_start(); stage = touch_calibration.calibration_start();
} }
else { else {
// clear last cross // clear last cross
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
drawCross(x, y, LV_COLOR_BACKGROUND.full); drawCross(x, y, LV_COLOR_BACKGROUND.full);
} }
const char *str = nullptr; const char *str = nullptr;
if (calibration_stage < CALIBRATION_SUCCESS) { if (stage < CALIBRATION_SUCCESS) {
// handle current state // handle current state
switch (calibration_stage) { switch (stage) {
case CALIBRATION_TOP_LEFT: str = GET_TEXT(MSG_TOP_LEFT); break; case CALIBRATION_TOP_LEFT: str = GET_TEXT(MSG_TOP_LEFT); break;
case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT(MSG_BOTTOM_LEFT); break; case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT(MSG_BOTTOM_LEFT); break;
case CALIBRATION_TOP_RIGHT: str = GET_TEXT(MSG_TOP_RIGHT); break; case CALIBRATION_TOP_RIGHT: str = GET_TEXT(MSG_TOP_RIGHT); break;
@ -78,13 +78,13 @@ void lv_update_touch_calibration_screen() {
default: break; default: break;
} }
x = touch_calibration.calibration_points[calibration_stage].x; x = touch_calibration.calibration_points[stage].x;
y = touch_calibration.calibration_points[calibration_stage].y; y = touch_calibration.calibration_points[stage].y;
drawCross(x, y, LV_COLOR_WHITE.full); drawCross(x, y, LV_COLOR_WHITE.full);
} }
else { else {
// end calibration // end calibration
str = calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED); str = stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED);
touch_calibration.calibration_end(); touch_calibration.calibration_end();
lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_TC_RETURN); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_TC_RETURN);
} }

View file

@ -228,24 +228,24 @@ void MarlinUI::clear_lcd() {
void MarlinUI::touch_calibration_screen() { void MarlinUI::touch_calibration_screen() {
uint16_t x, y; uint16_t x, y;
calibrationState calibration_stage = touch_calibration.get_calibration_state(); calibrationState stage = touch_calibration.get_calibration_state();
if (calibration_stage == CALIBRATION_NONE) { if (stage == CALIBRATION_NONE) {
defer_status_screen(true); defer_status_screen(true);
clear_lcd(); clear_lcd();
calibration_stage = touch_calibration.calibration_start(); stage = touch_calibration.calibration_start();
} }
else { else {
x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
tft.canvas(x - 15, y - 15, 31, 31); tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
} }
touch.clear(); touch.clear();
if (calibration_stage < CALIBRATION_SUCCESS) { if (stage < CALIBRATION_SUCCESS) {
switch (calibration_stage) { switch (stage) {
case CALIBRATION_TOP_LEFT: tft_string.set(GET_TEXT(MSG_TOP_LEFT)); break; case CALIBRATION_TOP_LEFT: tft_string.set(GET_TEXT(MSG_TOP_LEFT)); break;
case CALIBRATION_BOTTOM_LEFT: tft_string.set(GET_TEXT(MSG_BOTTOM_LEFT)); break; case CALIBRATION_BOTTOM_LEFT: tft_string.set(GET_TEXT(MSG_BOTTOM_LEFT)); break;
case CALIBRATION_TOP_RIGHT: tft_string.set(GET_TEXT(MSG_TOP_RIGHT)); break; case CALIBRATION_TOP_RIGHT: tft_string.set(GET_TEXT(MSG_TOP_RIGHT)); break;
@ -253,8 +253,8 @@ void MarlinUI::clear_lcd() {
default: break; default: break;
} }
x = touch_calibration.calibration_points[calibration_stage].x; x = touch_calibration.calibration_points[stage].x;
y = touch_calibration.calibration_points[calibration_stage].y; y = touch_calibration.calibration_points[stage].y;
tft.canvas(x - 15, y - 15, 31, 31); tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND); tft.set_background(COLOR_BACKGROUND);
@ -264,7 +264,7 @@ void MarlinUI::clear_lcd() {
touch.add_control(CALIBRATE, 0, 0, TFT_WIDTH, TFT_HEIGHT, uint32_t(x) << 16 | uint32_t(y)); touch.add_control(CALIBRATE, 0, 0, TFT_WIDTH, TFT_HEIGHT, uint32_t(x) << 16 | uint32_t(y));
} }
else { else {
tft_string.set(calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED)); tft_string.set(stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED));
defer_status_screen(false); defer_status_screen(false);
touch_calibration.calibration_end(); touch_calibration.calibration_end();
touch.add_control(BACK, 0, 0, TFT_WIDTH, TFT_HEIGHT); touch.add_control(BACK, 0, 0, TFT_WIDTH, TFT_HEIGHT);