diff --git a/CYD-Klipper/src/conf/global_config.h b/CYD-Klipper/src/conf/global_config.h index 4e58ed8..2e7a135 100644 --- a/CYD-Klipper/src/conf/global_config.h +++ b/CYD-Klipper/src/conf/global_config.h @@ -65,6 +65,7 @@ typedef struct _GLOBAL_CONFIG { bool multi_printer_mode : 1; bool on_during_print : 1; bool display_mode : 1; // Driver specifc usage. Currently only used on ESP32-2432S028R to fix the screen on the usb-c model + bool disable_m117_messaging : 1; }; }; diff --git a/CYD-Klipper/src/core/data_setup.cpp b/CYD-Klipper/src/core/data_setup.cpp index f1ea7e4..e57bf85 100644 --- a/CYD-Klipper/src/core/data_setup.cpp +++ b/CYD-Klipper/src/core/data_setup.cpp @@ -244,7 +244,11 @@ void fetch_printer_data() { printer.print_progress = status["display_status"]["progress"]; const char* message = status["display_status"]["message"]; - lv_create_popup_message(message, 10000); + + if (!global_config.disable_m117_messaging) + { + lv_create_popup_message(message, 10000); + } } if (printer.state == PRINTER_STATE_PRINTING && printer.print_progress > 0) @@ -301,16 +305,18 @@ void fetch_printer_data() } else { + unfreeze_request_thread(); klipper_request_consecutive_fail_count++; if (klipper_request_consecutive_fail_count == 5) { + freeze_render_thread(); printer.state = PRINTER_STATE_OFFLINE; lv_msg_send(DATA_PRINTER_STATE, &printer); + unfreeze_render_thread(); } Serial.printf("Failed to fetch printer data: %d\n", httpCode); - unfreeze_request_thread(); } } diff --git a/CYD-Klipper/src/ui/panels/settings_panel.cpp b/CYD-Klipper/src/ui/panels/settings_panel.cpp index 1105dd5..5ccc81c 100644 --- a/CYD-Klipper/src/ui/panels/settings_panel.cpp +++ b/CYD-Klipper/src/ui/panels/settings_panel.cpp @@ -96,6 +96,13 @@ static void dualusb_screen_fix_switch(lv_event_t* e){ ESP.restart(); } +static void disable_m117_messaging_switch(lv_event_t* e){ + auto state = lv_obj_get_state(lv_event_get_target(e)); + bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED); + global_config.disable_m117_messaging = checked; + write_global_config(); +} + static void rotate_screen_switch(lv_event_t* e){ auto state = lv_obj_get_state(lv_event_get_target(e)); bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED); @@ -187,6 +194,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_switch("Disable M117 Messaging", panel, disable_m117_messaging_switch, global_config.disable_m117_messaging); lv_create_custom_menu_button("Configure Printer IP", panel, reset_ip_click, "Restart"); } diff --git a/CYD-Klipper/src/ui/ui_utils.cpp b/CYD-Klipper/src/ui/ui_utils.cpp index 35b399e..013a13a 100644 --- a/CYD-Klipper/src/ui/ui_utils.cpp +++ b/CYD-Klipper/src/ui/ui_utils.cpp @@ -260,6 +260,7 @@ void lv_create_popup_message(const char* message, uint16_t timeout_ms) lv_layout_flex_column(panel, LV_FLEX_ALIGN_CENTER); lv_obj_align(panel, LV_ALIGN_TOP_RIGHT, -CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX); lv_obj_add_event_cb(panel, on_timer_destroy, LV_EVENT_DELETE, NULL); + lv_obj_add_event_cb(panel, destroy_event_user_data, LV_EVENT_CLICKED, panel); lv_obj_set_style_border_color(panel, lv_color_hex(0xFF0000), 0); lv_obj_t* label = lv_label_create(panel);