3 Commits

Author SHA1 Message Date
Sims
29dcb4717a Merge pull request #87 from suchmememanyskill/dev
v1.6.1
2024-04-14 12:13:50 +02:00
suchmememanyskill
356c78ee5f Lock UI thread when setting state to offline, fix #86 2024-04-14 12:01:35 +02:00
suchmememanyskill
dce6f70ef9 Allow dismissing m117 messages, allow disabling m117 messages 2024-04-05 23:03:48 +02:00
4 changed files with 18 additions and 2 deletions

View File

@@ -65,6 +65,7 @@ typedef struct _GLOBAL_CONFIG {
bool multi_printer_mode : 1; bool multi_printer_mode : 1;
bool on_during_print : 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 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;
}; };
}; };

View File

@@ -244,8 +244,12 @@ void fetch_printer_data()
{ {
printer.print_progress = status["display_status"]["progress"]; printer.print_progress = status["display_status"]["progress"];
const char* message = status["display_status"]["message"]; const char* message = status["display_status"]["message"];
if (!global_config.disable_m117_messaging)
{
lv_create_popup_message(message, 10000); lv_create_popup_message(message, 10000);
} }
}
if (printer.state == PRINTER_STATE_PRINTING && printer.print_progress > 0) if (printer.state == PRINTER_STATE_PRINTING && printer.print_progress > 0)
{ {
@@ -301,16 +305,18 @@ void fetch_printer_data()
} }
else else
{ {
unfreeze_request_thread();
klipper_request_consecutive_fail_count++; klipper_request_consecutive_fail_count++;
if (klipper_request_consecutive_fail_count == 5) if (klipper_request_consecutive_fail_count == 5)
{ {
freeze_render_thread();
printer.state = PRINTER_STATE_OFFLINE; printer.state = PRINTER_STATE_OFFLINE;
lv_msg_send(DATA_PRINTER_STATE, &printer); lv_msg_send(DATA_PRINTER_STATE, &printer);
unfreeze_render_thread();
} }
Serial.printf("Failed to fetch printer data: %d\n", httpCode); Serial.printf("Failed to fetch printer data: %d\n", httpCode);
unfreeze_request_thread();
} }
} }

View File

@@ -96,6 +96,13 @@ static void dualusb_screen_fix_switch(lv_event_t* e){
ESP.restart(); 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){ static void rotate_screen_switch(lv_event_t* e){
auto state = lv_obj_get_state(lv_event_get_target(e)); auto state = lv_obj_get_state(lv_event_get_target(e));
bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED); bool checked = (state & LV_STATE_CHECKED == LV_STATE_CHECKED);
@@ -187,6 +194,7 @@ void settings_section_behaviour(lv_obj_t* panel)
#endif #endif
lv_create_custom_menu_switch("Multi Printer Mode", panel, multi_printer_switch, global_config.multi_printer_mode); 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"); lv_create_custom_menu_button("Configure Printer IP", panel, reset_ip_click, "Restart");
} }

View File

@@ -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_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_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, 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_set_style_border_color(panel, lv_color_hex(0xFF0000), 0);
lv_obj_t* label = lv_label_create(panel); lv_obj_t* label = lv_label_create(panel);