mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 13:43:25 +00:00
Add macros to not ready screen
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "lvgl.h"
|
||||
#include "nav_buttons.h"
|
||||
#include "ui_utils.h"
|
||||
#include "panels/panel.h"
|
||||
#include "../core/macros_query.h"
|
||||
|
||||
char extruder_temp_buff[20];
|
||||
char bed_temp_buff[20];
|
||||
@@ -18,6 +20,29 @@ static void btn_click_firmware_restart(lv_event_t * e){
|
||||
send_gcode(false, "FIRMWARE_RESTART");
|
||||
}
|
||||
|
||||
void error_ui_macros_close(lv_event_t * e){
|
||||
lv_obj_t * obj = (lv_obj_t *)lv_event_get_user_data(e);
|
||||
lv_obj_del(obj);
|
||||
}
|
||||
|
||||
void error_ui_macros_open(lv_event_t * e){
|
||||
lv_obj_t * panel = lv_create_empty_panel(lv_scr_act());
|
||||
lv_obj_set_style_bg_opa(panel, LV_OPA_COVER, 0);
|
||||
lv_layout_flex_column(panel);
|
||||
lv_obj_set_size(panel, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_HEIGHT_PX - CYD_SCREEN_GAP_PX);
|
||||
lv_obj_align(panel, LV_ALIGN_TOP_LEFT, 0, CYD_SCREEN_GAP_PX);
|
||||
|
||||
lv_obj_t * button = lv_btn_create(panel);
|
||||
lv_obj_set_size(button, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_event_cb(button, error_ui_macros_close, LV_EVENT_CLICKED, panel);
|
||||
|
||||
lv_obj_t * label = lv_label_create(button);
|
||||
lv_label_set_text(label, LV_SYMBOL_CLOSE " Close");
|
||||
lv_obj_center(label);
|
||||
|
||||
macros_panel_add_macros_to_panel(panel, macros_query());
|
||||
}
|
||||
|
||||
void error_ui(){
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
@@ -56,8 +81,19 @@ void error_ui(){
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Firmware Restart");
|
||||
lv_label_set_text(label, "FW Restart");
|
||||
lv_obj_center(label);
|
||||
|
||||
if (macros_query().count >= 1){
|
||||
btn = lv_btn_create(button_row);
|
||||
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_add_event_cb(btn, error_ui_macros_open, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_flex_grow(btn, 1);
|
||||
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text(label, "Macros");
|
||||
lv_obj_center(label);
|
||||
}
|
||||
}
|
||||
|
||||
void check_if_screen_needs_to_be_disabled(){
|
||||
|
||||
@@ -19,24 +19,7 @@ static void btn_goto_settings(lv_event_t * e){
|
||||
nav_buttons_setup(3);
|
||||
}
|
||||
|
||||
void macros_panel_init(lv_obj_t* panel) {
|
||||
lv_obj_t * btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, btn_goto_settings, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_size(btn, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_GAP_PX);
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_SETTINGS " Screen Settings");
|
||||
lv_obj_center(label);
|
||||
|
||||
MACROSQUERY query = macros_query();
|
||||
if (query.count == 0){
|
||||
label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "No macros found.\nMacros with the description\n\"CYD_SCREEN_MACRO\"\nwill show up here.");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
void macros_panel_add_macros_to_panel(lv_obj_t * panel, MACROSQUERY query){
|
||||
lv_obj_t * root_panel = lv_create_empty_panel(panel);
|
||||
lv_obj_set_size(root_panel, CYD_SCREEN_PANEL_WIDTH_PX, CYD_SCREEN_HEIGHT_PX - CYD_SCREEN_MIN_BUTTON_HEIGHT_PX - CYD_SCREEN_GAP_PX * 2);
|
||||
lv_obj_align(root_panel, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX + CYD_SCREEN_GAP_PX * 2);
|
||||
@@ -67,4 +50,25 @@ void macros_panel_init(lv_obj_t* panel) {
|
||||
lv_obj_set_style_line_width(line, 1, 0);
|
||||
lv_obj_set_style_line_color(line, lv_color_hex(0xAAAAAA), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void macros_panel_init(lv_obj_t* panel) {
|
||||
lv_obj_t * btn = lv_btn_create(panel);
|
||||
lv_obj_add_event_cb(btn, btn_goto_settings, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_set_size(btn, CYD_SCREEN_PANEL_WIDTH_PX - CYD_SCREEN_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||
lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, CYD_SCREEN_GAP_PX);
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_SETTINGS " Screen Settings");
|
||||
lv_obj_center(label);
|
||||
|
||||
MACROSQUERY query = macros_query();
|
||||
if (query.count == 0){
|
||||
label = lv_label_create(panel);
|
||||
lv_label_set_text(label, "No macros found.\nMacros with the description\n\"CYD_SCREEN_MACRO\"\nwill show up here.");
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
macros_panel_add_macros_to_panel(panel, query);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "lvgl.h"
|
||||
#include "../../core/macros_query.h"
|
||||
|
||||
#define SIZEOF(arr) (sizeof(arr) / sizeof(*arr))
|
||||
|
||||
@@ -8,4 +9,5 @@ void print_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);
|
||||
void stats_panel_init(lv_obj_t* panel);
|
||||
void stats_panel_init(lv_obj_t* panel);
|
||||
void macros_panel_add_macros_to_panel(lv_obj_t * panel, MACROSQUERY query);
|
||||
Reference in New Issue
Block a user