From 083c857190043bec2031b3a465a96341f0021b1f Mon Sep 17 00:00:00 2001 From: Malderin Date: Sat, 27 Mar 2021 17:32:01 +0300 Subject: [PATCH 1/9] 1. Main screen buttons 2. Printing screen buttons --- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 52 ++++++++++++------- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 46 ++++++++-------- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index 70c57f4af884..b6768c7e6e78 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -47,7 +47,7 @@ static lv_obj_t *scr; static lv_obj_t *labelExt1, *labelFan, *labelZpos, *labelTime; static lv_obj_t *labelPause, *labelStop, *labelOperat; static lv_obj_t *bar1, *bar1ValueText; -static lv_obj_t *buttonPause, *buttonOperat, *buttonStop; +static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonExt2, *buttonBedstate, *buttonFanstate, *buttonZpos; #if ENABLED(HAS_MULTI_EXTRUDER) static lv_obj_t *labelExt2; @@ -60,7 +60,11 @@ static lv_obj_t *buttonPause, *buttonOperat, *buttonStop; enum { ID_PAUSE = 1, ID_STOP, - ID_OPTION + ID_OPTION, + ID_TEMP_EXT, + ID_TEMP_BED, + ID_BABYSTEP, + ID_FAN }; bool once_flag; // = false @@ -100,7 +104,6 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } #endif break; - case ID_STOP: lv_clear_printing(); lv_draw_dialog(DIALOG_TYPE_STOP); @@ -109,6 +112,24 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { lv_clear_printing(); lv_draw_operation(); break; + case ID_TEMP_EXT: + uiCfg.curTempType = 0; + lv_clear_printing(); + lv_draw_preHeat(); + break; + case ID_TEMP_BED: + uiCfg.curTempType = 1; + lv_clear_printing(); + lv_draw_preHeat(); + break; + case ID_BABYSTEP: + lv_clear_printing(); + lv_draw_baby_stepping(); + break; + case ID_FAN: + lv_clear_printing(); + lv_draw_fan(); + break; } } @@ -118,33 +139,23 @@ void lv_draw_printing() { scr = lv_screen_create(PRINTING_UI); // Create image buttons - 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); + buttonExt1 = lv_imgbtn_create(scr, "F:/bmp_ext1_state.bin", 206, 136, event_handler, ID_TEMP_EXT); #if HAS_MULTI_EXTRUDER - 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); + buttonExt2 = lv_imgbtn_create(scr, "F:/bmp_ext2_state.bin", 350, 136, event_handler, ID_TEMP_EXT); #endif #if HAS_HEATED_BED - 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); + buttonBedstate = lv_imgbtn_create(scr, "F:/bmp_bed_state.bin", 206, 186, event_handler, ID_TEMP_BED); #endif - 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); + buttonFanstate = lv_imgbtn_create(scr, "F:/bmp_fan_state.bin", 350, 186, event_handler, ID_FAN); 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_set_pos(buttonTime, 206, 86); - 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); + buttonZpos = lv_imgbtn_create(scr, "F:/bmp_zpos_state.bin", 350, 86, event_handler, ID_BABYSTEP); buttonPause = lv_imgbtn_create(scr, uiCfg.print_state == WORKING ? "F:/bmp_pause.bin" : "F:/bmp_resume.bin", 5, 240, event_handler, ID_PAUSE); buttonStop = lv_imgbtn_create(scr, "F:/bmp_stop.bin", 165, 240, event_handler, ID_STOP); @@ -155,6 +166,9 @@ void lv_draw_printing() { lv_group_add_obj(g, buttonPause); lv_group_add_obj(g, buttonStop); lv_group_add_obj(g, buttonOperat); + lv_group_add_obj(g, buttonPause); + lv_group_add_obj(g, buttonPause); + lv_group_add_obj(g, buttonPause); } #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index acdfa24f1b81..85d56e47ebde 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -63,7 +63,7 @@ static lv_obj_t *labelExt1, *labelExt1Target, *labelFan; uint8_t curent_disp_ui = 0; #endif -enum { ID_TOOL = 1, ID_SET, ID_PRINT }; +enum { ID_TOOL = 1, ID_SET, ID_PRINT, ID_INFO_EXT, ID_INFO_BED, ID_INFO_FAN }; static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; @@ -71,6 +71,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_TOOL: lv_draw_tool(); break; case ID_SET: lv_draw_set(); break; + case ID_INFO_EXT: uiCfg.curTempType = 0; lv_draw_preHeat(); break; + case ID_INFO_BED: uiCfg.curTempType = 1; lv_draw_preHeat(); break; + case ID_INFO_FAN: lv_draw_fan(); break; case ID_PRINT: lv_draw_print_file(); break; } } @@ -181,32 +184,14 @@ void lv_draw_ready_print() { lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 180, event_handler, ID_PRINT); // Monitoring - lv_obj_t *buttonExt1 = lv_img_create(scr, NULL); + lv_obj_t *buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT); #if HAS_MULTI_EXTRUDER - lv_obj_t *buttonExt2 = lv_img_create(scr, NULL); + lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 55, ICON_POS_Y + SECOND_EXT_MOD_Y, event_handler, ID_INFO_EXT); #endif #if HAS_HEATED_BED - lv_obj_t *buttonBedstate = lv_img_create(scr, NULL); + lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 210, ICON_POS_Y, event_handler, ID_INFO_BED); #endif - lv_obj_t *buttonFanstate = lv_img_create(scr, NULL); - - lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin"); - #if HAS_MULTI_EXTRUDER - lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin"); - #endif - #if HAS_HEATED_BED - lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin"); - #endif - lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin"); - - lv_obj_set_pos(buttonExt1, 55, ICON_POS_Y); - #if HAS_MULTI_EXTRUDER - lv_obj_set_pos(buttonExt2, 55, ICON_POS_Y + SECOND_EXT_MOD_Y); - #endif - #if HAS_HEATED_BED - lv_obj_set_pos(buttonBedstate, 210, ICON_POS_Y); - #endif - lv_obj_set_pos(buttonFanstate, 380, ICON_POS_Y); + lv_obj_t *buttonFanstate = lv_big_button_create(scr, "F:/bmp_fan_state.bin", " ", 380, ICON_POS_Y, event_handler, ID_INFO_FAN); labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); @@ -262,6 +247,21 @@ void lv_draw_ready_print() { #endif } +void lv_temp_refr() { +#if HAS_HEATED_BED + 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 + + 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 + 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 +} + void lv_clear_ready_print() { #if HAS_ROTARY_ENCODER if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); From 885419a90f5e59a9a743a0946ce63a9202f6494e Mon Sep 17 00:00:00 2001 From: Malderin Date: Sat, 27 Mar 2021 19:36:57 +0300 Subject: [PATCH 2/9] 1. Main screen buttons 2. Prinnting screen buttons --- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 52 ++++++++++++------- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 46 ++++++++-------- .../lcd/extui/lib/mks_ui/draw_ready_print.h | 1 + Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 4 ++ 4 files changed, 61 insertions(+), 42 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index 70c57f4af884..b6768c7e6e78 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -47,7 +47,7 @@ static lv_obj_t *scr; static lv_obj_t *labelExt1, *labelFan, *labelZpos, *labelTime; static lv_obj_t *labelPause, *labelStop, *labelOperat; static lv_obj_t *bar1, *bar1ValueText; -static lv_obj_t *buttonPause, *buttonOperat, *buttonStop; +static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonExt2, *buttonBedstate, *buttonFanstate, *buttonZpos; #if ENABLED(HAS_MULTI_EXTRUDER) static lv_obj_t *labelExt2; @@ -60,7 +60,11 @@ static lv_obj_t *buttonPause, *buttonOperat, *buttonStop; enum { ID_PAUSE = 1, ID_STOP, - ID_OPTION + ID_OPTION, + ID_TEMP_EXT, + ID_TEMP_BED, + ID_BABYSTEP, + ID_FAN }; bool once_flag; // = false @@ -100,7 +104,6 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } #endif break; - case ID_STOP: lv_clear_printing(); lv_draw_dialog(DIALOG_TYPE_STOP); @@ -109,6 +112,24 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { lv_clear_printing(); lv_draw_operation(); break; + case ID_TEMP_EXT: + uiCfg.curTempType = 0; + lv_clear_printing(); + lv_draw_preHeat(); + break; + case ID_TEMP_BED: + uiCfg.curTempType = 1; + lv_clear_printing(); + lv_draw_preHeat(); + break; + case ID_BABYSTEP: + lv_clear_printing(); + lv_draw_baby_stepping(); + break; + case ID_FAN: + lv_clear_printing(); + lv_draw_fan(); + break; } } @@ -118,33 +139,23 @@ void lv_draw_printing() { scr = lv_screen_create(PRINTING_UI); // Create image buttons - 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); + buttonExt1 = lv_imgbtn_create(scr, "F:/bmp_ext1_state.bin", 206, 136, event_handler, ID_TEMP_EXT); #if HAS_MULTI_EXTRUDER - 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); + buttonExt2 = lv_imgbtn_create(scr, "F:/bmp_ext2_state.bin", 350, 136, event_handler, ID_TEMP_EXT); #endif #if HAS_HEATED_BED - 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); + buttonBedstate = lv_imgbtn_create(scr, "F:/bmp_bed_state.bin", 206, 186, event_handler, ID_TEMP_BED); #endif - 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); + buttonFanstate = lv_imgbtn_create(scr, "F:/bmp_fan_state.bin", 350, 186, event_handler, ID_FAN); 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_set_pos(buttonTime, 206, 86); - 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); + buttonZpos = lv_imgbtn_create(scr, "F:/bmp_zpos_state.bin", 350, 86, event_handler, ID_BABYSTEP); buttonPause = lv_imgbtn_create(scr, uiCfg.print_state == WORKING ? "F:/bmp_pause.bin" : "F:/bmp_resume.bin", 5, 240, event_handler, ID_PAUSE); buttonStop = lv_imgbtn_create(scr, "F:/bmp_stop.bin", 165, 240, event_handler, ID_STOP); @@ -155,6 +166,9 @@ void lv_draw_printing() { lv_group_add_obj(g, buttonPause); lv_group_add_obj(g, buttonStop); lv_group_add_obj(g, buttonOperat); + lv_group_add_obj(g, buttonPause); + lv_group_add_obj(g, buttonPause); + lv_group_add_obj(g, buttonPause); } #endif diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index acdfa24f1b81..3cee44140f10 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -63,7 +63,7 @@ static lv_obj_t *labelExt1, *labelExt1Target, *labelFan; uint8_t curent_disp_ui = 0; #endif -enum { ID_TOOL = 1, ID_SET, ID_PRINT }; +enum { ID_TOOL = 1, ID_SET, ID_PRINT, ID_INFO_EXT, ID_INFO_BED, ID_INFO_FAN }; static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; @@ -71,6 +71,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_TOOL: lv_draw_tool(); break; case ID_SET: lv_draw_set(); break; + case ID_INFO_EXT: uiCfg.curTempType = 0; lv_draw_preHeat(); break; + case ID_INFO_BED: uiCfg.curTempType = 1; lv_draw_preHeat(); break; + case ID_INFO_FAN: lv_draw_fan(); break; case ID_PRINT: lv_draw_print_file(); break; } } @@ -181,32 +184,14 @@ void lv_draw_ready_print() { lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 180, event_handler, ID_PRINT); // Monitoring - lv_obj_t *buttonExt1 = lv_img_create(scr, NULL); + lv_obj_t *buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT); #if HAS_MULTI_EXTRUDER - lv_obj_t *buttonExt2 = lv_img_create(scr, NULL); + lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 55, ICON_POS_Y + SECOND_EXT_MOD_Y, event_handler, ID_INFO_EXT); #endif #if HAS_HEATED_BED - lv_obj_t *buttonBedstate = lv_img_create(scr, NULL); + lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 210, ICON_POS_Y, event_handler, ID_INFO_BED); #endif - lv_obj_t *buttonFanstate = lv_img_create(scr, NULL); - - lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin"); - #if HAS_MULTI_EXTRUDER - lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin"); - #endif - #if HAS_HEATED_BED - lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin"); - #endif - lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin"); - - lv_obj_set_pos(buttonExt1, 55, ICON_POS_Y); - #if HAS_MULTI_EXTRUDER - lv_obj_set_pos(buttonExt2, 55, ICON_POS_Y + SECOND_EXT_MOD_Y); - #endif - #if HAS_HEATED_BED - lv_obj_set_pos(buttonBedstate, 210, ICON_POS_Y); - #endif - lv_obj_set_pos(buttonFanstate, 380, ICON_POS_Y); + lv_obj_t *buttonFanstate = lv_big_button_create(scr, "F:/bmp_fan_state.bin", " ", 380, ICON_POS_Y, event_handler, ID_INFO_FAN); labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr); @@ -269,4 +254,19 @@ void lv_clear_ready_print() { lv_obj_del(scr); } +void lv_temp_refr() { +#if HAS_HEATED_BED + 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 + + 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 + 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 +} + #endif // HAS_TFT_LVGL_UI diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h index a3cfd6766578..56077e5dec39 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h @@ -32,6 +32,7 @@ extern void disp_Limit_error(); extern void disp_det_error(); extern void disp_det_ok(); extern void lv_clear_ready_print(); +extern void lv_temp_refr(); #ifdef __cplusplus } /* C-declarations for C++ */ diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp index 0c574b1e1568..2493ba10d61e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -805,6 +805,10 @@ void GUI_RefreshPage() { } break; case PRINT_READY_UI: + if (temps_update_flag) { + temps_update_flag = false; + lv_temp_refr(); + } break; case PRINT_FILE_UI: break; From 0d2d16be0703f9ca81c96918445fb61e529e6880 Mon Sep 17 00:00:00 2001 From: Malderin Date: Sat, 27 Mar 2021 20:07:40 +0300 Subject: [PATCH 3/9] fix --- .../src/lcd/extui/lib/mks_ui/draw_ready_print.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 315d25aaf93f..a340d31dcd46 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -269,19 +269,4 @@ void lv_clear_ready_print() { lv_obj_del(scr); } -void lv_temp_refr() { -#if HAS_HEATED_BED - 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 - - 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 - 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 -} - #endif // HAS_TFT_LVGL_UI From c56bf3b9ac69bc6df8bc7717cc8c1f9a9f3c785e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Mar 2021 03:13:44 -0500 Subject: [PATCH 4/9] More MKS UI cleanup --- .../src/lcd/extui/lib/mks_ui/draw_dialog.cpp | 2 +- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 2 +- .../extui/lib/mks_ui/draw_filament_change.cpp | 10 +++++----- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 8 ++++---- .../src/lcd/extui/lib/mks_ui/draw_printing.cpp | 6 +++--- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 18 +++++++++--------- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 12 ++++++------ 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp index c4ae6e221d55..c4056f392a57 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp @@ -486,7 +486,7 @@ void lv_draw_dialog(uint8_t type) { void filament_sprayer_temp() { char buf[20] = {0}; - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, uiCfg.extruderIndex < 1 ? extrude_menu.ext1 : extrude_menu.ext2); strcat_P(public_buf_l, PSTR(": ")); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index 43ed21419957..056e2e5d54cc 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -195,7 +195,7 @@ void disp_ext_speed() { void disp_hotend_temp() { char buf[20] = {0}; - sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, extrude_menu.temp_value, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, extrude_menu.temper_text); strcat(public_buf_l, buf); lv_label_set_text(tempText, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp index 56a776c79e30..296359bc538b 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -50,8 +50,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_FILAMNT_IN: uiCfg.filament_load_heat_flg = true; - if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1) - || (gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex))) { + if (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1 + || gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex)) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED); } @@ -67,8 +67,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_FILAMNT_OUT: uiCfg.filament_unload_heat_flg = true; if (thermalManager.degTargetHotend(uiCfg.extruderIndex) - && ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1) - || ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp)) + && (abs((int)(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1 + || thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp) ) { lv_clear_filament_change(); lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED); @@ -154,7 +154,7 @@ void disp_filament_temp() { public_buf_l[0] = '\0'; strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp index 73a0808e9c7f..d23ed0b05ff2 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -76,7 +76,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_P_DEC: if (uiCfg.curTempType == 0) { - if ((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat) + if (thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat) thermalManager.temp_hotend[uiCfg.extruderIndex].target -= uiCfg.stepHeat; else thermalManager.setTargetHotend(0, uiCfg.extruderIndex); @@ -84,7 +84,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { } #if HAS_HEATED_BED else { - if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat) + if (thermalManager.degTargetBed() > uiCfg.stepHeat) thermalManager.temp_bed.target -= uiCfg.stepHeat; else thermalManager.setTargetBed(0); @@ -217,12 +217,12 @@ void disp_desire_temp() { if (uiCfg.curTempType == 0) { strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); } #if HAS_HEATED_BED else { strcat(public_buf_l, preheat_menu.hotbed); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); + sprintf(buf, preheat_menu.value_state, thermalManager.degBed(), thermalManager.degTargetBed()); } #endif strcat_P(public_buf_l, PSTR(": ")); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index b6768c7e6e78..9bd120ce157d 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -219,18 +219,18 @@ void lv_draw_printing() { } void disp_ext_temp() { - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, public_buf_l); #endif } void disp_bed_temp() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); + sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); #endif } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index a340d31dcd46..5787cfb0091c 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -248,18 +248,18 @@ void lv_draw_ready_print() { } void lv_temp_refr() { -#if HAS_HEATED_BED - 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 + #if HAS_HEATED_BED + sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed()); + lv_label_set_text(labelBed, public_buf_l); + #endif - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); + sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); -#if HAS_MULTI_EXTRUDER - 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 + #if HAS_MULTI_EXTRUDER + sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1)); + lv_label_set_text(labelExt2, public_buf_l); + #endif } void lv_clear_ready_print() { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp index ddf717329731..44aa2300e271 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -897,9 +897,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcpy_P(outBuf, PSTR(" B:")); outBuf += 3; #if HAS_HEATED_BED - strcpy(outBuf, dtostrf(thermalManager.temp_bed.celsius, 1, 1, str_1)); + strcpy(outBuf, dtostrf(thermalManager.degBed(), 1, 1, str_1)); strcat_P(outBuf, PSTR(" /")); - strcat(outBuf, dtostrf(thermalManager.temp_bed.target, 1, 1, str_1)); + strcat(outBuf, dtostrf(thermalManager.degTargetBed(), 1, 1, str_1)); #else strcpy_P(outBuf, PSTR("0 /0")); #endif @@ -924,15 +924,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { } else { sprintf_P((char *)tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"), - (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0), + thermalManager.degHotend(0), thermalManager.degTargetHotend(0), #if HAS_HEATED_BED - (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target, + thermalManager.degBed(), thermalManager.degTargetBed(), #else 0, 0, #endif - (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0), + thermalManager.degHotend(0), thermalManager.degTargetHotend(0), #if HAS_MULTI_HOTEND - (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1) + thermalManager.degHotend(1), thermalManager.degTargetHotend(1) #else 0, 0 #endif From 0313ad4b121810ff7ec1c983292a82ba7153d576 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Mar 2021 03:16:36 -0500 Subject: [PATCH 5/9] finis --- Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp index 2493ba10d61e..8d560a19a43e 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp @@ -808,7 +808,7 @@ void GUI_RefreshPage() { if (temps_update_flag) { temps_update_flag = false; lv_temp_refr(); - } + } break; case PRINT_FILE_UI: break; @@ -847,8 +847,8 @@ void GUI_RefreshPage() { #if ENABLED(MKS_WIFI_MODULE) case WIFI_UI: if (temps_update_flag) { - disp_wifi_state(); temps_update_flag = false; + disp_wifi_state(); } break; From 1acb4d1c9fd07a42015c5cf1c81ae6edcf05ee71 Mon Sep 17 00:00:00 2001 From: Malderin Date: Mon, 29 Mar 2021 15:03:21 +0300 Subject: [PATCH 6/9] conf --- Marlin/Configuration.h | 12 ++++++------ platformio.ini | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index c9c83f9bb624..cc36a46100ab 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -102,7 +102,7 @@ * * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ -#define SERIAL_PORT 0 +#define SERIAL_PORT 3 /** * Select a secondary serial port on the board to use for communication with the host. @@ -127,7 +127,7 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_RAMPS_14_EFB + #define MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 #endif // Name displayed in the LCD "Ready" message and Info menu @@ -1923,7 +1923,7 @@ * SD Card support is disabled by default. If your controller has an SD slot, * you must uncomment the following option or it won't work. */ -//#define SDSUPPORT +#define SDSUPPORT /** * SD CARD: ENABLE CRC @@ -2430,7 +2430,7 @@ // 480x320, 3.5", SPI Display From MKS // Normally used in MKS Robin Nano V2 // -//#define MKS_TS35_V2_0 +#define MKS_TS35_V2_0 // // 320x240, 2.4", FSMC Display From MKS @@ -2522,7 +2522,7 @@ */ //#define TFT_CLASSIC_UI //#define TFT_COLOR_UI -//#define TFT_LVGL_UI +#define TFT_LVGL_UI #if ENABLED(TFT_LVGL_UI) //#define MKS_WIFI_MODULE // MKS WiFi module @@ -2550,7 +2550,7 @@ // // ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8 // -//#define TOUCH_SCREEN +#define TOUCH_SCREEN #if ENABLED(TOUCH_SCREEN) #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus diff --git a/platformio.ini b/platformio.ini index 26b27bbf9944..7aef7383394d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,7 +18,7 @@ [platformio] src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards -default_envs = mega2560 +default_envs = mks_robin_nano35 include_dir = Marlin # From af090a68b41234a988e5d0c733b9e2ab09a03661 Mon Sep 17 00:00:00 2001 From: Malderin Date: Thu, 1 Apr 2021 12:09:31 +0300 Subject: [PATCH 7/9] Revert "conf" This reverts commit 1acb4d1c9fd07a42015c5cf1c81ae6edcf05ee71. --- Marlin/Configuration.h | 12 ++++++------ platformio.ini | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index cc36a46100ab..c9c83f9bb624 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -102,7 +102,7 @@ * * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ -#define SERIAL_PORT 3 +#define SERIAL_PORT 0 /** * Select a secondary serial port on the board to use for communication with the host. @@ -127,7 +127,7 @@ // Choose the name from boards.h that matches your setup #ifndef MOTHERBOARD - #define MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 + #define MOTHERBOARD BOARD_RAMPS_14_EFB #endif // Name displayed in the LCD "Ready" message and Info menu @@ -1923,7 +1923,7 @@ * SD Card support is disabled by default. If your controller has an SD slot, * you must uncomment the following option or it won't work. */ -#define SDSUPPORT +//#define SDSUPPORT /** * SD CARD: ENABLE CRC @@ -2430,7 +2430,7 @@ // 480x320, 3.5", SPI Display From MKS // Normally used in MKS Robin Nano V2 // -#define MKS_TS35_V2_0 +//#define MKS_TS35_V2_0 // // 320x240, 2.4", FSMC Display From MKS @@ -2522,7 +2522,7 @@ */ //#define TFT_CLASSIC_UI //#define TFT_COLOR_UI -#define TFT_LVGL_UI +//#define TFT_LVGL_UI #if ENABLED(TFT_LVGL_UI) //#define MKS_WIFI_MODULE // MKS WiFi module @@ -2550,7 +2550,7 @@ // // ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8 // -#define TOUCH_SCREEN +//#define TOUCH_SCREEN #if ENABLED(TOUCH_SCREEN) #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus diff --git a/platformio.ini b/platformio.ini index 7aef7383394d..26b27bbf9944 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,7 +18,7 @@ [platformio] src_dir = Marlin boards_dir = buildroot/share/PlatformIO/boards -default_envs = mks_robin_nano35 +default_envs = mega2560 include_dir = Marlin # From 81ed1687ecf0469e044a7bce34427aea0971ca37 Mon Sep 17 00:00:00 2001 From: Malderin Date: Thu, 1 Apr 2021 12:24:01 +0300 Subject: [PATCH 8/9] Fix temp hotend refresh function --- Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 2 +- Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp | 4 ++-- Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp index d23ed0b05ff2..5ecf3d091c17 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -217,7 +217,7 @@ void disp_desire_temp() { if (uiCfg.curTempType == 0) { strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); } #if HAS_HEATED_BED else { diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index 9bd120ce157d..9fa59c1fbfb8 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -219,11 +219,11 @@ void lv_draw_printing() { } void disp_ext_temp() { - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); + 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 - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1)); + 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 } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 5787cfb0091c..4e2477c3b5a9 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -249,11 +249,11 @@ void lv_draw_ready_print() { void lv_temp_refr() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed()); + 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 - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); + 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 From 55ca037e4d5a908d0b40d1399d62bbe526dd8c36 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 1 Apr 2021 16:58:58 -0500 Subject: [PATCH 9/9] Just use int (?) and other fixes --- .../lcd/extui/lib/mks_ui/draw_extrusion.cpp | 2 +- .../extui/lib/mks_ui/draw_filament_change.cpp | 2 +- .../src/lcd/extui/lib/mks_ui/draw_preHeat.cpp | 23 +++++++------- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 6 ++-- .../lcd/extui/lib/mks_ui/draw_ready_print.cpp | 30 +++++++++---------- .../src/lcd/extui/lib/mks_ui/wifi_module.cpp | 12 ++------ 6 files changed, 34 insertions(+), 41 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp index 056e2e5d54cc..43ed21419957 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp @@ -195,7 +195,7 @@ void disp_ext_speed() { void disp_hotend_temp() { char buf[20] = {0}; - sprintf(buf, extrude_menu.temp_value, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcpy(public_buf_l, extrude_menu.temper_text); strcat(public_buf_l, buf); lv_label_set_text(tempText, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp index 296359bc538b..a3313285df6f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp @@ -154,7 +154,7 @@ void disp_filament_temp() { public_buf_l[0] = '\0'; strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp index 5ecf3d091c17..0395ccde52d0 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp @@ -62,15 +62,15 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { thermalManager.setTargetHotend(max_target, uiCfg.extruderIndex); thermalManager.start_watching_hotend(uiCfg.extruderIndex); } - #if HAS_HEATED_BED - else { + else { + #if HAS_HEATED_BED constexpr int16_t max_target = BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1); thermalManager.temp_bed.target += uiCfg.stepHeat; if (thermalManager.degTargetBed() > max_target) thermalManager.setTargetBed(max_target); thermalManager.start_watching_bed(); - } - #endif + #endif + } disp_desire_temp(); } break; @@ -211,20 +211,19 @@ void disp_temp_type() { } void disp_desire_temp() { - char buf[20] = {0}; - + char buf[20] = { 0 }; public_buf_l[0] = '\0'; if (uiCfg.curTempType == 0) { strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2); - sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex)); } - #if HAS_HEATED_BED - else { + else { + #if HAS_HEATED_BED strcat(public_buf_l, preheat_menu.hotbed); - sprintf(buf, preheat_menu.value_state, thermalManager.degBed(), thermalManager.degTargetBed()); - } - #endif + sprintf(buf, preheat_menu.value_state, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); + #endif + } strcat_P(public_buf_l, PSTR(": ")); strcat(public_buf_l, buf); lv_label_set_text(tempText1, public_buf_l); diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index 9fa59c1fbfb8..6025968d3b1f 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -219,18 +219,18 @@ void lv_draw_printing() { } void disp_ext_temp() { - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, public_buf_l); #endif } void disp_bed_temp() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed()); + sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); #endif } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp index 4e2477c3b5a9..45a2167a05b9 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp @@ -105,14 +105,14 @@ void disp_det_error() { lv_obj_t *e1, *e2, *e3, *bed; void mks_disp_test() { char buf[30] = {0}; - sprintf_P(buf, PSTR("e1:%d"), thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.degHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND - sprintf_P(buf, PSTR("e2:%d"), thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.degHotend(1)); lv_label_set_text(e2, buf); #endif #if HAS_HEATED_BED - sprintf_P(buf, PSTR("bed:%d"), thermalManager.degBed()); + sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.degBed()); lv_label_set_text(bed, buf); #endif } @@ -139,20 +139,20 @@ void lv_draw_ready_print() { e1 = lv_label_create_empty(scr); lv_obj_set_pos(e1, 20, 20); - sprintf_P(buf, PSTR("e1: %d"), thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(0)); lv_label_set_text(e1, buf); #if HAS_MULTI_HOTEND e2 = lv_label_create_empty(scr); lv_obj_set_pos(e2, 20, 45); - sprintf_P(buf, PSTR("e1: %d"), thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("e1: %d"), (int)thermalManager.degHotend(1)); lv_label_set_text(e2, buf); #endif #if HAS_HEATED_BED bed = lv_label_create_empty(scr); lv_obj_set_pos(bed, 20, 95); - sprintf_P(buf, PSTR("bed: %d"), thermalManager.degBed()); + sprintf_P(buf, PSTR("bed: %d"), (int)thermalManager.degBed()); lv_label_set_text(bed, buf); #endif @@ -208,27 +208,27 @@ void lv_draw_ready_print() { labelFan = lv_label_create(scr, 380, 80, nullptr); - sprintf_P(buf, PSTR("%d"), thermalManager.degHotend(0)); + sprintf_P(buf, PSTR("%d"), (int)thermalManager.degHotend(0)); lv_label_set_text(labelExt1, buf); lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(0)); + sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1Target, buf); lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #if HAS_MULTI_EXTRUDER - sprintf_P(buf, PSTR("%d"), thermalManager.degHotend(1)); + sprintf_P(buf, PSTR("%d"), (int)thermalManager.degHotend(1)); lv_label_set_text(labelExt2, buf); lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(1)); + sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2Target, buf); lv_obj_align(labelExt2Target, buttonExt2, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #endif #if HAS_HEATED_BED - sprintf_P(buf, PSTR("%d"), thermalManager.degBed()); + sprintf_P(buf, PSTR("%d"), (int)thermalManager.degBed()); lv_label_set_text(labelBed, buf); lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y); - sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetBed()); + sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetBed()); lv_label_set_text(labelBedTarget, buf); lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y); #endif @@ -249,15 +249,15 @@ void lv_draw_ready_print() { void lv_temp_refr() { #if HAS_HEATED_BED - sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target); + sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); lv_label_set_text(labelBed, public_buf_l); #endif - sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); lv_label_set_text(labelExt1, public_buf_l); #if HAS_MULTI_EXTRUDER - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1)); + sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); lv_label_set_text(labelExt2, public_buf_l); #endif } diff --git a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp index ac07dc010228..ea5b29607eea 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp @@ -885,9 +885,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { char *outBuf = (char *)tempBuf; char str_1[16], tbuf[34]; - dtostrf(thermalManager.degHotend(0), 1, 1, tbuf); - strcat_P(tbuf, PSTR(" /")); - strcat(tbuf, dtostrf(thermalManager.degTargetHotend(0), 1, 1, str_1)); + sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0)); const int tlen = strlen(tbuf); @@ -897,9 +895,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcpy_P(outBuf, PSTR(" B:")); outBuf += 3; #if HAS_HEATED_BED - strcpy(outBuf, dtostrf(thermalManager.degBed(), 1, 1, str_1)); - strcat_P(outBuf, PSTR(" /")); - strcat(outBuf, dtostrf(thermalManager.degTargetBed(), 1, 1, str_1)); + sprintf_P(outBuf, PSTR("%d /%d"), (int)thermalManager.degBed(), (int)thermalManager.degTargetBed()); #else strcpy_P(outBuf, PSTR("0 /0")); #endif @@ -912,9 +908,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { strcat_P(outBuf, PSTR(" T1:")); outBuf += 4; #if HAS_MULTI_HOTEND - strcat(outBuf, dtostrf(thermalManager.degHotend(1), 1, 1, str_1)); - strcat_P(outBuf, PSTR(" /")); - strcat(outBuf, dtostrf(thermalManager.degTargetHotend(1), 1, 1, str_1)); + sprintf_P(outBuf, PSTR("%d /%d"), (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)); #else strcat_P(outBuf, PSTR("0 /0")); #endif