Browse Source

Cast celsius to int for MKS LVGL UI (#21502)

Malderin 3 years ago
parent
commit
746eae15f3
No account linked to committer's email address

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp View File

@@ -195,7 +195,7 @@ void disp_ext_speed() {
195 195
 
196 196
 void disp_hotend_temp() {
197 197
   char buf[20] = {0};
198
-  sprintf(buf, extrude_menu.temp_value, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
198
+  sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
199 199
   strcpy(public_buf_l, extrude_menu.temper_text);
200 200
   strcat(public_buf_l, buf);
201 201
   lv_label_set_text(tempText, public_buf_l);

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp View File

@@ -154,7 +154,7 @@ void disp_filament_temp() {
154 154
   public_buf_l[0] = '\0';
155 155
 
156 156
   strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
157
-  sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
157
+  sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
158 158
 
159 159
   strcat_P(public_buf_l, PSTR(": "));
160 160
   strcat(public_buf_l, buf);

+ 11
- 12
Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp View File

@@ -62,15 +62,15 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
62 62
           thermalManager.setTargetHotend(max_target, uiCfg.extruderIndex);
63 63
         thermalManager.start_watching_hotend(uiCfg.extruderIndex);
64 64
       }
65
-      #if HAS_HEATED_BED
66
-        else {
65
+      else {
66
+        #if HAS_HEATED_BED
67 67
           constexpr int16_t max_target = BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
68 68
           thermalManager.temp_bed.target += uiCfg.stepHeat;
69 69
           if (thermalManager.degTargetBed() > max_target)
70 70
             thermalManager.setTargetBed(max_target);
71 71
           thermalManager.start_watching_bed();
72
-        }
73
-      #endif
72
+        #endif
73
+      }
74 74
       disp_desire_temp();
75 75
     } break;
76 76
 
@@ -211,20 +211,19 @@ void disp_temp_type() {
211 211
 }
212 212
 
213 213
 void disp_desire_temp() {
214
-  char buf[20] = {0};
215
-
214
+  char buf[20] = { 0 };
216 215
   public_buf_l[0] = '\0';
217 216
 
218 217
   if (uiCfg.curTempType == 0) {
219 218
     strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
220
-    sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
219
+    sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
221 220
   }
222
-  #if HAS_HEATED_BED
223
-    else {
221
+  else {
222
+    #if HAS_HEATED_BED
224 223
       strcat(public_buf_l, preheat_menu.hotbed);
225
-      sprintf(buf, preheat_menu.value_state, thermalManager.degBed(), thermalManager.degTargetBed());
226
-    }
227
-  #endif
224
+      sprintf(buf, preheat_menu.value_state, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed());
225
+    #endif
226
+  }
228 227
   strcat_P(public_buf_l, PSTR(": "));
229 228
   strcat(public_buf_l, buf);
230 229
   lv_label_set_text(tempText1, public_buf_l);

+ 3
- 3
Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp View File

@@ -219,18 +219,18 @@ void lv_draw_printing() {
219 219
 }
220 220
 
221 221
 void disp_ext_temp() {
222
-  sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0));
222
+  sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0));
223 223
   lv_label_set_text(labelExt1, public_buf_l);
224 224
 
225 225
   #if HAS_MULTI_EXTRUDER
226
-    sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1));
226
+    sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1));
227 227
     lv_label_set_text(labelExt2, public_buf_l);
228 228
   #endif
229 229
 }
230 230
 
231 231
 void disp_bed_temp() {
232 232
   #if HAS_HEATED_BED
233
-    sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed());
233
+    sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed());
234 234
     lv_label_set_text(labelBed, public_buf_l);
235 235
   #endif
236 236
 }

+ 15
- 15
Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp View File

@@ -105,14 +105,14 @@ void disp_det_error() {
105 105
 lv_obj_t *e1, *e2, *e3, *bed;
106 106
 void mks_disp_test() {
107 107
   char buf[30] = {0};
108
-  sprintf_P(buf, PSTR("e1:%d"), thermalManager.degHotend(0));
108
+  sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.degHotend(0));
109 109
   lv_label_set_text(e1, buf);
110 110
   #if HAS_MULTI_HOTEND
111
-    sprintf_P(buf, PSTR("e2:%d"), thermalManager.degHotend(1));
111
+    sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.degHotend(1));
112 112
     lv_label_set_text(e2, buf);
113 113
   #endif
114 114
   #if HAS_HEATED_BED
115
-    sprintf_P(buf, PSTR("bed:%d"), thermalManager.degBed());
115
+    sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.degBed());
116 116
     lv_label_set_text(bed, buf);
117 117
   #endif
118 118
 }
