Add files menu to params panel while printing (implement #80)

This commit is contained in:
suchmememanyskill
2024-06-11 20:52:51 +02:00
parent 4ac87c8ffc
commit d4645f4fa1
6 changed files with 57 additions and 23 deletions

View File

@@ -30,8 +30,11 @@ static void on_state_change(void * s, lv_msg_t * m){
else if (printer.state == PRINTER_STATE_ERROR){ else if (printer.state == PRINTER_STATE_ERROR){
nav_buttons_setup(PANEL_ERROR); nav_buttons_setup(PANEL_ERROR);
} }
else if (printer.state == PRINTER_STATE_IDLE) {
nav_buttons_setup(PANEL_FILES);
}
else { else {
nav_buttons_setup(PANEL_PRINT); nav_buttons_setup(PANEL_PROGRESS);
} }
} }

View File

@@ -58,7 +58,11 @@ static void update_printer_data_time(lv_event_t * e){
} }
static void btn_click_files(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){ 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); 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_clean(lv_scr_act());
lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE); 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){ if (printer.state > PRINTER_STATE_ERROR){
// Files/Print // 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 // 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); 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); lv_obj_align(panel, LV_ALIGN_TOP_RIGHT, 0, 0);
switch (active_panel){ switch (active_panel){
case PANEL_PRINT: case PANEL_FILES:
print_panel_init(panel); files_panel_init(panel);
break; break;
case PANEL_MOVE: case PANEL_MOVE:
move_panel_init(panel); move_panel_init(panel);
@@ -192,6 +203,9 @@ void nav_buttons_setup(unsigned char active_panel){
case PANEL_CONNECTING: case PANEL_CONNECTING:
connecting_panel_init(panel); connecting_panel_init(panel);
break; break;
case PANEL_PROGRESS:
progress_panel_init(panel);
break;
} }
lv_msg_send(DATA_PRINTER_DATA, &printer); lv_msg_send(DATA_PRINTER_DATA, &printer);

View File

@@ -1,14 +1,17 @@
#pragma once #pragma once
#define PANEL_PRINT 0 enum PANEL_TYPE {
#define PANEL_MOVE 1 PANEL_FILES = 0,
#define PANEL_TEMP 2 PANEL_MOVE = 1,
#define PANEL_SETTINGS 3 PANEL_TEMP = 2,
#define PANEL_MACROS 4 PANEL_SETTINGS = 3,
#define PANEL_STATS 5 PANEL_MACROS = 4,
#define PANEL_PRINTER 6 PANEL_STATS = 5,
#define PANEL_ERROR 7 PANEL_PRINTER = 6,
#define PANEL_CONNECTING 8 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(); void nav_style_setup();

View File

@@ -23,6 +23,10 @@ static void btn_print_file(lv_event_t * e){
} }
static void btn_print_file_verify(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; const auto button_size_mult = 1.3f;
lv_obj_t * btn = lv_event_get_target(e); 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){ void files_panel_init(lv_obj_t* panel){
if (printer.state == PRINTER_STATE_PRINTING || printer.state == PRINTER_STATE_PAUSED){
progress_panel_init(panel);
return;
}
clear_img_mem(); clear_img_mem();
lv_obj_t * list = lv_list_create(panel); lv_obj_t * list = lv_list_create(panel);

View File

@@ -5,7 +5,7 @@
void settings_panel_init(lv_obj_t* panel); void settings_panel_init(lv_obj_t* panel);
void temp_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 move_panel_init(lv_obj_t* panel);
void progress_panel_init(lv_obj_t* panel); void progress_panel_init(lv_obj_t* panel);
void macros_panel_init(lv_obj_t* panel); void macros_panel_init(lv_obj_t* panel);

View File

@@ -1,9 +1,14 @@
#include "panel.h" #include "panel.h"
#include "../ui_utils.h" #include "../ui_utils.h"
#include "../../core/data_setup.h" #include "../../core/data_setup.h"
#include "../nav_buttons.h"
#include <stdio.h> #include <stdio.h>
#include <Esp.h> #include <Esp.h>
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) { static void set_fan_speed_text(lv_event_t * e) {
lv_obj_t * label = lv_event_get_target(e); lv_obj_t * label = lv_event_get_target(e);
char data[64]; 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_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_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); 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_fan_speed_text, open_fan_speed_panel);
create_state_button(right_panel, set_zoffset_text, open_zoffset_panel); create_state_button(right_panel, set_zoffset_text, open_zoffset_panel);