From e5390e731f6f5b3654085cccca75a3a903358260 Mon Sep 17 00:00:00 2001 From: suchmememanyskill <38142618+suchmememanyskill@users.noreply.github.com> Date: Sat, 9 Nov 2024 12:30:38 +0100 Subject: [PATCH] Allow accessing device settings from wifi panel --- .../serial_klipper_printer_integration.cpp | 2 ++ CYD-Klipper/src/ui/panels/panel.h | 4 ++- CYD-Klipper/src/ui/wifi_setup.cpp | 28 ++++++++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CYD-Klipper/src/core/klipper-serial/serial_klipper_printer_integration.cpp b/CYD-Klipper/src/core/klipper-serial/serial_klipper_printer_integration.cpp index 4fe6f4d..a071e37 100644 --- a/CYD-Klipper/src/core/klipper-serial/serial_klipper_printer_integration.cpp +++ b/CYD-Klipper/src/core/klipper-serial/serial_klipper_printer_integration.cpp @@ -81,6 +81,8 @@ typedef struct unsigned char* data; } BinaryResponse; +// Request: {timeout} {method} {endpoint} +// Response: {8 char 0's padded body length}{body} bool make_binary_request(BinaryResponse* data, int timeout_ms, HttpRequestType requestType, const char* endpoint) { serial_console::global_disable_serial_console = true; diff --git a/CYD-Klipper/src/ui/panels/panel.h b/CYD-Klipper/src/ui/panels/panel.h index ef8b27e..9e97c49 100644 --- a/CYD-Klipper/src/ui/panels/panel.h +++ b/CYD-Klipper/src/ui/panels/panel.h @@ -11,4 +11,6 @@ void macros_panel_init(lv_obj_t* panel); void stats_panel_init(lv_obj_t* panel); void printer_panel_init(lv_obj_t* panel); void error_panel_init(lv_obj_t* panel); -void connecting_panel_init(lv_obj_t* panel); \ No newline at end of file +void connecting_panel_init(lv_obj_t* panel); + +void settings_section_device(lv_obj_t* panel); \ No newline at end of file diff --git a/CYD-Klipper/src/ui/wifi_setup.cpp b/CYD-Klipper/src/ui/wifi_setup.cpp index bad8f03..7a46e4e 100644 --- a/CYD-Klipper/src/ui/wifi_setup.cpp +++ b/CYD-Klipper/src/ui/wifi_setup.cpp @@ -6,6 +6,7 @@ #include "../core/data_setup.h" #include "../core/lv_setup.h" #include "serial/serial_console.h" +#include "panels/panel.h" void wifi_init_inner(); void wifi_pass_entry(const char* ssid); @@ -110,6 +111,23 @@ static void wifi_btn_skip_setup(lv_event_t * e){ global_config.wifi_configuration_skipped = true; } +static void wifi_btn_settings(lv_event_t * e){ + lv_obj_clean(lv_scr_act()); + lv_obj_t * panel = lv_create_empty_panel(lv_scr_act()); + lv_obj_set_size(panel, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_HEIGHT_PX); + lv_layout_flex_column(panel); + + lv_obj_t * btn = lv_btn_create(panel); + lv_obj_add_event_cb(btn, reset_btn_event_handler, LV_EVENT_CLICKED, NULL); + lv_obj_set_size(btn, LV_PCT(100), CYD_SCREEN_MIN_BUTTON_HEIGHT_PX); + + lv_obj_t * label = lv_label_create(btn); + lv_label_set_text(label, "Return to WiFi Setup"); + lv_obj_center(label); + + settings_section_device(panel); +} + void wifi_init_inner(){ WiFi.disconnect(); lv_obj_clean(lv_scr_act()); @@ -166,8 +184,16 @@ void wifi_init_inner(){ lv_obj_set_flex_grow(label, 1); lv_obj_t * btn = lv_btn_create(top_row); + lv_obj_add_event_cb(btn, wifi_btn_settings, LV_EVENT_CLICKED, NULL); + lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX); + + label = lv_label_create(btn); + lv_label_set_text(label, LV_SYMBOL_SETTINGS); + lv_obj_center(label); + + btn = lv_btn_create(top_row); lv_obj_add_event_cb(btn, wifi_btn_skip_setup, LV_EVENT_CLICKED, NULL); - lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX); + lv_obj_set_size(btn, CYD_SCREEN_MIN_BUTTON_WIDTH_PX * 1.5, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX); label = lv_label_create(btn); lv_label_set_text(label, "Skip");