@@ -139,20 +139,20 @@ void lv_draw_ready_print() {
139 139
 
140 140
     e1 = lv_label_create_empty(scr);
141 141
     lv_obj_set_pos(e1, 20, 20);
142
-    sprintf_P(buf, PSTR("e1:  %d"), thermalManager.degHotend(0));
142
+    sprintf_P(buf, PSTR("e1:  %d"), (int)thermalManager.degHotend(0));
143 143
     lv_label_set_text(e1, buf);
144 144
 
145 145
     #if HAS_MULTI_HOTEND
146 146
       e2 = lv_label_create_empty(scr);
147 147
       lv_obj_set_pos(e2, 20, 45);
148
-      sprintf_P(buf, PSTR("e1:  %d"), thermalManager.degHotend(1));
148
+      sprintf_P(buf, PSTR("e1:  %d"), (int)thermalManager.degHotend(1));
149 149
       lv_label_set_text(e2, buf);
150 150
     #endif
151 151
 
152 152
     #if HAS_HEATED_BED
153 153
       bed = lv_label_create_empty(scr);
154 154
       lv_obj_set_pos(bed, 20, 95);
155
-      sprintf_P(buf, PSTR("bed:  %d"), thermalManager.degBed());
155
+      sprintf_P(buf, PSTR("bed:  %d"), (int)thermalManager.degBed());
156 156
       lv_label_set_text(bed, buf);
157 157
     #endif
158 158
 
@@ -208,27 +208,27 @@ void lv_draw_ready_print() {
208 208
 
209 209
     labelFan = lv_label_create(scr, 380, 80, nullptr);
210 210
 
211
-    sprintf_P(buf, PSTR("%d"), thermalManager.degHotend(0));
211
+    sprintf_P(buf, PSTR("%d"), (int)thermalManager.degHotend(0));
212 212
     lv_label_set_text(labelExt1, buf);
213 213
     lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
214
-    sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(0));
214
+    sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(0));
215 215
     lv_label_set_text(labelExt1Target, buf);
216 216
     lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
217 217
 
218 218
     #if HAS_MULTI_EXTRUDER
219
-      sprintf_P(buf, PSTR("%d"), thermalManager.degHotend(1));
219
+      sprintf_P(buf, PSTR("%d"), (int)thermalManager.degHotend(1));
220 220
       lv_label_set_text(labelExt2, buf);
221 221
       lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
222
-      sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(1));
222
+      sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetHotend(1));
223 223
       lv_label_set_text(labelExt2Target, buf);
224 224
       lv_obj_align(labelExt2Target, buttonExt2, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
225 225
     #endif
226 226
 
227 227
     #if HAS_HEATED_BED
228
-      sprintf_P(buf, PSTR("%d"), thermalManager.degBed());
228
+      sprintf_P(buf, PSTR("%d"), (int)thermalManager.degBed());
229 229
       lv_label_set_text(labelBed, buf);
230 230
       lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
231
-      sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetBed());
231
+      sprintf_P(buf, PSTR("-> %d"), (int)thermalManager.degTargetBed());
232 232
       lv_label_set_text(labelBedTarget, buf);
233 233
       lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
234 234
     #endif
@@ -249,15 +249,15 @@ void lv_draw_ready_print() {
249 249
 
250 250
 void lv_temp_refr() {
251 251
   #if HAS_HEATED_BED
252
-    sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed());
252
+    sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.degBed(), (int)thermalManager.degTargetBed());
253 253
     lv_label_set_text(labelBed, public_buf_l);
254 254
   #endif
255 255
 
256
-  sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0));
256
+  sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0));
257 257
   lv_label_set_text(labelExt1, public_buf_l);
258 258
 
259 259
   #if HAS_MULTI_EXTRUDER
260
-    sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1));
260
+    sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1));
261 261
     lv_label_set_text(labelExt2, public_buf_l);
262 262
   #endif
263 263
 }

+ 3
- 9
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp View File

@@ -885,9 +885,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
885 885
             char *outBuf = (char *)tempBuf;
886 886
             char str_1[16], tbuf[34];
887 887
 
888
-            dtostrf(thermalManager.degHotend(0), 1, 1, tbuf);
889
-            strcat_P(tbuf, PSTR(" /"));
890
-            strcat(tbuf, dtostrf(thermalManager.degTargetHotend(0), 1, 1, str_1));
888
+            sprintf_P(tbuf, PSTR("%d /%d"), (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0));
891 889
 
892 890
             const int tlen = strlen(tbuf);
893 891
 
@@ -897,9 +895,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
897 895
             strcpy_P(outBuf, PSTR(" B:"));
898 896
             outBuf += 3;
899 897
             #if HAS_HEATED_BED
900
-              strcpy(outBuf, dtostrf(thermalManager.degBed(), 1, 1, str_1));
901
-              strcat_P(outBuf, PSTR(" /"));
902
-              strcat(outBuf, dtostrf(thermalManager.degTargetBed(), 1, 1, str_1));
898
+              sprintf_P(outBuf, PSTR("%d /%d"), (int)thermalManager.degBed(), (int)thermalManager.degTargetBed());
903 899
             #else
904 900
               strcpy_P(outBuf, PSTR("0 /0"));
905 901
             #endif
@@ -912,9 +908,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
912 908
             strcat_P(outBuf, PSTR(" T1:"));
913 909
             outBuf += 4;
914 910
             #if HAS_MULTI_HOTEND
915
-              strcat(outBuf, dtostrf(thermalManager.degHotend(1), 1, 1, str_1));
916
-              strcat_P(outBuf, PSTR(" /"));
917
-              strcat(outBuf, dtostrf(thermalManager.degTargetHotend(1), 1, 1, str_1));
911
+              sprintf_P(outBuf, PSTR("%d /%d"), (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1));
918 912
             #else
919 913
               strcat_P(outBuf, PSTR("0 /0"));
920 914
             #endif

Loading…
Cancel
Save