From 61f15ff6f3b4d67f538b90fb8708307062757f9e Mon Sep 17 00:00:00 2001 From: suchmememanyskill <38142618+suchmememanyskill@users.noreply.github.com> Date: Sat, 9 Mar 2024 21:43:46 +0100 Subject: [PATCH] Fix bugs --- CYD-Klipper/src/ui/panels/printer_panel.cpp | 6 ++-- CYD-Klipper/src/ui/panels/settings_panel.cpp | 37 +++++++++++++------- CYD-Klipper/src/ui/switch_printer.cpp | 15 +++++--- CYD-Klipper/src/ui/switch_printer.h | 1 + 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/CYD-Klipper/src/ui/panels/printer_panel.cpp b/CYD-Klipper/src/ui/panels/printer_panel.cpp index ca7c63c..900c15a 100644 --- a/CYD-Klipper/src/ui/panels/printer_panel.cpp +++ b/CYD-Klipper/src/ui/panels/printer_panel.cpp @@ -6,6 +6,7 @@ #include #include "../nav_buttons.h" #include "../../core/macros_query.h" +#include "../switch_printer.h" const char * printer_status[] = { "Error", @@ -148,10 +149,7 @@ static void btn_printer_activate(lv_event_t * e) PRINTER_CONFIG * config = (PRINTER_CONFIG*)lv_event_get_user_data(e); int index = config - global_config.printer_config; - set_printer_config_index(index); - set_color_scheme(); - _macros_query_internal(); - _power_devices_query_internal(); + switch_printer(index); lv_msg_send(DATA_PRINTER_MINIMAL, NULL); } diff --git a/CYD-Klipper/src/ui/panels/settings_panel.cpp b/CYD-Klipper/src/ui/panels/settings_panel.cpp index 1072fc8..12fdad9 100644 --- a/CYD-Klipper/src/ui/panels/settings_panel.cpp +++ b/CYD-Klipper/src/ui/panels/settings_panel.cpp @@ -127,19 +127,31 @@ void settings_panel_init(lv_obj_t* panel){ lv_layout_flex_column(panel); lv_obj_set_scrollbar_mode(panel, LV_SCROLLBAR_MODE_OFF); - lv_create_custom_menu_button("Configure WiFi", panel, reset_wifi_click, "Restart"); - lv_create_custom_menu_button("Configure IP", panel, reset_ip_click, "Restart"); + if (global_config.multi_printer_mode) + { + lv_obj_t * label = lv_label_create(panel); + lv_label_set_text(label, "Printer Specific Settings"); + } -#ifndef CYD_SCREEN_DISABLE_TOUCH_CALIBRATION - lv_create_custom_menu_button("Calibrate Touch", panel, reset_calibration_click, "Restart"); -#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION + lv_create_custom_menu_dropdown("Estimated Time", panel, estimated_time_dropdown, estimated_time_options, get_current_printer_config()->remaining_time_calc_mode); + lv_create_custom_menu_dropdown("Theme", panel, theme_dropdown, "Blue\nGreen\nGrey\nYellow\nOrange\nRed\nPurple", get_current_printer_config()->color_scheme); #ifndef CYD_SCREEN_DISABLE_INVERT_COLORS lv_create_custom_menu_switch("Invert Colors", panel, invert_color_switch, get_current_printer_config()->invert_colors); #endif // CYD_SCREEN_DISABLE_INVERT_COLORS lv_create_custom_menu_switch("Light Mode", panel, light_mode_switch, get_current_printer_config()->light_mode); - lv_create_custom_menu_dropdown("Theme", panel, theme_dropdown, "Blue\nGreen\nGrey\nYellow\nOrange\nRed\nPurple", get_current_printer_config()->color_scheme); + lv_create_custom_menu_button("Configure IP", panel, reset_ip_click, "Restart"); + + if (global_config.multi_printer_mode) + { + lv_obj_t * label = lv_label_create(panel); + lv_label_set_text(label, "\nGlobal Settings"); + } + +#ifndef CYD_SCREEN_DISABLE_TIMEOUT + lv_create_custom_menu_switch("Screen On During Print", panel, on_during_print_switch, global_config.on_during_print); +#endif int brightness_settings_index = 0; for (int i = 0; i < SIZEOF(brightness_options_values); i++){ @@ -151,7 +163,6 @@ void settings_panel_init(lv_obj_t* panel){ lv_create_custom_menu_dropdown("Brightness", panel, brightness_dropdown, brightness_options, brightness_settings_index); - #ifndef CYD_SCREEN_DISABLE_TIMEOUT int wake_timeout_settings_index = 0; for (int i = 0; i < SIZEOF(wake_timeout_options_values); i++){ @@ -164,13 +175,7 @@ void settings_panel_init(lv_obj_t* panel){ lv_create_custom_menu_dropdown("Wake Timeout", panel, wake_timeout_dropdown, wake_timeout_options, wake_timeout_settings_index); #endif - lv_create_custom_menu_dropdown("Estimated Time", panel, estimated_time_dropdown, estimated_time_options, get_current_printer_config()->remaining_time_calc_mode); lv_create_custom_menu_switch("Rotate Screen", panel, rotate_screen_switch, global_config.rotate_screen); - -#ifndef CYD_SCREEN_DISABLE_TIMEOUT - lv_create_custom_menu_switch("Screen On During Print", panel, on_during_print_switch, global_config.on_during_print); -#endif - lv_create_custom_menu_switch("Multi Printer Mode", panel, multi_printer_switch, global_config.multi_printer_mode); lv_create_custom_menu_switch("Auto Update", panel, auto_ota_update_switch, global_config.auto_ota_update); lv_create_custom_menu_label("Version", panel, REPO_VERSION " "); @@ -188,4 +193,10 @@ void settings_panel_init(lv_obj_t* panel){ else { lv_create_custom_menu_label("Device", panel, ARDUINO_BOARD " "); } + + #ifndef CYD_SCREEN_DISABLE_TOUCH_CALIBRATION + lv_create_custom_menu_button("Calibrate Touch", panel, reset_calibration_click, "Restart"); + #endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION + + lv_create_custom_menu_button("Configure WiFi", panel, reset_wifi_click, "Restart"); } \ No newline at end of file diff --git a/CYD-Klipper/src/ui/switch_printer.cpp b/CYD-Klipper/src/ui/switch_printer.cpp index 34c5684..f344334 100644 --- a/CYD-Klipper/src/ui/switch_printer.cpp +++ b/CYD-Klipper/src/ui/switch_printer.cpp @@ -5,16 +5,23 @@ #include "../core/http_client.h" #include "../core/lv_setup.h" #include "../core/macros_query.h" +#include "../core/screen_driver.h" + +void switch_printer(int index) +{ + set_printer_config_index(index); + set_color_scheme(); + set_invert_display(); + _macros_query_internal(); + _power_devices_query_internal(); +} static void btn_switch_printer(lv_event_t *e){ lv_obj_t *btn = lv_event_get_target(e); PRINTER_CONFIG * config = (PRINTER_CONFIG*)lv_event_get_user_data(e); int index = config - global_config.printer_config; - set_printer_config_index(index); - set_color_scheme(); - _macros_query_internal(); - _power_devices_query_internal(); + switch_printer(index); lv_obj_del(lv_obj_get_parent(lv_obj_get_parent(btn))); } diff --git a/CYD-Klipper/src/ui/switch_printer.h b/CYD-Klipper/src/ui/switch_printer.h index eb2d8a0..775303c 100644 --- a/CYD-Klipper/src/ui/switch_printer.h +++ b/CYD-Klipper/src/ui/switch_printer.h @@ -1,4 +1,5 @@ #pragma once +void switch_printer(int index); void switch_printer_init(); void draw_switch_printer_button(); \ No newline at end of file