From 746eae15f36e4211a22d53b8e12e82edb55a13e5 Mon Sep 17 00:00:00 2001 From: Malderin <52313714+Malderin@users.noreply.github.com> Date: Tue, 6 Apr 2021 04:55:00 +0300 Subject: [PATCH] Cast celsius to int for MKS LVGL UI (#21502) --- .../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 056e2e5d54..43ed214199 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 296359bc53..a3313285df 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 d23ed0b05f..0395ccde52 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, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex)); + 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 9bd120ce15..6025968d3b 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, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); + 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 } 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 5787cfb009..45a2167a05 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, 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 - sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0)); + 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 a74ecd2f1e..1057a0c689 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