Skip to content

Commit

Permalink
Make klipper error screen responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
suchmememanyskill committed Jan 29, 2024
1 parent c5b6401 commit de1833e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
8 changes: 4 additions & 4 deletions CYD-Klipper/src/core/device/ESP32-2432S028R.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ XPT2046_Touchscreen touchscreen(XPT2046_CS, XPT2046_IRQ);
uint32_t LV_EVENT_GET_COMP_CHILD;

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();

Expand Down Expand Up @@ -242,13 +242,13 @@ void screen_setup()

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*/
static lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = TFT_HEIGHT;
disp_drv.ver_res = TFT_WIDTH;
disp_drv.hor_res = CYD_SCREEN_WIDTH_PX;
disp_drv.ver_res = CYD_SCREEN_HEIGHT_PX;
disp_drv.flush_cb = screen_lv_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register(&disp_drv);
Expand Down
31 changes: 20 additions & 11 deletions CYD-Klipper/src/ui/main_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../core/screen_driver.h"
#include "lvgl.h"
#include "nav_buttons.h"
#include "ui_utils.h"

char extruder_temp_buff[20];
char bed_temp_buff[20];
Expand All @@ -19,32 +20,40 @@ static void btn_click_firmware_restart(lv_event_t * e){

void error_ui(){
lv_obj_clean(lv_scr_act());

lv_obj_t * panel = lv_create_empty_panel(lv_scr_act());
lv_layout_flex_column(panel);
lv_obj_set_size(panel, CYD_SCREEN_WIDTH_PX, CYD_SCREEN_HEIGHT_PX);
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);

lv_obj_t * label;
label = lv_label_create(lv_scr_act());
label = lv_label_create(panel);
lv_label_set_text(label, LV_SYMBOL_WARNING " Printer is not ready");
lv_obj_align(label, LV_ALIGN_TOP_LEFT, 10, 10);

label = lv_label_create(lv_scr_act());
label = lv_label_create(panel);
lv_label_set_text(label, printer.state_message);
lv_obj_align(label, LV_ALIGN_TOP_LEFT, 10, 30);
lv_obj_set_size(label, TFT_HEIGHT - 20, TFT_WIDTH - 30);
lv_obj_set_width(label, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_BIG_GAP_PX * 2);
lv_obj_clear_flag(label, LV_OBJ_FLAG_SCROLLABLE);
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);

lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_align(btn, LV_ALIGN_BOTTOM_LEFT, 10, -10);
lv_obj_set_size(btn, TFT_HEIGHT / 2 - 15, 30);
lv_obj_t * button_row = lv_create_empty_panel(panel);
lv_obj_set_size(button_row, CYD_SCREEN_WIDTH_PX - CYD_SCREEN_BIG_GAP_PX * 2, CYD_SCREEN_MIN_BUTTON_HEIGHT_PX);
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_set_flex_grow(btn, 1);

label = lv_label_create(btn);
lv_label_set_text(label, "Restart");
lv_obj_center(label);

btn = lv_btn_create(lv_scr_act());
lv_obj_align(btn, LV_ALIGN_BOTTOM_RIGHT, -10, -10);
lv_obj_set_size(btn, TFT_HEIGHT / 2 - 15, 30);
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_firmware_restart, LV_EVENT_CLICKED, NULL);
lv_obj_set_flex_grow(btn, 1);

label = lv_label_create(btn);
lv_label_set_text(label, "Firmware Restart");
Expand Down

0 comments on commit de1833e

Please sign in to comment.