Skip to content

Commit

Permalink
Just use int (?) and other fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 2, 2021
1 parent 452e94a commit 55ca037
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 11 additions & 12 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
30 changes: 15 additions & 15 deletions Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
12 changes: 3 additions & 9 deletions Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 55ca037

Please sign in to comment.