mirror of
https://github.com/suchmememanyskill/CYD-Klipper.git
synced 2026-03-21 05:33:24 +00:00
Make klipper error screen responsive
This commit is contained in:
@@ -21,7 +21,7 @@ XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);
|
|||||||
uint32_t LV_EVENT_GET_COMP_CHILD;
|
uint32_t LV_EVENT_GET_COMP_CHILD;
|
||||||
|
|
||||||
static lv_disp_draw_buf_t draw_buf;
|
static lv_disp_draw_buf_t draw_buf;
|
||||||
static lv_color_t buf[TFT_WIDTH * TFT_HEIGHT / 10];
|
static lv_color_t buf[CYD_SCREEN_HEIGHT_PX * CYD_SCREEN_WIDTH_PX / 10];
|
||||||
|
|
||||||
TFT_eSPI tft = TFT_eSPI();
|
TFT_eSPI tft = TFT_eSPI();
|
||||||
|
|
||||||
@@ -242,13 +242,13 @@ void screen_setup()
|
|||||||
|
|
||||||
touchscreen_calibrate(false);
|
touchscreen_calibrate(false);
|
||||||
|
|
||||||
lv_disp_draw_buf_init(&draw_buf, buf, NULL, TFT_WIDTH * TFT_HEIGHT / 10);
|
lv_disp_draw_buf_init(&draw_buf, buf, NULL, CYD_SCREEN_HEIGHT_PX * CYD_SCREEN_WIDTH_PX / 10);
|
||||||
|
|
||||||
/*Initialize the display*/
|
/*Initialize the display*/
|
||||||
static lv_disp_drv_t disp_drv;
|
static lv_disp_drv_t disp_drv;
|
||||||
lv_disp_drv_init(&disp_drv);
|
lv_disp_drv_init(&disp_drv);
|
||||||
disp_drv.hor_res = TFT_HEIGHT;
|
disp_drv.hor_res = CYD_SCREEN_WIDTH_PX;
|
||||||
disp_drv.ver_res = TFT_WIDTH;
|
disp_drv.ver_res = CYD_SCREEN_HEIGHT_PX;
|
||||||
disp_drv.flush_cb = screen_lv_flush;
|
disp_drv.flush_cb = screen_lv_flush;
|
||||||
disp_drv.draw_buf = &draw_buf;
|
disp_drv.draw_buf = &draw_buf;
|
||||||
lv_disp_drv_register(&disp_drv);
|
lv_disp_drv_register(&disp_drv);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../core/screen_driver.h"
|
#include "../core/screen_driver.h"
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
#include "nav_buttons.h"
|
#include "nav_buttons.h"
|
||||||
|
#include "ui_utils.h"
|
||||||
|
|
||||||
char extruder_temp_buff[20];
|
char extruder_temp_buff[20];
|
||||||
char bed_temp_buff[20];
|
char bed_temp_buff[20];
|
||||||
@@ -20,31 +21,39 @@ static void btn_click_firmware_restart(lv_event_t * e){
|
|||||||
void error_ui(){
|
void error_ui(){
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
|
|
||||||
lv_obj_t * label;
|
lv_obj_t * panel = lv_create_empty_panel(lv_scr_act());
|
||||||
label = lv_label_create(lv_scr_act());
|
lv_layout_flex_column(panel);
|
||||||
lv_label_set_text(label, LV_SYMBOL_WARNING " Printer is not ready");
|
lv_obj_set_size(panel, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_HEIGHT_PX);
|
||||||
lv_obj_align(label, LV_ALIGN_TOP_LEFT, 10, 10);
|
lv_obj_set_style_pad_all(panel, CYD_SCREEN_BIG_GAP_PX, 0);
|
||||||
|
lv_obj_set_flex_align(panel, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||||||
|
|
||||||
label = lv_label_create(lv_scr_act());
|
lv_obj_t * label;
|
||||||
|
label = lv_label_create(panel);
|
||||||
|
lv_label_set_text(label, LV_SYMBOL_WARNING " Printer is not ready");
|
||||||
|
|
||||||
|
label = lv_label_create(panel);
|
||||||
lv_label_set_text(label, printer.state_message);
|
lv_label_set_text(label, printer.state_message);
|
||||||
lv_obj_align(label, LV_ALIGN_TOP_LEFT, 10, 30);
|
lv_obj_set_width(label, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_BIG_GAP_PX * 2);
|
||||||
lv_obj_set_size(label, TFT_HEIGHT - 20, TFT_WIDTH - 30);
|
|
||||||
lv_obj_clear_flag(label, LV_OBJ_FLAG_SCROLLABLE);
|
lv_obj_clear_flag(label, LV_OBJ_FLAG_SCROLLABLE);
|
||||||
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
|
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
|
||||||
|
|
||||||
lv_obj_t * btn = lv_btn_create(lv_scr_act());
|
lv_obj_t * button_row = lv_create_empty_panel(panel);
|
||||||
lv_obj_align(btn, LV_ALIGN_BOTTOM_LEFT, 10, -10);
|
lv_obj_set_size(button_row, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_BIG_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
lv_obj_set_size(btn, TFT_HEIGHT / 2 - 15, 30);
|
lv_layout_flex_row(button_row);
|
||||||
|
|
||||||
|
lv_obj_t * btn = lv_btn_create(button_row);
|
||||||
|
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
lv_obj_add_event_cb(btn, btn_click_restart, LV_EVENT_CLICKED, NULL);
|
lv_obj_add_event_cb(btn, btn_click_restart, LV_EVENT_CLICKED, NULL);
|
||||||
|
lv_obj_set_flex_grow(btn, 1);
|
||||||
|
|
||||||
label = lv_label_create(btn);
|
label = lv_label_create(btn);
|
||||||
lv_label_set_text(label, "Restart");
|
lv_label_set_text(label, "Restart");
|
||||||
lv_obj_center(label);
|
lv_obj_center(label);
|
||||||
|
|
||||||
btn = lv_btn_create(lv_scr_act());
|
btn = lv_btn_create(button_row);
|
||||||
lv_obj_align(btn, LV_ALIGN_BOTTOM_RIGHT, -10, -10);
|
lv_obj_set_height(btn, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
|
||||||
lv_obj_set_size(btn, TFT_HEIGHT / 2 - 15, 30);
|
|
||||||
lv_obj_add_event_cb(btn, btn_click_firmware_restart, LV_EVENT_CLICKED, NULL);
|
lv_obj_add_event_cb(btn, btn_click_firmware_restart, LV_EVENT_CLICKED, NULL);
|
||||||
|
lv_obj_set_flex_grow(btn, 1);
|
||||||
|
|
||||||
label = lv_label_create(btn);
|
label = lv_label_create(btn);
|
||||||
lv_label_set_text(label, "Firmware Restart");
|
lv_label_set_text(label, "Firmware Restart");
|
||||||
|
|||||||
Reference in New Issue
Block a user