More MKS UI cleanup, optimization (#19869)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Victor Oliveira
2020-10-24 01:37:45 -03:00
committed by Scott Lahteine
parent c3e8b46284
commit 35597ae336
56 changed files with 2688 additions and 6566 deletions

View File

@@ -59,78 +59,61 @@ TERN_(HAS_MULTI_EXTRUDER, static lv_obj_t *labelExt2);
static lv_obj_t* labelBed;
#endif
#define ID_PAUSE 1
#define ID_STOP 2
#define ID_OPTION 3
enum {
ID_PAUSE = 1,
ID_STOP,
ID_OPTION
};
bool once_flag; // = false
extern bool flash_preview_begin, default_preview_flg, gcode_preview_over;
extern uint32_t To_pre_view;
static void event_handler(lv_obj_t * obj, lv_event_t event) {
static void event_handler(lv_obj_t *obj, lv_event_t event) {
if (event != LV_EVENT_RELEASED) return;
if (gcode_preview_over) return;
switch (obj->mks_obj_id) {
case ID_PAUSE:
if (event == LV_EVENT_CLICKED) {
// nothing to do
if (uiCfg.print_state == WORKING) {
// #if ENABLED(PARK_HEAD_ON_PAUSE)
// queue.inject_P(PSTR("M25 P\nM24"));
#if ENABLED(SDSUPPORT)
// queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90"));
card.pauseSDPrint();
stop_print_time();
uiCfg.print_state = PAUSING;
#endif
lv_imgbtn_set_src_both(buttonPause, "F:/bmp_resume.bin");
lv_label_set_text(labelPause, printing_menu.resume);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
}
else if (event == LV_EVENT_RELEASED) {
if (!gcode_preview_over) {
if (uiCfg.print_state == WORKING) {
// #if ENABLED(PARK_HEAD_ON_PAUSE)
// queue.inject_P(PSTR("M25 P\nM24"));
#if ENABLED(SDSUPPORT)
// queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90"));
card.pauseSDPrint();
stop_print_time();
uiCfg.print_state = PAUSING;
#endif
lv_imgbtn_set_src_both(buttonPause, "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;
lv_imgbtn_set_src_both(obj, "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_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
lv_label_set_text(labelPause, printing_menu.pause);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
// recovery.resume();
print_time.minutes = recovery.info.print_job_elapsed / 60;
print_time.seconds = recovery.info.print_job_elapsed % 60;
print_time.hours = print_time.minutes / 60;
}
#endif
else if (uiCfg.print_state == PAUSED) {
uiCfg.print_state = RESUMING;
lv_imgbtn_set_src_both(obj, "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_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
lv_label_set_text(labelPause, printing_menu.pause);
lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
// recovery.resume();
print_time.minutes = recovery.info.print_job_elapsed / 60;
print_time.seconds = recovery.info.print_job_elapsed % 60;
print_time.hours = print_time.minutes / 60;
}
}
#endif
break;
case ID_STOP:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
if (!gcode_preview_over) {
lv_clear_printing();
lv_draw_dialog(DIALOG_TYPE_STOP);
}
}
lv_clear_printing();
lv_draw_dialog(DIALOG_TYPE_STOP);
break;
case ID_OPTION:
if (event == LV_EVENT_CLICKED) {
// nothing to do
}
else if (event == LV_EVENT_RELEASED) {
if (!gcode_preview_over) {
lv_clear_printing();
lv_draw_operation();
}
}
lv_clear_printing();
lv_draw_operation();
break;
}
}
@@ -142,44 +125,38 @@ void lv_draw_printing(void) {
disp_state = PRINTING_UI;
scr = lv_obj_create(NULL, NULL);
// static lv_style_t tool_style;
lv_obj_set_style(scr, &tft_style_scr);
lv_scr_load(scr);
lv_obj_clean(scr);
scr = lv_screen_create();
(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
lv_refr_now(lv_refr_get_disp_refreshing());
// Create image buttons
lv_obj_t *buttonExt1 = lv_img_create(scr, NULL);
lv_obj_t *buttonExt1 = lv_img_create(scr, nullptr);
lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin");
lv_obj_set_pos(buttonExt1, 205, 136);
#if HAS_MULTI_EXTRUDER
lv_obj_t *buttonExt2 = lv_img_create(scr, NULL);
lv_obj_t *buttonExt2 = lv_img_create(scr, nullptr);
lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin");
lv_obj_set_pos(buttonExt2, 350, 136);
#endif
#if HAS_HEATED_BED
lv_obj_t *buttonBedstate = lv_img_create(scr, NULL);
lv_obj_t *buttonBedstate = lv_img_create(scr, nullptr);
lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin");
lv_obj_set_pos(buttonBedstate, 205, 186);
#endif
lv_obj_t *buttonFanstate = lv_img_create(scr, NULL);
lv_obj_t *buttonFanstate = lv_img_create(scr, nullptr);
lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin");
lv_obj_set_pos(buttonFanstate, 350, 186);
lv_obj_t *buttonTime = lv_img_create(scr, NULL);
lv_obj_t *buttonTime = lv_img_create(scr, nullptr);
lv_img_set_src(buttonTime, "F:/bmp_time_state.bin");
lv_obj_set_pos(buttonTime, 205, 86);
lv_obj_t *buttonZpos = lv_img_create(scr, NULL);
lv_obj_t *buttonZpos = lv_img_create(scr, nullptr);
lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin");
lv_obj_set_pos(buttonZpos, 350, 86);
@@ -209,19 +186,19 @@ void lv_draw_printing(void) {
//lv_btn_set_layout(buttonTime, LV_LAYOUT_OFF);
//lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
labelExt1 = lv_label_create(scr, 250, 146, NULL);
labelExt1 = lv_label_create(scr, 250, 146, nullptr);
#if HAS_MULTI_EXTRUDER
labelExt2 = lv_label_create(scr, 395, 146, NULL);
labelExt2 = lv_label_create(scr, 395, 146, nullptr);
#endif
#if HAS_HEATED_BED
labelBed = lv_label_create(scr, 250, 196, NULL);
labelBed = lv_label_create(scr, 250, 196, nullptr);
#endif
labelFan = lv_label_create(scr, 395, 196, NULL);
labelTime = lv_label_create(scr, 250, 96, NULL);
labelZpos = lv_label_create(scr, 395, 96, NULL);
labelFan = lv_label_create(scr, 395, 196, nullptr);
labelTime = lv_label_create(scr, 250, 96, nullptr);
labelZpos = lv_label_create(scr, 395, 96, nullptr);
labelPause = lv_label_create_empty(buttonPause);
labelStop = lv_label_create_empty(buttonStop);
@@ -238,7 +215,7 @@ void lv_draw_printing(void) {
lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0);
}
bar1 = lv_bar_create(scr, NULL);
bar1 = lv_bar_create(scr, nullptr);
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);
@@ -256,12 +233,10 @@ void lv_draw_printing(void) {
}
void disp_ext_temp() {
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target);
lv_label_set_text(labelExt1, public_buf_l);
#if HAS_MULTI_EXTRUDER
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target);
lv_label_set_text(labelExt2, public_buf_l);
#endif
@@ -269,20 +244,17 @@ void disp_ext_temp() {
void disp_bed_temp() {
#if HAS_HEATED_BED
ZERO(public_buf_l);
sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target);
lv_label_set_text(labelBed, public_buf_l);
#endif
}
void disp_fan_speed() {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%3d"), thermalManager.fan_speed[0]);
lv_label_set_text(labelFan, public_buf_l);
}
void disp_print_time() {
ZERO(public_buf_l);
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
const uint32_t r = ui.get_remaining_time();
sprintf_P(public_buf_l, PSTR("%02d:%02d R"), r / 3600, (r % 3600) / 60);
@@ -293,7 +265,6 @@ void disp_print_time() {
}
void disp_fan_Zpos() {
ZERO(public_buf_l);
sprintf_P(public_buf_l, PSTR("%.3f"), current_position[Z_AXIS]);
lv_label_set_text(labelZpos, public_buf_l);
}
@@ -333,7 +304,6 @@ 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);