Allow E3 V2 DWIN without EEPROM, POWER_LOSS_RECOVERY

This commit is contained in:
Scott Lahteine 2020-09-14 02:48:45 -05:00
parent 2877dc9794
commit 8e3ac54de3
3 changed files with 164 additions and 148 deletions

View file

@ -48,15 +48,17 @@
#include "../../../core/macros.h" #include "../../../core/macros.h"
#include "../../../gcode/queue.h" #include "../../../gcode/queue.h"
#include "../../../feature/powerloss.h"
#include "../../../feature/babystep.h" #include "../../../feature/babystep.h"
#include "../../../module/settings.h"
#include "../../../module/temperature.h" #include "../../../module/temperature.h"
#include "../../../module/printcounter.h" #include "../../../module/printcounter.h"
#include "../../../module/motion.h" #include "../../../module/motion.h"
#include "../../../module/planner.h" #include "../../../module/planner.h"
#if ENABLED(EEPROM_SETTINGS)
#include "../../../module/settings.h"
#endif
#if ENABLED(HOST_ACTION_COMMANDS) #if ENABLED(HOST_ACTION_COMMANDS)
#include "../../../feature/host_actions.h" #include "../../../feature/host_actions.h"
#endif #endif
@ -69,6 +71,10 @@
#include "../../../module/probe.h" #include "../../../module/probe.h"
#endif #endif
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../feature/powerloss.h"
#endif
#ifndef MACHINE_SIZE #ifndef MACHINE_SIZE
#define MACHINE_SIZE "220x220x250" #define MACHINE_SIZE "220x220x250"
#endif #endif
@ -130,7 +136,7 @@ constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other
#define MBASE(L) (49 + (L)*MLINE) #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 */ /* Value Init */
HMI_value_t HMI_ValueStruct; HMI_value_t HMI_ValueStruct;
@ -188,8 +194,8 @@ float last_E_scale = 0;
bool DWIN_lcd_sd_status = 0; bool DWIN_lcd_sd_status = 0;
bool pause_action_flag = 0; bool pause_action_flag = 0;
int temphot = 0, tempbed = 0; int temphot = 0, tempbed = 0;
float zprobe_zoffset = 0; float dwin_zoffset = 0;
float last_zoffset = 0, last_probe_zoffset = 0; float last_zoffset = 0;
#define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1)
// BL24CXX::check() uses 0x00 // BL24CXX::check() uses 0x00
@ -213,7 +219,7 @@ void HMI_SetAndSaveLanguageChinese(void) {
BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); 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) { if (value < 0) {
DWIN_Draw_String(false, true, size, White, bColor, x - 6, y, F("-")); 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); DWIN_Draw_FloatValue(true, true, 0, size, White, bColor, iNum, fNum, x, y, -value);
@ -517,7 +523,7 @@ inline void Prepare_Item_Offset(const uint8_t row) {
if (HMI_flag.language_chinese) { if (HMI_flag.language_chinese) {
#if HAS_BED_PROBE #if HAS_BED_PROBE
DWIN_Frame_AreaCopy(1, 174, 164, 271 - 48, 479 - 302, LBLX, MBASE(row)); 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 #else
DWIN_Frame_AreaCopy(1, 43, 89, 271 - 173, 479 - 378, LBLX, MBASE(row)); DWIN_Frame_AreaCopy(1, 43, 89, 271 - 173, 479 - 378, LBLX, MBASE(row));
#endif #endif
@ -525,7 +531,7 @@ inline void Prepare_Item_Offset(const uint8_t row) {
else { else {
#if HAS_BED_PROBE #if HAS_BED_PROBE
DWIN_Frame_AreaCopy(1, 93, 179, 271 - 130, 479 - 290, LBLX, MBASE(row)); // "Z-Offset" 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 #else
DWIN_Frame_AreaCopy(1, 1, 76, 271 - 165, 479 - 393, LBLX, MBASE(row)); // "..." DWIN_Frame_AreaCopy(1, 1, 76, 271 - 165, 479 - 393, LBLX, MBASE(row)); // "..."
#endif #endif
@ -633,22 +639,28 @@ inline void Draw_Control_Menu() {
Draw_Title(GET_TEXT_F(MSG_CONTROL)); 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 * 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 * 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)); #if ENABLED(EEPROM_SETTINGS)
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 * 2), GET_TEXT_F(MSG_STORE_EEPROM));
DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 3), GET_TEXT_F(MSG_LOAD_EEPROM));
if (CVISI(6)) DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 4), GET_TEXT_F(MSG_RESTORE_DEFAULTS));
DWIN_Draw_String(false, true, font8x16, White, Background_black, 60, 102 + (MLINE * 5), F("Info")); 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 #else
DWIN_Frame_AreaCopy(1, 128, 2, 271 - 95, 479 - 467, 14, 8); 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, 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, 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" #if ENABLED(EEPROM_SETTINGS)
DWIN_Frame_AreaCopy(1, 26, 104, 271 - 214, 479 - 365, LBLX, CLINE(4)); // "Read" DWIN_Frame_AreaCopy(1, 131 + 17, 89, 271 - 3, 479 - 377 - 1, LBLX, CLINE(3));// "Store Configuration"
DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 31 + 3, CLINE(4)); // "Configuration" DWIN_Frame_AreaCopy(1, 26, 104, 271 - 214, 479 - 365, LBLX, CLINE(4)); // "Read"
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 + 31 + 3, CLINE(4)); // "Configuration"
DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 34 + 3, CLINE(5)); // "Configuration" DWIN_Frame_AreaCopy(1, 59, 104, 271 - 178, 479 - 365, LBLX, CLINE(5)); // "Reset"
if (CVISI(6)) DWIN_Frame_AreaCopy(1, 131 + 51, 89, 271 - 3, 479 - 377 - 1, LBLX + 34 + 3, CLINE(5)); // "Configuration"
DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(6)); // Info > 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 #endif
} }
@ -708,7 +720,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(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(3), thermalManager.temp_bed.target);
DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4), thermalManager.fan_speed[0]); 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) { inline void draw_max_en(const uint16_t line) {
@ -1102,7 +1114,7 @@ void HMI_Move_Z(void) {
checkkey = AxisMove; checkkey = AxisMove;
EncoderRate.encoderRateEnabled = 0; EncoderRate.encoderRateEnabled = 0;
last_E_scale = HMI_ValueStruct.Move_E_scale; 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()) { if (!planner.is_full()) {
planner.synchronize(); // Wait for planner moves to finish! planner.synchronize(); // Wait for planner moves to finish!
planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder); planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E), active_extruder);
@ -1115,7 +1127,7 @@ void HMI_Move_Z(void) {
else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT) else if ((last_E_scale - HMI_ValueStruct.Move_E_scale) > (EXTRUDE_MAXLENGTH) * MINUNITMULT)
HMI_ValueStruct.Move_E_scale = last_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; 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(); DWIN_UpdateLCD();
} }
} }
@ -1125,7 +1137,7 @@ void HMI_Move_Z(void) {
void HMI_Zoffset(void) { void HMI_Zoffset(void) {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {
last_zoffset = zprobe_zoffset; last_zoffset = dwin_zoffset;
if (encoder_diffState == ENCODER_DIFF_CW) { if (encoder_diffState == ENCODER_DIFF_CW) {
HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue; HMI_ValueStruct.offset_value += EncoderRate.encoderMoveValue;
} }
@ -1134,24 +1146,22 @@ void HMI_Zoffset(void) {
} }
else if (encoder_diffState == ENCODER_DIFF_ENTER) { else if (encoder_diffState == ENCODER_DIFF_ENTER) {
EncoderRate.encoderRateEnabled = 0; EncoderRate.encoderRateEnabled = 0;
zprobe_zoffset = HMI_ValueStruct.offset_value / 100; dwin_zoffset = HMI_ValueStruct.offset_value / 100;
#if HAS_BED_PROBE #if HAS_BED_PROBE
if (WITHIN(zprobe_zoffset - last_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) if (WITHIN(dwin_zoffset - last_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
probe.offset.z = zprobe_zoffset; probe.offset.z = dwin_zoffset;
settings.save(); TERN_(EEPROM_SETTINGS, settings.save());
#elif ENABLED(BABYSTEPPING) #elif ENABLED(BABYSTEPPING)
babystep.add_mm(Z_AXIS, (zprobe_zoffset - last_zoffset)); babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset);
#else
UNUSED(zprobe_zoffset - last_zoffset);
#endif #endif
if (HMI_ValueStruct.show_mode == -4) { if (HMI_ValueStruct.show_mode == -4) {
checkkey = Prepare; 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)); 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 { else {
checkkey = Tune; 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)); 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(); DWIN_UpdateLCD();
return; return;
@ -1159,9 +1169,9 @@ void HMI_Zoffset(void) {
NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100); NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100);
NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100); NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100);
if (HMI_ValueStruct.show_mode == -4) 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); DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(4 + MROWS - index_prepare), HMI_ValueStruct.offset_value);
else else
show_plus_or_minus(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value); DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value);
DWIN_UpdateLCD(); DWIN_UpdateLCD();
} }
} }
@ -1213,7 +1223,7 @@ void HMI_Zoffset(void) {
} }
} }
#endif // if HAS_HOTEND #endif // HAS_HOTEND
#if HAS_HEATED_BED #if HAS_HEATED_BED
@ -1262,7 +1272,7 @@ void HMI_Zoffset(void) {
} }
} }
#endif // if HAS_HEATED_BED #endif // HAS_HEATED_BED
#if HAS_FAN #if HAS_FAN
@ -1311,7 +1321,7 @@ void HMI_Zoffset(void) {
} }
} }
#endif // if HAS_FAN #endif // HAS_FAN
void HMI_PrintSpeed(void) { void HMI_PrintSpeed(void) {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
@ -1515,27 +1525,20 @@ void update_variable(void) {
DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage); DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 2 * STAT_CHR_W, 429, feedrate_percentage);
last_speed = feedrate_percentage; last_speed = feedrate_percentage;
} }
#if HAS_BED_PROBE if (last_zoffset != BABY_Z_VAR) {
if (last_probe_zoffset != probe.offset.z) { DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, BABY_Z_VAR * 100);
show_plus_or_minus(STAT_FONT, Background_black, 2, 2, 178 + STAT_CHR_W, 429, probe.offset.z * 100); last_zoffset = BABY_Z_VAR;
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
} }
/** /**
* Read and cache the working directory. * Read and cache the working directory.
* *
* TODO: New code can follow the pattern of menu_media.cpp * TODO: New code can follow the pattern of menu_media.cpp
* and rely on Marlin caching for performance. No need to * and rely on Marlin caching for performance. No need to
* cache files here. * cache files here.
* *
*/ */
#ifndef strcasecmp_P #ifndef strcasecmp_P
#define strcasecmp_P(a, b) strcasecmp((a), (b)) #define strcasecmp_P(a, b) strcasecmp((a), (b))
@ -1723,7 +1726,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_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("%")); 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, 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("/")); DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 178 + 3 * STAT_CHR_W + 5, 383, F("/"));
@ -2223,7 +2226,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(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(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); 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; break;
case 2: // close motion case 2: // close motion
queue.inject_P(PSTR("M84")); queue.inject_P(PSTR("M84"));
@ -2237,9 +2240,9 @@ void HMI_Prepare(void) {
case 4: // Z-offset case 4: // Z-offset
#if HAS_BED_PROBE #if HAS_BED_PROBE
checkkey = Homeoffset; checkkey = Homeoffset;
HMI_ValueStruct.show_mode = -4; HMI_ValueStruct.show_mode = -4;
HMI_ValueStruct.offset_value = probe.offset.z * 100; 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; EncoderRate.encoderRateEnabled = 1;
#else #else
// Apply workspace offset, making the current position 0,0,0 // Apply workspace offset, making the current position 0,0,0
@ -2392,19 +2395,22 @@ void HMI_Control(void) {
select_motion.reset(); select_motion.reset();
Draw_Motion_Menu(); Draw_Motion_Menu();
break; break;
case 3: { // write EEPROM case 3:
const bool success = settings.save(); #if ENABLED(EEPROM_SETTINGS)
HMI_AudioFeedback(success); { // write EEPROM
} break; const bool success = settings.save();
case 4: { // read EEPROM HMI_AudioFeedback(success);
const bool success = settings.load(); } break;
HMI_AudioFeedback(success); case 4: { // read EEPROM
} break; const bool success = settings.load();
case 5: // resume EEPROM HMI_AudioFeedback(success);
settings.reset(); } break;
HMI_AudioFeedback(); case 5: // resume EEPROM
break; settings.reset();
case 6: // info HMI_AudioFeedback();
break;
case 6: // info
#endif
checkkey = Info; checkkey = Info;
Draw_Info_Menu(); Draw_Info_Menu();
break; break;
@ -2442,7 +2448,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(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(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); 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(); DWIN_UpdateLCD();
} }
return; return;
@ -2495,7 +2501,7 @@ void HMI_AxisMove(void) {
#endif #endif
checkkey = Extruder; checkkey = Extruder;
HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT; 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; EncoderRate.encoderRateEnabled = 1;
break; break;
#endif #endif
@ -2593,7 +2599,9 @@ void HMI_Temperature(void) {
Draw_Menu_Line(1, ICON_SetEndTemp); Draw_Menu_Line(1, ICON_SetEndTemp);
Draw_Menu_Line(2, ICON_SetBedTemp); Draw_Menu_Line(2, ICON_SetBedTemp);
Draw_Menu_Line(3, ICON_FanSpeed); 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(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); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), ui.material_preset[0].bed_temp);
@ -2647,14 +2655,16 @@ void HMI_Temperature(void) {
Draw_Menu_Line(1, ICON_SetEndTemp); Draw_Menu_Line(1, ICON_SetEndTemp);
Draw_Menu_Line(2, ICON_SetBedTemp); Draw_Menu_Line(2, ICON_SetBedTemp);
Draw_Menu_Line(3, ICON_FanSpeed); 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(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(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); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[1].fan_speed);
break; break;
#endif // if HAS_HOTEND #endif // HAS_HOTEND
} }
} }
DWIN_UpdateLCD(); DWIN_UpdateLCD();
@ -2996,7 +3006,7 @@ void HMI_Tune(void) {
case 5: // Z-offset case 5: // Z-offset
checkkey = Homeoffset; checkkey = Homeoffset;
HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; 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); DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(5 + MROWS - index_tune), HMI_ValueStruct.offset_value);
EncoderRate.encoderRateEnabled = 1; EncoderRate.encoderRateEnabled = 1;
break; break;
case 6: // Language case 6: // Language
@ -3067,10 +3077,12 @@ void HMI_PLAPreheatSetting(void) {
EncoderRate.encoderRateEnabled = 1; EncoderRate.encoderRateEnabled = 1;
break; break;
#endif #endif
case 4: { // save PLA configuration #if ENABLED(EEPROM_SETTINGS)
const bool success = settings.save(); case 4: { // save PLA configuration
HMI_AudioFeedback(success); const bool success = settings.save();
} break; HMI_AudioFeedback(success);
} break;
#endif
default: break; default: break;
} }
} }
@ -3121,10 +3133,12 @@ void HMI_ABSPreheatSetting(void) {
EncoderRate.encoderRateEnabled = 1; EncoderRate.encoderRateEnabled = 1;
break; break;
#endif #endif
case 4: { // save ABS configuration #if ENABLED(EEPROM_SETTINGS)
const bool success = settings.save(); case 4: { // save ABS configuration
HMI_AudioFeedback(success); const bool success = settings.save();
} break; HMI_AudioFeedback(success);
} break;
#endif
default: default:
break; break;
} }
@ -3441,7 +3455,7 @@ void EachMomentUpdate(void) {
else if (abort_flag && !HMI_flag.home_flag) { // Print Stop else if (abort_flag && !HMI_flag.home_flag) { // Print Stop
abort_flag = 0; abort_flag = 0;
HMI_ValueStruct.print_speed = feedrate_percentage = 100; 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(); planner.finish_and_disable();
@ -3452,70 +3466,72 @@ void EachMomentUpdate(void) {
select_page.set(0); select_page.set(0);
Goto_MainMenu(); Goto_MainMenu();
} }
else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off #if ENABLED(POWER_LOSS_RECOVERY)
recovery.dwin_flag = false; else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off
recovery.dwin_flag = false;
recovery.load(); recovery.load();
if (!recovery.valid()) return recovery.purge(); if (!recovery.valid()) return recovery.purge();
auto draw_first_option = [](const bool sel) { auto draw_first_option = [](const bool sel) {
const uint16_t c1 = sel ? Background_window : Select_Color; const uint16_t c1 = sel ? Background_window : Select_Color;
DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345); DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345);
DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346); DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346);
}; };
auto update_selection = [&](const bool sel) { auto update_selection = [&](const bool sel) {
HMI_flag.select_flag = sel; HMI_flag.select_flag = sel;
draw_first_option(sel); draw_first_option(sel);
const uint16_t c2 = sel ? Select_Color : Background_window; const uint16_t c2 = sel ? Select_Color : Background_window;
DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345); DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345);
DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346); DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346);
}; };
const uint16_t fileCnt = card.get_num_Files(); const uint16_t fileCnt = card.get_num_Files();
for (uint16_t i = 0; i < fileCnt; i++) { for (uint16_t i = 0; i < fileCnt; i++) {
// TODO: Resume print via M1000 then update the UI // TODO: Resume print via M1000 then update the UI
// with the active filename which can come from CardReader. // with the active filename which can come from CardReader.
card.getfilename_sorted(SD_ORDER(i, fileCnt)); 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 if (!strcmp(card.filename, &recovery.info.sd_filename[1])) { // Resume print before power failure while have the same file
recovery_flag = 1; recovery_flag = 1;
HMI_flag.select_flag = 1; HMI_flag.select_flag = 1;
Popup_Window_Resume(); Popup_Window_Resume();
draw_first_option(false); draw_first_option(false);
char * const name = card.longest_filename(); char * const name = card.longest_filename();
const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2; 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_Draw_String(false, true, font8x16, Font_window, Background_window, npos, 252, name);
DWIN_UpdateLCD(); DWIN_UpdateLCD();
break; break;
}
}
// if 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);
DWIN_UpdateLCD();
} }
}
select_print.set(0); // if hasn't resumable G-code file
HMI_ValueStruct.show_mode = 0; if (!recovery_flag) return;
HMI_StartFrame(false);
recovery.resume(); while (recovery_flag) {
return; 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);
DWIN_UpdateLCD();
}
}
select_print.set(0);
HMI_ValueStruct.show_mode = 0;
HMI_StartFrame(false);
recovery.resume();
return;
}
#endif
DWIN_UpdateLCD(); DWIN_UpdateLCD();
} }
@ -3572,7 +3588,7 @@ void DWIN_CompletedHoming(void) {
} }
else if (checkkey == Back_Main) { else if (checkkey == Back_Main) {
HMI_ValueStruct.print_speed = feedrate_percentage = 100; 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(); planner.finish_and_disable();
Goto_MainMenu(); Goto_MainMenu();
} }

View file

@ -318,7 +318,7 @@ void HMI_MaxCornerXYZE(void);
void HMI_StepXYZE(void); void HMI_StepXYZE(void);
void update_variable(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 // SD Card
void HMI_SDCardInit(void); void HMI_SDCardInit(void);

View file

@ -759,7 +759,7 @@ namespace ExtUI {
if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
probe.offset.z = value; probe.offset.z = value;
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL) #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
babystep.add_mm(Z_AXIS, (value - getZOffset_mm())); babystep.add_mm(Z_AXIS, value - getZOffset_mm());
#else #else
UNUSED(value); UNUSED(value);
#endif #endif