diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index b2731268a204..1a9976cd62ae 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -48,15 +48,15 @@ #include "../../../core/macros.h" #include "../../../gcode/queue.h" -#include "../../../feature/powerloss.h" -#include "../../../feature/babystep.h" - -#include "../../../module/settings.h" #include "../../../module/temperature.h" #include "../../../module/printcounter.h" #include "../../../module/motion.h" #include "../../../module/planner.h" +#if ENABLED(EEPROM_SETTINGS) + #include "../../../module/settings.h" +#endif + #if ENABLED(HOST_ACTION_COMMANDS) #include "../../../feature/host_actions.h" #endif @@ -69,6 +69,14 @@ #include "../../../module/probe.h" #endif +#if ENABLED(BABYSTEP_ZPROBE_OFFSET) || (!HAS_BED_PROBE && ENABLED(BABYSTEPPING)) + #include "../../../feature/babystep.h" +#endif + +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../../feature/powerloss.h" +#endif + #ifndef MACHINE_SIZE #define MACHINE_SIZE "220x220x250" #endif @@ -130,7 +138,7 @@ constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other #define MBASE(L) (49 + (L)*MLINE) -#define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, zprobe_zoffset) +#define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, dwin_zoffset) /* Value Init */ HMI_value_t HMI_ValueStruct; @@ -188,8 +196,8 @@ float last_E_scale = 0; bool DWIN_lcd_sd_status = 0; bool pause_action_flag = 0; int temphot = 0, tempbed = 0; -float zprobe_zoffset = 0; -float last_zoffset = 0, last_probe_zoffset = 0; +float dwin_zoffset = 0; +float last_zoffset = 0; #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 @@ -213,7 +221,7 @@ void HMI_SetAndSaveLanguageChinese(void) { BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); } -void show_plus_or_minus(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) { +void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) { if (value < 0) { DWIN_Draw_String(false, true, size, White, bColor, x - 6, y, F("-")); DWIN_Draw_FloatValue(true, true, 0, size, White, bColor, iNum, fNum, x, y, -value); @@ -517,7 +525,7 @@ inline void Prepare_Item_Offset(const uint8_t row) { if (HMI_flag.language_chinese) { #if HAS_BED_PROBE DWIN_Frame_AreaCopy(1, 174, 164, 271 - 48, 479 - 302, LBLX, MBASE(row)); - show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z * 100); + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z * 100); #else DWIN_Frame_AreaCopy(1, 43, 89, 271 - 173, 479 - 378, LBLX, MBASE(row)); #endif @@ -525,7 +533,7 @@ inline void Prepare_Item_Offset(const uint8_t row) { else { #if HAS_BED_PROBE DWIN_Frame_AreaCopy(1, 93, 179, 271 - 130, 479 - 290, LBLX, MBASE(row)); // "Z-Offset" - show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z * 100); + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), probe.offset.z * 100); #else DWIN_Frame_AreaCopy(1, 1, 76, 271 - 165, 479 - 393, LBLX, MBASE(row)); // "..." #endif @@ -633,22 +641,28 @@ inline void Draw_Control_Menu() { Draw_Title(GET_TEXT_F(MSG_CONTROL)); DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 0), GET_TEXT_F(MSG_TEMPERATURE)); DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 1), GET_TEXT_F(MSG_MOTION)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), GET_TEXT_F(MSG_STORE_EEPROM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), GET_TEXT_F(MSG_LOAD_EEPROM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); - if (CVISI(6)) - DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 5), F("Info")); + #if ENABLED(EEPROM_SETTINGS) + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), GET_TEXT_F(MSG_LOAD_EEPROM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); + if (CVISI(6)) DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 5), F("Info")); + #else + if (CVISI(3)) DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 2), F("Info")); + #endif #else DWIN_Frame_AreaCopy(1, 128, 2, 271 - 95, 479 - 467, 14, 8); DWIN_Frame_AreaCopy(1, 1, 89, 271 - 188, 479 - 377 - 1, LBLX, CLINE(1));// Temperature > DWIN_Frame_AreaCopy(1, 84, 89, 271 - 143, 479 - 380, LBLX, CLINE(2));// Motion > - DWIN_Frame_AreaCopy(1, 131 + 17, 89, 271 - 3, 479 - 377 - 1, LBLX, CLINE(3));// "Store Configuration" - DWIN_Frame_AreaCopy(1, 26, 104, 271 - 214, 479 - 365, LBLX, CLINE(4)); // "Read" - DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 31 + 3, CLINE(4)); // "Configuration" - DWIN_Frame_AreaCopy(1, 59, 104, 271 - 178, 479 - 365, LBLX, CLINE(5)); // "Reset" - DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 34 + 3, CLINE(5)); // "Configuration" - if (CVISI(6)) - DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(6)); // Info > + #if ENABLED(EEPROM_SETTINGS) + DWIN_Frame_AreaCopy(1, 131 + 17, 89, 271 - 3, 479 - 377 - 1, LBLX, CLINE(3));// "Store Configuration" + DWIN_Frame_AreaCopy(1, 26, 104, 271 - 214, 479 - 365, LBLX, CLINE(4)); // "Read" + DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 31 + 3, CLINE(4)); // "Configuration" + DWIN_Frame_AreaCopy(1, 59, 104, 271 - 178, 479 - 365, LBLX, CLINE(5)); // "Reset" + DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 34 + 3, CLINE(5)); // "Configuration" + if (CVISI(6)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(6)); // Info > + #else + if (CVISI(3)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(3)); // Info > + #endif #endif } @@ -708,7 +722,7 @@ inline void Draw_Tune_Menu() { DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_hotend[0].target); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.temp_bed.target); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4), thermalManager.fan_speed[0]); - show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(5), BABY_Z_VAR * 100); + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(5), BABY_Z_VAR * 100); } inline void draw_max_en(const uint16_t line) { @@ -1102,7 +1116,7 @@ void HMI_Move_Z(void) { checkkey = AxisMove; EncoderRate.encoderRateEnabled = 0; last_E_scale = HMI_ValueStruct.Move_E_scale; - show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); if (!planner.is_full()) { planner.synchronize(); // Wait for planner moves to finish! planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder); @@ -1115,57 +1129,55 @@ void HMI_Move_Z(void) { else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) HMI_ValueStruct.Move_E_scale = last_E_scale - (EXTRUDE_MAXLENGTH) * MINUNITMULT; current_position.e = HMI_ValueStruct.Move_E_scale / 10; - show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); DWIN_UpdateLCD(); } } #endif -void HMI_Zoffset(void) { - ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - last_zoffset = zprobe_zoffset; - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - EncoderRate.encoderRateEnabled = 0; - zprobe_zoffset = HMI_ValueStruct.offset_value / 100; - #if HAS_BED_PROBE - if (WITHIN(zprobe_zoffset - last_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) - probe.offset.z = zprobe_zoffset; - settings.save(); - #if ENABLED(BABYSTEPPING) - babystep.add_mm(Z_AXIS, (zprobe_zoffset - last_zoffset)); - #endif - #else - UNUSED(zprobe_zoffset - last_zoffset); - #endif +#if EITHER(BABYSTEPPING, HAS_BED_PROBE) - if (HMI_ValueStruct.show_mode == -4) { - checkkey = Prepare; - show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(4 + MROWS - index_prepare), TERN(HAS_BED_PROBE, probe.offset.z * 100, HMI_ValueStruct.offset_value)); - } - else { - checkkey = Tune; - show_plus_or_minus(font8x16, Background_black, 2, 2, 202, MBASE(5 + MROWS - index_tune), TERN(HAS_BED_PROBE, probe.offset.z * 100, HMI_ValueStruct.offset_value)); + void HMI_Zoffset(void) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.offset_value -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + EncoderRate.encoderRateEnabled = 0; + #if HAS_BED_PROBE + probe.offset.z = dwin_zoffset; + TERN_(EEPROM_SETTINGS, settings.save()); + #endif + if (HMI_ValueStruct.show_mode == -4) { + checkkey = Prepare; + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(4 + MROWS - index_prepare), TERN(HAS_BED_PROBE, probe.offset.z * 100, HMI_ValueStruct.offset_value)); + } + else { + checkkey = Tune; + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(5 + MROWS - index_tune), TERN(HAS_BED_PROBE, probe.offset.z * 100, HMI_ValueStruct.offset_value)); + } + DWIN_UpdateLCD(); + return; } + NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100); + NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100); + last_zoffset = dwin_zoffset; + dwin_zoffset = HMI_ValueStruct.offset_value / 100; + #if ENABLED(BABYSTEP_ZPROBE_OFFSET) || (!HAS_BED_PROBE && ENABLED(BABYSTEPPING)) + babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset); + #endif + if (HMI_ValueStruct.show_mode == -4) + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value); + else + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value); DWIN_UpdateLCD(); - return; } - NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100); - NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100); - if (HMI_ValueStruct.show_mode == -4) - show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value); - else - show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value); - DWIN_UpdateLCD(); } -} + +#endif // BABYSTEPPING || HAS_BED_PROBE #if HAS_HOTEND @@ -1214,7 +1226,7 @@ void HMI_Zoffset(void) { } } -#endif // if HAS_HOTEND +#endif // HAS_HOTEND #if HAS_HEATED_BED @@ -1263,7 +1275,7 @@ void HMI_Zoffset(void) { } } -#endif // if HAS_HEATED_BED +#endif // HAS_HEATED_BED #if HAS_FAN @@ -1312,7 +1324,7 @@ void HMI_Zoffset(void) { } } -#endif // if HAS_FAN +#endif // HAS_FAN void HMI_PrintSpeed(void) { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); @@ -1516,17 +1528,10 @@ void update_variable(void) { DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); last_speed = feedrate_percentage; } - #if HAS_BED_PROBE - if (last_probe_zoffset != probe.offset.z) { - show_plus_or_minus(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, probe.offset.z * 100); - last_probe_zoffset = probe.offset.z; - } - #else - if (last_zoffset != zprobe_zoffset) { - show_plus_or_minus(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, zprobe_zoffset * 100); - last_zoffset = zprobe_zoffset; - } - #endif + if (last_zoffset != BABY_Z_VAR) { + DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100); + last_zoffset = BABY_Z_VAR; + } } /** @@ -1724,7 +1729,7 @@ void HMI_StartFrame(const bool with_update) { DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + (2 + 3) * STAT_CHR_W + 2, 429, F("%")); - show_plus_or_minus(STAT_FONT, Background_black, 2, 2, 178, 429, BABY_Z_VAR * 100); + DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178, 429, BABY_Z_VAR * 100); DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 3 * STAT_CHR_W + 5, 383, F("/")); DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 178 + 3 * STAT_CHR_W + 5, 383, F("/")); @@ -2224,7 +2229,7 @@ void HMI_Prepare(void) { DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), current_position[X_AXIS] * MINUNITMULT); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), current_position[Y_AXIS] * MINUNITMULT); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), current_position[Z_AXIS] * MINUNITMULT); - show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), current_position.e * MINUNITMULT); + DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), current_position.e * MINUNITMULT); break; case 2: // close motion queue.inject_P(PSTR("M84")); @@ -2238,9 +2243,9 @@ void HMI_Prepare(void) { case 4: // Z-offset #if HAS_BED_PROBE checkkey = Homeoffset; - HMI_ValueStruct.show_mode = -4; + HMI_ValueStruct.show_mode = -4; HMI_ValueStruct.offset_value = probe.offset.z * 100; - show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value); + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value); EncoderRate.encoderRateEnabled = 1; #else // Apply workspace offset, making the current position 0,0,0 @@ -2393,19 +2398,22 @@ void HMI_Control(void) { select_motion.reset(); Draw_Motion_Menu(); break; - case 3: { // write EEPROM - const bool success = settings.save(); - HMI_AudioFeedback(success); - } break; - case 4: { // read EEPROM - const bool success = settings.load(); - HMI_AudioFeedback(success); - } break; - case 5: // resume EEPROM - settings.reset(); - HMI_AudioFeedback(); - break; - case 6: // info + case 3: + #if ENABLED(EEPROM_SETTINGS) + { // write EEPROM + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + case 4: { // read EEPROM + const bool success = settings.load(); + HMI_AudioFeedback(success); + } break; + case 5: // resume EEPROM + settings.reset(); + HMI_AudioFeedback(); + break; + case 6: // info + #endif checkkey = Info; Draw_Info_Menu(); break; @@ -2443,7 +2451,7 @@ void HMI_AxisMove(void) { DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); - show_plus_or_minus(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); DWIN_UpdateLCD(); } return; @@ -2496,7 +2504,7 @@ void HMI_AxisMove(void) { #endif checkkey = Extruder; HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT; - show_plus_or_minus(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); + DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); EncoderRate.encoderRateEnabled = 1; break; #endif @@ -2594,7 +2602,9 @@ void HMI_Temperature(void) { Draw_Menu_Line(1, ICON_SetEndTemp); Draw_Menu_Line(2, ICON_SetBedTemp); Draw_Menu_Line(3, ICON_FanSpeed); - Draw_Menu_Line(4, ICON_WriteEEPROM); + #if ENABLED(EEPROM_SETTINGS) + Draw_Menu_Line(4, ICON_WriteEEPROM); + #endif DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[0].hotend_temp); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[0].bed_temp); @@ -2648,14 +2658,16 @@ void HMI_Temperature(void) { Draw_Menu_Line(1, ICON_SetEndTemp); Draw_Menu_Line(2, ICON_SetBedTemp); Draw_Menu_Line(3, ICON_FanSpeed); - Draw_Menu_Line(4, ICON_WriteEEPROM); + #if ENABLED(EEPROM_SETTINGS) + Draw_Menu_Line(4, ICON_WriteEEPROM); + #endif DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), ui.material_preset[1].hotend_temp); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[1].bed_temp); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[1].fan_speed); break; - #endif // if HAS_HOTEND + #endif // HAS_HOTEND } } DWIN_UpdateLCD(); @@ -2995,11 +3007,14 @@ void HMI_Tune(void) { break; #endif case 5: // Z-offset - checkkey = Homeoffset; - HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; - show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value); - EncoderRate.encoderRateEnabled = 1; + #if EITHER(BABYSTEPPING, HAS_BED_PROBE) + checkkey = Homeoffset; + HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value); + EncoderRate.encoderRateEnabled = 1; + #endif break; + case 6: // Language // Select language HMI_flag.language_chinese ^= true; @@ -3068,10 +3083,12 @@ void HMI_PLAPreheatSetting(void) { EncoderRate.encoderRateEnabled = 1; break; #endif - case 4: { // save PLA configuration - const bool success = settings.save(); - HMI_AudioFeedback(success); - } break; + #if ENABLED(EEPROM_SETTINGS) + case 4: { // save PLA configuration + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + #endif default: break; } } @@ -3122,10 +3139,12 @@ void HMI_ABSPreheatSetting(void) { EncoderRate.encoderRateEnabled = 1; break; #endif - case 4: { // save ABS configuration - const bool success = settings.save(); - HMI_AudioFeedback(success); - } break; + #if ENABLED(EEPROM_SETTINGS) + case 4: { // save ABS configuration + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + #endif default: break; } @@ -3378,7 +3397,7 @@ void EachMomentUpdate(void) { update_variable(); if (checkkey == PrintProcess) { - // if print done + // print done if (HMI_flag.print_finish && !HMI_flag.confirm_flag) { HMI_flag.print_finish = 0; HMI_flag.confirm_flag = 1; @@ -3442,7 +3461,7 @@ void EachMomentUpdate(void) { else if (abort_flag && !HMI_flag.home_flag) { // Print Stop abort_flag = 0; HMI_ValueStruct.print_speed = feedrate_percentage = 100; - zprobe_zoffset = TERN(HAS_BED_PROBE, probe.offset.z, 0); + dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); planner.finish_and_disable(); @@ -3453,70 +3472,72 @@ void EachMomentUpdate(void) { select_page.set(0); Goto_MainMenu(); } - else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off - recovery.dwin_flag = false; - - recovery.load(); - if (!recovery.valid()) return recovery.purge(); - - auto draw_first_option = [](const bool sel) { - const uint16_t c1 = sel ? Background_window : Select_Color; - DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345); - DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346); - }; - - auto update_selection = [&](const bool sel) { - HMI_flag.select_flag = sel; - draw_first_option(sel); - const uint16_t c2 = sel ? Select_Color : Background_window; - DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345); - DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346); - }; - - const uint16_t fileCnt = card.get_num_Files(); - for (uint16_t i = 0; i < fileCnt; i++) { - // TODO: Resume print via M1000 then update the UI - // with the active filename which can come from CardReader. - card.getfilename_sorted(SD_ORDER(i, fileCnt)); - if (!strcmp(card.filename, &recovery.info.sd_filename[1])) { // Resume print before power failure while have the same file - recovery_flag = 1; - HMI_flag.select_flag = 1; - Popup_Window_Resume(); - draw_first_option(false); - char * const name = card.longest_filename(); - const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2; - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, npos, 252, name); - DWIN_UpdateLCD(); - break; + #if ENABLED(POWER_LOSS_RECOVERY) + else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off + recovery.dwin_flag = false; + + recovery.load(); + if (!recovery.valid()) return recovery.purge(); + + auto draw_first_option = [](const bool sel) { + const uint16_t c1 = sel ? Background_window : Select_Color; + DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345); + DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346); + }; + + auto update_selection = [&](const bool sel) { + HMI_flag.select_flag = sel; + draw_first_option(sel); + const uint16_t c2 = sel ? Select_Color : Background_window; + DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345); + DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346); + }; + + const uint16_t fileCnt = card.get_num_Files(); + for (uint16_t i = 0; i < fileCnt; i++) { + // TODO: Resume print via M1000 then update the UI + // with the active filename which can come from CardReader. + card.getfilename_sorted(SD_ORDER(i, fileCnt)); + if (!strcmp(card.filename, &recovery.info.sd_filename[1])) { // Resume print before power failure while have the same file + recovery_flag = 1; + HMI_flag.select_flag = 1; + Popup_Window_Resume(); + draw_first_option(false); + char * const name = card.longest_filename(); + const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2; + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, npos, 252, name); + DWIN_UpdateLCD(); + break; + } } - } - // if hasn't resumable G-code file - if (!recovery_flag) return; + // hasn't resumable G-code file + if (!recovery_flag) return; + + while (recovery_flag) { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_ENTER) { + recovery_flag = 0; + if (HMI_flag.select_flag) break; + TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); + HMI_StartFrame(true); + return; + } + else + update_selection(encoder_diffState == ENCODER_DIFF_CCW); - while (recovery_flag) { - ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_ENTER) { - recovery_flag = 0; - if (HMI_flag.select_flag) break; - TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); - HMI_StartFrame(true); - return; + DWIN_UpdateLCD(); } - else - update_selection(encoder_diffState == ENCODER_DIFF_CCW); - - DWIN_UpdateLCD(); } - } - select_print.set(0); - HMI_ValueStruct.show_mode = 0; - HMI_StartFrame(false); - recovery.resume(); - return; - } + select_print.set(0); + HMI_ValueStruct.show_mode = 0; + HMI_StartFrame(false); + recovery.resume(); + return; + } + #endif DWIN_UpdateLCD(); } @@ -3547,7 +3568,9 @@ void DWIN_HandleScreen(void) { case Extruder: HMI_Move_E(); break; case ETemp: HMI_ETemp(); break; #endif - case Homeoffset: HMI_Zoffset(); break; + #if EITHER(BABYSTEPPING, HAS_BED_PROBE) + case Homeoffset: HMI_Zoffset(); break; + #endif #if HAS_HEATED_BED case BedTemp: HMI_BedTemp(); break; #endif @@ -3573,7 +3596,7 @@ void DWIN_CompletedHoming(void) { } else if (checkkey == Back_Main) { HMI_ValueStruct.print_speed = feedrate_percentage = 100; - zprobe_zoffset = TERN0(BLTOUCH, probe.offset.z); + dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); planner.finish_and_disable(); Goto_MainMenu(); } diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index dffd40bd03fb..e5d95f61661c 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -318,7 +318,7 @@ void HMI_MaxCornerXYZE(void); void HMI_StepXYZE(void); void update_variable(void); -void show_plus_or_minus(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value); +void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value); // SD Card void HMI_SDCardInit(void); diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index c2eab2ba0604..5d500e707fba 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -759,7 +759,7 @@ namespace ExtUI { if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) probe.offset.z = value; #elif ENABLED(BABYSTEP_DISPLAY_TOTAL) - babystep.add_mm(Z_AXIS, (value - getZOffset_mm())); + babystep.add_mm(Z_AXIS, value - getZOffset_mm()); #else UNUSED(value); #endif