Skip to content

Commit

Permalink
🎨 calibration_stage => stage
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 23, 2023
1 parent 724ba4b commit 17b43d6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
22 changes: 11 additions & 11 deletions Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,40 +501,40 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT,

void MarlinUI::touch_calibration_screen() {
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
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.WriteMultiple(TFT_MARLINBG_COLOR, uint32_t(TFT_WIDTH) * (TFT_HEIGHT));
}
else {
// clear last cross
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;
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
drawCross(x, y, TFT_MARLINBG_COLOR);
}

FSTR_P str = nullptr;
if (calibration_stage < CALIBRATION_SUCCESS) {
if (stage < CALIBRATION_SUCCESS) {
// handle current state
switch (calibration_stage) {
switch (stage) {
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_TOP_RIGHT: str = GET_TEXT_F(MSG_TOP_RIGHT); break;
case CALIBRATION_BOTTOM_RIGHT: str = GET_TEXT_F(MSG_BOTTOM_RIGHT); break;
default: break;
}

x = touch_calibration.calibration_points[calibration_stage].x;
y = touch_calibration.calibration_points[calibration_stage].y;
x = touch_calibration.calibration_points[stage].x;
y = touch_calibration.calibration_points[stage].y;
drawCross(x, y, TFT_MARLINUI_COLOR);
}
else {
// 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);
touch_calibration.calibration_end();
TERN_(HAS_TOUCH_BUTTONS, redrawTouchButtons = true);
Expand All @@ -548,7 +548,7 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT,
} while (u8g.nextPage());
drawing_screen = false;
safe_delay(250);
if (calibration_stage == CALIBRATION_SUCCESS) {
if (stage == CALIBRATION_SUCCESS) {
safe_delay(500);
ui.goto_previous_screen();
}
Expand Down
20 changes: 10 additions & 10 deletions Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,36 @@ static void drawCross(uint16_t x, uint16_t y, uint16_t color) {
void lv_update_touch_calibration_screen() {
uint16_t x, y;

calibrationState calibration_stage = touch_calibration.get_calibration_state();
if (calibration_stage == CALIBRATION_NONE) {
calibrationState stage = touch_calibration.get_calibration_state();
if (stage == CALIBRATION_NONE) {
// start and clear screen
calibration_stage = touch_calibration.calibration_start();
stage = touch_calibration.calibration_start();
}
else {
// clear last cross
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;
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
drawCross(x, y, LV_COLOR_BACKGROUND.full);
}

const char *str = nullptr;
if (calibration_stage < CALIBRATION_SUCCESS) {
if (stage < CALIBRATION_SUCCESS) {
// handle current state
switch (calibration_stage) {
switch (stage) {
case CALIBRATION_TOP_LEFT: str = GET_TEXT(MSG_TOP_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_BOTTOM_RIGHT: str = GET_TEXT(MSG_BOTTOM_RIGHT); break;
default: break;
}

x = touch_calibration.calibration_points[calibration_stage].x;
y = touch_calibration.calibration_points[calibration_stage].y;
x = touch_calibration.calibration_points[stage].x;
y = touch_calibration.calibration_points[stage].y;
drawCross(x, y, LV_COLOR_WHITE.full);
}
else {
// 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();
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);
}
Expand Down
20 changes: 10 additions & 10 deletions Marlin/src/lcd/tft/ui_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,33 +228,33 @@ void MarlinUI::clear_lcd() {
void MarlinUI::touch_calibration_screen() {
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);
clear_lcd();
calibration_stage = touch_calibration.calibration_start();
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;
x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x;
y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y;
tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
}

touch.clear();

if (calibration_stage < CALIBRATION_SUCCESS) {
switch (calibration_stage) {
if (stage < CALIBRATION_SUCCESS) {
switch (stage) {
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_TOP_RIGHT: tft_string.set(GET_TEXT(MSG_TOP_RIGHT)); break;
case CALIBRATION_BOTTOM_RIGHT: tft_string.set(GET_TEXT(MSG_BOTTOM_RIGHT)); break;
default: break;
}

x = touch_calibration.calibration_points[calibration_stage].x;
y = touch_calibration.calibration_points[calibration_stage].y;
x = touch_calibration.calibration_points[stage].x;
y = touch_calibration.calibration_points[stage].y;

tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
Expand All @@ -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));
}
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);
touch_calibration.calibration_end();
touch.add_control(BACK, 0, 0, TFT_WIDTH, TFT_HEIGHT);
Expand Down

0 comments on commit 17b43d6

Please sign in to comment.