Add MKS Robin E3P, improve LVGL UI (#19442)
This commit is contained in:
committed by
Scott Lahteine
parent
32cd5a3dc4
commit
33788c8405
@@ -35,6 +35,7 @@
|
||||
#include "../../../../module/motion.h"
|
||||
#include "../../../../sd/cardreader.h"
|
||||
#include "../../../../gcode/queue.h"
|
||||
#include "../../../../gcode/gcode.h"
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../../../feature/powerloss.h"
|
||||
@@ -43,10 +44,11 @@
|
||||
#include "../../../ultralcd.h"
|
||||
#endif
|
||||
|
||||
extern lv_group_t * g;
|
||||
static lv_obj_t * scr;
|
||||
static lv_obj_t * labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime;
|
||||
static lv_obj_t * labelPause, * labelStop, * labelOperat;
|
||||
static lv_obj_t * bar1;
|
||||
static lv_obj_t *labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime;
|
||||
static lv_obj_t *labelPause, * labelStop, * labelOperat;
|
||||
static lv_obj_t * bar1, *bar1ValueText;
|
||||
static lv_obj_t * buttonPause, *buttonOperat, *buttonStop;
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
@@ -57,8 +59,6 @@ static lv_obj_t * buttonPause, *buttonOperat, *buttonStop;
|
||||
#define ID_STOP 2
|
||||
#define ID_OPTION 3
|
||||
|
||||
lv_style_t lv_bar_style_indic;
|
||||
|
||||
uint8_t once_flag = 0;
|
||||
extern uint32_t To_pre_view;
|
||||
extern uint8_t flash_preview_begin;
|
||||
@@ -82,21 +82,23 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||
stop_print_time();
|
||||
uiCfg.print_state = PAUSING;
|
||||
#endif
|
||||
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0);
|
||||
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_resume.bin");
|
||||
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_resume.bin");
|
||||
lv_label_set_text(labelPause, printing_menu.resume);
|
||||
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
|
||||
}
|
||||
else if (uiCfg.print_state == PAUSED) {
|
||||
uiCfg.print_state = RESUMING;
|
||||
// if (IS_SD_PAUSED())queue.inject_P(PSTR("M24"));// queue.inject_P(M24_STR);
|
||||
lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
|
||||
lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
|
||||
lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, "F:/bmp_pause.bin");
|
||||
lv_label_set_text(labelPause, printing_menu.pause);
|
||||
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
|
||||
}
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
else if (uiCfg.print_state == REPRINTING) {
|
||||
uiCfg.print_state = REPRINTED;
|
||||
lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
|
||||
lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
|
||||
lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, "F:/bmp_pause.bin");
|
||||
lv_label_set_text(labelPause, printing_menu.pause);
|
||||
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
|
||||
// recovery.resume();
|
||||
@@ -115,7 +117,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||
}
|
||||
else if (event == LV_EVENT_RELEASED) {
|
||||
if (gcode_preview_over != 1) {
|
||||
lv_obj_del(scr);
|
||||
lv_clear_printing();
|
||||
lv_draw_dialog(DIALOG_TYPE_STOP);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +128,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
|
||||
}
|
||||
else if (event == LV_EVENT_RELEASED) {
|
||||
if (gcode_preview_over != 1) {
|
||||
lv_obj_del(scr);
|
||||
lv_clear_printing();
|
||||
lv_draw_operation();
|
||||
}
|
||||
}
|
||||
@@ -159,88 +161,71 @@ void lv_draw_printing(void) {
|
||||
|
||||
lv_refr_now(lv_refr_get_disp_refreshing());
|
||||
|
||||
LV_IMG_DECLARE(bmp_pic_150x80);
|
||||
LV_IMG_DECLARE(bmp_pic_45x45);
|
||||
|
||||
/*Create an Image button*/
|
||||
buttonExt1 = lv_imgbtn_create(scr, NULL);
|
||||
if (EXTRUDERS == 2)
|
||||
buttonExt2 = lv_imgbtn_create(scr, NULL);
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
buttonBedstate = lv_imgbtn_create(scr, NULL);
|
||||
// Create image buttons
|
||||
buttonExt1 = lv_img_create(scr, NULL);
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
buttonExt2 = lv_img_create(scr, NULL);
|
||||
#endif
|
||||
|
||||
buttonFanstate = lv_imgbtn_create(scr, NULL);
|
||||
buttonZpos = lv_imgbtn_create(scr, NULL);
|
||||
#if HAS_HEATED_BED
|
||||
buttonBedstate = lv_img_create(scr, NULL);
|
||||
#endif
|
||||
buttonFanstate = lv_img_create(scr, NULL);
|
||||
buttonTime = lv_img_create(scr, NULL);
|
||||
buttonZpos = lv_img_create(scr, NULL);
|
||||
buttonPause = lv_imgbtn_create(scr, NULL);
|
||||
buttonStop = lv_imgbtn_create(scr, NULL);
|
||||
buttonOperat = lv_imgbtn_create(scr, NULL);
|
||||
buttonTime = lv_imgbtn_create(scr, NULL);
|
||||
|
||||
lv_obj_set_event_cb_mks(buttonExt1, event_handler, 0, "bmp_ext1_state.bin", 0);
|
||||
lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_REL, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_PR, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
lv_obj_clear_protect(buttonExt1, LV_PROTECT_FOLLOW);
|
||||
lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin");
|
||||
#if 1
|
||||
if (EXTRUDERS == 2) {
|
||||
lv_obj_set_event_cb_mks(buttonExt2, event_handler, 0, "bmp_ext2_state.bin", 0);
|
||||
lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_REL, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_PR, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
}
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin");
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
lv_obj_set_event_cb_mks(buttonBedstate, event_handler, 0, "bmp_bed_state.bin", 0);
|
||||
lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin");
|
||||
#endif
|
||||
|
||||
lv_obj_set_event_cb_mks(buttonFanstate, event_handler, 0, "bmp_fan_state.bin", 0);
|
||||
lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin");
|
||||
|
||||
lv_obj_set_event_cb_mks(buttonTime, event_handler, 0, "bmp_time_state.bin", 0);
|
||||
lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_REL, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_PR, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
lv_img_set_src(buttonTime, "F:/bmp_time_state.bin");
|
||||
|
||||
lv_obj_set_event_cb_mks(buttonZpos, event_handler, 0, "bmp_zpos_state.bin", 0);
|
||||
lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_REL, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_PR, &bmp_pic_45x45);
|
||||
lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin");
|
||||
|
||||
if (uiCfg.print_state == WORKING)
|
||||
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
|
||||
else
|
||||
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0);
|
||||
if (uiCfg.print_state == WORKING) {
|
||||
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
|
||||
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_pause.bin");
|
||||
}
|
||||
else {
|
||||
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_resume.bin");
|
||||
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_resume.bin");
|
||||
}
|
||||
|
||||
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, &bmp_pic_150x80);
|
||||
lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, &bmp_pic_150x80);
|
||||
lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, NULL, 0);
|
||||
lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
|
||||
lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, "bmp_stop.bin", 0);
|
||||
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, &bmp_pic_150x80);
|
||||
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, &bmp_pic_150x80);
|
||||
lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, NULL, 0);
|
||||
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, "F:/bmp_stop.bin");
|
||||
lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, "F:/bmp_stop.bin");
|
||||
lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
|
||||
lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, "bmp_operate.bin", 0);
|
||||
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, &bmp_pic_150x80);
|
||||
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, &bmp_pic_150x80);
|
||||
lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, NULL, 0);
|
||||
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, "F:/bmp_operate.bin");
|
||||
lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, "F:/bmp_operate.bin");
|
||||
lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_PR, &tft_style_label_pre);
|
||||
lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_REL, &tft_style_label_rel);
|
||||
|
||||
#endif // if 1
|
||||
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) {
|
||||
lv_group_add_obj(g, buttonPause);
|
||||
lv_group_add_obj(g, buttonStop);
|
||||
lv_group_add_obj(g, buttonOperat);
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_obj_set_pos(buttonExt1, 205, 136);
|
||||
|
||||
#if HAS_MULTI_EXTRUDER
|
||||
@@ -258,17 +243,19 @@ void lv_draw_printing(void) {
|
||||
lv_obj_set_pos(buttonStop, 165, 240);
|
||||
lv_obj_set_pos(buttonOperat, 325, 240);
|
||||
|
||||
/*Create a label on the Image button*/
|
||||
lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF);
|
||||
if (EXTRUDERS == 2)
|
||||
lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF);
|
||||
// Create labels on the image buttons
|
||||
//lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF);
|
||||
//#if HAS_MULTI_EXTRUDER
|
||||
//lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF);
|
||||
//#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF);
|
||||
#endif
|
||||
//#if HAS_HEATED_BED
|
||||
//lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF);
|
||||
//#endif
|
||||
|
||||
lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF);
|
||||
lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
|
||||
//lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF);
|
||||
//lv_btn_set_layout(buttonTime, LV_LAYOUT_OFF);
|
||||
//lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
|
||||
lv_btn_set_layout(buttonPause, LV_LAYOUT_OFF);
|
||||
lv_btn_set_layout(buttonStop, LV_LAYOUT_OFF);
|
||||
lv_btn_set_layout(buttonOperat, LV_LAYOUT_OFF);
|
||||
@@ -293,23 +280,20 @@ void lv_draw_printing(void) {
|
||||
lv_obj_set_style(labelFan, &tft_style_label_rel);
|
||||
lv_obj_set_pos(labelFan, 395, 196);
|
||||
|
||||
labelZpos = lv_label_create(scr, NULL);
|
||||
lv_obj_set_style(labelZpos, &tft_style_label_rel);
|
||||
lv_obj_set_pos(labelZpos, 395, 96);
|
||||
|
||||
labelTime = lv_label_create(scr, NULL);
|
||||
lv_obj_set_style(labelTime, &tft_style_label_rel);
|
||||
lv_obj_set_pos(labelTime, 250, 96);
|
||||
|
||||
labelZpos = lv_label_create(scr, NULL);
|
||||
lv_obj_set_style(labelZpos, &tft_style_label_rel);
|
||||
lv_obj_set_pos(labelZpos, 395, 96);
|
||||
|
||||
labelPause = lv_label_create(buttonPause, NULL);
|
||||
labelStop = lv_label_create(buttonStop, NULL);
|
||||
labelOperat = lv_label_create(buttonOperat, NULL);
|
||||
|
||||
if (gCfgItems.multiple_language != 0) {
|
||||
if (uiCfg.print_state == WORKING)
|
||||
lv_label_set_text(labelPause, printing_menu.pause);
|
||||
else
|
||||
lv_label_set_text(labelPause, printing_menu.resume);
|
||||
lv_label_set_text(labelPause, uiCfg.print_state == WORKING ? printing_menu.pause : printing_menu.resume);
|
||||
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 20, 0);
|
||||
|
||||
lv_label_set_text(labelStop, printing_menu.stop);
|
||||
@@ -319,20 +303,15 @@ void lv_draw_printing(void) {
|
||||
lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0);
|
||||
}
|
||||
|
||||
lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color);
|
||||
lv_bar_style_indic.text.color = lv_color_hex3(0xADF);
|
||||
lv_bar_style_indic.image.color = lv_color_hex3(0xADF);
|
||||
lv_bar_style_indic.line.color = lv_color_hex3(0xADF);
|
||||
lv_bar_style_indic.body.main_color = lv_color_hex3(0xADF);
|
||||
lv_bar_style_indic.body.grad_color = lv_color_hex3(0xADF);
|
||||
lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF);
|
||||
|
||||
bar1 = lv_bar_create(scr, NULL);
|
||||
lv_obj_set_pos(bar1, 205, 36);
|
||||
lv_obj_set_size(bar1, 270, 40);
|
||||
lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
|
||||
lv_bar_set_anim_time(bar1, 1000);
|
||||
lv_bar_set_value(bar1, 0, LV_ANIM_ON);
|
||||
bar1ValueText = lv_label_create(bar1, NULL);
|
||||
lv_label_set_text(bar1ValueText,"0%");
|
||||
lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
disp_ext_temp();
|
||||
disp_bed_temp();
|
||||
@@ -419,6 +398,10 @@ void setProBarRate() {
|
||||
|
||||
if (disp_state == PRINTING_UI) {
|
||||
lv_bar_set_value(bar1, rate, LV_ANIM_ON);
|
||||
ZERO(public_buf_l);
|
||||
sprintf_P(public_buf_l, "%d%%", rate);
|
||||
lv_label_set_text(bar1ValueText,public_buf_l);
|
||||
lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
if (marlin_state == MF_SD_COMPLETE) {
|
||||
if (once_flag == 0) {
|
||||
@@ -432,14 +415,22 @@ void setProBarRate() {
|
||||
once_flag = 1;
|
||||
|
||||
#if HAS_SUICIDE
|
||||
if (gCfgItems.finish_power_off == 1)
|
||||
suicide();
|
||||
if (gCfgItems.finish_power_off == 1) {
|
||||
gcode.process_subcommands_now_P(PSTR("M1001"));
|
||||
queue.inject_P(PSTR("M81"));
|
||||
marlin_state = MF_RUNNING;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_clear_printing() { lv_obj_del(scr); }
|
||||
void lv_clear_printing() {
|
||||
#if HAS_ROTARY_ENCODER
|
||||
if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
|
||||
#endif
|
||||
lv_obj_del(scr);
|
||||
}
|
||||
|
||||
#endif // HAS_TFT_LVGL_UI
|
||||
|
||||
Reference in New Issue
Block a user