Reset touch calibration when holding BOOT for 8 seconds

This commit is contained in:
suchmememanyskill
2024-03-29 20:16:13 +01:00
parent 86a999253f
commit 9a9134da4a
6 changed files with 31 additions and 13 deletions

View File

@@ -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;

View File

@@ -8,3 +8,4 @@ void screen_timer_stop();
void set_color_scheme();
void lv_setup();
bool is_screen_asleep();
void lv_handler();

View File

@@ -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())
{

View File

@@ -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();
}
}

View File

@@ -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)

View File

@@ -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();
}
}