This commit is contained in:
suchmememanyskill
2024-03-09 21:43:46 +01:00
parent 397c835129
commit 61f15ff6f3
4 changed files with 38 additions and 21 deletions

View File

@@ -6,6 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include "../nav_buttons.h" #include "../nav_buttons.h"
#include "../../core/macros_query.h" #include "../../core/macros_query.h"
#include "../switch_printer.h"
const char * printer_status[] = { const char * printer_status[] = {
"Error", "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); PRINTER_CONFIG * config = (PRINTER_CONFIG*)lv_event_get_user_data(e);
int index = config - global_config.printer_config; int index = config - global_config.printer_config;
set_printer_config_index(index); switch_printer(index);
set_color_scheme();
_macros_query_internal();
_power_devices_query_internal();
lv_msg_send(DATA_PRINTER_MINIMAL, NULL); lv_msg_send(DATA_PRINTER_MINIMAL, NULL);
} }

View File

@@ -127,19 +127,31 @@ void settings_panel_init(lv_obj_t* panel){
lv_layout_flex_column(panel); lv_layout_flex_column(panel);
lv_obj_set_scrollbar_mode(panel, LV_SCROLLBAR_MODE_OFF); lv_obj_set_scrollbar_mode(panel, LV_SCROLLBAR_MODE_OFF);
lv_create_custom_menu_button("Configure WiFi", panel, reset_wifi_click, "Restart"); if (global_config.multi_printer_mode)
lv_create_custom_menu_button("Configure IP", panel, reset_ip_click, "Restart"); {
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_dropdown("Estimated Time", panel, estimated_time_dropdown, estimated_time_options, get_current_printer_config()->remaining_time_calc_mode);
lv_create_custom_menu_button("Calibrate Touch", panel, reset_calibration_click, "Restart"); lv_create_custom_menu_dropdown("Theme", panel, theme_dropdown, "Blue\nGreen\nGrey\nYellow\nOrange\nRed\nPurple", get_current_printer_config()->color_scheme);
#endif // CYD_SCREEN_DISABLE_TOUCH_CALIBRATION
#ifndef CYD_SCREEN_DISABLE_INVERT_COLORS #ifndef CYD_SCREEN_DISABLE_INVERT_COLORS
lv_create_custom_menu_switch("Invert Colors", panel, invert_color_switch, get_current_printer_config()->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 #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_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; int brightness_settings_index = 0;
for (int i = 0; i < SIZEOF(brightness_options_values); i++){ 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); lv_create_custom_menu_dropdown("Brightness", panel, brightness_dropdown, brightness_options, brightness_settings_index);
#ifndef CYD_SCREEN_DISABLE_TIMEOUT #ifndef CYD_SCREEN_DISABLE_TIMEOUT
int wake_timeout_settings_index = 0; int wake_timeout_settings_index = 0;
for (int i = 0; i < SIZEOF(wake_timeout_options_values); i++){ 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); lv_create_custom_menu_dropdown("Wake Timeout", panel, wake_timeout_dropdown, wake_timeout_options, wake_timeout_settings_index);
#endif #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); 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("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_switch("Auto Update", panel, auto_ota_update_switch, global_config.auto_ota_update);
lv_create_custom_menu_label("Version", panel, REPO_VERSION " "); lv_create_custom_menu_label("Version", panel, REPO_VERSION " ");
@@ -188,4 +193,10 @@ void settings_panel_init(lv_obj_t* panel){
else { else {
lv_create_custom_menu_label("Device", panel, ARDUINO_BOARD " "); 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");
} }

View File

@@ -5,16 +5,23 @@
#include "../core/http_client.h" #include "../core/http_client.h"
#include "../core/lv_setup.h" #include "../core/lv_setup.h"
#include "../core/macros_query.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){ static void btn_switch_printer(lv_event_t *e){
lv_obj_t *btn = lv_event_get_target(e); lv_obj_t *btn = lv_event_get_target(e);
PRINTER_CONFIG * config = (PRINTER_CONFIG*)lv_event_get_user_data(e); PRINTER_CONFIG * config = (PRINTER_CONFIG*)lv_event_get_user_data(e);
int index = config - global_config.printer_config; int index = config - global_config.printer_config;
set_printer_config_index(index); switch_printer(index);
set_color_scheme();
_macros_query_internal();
_power_devices_query_internal();
lv_obj_del(lv_obj_get_parent(lv_obj_get_parent(btn))); lv_obj_del(lv_obj_get_parent(lv_obj_get_parent(btn)));
} }

View File

@@ -1,4 +1,5 @@
#pragma once #pragma once
void switch_printer(int index);
void switch_printer_init(); void switch_printer_init();
void draw_switch_printer_button(); void draw_switch_printer_button();