Skip to content

Commit

Permalink
Reset touch calibration when holding BOOT for 8 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Mar 29, 2024
1 parent 86a9992 commit 9a9134d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
27 changes: 23 additions & 4 deletions CYD-Klipper/src/core/lv_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion CYD-Klipper/src/core/lv_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ void screen_timer_start();
void screen_timer_stop();
void set_color_scheme();
void lv_setup();
bool is_screen_asleep();
bool is_screen_asleep();
void lv_handler();
3 changes: 1 addition & 2 deletions CYD-Klipper/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
4 changes: 2 additions & 2 deletions CYD-Klipper/src/ui/ip_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -232,7 +233,6 @@ void ip_init(){

while (!get_current_printer_config()->ip_configured)
{
lv_timer_handler();
lv_task_handler();
lv_handler();
}
}
3 changes: 1 addition & 2 deletions CYD-Klipper/src/ui/panels/settings_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions CYD-Klipper/src/ui/wifi_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -223,8 +224,7 @@ void wifi_init(){
Serial.printf("WiFi Status: %s\n", errs[WiFi.status()]);
}

lv_timer_handler();
lv_task_handler();
lv_handler();
}
}

Expand Down

0 comments on commit 9a9134d

Please sign in to comment.