From ec573df5fcb87a09cf82da75cafafb7553545c89 Mon Sep 17 00:00:00 2001 From: Miguel Risco-Castillo Date: Mon, 22 Jan 2024 13:25:27 -0500 Subject: [PATCH] Fix bugs and implement user feedback --- Marlin/src/lcd/e3v2/proui/dwin.cpp | 18 ++++++++++++------ Marlin/src/lcd/e3v2/proui/dwinui.cpp | 2 +- Marlin/src/module/settings.cpp | 18 ++++++++++++------ Marlin/src/module/settings.h | 2 +- .../pins/stm32f4/pins_CREALITY_CR4NTxxC10.h | 1 + 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 211c5a64d7..9345d49edb 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -735,7 +735,7 @@ void _drawXYZPosition(const bool force) { } void updateVariable() { - TERN_(DEBUG_DWIN,DWINUI::drawInt(COLOR_YELLOW, COLOR_BG_BLACK, 2, DWIN_WIDTH-6*DWINUI::fontWidth(), 6, checkkey)); + TERN_(DEBUG_DWIN,DWINUI::drawInt(COLOR_LIGHT_RED, COLOR_BG_BLACK, 2, DWIN_WIDTH-6*DWINUI::fontWidth(), 6, checkkey)); TERN_(DEBUG_DWIN,DWINUI::drawInt(COLOR_YELLOW, COLOR_BG_BLACK, 2, DWIN_WIDTH-3*DWINUI::fontWidth(), 6, last_checkkey)); _drawXYZPosition(false); @@ -1385,7 +1385,7 @@ void dwinHandleScreen() { case ID_SetIntNoDraw: hmiSetNoDraw(); break; case ID_PrintProcess: hmiPrinting(); break; case ID_Popup: hmiPopup(); break; - case ID_Leveling: TERN_(PROUI_EX, hmiWaitForUser();) break; + case ID_Leveling: TERN_(PROUI_EX, hmiWaitForUser()); break; #if HAS_LOCKSCREEN case ID_Locked: hmiLockScreen(); break; #endif @@ -1437,7 +1437,7 @@ void hmiReturnScreen() { void dwinHomingStart() { DEBUG_ECHOLNPGM("dwinHomingStart"); - hmiSaveProcessID(ID_Homing); + if (checkkey != ID_NothingToDo) hmiSaveProcessID(ID_Homing); title.draw(GET_TEXT_F(MSG_HOMING)); dwinShowPopup(ICON_BLTouch, GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT)); } @@ -1453,7 +1453,7 @@ void dwinHomingDone() { #endif if (last_checkkey == ID_PrintDone) gotoPrintDone(); - else + else if (checkkey != ID_NothingToDo) hmiReturnScreen(); } @@ -1463,10 +1463,10 @@ void dwinHomingDone() { DEBUG_ECHOLNPGM("dwinLevelingStart"); #if HAS_BED_PROBE hmiSaveProcessID(ID_Leveling); - TERN_(PROUI_EX,proUIEx.cancel_lev = 0); title.draw(GET_TEXT_F(MSG_BED_LEVELING)); #if PROUI_EX meshViewer.drawBackground(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); + proUIEx.cancel_lev = 0; DWINUI::drawButton(BTN_Cancel, 86, 305); #else dwinShowPopup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT), TERN(PROUI_EX, BTN_Cancel, 0)); @@ -1597,6 +1597,7 @@ void dwinHomingDone() { void dwinPidTuning(tempcontrol_t result) { hmiValue.tempControl = result; switch (result) { + #if ENABLED(PIDTEMPBED) case PIDTEMPBED_START: hmiSaveProcessID(ID_PIDProcess); #if HAS_PLOT @@ -1605,6 +1606,8 @@ void dwinHomingDone() { dwinDrawPopup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_BED_IS_RUN)); #endif break; + #endif + #if ENABLED(PIDTEMP) case PIDTEMP_START: hmiSaveProcessID(ID_PIDProcess); #if HAS_PLOT @@ -1613,6 +1616,7 @@ void dwinHomingDone() { dwinDrawPopup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_NOZZLE_IS_RUN)); #endif break; + #endif case PID_BAD_HEATER_ID: checkkey = last_checkkey; dwinPopupContinue(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_BAD_HEATER_ID)); @@ -2276,7 +2280,7 @@ void applyMove() { #endif #if HAS_HOME_OFFSET - void applyHomeOffset() { set_home_offset(hmiValue.select, menuData.value / MINUNITMULT); } + void applyHomeOffset() { set_home_offset((AxisEnum)hmiValue.select, menuData.value / MINUNITMULT); } void setHomeOffsetX() { hmiValue.select = X_AXIS; setPFloatOnClick(-50, 50, UNITFDIGITS, applyHomeOffset); } void setHomeOffsetY() { hmiValue.select = Y_AXIS; setPFloatOnClick(-50, 50, UNITFDIGITS, applyHomeOffset); } void setHomeOffsetZ() { hmiValue.select = Z_AXIS; setPFloatOnClick( -2, 2, UNITFDIGITS, applyHomeOffset); } @@ -2654,9 +2658,11 @@ void drawPrepareMenu() { #if ALL(HAS_BED_PROBE, HAS_TRAMMING_WIZARD) void runTrammingWizard() { + hmiSaveProcessID(ID_NothingToDo); meshViewer.meshfont = font8x16; trammingWizard(); meshViewer.meshfont = TERN(TJC_DISPLAY, font8x16, font6x12); + hmiSaveProcessID(ID_WaitResponse); } #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index 4b49a66b62..f4687377a6 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -331,7 +331,7 @@ uint16_t Title::backColor = defColorTitleBg; void Title::draw(const char * const caption) { dwinDrawRectangle(1, backColor, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); #if ENABLED(TITLE_CENTERED) - drawCenteredString(false, DWIN_FONT_HEAD, textColor, backColor, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, caption); + DWINUI::drawCenteredString(false, DWIN_FONT_HEAD, textColor, backColor, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, caption); #else dwinDrawString(false, DWIN_FONT_HEAD, textColor, backColor, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, caption); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 51561c2fac..d4b0daa184 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -46,8 +46,8 @@ // Check the integrity of data offsets. // Can be disabled for production build. -//#define DEBUG_EEPROM_READWRITE -//#define DEBUG_EEPROM_OBSERVE +// #define DEBUG_EEPROM_READWRITE +// #define DEBUG_EEPROM_OBSERVE #include "settings.h" @@ -707,11 +707,12 @@ typedef struct SettingsDataStruct { } SettingsData; -//static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); +constexpr size_t settingsdata_size = sizeof(SettingsData); +static_assert(settingsdata_size <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); MarlinSettings settings; -uint16_t MarlinSettings::datasize() { return sizeof(SettingsData); } +uint16_t MarlinSettings::datasize() { return settingsdata_size; } /** * Post-process after Retrieve or Reset @@ -846,11 +847,16 @@ void MarlinSettings::postprocess() { #endif #if ENABLED(DEBUG_EEPROM_OBSERVE) - #define EEPROM_READ(V...) do{ SERIAL_ECHOLNPGM("READ: ", F(STRINGIFY(FIRST(V)))); EEPROM_READ_(V); }while(0) - #define EEPROM_READ_ALWAYS(V...) do{ SERIAL_ECHOLNPGM("READ: ", F(STRINGIFY(FIRST(V)))); EEPROM_READ_ALWAYS_(V); }while(0) + #define EEPROM_READ(V...) do{ SERIAL_ECHOPGM("READ: ", F(STRINGIFY(FIRST(V)))); EEPROM_READ_(V); SERIAL_ECHOLNPGM(" CRC: ", working_crc); }while(0) + #define EEPROM_READ_ALWAYS(V...) do{ SERIAL_ECHOPGM("READ: ", F(STRINGIFY(FIRST(V)))); EEPROM_READ_ALWAYS_(V); SERIAL_ECHOLNPGM(" CRC: ", working_crc); }while(0) + #define EEPROM_WRITE(V...) do{ SERIAL_ECHOPGM("WRITE: ", F(STRINGIFY(FIRST(V)))); EEPROM_WRITE_(V); SERIAL_ECHOLNPGM(" CRC: ", working_crc); }while(0) + // #define EEPROM_READ(V...) do{ SERIAL_ECHOLNPGM("READ: ", F(STRINGIFY(FIRST(V)))); EEPROM_READ_(V); }while(0) + // #define EEPROM_READ_ALWAYS(V...) do{ SERIAL_ECHOLNPGM("READ: ", F(STRINGIFY(FIRST(V)))); EEPROM_READ_ALWAYS_(V); }while(0) + // #define EEPROM_WRITE(V...) do{ SERIAL_ECHOLNPGM("WRITE: ", F(STRINGIFY(FIRST(V)))); EEPROM_WRITE_(V); }while(0) #else #define EEPROM_READ(V...) EEPROM_READ_(V) #define EEPROM_READ_ALWAYS(V...) EEPROM_READ_ALWAYS_(V) + #define EEPROM_WRITE(V...) EEPROM_WRITE_(V) #endif const char version[4] = EEPROM_VERSION; diff --git a/Marlin/src/module/settings.h b/Marlin/src/module/settings.h index b7c5210db5..0518c8c2d4 100644 --- a/Marlin/src/module/settings.h +++ b/Marlin/src/module/settings.h @@ -132,7 +132,7 @@ class MarlinSettings { static void EEPROM_SKIP(const T &VAR) { eeprom_index += sizeof(VAR); } template - static void EEPROM_WRITE(const T &VAR) { + static void EEPROM_WRITE_(const T &VAR) { persistentStore.write_data(eeprom_index, (const uint8_t *) &VAR, sizeof(VAR), &working_crc); } diff --git a/Marlin/src/pins/stm32f4/pins_CREALITY_CR4NTxxC10.h b/Marlin/src/pins/stm32f4/pins_CREALITY_CR4NTxxC10.h index 73ab616a2b..0b3c9da21b 100644 --- a/Marlin/src/pins/stm32f4/pins_CREALITY_CR4NTxxC10.h +++ b/Marlin/src/pins/stm32f4/pins_CREALITY_CR4NTxxC10.h @@ -203,6 +203,7 @@ * ------ * EXP1 */ + #define EXP1_01_PIN PC0 #define EXP1_02_PIN PB2 #define EXP1_03_PIN PA2