diff --git a/CYD-Klipper/src/ui/main_ui.cpp b/CYD-Klipper/src/ui/main_ui.cpp index 4bff2e1..3a081dc 100644 --- a/CYD-Klipper/src/ui/main_ui.cpp +++ b/CYD-Klipper/src/ui/main_ui.cpp @@ -30,8 +30,11 @@ static void on_state_change(void * s, lv_msg_t * m){ else if (printer.state == PRINTER_STATE_ERROR){ nav_buttons_setup(PANEL_ERROR); } + else if (printer.state == PRINTER_STATE_IDLE) { + nav_buttons_setup(PANEL_FILES); + } else { - nav_buttons_setup(PANEL_PRINT); + nav_buttons_setup(PANEL_PROGRESS); } } diff --git a/CYD-Klipper/src/ui/nav_buttons.cpp b/CYD-Klipper/src/ui/nav_buttons.cpp index e2e55ae..d02f5de 100644 --- a/CYD-Klipper/src/ui/nav_buttons.cpp +++ b/CYD-Klipper/src/ui/nav_buttons.cpp @@ -58,7 +58,11 @@ static void update_printer_data_time(lv_event_t * e){ } static void btn_click_files(lv_event_t * e){ - nav_buttons_setup(PANEL_PRINT); + nav_buttons_setup(PANEL_FILES); +} + +static void btn_click_progress(lv_event_t * e){ + nav_buttons_setup(PANEL_PROGRESS); } static void btn_click_move(lv_event_t * e){ @@ -115,7 +119,7 @@ void create_button(const char* icon, const char* name, lv_event_cb_t button_clic lv_obj_add_style(label, &nav_button_text_style, 0); } -void nav_buttons_setup(unsigned char active_panel){ +void nav_buttons_setup(PANEL_TYPE active_panel){ lv_obj_clean(lv_scr_act()); lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE); @@ -134,7 +138,14 @@ void nav_buttons_setup(unsigned char active_panel){ if (printer.state > PRINTER_STATE_ERROR){ // Files/Print - create_button(LV_SYMBOL_COPY, "Idle", btn_click_files, update_printer_data_time, root_panel); + if (printer.state == PRINTER_STATE_IDLE) + { + create_button(LV_SYMBOL_COPY, "Idle", btn_click_files, update_printer_data_time, root_panel); + } + else + { + create_button(LV_SYMBOL_FILE, "Paused", btn_click_progress, update_printer_data_time, root_panel); + } // Move create_button(printer.state == PRINTER_STATE_PRINTING ? LV_SYMBOL_EDIT : LV_SYMBOL_CHARGE, "Z?", btn_click_move, update_printer_data_z_pos, root_panel); @@ -165,8 +176,8 @@ void nav_buttons_setup(unsigned char active_panel){ lv_obj_align(panel, LV_ALIGN_TOP_RIGHT, 0, 0); switch (active_panel){ - case PANEL_PRINT: - print_panel_init(panel); + case PANEL_FILES: + files_panel_init(panel); break; case PANEL_MOVE: move_panel_init(panel); @@ -192,6 +203,9 @@ void nav_buttons_setup(unsigned char active_panel){ case PANEL_CONNECTING: connecting_panel_init(panel); break; + case PANEL_PROGRESS: + progress_panel_init(panel); + break; } lv_msg_send(DATA_PRINTER_DATA, &printer); diff --git a/CYD-Klipper/src/ui/nav_buttons.h b/CYD-Klipper/src/ui/nav_buttons.h index 57f0bcb..f3337a6 100644 --- a/CYD-Klipper/src/ui/nav_buttons.h +++ b/CYD-Klipper/src/ui/nav_buttons.h @@ -1,14 +1,17 @@ #pragma once -#define PANEL_PRINT 0 -#define PANEL_MOVE 1 -#define PANEL_TEMP 2 -#define PANEL_SETTINGS 3 -#define PANEL_MACROS 4 -#define PANEL_STATS 5 -#define PANEL_PRINTER 6 -#define PANEL_ERROR 7 -#define PANEL_CONNECTING 8 +enum PANEL_TYPE { + PANEL_FILES = 0, + PANEL_MOVE = 1, + PANEL_TEMP = 2, + PANEL_SETTINGS = 3, + PANEL_MACROS = 4, + PANEL_STATS = 5, + PANEL_PRINTER = 6, + PANEL_ERROR = 7, + PANEL_CONNECTING = 8, + PANEL_PROGRESS = 9, +}; -void nav_buttons_setup(unsigned char active_panel); +void nav_buttons_setup(PANEL_TYPE active_panel); void nav_style_setup(); \ No newline at end of file diff --git a/CYD-Klipper/src/ui/panels/print_panel.cpp b/CYD-Klipper/src/ui/panels/files_panel.cpp similarity index 95% rename from CYD-Klipper/src/ui/panels/print_panel.cpp rename to CYD-Klipper/src/ui/panels/files_panel.cpp index 5bf267d..0ccbf23 100644 --- a/CYD-Klipper/src/ui/panels/print_panel.cpp +++ b/CYD-Klipper/src/ui/panels/files_panel.cpp @@ -23,6 +23,10 @@ static void btn_print_file(lv_event_t * e){ } static void btn_print_file_verify(lv_event_t * e){ + if (printer.state != PRINTER_STATE_IDLE){ + return; + } + const auto button_size_mult = 1.3f; lv_obj_t * btn = lv_event_get_target(e); @@ -76,12 +80,7 @@ static void btn_print_file_verify(lv_event_t * e){ } } -void print_panel_init(lv_obj_t* panel){ - if (printer.state == PRINTER_STATE_PRINTING || printer.state == PRINTER_STATE_PAUSED){ - progress_panel_init(panel); - return; - } - +void files_panel_init(lv_obj_t* panel){ clear_img_mem(); lv_obj_t * list = lv_list_create(panel); diff --git a/CYD-Klipper/src/ui/panels/panel.h b/CYD-Klipper/src/ui/panels/panel.h index 319fe08..7c3c283 100644 --- a/CYD-Klipper/src/ui/panels/panel.h +++ b/CYD-Klipper/src/ui/panels/panel.h @@ -5,7 +5,7 @@ void settings_panel_init(lv_obj_t* panel); void temp_panel_init(lv_obj_t* panel); -void print_panel_init(lv_obj_t* panel); +void files_panel_init(lv_obj_t* panel); void move_panel_init(lv_obj_t* panel); void progress_panel_init(lv_obj_t* panel); void macros_panel_init(lv_obj_t* panel); diff --git a/CYD-Klipper/src/ui/panels/stats_panel.cpp b/CYD-Klipper/src/ui/panels/stats_panel.cpp index e9d361b..df19e41 100644 --- a/CYD-Klipper/src/ui/panels/stats_panel.cpp +++ b/CYD-Klipper/src/ui/panels/stats_panel.cpp @@ -1,9 +1,14 @@ #include "panel.h" #include "../ui_utils.h" #include "../../core/data_setup.h" +#include "../nav_buttons.h" #include #include +static void swap_to_files_menu(lv_event_t * e) { + nav_buttons_setup(PANEL_FILES); +} + static void set_fan_speed_text(lv_event_t * e) { lv_obj_t * label = lv_event_get_target(e); char data[64]; @@ -248,6 +253,16 @@ void stats_panel_init(lv_obj_t* panel) { lv_obj_set_size(right_panel, panel_width, CYD_SCREEN_PANEL_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2); lv_layout_flex_column(right_panel, LV_FLEX_ALIGN_CENTER); lv_obj_align(right_panel, LV_ALIGN_TOP_RIGHT, -1 * CYD_SCREEN_GAP_PX, CYD_SCREEN_GAP_PX); + + if (printer.state >= PRINTER_STATE_PRINTING){ + lv_obj_t * btn = lv_btn_create(right_panel); + lv_obj_set_size(btn, CYD_SCREEN_PANEL_WIDTH_PX / 2 - CYD_SCREEN_GAP_PX * 3, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX); + lv_obj_add_event_cb(btn, swap_to_files_menu, LV_EVENT_CLICKED, NULL); + + lv_obj_t * label = lv_label_create(btn); + lv_label_set_text(label, "Files"); + lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); + } create_state_button(right_panel, set_fan_speed_text, open_fan_speed_panel); create_state_button(right_panel, set_zoffset_text, open_zoffset_panel);