Add Touch Calibration screen (#20049)

This commit is contained in:
Victor Oliveira
2020-11-15 19:39:58 -03:00
committed by GitHub
parent cab83ba840
commit ea371618da
45 changed files with 845 additions and 904 deletions

View File

@ -584,33 +584,37 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
#endif // AUTO_BED_LEVELING_UBL
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
void MarlinUI::touch_calibration() {
static uint16_t x, y;
void MarlinUI::touch_calibration_screen() {
uint16_t x, y;
calibrationState calibration_stage = touch.get_calibration_state();
calibrationState calibration_stage = touch_calibration.get_calibration_state();
if (calibration_stage == CALIBRATION_NONE) {
defer_status_screen(true);
clear_lcd();
calibration_stage = touch.calibration_start();
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_POINT_1: tft_string.set("Top Left"); break;
case CALIBRATION_POINT_2: y = TFT_HEIGHT - 21; tft_string.set("Bottom Left"); break;
case CALIBRATION_POINT_3: x = TFT_WIDTH - 21; tft_string.set("Top Right"); break;
case CALIBRATION_POINT_4: x = TFT_WIDTH - 21; y = TFT_HEIGHT - 21; tft_string.set("Bottom Right"); 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_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;
tft.canvas(x - 15, y - 15, 31, 31);
tft.set_background(COLOR_BACKGROUND);
tft.add_bar(0, 15, 31, 1, COLOR_TOUCH_CALIBRATION);
@ -619,9 +623,9 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
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 ? "Calibration Completed" : "Calibration Failed");
tft_string.set(calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED));
defer_status_screen(false);
touch.calibration_end();
touch_calibration.calibration_end();
touch.add_control(BACK, 0, 0, TFT_WIDTH, TFT_HEIGHT);
}