diff --git a/CYD-Klipper/src/core/lv_setup.cpp b/CYD-Klipper/src/core/lv_setup.cpp index 0cbb26b..47f696a 100644 --- a/CYD-Klipper/src/core/lv_setup.cpp +++ b/CYD-Klipper/src/core/lv_setup.cpp @@ -12,6 +12,27 @@ #define CPU_FREQ_LOW 80 #endif +unsigned long last_milis = 0; + +inline void lv_handler() +{ +#ifndef CYD_SCREEN_DISABLE_TOUCH_CALIBRATION + if (digitalRead(0) == HIGH) + { + last_milis = millis(); + } + else if (millis() - last_milis > 8000) + { + global_config.screen_calibrated = false; + write_global_config(); + ESP.restart(); + } +#endif + + lv_timer_handler(); + lv_task_handler(); +} + typedef void (*lv_indev_drv_read_cb_t)(struct _lv_indev_drv_t * indev_drv, lv_indev_data_t * data); bool is_screen_in_sleep = false; @@ -95,8 +116,7 @@ void lv_do_calibration(){ #endif while (true){ - lv_timer_handler(); - lv_task_handler(); + lv_handler(); if (point[0] != 0 && point[1] != 0){ break; @@ -130,8 +150,7 @@ void lv_do_calibration(){ #endif while (true){ - lv_timer_handler(); - lv_task_handler(); + lv_handler(); if (point[0] != 0 && point[1] != 0){ break; diff --git a/CYD-Klipper/src/core/lv_setup.h b/CYD-Klipper/src/core/lv_setup.h index 5758da4..c0970a5 100644 --- a/CYD-Klipper/src/core/lv_setup.h +++ b/CYD-Klipper/src/core/lv_setup.h @@ -7,4 +7,5 @@ void screen_timer_start(); void screen_timer_stop(); void set_color_scheme(); void lv_setup(); -bool is_screen_asleep(); \ No newline at end of file +bool is_screen_asleep(); +void lv_handler(); \ No newline at end of file diff --git a/CYD-Klipper/src/main.cpp b/CYD-Klipper/src/main.cpp index 4009166..03e60ce 100644 --- a/CYD-Klipper/src/main.cpp +++ b/CYD-Klipper/src/main.cpp @@ -30,8 +30,7 @@ void setup() { void loop(){ wifi_ok(); data_loop(); - lv_timer_handler(); - lv_task_handler(); + lv_handler(); if (is_ready_for_ota_update()) { diff --git a/CYD-Klipper/src/ui/ip_setup.cpp b/CYD-Klipper/src/ui/ip_setup.cpp index 47ad854..1419972 100644 --- a/CYD-Klipper/src/ui/ip_setup.cpp +++ b/CYD-Klipper/src/ui/ip_setup.cpp @@ -9,6 +9,7 @@ #include "../core/http_client.h" #include "switch_printer.h" #include "macros.h" +#include "../core/lv_setup.h" lv_obj_t * hostEntry; lv_obj_t * portEntry; @@ -232,7 +233,6 @@ void ip_init(){ while (!get_current_printer_config()->ip_configured) { - lv_timer_handler(); - lv_task_handler(); + lv_handler(); } } \ No newline at end of file diff --git a/CYD-Klipper/src/ui/panels/settings_panel.cpp b/CYD-Klipper/src/ui/panels/settings_panel.cpp index 9627fed..9d51474 100644 --- a/CYD-Klipper/src/ui/panels/settings_panel.cpp +++ b/CYD-Klipper/src/ui/panels/settings_panel.cpp @@ -181,8 +181,7 @@ void settings_section_behaviour(lv_obj_t* panel) #endif lv_create_custom_menu_switch("Multi Printer Mode", panel, multi_printer_switch, global_config.multi_printer_mode); - -lv_create_custom_menu_button("Configure IP", panel, reset_ip_click, "Restart"); + lv_create_custom_menu_button("Configure Printer IP", panel, reset_ip_click, "Restart"); } void settings_section_device(lv_obj_t* panel) diff --git a/CYD-Klipper/src/ui/wifi_setup.cpp b/CYD-Klipper/src/ui/wifi_setup.cpp index 99f84cf..027011d 100644 --- a/CYD-Klipper/src/ui/wifi_setup.cpp +++ b/CYD-Klipper/src/ui/wifi_setup.cpp @@ -4,6 +4,7 @@ #include "ui_utils.h" #include "WiFi.h" #include "../core/data_setup.h" +#include "../core/lv_setup.h" void wifi_init_inner(); void wifi_pass_entry(const char* ssid); @@ -223,8 +224,7 @@ void wifi_init(){ Serial.printf("WiFi Status: %s\n", errs[WiFi.status()]); } - lv_timer_handler(); - lv_task_handler(); + lv_handler(); } }