From 00c3b4eff70b865d7ef42b6db39a63fbe154881e Mon Sep 17 00:00:00 2001 From: cosmoderp <36945803+cosmoderp@users.noreply.github.com> Date: Thu, 17 Sep 2020 06:35:04 -0400 Subject: [PATCH] E3 V2 DWIN: Z-Offset, cleanup, versatility (#19384) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 2 +- Marlin/src/inc/Conditionals_adv.h | 2 +- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 2252 +++++++++-------- Marlin/src/lcd/dwin/e3v2/dwin.h | 136 +- Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp | 2 +- Marlin/src/lcd/dwin/e3v2/rotary_encoder.h | 2 +- Marlin/src/module/temperature.cpp | 26 +- .../PlatformIO/scripts/common-dependencies.h | 4 - platformio.ini | 1 - 9 files changed, 1349 insertions(+), 1078 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 022d4e8da2b7..000c0ab47d53 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1572,6 +1572,7 @@ #if ENABLED(BABYSTEPPING) //#define INTEGRATED_BABYSTEPPING // EXPERIMENTAL integration of babystepping into the Stepper ISR //#define BABYSTEP_WITHOUT_HOMING + //#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). //#define BABYSTEP_XY // Also enable X/Y Babystepping. Not supported on DELTA! #define BABYSTEP_INVERT_Z false // Change if Z babysteps should go the other way //#define BABYSTEP_MILLIMETER_UNITS // Specify BABYSTEP_MULTIPLICATOR_(XY|Z) in mm instead of micro-steps @@ -1582,7 +1583,6 @@ #if ENABLED(DOUBLECLICK_FOR_Z_BABYSTEPPING) #define DOUBLECLICK_MAX_INTERVAL 1250 // Maximum interval between clicks, in milliseconds. // Note: Extra time may be added to mitigate controller latency. - //#define BABYSTEP_ALWAYS_AVAILABLE // Allow babystepping at all times (not just during movement). //#define MOVE_Z_WHEN_IDLE // Jump to the move Z menu on doubleclick when printer is idle. #if ENABLED(MOVE_Z_WHEN_IDLE) #define MOVE_Z_IDLE_MULTIPLICATOR 1 // Multiply 1mm by this factor for the move step size. diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 9742967a09d9..ff13d2897df2 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -59,7 +59,7 @@ #if TEMP_SENSOR_BED == 0 #undef THERMAL_PROTECTION_BED #undef THERMAL_PROTECTION_BED_PERIOD -#endif +#endif #if TEMP_SENSOR_CHAMBER == 0 #undef THERMAL_PROTECTION_CHAMBER diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index c94292980506..d45511f5bc84 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -28,15 +28,19 @@ #if ENABLED(DWIN_CREALITY_LCD) +#include "dwin.h" + #if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY) #define HAS_ONESTEP_LEVELING 1 #endif -#if HAS_HOTEND || HAS_HEATED_BED || HAS_FAN - #define HAS_COOLDOWN 1 +#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) + #define HAS_ZOFFSET_ITEM 1 #endif -#include "dwin.h" +#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) + #define JUST_BABYSTEP 1 +#endif #include #include @@ -52,8 +56,6 @@ #include "../../../core/macros.h" #include "../../../gcode/queue.h" -#include "../../../feature/babystep.h" - #include "../../../module/temperature.h" #include "../../../module/printcounter.h" #include "../../../module/motion.h" @@ -75,6 +77,10 @@ #include "../../../module/probe.h" #endif +#if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) + #include "../../../feature/babystep.h" +#endif + #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../feature/powerloss.h" #endif @@ -89,7 +95,7 @@ #define CORP_WEBSITE_E "www.creality.com" #endif -#define PAUSE_HEAT true +#define PAUSE_HEAT #define USE_STRING_HEADINGS @@ -98,6 +104,7 @@ #define HEADER_FONT font10x20 #define MENU_CHAR_LIMIT 24 +#define STATUS_Y 360 // Fan speed limit #define FANON 255 @@ -146,11 +153,9 @@ constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, // Total rows, and other HMI_value_t HMI_ValueStruct; HMI_Flag HMI_flag{0}; -millis_t Encoder_ms = 0; -millis_t Wait_ms = 0; millis_t dwin_heat_time = 0; -int checkkey = 0, last_checkkey = 0; +uint8_t checkkey = 0; typedef struct { uint8_t now, last; @@ -158,7 +163,7 @@ typedef struct { void reset() { set(0); } bool changed() { bool c = (now != last); if (c) last = now; return c; } bool dec() { if (now) now--; return changed(); } - bool inc(uint8_t v) { if (now < v) now++; else now = v; return changed(); } + bool inc(uint8_t v) { if (now < (v - 1)) now++; else now = (v - 1); return changed(); } } select_t; select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0} @@ -175,13 +180,9 @@ uint8_t index_file = MROWS, index_prepare = MROWS, index_control = MROWS, index_leveling = MROWS, - index_tune = 5; - -// char filebuf[50]; - -uint8_t countbuf = 0; + index_tune = MROWS; -bool recovery_flag = false, abort_flag = false; +bool dwin_abort_flag = false; constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; @@ -189,38 +190,41 @@ constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, constexpr float default_axis_steps_per_unit[] = DEFAULT_AXIS_STEPS_PER_UNIT; uint8_t Percentrecord = 0; -uint16_t last_Printtime = 0, remain_time = 0; -float last_temp_hotend_target = 0, last_temp_bed_target = 0; -float last_temp_hotend_current = 0, last_temp_bed_current = 0; -uint8_t last_fan_speed = 0; -uint16_t last_speed = 0; -float last_E_scale = 0; -bool DWIN_lcd_sd_status = 0; -bool pause_action_flag = 0; -int temphot = 0, tempbed = 0; -float dwin_zoffset = 0; -float last_zoffset = 0; +uint16_t remain_time = 0; + +#if ENABLED(PAUSE_HEAT) + #if HAS_HOTEND + uint16_t temphot = 0; + #endif + #if HAS_HEATED_BED + uint16_t tempbed = 0; + #endif +#endif + +#if HAS_ZOFFSET_ITEM + float dwin_zoffset = 0, last_zoffset = 0; +#endif #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 -void HMI_SetLanguage(void) { - BL24CXX::read(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); - if (HMI_flag.language_chinese) - DWIN_JPG_CacheTo1(Language_Chinese); - else - DWIN_JPG_CacheTo1(Language_English); +void HMI_SetLanguageCache() { + DWIN_JPG_CacheTo1(HMI_flag.language_chinese ? Language_Chinese : Language_English); } -void HMI_SetAndSaveLanguageWestern(void) { - HMI_flag.language_chinese = false; - DWIN_JPG_CacheTo1(Language_English); - BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); +void HMI_SetLanguage() { + #if ENABLED(EEPROM_SETTINGS) + BL24CXX::read(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); + #endif + HMI_SetLanguageCache(); } -void HMI_SetAndSaveLanguageChinese(void) { - HMI_flag.language_chinese = true; - DWIN_JPG_CacheTo1(Language_Chinese); - BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); + +void HMI_ToggleLanguage() { + HMI_flag.language_chinese ^= true; + HMI_SetLanguageCache(); + #if ENABLED(EEPROM_SETTINGS) + BL24CXX::write(DWIN_LANGUAGE_EEPROM_ADDRESS, (uint8_t*)&HMI_flag.language_chinese, sizeof(HMI_flag.language_chinese)); + #endif } 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) { @@ -331,14 +335,14 @@ void ICON_Tune() { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 121, 447, 148, 458, 34, 325); else - DWIN_Frame_AreaCopy(1, 1, 465, 34, 477, 31, 325); + DWIN_Frame_AreaCopy(1, 0, 466, 34, 476, 31, 325); } else { DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252); if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 121, 405, 148, 420, 34, 325); else - DWIN_Frame_AreaCopy(1, 1, 438, 32, 448, 31, 325); + DWIN_Frame_AreaCopy(1, 0, 438, 32, 448, 31, 325); } } @@ -367,7 +371,7 @@ void ICON_Continue() { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 1, 447, 28, 460, 124, 325); else - DWIN_Frame_AreaCopy(1, 1, 451, 32, 463, 121, 325); + DWIN_Frame_AreaCopy(1, 1, 452, 32, 464, 121, 325); } else { DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252); @@ -385,7 +389,7 @@ void ICON_Stop() { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 151, 447, 178, 459, 210, 325); else - DWIN_Frame_AreaCopy(1, 218, 451, 249, 465, 209, 325); + DWIN_Frame_AreaCopy(1, 218, 452, 249, 466, 209, 325); } else { DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252); @@ -396,8 +400,8 @@ void ICON_Stop() { } } -inline void Clear_Title_Bar(void) { - DWIN_Draw_Rectangle(1, Background_blue, 0, 0, DWIN_WIDTH, 30); +inline void Clear_Title_Bar() { + DWIN_Draw_Rectangle(1, Background_blue, 0, 0, DWIN_WIDTH, 30); } inline void Draw_Title(const char * const title) { @@ -408,21 +412,21 @@ inline void Draw_Title(const __FlashStringHelper * title) { DWIN_Draw_String(false, false, HEADER_FONT, White, Background_blue, 14, 4, (char*)title); } -inline void Clear_Menu_Area(void) { - DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, 360); +inline void Clear_Menu_Area() { + DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, STATUS_Y); } -inline void Clear_Main_Window(void) { +inline void Clear_Main_Window() { Clear_Title_Bar(); Clear_Menu_Area(); } -inline void Clear_Popup_Area(void) { +inline void Clear_Popup_Area() { Clear_Title_Bar(); DWIN_Draw_Rectangle(1, Background_black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); } -void Draw_Popup_Bkgd_105(void) { +void Draw_Popup_Bkgd_105() { DWIN_Draw_Rectangle(1, Background_window, 14, 105, 258, 374); } @@ -476,7 +480,7 @@ inline void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char } // The "Back" label is always on the first line -inline void Draw_Back_Label(void) { +inline void Draw_Back_Label() { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); else @@ -494,13 +498,61 @@ inline void Draw_Back_First(const bool is_sel=true) { // Draw Menus // +#define MOTION_CASE_RATE 1 +#define MOTION_CASE_ACCEL 2 +#define MOTION_CASE_JERK (MOTION_CASE_ACCEL + ENABLED(HAS_CLASSIC_JERK)) +#define MOTION_CASE_STEPS (MOTION_CASE_JERK + 1) +#define MOTION_CASE_TOTAL MOTION_CASE_STEPS + +#define PREPARE_CASE_MOVE 1 +#define PREPARE_CASE_DISA 2 +#define PREPARE_CASE_HOME 3 +#define PREPARE_CASE_ZOFF (PREPARE_CASE_HOME + ENABLED(HAS_ZOFFSET_ITEM)) +#define PREPARE_CASE_PLA (PREPARE_CASE_ZOFF + ENABLED(HAS_HOTEND)) +#define PREPARE_CASE_ABS (PREPARE_CASE_PLA + ENABLED(HAS_HOTEND)) +#define PREPARE_CASE_COOL (PREPARE_CASE_ABS + EITHER(HAS_HOTEND, HAS_HEATED_BED)) +#define PREPARE_CASE_LANG (PREPARE_CASE_COOL + 1) +#define PREPARE_CASE_TOTAL PREPARE_CASE_LANG + +#define CONTROL_CASE_TEMP 1 +#define CONTROL_CASE_MOVE (CONTROL_CASE_TEMP + 1) +#define CONTROL_CASE_SAVE (CONTROL_CASE_MOVE + ENABLED(EEPROM_SETTINGS)) +#define CONTROL_CASE_LOAD (CONTROL_CASE_SAVE + ENABLED(EEPROM_SETTINGS)) +#define CONTROL_CASE_RESET (CONTROL_CASE_LOAD + ENABLED(EEPROM_SETTINGS)) +#define CONTROL_CASE_INFO (CONTROL_CASE_RESET + 1) +#define CONTROL_CASE_TOTAL CONTROL_CASE_INFO + +#define TUNE_CASE_SPEED 1 +#define TUNE_CASE_TEMP (TUNE_CASE_SPEED + ENABLED(HAS_HOTEND)) +#define TUNE_CASE_BED (TUNE_CASE_TEMP + ENABLED(HAS_HEATED_BED)) +#define TUNE_CASE_FAN (TUNE_CASE_BED + ENABLED(HAS_FAN)) +#define TUNE_CASE_ZOFF (TUNE_CASE_FAN + ENABLED(HAS_ZOFFSET_ITEM)) +#define TUNE_CASE_TOTAL TUNE_CASE_ZOFF + +#define TEMP_CASE_TEMP (0 + ENABLED(HAS_HOTEND)) +#define TEMP_CASE_BED (TEMP_CASE_TEMP + ENABLED(HAS_HEATED_BED)) +#define TEMP_CASE_FAN (TEMP_CASE_BED + ENABLED(HAS_FAN)) +#define TEMP_CASE_PLA (TEMP_CASE_FAN + ENABLED(HAS_HOTEND)) +#define TEMP_CASE_ABS (TEMP_CASE_PLA + ENABLED(HAS_HOTEND)) +#define TEMP_CASE_TOTAL TEMP_CASE_ABS + +#define PREHEAT_CASE_TEMP (0 + ENABLED(HAS_HOTEND)) +#define PREHEAT_CASE_BED (PREHEAT_CASE_TEMP + ENABLED(HAS_HEATED_BED)) +#define PREHEAT_CASE_FAN (PREHEAT_CASE_BED + ENABLED(HAS_FAN)) +#define PREHEAT_CASE_SAVE (PREHEAT_CASE_FAN + ENABLED(EEPROM_SETTINGS)) +#define PREHEAT_CASE_TOTAL PREHEAT_CASE_SAVE + +// +// Draw Menus +// + inline void draw_move_en(const uint16_t line) { DWIN_Frame_AreaCopy(1, 69, 61, 102, 71, LBLX, line); // "Move" } inline void DWIN_Frame_TitleCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { DWIN_Frame_AreaCopy(id, x1, y1, x2, y2, 14, 8); } -inline void Prepare_Item_Move(const uint8_t row) { +inline void Item_Prepare_Move(const uint8_t row) { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 159, 70, 200, 84, LBLX, MBASE(row)); else @@ -509,7 +561,7 @@ inline void Prepare_Item_Move(const uint8_t row) { Draw_More_Icon(row); } -inline void Prepare_Item_Disable(const uint8_t row) { +inline void Item_Prepare_Disable(const uint8_t row) { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 204, 70, 259, 82, LBLX, MBASE(row)); else @@ -517,7 +569,7 @@ inline void Prepare_Item_Disable(const uint8_t row) { Draw_Menu_Line(row, ICON_CloseMotor); } -inline void Prepare_Item_Home(const uint8_t row) { +inline void Item_Prepare_Home(const uint8_t row) { if (HMI_flag.language_chinese) DWIN_Frame_AreaCopy(1, 0, 89, 41, 101, LBLX, MBASE(row)); else @@ -525,57 +577,65 @@ inline void Prepare_Item_Home(const uint8_t row) { Draw_Menu_Line(row, ICON_Homing); } -inline void Prepare_Item_Offset(const uint8_t row) { - if (HMI_flag.language_chinese) { - #if HAS_BED_PROBE - DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(row)); - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); - #else - DWIN_Frame_AreaCopy(1, 43, 89, 98, 101, LBLX, MBASE(row)); - #endif - } - else { - #if HAS_BED_PROBE - DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset" - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); - #else - DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "..." - #endif - } - Draw_Menu_Line(row, ICON_SetHome); -} +#if HAS_ZOFFSET_ITEM -inline void Prepare_Item_PLA(const uint8_t row) { - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 100, 89, 151, 101, LBLX, MBASE(row)); - } - else { - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(row)); // "PLA" + inline void Item_Prepare_Offset(const uint8_t row) { + if (HMI_flag.language_chinese) { + #if HAS_BED_PROBE + DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(row)); + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); + #else + DWIN_Frame_AreaCopy(1, 43, 89, 98, 101, LBLX, MBASE(row)); + #endif + } + else { + #if HAS_BED_PROBE + DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(row)); // "Z-Offset" + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(row), BABY_Z_VAR * 100); + #else + DWIN_Frame_AreaCopy(1, 1, 76, 106, 86, LBLX, MBASE(row)); // "..." + #endif + } + Draw_Menu_Line(row, ICON_SetHome); } - Draw_Menu_Line(row, ICON_PLAPreheat); -} -inline void Prepare_Item_ABS(const uint8_t row) { - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 180, 89, 233, 100, LBLX, MBASE(row)); +#endif + +#if HAS_HOTEND + inline void Item_Prepare_PLA(const uint8_t row) { + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 100, 89, 151, 101, LBLX, MBASE(row)); + } + else { + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(row)); // "PLA" + } + Draw_Menu_Line(row, ICON_PLAPreheat); } - else { - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(row)); // "ABS" + + inline void Item_Prepare_ABS(const uint8_t row) { + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 180, 89, 233, 100, LBLX, MBASE(row)); + } + else { + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(row)); // "Preheat" + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(row)); // "ABS" + } + Draw_Menu_Line(row, ICON_ABSPreheat); } - Draw_Menu_Line(row, ICON_ABSPreheat); -} +#endif -inline void Prepare_Item_Cool(const uint8_t row) { - if (HMI_flag.language_chinese) - DWIN_Frame_AreaCopy(1, 1, 104, 56, 117, LBLX, MBASE(row)); - else - DWIN_Frame_AreaCopy(1, 200, 76, 264, 86, LBLX, MBASE(row)); // "Cooldown" - Draw_Menu_Line(row, ICON_Cool); -} +#if HAS_PREHEAT + inline void Item_Prepare_Cool(const uint8_t row) { + if (HMI_flag.language_chinese) + DWIN_Frame_AreaCopy(1, 1, 104, 56, 117, LBLX, MBASE(row)); + else + DWIN_Frame_AreaCopy(1, 200, 76, 264, 86, LBLX, MBASE(row)); // "Cooldown" + Draw_Menu_Line(row, ICON_Cool); + } +#endif -inline void Prepare_Item_Lang(const uint8_t row) { +inline void Item_Prepare_Lang(const uint8_t row) { if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 239, 134, 266, 146, LBLX, MBASE(row)); DWIN_Draw_String(false, false, font8x16, White, Background_black, 226, MBASE(row), F("CN")); @@ -605,15 +665,21 @@ inline void Draw_Prepare_Menu() { #endif } - if (PVISI(0)) Draw_Back_First(select_prepare.now == 0); // < Back - if (PVISI(1)) Prepare_Item_Move(PSCROL(1)); // Move > - if (PVISI(2)) Prepare_Item_Disable(PSCROL(2)); // Disable Stepper - if (PVISI(3)) Prepare_Item_Home(PSCROL(3)); // Auto Home - if (PVISI(4)) Prepare_Item_Offset(PSCROL(4)); // Z-Offset - if (PVISI(5)) Prepare_Item_PLA(PSCROL(5)); // Preheat PLA - if (PVISI(6)) Prepare_Item_ABS(PSCROL(6)); // Preheat ABS - if (PVISI(7)) Prepare_Item_Cool(PSCROL(7)); // Cooldown - if (PVISI(8)) Prepare_Item_Lang(PSCROL(8)); // Language CN/EN + if (PVISI(0)) Draw_Back_First(select_prepare.now == 0); // < Back + if (PVISI(PREPARE_CASE_MOVE)) Item_Prepare_Move(PSCROL(PREPARE_CASE_MOVE)); // Move > + if (PVISI(PREPARE_CASE_DISA)) Item_Prepare_Disable(PSCROL(PREPARE_CASE_DISA)); // Disable Stepper + if (PVISI(PREPARE_CASE_HOME)) Item_Prepare_Home(PSCROL(PREPARE_CASE_HOME)); // Auto Home + #if HAS_ZOFFSET_ITEM + if (PVISI(PREPARE_CASE_ZOFF)) Item_Prepare_Offset(PSCROL(PREPARE_CASE_ZOFF)); // Edit Z-Offset / Babystep / Set Home Offset + #endif + #if HAS_HOTEND + if (PVISI(PREPARE_CASE_PLA)) Item_Prepare_PLA(PSCROL(PREPARE_CASE_PLA)); // Preheat PLA + if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS)); // Preheat ABS + #endif + #if HAS_PREHEAT + if (PVISI(PREPARE_CASE_COOL)) Item_Prepare_Cool(PSCROL(PREPARE_CASE_COOL)); // Cooldown + #endif + if (PVISI(PREPARE_CASE_LANG)) Item_Prepare_Lang(PSCROL(PREPARE_CASE_LANG)); // Language CN/EN if (select_prepare.now) Draw_Menu_Cursor(PSCROL(select_prepare.now)); } @@ -621,52 +687,55 @@ inline void Draw_Prepare_Menu() { inline void Draw_Control_Menu() { Clear_Main_Window(); - const int16_t scroll = TERN(HAS_ONESTEP_LEVELING, MROWS - index_control, 0); // Scrolled-up lines - - #define CSCROL(L) (scroll + (L)) + #if CONTROL_CASE_TOTAL >= 6 + const int16_t scroll = MROWS - index_control; // Scrolled-up lines + #define CSCROL(L) (scroll + (L)) + #else + #define CSCROL(L) (L) + #endif #define CLINE(L) MBASE(CSCROL(L)) #define CVISI(L) WITHIN(CSCROL(L), 0, MROWS) if (CVISI(0)) Draw_Back_First(select_control.now == 0); // < Back if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 103, 1, 130, 14, 14, 8); - DWIN_Frame_AreaCopy(1, 57, 104, 84, 116, LBLX, CLINE(1)); // Temperature > - DWIN_Frame_AreaCopy(1, 87, 104, 114, 116, LBLX, CLINE(2)); // Motion > - DWIN_Frame_AreaCopy(1, 117, 104, 172, 116, LBLX, CLINE(3)); // Store Config - DWIN_Frame_AreaCopy(1, 174, 103, 229, 116, LBLX, CLINE(4)); // Read Config - DWIN_Frame_AreaCopy(1, 1, 118, 56, 131, LBLX, CLINE(5)); // Reset Config + DWIN_Frame_TitleCopy(1, 103, 1, 130, 14); // "Control" + + DWIN_Frame_AreaCopy(1, 57, 104, 84, 116, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature > + DWIN_Frame_AreaCopy(1, 87, 104, 114, 116, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion > + + #if ENABLED(EEPROM_SETTINGS) + DWIN_Frame_AreaCopy(1, 117, 104, 172, 116, LBLX, CLINE(CONTROL_CASE_SAVE)); // Store Configuration + DWIN_Frame_AreaCopy(1, 174, 103, 229, 116, LBLX, CLINE(CONTROL_CASE_LOAD)); // Read Configuration + DWIN_Frame_AreaCopy(1, 1, 118, 56, 131, LBLX, CLINE(CONTROL_CASE_RESET)); // Reset Configuration + #endif - if (CVISI(6)) - DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, CLINE(6)); // Info > + if (CVISI(CONTROL_CASE_INFO)) + DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, CLINE(CONTROL_CASE_TEMP)); // Info > } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_CONTROL)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), GET_TEXT_F(MSG_TEMPERATURE)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), GET_TEXT_F(MSG_MOTION)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_TEMP), GET_TEXT_F(MSG_TEMPERATURE)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_MOVE), GET_TEXT_F(MSG_MOTION)); #if ENABLED(EEPROM_SETTINGS) - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_STORE_EEPROM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_LOAD_EEPROM)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(5), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); - if (CVISI(6)) DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(6), F("Info")); - #else - if (CVISI(3)) DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), F("Info")); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_LOAD), GET_TEXT_F(MSG_LOAD_EEPROM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_RESET), GET_TEXT_F(MSG_RESTORE_DEFAULTS)); #endif + if (CVISI(CONTROL_CASE_INFO)) DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(CONTROL_CASE_INFO), F("Info")); #else - DWIN_Frame_AreaCopy(1, 128, 2, 176, 12, 14, 8); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(1)); // Temperature > - DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(2)); // Motion > + DWIN_Frame_TitleCopy(1, 128, 2, 176, 12); // "Control" + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX, CLINE(CONTROL_CASE_TEMP)); // Temperature > + DWIN_Frame_AreaCopy(1, 84, 89, 128, 99, LBLX, CLINE(CONTROL_CASE_MOVE)); // Motion > #if ENABLED(EEPROM_SETTINGS) - DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX, CLINE(3)); // "Store Configuration" - DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX, CLINE(4)); // "Read" - DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(4)); // "Configuration" - DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX, CLINE(5)); // "Reset" - DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, 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 > + DWIN_Frame_AreaCopy(1, 148, 89, 268, 101, LBLX , CLINE(CONTROL_CASE_SAVE // "Store Configuration" + DWIN_Frame_AreaCopy(1, 26, 104, 57, 114, LBLX , CLINE(CONTROL_CASE_LOAD)); // "Read" + DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 34, CLINE(CONTROL_CASE_LOAD)); // "Configuration" + DWIN_Frame_AreaCopy(1, 59, 104, 93, 114, LBLX , CLINE(CONTROL_CASE_RESET)); // "Reset" + DWIN_Frame_AreaCopy(1, 182, 89, 268, 101, LBLX + 37, CLINE(CONTROL_CASE_RESET)); // "Configuration" #endif + if (CVISI(CONTROL_CASE_INFO)) DWIN_Frame_AreaCopy(1, 0, 104, 25, 115, LBLX, CLINE(CONTROL_CASE_INFO)); // Info > #endif } @@ -674,12 +743,23 @@ inline void Draw_Control_Menu() { Draw_Menu_Cursor(CSCROL(select_control.now)); // Draw icons and lines - LOOP_L_N(i, 6) - if (CVISI(i + 1)) Draw_Menu_Line(CSCROL(i + 1), ICON_Temperature + i); + uint8_t i = 0; + #define _TEMP_ICON(N) do{ ++i; if (CVISI(i)) Draw_Menu_Line(CSCROL(i), ICON_SetEndTemp + (N) - 1); }while(0) + + _TEMP_ICON(CONTROL_CASE_TEMP); + if (CVISI(i)) Draw_More_Icon(CSCROL(i)); + + _TEMP_ICON(CONTROL_CASE_MOVE); + Draw_More_Icon(CSCROL(i)); - Draw_More_Icon(CSCROL(1)); - Draw_More_Icon(CSCROL(2)); - if (CVISI(6)) Draw_More_Icon(CSCROL(6)); + #if ENABLED(EEPROM_SETTINGS) + _TEMP_ICON(CONTROL_CASE_SAVE); + _TEMP_ICON(CONTROL_CASE_LOAD); + _TEMP_ICON(CONTROL_CASE_RESET); + #endif + + _TEMP_ICON(CONTROL_CASE_INFO); + if (CVISI(CONTROL_CASE_INFO)) Draw_More_Icon(CSCROL(i)); } inline void Draw_Tune_Menu() { @@ -687,46 +767,76 @@ inline void Draw_Tune_Menu() { if (HMI_flag.language_chinese) { DWIN_Frame_AreaCopy(1, 73, 2, 100, 13, 14, 9); - DWIN_Frame_AreaCopy(1, 116, 164, 171, 176, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(2)); - DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(5)); + DWIN_Frame_AreaCopy(1, 116, 164, 171, 176, LBLX, MBASE(TUNE_CASE_SPEED)); + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(TUNE_CASE_TEMP)); + #endif + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(TUNE_CASE_BED)); + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(TUNE_CASE_FAN)); + #endif + #if HAS_ZOFFSET_ITEM + DWIN_Frame_AreaCopy(1, 174, 164, 223, 177, LBLX, MBASE(TUNE_CASE_ZOFF)); + #endif } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TUNE)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), GET_TEXT_F(MSG_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_FAN_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(5), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_SPEED), GET_TEXT_F(MSG_SPEED)); + #if HAS_HOTEND + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + #endif + #if HAS_HEATED_BED + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + #endif + #if HAS_FAN + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + #endif + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TUNE_CASE_ZOFF), GET_TEXT_F(MSG_ZPROBE_ZOFFSET)); #else DWIN_Frame_AreaCopy(1, 94, 2, 126, 12, 14, 9); - DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(1)); // print speed - DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(2)); // Hotend... - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(2)); // ...Temperature - DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(3)); // Bed... - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(3)); // ...Temperature - DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(4)); // fan speed - DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(5)); // Z-offset + DWIN_Frame_AreaCopy(1, 1, 179, 92, 190, LBLX, MBASE(TUNE_CASE_SPEED)); // Print speed + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TUNE_CASE_TEMP)); // Hotend... + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(TUNE_CASE_TEMP)); // ...Temperature + #endif + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(TUNE_CASE_BED)); // Bed... + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(TUNE_CASE_BED)); // ...Temperature + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(TUNE_CASE_FAN)); // Fan speed + #endif + #if HAS_ZOFFSET_ITEM + DWIN_Frame_AreaCopy(1, 93, 179, 141, 189, LBLX, MBASE(TUNE_CASE_ZOFF)); // Z-offset + #endif #endif } Draw_Back_First(select_tune.now == 0); if (select_tune.now) Draw_Menu_Cursor(select_tune.now); - Draw_Menu_Line(1, ICON_Speed); - Draw_Menu_Line(2, ICON_HotendTemp); - Draw_Menu_Line(3, ICON_BedTemp); - Draw_Menu_Line(4, ICON_FanSpeed); - Draw_Menu_Line(5, ICON_Zoffset); + Draw_Menu_Line(TUNE_CASE_SPEED, ICON_Speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_SPEED), feedrate_percentage); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), feedrate_percentage); - 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]); - DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(5), BABY_Z_VAR * 100); + #if HAS_HOTEND + Draw_Menu_Line(TUNE_CASE_TEMP, ICON_HotendTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.temp_hotend[0].target); + #endif + #if HAS_HEATED_BED + Draw_Menu_Line(TUNE_CASE_BED, ICON_BedTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.temp_bed.target); + #endif + #if HAS_FAN + Draw_Menu_Line(TUNE_CASE_FAN, ICON_FanSpeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_FAN), thermalManager.fan_speed[0]); + #endif + #if HAS_ZOFFSET_ITEM + Draw_Menu_Line(TUNE_CASE_ZOFF, ICON_Zoffset); + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(TUNE_CASE_ZOFF), BABY_Z_VAR * 100); + #endif } inline void draw_max_en(const uint16_t line) { @@ -762,74 +872,84 @@ inline void Draw_Motion_Menu() { Clear_Main_Window(); if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 1, 16, 28, 28, 14, 8); - - DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, MBASE(1)); // Max speed - DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(2)); // Max... - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(2) + 1); // ...acceleration - DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(3)); // Max... - DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(3) + 1); // ... - DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(3)); // ...jerk - DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(4)); // Flow ratio + DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Motion" + DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, MBASE(MOTION_CASE_RATE)); // Max speed + DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(MOTION_CASE_ACCEL)); // Max... + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(MOTION_CASE_ACCEL) + 1); // ...Acceleration + #if HAS_CLASSIC_JERK + DWIN_Frame_AreaCopy(1, 173, 133, 200, 147, LBLX, MBASE(MOTION_CASE_JERK)); // Max... + DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(MOTION_CASE_JERK) + 1); // ... + DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(MOTION_CASE_JERK)); // ...Jerk + #endif + DWIN_Frame_AreaCopy(1, 153, 148, 194, 161, LBLX, MBASE(MOTION_CASE_STEPS)); // Flow ratio } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_MOTION)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Feedrate")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), GET_TEXT_F(MSG_ACCELERATION)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_JERK)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_STEPS_PER_MM)); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_RATE), F("Feedrate")); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_ACCEL), GET_TEXT_F(MSG_ACCELERATION)); + #if HAS_CLASSIC_JERK + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_JERK), GET_TEXT_F(MSG_JERK)); + #endif + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(MOTION_CASE_STEPS), GET_TEXT_F(MSG_STEPS_PER_MM)); #else - DWIN_Frame_AreaCopy(1, 144, 16, 189, 26, 14, 8); - draw_max_en(MBASE(1)); draw_speed_en(27, MBASE(1)); // "Max Speed" - draw_max_accel_en(MBASE(2)); // "Max Acceleration" - draw_max_en(MBASE(3)); draw_jerk_en(MBASE(3)); // "Max Jerk" - draw_steps_per_mm(MBASE(4)); // "Steps-per-mm" + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Motion" + draw_max_en(MBASE(MOTION_CASE_RATE)); draw_speed_en(27, MBASE(MOTION_CASE_RATE)); // "Max Speed" + draw_max_accel_en(MBASE(MOTION_CASE_ACCEL)); // "Max Acceleration" + #if HAS_CLASSIC_JERK + draw_max_en(MBASE(MOTION_CASE_JERK)); draw_jerk_en(MBASE(MOTION_CASE_JERK)); // "Max Jerk" + #endif + draw_steps_per_mm(MBASE(MOTION_CASE_STEPS)); // "Steps-per-mm" #endif } Draw_Back_First(select_motion.now == 0); if (select_motion.now) Draw_Menu_Cursor(select_motion.now); - LOOP_L_N(i, 4) Draw_Menu_Line(i + 1, ICON_MaxSpeed + i); - - Draw_More_Icon(1); - Draw_More_Icon(2); - Draw_More_Icon(3); - Draw_More_Icon(4); + uint8_t i = 0; + #define _MOTION_ICON(N) Draw_Menu_Line(++i, ICON_MaxSpeed + (N) - 1) + _MOTION_ICON(MOTION_CASE_RATE); Draw_More_Icon(i); + _MOTION_ICON(MOTION_CASE_ACCEL); Draw_More_Icon(i); + #if HAS_CLASSIC_JERK + _MOTION_ICON(MOTION_CASE_JERK); Draw_More_Icon(i); + #endif + _MOTION_ICON(MOTION_CASE_STEPS); Draw_More_Icon(i); } // // Draw Popup Windows // - -void Popup_Window_Temperature(const bool toohigh) { - Clear_Popup_Area(); - Draw_Popup_Bkgd_105(); - if (toohigh) { - DWIN_ICON_Show(ICON, ICON_TempTooHigh, 102, 165); - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285); - DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); - DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); - } - else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too high")); - } - } - else { - DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 165); - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 103, 371, 270, 386, 52, 285); - DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); +#if HAS_HOTEND || HAS_HEATED_BED + + void DWIN_Popup_Temperature(const bool toohigh) { + Clear_Popup_Area(); + Draw_Popup_Bkgd_105(); + if (toohigh) { + DWIN_ICON_Show(ICON, ICON_TempTooHigh, 102, 165); + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285); + DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); + DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); + } + else { + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too high")); + } } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too low")); + DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 165); + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 103, 371, 270, 386, 52, 285); + DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); + } + else { + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 36, 300, F("Nozzle or Bed temperature")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 300, F("is too low")); + } } } -} + +#endif inline void Draw_Popup_Bkgd_60() { DWIN_Draw_Rectangle(1, Background_window, 14, 60, 258, 330); @@ -837,7 +957,7 @@ inline void Draw_Popup_Bkgd_60() { #if HAS_HOTEND - void Popup_Window_ETempTooLow(void) { + void Popup_Window_ETempTooLow() { Clear_Main_Window(); Draw_Popup_Bkgd_60(); DWIN_ICON_Show(ICON, ICON_TempTooLow, 102, 105); @@ -854,7 +974,7 @@ inline void Draw_Popup_Bkgd_60() { #endif -void Popup_Window_Resume(void) { +void Popup_Window_Resume() { Clear_Popup_Area(); Draw_Popup_Bkgd_105(); if (HMI_flag.language_chinese) { @@ -864,15 +984,15 @@ void Popup_Window_Resume(void) { DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 307); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 120, 115, F("Tips")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 192, F("I see the file stopped")); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 68, 212, F("unexpectedly last time")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 14) / 2, 115, F("Continue Print")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 22) / 2, 192, F("It looks like the last")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 22) / 2, 212, F("file was interrupted.")); DWIN_ICON_Show(ICON, ICON_Continue_E, 26, 307); DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 307); } } -void Popup_Window_Home(void) { +void Popup_Window_Home(const bool parking/*=false*/) { Clear_Main_Window(); Draw_Popup_Bkgd_60(); DWIN_ICON_Show(ICON, ICON_BLTouch, 101, 105); @@ -882,24 +1002,28 @@ void Popup_Window_Home(void) { DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); } else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 80, 230, GET_TEXT_F(MSG_LEVEL_BED_HOMING)); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 260, F("Please wait until completed")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * (parking ? 7 : 10)) / 2, 230, parking ? F("Parking") : F("Homing XYZ")); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); } } -void Popup_Window_Leveling(void) { - Clear_Main_Window(); - Draw_Popup_Bkgd_60(); - DWIN_ICON_Show(ICON, ICON_AutoLeveling, 101, 105); - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 0, 371, 100, 386, 84, 240); - DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); - } - else { - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 76, 230, GET_TEXT_F(MSG_BED_LEVELING)); - DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 24, 260, F("Please wait until completed")); +#if HAS_ONESTEP_LEVELING + + void Popup_Window_Leveling() { + Clear_Main_Window(); + Draw_Popup_Bkgd_60(); + DWIN_ICON_Show(ICON, ICON_AutoLeveling, 101, 105); + if (HMI_flag.language_chinese) { + DWIN_Frame_AreaCopy(1, 0, 371, 100, 386, 84, 240); + DWIN_Frame_AreaCopy(1, 0, 389, 150, 402, 61, 280); + } + else { + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 13) / 2, 230, GET_TEXT_F(MSG_BED_LEVELING)); + DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 23) / 2, 260, F("Please wait until done.")); + } } -} + +#endif void Draw_Select_Highlight(const bool sel) { HMI_flag.select_flag = sel; @@ -911,34 +1035,34 @@ void Draw_Select_Highlight(const bool sel) { DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319); } -void Popup_window_PauseOrStop(void) { +void Popup_window_PauseOrStop() { Clear_Main_Window(); Draw_Popup_Bkgd_60(); if (HMI_flag.language_chinese) { - if (select_print.now == 1) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); + if (select_print.now == 1) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); else if (select_print.now == 2) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); DWIN_ICON_Show(ICON, ICON_Confirm_C, 26, 280); DWIN_ICON_Show(ICON, ICON_Cancel_C, 146, 280); } else { - if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 88, 150, GET_TEXT_F(MSG_PAUSE_PRINT)); - else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, 92, 150, GET_TEXT_F(MSG_STOP_PRINT)); + if (select_print.now == 1) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 11) / 2, 150, GET_TEXT_F(MSG_PAUSE_PRINT)); + else if (select_print.now == 2) DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (272 - 8 * 10) / 2, 150, GET_TEXT_F(MSG_STOP_PRINT)); DWIN_ICON_Show(ICON, ICON_Confirm_E, 26, 280); DWIN_ICON_Show(ICON, ICON_Cancel_E, 146, 280); } Draw_Select_Highlight(true); } -void Draw_Printing_Screen(void) { +void Draw_Printing_Screen() { if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 30, 1, 71, 14, 14, 9); // Tune - DWIN_Frame_AreaCopy(1, 0, 72, 63, 86, 41, 188); // Pause + DWIN_Frame_AreaCopy(1, 30, 1, 71, 14, 14, 9); // Tune + DWIN_Frame_AreaCopy(1, 0, 72, 63, 86, 41, 188); // Pause DWIN_Frame_AreaCopy(1, 65, 72, 128, 86, 176, 188); // Stop } else { - DWIN_Frame_AreaCopy(1, 40, 2, 92, 14, 14, 9); // Tune - DWIN_Frame_AreaCopy(1, 0, 44, 96, 58, 41, 188); // Pause + DWIN_Frame_AreaCopy(1, 40, 2, 92, 14, 14, 9); // Tune + DWIN_Frame_AreaCopy(1, 0, 44, 96, 58, 41, 188); // Pause DWIN_Frame_AreaCopy(1, 98, 44, 152, 58, 176, 188); // Stop } } @@ -963,7 +1087,7 @@ void Draw_Print_ProgressRemain() { DWIN_Draw_IntValue(true, true, 1, font8x16, White, Background_black, 2, 200, 212, (remain_time % 3600) / 60); } -void Goto_PrintProcess(void) { +void Goto_PrintProcess() { checkkey = PrintProcess; Clear_Main_Window(); @@ -986,7 +1110,7 @@ void Goto_PrintProcess(void) { Draw_Print_ProgressRemain(); } -void Goto_MainMenu(void) { +void Goto_MainMenu() { checkkey = MainMenu; Clear_Main_Window(); @@ -1011,6 +1135,7 @@ void Goto_MainMenu(void) { } inline ENCODER_DiffState get_encoder_state() { + static millis_t Encoder_ms = 0; const millis_t ms = millis(); if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; const ENCODER_DiffState state = Encoder_ReceiveAnalyze(); @@ -1018,7 +1143,7 @@ inline ENCODER_DiffState get_encoder_state() { return state; } -void HMI_Move_X(void) { +void HMI_Move_X() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1029,7 +1154,7 @@ void HMI_Move_X(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); if (!planner.is_full()) { // Wait for planner moves to finish! @@ -1047,7 +1172,7 @@ void HMI_Move_X(void) { } } -void HMI_Move_Y(void) { +void HMI_Move_Y() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1058,7 +1183,7 @@ void HMI_Move_Y(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); if (!planner.is_full()) { // Wait for planner moves to finish! @@ -1076,7 +1201,7 @@ void HMI_Move_Y(void) { } } -void HMI_Move_Z(void) { +void HMI_Move_Z() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1087,7 +1212,7 @@ void HMI_Move_Z(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); if (!planner.is_full()) { // Wait for planner moves to finish! @@ -1107,7 +1232,8 @@ void HMI_Move_Z(void) { #if HAS_HOTEND - void HMI_Move_E(void) { + void HMI_Move_E() { + static float last_E_scale = 0; ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1118,7 +1244,7 @@ void HMI_Move_Z(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { checkkey = AxisMove; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; last_E_scale = 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()) { @@ -1140,53 +1266,66 @@ void HMI_Move_Z(void) { #endif -void HMI_Zoffset(void) { - ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - last_zoffset = dwin_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; - dwin_zoffset = HMI_ValueStruct.offset_value / 100; - #if HAS_BED_PROBE - if (WITHIN(dwin_zoffset - last_zoffset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) - probe.offset.z = dwin_zoffset; - TERN_(EEPROM_SETTINGS, settings.save()); - #elif ENABLED(BABYSTEPPING) - babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset); - #endif +#if HAS_ZOFFSET_ITEM - 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)); + bool printer_busy() { return planner.movesplanned() || printingIsActive(); } + + void HMI_Zoffset() { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + uint8_t zoff_line; + switch (HMI_ValueStruct.show_mode) { + case -4: zoff_line = PREPARE_CASE_ZOFF + MROWS - index_prepare; break; + default: zoff_line = TUNE_CASE_ZOFF + MROWS - index_tune; } - 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)); + 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.enabled = false; + #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(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 100, HMI_ValueStruct.offset_value)); + } + else { + checkkey = Tune; + DWIN_Draw_Signed_Float(font8x16, Background_black, 2, 2, 202, MBASE(zoff_line), TERN(HAS_BED_PROBE, BABY_Z_VAR * 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.0f; + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) + if ( (ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_known()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy()) ) + babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset); + #endif + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(zoff_line), 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) - 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(); } -} + +#endif // HAS_ZOFFSET_ITEM #if HAS_HOTEND - void HMI_ETemp(void) { + void HMI_ETemp() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { + uint8_t temp_line; + switch (HMI_ValueStruct.show_mode) { + case -1: temp_line = TEMP_CASE_TEMP; break; + case -2: temp_line = PREHEAT_CASE_TEMP; break; + case -3: temp_line = PREHEAT_CASE_TEMP; break; + default: temp_line = TUNE_CASE_TEMP + MROWS - index_tune; + } if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.E_Temp += EncoderRate.encoderMoveValue; } @@ -1194,26 +1333,26 @@ void HMI_Zoffset(void) { HMI_ValueStruct.E_Temp -= EncoderRate.encoderMoveValue; } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { // temperature checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].hotend_temp = HMI_ValueStruct.E_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(temp_line), ui.material_preset[0].hotend_temp); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].hotend_temp = HMI_ValueStruct.E_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(temp_line), ui.material_preset[1].hotend_temp); return; } else { // tune checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2 + MROWS - index_tune), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } thermalManager.setTargetHotend(HMI_ValueStruct.E_Temp, 0); return; @@ -1222,10 +1361,7 @@ void HMI_Zoffset(void) { NOMORE(HMI_ValueStruct.E_Temp, MAX_E_TEMP); NOLESS(HMI_ValueStruct.E_Temp, MIN_E_TEMP); // E_Temp value - if (HMI_ValueStruct.show_mode >= 0) // tune - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2 + MROWS - index_tune), HMI_ValueStruct.E_Temp); - else // other page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp); } } @@ -1233,9 +1369,16 @@ void HMI_Zoffset(void) { #if HAS_HEATED_BED - void HMI_BedTemp(void) { + void HMI_BedTemp() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { + uint8_t bed_line; + switch (HMI_ValueStruct.show_mode) { + case -1: bed_line = TEMP_CASE_BED; break; + case -2: bed_line = PREHEAT_CASE_BED; break; + case -3: bed_line = PREHEAT_CASE_BED; break; + default: bed_line = TUNE_CASE_BED + MROWS - index_tune; + } if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Bed_Temp += EncoderRate.encoderMoveValue; } @@ -1243,26 +1386,26 @@ void HMI_Zoffset(void) { HMI_ValueStruct.Bed_Temp -= EncoderRate.encoderMoveValue; } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].bed_temp = HMI_ValueStruct.Bed_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(bed_line), ui.material_preset[0].bed_temp); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].bed_temp = HMI_ValueStruct.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(bed_line), ui.material_preset[1].bed_temp); return; } else { checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3 + MROWS - index_tune), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } thermalManager.setTargetBed(HMI_ValueStruct.Bed_Temp); return; @@ -1271,20 +1414,25 @@ void HMI_Zoffset(void) { NOMORE(HMI_ValueStruct.Bed_Temp, BED_MAX_TARGET); NOLESS(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP); // Bed_Temp value - if (HMI_ValueStruct.show_mode >= 0) // tune page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3 + MROWS - index_tune), HMI_ValueStruct.Bed_Temp); - else // other page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp); } } #endif // HAS_HEATED_BED -#if HAS_FAN +#if HAS_PREHEAT - void HMI_FanSpeed(void) { + void HMI_FanSpeed() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { + uint8_t fan_line; + switch (HMI_ValueStruct.show_mode) { + case -1: fan_line = TEMP_CASE_FAN; break; + case -2: fan_line = PREHEAT_CASE_FAN; break; + case -3: fan_line = PREHEAT_CASE_FAN; break; + default: fan_line = TUNE_CASE_FAN + MROWS - index_tune; + } + if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Fan_speed += EncoderRate.encoderMoveValue; } @@ -1292,26 +1440,26 @@ void HMI_Zoffset(void) { HMI_ValueStruct.Fan_speed -= EncoderRate.encoderMoveValue; } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; if (HMI_ValueStruct.show_mode == -1) { checkkey = TemperatureID; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } else if (HMI_ValueStruct.show_mode == -2) { checkkey = PLAPreheat; ui.material_preset[0].fan_speed = HMI_ValueStruct.Fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[0].fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), ui.material_preset[0].fan_speed); return; } else if (HMI_ValueStruct.show_mode == -3) { checkkey = ABSPreheat; ui.material_preset[1].fan_speed = HMI_ValueStruct.Fan_speed; - 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(fan_line), ui.material_preset[1].fan_speed); return; } else { checkkey = Tune; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4 + MROWS - index_tune), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } thermalManager.set_fan_speed(0, HMI_ValueStruct.Fan_speed); return; @@ -1320,16 +1468,13 @@ void HMI_Zoffset(void) { NOMORE(HMI_ValueStruct.Fan_speed, FANON); NOLESS(HMI_ValueStruct.Fan_speed, FANOFF); // Fan_speed value - if (HMI_ValueStruct.show_mode >= 0) // tune page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(4 + MROWS - index_tune), HMI_ValueStruct.Fan_speed); - else // other page - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed); } } -#endif // HAS_FAN +#endif // HAS_PREHEAT -void HMI_PrintSpeed(void) { +void HMI_PrintSpeed() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1340,20 +1485,20 @@ void HMI_PrintSpeed(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return checkkey = Tune; - EncoderRate.encoderRateEnabled = 0; + EncoderRate.enabled = false; feedrate_percentage = HMI_ValueStruct.print_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1 + MROWS - index_tune), HMI_ValueStruct.print_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); return; } // print_speed limit NOMORE(HMI_ValueStruct.print_speed, MAX_PRINT_SPEED); NOLESS(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED); // print_speed value - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1 + MROWS - index_tune), HMI_ValueStruct.print_speed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed); } } -void HMI_MaxFeedspeedXYZE(void) { +void HMI_MaxFeedspeedXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1364,82 +1509,76 @@ void HMI_MaxFeedspeedXYZE(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return checkkey = MaxSpeed; - EncoderRate.encoderRateEnabled = 0; - if (WITHIN(HMI_flag.feedspeed_flag, X_AXIS, E_AXIS)) - planner.set_max_feedrate(HMI_flag.feedspeed_flag, HMI_ValueStruct.Max_Feedspeed); + EncoderRate.enabled = false; + if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) + planner.set_max_feedrate(HMI_flag.feedspeed_axis, HMI_ValueStruct.Max_Feedspeed); DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); return; } // MaxFeedspeed limit - if (WITHIN(HMI_flag.feedspeed_flag, X_AXIS, E_AXIS)) - NOMORE(HMI_ValueStruct.Max_Feedspeed, default_max_feedrate[HMI_flag.feedspeed_flag] * 2); + if (WITHIN(HMI_flag.feedspeed_axis, X_AXIS, E_AXIS)) + NOMORE(HMI_ValueStruct.Max_Feedspeed, default_max_feedrate[HMI_flag.feedspeed_axis] * 2); if (HMI_ValueStruct.Max_Feedspeed < MIN_MAXFEEDSPEED) HMI_ValueStruct.Max_Feedspeed = MIN_MAXFEEDSPEED; // MaxFeedspeed value DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); } } -void HMI_MaxAccelerationXYZE(void) { +void HMI_MaxAccelerationXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { HMI_ValueStruct.Max_Acceleration += EncoderRate.encoderMoveValue;} else if (encoder_diffState == ENCODER_DIFF_CCW) { HMI_ValueStruct.Max_Acceleration -= EncoderRate.encoderMoveValue;} else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return checkkey = MaxAcceleration; - EncoderRate.encoderRateEnabled = 0; - if (HMI_flag.acc_flag == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration); - else if (HMI_flag.acc_flag == Y_AXIS) planner.set_max_acceleration(Y_AXIS, HMI_ValueStruct.Max_Acceleration); - else if (HMI_flag.acc_flag == Z_AXIS) planner.set_max_acceleration(Z_AXIS, HMI_ValueStruct.Max_Acceleration); + EncoderRate.enabled = false; + if (HMI_flag.acc_axis == X_AXIS) planner.set_max_acceleration(X_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_axis == Y_AXIS) planner.set_max_acceleration(Y_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_axis == Z_AXIS) planner.set_max_acceleration(Z_AXIS, HMI_ValueStruct.Max_Acceleration); #if HAS_HOTEND - else if (HMI_flag.acc_flag == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration); + else if (HMI_flag.acc_axis == E_AXIS) planner.set_max_acceleration(E_AXIS, HMI_ValueStruct.Max_Acceleration); #endif DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); return; } // MaxAcceleration limit - if (WITHIN(HMI_flag.acc_flag, X_AXIS, E_AXIS)) - NOMORE(HMI_ValueStruct.Max_Acceleration, default_max_acceleration[HMI_flag.acc_flag] * 2); + if (WITHIN(HMI_flag.acc_axis, X_AXIS, E_AXIS)) + NOMORE(HMI_ValueStruct.Max_Acceleration, default_max_acceleration[HMI_flag.acc_axis] * 2); if (HMI_ValueStruct.Max_Acceleration < MIN_MAXACCELERATION) HMI_ValueStruct.Max_Acceleration = MIN_MAXACCELERATION; // MaxAcceleration value DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); } } -void HMI_MaxJerkXYZE(void) { - ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_CW) { - HMI_ValueStruct.Max_Jerk += EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - HMI_ValueStruct.Max_Jerk -= EncoderRate.encoderMoveValue; - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return - checkkey = MaxJerk; - EncoderRate.encoderRateEnabled = 0; - if (HMI_flag.jerk_flag == X_AXIS) planner.set_max_jerk(X_AXIS, HMI_ValueStruct.Max_Jerk / 10); - else if (HMI_flag.jerk_flag == Y_AXIS) planner.set_max_jerk(Y_AXIS, HMI_ValueStruct.Max_Jerk / 10); - else if (HMI_flag.jerk_flag == Z_AXIS) planner.set_max_jerk(Z_AXIS, HMI_ValueStruct.Max_Jerk / 10); - else if (HMI_flag.jerk_flag == E_AXIS) planner.set_max_jerk(E_AXIS, HMI_ValueStruct.Max_Jerk / 10); - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); - return; +#if HAS_CLASSIC_JERK + + void HMI_MaxJerkXYZE() { + ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (encoder_diffState == ENCODER_DIFF_CW) + HMI_ValueStruct.Max_Jerk += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + HMI_ValueStruct.Max_Jerk -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return + checkkey = MaxJerk; + EncoderRate.enabled = false; + if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) + planner.set_max_jerk(HMI_flag.step_axis, HMI_ValueStruct.Max_Jerk / 10); + DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + return; + } + // MaxJerk limit + if (WITHIN(HMI_flag.jerk_axis, X_AXIS, E_AXIS)) + NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[HMI_flag.jerk_axis] * 2 * MINUNITMULT); + NOLESS(HMI_ValueStruct.Max_Jerk, (MIN_MAXJERK) * MINUNITMULT); + // MaxJerk value + DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); } - // MaxJerk limit - if (HMI_flag.jerk_flag == X_AXIS) - NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[X_AXIS] * 2 * MINUNITMULT); - else if (HMI_flag.jerk_flag == Y_AXIS) - NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[Y_AXIS] * 2 * MINUNITMULT); - else if (HMI_flag.jerk_flag == Z_AXIS) - NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[Z_AXIS] * 2 * MINUNITMULT); - else if (HMI_flag.jerk_flag == E_AXIS) - NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[E_AXIS] * 2 * MINUNITMULT); - NOLESS(HMI_ValueStruct.Max_Jerk, (MIN_MAXJERK) * MINUNITMULT); - // MaxJerk value - DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); } -} -void HMI_StepXYZE(void) { +#endif // HAS_CLASSIC_JERK + +void HMI_StepXYZE() { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_CW) { @@ -1450,71 +1589,100 @@ void HMI_StepXYZE(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { // return checkkey = Step; - EncoderRate.encoderRateEnabled = 0; - if (WITHIN(HMI_flag.step_flag, X_AXIS, E_AXIS)) - planner.settings.axis_steps_per_mm[HMI_flag.step_flag] = HMI_ValueStruct.Max_Step / 10; + EncoderRate.enabled = false; + if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) + planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step / 10; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); return; } // Step limit - if (WITHIN(HMI_flag.step_flag, X_AXIS, E_AXIS)) - NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[HMI_flag.step_flag] * 2 * MINUNITMULT); + if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS)) + NOMORE(HMI_ValueStruct.Max_Step, default_axis_steps_per_unit[HMI_flag.step_axis] * 2 * MINUNITMULT); NOLESS(HMI_ValueStruct.Max_Step, MIN_STEP); // Step value DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); } } -void update_variable(void) { +void update_variable() { + #if HAS_HOTEND + static float last_temp_hotend_target = 0, last_temp_hotend_current = 0; + #endif + #if HAS_HEATED_BED + static float last_temp_bed_target = 0, last_temp_bed_current = 0; + #endif + #if HAS_FAN + static uint8_t last_fan_speed = 0; + #endif + /* Tune page temperature update */ if (checkkey == Tune) { - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2 + MROWS - index_tune), thermalManager.temp_hotend[0].target); - if (last_temp_bed_target != thermalManager.temp_bed.target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3 + MROWS - index_tune), thermalManager.temp_bed.target); - if (last_fan_speed != thermalManager.fan_speed[0]) { - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(4 + MROWS - index_tune), thermalManager.fan_speed[0]); - last_fan_speed = thermalManager.fan_speed[0]; - } + #if HAS_HOTEND + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); + #endif + #if HAS_HEATED_BED + if (last_temp_bed_target != thermalManager.temp_bed.target) + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); + #endif + #if HAS_FAN + if (last_fan_speed != thermalManager.fan_speed[0]) { + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); + last_fan_speed = thermalManager.fan_speed[0]; + } + #endif } /* Temperature page temperature update */ if (checkkey == TemperatureID) { - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); - if (last_temp_bed_target != thermalManager.temp_bed.target) - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_bed.target); - if (last_fan_speed != thermalManager.fan_speed[0]) { - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.fan_speed[0]); - last_fan_speed = thermalManager.fan_speed[0]; - } + #if HAS_HOTEND + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_TEMP), thermalManager.temp_hotend[0].target); + #endif + #if HAS_HEATED_BED + if (last_temp_bed_target != thermalManager.temp_bed.target) + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_BED), thermalManager.temp_bed.target); + #endif + #if HAS_FAN + if (last_fan_speed != thermalManager.fan_speed[0]) { + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(TEMP_CASE_FAN), thermalManager.fan_speed[0]); + last_fan_speed = thermalManager.fan_speed[0]; + } + #endif } /* Bottom temperature update */ - if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); - last_temp_hotend_current = thermalManager.temp_hotend[0].celsius; - } - if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); - last_temp_hotend_target = thermalManager.temp_hotend[0].target; - } - if (last_temp_bed_current != thermalManager.temp_bed.celsius) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); - last_temp_bed_current = thermalManager.temp_bed.celsius; - } - if (last_temp_bed_target != thermalManager.temp_bed.target) { - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); - last_temp_bed_target = thermalManager.temp_bed.target; - } + #if HAS_HOTEND + if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) { + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); + last_temp_hotend_current = thermalManager.temp_hotend[0].celsius; + } + if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) { + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); + last_temp_hotend_target = thermalManager.temp_hotend[0].target; + } + #endif + #if HAS_HEATED_BED + if (last_temp_bed_current != thermalManager.temp_bed.celsius) { + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); + last_temp_bed_current = thermalManager.temp_bed.celsius; + } + if (last_temp_bed_target != thermalManager.temp_bed.target) { + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); + last_temp_bed_target = thermalManager.temp_bed.target; + } + #endif + static uint16_t last_speed = 0; if (last_speed != 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; } - 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; - } + #if HAS_ZOFFSET_ITEM + 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; + } + #endif } /** @@ -1553,38 +1721,37 @@ inline void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_ while (pos--) dst[pos] = src[pos]; } -inline void HMI_SDCardInit(void) { card.cdroot(); } +inline void HMI_SDCardInit() { card.cdroot(); } -void MarlinUI::refresh() { - // The card was mounted or unmounted - // or some other status change occurred - // DWIN_lcd_sd_status = false; // On next DWIN_Update - // HMI_SDCardUpdate(); -} +void MarlinUI::refresh() { /* Nothing to see here */ } #define ICON_Folder ICON_More -char shift_name[LONG_FILENAME_LENGTH + 1]; -int8_t shift_amt; // = 0 -millis_t shift_ms; // = 0 +#if ENABLED(SCROLL_LONG_FILENAMES) -// Init the shift name based on the highlighted item -inline void Init_Shift_Name() { - const bool is_subdir = !card.flag.workDirIsRoot; - const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".." - const uint16_t fileCnt = card.get_num_Files(); - if (WITHIN(filenum, 0, fileCnt - 1)) { - card.getfilename_sorted(SD_ORDER(filenum, fileCnt)); - char * const name = card.longest_filename(); - make_name_without_ext(shift_name, name, 100); + char shift_name[LONG_FILENAME_LENGTH + 1]; + int8_t shift_amt; // = 0 + millis_t shift_ms; // = 0 + + // Init the shift name based on the highlighted item + inline void Init_Shift_Name() { + const bool is_subdir = !card.flag.workDirIsRoot; + const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".." + const uint16_t fileCnt = card.get_num_Files(); + if (WITHIN(filenum, 0, fileCnt - 1)) { + card.getfilename_sorted(SD_ORDER(filenum, fileCnt)); + char * const name = card.longest_filename(); + make_name_without_ext(shift_name, name, 100); + } } -} -inline void Init_SDItem_Shift() { - shift_amt = 0; - shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT - ? millis() + 750UL : 0; -} + inline void Init_SDItem_Shift() { + shift_amt = 0; + shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT + ? millis() + 750UL : 0; + } + +#endif /** * Display an SD item, adding a CDUP for subfolders. @@ -1600,37 +1767,42 @@ inline void Draw_SDItem(const uint16_t item, int16_t row=-1) { card.getfilename_sorted(item - is_subdir); char * const name = card.longest_filename(); - // Init the current selected name - // This is used during scroll drawing - if (item == select_file.now - 1) { - make_name_without_ext(shift_name, name, 100); - Init_SDItem_Shift(); - } + #if ENABLED(SCROLL_LONG_FILENAMES) + // Init the current selected name + // This is used during scroll drawing + if (item == select_file.now - 1) { + make_name_without_ext(shift_name, name, 100); + Init_SDItem_Shift(); + } + #endif + // Draw the file/folder with name aligned left char str[strlen(name) + 1]; - make_name_without_ext(str, name); - Draw_Menu_Line(row, card.flag.filenameIsDir ? ICON_Folder : ICON_File, str); } -inline void Draw_SDItem_Shifted(int8_t &shift) { - // Limit to the number of chars past the cutoff - const size_t len = strlen(shift_name); - NOMORE(shift, _MAX((signed)len - MENU_CHAR_LIMIT, 0)); +#if ENABLED(SCROLL_LONG_FILENAMES) - // Shorten to the available space - const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); + inline void Draw_SDItem_Shifted(int8_t &shift) { + // Limit to the number of chars past the cutoff + const size_t len = strlen(shift_name); + NOMORE(shift, _MAX((signed)len - MENU_CHAR_LIMIT, 0)); - const char c = shift_name[lastchar]; - shift_name[lastchar] = '\0'; + // Shorten to the available space + const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); - const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll - Erase_Menu_Text(row); - Draw_Menu_Line(row, 0, &shift_name[shift]); + const char c = shift_name[lastchar]; + shift_name[lastchar] = '\0'; - shift_name[lastchar] = c; -} + const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll + Erase_Menu_Text(row); + Draw_Menu_Line(row, 0, &shift_name[shift]); + + shift_name[lastchar] = c; + } + +#endif // Redraw the first set of SD Files inline void Redraw_SD_List() { @@ -1645,10 +1817,12 @@ inline void Redraw_SD_List() { LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS)) Draw_SDItem(i, i + 1); - Init_SDItem_Shift(); + TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); } -inline void SDCard_Up(void) { +bool DWIN_lcd_sd_status = false; + +inline void SDCard_Up() { card.cdup(); Redraw_SD_List(); DWIN_lcd_sd_status = false; // On next DWIN_Update @@ -1663,7 +1837,7 @@ inline void SDCard_Folder(char * const dirname) { // // Watch for media mount / unmount // -void HMI_SDCardUpdate(void) { +void HMI_SDCardUpdate() { if (HMI_flag.home_flag) return; if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); @@ -1681,40 +1855,50 @@ void HMI_SDCardUpdate(void) { // TODO: Move card removed abort handling // to CardReader::manage_media. card.flag.abort_sd_printing = true; - wait_for_heatup = false; - abort_flag = true; + wait_for_heatup = false; + dwin_abort_flag = true; } } DWIN_UpdateLCD(); } } -/* Start */ +/* Start Frame */ + void HMI_StartFrame(const bool with_update) { Goto_MainMenu(); - DWIN_Draw_Rectangle(1, Background_black, 0, 360, DWIN_WIDTH, DWIN_HEIGHT - 1); + // Clear the bottom area of the screen + DWIN_Draw_Rectangle(1, Background_black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); - DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381); + // + // Status Area + // + #if HAS_HOTEND + DWIN_ICON_Show(ICON, ICON_HotendTemp, 13, 381); + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); + DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 33 + 3 * STAT_CHR_W + 5, 383, F("/")); + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); + #endif #if HOTENDS > 1 // DWIN_ICON_Show(ICON,ICON_HotendTemp, 13, 381); #endif - DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381); - DWIN_ICON_Show(ICON, ICON_Speed, 13, 429); - DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428); - // Draw initial Status Area - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33, 382, thermalManager.temp_hotend[0].celsius); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); - DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); + #if HAS_HEATED_BED + DWIN_ICON_Show(ICON, ICON_BedTemp, 158, 381); + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178, 382, thermalManager.temp_bed.celsius); + DWIN_Draw_String(false, false, STAT_FONT, White, Background_black, 178 + 3 * STAT_CHR_W + 5, 383, F("/")); + DWIN_Draw_IntValue(true, true, 0, STAT_FONT, White, Background_black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target); + #endif + DWIN_ICON_Show(ICON, ICON_Speed, 13, 429); 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 + 5 * STAT_CHR_W + 2, 429, F("%")); - 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("/")); + #if HAS_ZOFFSET_ITEM + DWIN_ICON_Show(ICON, ICON_Zoffset, 158, 428); + DWIN_Draw_Signed_Float(STAT_FONT, Background_black, 2, 2, 178, 429, BABY_Z_VAR * 100); + #endif if (with_update) { DWIN_UpdateLCD(); @@ -1774,12 +1958,12 @@ inline void Draw_Print_File_Menu() { } /* Main Process */ -void HMI_MainMenu(void) { +void HMI_MainMenu() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_page.inc(3)) { + if (select_page.inc(4)) { switch (select_page.now) { case 0: ICON_Print(); break; case 1: ICON_Print(); ICON_Prepare(); break; @@ -1834,27 +2018,29 @@ void HMI_MainMenu(void) { } // Select (and Print) File -void HMI_SelectFile(void) { +void HMI_SelectFile() { ENCODER_DiffState encoder_diffState = get_encoder_state(); const uint16_t hasUpDir = !card.flag.workDirIsRoot; if (encoder_diffState == ENCODER_DIFF_NO) { - if (shift_ms && select_file.now >= 1 + hasUpDir) { - // Scroll selected filename every second - const millis_t ms = millis(); - if (ELAPSED(ms, shift_ms)) { - const bool was_reset = shift_amt < 0; - shift_ms = ms + 375UL + was_reset * 250UL; // ms per character - int8_t shift_new = shift_amt + 1; // Try to shift by... - Draw_SDItem_Shifted(shift_new); // Draw the item - if (!was_reset && shift_new == 0) // Was it limited to 0? - shift_ms = 0; // No scrolling needed - else if (shift_new == shift_amt) // Scroll reached the end - shift_new = -1; // Reset - shift_amt = shift_new; // Set new scroll + #if ENABLED(SCROLL_LONG_FILENAMES) + if (shift_ms && select_file.now >= 1 + hasUpDir) { + // Scroll selected filename every second + const millis_t ms = millis(); + if (ELAPSED(ms, shift_ms)) { + const bool was_reset = shift_amt < 0; + shift_ms = ms + 375UL + was_reset * 250UL; // ms per character + int8_t shift_new = shift_amt + 1; // Try to shift by... + Draw_SDItem_Shifted(shift_new); // Draw the item + if (!was_reset && shift_new == 0) // Was it limited to 0? + shift_ms = 0; // No scrolling needed + else if (shift_new == shift_amt) // Scroll reached the end + shift_new = -1; // Reset + shift_amt = shift_new; // Set new scroll + } } - } + #endif return; } @@ -1864,10 +2050,10 @@ void HMI_SelectFile(void) { const uint16_t fullCnt = nr_sd_menu_items(); if (encoder_diffState == ENCODER_DIFF_CW && fullCnt) { - if (select_file.inc(fullCnt)) { + if (select_file.inc(1 + fullCnt)) { const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - if (shift_ms) { // If line was shifted - Erase_Menu_Text(select_file.now - 1 + MROWS - index_file); // Erase and + if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted + Erase_Menu_Text(itemnum + MROWS - index_file); // Erase and Draw_SDItem(itemnum - 1); // redraw } if (select_file.now > MROWS && select_file.now > index_file) { // Cursor past the bottom @@ -1877,15 +2063,15 @@ void HMI_SelectFile(void) { } else { Move_Highlight(1, select_file.now + MROWS - index_file); // Just move highlight - Init_Shift_Name(); // ...and init the shift name + TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name } - Init_SDItem_Shift(); + TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); } } else if (encoder_diffState == ENCODER_DIFF_CCW && fullCnt) { if (select_file.dec()) { const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - if (shift_ms) { // If line was shifted + if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted Erase_Menu_Text(select_file.now + 1 + MROWS - index_file); // Erase and Draw_SDItem(itemnum + 1); // redraw } @@ -1894,7 +2080,7 @@ void HMI_SelectFile(void) { Scroll_Menu(DWIN_SCROLL_DOWN); if (index_file == MROWS) { Draw_Back_First(); - shift_ms = 0; + TERN_(SCROLL_LONG_FILENAMES, shift_ms = 0); } else { Draw_SDItem(itemnum, 0); // Draw the item (and init shift name) @@ -1902,19 +2088,17 @@ void HMI_SelectFile(void) { } else { Move_Highlight(-1, select_file.now + MROWS - index_file); // Just move highlight - Init_Shift_Name(); // ...and init the shift name + TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name } - Init_SDItem_Shift(); // Reset left. Init timer. + TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); // Reset left. Init timer. } } else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (select_file.now == 0) { - /* back */ + if (select_file.now == 0) { // Back select_page.set(0); Goto_MainMenu(); } - else if (hasUpDir && select_file.now == 1) { - /* CDUP */ + else if (hasUpDir && select_file.now == 1) { // CD-Up SDCard_Up(); goto HMI_SelectFileExit; } @@ -1933,8 +2117,8 @@ void HMI_SelectFile(void) { select_file.reset(); // Start choice and print SD file - HMI_flag.heat_flag = 1; - HMI_flag.print_finish = 0; + HMI_flag.heat_flag = true; + HMI_flag.print_finish = false; HMI_ValueStruct.show_mode = 0; card.openAndPrintFile(card.filename); @@ -1954,21 +2138,21 @@ void HMI_SelectFile(void) { } /* Printing */ -void HMI_Printing(void) { +void HMI_Printing() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; - if (HMI_flag.confirm_flag) { + if (HMI_flag.done_confirm_flag) { if (encoder_diffState == ENCODER_DIFF_ENTER) { - HMI_flag.confirm_flag = 0; - abort_flag = 1; + HMI_flag.done_confirm_flag = false; + dwin_abort_flag = true; } return; } // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_print.inc(2)) { + if (select_print.inc(3)) { switch (select_print.now) { case 0: ICON_Tune(); break; case 1: @@ -1999,15 +2183,14 @@ void HMI_Printing(void) { } else if (encoder_diffState == ENCODER_DIFF_ENTER) { switch (select_print.now) { - case 0: // Setting + case 0: // Tune checkkey = Tune; HMI_ValueStruct.show_mode = 0; select_tune.reset(); - index_tune = 5; + index_tune = MROWS; Draw_Tune_Menu(); break; case 1: // Pause - /* pause */ if (HMI_flag.pause_flag) { ICON_Pause(); @@ -2015,23 +2198,26 @@ void HMI_Printing(void) { cmd[0] = '\0'; #if ENABLED(PAUSE_HEAT) - if (tempbed) sprintf_P(cmd, PSTR("M190 S%i\n"), tempbed); - if (temphot) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), temphot); + #if HAS_HEATED_BED + if (tempbed) sprintf_P(cmd, PSTR("M190 S%i\n"), tempbed); + #endif + #if HAS_HOTEND + if (temphot) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), temphot); + #endif #endif strcat_P(cmd, PSTR("M24")); queue.inject(cmd); } else { - HMI_flag.select_flag = 1; + HMI_flag.select_flag = true; checkkey = Print_window; Popup_window_PauseOrStop(); } break; case 2: // Stop - /* stop */ - HMI_flag.select_flag = 1; + HMI_flag.select_flag = true; checkkey = Print_window; Popup_window_PauseOrStop(); break; @@ -2043,7 +2229,7 @@ void HMI_Printing(void) { } /* Pause and Stop window */ -void HMI_PauseOrStop(void) { +void HMI_PauseOrStop() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; @@ -2056,7 +2242,7 @@ void HMI_PauseOrStop(void) { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (select_print.now == 1) { // pause window if (HMI_flag.select_flag) { - pause_action_flag = 1; + HMI_flag.pause_action = true; ICON_Continue(); #if ENABLED(POWER_LOSS_RECOVERY) if (recovery.enabled) recovery.save(true); @@ -2084,10 +2270,10 @@ void HMI_PauseOrStop(void) { host_action_cancel(); #endif #ifdef EVENT_GCODE_SD_ABORT - Popup_Window_Home(); + Popup_Window_Home(true); queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT)); #endif - abort_flag = true; + dwin_abort_flag = true; #endif } else { @@ -2114,20 +2300,20 @@ inline void Draw_Move_Menu() { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_MOVE_AXIS)); #else - DWIN_Frame_TitleCopy(1, 231, 2, 265, 12); // "Move" + DWIN_Frame_TitleCopy(1, 231, 2, 265, 12); // "Move" #endif draw_move_en(MBASE(1)); say_x(36, MBASE(1)); // "Move X" draw_move_en(MBASE(2)); say_y(36, MBASE(2)); // "Move Y" draw_move_en(MBASE(3)); say_z(36, MBASE(3)); // "Move Z" #if HAS_HOTEND - DWIN_Frame_AreaCopy(1, 123, 192, 176, 202, LBLX, MBASE(4)); // "Extruder" + DWIN_Frame_AreaCopy(1, 123, 192, 176, 202, LBLX, MBASE(4)); // "Extruder" #endif } Draw_Back_First(select_axis.now == 0); if (select_axis.now) Draw_Menu_Cursor(select_axis.now); - // Draw separators so it looks like a menu + // Draw separators and icons LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MoveX + i); } @@ -2144,13 +2330,13 @@ void HMI_AudioFeedback(const bool success=true) { } /* Prepare */ -void HMI_Prepare(void) { +void HMI_Prepare() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_prepare.inc(8)) { + if (select_prepare.inc(1 + PREPARE_CASE_TOTAL)) { if (select_prepare.now > MROWS && select_prepare.now > index_prepare) { index_prepare = select_prepare.now; @@ -2161,9 +2347,13 @@ void HMI_Prepare(void) { // Draw "More" icon for sub-menus if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1); - if (index_prepare == 6) Prepare_Item_ABS(MROWS); - else if (index_prepare == 7) Prepare_Item_Cool(MROWS); - else if (index_prepare == 8) Prepare_Item_Lang(MROWS); + #if HAS_HOTEND + if (index_prepare == PREPARE_CASE_ABS) Item_Prepare_ABS(MROWS); + #endif + #if HAS_PREHEAT + if (index_prepare == PREPARE_CASE_COOL) Item_Prepare_Cool(MROWS); + #endif + if (index_prepare == PREPARE_CASE_LANG) Item_Prepare_Lang(MROWS); } else { Move_Highlight(1, select_prepare.now + MROWS - index_prepare); @@ -2183,9 +2373,9 @@ void HMI_Prepare(void) { if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1); - if (index_prepare == 6) Prepare_Item_Move(0); - else if (index_prepare == 7) Prepare_Item_Disable(0); - else if (index_prepare == 8) Prepare_Item_Home(0); + if (index_prepare == 6) Item_Prepare_Move(0); + else if (index_prepare == 7) Item_Prepare_Disable(0); + else if (index_prepare == 8) Item_Prepare_Home(0); } else { Move_Highlight(-1, select_prepare.now + MROWS - index_prepare); @@ -2198,67 +2388,66 @@ void HMI_Prepare(void) { select_page.set(1); Goto_MainMenu(); break; - case 1: // axis move + case PREPARE_CASE_MOVE: // Axis move checkkey = AxisMove; select_axis.reset(); Draw_Move_Menu(); - queue.inject_P(PSTR("G92 E0")); - current_position.e = HMI_ValueStruct.Move_E_scale = 0; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(1), current_position.x * MINUNITMULT); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(2), current_position.y * MINUNITMULT); DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Background_black, 3, 1, 216, MBASE(3), current_position.z * MINUNITMULT); #if HAS_HOTEND - DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), current_position.e * MINUNITMULT); + queue.inject_P(PSTR("G92 E0")); + current_position.e = HMI_ValueStruct.Move_E_scale = 0; + DWIN_Draw_Signed_Float(font8x16, Background_black, 3, 1, 216, MBASE(4), 0); #endif break; - case 2: // close motion + case PREPARE_CASE_DISA: // Disable steppers queue.inject_P(PSTR("M84")); break; - case 3: // homing + case PREPARE_CASE_HOME: // Homing checkkey = Last_Prepare; index_prepare = MROWS; queue.inject_P(PSTR("G28")); // G28 will set home_flag Popup_Window_Home(); break; - case 4: // Z-offset - #if HAS_BED_PROBE - checkkey = Homeoffset; - HMI_ValueStruct.show_mode = -4; - HMI_ValueStruct.offset_value = probe.offset.z * 100; - 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 - queue.inject_P(PSTR("G92 X0 Y0 Z0")); - HMI_AudioFeedback(); - #endif - break; - case 5: // PLA preheat - thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0); - thermalManager.setTargetBed(ui.material_preset[0].bed_temp); - thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed); - break; - case 6: // ABS preheat - thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0); - thermalManager.setTargetBed(ui.material_preset[1].bed_temp); - thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed); - break; - case 7: // cool - thermalManager.zero_fan_speeds(); - thermalManager.disable_all_heaters(); - break; - case 8: // language - /* select language */ - HMI_flag.language_chinese ^= true; - if (HMI_flag.language_chinese) { - HMI_SetAndSaveLanguageChinese(); - DWIN_JPG_CacheTo1(Language_Chinese); - } - else { - HMI_SetAndSaveLanguageWestern(); - DWIN_JPG_CacheTo1(Language_English); - } + #if HAS_ZOFFSET_ITEM + case PREPARE_CASE_ZOFF: // Z-offset + #if EITHER(HAS_BED_PROBE, BABYSTEPPING) + checkkey = Homeoffset; + HMI_ValueStruct.show_mode = -4; + HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(PREPARE_CASE_ZOFF + MROWS - index_prepare), HMI_ValueStruct.offset_value); + EncoderRate.enabled = true; + #else + // Apply workspace offset, making the current position 0,0,0 + queue.inject_P(PSTR("G92 X0 Y0 Z0")); + HMI_AudioFeedback(); + #endif + break; + #endif + #if HAS_HOTEND + case PREPARE_CASE_PLA: // PLA preheat + thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0); + thermalManager.setTargetBed(ui.material_preset[0].bed_temp); + thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed); + break; + case PREPARE_CASE_ABS: // ABS preheat + thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0); + thermalManager.setTargetBed(ui.material_preset[1].bed_temp); + thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed); + break; + #endif + #if HAS_PREHEAT + case PREPARE_CASE_COOL: // Cool + TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); + #if HAS_HOTEND || HAS_HEATED_BED + thermalManager.disable_all_heaters(); + #endif + break; + #endif + case PREPARE_CASE_LANG: // Toggle Language + HMI_ToggleLanguage(); Draw_Prepare_Menu(); break; default: break; @@ -2271,72 +2460,108 @@ void Draw_Temperature_Menu() { Clear_Main_Window(); if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 236, 2, 263, 13, 14, 8); - - DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(2)); - DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 100, 89, 178, 101, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 180, 89, 260, 100, LBLX, MBASE(5)); + DWIN_Frame_TitleCopy(1, 236, 2, 263, 13); // "Temperature" + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX, MBASE(TEMP_CASE_TEMP)); + #endif + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX, MBASE(TEMP_CASE_BED)); + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX, MBASE(TEMP_CASE_FAN)); + #endif + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 100, 89, 178, 101, LBLX, MBASE(TEMP_CASE_PLA)); + DWIN_Frame_AreaCopy(1, 180, 89, 260, 100, LBLX, MBASE(TEMP_CASE_ABS)); + #endif } else { #ifdef USE_STRING_HEADINGS Draw_Title(GET_TEXT_F(MSG_TEMPERATURE)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_FAN_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), F("PLA Preheat Settings")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(5), F("ABS Preheat Settings")); + #if HAS_HOTEND + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_TEMP), GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND)); + #endif + #if HAS_HEATED_BED + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_BED), GET_TEXT_F(MSG_UBL_SET_TEMP_BED)); + #endif + #if HAS_FAN + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + #endif + #if HAS_HOTEND + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_PLA), F("PLA Preheat Settings")); + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(TEMP_CASE_ABS), F("ABS Preheat Settings")); + #endif #else - DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8); - DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(1)); // Nozzle... - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(1)); // ...Temperature - DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(2)); // Bed... - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(2)); // ...Temperature - DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(3)); // Fan speed - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(4)); // Preheat... - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(4)); // ...PLA - DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 79, MBASE(4)); // PLA setting - DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(5)); // Preheat... - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(5)); // ...ABS - DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 81, MBASE(5)); // ABS setting + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "Temperature" + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX, MBASE(TEMP_CASE_TEMP)); // Nozzle... + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 44, MBASE(TEMP_CASE_TEMP)); // ...Temperature + #endif + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX, MBASE(TEMP_CASE_BED)); // Bed... + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 27, MBASE(TEMP_CASE_BED)); // ...Temperature + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX, MBASE(TEMP_CASE_FAN)); // Fan speed + #endif + #if HAS_HOTEND + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(TEMP_CASE_PLA)); // Preheat... + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX + 52, MBASE(TEMP_CASE_PLA)); // ...PLA + DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 79, MBASE(TEMP_CASE_PLA)); // PLA setting + DWIN_Frame_AreaCopy(1, 107, 76, 156, 86, LBLX, MBASE(TEMP_CASE_ABS)); // Preheat... + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 52, MBASE(TEMP_CASE_ABS)); // ...ABS + DWIN_Frame_AreaCopy(1, 131, 119, 182, 132, LBLX + 81, MBASE(TEMP_CASE_ABS)); // ABS setting + #endif #endif } Draw_Back_First(select_temp.now == 0); if (select_temp.now) Draw_Menu_Cursor(select_temp.now); - LOOP_L_N(i, 5) Draw_Menu_Line(i + 1, ICON_SetEndTemp + i); - - Draw_More_Icon(4); - Draw_More_Icon(5); - - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(2), thermalManager.temp_bed.target); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), thermalManager.fan_speed[0]); + // Draw icons and lines + uint8_t i = 0; + #define _TMENU_ICON(N) Draw_Menu_Line(++i, ICON_SetEndTemp + (N) - 1) + #if HAS_HOTEND + _TMENU_ICON(TEMP_CASE_TEMP); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.temp_hotend[0].target); + #endif + #if HAS_HEATED_BED + _TMENU_ICON(TEMP_CASE_BED); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.temp_bed.target); + #endif + #if HAS_FAN + _TMENU_ICON(TEMP_CASE_FAN); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), thermalManager.fan_speed[0]); + #endif + #if HAS_HOTEND + // PLA/ABS items have submenus + _TMENU_ICON(TEMP_CASE_PLA); + Draw_More_Icon(i); + _TMENU_ICON(TEMP_CASE_ABS); + Draw_More_Icon(i); + #endif } /* Control */ -void HMI_Control(void) { +void HMI_Control() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - #define CONTROL_ITEMS (5 + ENABLED(HAS_ONESTEP_LEVELING)) - if (select_control.inc(CONTROL_ITEMS)) { + if (select_control.inc(1 + CONTROL_CASE_TOTAL)) { if (select_control.now > MROWS && select_control.now > index_control) { index_control = select_control.now; Scroll_Menu(DWIN_SCROLL_UP); - Draw_Menu_Icon(MROWS, ICON_Temperature + select_control.now - 1); - Draw_More_Icon(1 + MROWS - index_control); // Temperature > - Draw_More_Icon(2 + MROWS - index_control); // Motion > + Draw_Menu_Icon(MROWS, ICON_Temperature + index_control - 1); + Draw_More_Icon(CONTROL_CASE_TEMP + MROWS - index_control); // Temperature > + Draw_More_Icon(CONTROL_CASE_MOVE + MROWS - index_control); // Motion > if (index_control > MROWS) { - Draw_More_Icon(6 + MROWS - index_control); // Info > + Draw_More_Icon(CONTROL_CASE_INFO + MROWS - index_control); // Info > if (HMI_flag.language_chinese) - DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, MBASE(5)); + DWIN_Frame_AreaCopy(1, 231, 104, 258, 116, LBLX, MBASE(CONTROL_CASE_INFO - 1)); else - DWIN_Frame_AreaCopy(1, 0, 104, 24, 114, LBLX, MBASE(5)); + DWIN_Frame_AreaCopy(1, 0, 104, 24, 114, LBLX, MBASE(CONTROL_CASE_INFO - 1)); } } else { @@ -2367,33 +2592,32 @@ void HMI_Control(void) { select_page.set(2); Goto_MainMenu(); break; - case 1: // temperature + case CONTROL_CASE_TEMP: // Temperature checkkey = TemperatureID; HMI_ValueStruct.show_mode = -1; select_temp.reset(); Draw_Temperature_Menu(); break; - case 2: // motion + case CONTROL_CASE_MOVE: // Motion checkkey = Motion; select_motion.reset(); Draw_Motion_Menu(); break; - case 3: #if ENABLED(EEPROM_SETTINGS) - { // write EEPROM + case CONTROL_CASE_SAVE: { // Write EEPROM const bool success = settings.save(); HMI_AudioFeedback(success); } break; - case 4: { // read EEPROM + case CONTROL_CASE_LOAD: { // Read EEPROM const bool success = settings.load(); HMI_AudioFeedback(success); } break; - case 5: // resume EEPROM + case CONTROL_CASE_RESET: // Reset EEPROM settings.reset(); HMI_AudioFeedback(); break; - case 6: // info #endif + case CONTROL_CASE_INFO: // Info checkkey = Info; Draw_Info_Menu(); break; @@ -2407,7 +2631,7 @@ void HMI_Control(void) { #if HAS_ONESTEP_LEVELING /* Leveling */ - void HMI_Leveling(void) { + void HMI_Leveling() { Popup_Window_Leveling(); DWIN_UpdateLCD(); queue.inject_P(PSTR("G28O\nG29")); @@ -2416,21 +2640,21 @@ void HMI_Control(void) { #endif /* Axis Move */ -void HMI_AxisMove(void) { +void HMI_AxisMove() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; - #if HAS_HOTEND + #if ENABLED(PREVENT_COLD_EXTRUSION) // popup window resume if (HMI_flag.ETempTooLow_flag) { if (encoder_diffState == ENCODER_DIFF_ENTER) { - HMI_flag.ETempTooLow_flag = 0; - Draw_Move_Menu(); + HMI_flag.ETempTooLow_flag = false; current_position.e = HMI_ValueStruct.Move_E_scale = 0; + Draw_Move_Menu(); 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); - DWIN_Draw_Signed_Float(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), 0); DWIN_UpdateLCD(); } return; @@ -2439,7 +2663,7 @@ void HMI_AxisMove(void) { // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_axis.inc(4)) Move_Highlight(1, select_axis.now); + if (select_axis.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_axis.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_axis.dec()) Move_Highlight(-1, select_axis.now); @@ -2456,26 +2680,26 @@ void HMI_AxisMove(void) { checkkey = Move_X; HMI_ValueStruct.Move_X_scale = current_position.x * MINUNITMULT; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; break; case 2: // Y axis move checkkey = Move_Y; HMI_ValueStruct.Move_Y_scale = current_position.y * MINUNITMULT; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; break; case 3: // Z axis move checkkey = Move_Z; HMI_ValueStruct.Move_Z_scale = current_position.z * MINUNITMULT; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; break; #if HAS_HOTEND case 4: // Extruder // window tips #ifdef PREVENT_COLD_EXTRUSION if (thermalManager.temp_hotend[0].celsius < EXTRUDE_MINTEMP) { - HMI_flag.ETempTooLow_flag = 1; + HMI_flag.ETempTooLow_flag = true; Popup_Window_ETempTooLow(); DWIN_UpdateLCD(); return; @@ -2484,7 +2708,7 @@ void HMI_AxisMove(void) { checkkey = Extruder; HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT; DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; break; #endif } @@ -2493,13 +2717,13 @@ void HMI_AxisMove(void) { } /* TemperatureID */ -void HMI_Temperature(void) { +void HMI_Temperature() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_temp.inc(5)) Move_Highlight(1, select_temp.now); + if (select_temp.inc(1 + TEMP_CASE_TOTAL)) Move_Highlight(1, select_temp.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_temp.dec()) Move_Highlight(-1, select_temp.now); @@ -2512,141 +2736,184 @@ void HMI_Temperature(void) { index_control = MROWS; Draw_Control_Menu(); break; - #if HAS_HOTEND - case 1: // nozzle temperature - checkkey = ETemp; - HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_HEATED_BED - case 2: // bed temperature - checkkey = BedTemp; - HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_FAN - case 3: // fan speed - checkkey = FanSpeed; - HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_HOTEND - case 4: // PLA preheat setting - checkkey = PLAPreheat; - select_PLA.reset(); - HMI_ValueStruct.show_mode = -2; - - Clear_Main_Window(); - - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 59, 16, 139, 29, 14, 8); - - DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(1)); // PLA nozzle temp - DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(2)); - DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(2)); // PLA bed temp - DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(3)); // PLA fan speed - DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(4)); // save PLA configuration - } - else { - #ifdef USE_STRING_HEADINGS - Draw_Title("PLA Settings"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Nozzle Temp")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), F("Bed Temp")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_FAN_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_STORE_EEPROM)); - #else - DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8); - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(1)); // PLA nozzle temp - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(2) + 3); // PLA bed temp - DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(3)); // PLA fan speed - DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(4)); // save PLA configuration - #endif - } - - Draw_Back_First(); - - Draw_Menu_Line(1, ICON_SetEndTemp); - Draw_Menu_Line(2, ICON_SetBedTemp); - Draw_Menu_Line(3, ICON_FanSpeed); + #if HAS_HOTEND + case TEMP_CASE_TEMP: // Nozzle temperature + checkkey = ETemp; + HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target); + EncoderRate.enabled = true; + break; + #endif + #if HAS_HEATED_BED + case TEMP_CASE_BED: // Bed temperature + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target); + EncoderRate.enabled = true; + break; + #endif + #if HAS_FAN + case TEMP_CASE_FAN: // Fan speed + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]); + EncoderRate.enabled = true; + break; + #endif + #if HAS_HOTEND + case TEMP_CASE_PLA: { // PLA preheat setting + checkkey = PLAPreheat; + select_PLA.reset(); + HMI_ValueStruct.show_mode = -2; + + Clear_Main_Window(); + + if (HMI_flag.language_chinese) { + DWIN_Frame_TitleCopy(1, 59, 16, 139, 29); // "PLA Settings" + DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_BED)); + DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(PREHEAT_CASE_BED)); // PLA bed temp + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 100, 89, 124, 101, LBLX, MBASE(PREHEAT_CASE_FAN)); + DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(PREHEAT_CASE_FAN)); // PLA fan speed + #endif #if ENABLED(EEPROM_SETTINGS) - Draw_Menu_Line(4, ICON_WriteEEPROM); + DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration + #endif + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("PLA Settings"); // TODO: GET_TEXT_F + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); + #if HAS_HEATED_BED + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); + #endif + #if HAS_FAN + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + #endif + #if ENABLED(EEPROM_SETTINGS) + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + #endif + #else + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "PLA Settings" + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3); + DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3); + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(PREHEAT_CASE_BED) + 3); // PLA bed temp + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_FAN)); + DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN)); // PLA fan speed + #endif + #if ENABLED(EEPROM_SETTINGS) + DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); // Save PLA configuration + #endif #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); - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(3), ui.material_preset[0].fan_speed); + Draw_Back_First(); - break; + uint8_t i = 0; + Draw_Menu_Line(++i, ICON_SetEndTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].hotend_temp); + #if HAS_HEATED_BED + Draw_Menu_Line(++i, ICON_SetBedTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].bed_temp); + #endif + #if HAS_FAN + Draw_Menu_Line(++i, ICON_FanSpeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[0].fan_speed); + #endif + #if ENABLED(EEPROM_SETTINGS) + Draw_Menu_Line(++i, ICON_WriteEEPROM); + #endif + } break; - case 5: // ABS preheat setting - checkkey = ABSPreheat; - select_ABS.reset(); - HMI_ValueStruct.show_mode = -3; - - Clear_Main_Window(); - - if (HMI_flag.language_chinese) { - DWIN_Frame_AreaCopy(1, 142, 16, 223, 29, 14, 8); - - DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(1)); // ABS nozzle temp - DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(2)); - DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(2)); // ABS bed temp - DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(3)); // ABS fan speed - DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX + 28, MBASE(4) + 2); // save ABS configuration - } - else { - #ifdef USE_STRING_HEADINGS - Draw_Title("ABS Settings"); // TODO: GET_TEXT_F - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(1), F("Nozzle Temp")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(2), F("Bed Temp")); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(3), GET_TEXT_F(MSG_FAN_SPEED)); - DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), GET_TEXT_F(MSG_STORE_EEPROM)); - #else - DWIN_Frame_AreaCopy(1, 56, 16, 141, 28, 14, 8); - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(1)); - DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(1)); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(1)); // ABS nozzle temp - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(2) + 3); - DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(2) + 3); // ABS bed temp - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(3)); - DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(3)); // ABS fan speed - DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(4)); - DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 33, MBASE(4)); // save ABS configuration - #endif - } + case TEMP_CASE_ABS: { // ABS preheat setting + checkkey = ABSPreheat; + select_ABS.reset(); + HMI_ValueStruct.show_mode = -3; - Draw_Back_First(); + Clear_Main_Window(); - Draw_Menu_Line(1, ICON_SetEndTemp); - Draw_Menu_Line(2, ICON_SetBedTemp); - Draw_Menu_Line(3, ICON_FanSpeed); + if (HMI_flag.language_chinese) { + DWIN_Frame_TitleCopy(1, 142, 16, 223, 29); // "ABS Settings" + + DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 1, 134, 56, 146, LBLX + 24, MBASE(PREHEAT_CASE_TEMP)); // ABS nozzle temp + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_BED)); + DWIN_Frame_AreaCopy(1, 58, 134, 113, 146, LBLX + 24, MBASE(PREHEAT_CASE_BED)); // ABS bed temp + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX, MBASE(PREHEAT_CASE_FAN)); + DWIN_Frame_AreaCopy(1, 115, 134, 170, 146, LBLX + 24, MBASE(PREHEAT_CASE_FAN)); // ABS fan speed + #endif #if ENABLED(EEPROM_SETTINGS) - Draw_Menu_Line(4, ICON_WriteEEPROM); + DWIN_Frame_AreaCopy(1, 72, 148, 151, 162, LBLX, MBASE(PREHEAT_CASE_SAVE)); + DWIN_Frame_AreaCopy(1, 180, 89, 204, 100, LBLX + 28, MBASE(PREHEAT_CASE_SAVE) + 2); // Save ABS configuration + #endif + } + else { + #ifdef USE_STRING_HEADINGS + Draw_Title("ABS Settings"); // TODO: GET_TEXT_F + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp")); + #if HAS_HEATED_BED + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_BED), F("Bed Temp")); + #endif + #if HAS_FAN + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_FAN), GET_TEXT_F(MSG_FAN_SPEED)); + #endif + #if ENABLED(EEPROM_SETTINGS) + DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(PREHEAT_CASE_SAVE), GET_TEXT_F(MSG_STORE_EEPROM)); + #endif + #else + DWIN_Frame_TitleCopy(1, 56, 16, 141, 28); // "ABS Settings" + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP)); + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // ABS nozzle temp + #if HAS_HEATED_BED + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3); + DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3); + DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 54, MBASE(PREHEAT_CASE_BED) + 3); // ABS bed temp + #endif + #if HAS_FAN + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX, MBASE(PREHEAT_CASE_FAN)); + DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN)); // ABS fan speed + #endif + #if ENABLED(EEPROM_SETTINGS) + DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE)); + DWIN_Frame_AreaCopy(1, 172, 76, 198, 86, LBLX + 33, MBASE(PREHEAT_CASE_SAVE)); // Save ABS configuration + #endif #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); + Draw_Back_First(); - break; - #endif // HAS_HOTEND + uint8_t i = 0; + Draw_Menu_Line(++i, ICON_SetEndTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].hotend_temp); + #if HAS_HEATED_BED + Draw_Menu_Line(++i, ICON_SetBedTemp); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].bed_temp); + #endif + #if HAS_FAN + Draw_Menu_Line(++i, ICON_FanSpeed); + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Background_black, 3, 216, MBASE(i), ui.material_preset[1].fan_speed); + #endif + #if ENABLED(EEPROM_SETTINGS) + Draw_Menu_Line(++i, ICON_WriteEEPROM); + #endif + + } break; + + #endif // HAS_HOTEND } } DWIN_UpdateLCD(); @@ -2659,18 +2926,18 @@ inline void Draw_Max_Speed_Menu() { DWIN_Frame_TitleCopy(1, 1, 16, 28, 28); // "Max Speed (mm/s)" auto say_max_speed = [](const uint16_t row) { - DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, row); // "Max speed" + DWIN_Frame_AreaCopy(1, 173, 133, 228, 147, LBLX, row); // "Max speed" }; - say_max_speed(MBASE(1)); // "Max speed" - DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(1)); // X - say_max_speed(MBASE(2)); // "Max speed" - DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(2) + 3); // Y - say_max_speed(MBASE(3)); // "Max speed" - DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(3) + 3); // Z + say_max_speed(MBASE(1)); // "Max speed" + DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(1)); // X + say_max_speed(MBASE(2)); // "Max speed" + DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(2) + 3); // Y + say_max_speed(MBASE(3)); // "Max speed" + DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(3) + 3); // Z #if HAS_HOTEND - say_max_speed(MBASE(4)); // "Max speed" - DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(4) + 3); // E + say_max_speed(MBASE(4)); // "Max speed" + DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(4) + 3); // E #endif } else { @@ -2745,7 +3012,7 @@ inline void Draw_Max_Accel_Menu() { DWIN_Draw_String(false, true, font8x16, White, Background_black, LBLX, MBASE(4), F("Max Accel E")); #endif #else - DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Acceleration" + DWIN_Frame_TitleCopy(1, 144, 16, 189, 26); // "Acceleration" draw_max_accel_en(MBASE(1)); say_x(108, MBASE(1)); // "Max Acceleration X" draw_max_accel_en(MBASE(2)); say_y(108, MBASE(2)); // "Max Acceleration Y" draw_max_accel_en(MBASE(3)); say_z(108, MBASE(3)); // "Max Acceleration Z" @@ -2883,13 +3150,13 @@ inline void Draw_Steps_Menu() { } /* Motion */ -void HMI_Motion(void) { +void HMI_Motion() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_motion.inc(4)) Move_Highlight(1, select_motion.now); + if (select_motion.inc(1 + MOTION_CASE_TOTAL)) Move_Highlight(1, select_motion.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_motion.dec()) Move_Highlight(-1, select_motion.now); @@ -2898,26 +3165,28 @@ void HMI_Motion(void) { switch (select_motion.now) { case 0: // Back checkkey = Control; - select_control.set(2); + select_control.set(CONTROL_CASE_MOVE); index_control = MROWS; Draw_Control_Menu(); break; - case 1: // max speed + case MOTION_CASE_RATE: // Max speed checkkey = MaxSpeed; select_speed.reset(); Draw_Max_Speed_Menu(); break; - case 2: // max acceleration + case MOTION_CASE_ACCEL: // Max acceleration checkkey = MaxAcceleration; select_acc.reset(); Draw_Max_Accel_Menu(); break; - case 3: // max jerk speed - checkkey = MaxJerk; - select_jerk.reset(); - Draw_Max_Jerk_Menu(); - break; - case 4: // transmission ratio + #if HAS_CLASSIC_JERK + case MOTION_CASE_JERK: // Max jerk + checkkey = MaxJerk; + select_jerk.reset(); + Draw_Max_Jerk_Menu(); + break; + #endif + case MOTION_CASE_STEPS: // Steps per mm checkkey = Step; select_step.reset(); Draw_Steps_Menu(); @@ -2929,13 +3198,13 @@ void HMI_Motion(void) { } /* Info */ -void HMI_Info(void) { +void HMI_Info() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_ENTER) { #if HAS_ONESTEP_LEVELING checkkey = Control; - select_control.set(CONTROL_ITEMS); + select_control.set(CONTROL_CASE_INFO); Draw_Control_Menu(); #else select_page.set(3); @@ -2946,17 +3215,16 @@ void HMI_Info(void) { } /* Tune */ -void HMI_Tune(void) { +void HMI_Tune() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_tune.inc(6)) { + if (select_tune.inc(1 + TUNE_CASE_TOTAL)) { if (select_tune.now > MROWS && select_tune.now > index_tune) { index_tune = select_tune.now; Scroll_Menu(DWIN_SCROLL_UP); - Prepare_Item_Lang(5); } else { Move_Highlight(1, select_tune.now + MROWS - index_tune); @@ -2982,186 +3250,180 @@ void HMI_Tune(void) { Goto_PrintProcess(); } break; - case 1: // Print speed + case TUNE_CASE_SPEED: // Print speed checkkey = PrintSpeed; HMI_ValueStruct.print_speed = feedrate_percentage; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1 + MROWS - index_tune), feedrate_percentage); - EncoderRate.encoderRateEnabled = 1; - break; - #if HAS_HOTEND - case 2: // Nozzle temp - checkkey = ETemp; - HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2 + MROWS - index_tune), thermalManager.temp_hotend[0].target); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_HEATED_BED - case 3: // Bed temp - checkkey = BedTemp; - HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3 + MROWS - index_tune), thermalManager.temp_bed.target); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - #if HAS_FAN - case 4: // Fan speed - checkkey = FanSpeed; - HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(4 + MROWS - index_tune), thermalManager.fan_speed[0]); - EncoderRate.encoderRateEnabled = 1; - break; - #endif - case 5: // Z-offset - 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; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), feedrate_percentage); + EncoderRate.enabled = true; break; - case 6: // Language - // Select language - HMI_flag.language_chinese ^= true; - - Clear_Main_Window(); - - if (HMI_flag.language_chinese) { - HMI_SetAndSaveLanguageChinese(); - DWIN_JPG_CacheTo1(Language_Chinese); - } - else { - HMI_SetAndSaveLanguageWestern(); - DWIN_JPG_CacheTo1(Language_English); - } - - Draw_Tune_Menu(); + #if HAS_HOTEND + case TUNE_CASE_TEMP: // Nozzle temp + checkkey = ETemp; + HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target); + EncoderRate.enabled = true; + break; + #endif + #if HAS_HEATED_BED + case TUNE_CASE_BED: // Bed temp + checkkey = BedTemp; + HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target); + EncoderRate.enabled = true; + break; + #endif + #if HAS_FAN + case TUNE_CASE_FAN: // Fan speed + checkkey = FanSpeed; + HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0]; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]); + EncoderRate.enabled = true; + break; + #endif + #if HAS_ZOFFSET_ITEM + case TUNE_CASE_ZOFF: // Z-offset + #if EITHER(HAS_BED_PROBE, BABYSTEPPING) + checkkey = Homeoffset; + HMI_ValueStruct.offset_value = BABY_Z_VAR * 100; + DWIN_Draw_Signed_Float(font8x16, Select_Color, 2, 2, 202, MBASE(TUNE_CASE_ZOFF + MROWS - index_tune), HMI_ValueStruct.offset_value); + EncoderRate.enabled = true; + #else + // Apply workspace offset, making the current position 0,0,0 + queue.inject_P(PSTR("G92 X0 Y0 Z0")); + HMI_AudioFeedback(); + #endif break; - + #endif default: break; } } DWIN_UpdateLCD(); } -/* PLA Preheat */ -void HMI_PLAPreheatSetting(void) { - ENCODER_DiffState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; +#if HAS_PREHEAT - // Avoid flicker by updating only the previous menu - if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_PLA.inc(4)) Move_Highlight(1, select_PLA.now); - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - if (select_PLA.dec()) Move_Highlight(-1, select_PLA.now); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - switch (select_PLA.now) { - case 0: // Back - checkkey = TemperatureID; - select_temp.now = 4; - HMI_ValueStruct.show_mode = -1; - Draw_Temperature_Menu(); - break; + /* PLA Preheat */ + void HMI_PLAPreheatSetting() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_PLA.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_PLA.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_PLA.dec()) Move_Highlight(-1, select_PLA.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_PLA.now) { + case 0: // Back + checkkey = TemperatureID; + select_temp.now = TEMP_CASE_PLA; + HMI_ValueStruct.show_mode = -1; + Draw_Temperature_Menu(); + break; #if HAS_HOTEND - case 1: // set nozzle temperature + case PREHEAT_CASE_TEMP: // Nozzle temperature checkkey = ETemp; HMI_ValueStruct.E_Temp = ui.material_preset[0].hotend_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), ui.material_preset[0].hotend_temp); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[0].hotend_temp); + EncoderRate.enabled = true; break; #endif #if HAS_HEATED_BED - case 2: // set bed temperature + case PREHEAT_CASE_BED: // Bed temperature checkkey = BedTemp; HMI_ValueStruct.Bed_Temp = ui.material_preset[0].bed_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), ui.material_preset[0].bed_temp); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[0].bed_temp); + EncoderRate.enabled = true; break; #endif #if HAS_FAN - case 3: // set fan speed + case PREHEAT_CASE_FAN: // Fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = ui.material_preset[0].fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), ui.material_preset[0].fan_speed); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[0].fan_speed); + EncoderRate.enabled = true; break; #endif - #if ENABLED(EEPROM_SETTINGS) - case 4: { // Save PLA configuration - const bool success = settings.save(); - HMI_AudioFeedback(success); - } break; - #endif - default: break; + #if ENABLED(EEPROM_SETTINGS) + case 4: { // Save PLA configuration + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + #endif + default: break; + } } + DWIN_UpdateLCD(); } - DWIN_UpdateLCD(); -} -/* ABS Preheat */ -void HMI_ABSPreheatSetting(void) { - ENCODER_DiffState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; + /* ABS Preheat */ + void HMI_ABSPreheatSetting() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; - // Avoid flicker by updating only the previous menu - if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_ABS.inc(4)) Move_Highlight(1, select_ABS.now); - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - switch (select_ABS.now) { - case 0: // Back - checkkey = TemperatureID; - select_temp.now = 5; - HMI_ValueStruct.show_mode = -1; - Draw_Temperature_Menu(); - break; + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now); + } + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + switch (select_ABS.now) { + case 0: // Back + checkkey = TemperatureID; + select_temp.now = TEMP_CASE_ABS; + HMI_ValueStruct.show_mode = -1; + Draw_Temperature_Menu(); + break; #if HAS_HOTEND - case 1: // set nozzle temperature + case PREHEAT_CASE_TEMP: // Set nozzle temperature checkkey = ETemp; HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(1), ui.material_preset[1].hotend_temp); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_TEMP), ui.material_preset[1].hotend_temp); + EncoderRate.enabled = true; break; #endif #if HAS_HEATED_BED - case 2: // set bed temperature + case PREHEAT_CASE_BED: // Set bed temperature checkkey = BedTemp; HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(2), ui.material_preset[1].bed_temp); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_BED), ui.material_preset[1].bed_temp); + EncoderRate.enabled = true; break; #endif #if HAS_FAN - case 3: // set fan speed + case PREHEAT_CASE_FAN: // Set fan speed checkkey = FanSpeed; HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(3), ui.material_preset[1].fan_speed); - EncoderRate.encoderRateEnabled = 1; + DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 3, 216, MBASE(PREHEAT_CASE_FAN), ui.material_preset[1].fan_speed); + EncoderRate.enabled = true; break; #endif - #if ENABLED(EEPROM_SETTINGS) - case 4: { // save ABS configuration - const bool success = settings.save(); - HMI_AudioFeedback(success); - } break; - #endif - default: break; + #if ENABLED(EEPROM_SETTINGS) + case PREHEAT_CASE_SAVE: { // Save ABS configuration + const bool success = settings.save(); + HMI_AudioFeedback(success); + } break; + #endif + default: break; + } } + DWIN_UpdateLCD(); } - DWIN_UpdateLCD(); -} + +#endif /* Max Speed */ -void HMI_MaxSpeed(void) { +void HMI_MaxSpeed() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_speed.inc(4)) Move_Highlight(1, select_speed.now); + if (select_speed.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_speed.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_speed.dec()) Move_Highlight(-1, select_speed.now); @@ -3169,14 +3431,14 @@ void HMI_MaxSpeed(void) { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (WITHIN(select_speed.now, 1, 4)) { checkkey = MaxSpeed_value; - HMI_flag.feedspeed_flag = AxisEnum(select_speed.now - 1); - HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[HMI_flag.feedspeed_flag]; + HMI_flag.feedspeed_axis = AxisEnum(select_speed.now - 1); + HMI_ValueStruct.Max_Feedspeed = planner.settings.max_feedrate_mm_s[HMI_flag.feedspeed_axis]; DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_speed.now), HMI_ValueStruct.Max_Feedspeed); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; } else { // Back checkkey = Motion; - select_motion.now = 1; + select_motion.now = MOTION_CASE_RATE; Draw_Motion_Menu(); } } @@ -3184,13 +3446,13 @@ void HMI_MaxSpeed(void) { } /* Max Acceleration */ -void HMI_MaxAcceleration(void) { +void HMI_MaxAcceleration() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_acc.inc(4)) Move_Highlight(1, select_acc.now); + if (select_acc.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_acc.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_acc.dec()) Move_Highlight(-1, select_acc.now); @@ -3198,57 +3460,59 @@ void HMI_MaxAcceleration(void) { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (WITHIN(select_acc.now, 1, 4)) { checkkey = MaxAcceleration_value; - HMI_flag.acc_flag = AxisEnum(select_acc.now - 1); - HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[HMI_flag.acc_flag]; + HMI_flag.acc_axis = AxisEnum(select_acc.now - 1); + HMI_ValueStruct.Max_Acceleration = planner.settings.max_acceleration_mm_per_s2[HMI_flag.acc_axis]; DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_acc.now), HMI_ValueStruct.Max_Acceleration); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; } else { // Back checkkey = Motion; - select_motion.now = 2; + select_motion.now = MOTION_CASE_ACCEL; Draw_Motion_Menu(); } } DWIN_UpdateLCD(); } -/* Max Jerk */ -void HMI_MaxJerk(void) { - ENCODER_DiffState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; +#if HAS_CLASSIC_JERK + /* Max Jerk */ + void HMI_MaxJerk() { + ENCODER_DiffState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; - // Avoid flicker by updating only the previous menu - if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_jerk.inc(4)) Move_Highlight(1, select_jerk.now); - } - else if (encoder_diffState == ENCODER_DIFF_CCW) { - if (select_jerk.dec()) Move_Highlight(-1, select_jerk.now); - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (WITHIN(select_jerk.now, 1, 4)) { - checkkey = MaxJerk_value; - HMI_flag.jerk_flag = AxisEnum(select_jerk.now - 1); - HMI_ValueStruct.Max_Jerk = planner.max_jerk[HMI_flag.jerk_flag] * MINUNITMULT; - DWIN_Draw_IntValue(true, true, 0, font8x16, White, Select_Color, 4, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); - EncoderRate.encoderRateEnabled = 1; + // Avoid flicker by updating only the previous menu + if (encoder_diffState == ENCODER_DIFF_CW) { + if (select_jerk.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_jerk.now); } - else { // Back - checkkey = Motion; - select_motion.now = 3; - Draw_Motion_Menu(); + else if (encoder_diffState == ENCODER_DIFF_CCW) { + if (select_jerk.dec()) Move_Highlight(-1, select_jerk.now); + } + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (WITHIN(select_jerk.now, 1, 4)) { + checkkey = MaxJerk_value; + HMI_flag.jerk_axis = AxisEnum(select_jerk.now - 1); + HMI_ValueStruct.Max_Jerk = planner.max_jerk[HMI_flag.jerk_axis] * MINUNITMULT; + DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk); + EncoderRate.enabled = true; + } + else { // Back + checkkey = Motion; + select_motion.now = MOTION_CASE_JERK; + Draw_Motion_Menu(); + } } + DWIN_UpdateLCD(); } - DWIN_UpdateLCD(); -} +#endif // HAS_CLASSIC_JERK /* Step */ -void HMI_Step(void) { +void HMI_Step() { ENCODER_DiffState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; // Avoid flicker by updating only the previous menu if (encoder_diffState == ENCODER_DIFF_CW) { - if (select_step.inc(4)) Move_Highlight(1, select_step.now); + if (select_step.inc(1 + 3 + ENABLED(HAS_HOTEND))) Move_Highlight(1, select_step.now); } else if (encoder_diffState == ENCODER_DIFF_CCW) { if (select_step.dec()) Move_Highlight(-1, select_step.now); @@ -3256,21 +3520,21 @@ void HMI_Step(void) { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (WITHIN(select_step.now, 1, 4)) { checkkey = Step_value; - HMI_flag.step_flag = AxisEnum(select_step.now - 1); - HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[HMI_flag.step_flag] * MINUNITMULT; + HMI_flag.step_axis = AxisEnum(select_step.now - 1); + HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[HMI_flag.step_axis] * MINUNITMULT; DWIN_Draw_FloatValue(true, true, 0, font8x16, White, Select_Color, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step); - EncoderRate.encoderRateEnabled = 1; + EncoderRate.enabled = true; } else { // Back checkkey = Motion; - select_motion.now = 4; + select_motion.now = MOTION_CASE_STEPS; Draw_Motion_Menu(); } } DWIN_UpdateLCD(); } -void HMI_Init(void) { +void HMI_Init() { HMI_SDCardInit(); for (uint16_t t = 0; t <= 100; t += 2) { @@ -3283,13 +3547,13 @@ void HMI_Init(void) { HMI_SetLanguage(); } -void DWIN_Update(void) { +void DWIN_Update() { EachMomentUpdate(); // Status update HMI_SDCardUpdate(); // SD card update DWIN_HandleScreen(); // Rotary encoder update } -void EachMomentUpdate(void) { +void EachMomentUpdate() { static millis_t next_rts_update_ms = 0; const millis_t ms = millis(); if (PENDING(ms, next_rts_update_ms)) return; @@ -3300,9 +3564,9 @@ void EachMomentUpdate(void) { if (checkkey == PrintProcess) { // if print done - if (HMI_flag.print_finish && !HMI_flag.confirm_flag) { - HMI_flag.print_finish = 0; - HMI_flag.confirm_flag = 1; + if (HMI_flag.print_finish && !HMI_flag.done_confirm_flag) { + HMI_flag.print_finish = false; + HMI_flag.done_confirm_flag = true; TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); @@ -3313,7 +3577,7 @@ void EachMomentUpdate(void) { Draw_Print_ProgressBar(); // show print done confirm - DWIN_Draw_Rectangle(1, Background_black, 0, 250, 271, 360); + DWIN_Draw_Rectangle(1, Background_black, 0, 250, DWIN_WIDTH - 1, STATUS_Y); DWIN_ICON_Show(ICON, HMI_flag.language_chinese ? ICON_Confirm_C : ICON_Confirm_E, 86, 283); } else if (HMI_flag.pause_flag != printingIsPaused()) { @@ -3324,11 +3588,15 @@ void EachMomentUpdate(void) { } // pause after homing - if (pause_action_flag && printingIsPaused() && !planner.has_blocks_queued()) { - pause_action_flag = 0; + if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) { + HMI_flag.pause_action = false; #if ENABLED(PAUSE_HEAT) - tempbed = thermalManager.temp_bed.target; - temphot = thermalManager.temp_hotend[0].target; + #if HAS_HEATED_BED + tempbed = thermalManager.temp_bed.target; + #endif + #if HAS_HOTEND + temphot = thermalManager.temp_hotend[0].target; + #endif thermalManager.disable_all_heaters(); #endif queue.inject_P(PSTR("G1 F1200 X0 Y0")); @@ -3348,6 +3616,7 @@ void EachMomentUpdate(void) { duration_t elapsed = print_job_timer.duration(); // print timer // Print time so far + static uint16_t last_Printtime = 0; const uint16_t min = (elapsed.value % 3600) / 60; if (last_Printtime != min) { // 1 minute update last_Printtime = min; @@ -3356,14 +3625,14 @@ void EachMomentUpdate(void) { // Estimate remaining time every 20 seconds static millis_t next_remain_time_update = 0; - if (Percentrecord > 1 && ELAPSED(ms, next_remain_time_update) && HMI_flag.heat_flag == 0) { + if (Percentrecord > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) { remain_time = (elapsed.value - dwin_heat_time) / (Percentrecord * 0.01f) - (elapsed.value - dwin_heat_time); next_remain_time_update += 20 * 1000UL; Draw_Print_ProgressRemain(); } } - else if (abort_flag && !HMI_flag.home_flag) { // Print Stop - abort_flag = 0; + else if (dwin_abort_flag && !HMI_flag.home_flag) { // Print Stop + dwin_abort_flag = false; HMI_ValueStruct.print_speed = feedrate_percentage = 100; dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); @@ -3378,6 +3647,7 @@ void EachMomentUpdate(void) { } #if ENABLED(POWER_LOSS_RECOVERY) else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off + static bool recovery_flag = false; recovery.dwin_flag = false; recovery.load(); @@ -3403,8 +3673,8 @@ void EachMomentUpdate(void) { // 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; + recovery_flag = true; + HMI_flag.select_flag = true; Popup_Window_Resume(); draw_first_option(false); char * const name = card.longest_filename(); @@ -3422,7 +3692,7 @@ void EachMomentUpdate(void) { ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState == ENCODER_DIFF_ENTER) { - recovery_flag = 0; + recovery_flag = false; if (HMI_flag.select_flag) break; TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); HMI_StartFrame(true); @@ -3445,7 +3715,7 @@ void EachMomentUpdate(void) { DWIN_UpdateLCD(); } -void DWIN_HandleScreen(void) { +void DWIN_HandleScreen() { switch (checkkey) { case MainMenu: HMI_MainMenu(); break; case SelectFile: HMI_SelectFile(); break; @@ -3459,8 +3729,10 @@ void DWIN_HandleScreen(void) { case Motion: HMI_Motion(); break; case Info: HMI_Info(); break; case Tune: HMI_Tune(); break; - case PLAPreheat: HMI_PLAPreheatSetting(); break; - case ABSPreheat: HMI_ABSPreheatSetting(); break; + #if HAS_PREHEAT + case PLAPreheat: HMI_PLAPreheatSetting(); break; + case ABSPreheat: HMI_ABSPreheatSetting(); break; + #endif case MaxSpeed: HMI_MaxSpeed(); break; case MaxAcceleration: HMI_MaxAcceleration(); break; case MaxJerk: HMI_MaxJerk(); break; @@ -3472,11 +3744,13 @@ void DWIN_HandleScreen(void) { case Extruder: HMI_Move_E(); break; case ETemp: HMI_ETemp(); break; #endif - case Homeoffset: HMI_Zoffset(); break; + #if EITHER(HAS_BED_PROBE, BABYSTEPPING) + case Homeoffset: HMI_Zoffset(); break; + #endif #if HAS_HEATED_BED case BedTemp: HMI_BedTemp(); break; #endif - #if HAS_FAN + #if HAS_PREHEAT case FanSpeed: HMI_FanSpeed(); break; #endif case PrintSpeed: HMI_PrintSpeed(); break; @@ -3488,11 +3762,11 @@ void DWIN_HandleScreen(void) { } } -void DWIN_CompletedHoming(void) { +void DWIN_CompletedHoming() { HMI_flag.home_flag = false; if (checkkey == Last_Prepare) { checkkey = Prepare; - select_prepare.now = 3; + select_prepare.now = PREPARE_CASE_HOME; index_prepare = MROWS; Draw_Prepare_Menu(); } @@ -3504,7 +3778,7 @@ void DWIN_CompletedHoming(void) { } } -void DWIN_CompletedLeveling(void) { +void DWIN_CompletedLeveling() { if (checkkey == Leveling) Goto_MainMenu(); } diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.h b/Marlin/src/lcd/dwin/e3v2/dwin.h index abdf343a9ded..fedb87afdd81 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.h +++ b/Marlin/src/lcd/dwin/e3v2/dwin.h @@ -29,9 +29,16 @@ #include "rotary_encoder.h" #include "../../../libs/BL24CXX.h" -#include +#include "../../../inc/MarlinConfigPre.h" -enum processID { +#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT + #define HAS_PREHEAT 1 + #if PREHEAT_COUNT < 2 + #error "Creality DWIN requires two material preheat presets." + #endif +#endif + +enum processID : uint8_t { // Process ID MainMenu, SelectFile, @@ -44,7 +51,7 @@ enum processID { Motion, Info, Tune, - #if HAS_HOTEND + #if HAS_PREHEAT PLAPreheat, ABSPreheat, #endif @@ -218,7 +225,7 @@ enum processID { #define BarFill_Color 0x10E4 // fill color of progress bar #define Select_Color 0x33BB // selected color -extern int checkkey, last_checkkey; +extern uint8_t checkkey; extern float zprobe_zoffset; extern char print_filename[16]; @@ -227,7 +234,7 @@ extern millis_t dwin_heat_time; typedef struct { TERN_(HAS_HOTEND, int16_t E_Temp = 0); TERN_(HAS_HEATED_BED, int16_t Bed_Temp = 0); - TERN_(HAS_FAN, int16_t Fan_speed = 0); + TERN_(HAS_PREHEAT, int16_t Fan_speed = 0); int16_t print_speed = 100; float Max_Feedspeed = 0; float Max_Acceleration = 0; @@ -236,7 +243,7 @@ typedef struct { float Move_X_scale = 0; float Move_Y_scale = 0; float Move_Z_scale = 0; - #if EXTRUDERS + #if HAS_HOTEND float Move_E_scale = 0; #endif float offset_value = 0; @@ -246,33 +253,27 @@ typedef struct { typedef struct { bool language_chinese; // 0: EN, 1: CN bool pause_flag:1; + bool pause_action:1; bool print_finish:1; - bool confirm_flag:1; + bool done_confirm_flag:1; bool select_flag:1; bool home_flag:1; bool heat_flag:1; // 0: heating done 1: during heating - #if HAS_HOTEND + #if ENABLED(PREVENT_COLD_EXTRUSION) bool ETempTooLow_flag:1; #endif #if HAS_LEVELING bool leveling_offset_flag:1; #endif #if HAS_FAN - AxisEnum feedspeed_flag; + AxisEnum feedspeed_axis; #endif - AxisEnum acc_flag; - AxisEnum jerk_flag; - AxisEnum step_flag; + AxisEnum acc_axis, jerk_axis, step_axis; } HMI_Flag; extern HMI_value_t HMI_ValueStruct; extern HMI_Flag HMI_flag; -// Language -void HMI_SetLanguage(void); -void HMI_SetAndSaveLanguageWestern(void); -void HMI_SetAndSaveLanguageChinese(void); - // Show ICO void ICON_Print(bool show); void ICON_Prepare(bool show); @@ -285,44 +286,47 @@ void ICON_Pause(bool show); void ICON_Continue(bool show); void ICON_Stop(bool show); -// Popup window tips +#if HAS_HOTEND || HAS_HEATED_BED + // Popup message window + void DWIN_Popup_Temperature(const bool toohigh); +#endif + #if HAS_HOTEND - void Popup_Window_Temperature(const bool toohigh); - void Popup_Window_ETempTooLow(void); + void Popup_Window_ETempTooLow(); #endif -void Popup_Window_Resume(void); -void Popup_Window_Home(void); -void Popup_Window_Leveling(void); +void Popup_Window_Resume(); +void Popup_Window_Home(const bool parking=false); +void Popup_Window_Leveling(); -void Goto_PrintProcess(void); -void Goto_MainMenu(void); +void Goto_PrintProcess(); +void Goto_MainMenu(); // Variable control -void HMI_Move_X(void); -void HMI_Move_Y(void); -void HMI_Move_Z(void); -void HMI_Move_E(void); +void HMI_Move_X(); +void HMI_Move_Y(); +void HMI_Move_Z(); +void HMI_Move_E(); -void HMI_Zoffset(void); +void HMI_Zoffset(); -TERN_(HAS_HOTEND, void HMI_ETemp(void)); -TERN_(HAS_HEATED_BED, void HMI_BedTemp(void)); -TERN_(HAS_FAN, void HMI_FanSpeed(void)); +TERN_(HAS_HOTEND, void HMI_ETemp()); +TERN_(HAS_HEATED_BED, void HMI_BedTemp()); +TERN_(HAS_FAN, void HMI_FanSpeed()); -void HMI_PrintSpeed(void); +void HMI_PrintSpeed(); -void HMI_MaxFeedspeedXYZE(void); -void HMI_MaxAccelerationXYZE(void); -void HMI_MaxJerkXYZE(void); -void HMI_StepXYZE(void); +void HMI_MaxFeedspeedXYZE(); +void HMI_MaxAccelerationXYZE(); +void HMI_MaxJerkXYZE(); +void HMI_StepXYZE(); -void update_variable(void); +void update_variable(); 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); -void HMI_SDCardUpdate(void); +void HMI_SDCardInit(); +void HMI_SDCardUpdate(); // Main Process void Icon_print(bool value); @@ -333,32 +337,32 @@ void Icon_leveling(bool value); // Other bool Pause_HeatStatus(); void HMI_StartFrame(const bool with_update); // Startup screen -void HMI_MainMenu(void); // Main process screen -void HMI_SelectFile(void); // File page -void HMI_Printing(void); // Print page -void HMI_Prepare(void); // Prepare page -void HMI_Control(void); // Control page -void HMI_Leveling(void); // Level the page -void HMI_AxisMove(void); // Axis movement menu -void HMI_Temperature(void); // Temperature menu -void HMI_Motion(void); // Sports menu -void HMI_Info(void); // Information menu -void HMI_Tune(void); // Adjust the menu - -#if HAS_HOTEND - void HMI_PLAPreheatSetting(void); // PLA warm-up setting - void HMI_ABSPreheatSetting(void); // ABS warm-up setting +void HMI_MainMenu(); // Main process screen +void HMI_SelectFile(); // File page +void HMI_Printing(); // Print page +void HMI_Prepare(); // Prepare page +void HMI_Control(); // Control page +void HMI_Leveling(); // Level the page +void HMI_AxisMove(); // Axis movement menu +void HMI_Temperature(); // Temperature menu +void HMI_Motion(); // Sports menu +void HMI_Info(); // Information menu +void HMI_Tune(); // Adjust the menu + +#if HAS_PREHEAT + void HMI_PLAPreheatSetting(); // PLA warm-up setting + void HMI_ABSPreheatSetting(); // ABS warm-up setting #endif -void HMI_MaxSpeed(void); // Maximum speed submenu -void HMI_MaxAcceleration(void); // Maximum acceleration submenu -void HMI_MaxJerk(void); // Maximum jerk speed submenu -void HMI_Step(void); // Transmission ratio +void HMI_MaxSpeed(); // Maximum speed submenu +void HMI_MaxAcceleration(); // Maximum acceleration submenu +void HMI_MaxJerk(); // Maximum jerk speed submenu +void HMI_Step(); // Transmission ratio -void HMI_Init(void); -void DWIN_Update(void); -void EachMomentUpdate(void); -void DWIN_HandleScreen(void); +void HMI_Init(); +void DWIN_Update(); +void EachMomentUpdate(); +void DWIN_HandleScreen(); -void DWIN_CompletedHoming(void); -void DWIN_CompletedLeveling(void); +void DWIN_CompletedHoming(); +void DWIN_CompletedLeveling(); diff --git a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp index dbbd356eff2d..b1d905d9adcd 100644 --- a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp +++ b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.cpp @@ -124,7 +124,7 @@ ENCODER_DiffState Encoder_ReceiveAnalyze(void) { int32_t encoderMultiplier = 1; // if must encoder rati multiplier - if (EncoderRate.encoderRateEnabled) { + if (EncoderRate.enabled) { const float abs_diff = ABS(temp_diff), encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP); if (EncoderRate.lastEncoderTime) { diff --git a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h index fb8102f8b22a..93e54839d625 100644 --- a/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h +++ b/Marlin/src/lcd/dwin/e3v2/rotary_encoder.h @@ -44,7 +44,7 @@ #define BUTTON_PRESSED(BN) !READ(BTN_## BN) typedef struct { - bool encoderRateEnabled = 0; + bool enabled = false; int encoderMoveValue = 0; millis_t lastEncoderTime = 0; } ENCODER_Rate; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e0fa6fa98f53..d2145bcc804a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -576,7 +576,7 @@ volatile bool Temperature::raw_temps_ready = false; #define MAX_CYCLE_TIME_PID_AUTOTUNE 20L #endif if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) { - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); break; @@ -812,12 +812,16 @@ void Temperature::_temp_error(const heater_id_t heater_id, PGM_P const serial_ms } void Temperature::max_temp_error(const heater_id_t heater_id) { - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(1)); + #if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED) + DWIN_Popup_Temperature(1); + #endif _temp_error(heater_id, PSTR(STR_T_MAXTEMP), GET_TEXT(MSG_ERR_MAXTEMP)); } void Temperature::min_temp_error(const heater_id_t heater_id) { - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + #if ENABLED(DWIN_CREALITY_LCD) && (HAS_HOTEND || HAS_HEATED_BED) + DWIN_Popup_Temperature(0); + #endif _temp_error(heater_id, PSTR(STR_T_MINTEMP), GET_TEXT(MSG_ERR_MINTEMP)); } @@ -1055,7 +1059,7 @@ void Temperature::manage_heater() { // Make sure temperature is increasing if (watch_hotend[e].next_ms && ELAPSED(ms, watch_hotend[e].next_ms)) { // Time to check this extruder? if (degHotend(e) < watch_hotend[e].target) { // Failed to increase enough? - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); _temp_error((heater_id_t)e, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); } else // Start again if the target is still far off @@ -1098,7 +1102,7 @@ void Temperature::manage_heater() { // Make sure temperature is increasing if (watch_bed.elapsed(ms)) { // Time to check the bed? if (degBed() < watch_bed.target) { // Failed to increase enough? - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); _temp_error(H_BED, str_t_heating_failed, GET_TEXT(MSG_HEATING_FAILED_LCD)); } else // Start again if the target is still far off @@ -2023,7 +2027,7 @@ void Temperature::init() { state = TRRunaway; case TRRunaway: - TERN_(DWIN_CREALITY_LCD, Popup_Window_Temperature(0)); + TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); _temp_error(heater_id, str_t_thermal_runaway, GET_TEXT(MSG_THERMAL_RUNAWAY)); } } @@ -2440,14 +2444,8 @@ void Temperature::tick() { #if DISABLED(SLOW_PWM_HEATERS) - #if HAS_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER - constexpr uint8_t pwm_mask = - #if ENABLED(SOFT_PWM_DITHER) - _BV(SOFT_PWM_SCALE) - 1 - #else - 0 - #endif - ; + #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_HEATED_CHAMBER, FAN_SOFT_PWM) + constexpr uint8_t pwm_mask = TERN0(SOFT_PWM_DITHER, _BV(SOFT_PWM_SCALE) - 1); #define _PWM_MOD(N,S,T) do{ \ const bool on = S.add(pwm_mask, T.soft_pwm_amount); \ WRITE_HEATER_##N(on); \ diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index c41027003e9e..e27e628b9a0d 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -89,10 +89,6 @@ #define HAS_GCODE_M876 #endif -#if PREHEAT_COUNT - #define HAS_PREHEAT_COUNT -#endif - #if EXTRUDERS #define HAS_EXTRUDERS #if EXTRUDERS > 1 diff --git a/platformio.ini b/platformio.ini index d97522dac138..2ef6189712da 100644 --- a/platformio.ini +++ b/platformio.ini @@ -173,7 +173,6 @@ HOST_KEEPALIVE_FEATURE = src_filter=+ REPETIER_GCODE_M360 = src_filter=+ HAS_GCODE_M876 = src_filter=+ HAS_RESUME_CONTINUE = src_filter=+ -HAS_PREHEAT_COUNT = src_filter=+ HAS_LCD_CONTRAST = src_filter=+ LCD_SET_PROGRESS_MANUALLY = src_filter=+ TOUCH_SCREEN_CALIBRATION = src_filter=+