diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 83cb66fae4..83d149fa09 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -410,7 +410,6 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool #endif TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR))); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); // Indicate that the printer is paused ++did_pause_print; @@ -461,6 +460,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool // If axes don't need to home then the nozzle can park if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move + TERN_(DWIN_LCD_PROUI, if (!do_park) ui.set_status(GET_TEXT_F(MSG_PARK_FAILED))); #if ENABLED(DUAL_X_CARRIAGE) const int8_t saved_ext = active_extruder; @@ -710,13 +710,8 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HAS_FILAMENT_SENSOR, runout.reset()); - #if ENABLED(DWIN_LCD_PROUI) - DWIN_Print_Resume(); - HMI_ReturnScreen(); - #else - ui.reset_status(); - ui.return_to_status(); - #endif + ui.reset_status(); + ui.return_to_status(); } #endif // ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/gcode/config/M302.cpp b/Marlin/src/gcode/config/M302.cpp index 9f4d569d7b..12408c8987 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -28,7 +28,7 @@ #include "../../module/temperature.h" #if ENABLED(DWIN_LCD_PROUI) - #include "../../lcd/e3v2/proui/dwin_defines.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif /** diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index 8dbe2fb07e..942d20afd2 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -47,7 +47,7 @@ void GcodeSuite::M145() { preheat_t &mat = ui.material_preset[material]; #if HAS_HOTEND if (parser.seenval('H')) - mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0)); + mat.hotend_temp = constrain(parser.value_int(), thermalManager.extrude_min_temp, thermalManager.hotend_max_target(0)); #endif #if HAS_HEATED_BED if (parser.seenval('B')) diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index f404358862..c7728a5a47 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -109,7 +109,6 @@ void GcodeSuite::M1001() { #endif TERN_(EXTENSIBLE_UI, ExtUI::onPrintDone()); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); // Re-select the last printed file in the UI TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file()); diff --git a/Marlin/src/gcode/sd/M524.cpp b/Marlin/src/gcode/sd/M524.cpp index 001a1e1842..f2b9274223 100644 --- a/Marlin/src/gcode/sd/M524.cpp +++ b/Marlin/src/gcode/sd/M524.cpp @@ -28,7 +28,7 @@ #include "../../sd/cardreader.h" #if ENABLED(DWIN_LCD_PROUI) - #include "../../lcd/e3v2/proui/dwin.h" + #include "../../lcd/marlinui.h" #endif /** @@ -38,7 +38,7 @@ void GcodeSuite::M524() { #if ENABLED(DWIN_LCD_PROUI) - HMI_flag.abort_flag = true; // The LCD will handle it + ui.abort_print(); #else diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 0ed1e66930..2ff04797eb 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -39,7 +39,6 @@ void GcodeSuite::M75() { startOrResumeJob(); #if ENABLED(DWIN_LCD_PROUI) - DWIN_Print_Started(false); if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); #endif } @@ -48,9 +47,8 @@ void GcodeSuite::M75() { * M76: Pause print timer */ void GcodeSuite::M76() { - print_job_timer.pause(); + TERN(DWIN_LCD_PROUI, ui.pause_print(), print_job_timer.pause()); TERN_(HOST_PAUSE_M76, hostui.pause()); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); } /** @@ -58,7 +56,6 @@ void GcodeSuite::M76() { */ void GcodeSuite::M77() { print_job_timer.stop(); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); } #if ENABLED(PRINTCOUNTER) diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index a4d514c733..449748abf1 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -86,7 +86,7 @@ void GcodeSuite::M303() { #if ENABLED(DWIN_LCD_PROUI) if (seenC) HMI_data.PidCycles = c; - if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; } + if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else TERN_(PIDTEMP, HMI_data.HotendPidT = temp); } #endif #if DISABLED(BUSY_WHILE_HEATING) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 18a28130eb..b9bcb4d0d2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2472,6 +2472,7 @@ #define BED_MAX_TARGET (BED_MAXTEMP - (BED_OVERSHOOT)) #else #undef PIDTEMPBED + #undef PREHEAT_BEFORE_LEVELING #endif #if HAS_TEMP_COOLER && PIN_EXISTS(COOLER) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index aabb93e8f2..d82313461a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -940,8 +940,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SD_REPRINT_LAST_SELECTED_FILE currently requires a Marlin-native LCD menu." #endif -#if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, EXTENSIBLE_UI) && !defined(MANUAL_FEEDRATE) - #error "MANUAL_FEEDRATE is required for MarlinUI, ExtUI, or FTDI EVE Touch UI." +#if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, EXTENSIBLE_UI, DWIN_LCD_PROUI) && !defined(MANUAL_FEEDRATE) + #error "MANUAL_FEEDRATE is required for ProUI, MarlinUI, ExtUI, or FTDI EVE Touch UI." #endif /** diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index e967c26198..c4f43eab10 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -19,27 +19,37 @@ * along with this program. If not, see . * */ - + /** * Bed Level Tools for Pro UI * Extended by: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.0.0 - * Date: 2022/05/23 - * + * Version: 2.1.0 + * Date: 2022/08/27 + * * Based on the original work of: Henri-J-Norden * https://github.com/Jyers/Marlin/pull/126 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * */ #include "../../../inc/MarlinConfigPre.h" -#include "bedlevel_tools.h" #if BOTH(DWIN_LCD_PROUI, HAS_LEVELING) #include "../../marlinui.h" #include "../../../core/types.h" -#include "dwin.h" -#include "dwinui.h" -#include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" #include "../../../module/probe.h" #include "../../../gcode/gcode.h" @@ -48,9 +58,14 @@ #include "../../../libs/least_squares_fit.h" #include "../../../libs/vector_3.h" -BedLevelToolsClass BedLevelTools; +#include "dwin.h" +#include "dwinui.h" +#include "dwin_popup.h" +#include "bedlevel_tools.h" -#if USE_UBL_VIEWER +BedLevelToolsClass bedLevelTools; + +#if ENABLED(USE_UBL_VIEWER) bool BedLevelToolsClass::viewer_asymmetric_range = false; bool BedLevelToolsClass::viewer_print_value = false; #endif @@ -153,26 +168,30 @@ void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, } } +// Move / Probe methods. As examples, not yet used. void BedLevelToolsClass::MoveToXYZ() { - BedLevelTools.goto_mesh_value = true; - BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false); + bedLevelTools.goto_mesh_value = true; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, false); } void BedLevelToolsClass::MoveToXY() { - BedLevelTools.goto_mesh_value = false; - BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, false); + bedLevelTools.goto_mesh_value = false; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, false); } void BedLevelToolsClass::MoveToZ() { - BedLevelTools.goto_mesh_value = true; - BedLevelTools.manual_move(BedLevelTools.mesh_x, BedLevelTools.mesh_y, true); + bedLevelTools.goto_mesh_value = true; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, true); } void BedLevelToolsClass::ProbeXY() { - sprintf_P(cmd, PSTR("G30X%sY%s"), - dtostrf(bedlevel.get_mesh_x(BedLevelTools.mesh_x), 1, 2, str_1), - dtostrf(bedlevel.get_mesh_y(BedLevelTools.mesh_y), 1, 2, str_2) + const uint16_t Clear = Z_CLEARANCE_DEPLOY_PROBE; + sprintf_P(cmd, PSTR("G0Z%i\nG30X%sY%s"), + Clear, + dtostrf(bedlevel.get_mesh_x(bedLevelTools.mesh_x), 1, 2, str_1), + dtostrf(bedlevel.get_mesh_y(bedLevelTools.mesh_y), 1, 2, str_2) ); gcode.process_subcommands_now(cmd); } +// Accessors float BedLevelToolsClass::get_max_value() { float max = __FLT_MAX__ * -1; GRID_LOOP(x, y) { @@ -191,18 +210,16 @@ float BedLevelToolsClass::get_min_value() { return min; } +// Return 'true' if mesh is good and within LCD limits bool BedLevelToolsClass::meshvalidate() { - float min = __FLT_MAX__, max = __FLT_MAX__ * -1; - GRID_LOOP(x, y) { - if (isnan(bedlevel.z_values[x][y])) return false; - if (bedlevel.z_values[x][y] < min) min = bedlevel.z_values[x][y]; - if (bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; + const float v = bedlevel.z_values[x][y]; + if (isnan(v) || !WITHIN(v, UBL_Z_OFFSET_MIN, UBL_Z_OFFSET_MAX)) return false; } - return WITHIN(max, MESH_Z_OFFSET_MIN, MESH_Z_OFFSET_MAX); + return true; } -#if USE_UBL_VIEWER +#if ENABLED(USE_UBL_VIEWER) void BedLevelToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) { drawing_mesh = true; diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 9373d593f9..b476cb38b6 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -23,27 +23,38 @@ /** * Bed Level Tools for Pro UI * Extended by: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.0.0 - * Date: 2022/05/23 - * + * Version: 2.1.0 + * Date: 2022/08/27 + * * Based on the original work of: Henri-J-Norden * https://github.com/Jyers/Marlin/pull/126 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * */ - #pragma once #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(AUTO_BED_LEVELING_UBL) - //#define USE_UBL_VIEWER 1 -#endif +//#define USE_UBL_VIEWER 1 -#define MESH_Z_OFFSET_MIN -3.0 -#define MESH_Z_OFFSET_MAX 3.0 +#define UBL_Z_OFFSET_MIN -3.0 +#define UBL_Z_OFFSET_MAX 3.0 class BedLevelToolsClass { public: - #if USE_UBL_VIEWER + #if ENABLED(USE_UBL_VIEWER) static bool viewer_asymmetric_range; static bool viewer_print_value; #endif @@ -66,12 +77,10 @@ public: static float get_max_value(); static float get_min_value(); static bool meshvalidate(); - #if USE_UBL_VIEWER + #if ENABLED(USE_UBL_VIEWER) static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); static void Set_Mesh_Viewer_Status(); #endif }; -extern BedLevelToolsClass BedLevelTools; - -void Goto_MeshViewer(); +extern BedLevelToolsClass bedLevelTools; diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index fcceb2d52d..a5570026d0 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -23,8 +23,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.2 - * Date: 2022/04/08 + * Version: 3.21.2 + * Date: 2022/12/02 */ #include "../../../inc/MarlinConfig.h" @@ -62,10 +62,6 @@ #warning "MESH_EDIT_MENU is recommended with ProUI." #endif -#include "dwin.h" -#include "menus.h" -#include "dwin_popup.h" - #include "../../fontutils.h" #include "../../marlinui.h" @@ -78,6 +74,7 @@ #include "../../../module/temperature.h" #include "../../../module/printcounter.h" #include "../../../module/motion.h" +#include "../../../module/stepper.h" #include "../../../module/planner.h" #include "../../../gcode/gcode.h" @@ -126,22 +123,6 @@ #include "../../../feature/powerloss.h" #endif -#if HAS_ESDIAG - #include "endstop_diag.h" -#endif - -#if HAS_PIDPLOT - #include "plot.h" -#endif - -#if HAS_GCODE_PREVIEW - #include "gcode_preview.h" -#endif - -#if HAS_MESH - #include "meshviewer.h" -#endif - #if ENABLED(PRINTCOUNTER) #include "printstats.h" #endif @@ -154,18 +135,40 @@ #include "../../../feature/leds/leds.h" #endif +#include "dwin.h" +#include "dwinui.h" +#include "menus.h" +#include "dwin_popup.h" + +#if HAS_GCODE_PREVIEW + #include "gcode_preview.h" +#endif + +#if HAS_ESDIAG + #include "endstop_diag.h" +#endif + +#if HAS_PIDPLOT + #include "plot.h" +#endif + +#if HAS_MESH + #include "meshviewer.h" +#endif + #if HAS_LOCKSCREEN #include "lockscreen.h" #endif +#define DEBUG_OUT ENABLED(DEBUG_DWIN) +#include "../../../core/debug_out.h" + #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif #define PAUSE_HEAT -#define MENU_CHAR_LIMIT 24 - // Print speed limit #define MIN_PRINT_SPEED 10 #define MAX_PRINT_SPEED 999 @@ -186,32 +189,21 @@ // Editable temperature limits #define MIN_ETEMP 0 -#define MAX_ETEMP (HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT)) +#define MAX_ETEMP (thermalManager.hotend_maxtemp[0] - (HOTEND_OVERSHOOT)) #define MIN_BEDTEMP 0 #define MAX_BEDTEMP BED_MAX_TARGET -#define FEEDRATE_E (60) - #define DWIN_VAR_UPDATE_INTERVAL 1024 -#define DWIN_SCROLL_UPDATE_INTERVAL SEC_TO_MS(2) +#define DWIN_UPDATE_INTERVAL 1024 #define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20) -#if HAS_MESH - #define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset) -#else - float z_offset = 0; - #define BABY_Z_VAR z_offset -#endif +#define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset) // Structs HMI_value_t HMI_value; HMI_flag_t HMI_flag{0}; HMI_data_t HMI_data; -millis_t dwin_heat_time = 0; - -uint8_t checkkey = 255, last_checkkey = MainMenu; - enum SelectItem : uint8_t { PAGE_PRINT = 0, PAGE_PREPARE, @@ -233,11 +225,7 @@ typedef struct { bool dec() { if (now) now--; 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}; -uint8_t index_file = MROWS; - -bool hash_changed = true; // Flag to know if message status was changed +select_t select_page{0}, select_print{0}; constexpr float max_feedrate_edit_values[] = #ifdef MAX_FEEDRATE_EDIT_VALUES @@ -265,17 +253,21 @@ constexpr float max_acceleration_edit_values[] = ; #endif -static uint8_t _percent_done = 0; -static uint32_t _remain_time = 0; - -// Additional Aux Host Support -static bool sdprint = false; - #if HAS_HOTEND float last_E = 0; + #define E_MIN_POS (last_E - (EXTRUDE_MAXLENGTH)) + #define E_MAX_POS (last_E + (EXTRUDE_MAXLENGTH)) #endif +bool hash_changed = true; // Flag to know if message status was changed +uint8_t _percent_done = 0; +uint32_t _remain_time = 0; +bool blink = false; +millis_t dwin_heat_time = 0; +uint8_t checkkey = 255, last_checkkey = MainMenu; + // New menu system pointers +MenuClass *FileMenu = nullptr; MenuClass *PrepareMenu = nullptr; MenuClass *TrammingMenu = nullptr; MenuClass *MoveMenu = nullptr; @@ -306,8 +298,12 @@ MenuClass *MaxAccelMenu = nullptr; MenuClass *MaxJerkMenu = nullptr; #endif MenuClass *StepsMenu = nullptr; -MenuClass *HotendPIDMenu = nullptr; -MenuClass *BedPIDMenu = nullptr; +#if ENABLED(PIDTEMP) + MenuClass *HotendPIDMenu = nullptr; +#endif +#if ENABLED(PIDTEMPBED) + MenuClass *BedPIDMenu = nullptr; +#endif #if ENABLED(CASELIGHT_USES_BRIGHTNESS) MenuClass *CaseLightMenu = nullptr; #endif @@ -337,6 +333,10 @@ MenuItemClass *FanSpeedItem = nullptr; MenuItemClass *MMeshMoveZItem = nullptr; MenuItemClass *EditZValueItem = nullptr; +bool Printing() { return printingIsActive() || printingIsPaused(); } +bool SD_Printing() { return Printing() && IS_SD_FILE_OPEN(); } +bool Host_Printing() { return Printing() && !IS_SD_FILE_OPEN(); } + #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 @@ -368,7 +368,7 @@ void HMI_ToggleLanguage() { typedef struct { uint16_t x, y[2], w, h; } text_info_t; void ICON_Button(const bool selected, const int iconid, const frame_rect_t &ico, const text_info_t (&txt), FSTR_P caption) { - DWIN_ICON_Show(true, false, false, ICON, iconid + selected, ico.x, ico.y); + DWINUI::Draw_IconWB(iconid + selected, ico.x, ico.y); if (selected) DWINUI::Draw_Box(0, HMI_data.Highlight_Color, ico); if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, txt.x, txt.y[selected], txt.x + txt.w - 1, txt.y[selected] + txt.h - 1, ico.x + (ico.w - txt.w) / 2, (ico.y + ico.h - 25) - txt.h/2); @@ -452,47 +452,9 @@ void ICON_Stop() { ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt, GET_TEXT_F(MSG_BUTTON_STOP)); } -//----------------------------------------------------------------------------- -// Drawing routines -//----------------------------------------------------------------------------- - -void Move_Highlight(const int8_t from, const int8_t newline) { - Erase_Menu_Cursor(newline - from); - Draw_Menu_Cursor(newline); -} - -void Add_Menu_Line() { - Move_Highlight(1, MROWS); - DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(MROWS + 1), 240); -} - -void Scroll_Menu(const uint8_t dir) { - DWIN_Frame_AreaMove(1, dir, MLINE, HMI_data.Background_Color, 0, 31, DWIN_WIDTH, 349); - switch (dir) { - case DWIN_SCROLL_DOWN: Move_Highlight(-1, 0); break; - case DWIN_SCROLL_UP: Add_Menu_Line(); break; - } -} - -inline uint16_t nr_sd_menu_items() { - return card.get_num_Files() + !card.flag.workDirIsRoot; -} - -void Erase_Menu_Text(const uint8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); -} - -// Draw "Back" line at the top -void Draw_Back_First(const bool is_sel=true) { - Draw_Menu_Line(0, ICON_Back); - if (HMI_IsChinese()) - DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); - else - DWINUI::Draw_String(LBLX, MBASE(0), GET_TEXT_F(MSG_BACK)); - if (is_sel) Draw_Menu_Cursor(0); -} - +// //PopUps +// void Popup_window_PauseOrStop() { if (HMI_IsChinese()) { DWINUI::ClearMainArea(); @@ -546,15 +508,19 @@ void Popup_window_PauseOrStop() { DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } } - else DWIN_Show_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low"), BTN_Continue); + else + DWIN_Show_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low"), BTN_Continue); } #endif +// // Draw status line -void DWIN_DrawStatusLine() { +// +void DWIN_DrawStatusLine(const char *text) { DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, ui.status_message); + if (text) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, text); } +void DWIN_DrawStatusLine(FSTR_P fstr) { DWIN_DrawStatusLine(FTOP(fstr)); } // Clear & reset status line void DWIN_ResetStatusLine() { @@ -563,12 +529,16 @@ void DWIN_ResetStatusLine() { } // Djb2 hash algorithm -void DWIN_CheckStatusMessage() { - static uint32_t old_hash = 0; - char * str = &ui.status_message[0]; +uint32_t GetHash(char * str) { uint32_t hash = 5381; char c; while ((c = *str++)) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + return hash; +} + +void DWIN_CheckStatusMessage() { + static uint32_t old_hash = 0; + uint32_t hash = GetHash(&ui.status_message[0]); hash_changed = hash != old_hash; old_hash = hash; }; @@ -582,7 +552,7 @@ void DWIN_DrawStatusMessage() { // If the string fits the status line do not scroll it if (slen <= LCD_WIDTH) { if (hash_changed) { - DWIN_DrawStatusLine(); + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } } @@ -601,7 +571,7 @@ void DWIN_DrawStatusMessage() { if (rlen < LCD_WIDTH) { DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); // Always at 1+ spaces left, draw a dot uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - if (--chars) { // Draw a second dot if there's space + if (--chars) { // Draw a second dot if there's space DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); if (--chars) DWINUI::Draw_String(HMI_data.StatusTxt_Color, ui.status_message, chars); // Print a second copy of the message @@ -614,7 +584,7 @@ void DWIN_DrawStatusMessage() { if (hash_changed) { ui.status_message[LCD_WIDTH] = 0; - DWIN_DrawStatusLine(); + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } @@ -633,7 +603,7 @@ void Draw_Print_Labels() { } void Draw_Print_ProgressBar() { - DWIN_ICON_Show(true, false, false, ICON, ICON_Bar, 15, 93); + DWINUI::Draw_IconWB(ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, HMI_data.Barfill_Color, 16 + _percent_done * 240 / 100, 93, 256, 113); DWINUI::Draw_Int(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 3, 117, 133, _percent_done); DWINUI::Draw_String(HMI_data.PercentTxt_Color, 142, 133, F("%")); @@ -657,7 +627,7 @@ void ICON_ResumeOrPause() { } // Update filename on print -void DWIN_Print_Header(const char *text=nullptr) { +void DWIN_Print_Header(const char *text = nullptr) { static char headertxt[31] = ""; // Print header text if (text) { const int8_t size = _MIN(30U, strlen_P(text)); @@ -676,7 +646,7 @@ void Draw_PrintProcess() { else Title.ShowCaption(GET_TEXT_F(MSG_PRINTING)); DWINUI::ClearMainArea(); - DWIN_Print_Header(sdprint ? card.longest_filename() : nullptr); + DWIN_Print_Header(SD_Printing() ? card.longest_filename() : nullptr); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); @@ -707,11 +677,14 @@ void Draw_PrintDone() { Title.ShowCaption(GET_TEXT_F(MSG_PRINT_DONE)); DWINUI::ClearMainArea(); DWIN_Print_Header(nullptr); - if (sdprint && TERN0(HAS_GCODE_PREVIEW, Preview_Valid())) { - DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); - DWINUI::Draw_Button(BTN_Continue, 86, 300); - } - else { + #if HAS_GCODE_PREVIEW + if (Preview_Valid()) { + DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); + DWINUI::Draw_Button(BTN_Continue, 86, 300); + } + else + #endif + { Draw_Print_ProgressBar(); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); @@ -738,7 +711,6 @@ void Draw_Main_Menu() { else Title.ShowCaption(MACHINE_NAME); DWINUI::Draw_Icon(ICON_LOGO, 71, 52); // CREALITY logo - DWIN_ResetStatusLine(); ICON_Print(); ICON_Prepare(); ICON_Control(); @@ -753,13 +725,19 @@ void Goto_Main_Menu() { } // Draw X, Y, Z and blink if in an un-homed or un-trusted state -void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool blink, const bool force) { +void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool force) { const bool draw_qmark = axis_should_home(axis), draw_empty = NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !draw_qmark && !axis_is_trusted(axis); // Check for a position change static xyz_pos_t oldpos = { -1, -1, -1 }; - const float p = current_position[axis]; + + #if ENABLED(SHOW_REAL_POS) + const float p = stepper.position(axis) / planner.settings.axis_steps_per_mm[axis]; + #else + const float p = current_position[axis]; + #endif + const bool changed = oldpos[axis] != p; if (changed) oldpos[axis] = p; @@ -773,18 +751,38 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, } } +void _draw_ZOffsetIcon() { + #if HAS_LEVELING + #if NO_BLINK_LEV_IND + static bool _leveling_active = false; + if (_leveling_active != planner.leveling_active) { + _leveling_active = planner.leveling_active; + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(_leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); + } + #else + if (planner.leveling_active) { + DWIN_Draw_Rectangle(1, blink ? HMI_data.SplitLine_Color : HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(ICON_SetZOffset, 186, 416); + } + static bool _leveling_active = false; + if (_leveling_active != planner.leveling_active) { + _leveling_active = planner.leveling_active; + if (!_leveling_active) { + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + } + } + #endif + #else + DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + #endif +} + void _draw_xyz_position(const bool force) { - //SERIAL_ECHOPGM("Draw XYZ:"); - static bool _blink = false; - const bool blink = !!(millis() & 0x400UL); - if (force || blink != _blink) { - _blink = blink; - //SERIAL_ECHOPGM(" (blink)"); - _update_axis_value(X_AXIS, 27, 459, blink, true); - _update_axis_value(Y_AXIS, 112, 459, blink, true); - _update_axis_value(Z_AXIS, 197, 459, blink, true); - } - //SERIAL_EOL(); + _update_axis_value(X_AXIS, 27, 459, force); + _update_axis_value(Y_AXIS, 112, 459, force); + _update_axis_value(Z_AXIS, 197, 459, force); } void update_variable() { @@ -812,7 +810,7 @@ void update_variable() { if (_new_fanspeed) _fanspeed = thermalManager.fan_speed[0]; #endif - if (checkkey == Menu && (CurrentMenu == TuneMenu || CurrentMenu == TemperatureMenu)) { + if (IsMenu(TuneMenu) || IsMenu(TemperatureMenu)) { // Tune page temperature update #if HAS_HOTEND if (_new_hotend_target) HotendTargetItem->redraw(); @@ -866,34 +864,23 @@ void update_variable() { DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, _offset); } - #if HAS_MESH - static bool _leveling_active = false; - if (_leveling_active != planner.leveling_active) { - _leveling_active = planner.leveling_active; - DWIN_Draw_Box(1, HMI_data.Background_Color, 186, 416, 20, 20); - if (_leveling_active) - DWINUI::Draw_Icon(ICON_SetZOffset, 186, 416); - else - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); - } - #else - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); - #endif - + _draw_ZOffsetIcon(); _draw_xyz_position(false); } /** - * Read and cache the working directory. - * - * TODO: New code can follow the pattern of menu_media.cpp - * and rely on Marlin caching for performance. No need to - * cache files here. + * Memory card and file management */ -#ifndef strcasecmp_P - #define strcasecmp_P(a, b) strcasecmp((a), (b)) -#endif +bool DWIN_lcd_sd_status = false; + +void SetMediaAutoMount() { + Toogle_Chkb_Line(HMI_data.MediaAutoMount); +} + +inline uint16_t nr_sd_menu_items() { + return _MIN(card.get_num_Files() + !card.flag.workDirIsRoot, MENU_MAX_ITEMS); +} void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) { size_t pos = strlen(src); // index of ending nul @@ -919,117 +906,121 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) while (pos--) dst[pos] = src[pos]; } -void HMI_SDCardInit() { card.cdroot(); } +void Redraw_SD_List() { + InvalidateMenu(); + Draw_Print_File_Menu(); +} -#if ENABLED(SCROLL_LONG_FILENAMES) +void SDCard_Up() { + card.cdup(); + DWIN_lcd_sd_status = false; // On next DWIN_Update +} - char shift_name[LONG_FILENAME_LENGTH + 1]; - int8_t shift_amt; // = 0 - millis_t shift_ms; // = 0 +void SDCard_Folder(char * const dirname) { + card.cd(dirname); + DWIN_lcd_sd_status = false; // On next DWIN_Update +} - // Init the shift name based on the highlighted item - 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); - } +void onClickSDItem() { + const uint16_t hasUpDir = !card.flag.workDirIsRoot; + if (hasUpDir && CurrentMenu->selected == 1) return SDCard_Up(); + else { + const uint16_t filenum = CurrentMenu->selected - 1 - hasUpDir; + card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); + + // Enter that folder! + if (card.flag.filenameIsDir) return SDCard_Folder(card.filename); + + if (card.fileIsBinary()) + return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); + else + return Goto_ConfirmToPrint(); } - - 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. - */ -void Draw_SDItem(const uint16_t item, int16_t row=-1) { - if (row < 0) row = item + 1 + MROWS - index_file; - const bool is_subdir = !card.flag.workDirIsRoot; - if (is_subdir && item == 0) - return Draw_Menu_Line(row, ICON_Folder, ".."); - - card.getfilename_sorted(SD_ORDER(item - is_subdir, card.get_num_Files())); - char * const name = card.longest_filename(); - - #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); - const uint8_t icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; - Draw_Menu_Line(row, icon, str); } #if ENABLED(SCROLL_LONG_FILENAMES) + char shift_name[LONG_FILENAME_LENGTH + 1] = ""; void Draw_SDItem_Shifted(uint8_t &shift) { - // Limit to the number of chars past the cutoff - const size_t len = strlen(shift_name); - NOMORE(shift, _MAX(len - MENU_CHAR_LIMIT, 0U)); - // Shorten to the available space - const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); - + const size_t lastchar = shift + MENU_CHAR_LIMIT; const char c = shift_name[lastchar]; shift_name[lastchar] = '\0'; - const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll + const uint8_t row = FileMenu->line(); Erase_Menu_Text(row); Draw_Menu_Line(row, 0, &shift_name[shift]); shift_name[lastchar] = c; } + void FileMenuIdle(bool reset=false) { + static bool hasUpDir = false; + static uint8_t last_itemselected = 0; + static int8_t shift_amt = 0; + static int8_t shift_len = 0; + if (reset) { + last_itemselected = 0; + hasUpDir = !card.flag.workDirIsRoot; // is a SubDir + return; + } + const uint8_t selected = FileMenu->selected; + if (last_itemselected != selected) { + if (last_itemselected >= 1 + hasUpDir) FileMenu->Items()[last_itemselected]->redraw(true); + last_itemselected = selected; + if (selected >= 1 + hasUpDir) { + const int8_t filenum = selected - 1 - hasUpDir; // Skip "Back" and ".." + card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); + make_name_without_ext(shift_name, card.longest_filename(), LONG_FILENAME_LENGTH); + shift_len = strlen(shift_name); + shift_amt = 0; + } + } + else if ((selected >= 1 + hasUpDir) && (shift_len > MENU_CHAR_LIMIT)) { + uint8_t shift_new = _MIN(shift_amt + 1, shift_len - MENU_CHAR_LIMIT); // Try to shift by... + Draw_SDItem_Shifted(shift_new); // Draw the item + if (shift_new == shift_amt) // Scroll reached the end + shift_new = -1; // Reset + shift_amt = shift_new; // Set new scroll + } + } +#else + char shift_name[FILENAME_LENGTH + 1] = ""; #endif -// Redraw the first set of SD Files -void Redraw_SD_List() { - select_file.reset(); - index_file = MROWS; - - DWINUI::ClearMainArea(); // Leave title bar unchanged - - Draw_Back_First(); - - if (card.isMounted()) { - // As many files as will fit - LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS)) - Draw_SDItem(i, i + 1); - - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); +void onDrawFileName(MenuItemClass* menuitem, int8_t line) { + const bool is_subdir = !card.flag.workDirIsRoot; + if (is_subdir && menuitem->pos == 1) { + Draw_Menu_Line(line, ICON_Folder, ".."); } else { + uint8_t icon; + card.getfilename_sorted(SD_ORDER(menuitem->pos - is_subdir - 1, card.get_num_Files())); + make_name_without_ext(shift_name, card.longest_filename()); + icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; + Draw_Menu_Line(line, icon, shift_name); + } +} + +void Draw_Print_File_Menu() { + checkkey = Menu; + if (card.isMounted()) { + if (SET_MENU(FileMenu, MSG_MEDIA_MENU, nr_sd_menu_items() + 1)) { + BACK_ITEM(Goto_Main_Menu); + LOOP_L_N(i, nr_sd_menu_items()) { + MenuItemAdd(onDrawFileName, onClickSDItem); + } + } + UpdateMenu(FileMenu); + TERN_(DASH_REDRAW, DWIN_RedrawDash()); + } + else { + if (SET_MENU(FileMenu, MSG_MEDIA_MENU, 1)) BACK_ITEM(Goto_Main_Menu); + UpdateMenu(FileMenu); DWIN_Draw_Rectangle(1, HMI_data.AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); DWINUI::Draw_CenteredString(font12x24, HMI_data.AlertTxt_Color, MBASE(3), GET_TEXT_F(MSG_MEDIA_NOT_INSERTED)); } -} - -bool DWIN_lcd_sd_status = false; - -void SDCard_Up() { - card.cdup(); - Redraw_SD_List(); - DWIN_lcd_sd_status = false; // On next DWIN_Update -} - -void SDCard_Folder(char * const dirname) { - card.cd(dirname); - Redraw_SD_List(); - DWIN_lcd_sd_status = false; // On next DWIN_Update + TERN_(SCROLL_LONG_FILENAMES, FileMenuIdle(true)); } // @@ -1039,29 +1030,16 @@ void HMI_SDCardUpdate() { if (HMI_flag.home_flag) return; if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); - //SERIAL_ECHOLNPGM("HMI_SDCardUpdate: ", DWIN_lcd_sd_status); - if (DWIN_lcd_sd_status) { // Media inserted - if (checkkey == SelectFile) - Redraw_SD_List(); - } - else { // Media removed - // clean file icon - if (checkkey == SelectFile) { - Redraw_SD_List(); - } - else if (sdprint && card.isPrinting() && printingIsActive()) { - wait_for_heatup = wait_for_user = false; - HMI_flag.abort_flag = true; // Abort print - } - } + if (IsMenu(FileMenu)) Redraw_SD_List(); + if (!DWIN_lcd_sd_status && SD_Printing()) ui.abort_print(); // Media removed while printing DWIN_UpdateLCD(); } } -// -// The Dashboard is always on-screen, except during -// full-screen modal dialogs. -// +/** + * Dash board and indicators + */ + void DWIN_Draw_Dashboard() { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1); @@ -1110,11 +1088,11 @@ void DWIN_Draw_Dashboard() { void Draw_Info_Menu() { DWINUI::ClearMainArea(); - Draw_Back_First(); if (HMI_IsChinese()) Title.FrameCopy(30, 17, 28, 13); // "Info" else Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); + Draw_Menu_Line(0, ICON_Back, GET_TEXT_F(MSG_BACK), false, true); if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102); // "Size" @@ -1137,15 +1115,6 @@ void Draw_Info_Menu() { } } -void Draw_Print_File_Menu() { - if (HMI_IsChinese()) - Title.FrameCopy(0, 31, 56, 14); // "Print file" - else - Title.ShowCaption(GET_TEXT_F(MSG_MEDIA_MENU)); - Redraw_SD_List(); - TERN_(DASH_REDRAW, DWIN_RedrawDash()); -} - // Main Process void HMI_MainMenu() { EncoderState encoder_diffState = get_encoder_state(); @@ -1174,9 +1143,10 @@ void HMI_MainMenu() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { switch (select_page.now) { case PAGE_PRINT: - checkkey = SelectFile; - card.mount(); - safe_delay(300); + if (HMI_data.MediaAutoMount) { + card.mount(); + safe_delay(800); + }; Draw_Print_File_Menu(); break; case PAGE_PREPARE: Draw_Prepare_Menu(); break; @@ -1187,125 +1157,11 @@ void HMI_MainMenu() { DWIN_UpdateLCD(); } -// Select (and Print) File -void HMI_SelectFile() { - EncoderState encoder_diffState = get_encoder_state(); - - const uint16_t hasUpDir = !card.flag.workDirIsRoot; - - if (encoder_diffState == ENCODER_DIFF_NO) { - #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 - uint8_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; - } - - // First pause is long. Easy. - // On reset, long pause must be after 0. - - const uint16_t fullCnt = nr_sd_menu_items(); - - if (encoder_diffState == ENCODER_DIFF_CW && fullCnt) { - if (select_file.inc(1 + fullCnt)) { - const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - 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 - index_file = select_file.now; // New bottom line - Scroll_Menu(DWIN_SCROLL_UP); - Draw_SDItem(itemnum, MROWS); // Draw and init the shift name - } - else { - Move_Highlight(1, select_file.now + MROWS - index_file); // Just move highlight - TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name - } - 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 (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 - } - if (select_file.now < index_file - MROWS) { // Cursor past the top - index_file--; // New bottom line - Scroll_Menu(DWIN_SCROLL_DOWN); - if (index_file == MROWS) { - Draw_Back_First(); - TERN_(SCROLL_LONG_FILENAMES, shift_ms = 0); - } - else { - Draw_SDItem(itemnum, 0); // Draw the item (and init shift name) - } - } - else { - Move_Highlight(-1, select_file.now + MROWS - index_file); // Just move highlight - TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name - } - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); // Reset left. Init timer. - } - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (select_file.now == 0) { // Back - select_page.set(PAGE_PRINT); - return Goto_Main_Menu(); - } - else if (hasUpDir && select_file.now == 1) { // CD-Up - SDCard_Up(); - goto HMI_SelectFileExit; - } - else { - const uint16_t filenum = select_file.now - 1 - hasUpDir; - card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); - - // Enter that folder! - if (card.flag.filenameIsDir) { - SDCard_Folder(card.filename); - goto HMI_SelectFileExit; - } - - // Reset highlight for next entry - select_print.reset(); - select_file.reset(); - - // Start choice and print SD file - HMI_flag.heat_flag = true; - HMI_flag.print_finish = false; - - if (card.fileIsBinary()) - return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); - else - return Goto_ConfirmToPrint(); - } - } - - HMI_SelectFileExit: - DWIN_UpdateLCD(); -} - // Pause or Stop popup void onClick_PauseOrStop() { switch (select_print.now) { - case PRINT_PAUSE_RESUME: if (HMI_flag.select_flag) HMI_flag.pause_flag = true; break; // confirm pause - case PRINT_STOP: if (HMI_flag.select_flag) HMI_flag.abort_flag = true; break; // stop confirmed then abort print + case PRINT_PAUSE_RESUME: if (HMI_flag.select_flag) ui.pause_print(); break; // confirm pause + case PRINT_STOP: if (HMI_flag.select_flag) ui.abort_print(); break; // stop confirmed then abort print default: break; } return Goto_PrintProcess(); @@ -1357,7 +1213,6 @@ void HMI_Printing() { void Draw_Main_Area() { switch (checkkey) { case MainMenu: Draw_Main_Menu(); break; - case SelectFile: Draw_Print_File_Menu(); break; case PrintProcess: Draw_PrintProcess(); break; case PrintDone: Draw_PrintDone(); break; #if HAS_ESDIAG @@ -1384,27 +1239,35 @@ void HMI_ReturnScreen() { } void HMI_WaitForUser() { - get_encoder_state(); + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState != ENCODER_DIFF_NO && !ui.backlight) { + if (checkkey == WaitResponse) HMI_ReturnScreen(); + return ui.refresh_brightness(); + } if (!wait_for_user) { switch (checkkey) { case PrintDone: select_page.reset(); Goto_Main_Menu(); break; - TERN_(HAS_ONESTEP_LEVELING, case Leveling:) - default: HMI_ReturnScreen(); break; + #if HAS_BED_PROBE + case Leveling: + #endif + default: + HMI_ReturnScreen(); + break; } } } void HMI_Init() { - DWINUI::Draw_Box(1, Color_Black, {5, 220, DWIN_WIDTH-5, DWINUI::fontHeight()}); + DWINUI::Draw_Box(1, Color_Black, { 5, 220, DWIN_WIDTH - 5, DWINUI::fontHeight() }); DWINUI::Draw_CenteredString(Color_White, 220, F("Professional Firmware ")); - for (uint16_t t = 0; t <= 100; t += 2) { + for (uint16_t t = 15; t <= 257; t += 10) { DWINUI::Draw_Icon(ICON_Bar, 15, 260); - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 15 + t * 242 / 100, 260, 257, 280); + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, t, 260, 257, 280); DWIN_UpdateLCD(); - delay(20); + delay(50); } HMI_SetLanguage(); } @@ -1415,12 +1278,13 @@ void EachMomentUpdate() { if (ELAPSED(ms, next_var_update_ms)) { next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL; + blink = !blink; update_variable(); #if HAS_ESDIAG if (checkkey == ESDiagProcess) ESDiag.Update(); #endif #if HAS_PIDPLOT - if (checkkey == PidProcess) Plot.Update((HMI_value.pidresult == PID_EXTR_START) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); + if (checkkey == PidProcess) Plot.Update((HMI_value.pidresult == PIDTEMP_START) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); #endif } @@ -1433,73 +1297,73 @@ void EachMomentUpdate() { if (ELAPSED(ms, next_status_update_ms)) { next_status_update_ms = ms + 500; DWIN_DrawStatusMessage(); + #if ENABLED(SCROLL_LONG_FILENAMES) + if (IsMenu(FileMenu)) FileMenuIdle(); + #endif } - if (PENDING(ms, next_rts_update_ms)) return; - next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL; + if (!PENDING(ms, next_rts_update_ms)) { + next_rts_update_ms = ms + DWIN_UPDATE_INTERVAL; - if (checkkey == PrintProcess) { // print process - - // Print pause - if (HMI_flag.pause_flag && !HMI_flag.home_flag) { - HMI_flag.pause_flag = false; - if (!HMI_flag.pause_action) { - HMI_flag.pause_action = true; - return ui.pause_print(); - } + if ((Printing() != HMI_flag.printing_flag) && !HMI_flag.home_flag) { + HMI_flag.printing_flag = Printing(); + DEBUG_ECHOLNPGM("printing_flag: ", HMI_flag.printing_flag); + if (HMI_flag.printing_flag) + DWIN_Print_Started(); + else if (HMI_flag.abort_flag) + DWIN_Print_Aborted(); + else + DWIN_Print_Finished(); } - // if print done - if (HMI_flag.print_finish && !HMI_flag.home_flag) { - HMI_flag.print_finish = false; - return DWIN_Print_Finished(); + if ((printingIsPaused() != HMI_flag.pause_flag) && !HMI_flag.home_flag) { + HMI_flag.pause_flag = printingIsPaused(); + DEBUG_ECHOLNPGM("pause_flag: ", HMI_flag.pause_flag); + if (HMI_flag.pause_flag) + DWIN_Print_Pause(); + else if (HMI_flag.abort_flag) + DWIN_Print_Aborted(); + else + DWIN_Print_Resume(); } - // if print was aborted - if (HMI_flag.abort_flag && !HMI_flag.home_flag) { // Print Stop - HMI_flag.abort_flag = false; - if (!HMI_flag.abort_action) { - HMI_flag.abort_action = true; - ui.abort_print(); - return Goto_PrintDone(); - } - } + if (checkkey == PrintProcess) { // print process - duration_t elapsed = print_job_timer.duration(); // print timer + duration_t elapsed = print_job_timer.duration(); // print timer - if (sdprint && card.isPrinting() && !HMI_flag.percent_flag) { - uint8_t percentDone = card.percentDone(); - if (_percent_done != percentDone) { // print percent - _percent_done = percentDone; - Draw_Print_ProgressBar(); + if (card.isPrinting() && !HMI_flag.percent_flag) { + uint8_t percentDone = card.percentDone(); + if (_percent_done != percentDone) { // print percent + _percent_done = percentDone; + Draw_Print_ProgressBar(); } - // Estimate remaining time every 20 seconds - static millis_t next_remain_time_update = 0; - if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag && !HMI_flag.remain_flag) { - _remain_time = (elapsed.value - dwin_heat_time) / (_percent_done * 0.01f) - (elapsed.value - dwin_heat_time); - next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; - Draw_Print_ProgressRemain(); + // Estimate remaining time every 20 seconds + static millis_t next_remain_time_update = 0; + if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag && !HMI_flag.remain_flag) { + _remain_time = (elapsed.value - dwin_heat_time) / (_percent_done * 0.01f) - (elapsed.value - dwin_heat_time); + next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; + Draw_Print_ProgressRemain(); + } } - } - // 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; - Draw_Print_ProgressElapsed(); - } + // 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; + Draw_Print_ProgressElapsed(); + } + } + #if ENABLED(POWER_LOSS_RECOVERY) + else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off + return Goto_PowerLossRecovery(); + } + #endif // POWER_LOSS_RECOVERY + + DWIN_UpdateLCD(); } - - #if ENABLED(POWER_LOSS_RECOVERY) - else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off - return Goto_PowerLossRecovery(); - } - #endif // POWER_LOSS_RECOVERY - - DWIN_UpdateLCD(); } #if ENABLED(POWER_LOSS_RECOVERY) @@ -1536,8 +1400,6 @@ void EachMomentUpdate() { else { select_print.set(PRINT_SETUP); queue.inject(F("M1000")); - sdprint = true; - return Goto_PrintProcess(); } } @@ -1554,12 +1416,11 @@ void DWIN_HandleScreen() { switch (checkkey) { case MainMenu: HMI_MainMenu(); break; case Menu: HMI_Menu(); break; - case SetInt: HMI_SetInt(); break; + case SetInt: HMI_SetDraw(); break; + case SetFloat: HMI_SetDraw(); break; case SetPInt: HMI_SetPInt(); break; - case SetIntNoDraw: HMI_SetIntNoDraw(); break; - case SetFloat: HMI_SetFloat(); break; case SetPFloat: HMI_SetPFloat(); break; - case SelectFile: HMI_SelectFile(); break; + case SetIntNoDraw: HMI_SetNoDraw(); break; case PrintProcess: HMI_Printing(); break; case Popup: HMI_Popup(); break; case Leveling: break; @@ -1607,15 +1468,15 @@ void DWIN_HomingStart() { void DWIN_HomingDone() { HMI_flag.home_flag = false; - #if ENABLED(MESH_BED_LEVELING) && EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) + #if DISABLED(HAS_BED_PROBE) && EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) planner.synchronize(); babystep.add_mm(Z_AXIS, HMI_data.ManualZOffset); #endif - if (HMI_flag.abort_action) DWIN_Print_Aborted(); else HMI_ReturnScreen(); + HMI_ReturnScreen(); } void DWIN_LevelingStart() { - #if HAS_ONESTEP_LEVELING + #if HAS_BED_PROBE HMI_SaveProcessID(Leveling); Title.ShowCaption(GET_TEXT_F(MSG_BED_LEVELING)); DWIN_Show_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT)); @@ -1641,10 +1502,10 @@ void DWIN_LevelingDone() { } #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { + void DWIN_MeshUpdate(const int8_t cpos, const int8_t tpos, const_float_t zval) { char msg[33] = ""; char str_1[6] = ""; - sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), xpos, ypos, dtostrf(zval, 1, 2, str_1)); + sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), cpos, tpos, dtostrf(zval, 1, 2, str_1)); ui.set_status(msg); } #endif @@ -1659,12 +1520,12 @@ void DWIN_LevelingDone() { DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE)); DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius")); switch (HMI_value.pidresult) { - case PID_EXTR_START: + case PIDTEMP_START: DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running.")); Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], HMI_data.HotendPidT); DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.HotendPidT); break; - case PID_BED_START: + case PIDTEMPBED_START: DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running.")); Plot.Draw(gfrm, BED_MAXTEMP, HMI_data.BedPidT); DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.BedPidT); @@ -1678,7 +1539,7 @@ void DWIN_LevelingDone() { void DWIN_PidTuning(pidresult_t result) { HMI_value.pidresult = result; switch (result) { - case PID_BED_START: + case PIDTEMPBED_START: HMI_SaveProcessID(PidProcess); #if HAS_PIDPLOT DWIN_Draw_PIDPopup(); @@ -1686,7 +1547,7 @@ void DWIN_PidTuning(pidresult_t result) { DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running.")); #endif break; - case PID_EXTR_START: + case PIDTEMP_START: HMI_SaveProcessID(PidProcess); #if HAS_PIDPLOT DWIN_Draw_PIDPopup(); @@ -1717,38 +1578,35 @@ void DWIN_PidTuning(pidresult_t result) { } // Started a Print Job -void DWIN_Print_Started(const bool sd) { - sdprint = IS_SD_PRINTING() || sd; +void DWIN_Print_Started() { + DEBUG_ECHOLNPGM("DWIN_Print_Started: ", SD_Printing()); + TERN_(HAS_GCODE_PREVIEW, if (Host_Printing()) Preview_Invalidate()); _percent_done = 0; _remain_time = 0; HMI_flag.percent_flag = false; HMI_flag.remain_flag = false; HMI_flag.pause_flag = false; - HMI_flag.pause_action = false; HMI_flag.abort_flag = false; - HMI_flag.abort_action = false; - HMI_flag.print_finish = false; + select_print.reset(); Goto_PrintProcess(); } // Pause a print job void DWIN_Print_Pause() { + DEBUG_ECHOLNPGM("DWIN_Print_Pause"); ICON_ResumeOrPause(); } // Resume print job void DWIN_Print_Resume() { - HMI_flag.pause_action = false; + DEBUG_ECHOLNPGM("DWIN_Print_Resume"); ICON_ResumeOrPause(); - if (printJobOngoing()) { - LCD_MESSAGE(MSG_RESUME_PRINT); - Goto_PrintProcess(); - } + LCD_MESSAGE(MSG_RESUME_PRINT); } // Ended print job void DWIN_Print_Finished() { - if (HMI_flag.abort_flag || checkkey == PrintDone) return; + DEBUG_ECHOLNPGM("DWIN_Print_Finished"); TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel()); HMI_flag.pause_flag = false; wait_for_heatup = false; @@ -1759,12 +1617,8 @@ void DWIN_Print_Finished() { // Print was aborted void DWIN_Print_Aborted() { - TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Print_Aborted")); - HMI_flag.abort_action = false; - wait_for_heatup = false; - planner.finish_and_disable(); - thermalManager.cooldown(); - Goto_PrintDone(); + DEBUG_ECHOLNPGM("DWIN_Print_Aborted"); + DWIN_Print_Finished(); } // Progress and remaining time update @@ -1791,16 +1645,16 @@ void DWIN_M73() { void DWIN_SetColorDefaults() { HMI_data.Background_Color = Def_Background_Color; - HMI_data.Cursor_color = Def_Cursor_color; - HMI_data.TitleBg_color = Def_TitleBg_color; - HMI_data.TitleTxt_color = Def_TitleTxt_color; + HMI_data.Cursor_Color = Def_Cursor_Color; + HMI_data.TitleBg_Color = Def_TitleBg_Color; + HMI_data.TitleTxt_Color = Def_TitleTxt_Color; HMI_data.Text_Color = Def_Text_Color; HMI_data.Selected_Color = Def_Selected_Color; HMI_data.SplitLine_Color = Def_SplitLine_Color; HMI_data.Highlight_Color = Def_Highlight_Color; HMI_data.StatusBg_Color = Def_StatusBg_Color; HMI_data.StatusTxt_Color = Def_StatusTxt_Color; - HMI_data.PopupBg_color = Def_PopupBg_color; + HMI_data.PopupBg_Color = Def_PopupBg_Color; HMI_data.PopupTxt_Color = Def_PopupTxt_Color; HMI_data.AlertBg_Color = Def_AlertBg_Color; HMI_data.AlertTxt_Color = Def_AlertTxt_Color; @@ -1811,11 +1665,12 @@ void DWIN_SetColorDefaults() { } void DWIN_SetDataDefaults() { + DEBUG_ECHOLNPGM("DWIN_SetDataDefaults"); DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); - TERN_(HAS_HOTEND, HMI_data.HotendPidT = PREHEAT_1_TEMP_HOTEND); - TERN_(HAS_HEATED_BED, HMI_data.BedPidT = PREHEAT_1_TEMP_BED); - TERN_(HAS_HOTEND, HMI_data.PidCycles = 5); + TERN_(PIDTEMP, HMI_data.HotendPidT = DEF_HOTENDPIDT); + TERN_(PIDTEMPBED, HMI_data.BedPidT = DEF_BEDPIDT); + TERN_(HAS_PID_HEATING, HMI_data.PidCycles = DEF_PIDCYCLES); #if ENABLED(PREVENT_COLD_EXTRUSION) HMI_data.ExtMinT = EXTRUDE_MINTEMP; ApplyExtMinT(); @@ -1824,6 +1679,14 @@ void DWIN_SetDataDefaults() { HMI_data.BedLevT = LEVELING_BED_TEMP; #endif TERN_(BAUD_RATE_GCODE, SetBaud250K()); + HMI_data.FullManualTramming = false; + HMI_data.MediaAutoMount = ENABLED(HAS_SD_EXTENDER); + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + HMI_data.z_after_homing = DEF_Z_AFTER_HOMING; + #endif + #if DISABLED(HAS_BED_PROBE) + HMI_data.ManualZOffset = 0; + #endif #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) TERN_(LED_COLOR_PRESETS, leds.set_default()); ApplyLEDColor(); @@ -1831,10 +1694,13 @@ void DWIN_SetDataDefaults() { } void DWIN_CopySettingsTo(char * const buff) { + DEBUG_ECHOLNPGM("DWIN_CopySettingsTo"); + DEBUG_ECHOLNPGM("HMI_data: ", sizeof(HMI_data_t)); memcpy(buff, &HMI_data, eeprom_data_size); } void DWIN_CopySettingsFrom(const char * const buff) { + DEBUG_ECHOLNPGM("DWIN_CopySettingsFrom"); memcpy(&HMI_data, buff, sizeof(HMI_data_t)); if (HMI_data.Text_Color == HMI_data.Background_Color) DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); @@ -1855,22 +1721,25 @@ void DWIN_CopySettingsFrom(const char * const buff) { // Initialize or re-initialize the LCD void MarlinUI::init_lcd() { - TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Startup")); - DWINUI::init(); + DEBUG_ECHOLNPGM("MarlinUI::init_lcd"); + delay(750); // wait to wakeup screen + const bool hs = DWIN_Handshake(); UNUSED(hs); + DEBUG_ECHOPGM("DWIN_Handshake "); + DEBUG_ECHOLNF(hs ? F("ok.") : F("error.")); + DWIN_Frame_SetDir(1); DWIN_JPG_CacheTo1(Language_English); Encoder_Configuration(); } void DWIN_InitScreen() { + DEBUG_ECHOLNPGM("DWIN_InitScreen"); + DWIN_SetColorDefaults(); HMI_Init(); // draws boot screen - onCursorDraw = Draw_Menu_Cursor; - onCursorErase = Erase_Menu_Cursor; + DWINUI::init(); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWINUI::onTitleDraw = Draw_Title; - onMenuDraw = Draw_Menu; + InitMenu(); checkkey = 255; - CurrentMenu = nullptr; - PreviousMenu = nullptr; - index_file = MROWS; hash_changed = true; last_E = 0; DWIN_DrawStatusLine(); @@ -1925,12 +1794,12 @@ void DWIN_RedrawScreen() { //if (mode == PAUSE_MODE_SAME) return; pause_mode = mode; switch (message) { - case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 - case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) + case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 + case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break; case PAUSE_MESSAGE_INSERT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT), BTN_Continue); break; case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; - case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 + case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 case PAUSE_MESSAGE_PURGE: #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_CONT_PURGE)); @@ -1942,7 +1811,7 @@ void DWIN_RedrawScreen() { case PAUSE_MESSAGE_RESUME: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break; case PAUSE_MESSAGE_HEAT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), BTN_Continue); break; case PAUSE_MESSAGE_HEATING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEATING)); break; - case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; // Exit from Pause, Load and Unload + case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; // Exit from Pause, Load and Unload default: break; } } @@ -1955,13 +1824,13 @@ void DWIN_RedrawScreen() { } void onClick_FilamentPurge() { - if (HMI_flag.select_flag) - pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button - else { - HMI_SaveProcessID(NothingToDo); - pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button - } + if (HMI_flag.select_flag) + pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button + else { + HMI_SaveProcessID(NothingToDo); + pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button } + } void Goto_FilamentPurge() { pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; @@ -2011,15 +1880,14 @@ void DWIN_RedrawScreen() { #if HAS_GCODE_PREVIEW void onClick_ConfirmToPrint() { + Preview_Reset(); + DWIN_ResetStatusLine(); if (HMI_flag.select_flag) { // Confirm - card.openAndPrintFile(card.filename); - return DWIN_Print_Started(true); - } - else { // Cancel - DWIN_ResetStatusLine(); - checkkey = SelectFile; - return Draw_Print_File_Menu(); + HMI_flag.heat_flag = true; + Goto_Main_Menu(); + return card.openAndPrintFile(card.filename); } + else HMI_ReturnScreen(); } void Goto_ConfirmToPrint() { @@ -2028,8 +1896,9 @@ void DWIN_RedrawScreen() { #else void Goto_ConfirmToPrint() { + // Print SD file + HMI_flag.heat_flag = true; card.openAndPrintFile(card.filename); - DWIN_Print_Started(true); } #endif @@ -2048,8 +1917,7 @@ void DWIN_RedrawScreen() { #if ENABLED(EEPROM_SETTINGS) void WriteEeprom() { - ui.set_status(GET_TEXT_F(MSG_STORE_EEPROM)); - DWIN_DrawStatusLine(); + DWIN_DrawStatusLine(GET_TEXT_F(MSG_STORE_EEPROM)); DWIN_UpdateLCD(); DONE_BUZZ(settings.save()); } @@ -2086,13 +1954,6 @@ void Goto_Info_Menu() { HMI_SaveProcessID(WaitResponse); } -void Goto_Move_Menu() { - #if HAS_HOTEND - gcode.process_subcommands_now(F("G92E0")); // reset extruder position - #endif - Draw_Move_Menu(); -} - void DisableMotors() { queue.inject(F("M84")); } void AutoLev() { // Always reacquire the Z "home" position @@ -2100,15 +1961,22 @@ void AutoLev() { // Always reacquire the Z "home" position } void AutoHome() { queue.inject_P(G28_STR); } -void HomeX() { queue.inject(F("G28X")); } -void HomeY() { queue.inject(F("G28Y")); } -void HomeZ() { queue.inject(F("G28Z")); } + +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + void HomeX() { queue.inject(F("G28X")); } + void HomeY() { queue.inject(F("G28Y")); } + void HomeZ() { queue.inject(F("G28Z")); } + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + void ApplyZAfterHoming() { HMI_data.z_after_homing = MenuData.Value; }; + void SetZAfterHoming() { SetIntOnClick(0, 20, HMI_data.z_after_homing, ApplyZAfterHoming); } + #endif +#endif #if HAS_HOME_OFFSET // Apply workspace offset, making the current position 0,0,0 void SetHome() { - queue.inject(F("G92X0Y0Z0")); - DONE_BUZZ(true); + queue.inject(F("G92X0Y0Z0")); + DONE_BUZZ(true); } #endif @@ -2119,15 +1987,15 @@ void HomeZ() { queue.inject(F("G28Z")); } #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) const_float_t step_zoffset = round((MenuData.Value / 100.0f) * planner.settings.axis_steps_per_mm[Z_AXIS]) - babystep.accum; if (BABYSTEP_ALLOWED()) babystep.add_steps(Z_AXIS, step_zoffset); + //DEBUG_ECHOLNF(F("BB Steps: "), step_zoffset); #endif } - - #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - void SetZOffset() { + void SetZOffset() { + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) babystep.accum = round(planner.settings.axis_steps_per_mm[Z_AXIS] * BABY_Z_VAR); - SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); - } - #endif + #endif + SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); + } void SetMoveZto0() { #if ENABLED(Z_SAFE_HOMING) @@ -2139,7 +2007,7 @@ void HomeZ() { queue.inject(F("G28Z")); } gcode.process_subcommands_now(cmd); #else TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); - gcode.process_subcommands_now(F("G28O\nG0Z0F300\nM400")); + gcode.process_subcommands_now(F("G28Z\nG0Z0F300\nM400")); #endif ui.reset_status(); DONE_BUZZ(true); @@ -2155,13 +2023,9 @@ void HomeZ() { queue.inject(F("G28Z")); } #endif // HAS_ZOFFSET_ITEM #if HAS_PREHEAT - void DoPreheat0() { ui.preheat_all(0); } - #if PREHEAT_COUNT >= 2 - void DoPreheat1() { ui.preheat_all(1); } - #if PREHEAT_COUNT >= 3 - void DoPreheat2() { ui.preheat_all(2); } - #endif - #endif + #define _DoPreheat(N) void DoPreheat##N() { ui.preheat_all(N-1); }\ + void DoPreheatHotend##N() { ui.preheat_hotend(N-1); } + REPEAT_1(PREHEAT_COUNT, _DoPreheat) #endif void DoCoolDown() { thermalManager.cooldown(); } @@ -2172,31 +2036,29 @@ void SetLanguage() { Draw_Prepare_Menu(); } +bool EnableLiveMove = false; +void SetLiveMove() { Toogle_Chkb_Line(EnableLiveMove); } void LiveMove() { + planner.synchronize(); + if (!EnableLiveMove) return; *MenuData.P_Float = MenuData.Value / MINUNITMULT; - if (!planner.is_full()) { - planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(HMI_value.axis)); - } + if (!planner.is_full()) planner.buffer_line(current_position, manual_feedrate_mm_s[HMI_value.axis]); } -void ApplyMoveE() { - last_E = MenuData.Value / MINUNITMULT; - if (!planner.is_full()) { - planner.synchronize(); - planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E)); - } +void ApplyMove() { + planner.synchronize(); + if (EnableLiveMove) return; + if (HMI_value.axis == E_AXIS) last_E = MenuData.Value / MINUNITMULT; + if (!planner.is_full()) planner.buffer_line(current_position, manual_feedrate_mm_s[HMI_value.axis]); } -void SetMoveX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(X_MIN_POS, X_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } -void SetMoveY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(Y_MIN_POS, Y_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } -void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } + +void SetMoveX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(X_MIN_POS, X_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } +void SetMoveY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(Y_MIN_POS, Y_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } +void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } #if HAS_HOTEND void SetMoveE() { - #if ENABLED(PREVENT_COLD_EXTRUSION) - if (thermalManager.tooColdToExtrude(0)) - return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); - #endif - SetPFloatOnClick(last_E - (EXTRUDE_MAXLENGTH), last_E + (EXTRUDE_MAXLENGTH), UNITFDIGITS, ApplyMoveE); + if (thermalManager.tooColdToExtrude(0)) return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); + HMI_value.axis = E_AXIS; SetPFloatOnClick(E_MIN_POS, E_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } #endif @@ -2210,18 +2072,17 @@ void SetPID(celsius_t t, heater_id_t h) { gcode.process_subcommands_now(cmd); thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); } -#if HAS_HOTEND +#if ENABLED(PIDTEMP) void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); } #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void BedPID() { SetPID(HMI_data.BedPidT, H_BED); } #endif #if ENABLED(POWER_LOSS_RECOVERY) void SetPwrLossr() { - recovery.enable(!recovery.enabled); - Draw_Chkb_Line(CurrentMenu->line(), recovery.enabled); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(recovery.enabled); + recovery.changed(); } #endif @@ -2246,10 +2107,8 @@ void SetPID(celsius_t t, heater_id_t h) { #if ENABLED(CASE_LIGHT_MENU) void SetCaseLight() { - caselight.on = !caselight.on; + Toogle_Chkb_Line(caselight.on); caselight.update_enabled(); - Draw_Chkb_Line(CurrentMenu->line(), caselight.on); - DWIN_UpdateLCD(); } #if ENABLED(CASELIGHT_USES_BRIGHTNESS) void LiveCaseLightBrightness() { caselight.brightness = MenuData.Value; caselight.update_brightness(); } @@ -2261,8 +2120,7 @@ void SetPID(celsius_t t, heater_id_t h) { #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) void SetLedStatus() { leds.toggle(); - Draw_Chkb_Line(CurrentMenu->line(), leds.lights_on); - DWIN_UpdateLCD(); + Show_Chkb_Line(leds.lights_on); } #endif #if HAS_COLOR_LEDS @@ -2285,9 +2143,7 @@ void SetPID(celsius_t t, heater_id_t h) { #if ENABLED(SOUND_MENU_ITEM) void SetEnableSound() { - ui.sound_on = !ui.sound_on; - Draw_Chkb_Line(CurrentMenu->line(), ui.sound_on); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(ui.sound_on); } #endif @@ -2309,11 +2165,9 @@ void SetPID(celsius_t t, heater_id_t h) { void ProbeStow() { probe.stow(); } void ProbeDeploy() { probe.deploy(); } - #ifdef BLTOUCH_HS_MODE + #if ENABLED(BLTOUCH_HS_MODE) void SetHSMode() { - bltouch.high_speed_mode = !bltouch.high_speed_mode; - Draw_Chkb_Line(CurrentMenu->line(), bltouch.high_speed_mode); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(bltouch.high_speed_mode); } #endif @@ -2322,9 +2176,7 @@ void SetPID(celsius_t t, heater_id_t h) { #if HAS_FILAMENT_SENSOR void SetRunoutEnable() { runout.reset(); - runout.enabled = !runout.enabled; - Draw_Chkb_Line(CurrentMenu->line(), runout.enabled); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(runout.enabled); } #if HAS_FILAMENT_RUNOUT_DISTANCE void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } @@ -2342,7 +2194,7 @@ void SetPID(celsius_t t, heater_id_t h) { void SetExtMinT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP, ApplyExtMinT); } #endif -void RestoreDefaultsColors() { +void RestoreDefaultColors() { DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWIN_RedrawScreen(); @@ -2362,7 +2214,7 @@ void LiveRGBColor() { DWIN_Draw_Rectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); } void SetRGBColor() { - const uint8_t color = CurrentMenu->SelectedItem()->icon; + const uint8_t color = static_cast(CurrentMenu->SelectedItem())->icon; SetIntOnClick(0, (color == 1) ? 63 : 31, HMI_value.Color[color], nullptr, LiveRGBColor); } @@ -2399,10 +2251,12 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } queue.inject(F("M600 B2")); } - void ParkHead() { - LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED); - queue.inject(F("G28O\nG27")); - } + #if ENABLED(NOZZLE_PARK_FEATURE) + void ParkHead() { + LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED); + queue.inject(F("G28O\nG27")); + } + #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) void UnloadFilament() { @@ -2418,8 +2272,7 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } #endif // ADVANCED_PAUSE_FEATURE -void ApplyFlow() { planner.refresh_e_factor(0); } -void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, ApplyFlow); } +void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, []{ planner.refresh_e_factor(0); }); } // Bed Tramming @@ -2585,9 +2438,7 @@ void TramC () { Tram(4); } } void SetManualTramming() { - HMI_data.FullManualTramming = !HMI_data.FullManualTramming; - Draw_Chkb_Line(CurrentMenu->line(), HMI_data.FullManualTramming); - DWIN_UpdateLCD(); + Toogle_Chkb_Line(HMI_data.FullManualTramming); } #endif // HAS_BED_PROBE @@ -2607,7 +2458,7 @@ void TramC () { Tram(4); } *MenuData.P_Float = MenuData.Value / POW(10, 2); if (!planner.is_full()) { planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS)); + planner.buffer_line(current_position, manual_feedrate_mm_s[Z_AXIS]); } } void SetMMeshMoveZ() { SetPFloatOnClick(-1, 1, 2, planner.synchronize, LiveMeshMoveZ); } @@ -2907,16 +2758,6 @@ void onDrawSteps(MenuItemClass* menuitem, int8_t line) { onDrawPIntMenu(menuitem, line); } #endif - void onDrawPLAPreheatSubMenu(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 100, 89, 178, 101); - onDrawSubMenu(menuitem,line); - } - #if PREHEAT_COUNT >= 2 - void onDrawABSPreheatSubMenu(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 180, 89, 260, 100); - onDrawSubMenu(menuitem,line); - } - #endif #endif // HAS_PREHEAT void onDrawSpeed(MenuItemClass* menuitem, int8_t line) { @@ -3100,161 +2941,145 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) { // Menu Creation and Drawing functions ====================================================== -void SetMenuTitle(frame_rect_t cn, const __FlashStringHelper* fstr) { - if (HMI_IsChinese() && (cn.w != 0)) - CurrentMenu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h); +frame_rect_t selrect(frame_rect_t) { + if (HMI_IsChinese()) + return {133, 1, 28, 13}; else - CurrentMenu->MenuTitle.SetCaption(fstr); + return{0}; } void Draw_Prepare_Menu() { checkkey = Menu; - if (!PrepareMenu) PrepareMenu = new MenuClass(); - if (CurrentMenu != PrepareMenu) { - CurrentMenu = PrepareMenu; - SetMenuTitle({133, 1, 28, 13}, GET_TEXT_F(MSG_PREPARE)); - MenuItemsPrepare(13); + if (SET_MENU_R(PrepareMenu, selrect({133, 1, 28, 13}), MSG_PREPARE, 10 + PREHEAT_COUNT)) { BACK_ITEM(Goto_Main_Menu); #if ENABLED(ADVANCED_PAUSE_FEATURE) - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, Draw_FilamentMan_Menu); + MENU_ITEM(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, Draw_FilamentMan_Menu); #endif - MENU_ITEM_F(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, Goto_Move_Menu); - MENU_ITEM_F(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, Draw_Tramming_Menu); - MENU_ITEM_F(ICON_CloseMotor, MSG_DISABLE_STEPPERS, onDrawDisableMotors, DisableMotors); + MENU_ITEM(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, Draw_Move_Menu); + MENU_ITEM(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, Draw_Tramming_Menu); + MENU_ITEM(ICON_CloseMotor, MSG_DISABLE_STEPPERS, onDrawDisableMotors, DisableMotors); #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) - MENU_ITEM_F(ICON_Homing, MSG_HOMING, onDrawSubMenu, Draw_Homing_Menu); + MENU_ITEM(ICON_Homing, MSG_HOMING, onDrawSubMenu, Draw_Homing_Menu); #else - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawAutoHome, AutoHome); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawAutoHome, AutoHome); #endif #if ENABLED(MESH_BED_LEVELING) - MENU_ITEM_F(ICON_ManualMesh, MSG_MANUAL_MESH, onDrawSubMenu, Draw_ManualMesh_Menu); - #endif - #if HAS_ONESTEP_LEVELING - MENU_ITEM_F(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); + MENU_ITEM(ICON_ManualMesh, MSG_MANUAL_MESH, onDrawSubMenu, Draw_ManualMesh_Menu); + #elif HAS_BED_PROBE + MENU_ITEM(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); #endif #if HAS_ZOFFSET_ITEM - #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - MENU_ITEM_F(ICON_SetZOffset, MSG_PROBE_WIZARD, onDrawSubMenu, Draw_ZOffsetWiz_Menu); - #elif JUST_BABYSTEP - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); - #else - MENU_ITEM_F(ICON_SetHome, MSG_SET_HOME_OFFSETS, onDrawHomeOffset, SetHome); + #if HAS_BED_PROBE + MENU_ITEM(ICON_SetZOffset, MSG_PROBE_WIZARD, onDrawSubMenu, Draw_ZOffsetWiz_Menu); + #elif ENABLED(BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_HOME_OFFSET_Z, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); + #elif HAS_HOME_OFFSET + MENU_ITEM(ICON_SetHome, MSG_SET_HOME_OFFSETS, onDrawHomeOffset, SetHome); #endif #endif #if HAS_PREHEAT - MENU_ITEM_F(ICON_PLAPreheat, MSG_PREHEAT_1, onDrawPreheat1, DoPreheat0); - #if PREHEAT_COUNT > 1 - MENU_ITEM(ICON_ABSPreheat, F("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, DoPreheat1); - #if PREHEAT_COUNT > 2 - MENU_ITEM(ICON_CustomPreheat, F("Preheat " PREHEAT_3_LABEL), onDrawMenuItem, DoPreheat2); - #endif - #endif + #define _ITEM_PREHEAT(N) MENU_ITEM(ICON_Preheat##N, MSG_PREHEAT_##N, onDrawMenuItem, DoPreheat##N); + REPEAT_1(PREHEAT_COUNT, _ITEM_PREHEAT) #endif - MENU_ITEM_F(ICON_Cool, MSG_COOLDOWN, onDrawCooldown, DoCoolDown); - MENU_ITEM_F(ICON_Language, MSG_UI_LANGUAGE, onDrawLanguage, SetLanguage); + MENU_ITEM(ICON_Cool, MSG_COOLDOWN, onDrawCooldown, DoCoolDown); + MENU_ITEM(ICON_Language, MSG_UI_LANGUAGE, onDrawLanguage, SetLanguage); } ui.reset_status(true); - CurrentMenu->draw(); + UpdateMenu(PrepareMenu); } void Draw_Tramming_Menu() { checkkey = Menu; - if (SetMenu(TrammingMenu, GET_TEXT_F(MSG_BED_TRAMMING), 8)) { + if (SET_MENU(TrammingMenu, MSG_BED_TRAMMING, 8)) { BACK_ITEM(Draw_Prepare_Menu); #if HAS_BED_PROBE - MENU_ITEM_F(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); - EDIT_ITEM_F(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); + MENU_ITEM(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); + EDIT_ITEM(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); #else - MENU_ITEM(ICON_MoveZ0, F("Home Z and disable"), onDrawMenuItem, HomeZandDisable); + MENU_ITEM_F(ICON_MoveZ0, "Home Z and disable", onDrawMenuItem, HomeZandDisable); #endif - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_FL, onDrawMenuItem, TramFL); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_FR, onDrawMenuItem, TramFR); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_BR, onDrawMenuItem, TramBR); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_BL, onDrawMenuItem, TramBL); - MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_C ), onDrawMenuItem, TramC ); + MENU_ITEM(ICON_Axis, MSG_LEVBED_FL, onDrawMenuItem, TramFL); + MENU_ITEM(ICON_Axis, MSG_LEVBED_FR, onDrawMenuItem, TramFR); + MENU_ITEM(ICON_Axis, MSG_LEVBED_BR, onDrawMenuItem, TramBR); + MENU_ITEM(ICON_Axis, MSG_LEVBED_BL, onDrawMenuItem, TramBL); + MENU_ITEM(ICON_Axis, MSG_LEVBED_C, onDrawMenuItem, TramC ); } UpdateMenu(TrammingMenu); } void Draw_Control_Menu() { checkkey = Menu; - if (!ControlMenu) ControlMenu = new MenuClass(); - if (CurrentMenu != ControlMenu) { - CurrentMenu = ControlMenu; - SetMenuTitle({103, 1, 28, 14}, GET_TEXT_F(MSG_CONTROL)); - MenuItemsPrepare(10); + if (SET_MENU_R(ControlMenu, selrect({103, 1, 28, 14}), MSG_CONTROL, 10)) { BACK_ITEM(Goto_Main_Menu); - MENU_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawTempSubMenu, Draw_Temperature_Menu); - MENU_ITEM_F(ICON_Motion, MSG_MOTION, onDrawMotionSubMenu, Draw_Motion_Menu); + MENU_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawTempSubMenu, Draw_Temperature_Menu); + MENU_ITEM(ICON_Motion, MSG_MOTION, onDrawMotionSubMenu, Draw_Motion_Menu); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); - MENU_ITEM_F(ICON_ReadEEPROM, MSG_LOAD_EEPROM, onDrawReadEeprom, ReadEeprom); - MENU_ITEM_F(ICON_ResumeEEPROM, MSG_RESTORE_DEFAULTS, onDrawResetEeprom, ResetEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); + MENU_ITEM(ICON_ReadEEPROM, MSG_LOAD_EEPROM, onDrawReadEeprom, ReadEeprom); + MENU_ITEM(ICON_ResumeEEPROM, MSG_RESTORE_DEFAULTS, onDrawResetEeprom, ResetEeprom); #endif - MENU_ITEM_F(ICON_Reboot, MSG_RESET_PRINTER, onDrawMenuItem, RebootPrinter); + MENU_ITEM(ICON_Reboot, MSG_RESET_PRINTER, onDrawMenuItem, RebootPrinter); #if ENABLED(CASE_LIGHT_MENU) #if ENABLED(CASELIGHT_USES_BRIGHTNESS) - MENU_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawSubMenu, Draw_CaseLight_Menu); + MENU_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawSubMenu, Draw_CaseLight_Menu); #else - MENU_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + MENU_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); #endif #endif #if ENABLED(LED_CONTROL_MENU) - MENU_ITEM_F(ICON_LedControl, MSG_LED_CONTROL, onDrawSubMenu, Draw_LedControl_Menu); + MENU_ITEM(ICON_LedControl, MSG_LED_CONTROL, onDrawSubMenu, Draw_LedControl_Menu); #endif - MENU_ITEM_F(ICON_Info, MSG_INFO_SCREEN, onDrawInfoSubMenu, Goto_Info_Menu); + MENU_ITEM(ICON_Info, MSG_INFO_SCREEN, onDrawInfoSubMenu, Goto_Info_Menu); } ui.reset_status(true); - CurrentMenu->draw(); + UpdateMenu(ControlMenu); } void Draw_AdvancedSettings_Menu() { checkkey = Menu; - if (SetMenu(AdvancedSettings, GET_TEXT_F(MSG_ADVANCED_SETTINGS), 20)) { + if (SET_MENU(AdvancedSettings, MSG_ADVANCED_SETTINGS, 18)) { BACK_ITEM(Goto_Main_Menu); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); - #endif - #if HAS_BED_PROBE - MENU_ITEM_F(ICON_ProbeSet, MSG_ZPROBE_SETTINGS, onDrawSubMenu, Draw_ProbeSet_Menu); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif #if HAS_MESH - MENU_ITEM_F(ICON_ProbeSet, MSG_MESH_LEVELING, onDrawSubMenu, Draw_MeshSet_Menu); + MENU_ITEM(ICON_ProbeSet, MSG_MESH_LEVELING, onDrawSubMenu, Draw_MeshSet_Menu); #endif - #if HAS_HOME_OFFSET - MENU_ITEM_F(ICON_HomeOffset, MSG_SET_HOME_OFFSETS, onDrawSubMenu, Draw_HomeOffset_Menu); + #if HAS_BED_PROBE + MENU_ITEM(ICON_ProbeSet, MSG_ZPROBE_SETTINGS, onDrawSubMenu, Draw_ProbeSet_Menu); #endif + MENU_ITEM(ICON_FilSet, MSG_FILAMENT_SET, onDrawSubMenu, Draw_FilSet_Menu); #if ENABLED(PIDTEMP) - MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID " Settings"), onDrawSubMenu, Draw_HotendPID_Menu); + MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID " Settings", onDrawSubMenu, Draw_HotendPID_Menu); #endif #if ENABLED(PIDTEMPBED) - MENU_ITEM(ICON_PIDbed, F(STR_BED_PID " Settings"), onDrawSubMenu, Draw_BedPID_Menu); - #endif - MENU_ITEM_F(ICON_FilSet, MSG_FILAMENT_SET, onDrawSubMenu, Draw_FilSet_Menu); - #if ENABLED(POWER_LOSS_RECOVERY) - EDIT_ITEM_F(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); - #endif - #if ENABLED(BAUD_RATE_GCODE) - EDIT_ITEM(ICON_SetBaudRate, F("115K baud"), onDrawChkbMenu, SetBaudRate, &HMI_data.Baud115K); - #endif - #if HAS_LCD_BRIGHTNESS - EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); - MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); - #endif - MENU_ITEM_F(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, Draw_SelectColors_Menu); - #if ENABLED(SOUND_MENU_ITEM) - EDIT_ITEM_F(ICON_Sound, MSG_SOUND_ENABLE, onDrawChkbMenu, SetEnableSound, &ui.sound_on); + MENU_ITEM_F(ICON_PIDBed, STR_BED_PID " Settings", onDrawSubMenu, Draw_BedPID_Menu); #endif #if HAS_ESDIAG - MENU_ITEM(ICON_ESDiag, F("End-stops diag."), onDrawSubMenu, Draw_EndStopDiag); + MENU_ITEM_F(ICON_ESDiag, "End-stops diag.", onDrawSubMenu, Draw_EndStopDiag); #endif #if ENABLED(PRINTCOUNTER) - MENU_ITEM_F(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); - MENU_ITEM_F(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStats.Reset); + MENU_ITEM(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); + MENU_ITEM(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStatsReset); #endif #if HAS_LOCKSCREEN - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #endif + #if ENABLED(SOUND_MENU_ITEM) + EDIT_ITEM(ICON_Sound, MSG_SOUND_ENABLE, onDrawChkbMenu, SetEnableSound, &ui.sound_on); + #endif + #if ENABLED(POWER_LOSS_RECOVERY) + EDIT_ITEM(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); + #endif + EDIT_ITEM(ICON_File, MSG_MEDIA_UPDATE, onDrawChkbMenu, SetMediaAutoMount, &HMI_data.MediaAutoMount); + #if ENABLED(BAUD_RATE_GCODE) + EDIT_ITEM_F(ICON_SetBaudRate, "115K baud", onDrawChkbMenu, SetBaudRate, &HMI_data.Baud115K); + #endif + #if HAS_LCD_BRIGHTNESS + EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); + #endif + MENU_ITEM(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, Draw_SelectColors_Menu); } ui.reset_status(true); UpdateMenu(AdvancedSettings); @@ -3262,31 +3087,29 @@ void Draw_AdvancedSettings_Menu() { void Draw_Move_Menu() { checkkey = Menu; - if (!MoveMenu) MoveMenu = new MenuClass(); - if (CurrentMenu != MoveMenu) { - CurrentMenu = MoveMenu; - SetMenuTitle({192, 1, 42, 14}, GET_TEXT_F(MSG_MOVE_AXIS)); - MenuItemsPrepare(5); + if (SET_MENU_R(MoveMenu, selrect({192, 1, 42, 14}), MSG_MOVE_AXIS, 6)) { BACK_ITEM(Draw_Prepare_Menu); - EDIT_ITEM_F(ICON_MoveX, MSG_MOVE_X, onDrawMoveX, SetMoveX, ¤t_position.x); - EDIT_ITEM_F(ICON_MoveY, MSG_MOVE_Y, onDrawMoveY, SetMoveY, ¤t_position.y); - EDIT_ITEM_F(ICON_MoveZ, MSG_MOVE_Z, onDrawMoveZ, SetMoveZ, ¤t_position.z); + EDIT_ITEM(ICON_Axis, MSG_LIVE_MOVE, onDrawChkbMenu, SetLiveMove, &EnableLiveMove); + EDIT_ITEM(ICON_MoveX, MSG_MOVE_X, onDrawMoveX, SetMoveX, ¤t_position.x); + EDIT_ITEM(ICON_MoveY, MSG_MOVE_Y, onDrawMoveY, SetMoveY, ¤t_position.y); + EDIT_ITEM(ICON_MoveZ, MSG_MOVE_Z, onDrawMoveZ, SetMoveZ, ¤t_position.z); #if HAS_HOTEND - EDIT_ITEM_F(ICON_Extruder, MSG_MOVE_E, onDrawMoveE, SetMoveE, ¤t_position.e); + gcode.process_subcommands_now(F("G92E0")); // reset extruder position + EDIT_ITEM(ICON_Extruder, MSG_MOVE_E, onDrawMoveE, SetMoveE, ¤t_position.e); #endif } - CurrentMenu->draw(); + UpdateMenu(MoveMenu); if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: Current position unknown. Home axes."); } #if HAS_HOME_OFFSET void Draw_HomeOffset_Menu() { checkkey = Menu; - if (SetMenu(HomeOffMenu, GET_TEXT_F(MSG_SET_HOME_OFFSETS), 4)) { - BACK_ITEM(Draw_AdvancedSettings_Menu); - EDIT_ITEM_F(ICON_HomeOffsetX, MSG_HOME_OFFSET_X, onDrawPFloatMenu, SetHomeOffsetX, &home_offset.x); - EDIT_ITEM_F(ICON_HomeOffsetY, MSG_HOME_OFFSET_Y, onDrawPFloatMenu, SetHomeOffsetY, &home_offset.y); - EDIT_ITEM_F(ICON_HomeOffsetZ, MSG_HOME_OFFSET_Z, onDrawPFloatMenu, SetHomeOffsetZ, &home_offset.z); + if (SET_MENU(HomeOffMenu, MSG_SET_HOME_OFFSETS, 4)) { + BACK_ITEM(Draw_PhySet_Menu); + EDIT_ITEM(ICON_HomeOffsetX, MSG_HOME_OFFSET_X, onDrawPFloatMenu, SetHomeOffsetX, &home_offset.x); + EDIT_ITEM(ICON_HomeOffsetY, MSG_HOME_OFFSET_Y, onDrawPFloatMenu, SetHomeOffsetY, &home_offset.y); + EDIT_ITEM(ICON_HomeOffsetZ, MSG_HOME_OFFSET_Z, onDrawPFloatMenu, SetHomeOffsetZ, &home_offset.z); } UpdateMenu(HomeOffMenu); } @@ -3295,45 +3118,44 @@ void Draw_Move_Menu() { #if HAS_BED_PROBE void Draw_ProbeSet_Menu() { checkkey = Menu; - if (SetMenu(ProbeSetMenu, GET_TEXT_F(MSG_ZPROBE_SETTINGS), 8)) { + if (SET_MENU(ProbeSetMenu, MSG_ZPROBE_SETTINGS, 9)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - EDIT_ITEM_F(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); - EDIT_ITEM_F(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); - EDIT_ITEM_F(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); + EDIT_ITEM(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); + EDIT_ITEM(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); + EDIT_ITEM(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); #if ENABLED(BLTOUCH) - MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); - MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); - MENU_ITEM_F(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset); - #ifdef BLTOUCH_HS_MODE - EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); + MENU_ITEM(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); + MENU_ITEM(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); + MENU_ITEM(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset); + #if ENABLED(BLTOUCH_HS_MODE) + EDIT_ITEM(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); #endif #endif - MENU_ITEM_F(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); + MENU_ITEM(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); } UpdateMenu(ProbeSetMenu); } - #endif void Draw_FilSet_Menu() { checkkey = Menu; - if (SetMenu(FilSetMenu, GET_TEXT_F(MSG_FILAMENT_SET), 9)) { + if (SET_MENU(FilSetMenu, MSG_FILAMENT_SET, 9)) { BACK_ITEM(Draw_AdvancedSettings_Menu); #if HAS_FILAMENT_SENSOR - EDIT_ITEM_F(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); #endif #if HAS_FILAMENT_RUNOUT_DISTANCE - EDIT_ITEM_F(ICON_Runout, MSG_RUNOUT_DISTANCE_MM, onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_DISTANCE_MM, onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); #endif #if ENABLED(PREVENT_COLD_EXTRUSION) - EDIT_ITEM_F(ICON_ExtrudeMinT, MSG_EXTRUDER_MIN_TEMP, onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); + EDIT_ITEM(ICON_ExtrudeMinT, MSG_EXTRUDER_MIN_TEMP, onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) - EDIT_ITEM_F(ICON_FilLoad, MSG_FILAMENT_LOAD, onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); - EDIT_ITEM_F(ICON_FilUnload, MSG_FILAMENT_UNLOAD, onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); + EDIT_ITEM(ICON_FilLoad, MSG_FILAMENT_LOAD, onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); + EDIT_ITEM(ICON_FilUnload, MSG_FILAMENT_UNLOAD, onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); #endif #if ENABLED(FWRETRACT) - MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + MENU_ITEM(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); #endif } UpdateMenu(FilSetMenu); @@ -3341,80 +3163,80 @@ void Draw_FilSet_Menu() { void Draw_SelectColors_Menu() { checkkey = Menu; - if (SetMenu(SelectColorMenu, GET_TEXT_F(MSG_COLORS_SELECT), 20)) { + if (SET_MENU(SelectColorMenu, MSG_COLORS_SELECT, 20)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - MENU_ITEM_F(ICON_StockConfiguration, MSG_RESTORE_DEFAULTS, onDrawMenuItem, RestoreDefaultsColors); - EDIT_ITEM(0, F("Screen Background"), onDrawSelColorItem, SelColor, &HMI_data.Background_Color); - EDIT_ITEM(0, F("Cursor"), onDrawSelColorItem, SelColor, &HMI_data.Cursor_color); - EDIT_ITEM(0, F("Title Background"), onDrawSelColorItem, SelColor, &HMI_data.TitleBg_color); - EDIT_ITEM(0, F("Title Text"), onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_color); - EDIT_ITEM(0, F("Text"), onDrawSelColorItem, SelColor, &HMI_data.Text_Color); - EDIT_ITEM(0, F("Selected"), onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); - EDIT_ITEM(0, F("Split Line"), onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); - EDIT_ITEM(0, F("Highlight"), onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); - EDIT_ITEM(0, F("Status Background"), onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); - EDIT_ITEM(0, F("Status Text"), onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); - EDIT_ITEM(0, F("Popup Background"), onDrawSelColorItem, SelColor, &HMI_data.PopupBg_color); - EDIT_ITEM(0, F("Popup Text"), onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); - EDIT_ITEM(0, F("Alert Background"), onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); - EDIT_ITEM(0, F("Alert Text"), onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); - EDIT_ITEM(0, F("Percent Text"), onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); - EDIT_ITEM(0, F("Bar Fill"), onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); - EDIT_ITEM(0, F("Indicator value"), onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); - EDIT_ITEM(0, F("Coordinate value"), onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); + MENU_ITEM(ICON_StockConfiguration, MSG_RESTORE_DEFAULTS, onDrawMenuItem, RestoreDefaultColors); + EDIT_ITEM_F(0, "Screen Background", onDrawSelColorItem, SelColor, &HMI_data.Background_Color); + EDIT_ITEM_F(0, "Cursor", onDrawSelColorItem, SelColor, &HMI_data.Cursor_Color); + EDIT_ITEM_F(0, "Title Background", onDrawSelColorItem, SelColor, &HMI_data.TitleBg_Color); + EDIT_ITEM_F(0, "Title Text", onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_Color); + EDIT_ITEM_F(0, "Text", onDrawSelColorItem, SelColor, &HMI_data.Text_Color); + EDIT_ITEM_F(0, "Selected", onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); + EDIT_ITEM_F(0, "Split Line", onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); + EDIT_ITEM_F(0, "Highlight", onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); + EDIT_ITEM_F(0, "Status Background", onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); + EDIT_ITEM_F(0, "Status Text", onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); + EDIT_ITEM_F(0, "Popup Background", onDrawSelColorItem, SelColor, &HMI_data.PopupBg_Color); + EDIT_ITEM_F(0, "Popup Text", onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); + EDIT_ITEM_F(0, "Alert Background", onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); + EDIT_ITEM_F(0, "Alert Text", onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); + EDIT_ITEM_F(0, "Percent Text", onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); + EDIT_ITEM_F(0, "Bar Fill", onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); + EDIT_ITEM_F(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); + EDIT_ITEM_F(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); } UpdateMenu(SelectColorMenu); } void Draw_GetColor_Menu() { checkkey = Menu; - if (SetMenu(GetColorMenu, GET_TEXT_F(MSG_COLORS_GET), 5)) { + if (SET_MENU(GetColorMenu, MSG_COLORS_GET, 5)) { BACK_ITEM(DWIN_ApplyColor); - MENU_ITEM_F(ICON_Cancel, MSG_BUTTON_CANCEL, onDrawMenuItem, Draw_SelectColors_Menu); - MENU_ITEM_F(0, MSG_COLORS_RED, onDrawGetColorItem, SetRGBColor); - MENU_ITEM_F(1, MSG_COLORS_GREEN, onDrawGetColorItem, SetRGBColor); - MENU_ITEM_F(2, MSG_COLORS_BLUE, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(ICON_Cancel, MSG_BUTTON_CANCEL, onDrawMenuItem, Draw_SelectColors_Menu); + MENU_ITEM(0, MSG_COLORS_RED, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(1, MSG_COLORS_GREEN, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(2, MSG_COLORS_BLUE, onDrawGetColorItem, SetRGBColor); } UpdateMenu(GetColorMenu); DWIN_Draw_Rectangle(1, *MenuData.P_Int, 20, 315, DWIN_WIDTH - 20, 335); } #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - void Draw_CaseLight_Menu() { - checkkey = Menu; - if (SetMenu(CaseLightMenu, GET_TEXT_F(MSG_CASE_LIGHT), 3)) { - BACK_ITEM(Draw_Control_Menu); - EDIT_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); - EDIT_ITEM_F(ICON_Brightness, MSG_CASE_LIGHT_BRIGHTNESS, onDrawPInt8Menu, SetCaseLightBrightness, &caselight.brightness); - } - UpdateMenu(CaseLightMenu); + void Draw_CaseLight_Menu() { + checkkey = Menu; + if (SET_MENU(CaseLightMenu, MSG_CASE_LIGHT, 3)) { + BACK_ITEM(Draw_Control_Menu); + EDIT_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + EDIT_ITEM(ICON_Brightness, MSG_CASE_LIGHT_BRIGHTNESS, onDrawPInt8Menu, SetCaseLightBrightness, &caselight.brightness); } + UpdateMenu(CaseLightMenu); + } #endif #if ENABLED(LED_CONTROL_MENU) void Draw_LedControl_Menu() { checkkey = Menu; - if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) { + if (SET_MENU(LedControlMenu, MSG_LED_CONTROL, 10)) { BACK_ITEM(Draw_Control_Menu); #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) - EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); + EDIT_ITEM(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); #endif #if HAS_COLOR_LEDS #if ENABLED(LED_COLOR_PRESETS) - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_WHITE, onDrawMenuItem, leds.set_white); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_RED, onDrawMenuItem, leds.set_red); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_ORANGE, onDrawMenuItem, leds.set_orange); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_YELLOW, onDrawMenuItem, leds.set_yellow); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_GREEN, onDrawMenuItem, leds.set_green); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_BLUE, onDrawMenuItem, leds.set_blue); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_INDIGO, onDrawMenuItem, leds.set_indigo); - MENU_ITEM_F(ICON_LedControl, MSG_SET_LEDS_VIOLET, onDrawMenuItem, leds.set_violet); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_WHITE, onDrawMenuItem, leds.set_white); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_RED, onDrawMenuItem, leds.set_red); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_ORANGE, onDrawMenuItem, leds.set_orange); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_YELLOW, onDrawMenuItem, leds.set_yellow); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_GREEN, onDrawMenuItem, leds.set_green); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_BLUE, onDrawMenuItem, leds.set_blue); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_INDIGO, onDrawMenuItem, leds.set_indigo); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_VIOLET, onDrawMenuItem, leds.set_violet); #else - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); #if ENABLED(HAS_WHITE_LED) - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLEDColorW, &leds.color.w); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLEDColorW, &leds.color.w); #endif #endif #endif @@ -3425,77 +3247,76 @@ void Draw_GetColor_Menu() { void Draw_Tune_Menu() { checkkey = Menu; - if (!TuneMenu) TuneMenu = new MenuClass(); - if (CurrentMenu != TuneMenu) { - CurrentMenu = TuneMenu; - SetMenuTitle({73, 2, 28, 12}, GET_TEXT_F(MSG_TUNE)); // TODO: Chinese, English "Tune" JPG - MenuItemsPrepare(16); + if (SET_MENU_R(TuneMenu, selrect({73, 2, 28, 12}), MSG_TUNE, 14)) { BACK_ITEM(Goto_PrintProcess); - EDIT_ITEM_F(ICON_Speed, MSG_SPEED, onDrawSpeedItem, SetSpeed, &feedrate_percentage); + EDIT_ITEM(ICON_Speed, MSG_SPEED, onDrawSpeedItem, SetSpeed, &feedrate_percentage); #if HAS_HOTEND - HotendTargetItem = EDIT_ITEM_F(ICON_HotendTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM(ICON_HotendTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = EDIT_ITEM_F(ICON_BedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM(ICON_BedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif - #if HAS_ZOFFSET_ITEM && EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawZOffset, SetZOffset, &BABY_Z_VAR); + #if ALL(HAS_ZOFFSET_ITEM, HAS_BED_PROBE, BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawZOffset, SetZOffset, &BABY_Z_VAR); + #elif ALL(HAS_ZOFFSET_ITEM, MESH_BED_LEVELING, BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_HOME_OFFSET_Z, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); #endif - EDIT_ITEM_F(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + EDIT_ITEM(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); #if ENABLED(ADVANCED_PAUSE_FEATURE) - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + MENU_ITEM(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + #endif + #if HAS_FILAMENT_SENSOR + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); #endif #if ENABLED(FWRETRACT) - MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + MENU_ITEM(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); #endif #if HAS_LOCKSCREEN - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #endif #if HAS_LCD_BRIGHTNESS - EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); - MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); + EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); #endif #if ENABLED(CASE_LIGHT_MENU) - EDIT_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + EDIT_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); #elif ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) - EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); + EDIT_ITEM(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); #endif } - CurrentMenu->draw(); + UpdateMenu(TuneMenu); } void Draw_Motion_Menu() { checkkey = Menu; - if (!MotionMenu) MotionMenu = new MenuClass(); - if (CurrentMenu != MotionMenu) { - CurrentMenu = MotionMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MOTION)); // TODO: Chinese, English "Motion" JPG - MenuItemsPrepare(6); + if (SET_MENU_R(MotionMenu, selrect({1, 16, 28, 13}), MSG_MOTION, 6)) { BACK_ITEM(Draw_Control_Menu); - MENU_ITEM_F(ICON_MaxSpeed, MSG_SPEED, onDrawSpeed, Draw_MaxSpeed_Menu); - MENU_ITEM_F(ICON_MaxAccelerated, MSG_ACCELERATION, onDrawAcc, Draw_MaxAccel_Menu); + MENU_ITEM(ICON_MaxSpeed, MSG_SPEED, onDrawSpeed, Draw_MaxSpeed_Menu); + MENU_ITEM(ICON_MaxAccelerated, MSG_ACCELERATION, onDrawAcc, Draw_MaxAccel_Menu); #if HAS_CLASSIC_JERK - MENU_ITEM_F(ICON_MaxJerk, MSG_JERK, onDrawJerk, Draw_MaxJerk_Menu); + MENU_ITEM(ICON_MaxJerk, MSG_JERK, onDrawJerk, Draw_MaxJerk_Menu); #endif - MENU_ITEM_F(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, Draw_Steps_Menu); - EDIT_ITEM_F(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + MENU_ITEM(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, Draw_Steps_Menu); + EDIT_ITEM(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); } - CurrentMenu->draw(); + UpdateMenu(MotionMenu); } #if ENABLED(ADVANCED_PAUSE_FEATURE) void Draw_FilamentMan_Menu() { checkkey = Menu; - if (SetMenu(FilamentMenu, GET_TEXT_F(MSG_FILAMENT_MAN), 5)) { + if (SET_MENU(FilamentMenu, MSG_FILAMENT_MAN, 5)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Park, MSG_FILAMENT_PARK_ENABLED, onDrawMenuItem, ParkHead); - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + #if ENABLED(NOZZLE_PARK_FEATURE) + MENU_ITEM(ICON_Park, MSG_FILAMENT_PARK_ENABLED, onDrawMenuItem, ParkHead); + #endif + MENU_ITEM(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - MENU_ITEM_F(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, UnloadFilament); - MENU_ITEM_F(ICON_FilLoad, MSG_FILAMENTLOAD, onDrawMenuItem, LoadFilament); + MENU_ITEM(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, UnloadFilament); + MENU_ITEM(ICON_FilLoad, MSG_FILAMENTLOAD, onDrawMenuItem, LoadFilament); #endif } UpdateMenu(FilamentMenu); @@ -3505,13 +3326,13 @@ void Draw_Motion_Menu() { #if ENABLED(MESH_BED_LEVELING) void Draw_ManualMesh_Menu() { checkkey = Menu; - if (SetMenu(ManualMesh, GET_TEXT_F(MSG_UBL_MANUAL_MESH), 6)) { + if (SET_MENU(ManualMesh, MSG_UBL_MANUAL_MESH, 6)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_ManualMesh, MSG_LEVEL_BED, onDrawMenuItem, ManualMeshStart); - MMeshMoveZItem = EDIT_ITEM_F(ICON_Zoffset, MSG_MOVE_Z, onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); - MENU_ITEM_F(ICON_Axis, MSG_UBL_CONTINUE_MESH, onDrawMenuItem, ManualMeshContinue); - MENU_ITEM_F(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); - MENU_ITEM_F(ICON_MeshSave, MSG_UBL_SAVE_MESH, onDrawMenuItem, ManualMeshSave); + MENU_ITEM(ICON_ManualMesh, MSG_LEVEL_BED, onDrawMenuItem, ManualMeshStart); + MMeshMoveZItem = EDIT_ITEM(ICON_Zoffset, MSG_MOVE_Z, onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); + MENU_ITEM(ICON_Axis, MSG_UBL_CONTINUE_MESH, onDrawMenuItem, ManualMeshContinue); + MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); + MENU_ITEM(ICON_MeshSave, MSG_UBL_SAVE_MESH, onDrawMenuItem, ManualMeshSave); } UpdateMenu(ManualMesh); } @@ -3519,170 +3340,127 @@ void Draw_Motion_Menu() { #if HAS_PREHEAT - void Draw_Preheat_Menu(frame_rect_t cn, const __FlashStringHelper* fstr) { + void Draw_Preheat_Menu(bool NotCurrent) { checkkey = Menu; - if (CurrentMenu != PreheatMenu) { - CurrentMenu = PreheatMenu; - SetMenuTitle(cn, fstr); - MenuItemsPrepare(5); + if (NotCurrent) { BACK_ITEM(Draw_Temperature_Menu); #if HAS_HOTEND - EDIT_ITEM_F(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Select].hotend_temp); + EDIT_ITEM(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Select].hotend_temp); #endif #if HAS_HEATED_BED - EDIT_ITEM_F(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Select].bed_temp); + EDIT_ITEM(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Select].bed_temp); #endif #if HAS_FAN - EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Select].fan_speed); + EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Select].fan_speed); #endif #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); #endif } - CurrentMenu->draw(); + UpdateMenu(PreheatMenu); } - void Draw_Preheat1_Menu() { - HMI_value.Select = 0; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({59, 16, 81, 14}, F(PREHEAT_1_LABEL " Preheat Settings")); // TODO: English "PLA Settings" JPG - } - - #if PREHEAT_COUNT >= 2 - void Draw_Preheat2_Menu() { - HMI_value.Select = 1; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({142, 16, 82, 14}, F(PREHEAT_2_LABEL " Preheat Settings")); // TODO: English "ABS Settings" JPG + #define _Preheat_Menu(N) \ + void Draw_Preheat## N ##_Menu() { \ + HMI_value.Select = N-1; \ + Draw_Preheat_Menu(SET_MENU(PreheatMenu, MSG_PREHEAT_## N ##_SETTINGS, 5)); \ } - #endif - - #if PREHEAT_COUNT >= 3 - void Draw_Preheat3_Menu() { - HMI_value.Select = 2; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({225, 16, 82, 14}, F(PREHEAT_3_LABEL " Preheat Settings")); // TODO: English "... Settings" JPG - } - #endif + REPEAT_1(PREHEAT_COUNT, _Preheat_Menu) #endif // HAS_PREHEAT void Draw_Temperature_Menu() { checkkey = Menu; - if (!TemperatureMenu) TemperatureMenu = new MenuClass(); - if (CurrentMenu != TemperatureMenu) { - CurrentMenu = TemperatureMenu; - SetMenuTitle({236, 2, 28, 12}, GET_TEXT_F(MSG_TEMPERATURE)); - MenuItemsPrepare(7); + if (SET_MENU_R(TemperatureMenu, selrect({236, 2, 28, 12}), MSG_TEMPERATURE, 4 + PREHEAT_COUNT)) { BACK_ITEM(Draw_Control_Menu); #if HAS_HOTEND - HotendTargetItem = EDIT_ITEM_F(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = EDIT_ITEM_F(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif #if HAS_PREHEAT - MENU_ITEM_F(ICON_SetPLAPreheat, MSG_PREHEAT_1_SETTINGS, onDrawPLAPreheatSubMenu, Draw_Preheat1_Menu); - #if PREHEAT_COUNT >= 2 - MENU_ITEM_F(ICON_SetABSPreheat, MSG_PREHEAT_2_SETTINGS, onDrawABSPreheatSubMenu, Draw_Preheat2_Menu); - #if PREHEAT_COUNT >= 3 - MENU_ITEM_F(ICON_SetCustomPreheat, MSG_PREHEAT_3_SETTINGS, onDrawSubMenu, Draw_Preheat3_Menu); - #endif - #endif + #define _ITEM_SETPREHEAT(N) MENU_ITEM(ICON_SetPreheat##N, MSG_PREHEAT_## N ##_SETTINGS, onDrawSubMenu, Draw_Preheat## N ##_Menu); + REPEAT_1(PREHEAT_COUNT, _ITEM_SETPREHEAT) #endif } - CurrentMenu->draw(); + UpdateMenu(TemperatureMenu); } void Draw_MaxSpeed_Menu() { checkkey = Menu; - if (!MaxSpeedMenu) MaxSpeedMenu = new MenuClass(); - if (CurrentMenu != MaxSpeedMenu) { - CurrentMenu = MaxSpeedMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MAX_SPEED)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxSpeedMenu, selrect({1, 16, 28, 13}), MSG_MAX_SPEED, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxSpeedX, MSG_VMAX_A, onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedY, MSG_VMAX_B, onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedZ, MSG_VMAX_C, onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); + EDIT_ITEM(ICON_MaxSpeedX, MSG_VMAX_A, onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); + EDIT_ITEM(ICON_MaxSpeedY, MSG_VMAX_B, onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); + EDIT_ITEM(ICON_MaxSpeedZ, MSG_VMAX_C, onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxSpeedE, MSG_VMAX_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]); + EDIT_ITEM(ICON_MaxSpeedE, MSG_VMAX_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxSpeedMenu); } void Draw_MaxAccel_Menu() { checkkey = Menu; - if (!MaxAccelMenu) MaxAccelMenu = new MenuClass(); - if (CurrentMenu != MaxAccelMenu) { - CurrentMenu = MaxAccelMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_ACCELERATION)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxAccelMenu, selrect({1, 16, 28, 13}), MSG_AMAX_EN, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxAccX, MSG_AMAX_A, onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); - EDIT_ITEM_F(ICON_MaxAccY, MSG_AMAX_B, onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); - EDIT_ITEM_F(ICON_MaxAccZ, MSG_AMAX_C, onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + EDIT_ITEM(ICON_MaxAccX, MSG_AMAX_A, onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); + EDIT_ITEM(ICON_MaxAccY, MSG_AMAX_B, onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + EDIT_ITEM(ICON_MaxAccZ, MSG_AMAX_C, onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxAccE, MSG_AMAX_E, onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); + EDIT_ITEM(ICON_MaxAccE, MSG_AMAX_E, onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxAccelMenu); } #if HAS_CLASSIC_JERK void Draw_MaxJerk_Menu() { checkkey = Menu; - if (!MaxJerkMenu) MaxJerkMenu = new MenuClass(); - if (CurrentMenu != MaxJerkMenu) { - CurrentMenu = MaxJerkMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_JERK)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxJerkMenu, selrect({1, 16, 28, 13}), MSG_JERK, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxSpeedJerkX, MSG_VA_JERK, onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk.x); - EDIT_ITEM_F(ICON_MaxSpeedJerkY, MSG_VB_JERK, onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk.y); - EDIT_ITEM_F(ICON_MaxSpeedJerkZ, MSG_VC_JERK, onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk.z); + EDIT_ITEM(ICON_MaxSpeedJerkX, MSG_VA_JERK, onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk.x); + EDIT_ITEM(ICON_MaxSpeedJerkY, MSG_VB_JERK, onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk.y); + EDIT_ITEM(ICON_MaxSpeedJerkZ, MSG_VC_JERK, onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk.z); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxSpeedJerkE, MSG_VE_JERK, onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk.e); + EDIT_ITEM(ICON_MaxSpeedJerkE, MSG_VE_JERK, onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk.e); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxJerkMenu); } #endif void Draw_Steps_Menu() { checkkey = Menu; - if (!StepsMenu) StepsMenu = new MenuClass(); - if (CurrentMenu != StepsMenu) { - CurrentMenu = StepsMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_STEPS_PER_MM)); - MenuItemsPrepare(5); + if (SET_MENU_R(StepsMenu, selrect({1, 16, 28, 13}), MSG_STEPS_PER_MM, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_StepX, MSG_A_STEPS, onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); - EDIT_ITEM_F(ICON_StepY, MSG_B_STEPS, onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); - EDIT_ITEM_F(ICON_StepZ, MSG_C_STEPS, onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); + EDIT_ITEM(ICON_StepX, MSG_A_STEPS, onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); + EDIT_ITEM(ICON_StepY, MSG_B_STEPS, onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); + EDIT_ITEM(ICON_StepZ, MSG_C_STEPS, onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_StepE, MSG_E_STEPS, onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); + EDIT_ITEM(ICON_StepE, MSG_E_STEPS, onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(StepsMenu); } #if ENABLED(PIDTEMP) void Draw_HotendPID_Menu() { checkkey = Menu; - if (SetMenu(HotendPIDMenu, F(STR_HOTEND_PID " Settings"), 8)) { + if (SET_MENU_F(HotendPIDMenu, STR_HOTEND_PID " Settings", 8)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID), onDrawMenuItem, HotendPID); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); - EDIT_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); - EDIT_ITEM_F(ICON_PIDcycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID, onDrawMenuItem, HotendPID); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KP, onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KI, onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KD, onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); + EDIT_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); + EDIT_ITEM(ICON_PIDCycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif } UpdateMenu(HotendPIDMenu); @@ -3692,30 +3470,30 @@ void Draw_Steps_Menu() { #if ENABLED(PIDTEMPBED) void Draw_BedPID_Menu() { checkkey = Menu; - if (SetMenu(BedPIDMenu, F(STR_BED_PID " Settings"), 8)) { + if (SET_MENU_F(BedPIDMenu, STR_BED_PID " Settings", 8)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - MENU_ITEM(ICON_PIDNozzle, F(STR_BED_PID), onDrawMenuItem,BedPID); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); - EDIT_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); - EDIT_ITEM_F(ICON_PIDcycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + MENU_ITEM_F(ICON_PIDBed, STR_BED_PID, onDrawMenuItem,BedPID); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KP, onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KI, onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KD, onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); + EDIT_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); + EDIT_ITEM(ICON_PIDCycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif } UpdateMenu(BedPIDMenu); } #endif -#if ENABLED(BABYSTEP_ZPROBE_OFFSET) +#if HAS_BED_PROBE void Draw_ZOffsetWiz_Menu() { checkkey = Menu; - if (SetMenu(ZOffsetWizMenu, GET_TEXT_F(MSG_PROBE_WIZARD), 4)) { + if (SET_MENU(ZOffsetWizMenu, MSG_PROBE_WIZARD, 4)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); - MENU_ITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0); - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); + MENU_ITEM_F(ICON_MoveZ0, "Move Z to Home", onDrawMenuItem, SetMoveZto0); + EDIT_ITEM(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); } UpdateMenu(ZOffsetWizMenu); if (!axis_is_trusted(Z_AXIS)) LCD_MESSAGE_F("WARNING: Z position unknown, move Z to home"); @@ -3725,12 +3503,15 @@ void Draw_Steps_Menu() { #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) void Draw_Homing_Menu() { checkkey = Menu; - if (SetMenu(HomingMenu, GET_TEXT_F(MSG_HOMING), 5)) { + if (SET_MENU(HomingMenu, MSG_HOMING, 6)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); - MENU_ITEM_F(ICON_HomeX, MSG_AUTO_HOME_X, onDrawMenuItem, HomeX); - MENU_ITEM_F(ICON_HomeY, MSG_AUTO_HOME_Y, onDrawMenuItem, HomeY); - MENU_ITEM_F(ICON_HomeZ, MSG_AUTO_HOME_Z, onDrawMenuItem, HomeZ); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); + MENU_ITEM(ICON_HomeX, MSG_AUTO_HOME_X, onDrawMenuItem, HomeX); + MENU_ITEM(ICON_HomeY, MSG_AUTO_HOME_Y, onDrawMenuItem, HomeY); + MENU_ITEM(ICON_HomeZ, MSG_AUTO_HOME_Z, onDrawMenuItem, HomeZ); + #if ENABLED(MESH_BED_LEVELING) + EDIT_ITEM(ICON_ZAfterHome, MSG_Z_AFTER_HOME, onDrawPInt8Menu, SetZAfterHoming, &HMI_data.z_after_homing); + #endif } UpdateMenu(HomingMenu); } @@ -3739,13 +3520,13 @@ void Draw_Steps_Menu() { #if ENABLED(FWRETRACT) void Draw_FWRetract_Menu() { checkkey = Menu; - if (SetMenu(FWRetractMenu, GET_TEXT_F(MSG_FWRETRACT), 6)) { + if (SET_MENU(FWRetractMenu, MSG_FWRETRACT, 6)) { BACK_ITEM(Return_FWRetract_Menu); - EDIT_ITEM_F(ICON_FWRetLength, MSG_CONTROL_RETRACT, onDrawPFloatMenu, SetRetractLength, &fwretract.settings.retract_length); - EDIT_ITEM_F(ICON_FWRetSpeed, MSG_SINGLENOZZLE_RETRACT_SPEED, onDrawPFloatMenu, SetRetractSpeed, &fwretract.settings.retract_feedrate_mm_s); - EDIT_ITEM_F(ICON_FWRetZRaise, MSG_CONTROL_RETRACT_ZHOP, onDrawPFloat2Menu, SetZRaise, &fwretract.settings.retract_zraise); - EDIT_ITEM_F(ICON_FWRecSpeed, MSG_SINGLENOZZLE_UNRETRACT_SPEED, onDrawPFloatMenu, SetRecoverSpeed, &fwretract.settings.retract_recover_feedrate_mm_s); - EDIT_ITEM_F(ICON_FWRecExtra, MSG_CONTROL_RETRACT_RECOVER, onDrawPFloatMenu, SetAddRecover, &fwretract.settings.retract_recover_extra); + EDIT_ITEM(ICON_FWRetLength, MSG_CONTROL_RETRACT, onDrawPFloatMenu, SetRetractLength, &fwretract.settings.retract_length); + EDIT_ITEM(ICON_FWRetSpeed, MSG_SINGLENOZZLE_RETRACT_SPEED, onDrawPFloatMenu, SetRetractSpeed, &fwretract.settings.retract_feedrate_mm_s); + EDIT_ITEM(ICON_FWRetZRaise, MSG_CONTROL_RETRACT_ZHOP, onDrawPFloat2Menu, SetZRaise, &fwretract.settings.retract_zraise); + EDIT_ITEM(ICON_FWRecSpeed, MSG_SINGLENOZZLE_UNRETRACT_SPEED, onDrawPFloatMenu, SetRecoverSpeed, &fwretract.settings.retract_recover_feedrate_mm_s); + EDIT_ITEM(ICON_FWRecExtra, MSG_CONTROL_RETRACT_RECOVER, onDrawPFloatMenu, SetAddRecover, &fwretract.settings.retract_recover_extra); } UpdateMenu(FWRetractMenu); } @@ -3774,11 +3555,11 @@ void Draw_Steps_Menu() { #define Z_OFFSET_MIN -3 #define Z_OFFSET_MAX 3 - void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? BedLevelTools.mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : BedLevelTools.mesh_y]; EditZValueItem->redraw(); } - void ApplyEditMeshX() { BedLevelTools.mesh_x = MenuData.Value; } - void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, BedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); } - void ApplyEditMeshY() { BedLevelTools.mesh_y = MenuData.Value; } - void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, BedLevelTools.mesh_y, ApplyEditMeshY, LiveEditMesh); } + void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? bedLevelTools.mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : bedLevelTools.mesh_y]; EditZValueItem->redraw(); } + void ApplyEditMeshX() { bedLevelTools.mesh_x = MenuData.Value; } + void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, bedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); } + void ApplyEditMeshY() { bedLevelTools.mesh_y = MenuData.Value; } + void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, bedLevelTools.mesh_y, ApplyEditMeshY, LiveEditMesh); } void SetEditZValue() { SetPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } #endif #endif @@ -3792,14 +3573,14 @@ void Draw_Steps_Menu() { onDrawIntMenu(menuitem, line, bedlevel.storage_slot); } - void ApplyUBLTiltGrid() { BedLevelTools.tilt_grid = MenuData.Value; } - void SetUBLTiltGrid() { SetIntOnClick(1, 3, BedLevelTools.tilt_grid, ApplyUBLTiltGrid); } + void ApplyUBLTiltGrid() { bedLevelTools.tilt_grid = MenuData.Value; } + void SetUBLTiltGrid() { SetIntOnClick(1, 3, bedLevelTools.tilt_grid, ApplyUBLTiltGrid); } void UBLTiltMesh() { if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; char buf[15]; - if (BedLevelTools.tilt_grid > 1) { - sprintf_P(buf, PSTR("G28O\nG29 J%i"), BedLevelTools.tilt_grid); + if (bedLevelTools.tilt_grid > 1) { + sprintf_P(buf, PSTR("G28O\nG29 J%i"), bedLevelTools.tilt_grid); gcode.process_subcommands_now(buf); } else @@ -3830,28 +3611,28 @@ void Draw_Steps_Menu() { void Draw_MeshSet_Menu() { checkkey = Menu; - if (SetMenu(MeshMenu, GET_TEXT_F(MSG_MESH_LEVELING), 15)) { + if (SET_MENU(MeshMenu, MSG_MESH_LEVELING, 13)) { BACK_ITEM(Draw_AdvancedSettings_Menu); #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) - EDIT_ITEM_F(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); + EDIT_ITEM(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); #endif - EDIT_ITEM_F(ICON_SetZOffset, MSG_Z_FADE_HEIGHT, onDrawPFloatMenu, SetMeshFadeHeight, &planner.z_fade_height); - EDIT_ITEM_F(ICON_UBLActive, MSG_ACTIVATE_MESH, onDrawChkbMenu, SetMeshActive, &planner.leveling_active); + EDIT_ITEM(ICON_SetZOffset, MSG_Z_FADE_HEIGHT, onDrawPFloatMenu, SetMeshFadeHeight, &planner.z_fade_height); + EDIT_ITEM(ICON_UBLActive, MSG_ACTIVATE_MESH, onDrawChkbMenu, SetMeshActive, &planner.leveling_active); #if HAS_BED_PROBE - MENU_ITEM_F(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); + MENU_ITEM(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh); - EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &BedLevelTools.tilt_grid); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); + EDIT_ITEM(ICON_UBLSlot, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); + MENU_ITEM(ICON_UBLSaveMesh, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh); + MENU_ITEM(ICON_UBLLoadMesh, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh); + EDIT_ITEM(ICON_UBLTiltGrid, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &bedLevelTools.tilt_grid); + MENU_ITEM(ICON_UBLTiltGrid, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh); + MENU_ITEM(ICON_UBLSmartFill, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); #endif #if ENABLED(MESH_EDIT_MENU) - MENU_ITEM_F(ICON_UBLActive, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu); + MENU_ITEM(ICON_MeshEdit, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu); #endif - MENU_ITEM_F(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); + MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); } UpdateMenu(MeshMenu); } @@ -3861,12 +3642,12 @@ void Draw_Steps_Menu() { if (!leveling_is_valid()) { LCD_MESSAGE(MSG_UBL_MESH_INVALID); return; } set_bed_leveling_enabled(false); checkkey = Menu; - if (SetMenu(EditMeshMenu, GET_TEXT_F(MSG_EDIT_MESH), 4)) { - BedLevelTools.mesh_x = BedLevelTools.mesh_y = 0; + if (SET_MENU(EditMeshMenu, MSG_EDIT_MESH, 4)) { + bedLevelTools.mesh_x = bedLevelTools.mesh_y = 0; BACK_ITEM(Draw_MeshSet_Menu); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX,&BedLevelTools.mesh_x); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY,&BedLevelTools.mesh_y); - EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[BedLevelTools.mesh_x][BedLevelTools.mesh_y]); + EDIT_ITEM(ICON_MeshEditX, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX, &bedLevelTools.mesh_x); + EDIT_ITEM(ICON_MeshEditY, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &bedLevelTools.mesh_y); + EditZValueItem = EDIT_ITEM(ICON_MeshEditZ, MSG_MESH_EDIT_Z, onDrawPFloat2Menu, SetEditZValue, &bedlevel.z_values[bedLevelTools.mesh_x][bedLevelTools.mesh_y]); } UpdateMenu(EditMeshMenu); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index f4c0618691..50be4a8ba5 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -24,16 +24,25 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.2 - * Date: 2022/04/08 + * Version: 3.21.2 + * Date: 2022/12/02 */ +#include "../../../inc/MarlinConfig.h" + #include "dwin_defines.h" #include "dwinui.h" #include "../common/encoder.h" #include "../../../libs/BL24CXX.h" -#include "../../../inc/MarlinConfig.h" +namespace GET_LANG(LCD_LANGUAGE) { + #define _MSG_PREHEAT(N) \ + LSTR MSG_PREHEAT_##N = _UxGT("Preheat ") PREHEAT_## N ##_LABEL; \ + LSTR MSG_PREHEAT_## N ##_SETTINGS = _UxGT("Preheat ") PREHEAT_## N ##_LABEL _UxGT(" Conf"); + #if PREHEAT_COUNT > 3 + REPEAT_S(4, PREHEAT_COUNT, _MSG_PREHEAT) + #endif +} enum processID : uint8_t { // Process ID @@ -44,7 +53,6 @@ enum processID : uint8_t { SetIntNoDraw, SetFloat, SetPFloat, - SelectFile, PrintProcess, Popup, Leveling, @@ -59,33 +67,88 @@ enum processID : uint8_t { }; enum pidresult_t : uint8_t { + PIDTEMP_START = 0, + PIDTEMPBED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, - PID_EXTR_START, - PID_BED_START, - PID_DONE + PID_DONE, }; #define DWIN_CHINESE 123 #define DWIN_ENGLISH 0 +typedef struct { + // Color settings + uint16_t Background_Color; + uint16_t Cursor_Color; + uint16_t TitleBg_Color; + uint16_t TitleTxt_Color; + uint16_t Text_Color; + uint16_t Selected_Color; + uint16_t SplitLine_Color; + uint16_t Highlight_Color; + uint16_t StatusBg_Color; + uint16_t StatusTxt_Color; + uint16_t PopupBg_Color; + uint16_t PopupTxt_Color; + uint16_t AlertBg_Color; + uint16_t AlertTxt_Color; + uint16_t PercentTxt_Color; + uint16_t Barfill_Color; + uint16_t Indicator_Color; + uint16_t Coordinate_Color; + + // Temperatures + #if ENABLED(PIDTEMP) + int16_t HotendPidT = DEF_HOTENDPIDT; + #endif + #if ENABLED(PIDTEMPBED) + int16_t BedPidT = DEF_BEDPIDT; + #endif + #if (HAS_HOTEND || HAS_HEATED_BED) && HAS_PID_HEATING + int16_t PidCycles = DEF_PIDCYCLES; + #endif + #if ENABLED(PREVENT_COLD_EXTRUSION) + int16_t ExtMinT = EXTRUDE_MINTEMP; + #endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) + int16_t BedLevT = LEVELING_BED_TEMP; + #endif + #if ENABLED(BAUD_RATE_GCODE) + bool Baud115K = false; + #endif + bool FullManualTramming = false; + bool MediaAutoMount = ENABLED(HAS_SD_EXTENDER); + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + uint8_t z_after_homing = DEF_Z_AFTER_HOMING; + #endif + #if ENABLED(MESH_BED_LEVELING) + float ManualZOffset = 0; + #endif + // Led + #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + LEDColor Led_Color = Def_Leds_Color; + #endif +} HMI_data_t; + +extern HMI_data_t HMI_data; +static constexpr size_t eeprom_data_size = sizeof(HMI_data_t); + typedef struct { int8_t Color[3]; // Color components - pidresult_t pidresult = PID_DONE; + TERN_(HAS_PID_HEATING, pidresult_t pidresult = PID_DONE); uint8_t Select = 0; // Auxiliary selector variable AxisEnum axis = X_AXIS; // Axis Select } HMI_value_t; typedef struct { uint8_t language; + bool printing_flag:1; // sd or host printing + bool abort_flag:1; // sd or host was aborted + bool pause_flag:1; // printing is paused bool percent_flag:1; // percent was override by M73 bool remain_flag:1; // remain was override by M73 - bool pause_flag:1; // printing is paused - bool pause_action:1; // flag a pause action - bool abort_flag:1; // printing is aborting - bool abort_action:1; // flag a aborting action - bool print_finish:1; // print was finished bool select_flag:1; // Popup button selected bool home_flag:1; // homing in course bool heat_flag:1; // 0: heating done 1: during heating @@ -105,6 +168,7 @@ extern millis_t dwin_heat_time; #endif // Tool Functions +uint32_t GetHash(char * str); #if ENABLED(EEPROM_SETTINGS) void WriteEeprom(); void ReadEeprom(); @@ -118,15 +182,14 @@ void DisableMotors(); void AutoLev(); void AutoHome(); #if HAS_PREHEAT - void DoPreheat0(); - void DoPreheat1(); - void DoPreheat2(); + #define _DOPREHEAT(N) void DoPreheat##N(); + REPEAT_1(PREHEAT_COUNT, _DOPREHEAT) #endif void DoCoolDown(); -#if HAS_HOTEND +#if ENABLED(PIDTEMP) void HotendPID(); #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void BedPID(); #endif #if ENABLED(BAUD_RATE_GCODE) @@ -151,6 +214,12 @@ void ParkHead(); void UBLSaveMesh(); void UBLLoadMesh(); #endif +#if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION) + void HostShutDown(); +#endif +#if !HAS_BED_PROBE + void HomeZandDisable(); +#endif // Other void Goto_PrintProcess(); @@ -160,7 +229,7 @@ void Goto_PowerLossRecovery(); void Goto_ConfirmToPrint(); void DWIN_Draw_Dashboard(const bool with_update); // Status Area void Draw_Main_Area(); // Redraw main area -void DWIN_DrawStatusLine(); // Draw simple status text +void DWIN_DrawStatusLine(const char *text = ""); // Draw simple status text void DWIN_RedrawDash(); // Redraw Dash and Status line void DWIN_RedrawScreen(); // Redraw all screen elements void HMI_MainMenu(); // Main process screen @@ -169,7 +238,6 @@ void HMI_Printing(); // Print page void HMI_ReturnScreen(); // Return to previous screen before popups void HMI_WaitForUser(); void HMI_SaveProcessID(const uint8_t id); -void HMI_SDCardInit(); void HMI_SDCardUpdate(); void EachMomentUpdate(); void update_variable(); @@ -179,12 +247,11 @@ void DWIN_CheckStatusMessage(); void DWIN_HomingStart(); void DWIN_HomingDone(); #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); + void DWIN_MeshUpdate(const int8_t cpos, const int8_t tpos, const_float_t zval); #endif void DWIN_LevelingStart(); void DWIN_LevelingDone(); -void DWIN_PidTuning(pidresult_t result); -void DWIN_Print_Started(const bool sd=false); +void DWIN_Print_Started(); void DWIN_Print_Pause(); void DWIN_Print_Resume(); void DWIN_Print_Finished(); @@ -228,6 +295,7 @@ void DWIN_RebootScreen(); #endif // Menu drawing functions +void Draw_Print_File_Menu(); void Draw_Control_Menu(); void Draw_AdvancedSettings_Menu(); void Draw_Prepare_Menu(); @@ -260,14 +328,6 @@ void Draw_Motion_Menu(); #if ENABLED(MESH_BED_LEVELING) void Draw_ManualMesh_Menu(); #endif -#if HAS_HOTEND - void Draw_Preheat1_Menu(); - void Draw_Preheat2_Menu(); - void Draw_Preheat3_Menu(); - #if ENABLED(PIDTEMP) - void Draw_HotendPID_Menu(); - #endif -#endif void Draw_Temperature_Menu(); void Draw_MaxSpeed_Menu(); void Draw_MaxAccel_Menu(); @@ -275,9 +335,6 @@ void Draw_MaxAccel_Menu(); void Draw_MaxJerk_Menu(); #endif void Draw_Steps_Menu(); -#if ENABLED(PIDTEMPBED) - void Draw_BedPID_Menu(); -#endif #if EITHER(HAS_BED_PROBE, BABYSTEPPING) void Draw_ZOffsetWiz_Menu(); #endif @@ -293,3 +350,12 @@ void Draw_Steps_Menu(); void Draw_EditMesh_Menu(); #endif #endif + +// PID +void DWIN_PidTuning(pidresult_t result); +#if ENABLED(PIDTEMP) + void Draw_HotendPID_Menu(); +#endif +#if ENABLED(PIDTEMPBED) + void Draw_BedPID_Menu(); +#endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index dffc26478d..de3f40e281 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -19,44 +19,45 @@ * along with this program. If not, see . * */ -#pragma once - /** * DWIN general defines and data structs for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.11.2 - * Date: 2022/02/28 + * Version: 3.12.2 + * Date: 2022/08/08 */ -#define HAS_GCODE_PREVIEW 1 -#define HAS_PIDPLOT 1 -#define HAS_ESDIAG 1 -#define HAS_LOCKSCREEN 1 +#pragma once + //#define DEBUG_DWIN 1 //#define NEED_HEX_PRINT 1 -#include "../../../inc/MarlinConfigPre.h" -#include "../common/dwin_color.h" -#if ENABLED(LED_CONTROL_MENU) - #include "../../../feature/leds/leds.h" -#endif -#include - #if defined(__STM32F1__) || defined(STM32F1) #define DASH_REDRAW 1 #endif +#if DISABLED(PROBE_MANUALLY) && ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL) + #define HAS_ONESTEP_LEVELING 1 +#endif + +#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) + #define JUST_BABYSTEP 1 +#endif + +#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) + #define HAS_ZOFFSET_ITEM 1 +#endif + #define Def_Background_Color RGB( 1, 12, 8) -#define Def_Cursor_color RGB(20, 49, 31) -#define Def_TitleBg_color RGB( 0, 23, 16) -#define Def_TitleTxt_color Color_White +#define Def_Cursor_Color RGB(20, 49, 31) +#define Def_TitleBg_Color RGB( 0, 23, 16) +#define Def_TitleTxt_Color Color_White #define Def_Text_Color Color_White #define Def_Selected_Color Select_Color #define Def_SplitLine_Color RGB( 0, 23, 16) #define Def_Highlight_Color Color_White #define Def_StatusBg_Color RGB( 0, 23, 16) #define Def_StatusTxt_Color Color_Yellow -#define Def_PopupBg_color Color_Bg_Window +#define Def_PopupBg_Color Color_Bg_Window #define Def_PopupTxt_Color Popup_Text_Color #define Def_AlertBg_Color Color_Bg_Red #define Def_AlertTxt_Color Color_Yellow @@ -68,55 +69,15 @@ #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) #define Def_Leds_Color LEDColorWhite() #endif +#if ENABLED(CASELIGHT_USES_BRIGHTNESS) + #define Def_CaseLight_Brightness 255 +#endif +#ifdef Z_AFTER_HOMING + #define DEF_Z_AFTER_HOMING Z_AFTER_HOMING +#else + #define DEF_Z_AFTER_HOMING 0 +#endif +#define DEF_HOTENDPIDT TERN(PREHEAT_1_TEMP_BED, PREHEAT_1_TEMP_HOTEND, 195) +#define DEF_BEDPIDT TERN(PREHEAT_1_TEMP_BED, PREHEAT_1_TEMP_HOTEND, 60) +#define DEF_PIDCYCLES 5 -typedef struct { - // Color settings - uint16_t Background_Color = Def_Background_Color; - uint16_t Cursor_color = Def_Cursor_color; - uint16_t TitleBg_color = Def_TitleBg_color; - uint16_t TitleTxt_color = Def_TitleTxt_color; - uint16_t Text_Color = Def_Text_Color; - uint16_t Selected_Color = Def_Selected_Color; - uint16_t SplitLine_Color = Def_SplitLine_Color; - uint16_t Highlight_Color = Def_Highlight_Color; - uint16_t StatusBg_Color = Def_StatusBg_Color; - uint16_t StatusTxt_Color = Def_StatusTxt_Color; - uint16_t PopupBg_color = Def_PopupBg_color; - uint16_t PopupTxt_Color = Def_PopupTxt_Color; - uint16_t AlertBg_Color = Def_AlertBg_Color; - uint16_t AlertTxt_Color = Def_AlertTxt_Color; - uint16_t PercentTxt_Color = Def_PercentTxt_Color; - uint16_t Barfill_Color = Def_Barfill_Color; - uint16_t Indicator_Color = Def_Indicator_Color; - uint16_t Coordinate_Color = Def_Coordinate_Color; - // Temperatures - #if HAS_HOTEND && defined(PREHEAT_1_TEMP_HOTEND) - int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND; - #endif - #if HAS_HEATED_BED && defined(PREHEAT_1_TEMP_BED) - int16_t BedPidT = PREHEAT_1_TEMP_BED; - #endif - #if HAS_HOTEND || HAS_HEATED_BED - int16_t PidCycles = 10; - #endif - #if ENABLED(PREVENT_COLD_EXTRUSION) - int16_t ExtMinT = EXTRUDE_MINTEMP; - #endif - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) - int16_t BedLevT = LEVELING_BED_TEMP; - #endif - #if ENABLED(BAUD_RATE_GCODE) - bool Baud115K = false; - #endif - bool FullManualTramming = false; - #if ENABLED(MESH_BED_LEVELING) - float ManualZOffset = 0; - #endif - // Led - #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - LEDColor Led_Color = Def_Leds_Color; - #endif -} HMI_data_t; - -static constexpr size_t eeprom_data_size = sizeof(HMI_data_t); -extern HMI_data_t HMI_data; diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp index 59b6c0d328..552075f9dc 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -46,8 +46,8 @@ uint16_t HighlightYPos = 280; void Draw_Select_Highlight(const bool sel, const uint16_t ypos) { HighlightYPos = ypos; HMI_flag.select_flag = sel; - const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color, - c2 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color; + const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_Color, + c2 = sel ? HMI_data.PopupBg_Color : HMI_data.Highlight_Color; DWIN_Draw_Rectangle(0, c1, 25, ypos - 1, 126, ypos + 38); DWIN_Draw_Rectangle(0, c1, 24, ypos - 2, 127, ypos + 39); DWIN_Draw_Rectangle(0, c2, 145, ypos - 1, 246, ypos + 38); diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.h b/Marlin/src/lcd/e3v2/proui/dwin_popup.h index b4503ea786..f24aac582e 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.h @@ -44,7 +44,7 @@ void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick=nul void HMI_Popup(); inline void Draw_Popup_Bkgd() { - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330); + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_Color, 14, 60, 258, 330); DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330); } diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index 5ed36e7dac..afb18f24db 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -23,21 +23,17 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.18.1 - * Date: 2022/07/05 + * Version: 3.20.1 + * Date: 2022/10/25 */ -#include "../../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(DWIN_LCD_PROUI) -#include "../../../inc/MarlinConfig.h" +#include "dwin_defines.h" #include "dwin_lcd.h" #include "dwinui.h" -#include "dwin_defines.h" - -//#define DEBUG_OUT 1 -#include "../../../core/debug_out.h" xy_int_t DWINUI::cursor = { 0 }; uint16_t DWINUI::pencolor = Color_White; @@ -50,13 +46,6 @@ FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr; void DWINUI::init() { - delay(750); // Delay for wait to wakeup screen - const bool hs = DWIN_Handshake(); UNUSED(hs); - #if ENABLED(DEBUG_DWIN) - SERIAL_ECHOPGM("DWIN_Handshake "); - SERIAL_ECHOLNF(hs ? F("ok.") : F("error.")); - #endif - DWIN_Frame_SetDir(1); cursor.reset(); pencolor = Color_White; textcolor = Def_Text_Color; @@ -210,6 +199,19 @@ void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t c DWIN_Draw_String(bShow, fid, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); } +// ------------------------- Icons -------------------------------// + +// Draw an Icon and select library automatically +// BG: The icon background display: false=Background filtering is not displayed, true=Background display +// libID: Icon library ID +// picID: Icon ID +// x/y: Upper-left point +void DWINUI::ICON_Show(bool BG, uint8_t icon, uint16_t x, uint16_t y) { + const uint8_t libID = ICON TERN_(HAS_CUSTOMICONS, + (icon / 100)); + const uint8_t picID = icon TERN_(HAS_CUSTOMICONS, % 100); + DWIN_ICON_Show(BG, false, !BG, libID, picID, x, y); +} + // ------------------------- Buttons ------------------------------// void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { @@ -320,8 +322,8 @@ uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { // x/y: Upper-left point // mode : 0 : unchecked, 1 : checked void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) { - DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" ")); DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17); + DWIN_Draw_Rectangle(1, checked ? color : bcolor, x + 6, y + 6, x + 13, y + 13); } // Clear Menu by filling the menu area with background color diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h index a544471831..3dd37f30df 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -19,7 +19,6 @@ * along with this program. If not, see . * */ -#pragma once /** * DWIN Enhanced implementation for PRO UI @@ -28,10 +27,14 @@ * Date: 2022/07/05 */ -#include "dwin_lcd.h" +#pragma once + +#include "../../../inc/MarlinConfigPre.h" + #include "../common/dwin_set.h" #include "../common/dwin_font.h" #include "../common/dwin_color.h" +#include "dwin_lcd.h" // Extra Icons #define ICON_AdvSet ICON_Language @@ -74,6 +77,10 @@ #define ICON_MaxPosX ICON_MoveX #define ICON_MaxPosY ICON_MoveY #define ICON_MaxPosZ ICON_MoveZ +#define ICON_MeshEdit ICON_Homing +#define ICON_MeshEditX ICON_MoveX +#define ICON_MeshEditY ICON_MoveY +#define ICON_MeshEditZ ICON_MoveZ #define ICON_MeshNext ICON_Axis #define ICON_MeshPoints ICON_SetEndTemp #define ICON_MeshSave ICON_WriteEEPROM @@ -85,11 +92,22 @@ #define ICON_ParkPosY ICON_StepY #define ICON_ParkPosZ ICON_StepZ #define ICON_PhySet ICON_PrintSize -#define ICON_PIDbed ICON_SetBedTemp -#define ICON_PIDcycles ICON_ResumeEEPROM +#define ICON_PIDNozzle ICON_SetEndTemp +#define ICON_PIDBed ICON_SetBedTemp +#define ICON_PIDCycles ICON_ResumeEEPROM #define ICON_PIDValue ICON_Contact #define ICON_PrintStats ICON_PrintTime #define ICON_PrintStatsReset ICON_RemainTime +#define ICON_Preheat1 ICON_PLAPreheat +#define ICON_Preheat2 ICON_ABSPreheat +#define ICON_Preheat3 ICON_CustomPreheat +#define ICON_Preheat4 ICON_CustomPreheat +#define ICON_Preheat5 ICON_CustomPreheat +#define ICON_Preheat6 ICON_CustomPreheat +#define ICON_Preheat7 ICON_CustomPreheat +#define ICON_Preheat8 ICON_CustomPreheat +#define ICON_Preheat9 ICON_CustomPreheat +#define ICON_Preheat10 ICON_CustomPreheat #define ICON_ProbeDeploy ICON_SetEndTemp #define ICON_ProbeMargin ICON_PrintSize #define ICON_ProbeOffsetX ICON_StepX @@ -105,9 +123,28 @@ #define ICON_Scolor ICON_MaxSpeed #define ICON_SetBaudRate ICON_Setspeed #define ICON_SetCustomPreheat ICON_SetEndTemp +#define ICON_SetPreheat1 ICON_SetPLAPreheat +#define ICON_SetPreheat2 ICON_SetABSPreheat +#define ICON_SetPreheat3 ICON_SetCustomPreheat +#define ICON_SetPreheat4 ICON_SetCustomPreheat +#define ICON_SetPreheat5 ICON_SetCustomPreheat +#define ICON_SetPreheat6 ICON_SetCustomPreheat +#define ICON_SetPreheat7 ICON_SetCustomPreheat +#define ICON_SetPreheat8 ICON_SetCustomPreheat +#define ICON_SetPreheat9 ICON_SetCustomPreheat +#define ICON_SetPreheat10 ICON_SetCustomPreheat #define ICON_Sound ICON_Cool #define ICON_TBSetup ICON_Contact #define ICON_UBLActive ICON_HotendTemp +#define ICON_UBLActive ICON_HotendTemp +#define ICON_UBLSlot ICON_ResumeEEPROM +#define ICON_UBLSaveMesh ICON_WriteEEPROM +#define ICON_UBLLoadMesh ICON_ReadEEPROM +#define ICON_UBLTiltGrid ICON_PrintSize +#define ICON_UBLSmartFill ICON_StockConfiguration +#define ICON_ZAfterHome ICON_SetEndTemp + + #define ICON_CaseLight ICON_Motion #define ICON_LedControl ICON_Motion @@ -262,18 +299,25 @@ namespace DWINUI { return t; } + // Draw an Icon and select library automatically + // BG: The icon background display: false=Background filtering is not displayed, true=Background display + // libID: Icon library ID + // picID: Icon ID + // x/y: Upper-left point + void ICON_Show(bool BG, uint8_t icon, uint16_t x, uint16_t y); + // Draw an Icon with transparent background from the library ICON // icon: Icon ID // x/y: Upper-left point inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(ICON, icon, x, y); + ICON_Show(false, icon, x, y); } // Draw an Icon from the library ICON with its background // icon: Icon ID // x/y: Upper-left point inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(true, false, false, ICON, icon, x, y); + ICON_Show(true, icon, x, y); } // Draw a numeric integer value diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 19d726037c..0945d69778 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -23,17 +23,13 @@ /** * DWIN Endstops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.2.2 - * Date: 2022/02/24 + * Version: 1.3.3 + * Date: 2022/10/07 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) - -#include "dwin_defines.h" - -#if HAS_ESDIAG +#if BOTH(DWIN_LCD_PROUI, HAS_ESDIAG) #include "endstop_diag.h" @@ -64,7 +60,7 @@ void draw_es_label(FSTR_P const flabel=nullptr) { void draw_es_state(const bool is_hit) { const uint8_t LM = 130; DWINUI::cursor.x = LM; - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_Color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN)); DWINUI::MoveBy(0, 25); } @@ -109,5 +105,4 @@ void ESDiagClass::Update() { DWIN_UpdateLCD(); } -#endif // HAS_ESDIAG -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_ESDIAG diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.h b/Marlin/src/lcd/e3v2/proui/endstop_diag.h index 316a1e1ed3..33f1d10d2d 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.h +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.h @@ -24,8 +24,8 @@ /** * DWIN End Stops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.2.3 - * Date: 2022/02/24 + * Version: 1.3.2 + * Date: 2022/10/07 */ class ESDiagClass { diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index adb23a9664..6411b669bb 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -23,8 +23,8 @@ /** * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo - * version: 2.1 - * Date: 2021/06/19 + * version: 3.1.2 + * Date: 2022/09/03 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -43,11 +43,8 @@ */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) -#include "dwin_defines.h" - -#if HAS_GCODE_PREVIEW +#if BOTH(DWIN_LCD_PROUI, HAS_GCODE_PREVIEW) #include "../../../core/types.h" #include "../../marlinui.h" @@ -246,6 +243,10 @@ void Preview_DrawFromSD() { } } +void Preview_Invalidate() { + fileprop.thumbstart = 0; +} + bool Preview_Valid() { return !!fileprop.thumbstart; } @@ -254,5 +255,4 @@ void Preview_Reset() { fileprop.thumbsize = 0; } -#endif // HAS_GCODE_PREVIEW -#endif // DWIN_LCD_PROUI +#endif // HAS_GCODE_PREVIEW && DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.h b/Marlin/src/lcd/e3v2/proui/gcode_preview.h index 4417084a24..c1949c5abc 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -1,8 +1,8 @@ /** * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo - * version: 2.1 - * Date: 2021/06/19 + * version: 3.1.2 + * Date: 2022/09/03 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -23,5 +23,6 @@ #pragma once void Preview_DrawFromSD(); +void Preview_Invalidate(); bool Preview_Valid(); void Preview_Reset(); diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp index 86c2095294..85f35582b2 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -23,18 +23,15 @@ /** * Lock screen implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.2.0 - * Date: 2022/04/11 + * Version: 2.3.2 + * Date: 2022/11/20 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) +#if BOTH(DWIN_LCD_PROUI, HAS_LOCKSCREEN) #include "dwin_defines.h" - -#if HAS_LOCKSCREEN - #include "dwinui.h" #include "dwin.h" #include "lockscreen.h" @@ -75,6 +72,4 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) { DWIN_UpdateLCD(); } -#endif // HAS_LOCKSCREEN - -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_LOCKSCREEN diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.h b/Marlin/src/lcd/e3v2/proui/lockscreen.h index 83d5530be3..cb75f2c7c0 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.h +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.h @@ -24,8 +24,8 @@ /** * Lock screen implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.2.0 - * Date: 2022/04/11 + * Version: 2.3.2 + * Date: 2022/11/20 */ #include "../common/encoder.h" diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp index 85594fecdb..32c19acb69 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.cpp +++ b/Marlin/src/lcd/e3v2/proui/menus.cpp @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.5.1 - * Date: 2022/05/23 + * Version: 1.9.1 + * Date: 2022/12/02 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -53,22 +53,23 @@ int8_t MenuItemTotal = 0; int8_t MenuItemCount = 0; -MenuItemClass** MenuItems = nullptr; +CustomMenuItemClass** MenuItems = nullptr; MenuClass *CurrentMenu = nullptr; MenuClass *PreviousMenu = nullptr; -void (*onMenuDraw)(MenuClass* menu) = nullptr; -void (*onCursorErase)(const int8_t line) = nullptr; -void (*onCursorDraw)(const int8_t line) = nullptr; MenuData_t MenuData; // Menuitem Drawing functions ================================================= void Draw_Title(TitleClass* title) { - DWIN_Draw_Rectangle(1, HMI_data.TitleBg_color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); + DWIN_Draw_Rectangle(1, HMI_data.TitleBg_Color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); if (title->frameid) DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1); else - DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #if ENABLED(TITLE_CENTERED) + DWINUI::Draw_CenteredString(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_Color, HMI_data.TitleBg_Color, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #else + DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_Color, HMI_data.TitleBg_Color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #endif } void Draw_Menu(MenuClass* menu) { @@ -78,7 +79,7 @@ void Draw_Menu(MenuClass* menu) { void Draw_Menu_Cursor(const int8_t line) { const uint16_t ypos = MYPOS(line); - DWINUI::Draw_Box(1, HMI_data.Cursor_color, {0, ypos, 15, MLINE - 1}); + DWINUI::Draw_Box(1, HMI_data.Cursor_Color, {0, ypos, 15, MLINE - 1}); } void Erase_Menu_Cursor(const int8_t line) { @@ -86,17 +87,39 @@ void Erase_Menu_Cursor(const int8_t line) { DWINUI::Draw_Box(1, HMI_data.Background_Color, {0, ypos, 15, MLINE - 1}); } -void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * const label /*=nullptr*/, bool more /*=false*/) { +void Erase_Menu_Text(const int8_t line) { + if (line < 0 || line >= TROWS) return; + const uint16_t ypos = MYPOS(line) + 1; + DWINUI::Draw_Box(1, HMI_data.Background_Color, {LBLX, ypos, DWIN_WIDTH - LBLX, MLINE - 2}); +} + +void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * const label /*=nullptr*/, bool more /*=false*/, bool selected /*=false*/) { if (icon) DWINUI::Draw_Icon(icon, ICOX, MBASE(line) - 3); if (label) DWINUI::Draw_String(LBLX, MBASE(line) - 1, (char*)label); if (more) DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); + if (selected) Draw_Menu_Cursor(line); DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); } +void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, FSTR_P label /*=nullptr*/, bool more /*=false*/, bool selected /*=false*/) { + Draw_Menu_Line(line, icon, FTOP(label), more, selected); +} + void Draw_Chkb_Line(const uint8_t line, const bool checked) { DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked); } +void Show_Chkb_Line(const bool checked) { + const uint8_t line = CurrentMenu->line(); + DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked); + DWIN_UpdateLCD(); +} + +void Toogle_Chkb_Line(bool &checked) { + checked = !checked; + Show_Chkb_Line(checked); +} + void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value /*=0*/) { DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); } @@ -140,22 +163,11 @@ void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const flo DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value); } -void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp) { const float value = *(float*)static_cast(menuitem)->value; - const int8_t dp = UNITFDIGITS; onDrawFloatMenu(menuitem, line, dp, value); } -void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - onDrawFloatMenu(menuitem, line, 2, value); -} - -void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - onDrawFloatMenu(menuitem, line, 3, value); -} - void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) { onDrawMenuItem(menuitem, line); Draw_Chkb_Line(line, checked); @@ -166,13 +178,15 @@ void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, val); } -void DrawItemEdit() { +void DrawItemEdit(const bool selected) { + const uint16_t bcolor = selected ? HMI_data.Selected_Color : HMI_data.Background_Color; + const uint8_t iNum = 4 - ((MenuData.dp > 0) ? (MenuData.dp - 1) : 0); switch (checkkey) { case SetIntNoDraw: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; case SetInt: - case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break; + case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break; case SetFloat: - case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, MenuData.dp, VALX - MenuData.dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break; + case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, bcolor, iNum, MenuData.dp, VALX - 2 * DWINUI::fontWidth(), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break; default: break; } } @@ -209,7 +223,7 @@ void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, // Apply: update function when the encoder is pressed void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate); - Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, MenuData.Value); + DrawItemEdit(true); } // Generic onclick event for float values @@ -222,7 +236,7 @@ void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { const int32_t value = round(val * POW(10, dp)); SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val); + DrawItemEdit(true); } // Generic onclick event for integer values @@ -271,8 +285,8 @@ void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)( // Generic menu control using the encoder void HMI_Menu() { EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; if (CurrentMenu) { + if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_ENTER) CurrentMenu->onClick(); else @@ -280,65 +294,46 @@ void HMI_Menu() { } } -// Get an integer value using the encoder without draw anything -// lo: low limit -// hi: high limit +// Get a value using the encoder +// draw : draw the value // Return value: // 0 : no change // 1 : live change // 2 : apply change -int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { +int8_t HMI_Get(bool draw) { + const int32_t lo = MenuData.MinValue; + const int32_t hi = MenuData.MaxValue; const int32_t cval = MenuData.Value; - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + EncoderState encoder_diffState = get_encoder_state(); if (encoder_diffState != ENCODER_DIFF_NO) { if (Apply_Encoder(encoder_diffState, MenuData.Value)) { EncoderRate.enabled = false; + if (draw) DrawItemEdit(false); checkkey = Menu; return 2; } LIMIT(MenuData.Value, lo, hi); } - return int8_t(cval != MenuData.Value); + const bool change = cval != MenuData.Value; + if (change) DrawItemEdit(true); + return int8_t(change); } -// Get an integer value using the encoder -// lo: low limit -// hi: high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, MenuData.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Background_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); - checkkey = Menu; - return 2; - } - LIMIT(MenuData.Value, lo, hi); - DrawItemEdit(); - return 1; - } - return 0; -} - -// Set an integer using the encoder -void HMI_SetInt() { - int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); +// Set and draw a value using the encoder +void HMI_SetDraw() { + int8_t val = HMI_Get(true); switch (val) { - case 0: return; break; + case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; case 2: if (MenuData.Apply) MenuData.Apply(); break; } } -// Set an integer without drawing -void HMI_SetIntNoDraw() { - int8_t val = HMI_GetIntNoDraw(MenuData.MinValue, MenuData.MaxValue); +// Set an value without drawing +void HMI_SetNoDraw() { + int8_t val = HMI_Get(false); switch (val) { - case 0: return; break; + case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; case 2: if (MenuData.Apply) MenuData.Apply(); break; } @@ -346,7 +341,7 @@ void HMI_SetIntNoDraw() { // Set an integer pointer variable using the encoder void HMI_SetPInt() { - int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + int8_t val = HMI_Get(true); switch (val) { case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; @@ -354,43 +349,9 @@ void HMI_SetPInt() { } } -// Get a scaled float value using the encoder -// dp: decimal places -// lo: scaled low limit -// hi: scaled high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, MenuData.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); - checkkey = Menu; - return 2; - } - LIMIT(MenuData.Value, lo, hi); - DrawItemEdit(); - return 1; - } - return 0; -} - -// Set a scaled float using the encoder -void HMI_SetFloat() { - const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); - switch (val) { - case 0: return; - case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; - case 2: if (MenuData.Apply) MenuData.Apply(); break; - } -} - // Set a scaled float pointer variable using the encoder void HMI_SetPFloat() { - const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); + const int8_t val = HMI_Get(true); switch (val) { case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; @@ -398,7 +359,7 @@ void HMI_SetPFloat() { } } -// Menu Classes =============================================================== +// Menu Class =============================================================== MenuClass::MenuClass() { selected = 0; @@ -407,10 +368,10 @@ MenuClass::MenuClass() { void MenuClass::draw() { MenuTitle.draw(); - if (onMenuDraw != nullptr) onMenuDraw(this); + Draw_Menu(this); for (int8_t i = 0; i < MenuItemCount; i++) MenuItems[i]->draw(i - topline); - if (onCursorDraw != nullptr) onCursorDraw(line()); + Draw_Menu_Cursor(line()); DWIN_UpdateLCD(); } @@ -419,7 +380,7 @@ void MenuClass::onScroll(bool dir) { if (dir) sel++; else sel--; LIMIT(sel, 0, MenuItemCount - 1); if (sel != selected) { - if (onCursorErase != nullptr) onCursorErase(line()); + Erase_Menu_Cursor(line()); DWIN_UpdateLCD(); if ((sel - topline) == TROWS) { DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1); @@ -432,63 +393,70 @@ void MenuClass::onScroll(bool dir) { MenuItems[sel]->draw(0); } selected = sel; - if (onCursorDraw != nullptr) onCursorDraw(line()); + Draw_Menu_Cursor(line()); DWIN_UpdateLCD(); } } void MenuClass::onClick() { - if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)(); + if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)(); } -MenuItemClass *MenuClass::SelectedItem() { +CustomMenuItemClass *MenuClass::SelectedItem() { return MenuItems[selected]; } -MenuItemClass** MenuClass::Items() { +CustomMenuItemClass** MenuClass::Items() { return MenuItems; } -int8_t MenuClass::count() { - return MenuItemCount; +int8_t MenuClass::count() { + return MenuItemCount; }; /* MenuItem Class ===========================================================*/ -MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) { - icon = cicon; - onClick = onclick; - onDraw = ondraw; - const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text)); - memcpy(&caption[0], text, len); - caption[len] = '\0'; +void CustomMenuItemClass::draw(int8_t line) { + if (line < 0 || line >= TROWS) return; + if (onDraw != nullptr) (*onDraw)(static_cast(this), line); +}; + +void CustomMenuItemClass::redraw(bool erase /*=false*/) { + const int8_t line = CurrentMenu->line(this->pos); + if (erase) Erase_Menu_Text(line); + draw(line); } -MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) { - icon = cicon; +CustomMenuItemClass::CustomMenuItemClass(OnDrawItem ondraw, OnClickItem onclick) { onClick = onclick; - onDraw = ondraw; + onDraw = ondraw; +} + +MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItemClass(ondraw, onclick) { + icon = cicon; + SetCaption(text); +} + +MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItemClass(ondraw, onclick) { + icon = cicon; caption[0] = '\0'; frameid = id; frame = { x1, y1, x2, y2 }; } +void MenuItemClass::SetCaption(const char * const text) { + const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text)); + memcpy(&caption[0], text, len); + caption[len] = '\0'; +} + void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { caption[0] = '\0'; frameid = id; frame = { x1, y1, x2, y2 }; } -void MenuItemClass::draw(int8_t line) { - if (!WITHIN(line, 0, TROWS - 1)) return; - if (onDraw != nullptr) (*onDraw)(this, line); -}; - -void MenuItemClass::redraw() { - draw(CurrentMenu->line(this->pos)); -} - -MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemClass(cicon, text, ondraw, onclick) { +MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemClass(cicon, text, ondraw, onclick) { value = val; }; @@ -505,38 +473,56 @@ void MenuItemsClear() { void MenuItemsPrepare(int8_t totalitems) { MenuItemsClear(); - MenuItemTotal = totalitems; - MenuItems = new MenuItemClass*[totalitems]; + MenuItemTotal = _MIN(totalitems, MENU_MAX_ITEMS); + MenuItems = new CustomMenuItemClass*[totalitems]; } -MenuItemClass* MenuItemsAdd(MenuItemClass* menuitem) { +bool IsMenu(MenuClass* _menu) { + return ((checkkey == Menu) && !!CurrentMenu && (CurrentMenu == _menu)); +} + +template +T* MenuItemAdd(T* menuitem) { MenuItems[MenuItemCount] = menuitem; menuitem->pos = MenuItemCount++; return menuitem; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text/*=nullptr*/, void (*ondraw)(MenuItemClass* menuitem, int8_t line)/*=nullptr*/, void (*onclick)()/*=nullptr*/) { +CustomMenuItemClass* MenuItemAdd(OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { + if (MenuItemCount < MenuItemTotal) { + CustomMenuItemClass* menuitem = new CustomMenuItemClass(ondraw, onclick); + return MenuItemAdd(menuitem); + } + else return nullptr; +} + +MenuItemClass* MenuItemAdd(uint8_t cicon, const char * const text/*=nullptr*/, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { if (MenuItemCount < MenuItemTotal) { MenuItemClass* menuitem = new MenuItemClass(cicon, text, ondraw, onclick); - return MenuItemsAdd(menuitem); + return MenuItemAdd(menuitem); } else return nullptr; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)/*=nullptr*/, void (*onclick)()/*=nullptr*/) { +MenuItemClass* MenuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { if (MenuItemCount < MenuItemTotal) { MenuItemClass* menuitem = new MenuItemClass(cicon, id, x1, y1, x2, y2, ondraw, onclick); - return MenuItemsAdd(menuitem); + return MenuItemAdd(menuitem); + } + else return nullptr; +} + +MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) { + if (MenuItemCount < MenuItemTotal) { + MenuItemClass* menuitem = new MenuItemPtrClass(cicon, text, ondraw, onclick, val); + return MenuItemAdd(menuitem); } else return nullptr; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) { - if (MenuItemCount < MenuItemTotal) { - MenuItemClass* menuitem = new MenuItemPtrClass(cicon, text, ondraw, onclick, val); - return MenuItemsAdd(menuitem); - } - else return nullptr; +void InitMenu() { + PreviousMenu = nullptr; + InvalidateMenu(); } bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) { @@ -549,6 +535,27 @@ bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) { return NotCurrent; } +bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems) { + if (!menu) menu = new MenuClass(); + const bool NotCurrent = (CurrentMenu != menu); + if (NotCurrent) { + if (cn.w != 0) + menu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h); + else + menu->MenuTitle.SetCaption(title); + MenuItemsPrepare(totalitems); + } + return NotCurrent; +} + +void InvalidateMenu() { + if (CurrentMenu) { + CurrentMenu->topline = 0; + CurrentMenu->selected = 0; + CurrentMenu = nullptr; + } +} + void UpdateMenu(MenuClass* &menu) { if (!menu) return; if (CurrentMenu != menu) { @@ -558,9 +565,9 @@ void UpdateMenu(MenuClass* &menu) { menu->draw(); } -void ReDrawMenu(const bool force/*=false*/) { - if (CurrentMenu && (force || checkkey == Menu)) CurrentMenu->draw(); - if (force) DrawItemEdit(); +void ReDrawMenu(bool force /*= false*/) { + if (CurrentMenu && (force || checkkey==Menu)) CurrentMenu->draw(); + if (force) DrawItemEdit(true); } #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h index 6a5f8786ca..9bc9d702bd 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.h +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.5.1 - * Date: 2022/05/23 + * Version: 1.9.1 + * Date: 2022/12/02 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -44,6 +44,9 @@ #include "dwinui.h" +#define MENU_CHAR_LIMIT 24 +#define MENU_MAX_ITEMS TERN(SDSORT_LIMIT, SDSORT_LIMIT, 64) + typedef struct { int32_t MaxValue = 0; // Auxiliar max integer/scaled float value int32_t MinValue = 0; // Auxiliar min integer/scaled float value @@ -56,46 +59,60 @@ typedef struct { } MenuData_t; extern MenuData_t MenuData; -extern void (*onCursorErase)(const int8_t line); -extern void (*onCursorDraw)(const int8_t line); // Auxiliary Macros =========================================================== // Create and add a MenuItem object to the menu array -#define BACK_ITEM(H) MenuItemsAdd(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, H) -#define MENU_ITEM(V...) MenuItemsAdd(V) -#define EDIT_ITEM(V...) MenuItemsAdd(V) -#define MENU_ITEM_F(I,L,V...) MenuItemsAdd(I, GET_TEXT_F(L), V) -#define EDIT_ITEM_F(I,L,V...) MenuItemsAdd(I, GET_TEXT_F(L), V) +#define SET_MENU(I,L,V) SetMenu(I, GET_TEXT_F(L), V) +#define SET_MENU_F(I,L,V) SetMenu(I, F(L), V) +#define SET_MENU_R(I,R,L,V) SetMenu(I, R, GET_TEXT_F(L), V) + +#define BACK_ITEM(H) MenuItemAdd(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, H) +#define MENU_ITEM(I,L,V...) MenuItemAdd(I, GET_TEXT_F(L), V) +#define EDIT_ITEM(I,L,V...) EditItemAdd(I, GET_TEXT_F(L), V) +#define MENU_ITEM_F(I,L,V...) MenuItemAdd(I, F(L), V) +#define EDIT_ITEM_F(I,L,V...) EditItemAdd(I, F(L), V) // Menu Classes =============================================================== -class MenuItemClass { -protected: +class CustomMenuItemClass; +class MenuItemClass; + +typedef void (*OnDrawCustomItem)(CustomMenuItemClass* menuitem, int8_t line); +typedef void (*OnDrawItem)(MenuItemClass* menuitem, int8_t line); +typedef void (*OnClickItem)(); + +class CustomMenuItemClass { public: int8_t pos = 0; + OnDrawItem onDraw = nullptr; + void (*onClick)() = nullptr; + CustomMenuItemClass() {}; + CustomMenuItemClass(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); + virtual ~CustomMenuItemClass(){}; + virtual void draw(int8_t line); + void redraw(bool erase=false); +}; + +class MenuItemClass: public CustomMenuItemClass { +public: uint8_t icon = 0; - char caption[32] = ""; + char caption[MENU_CHAR_LIMIT] = ""; uint8_t frameid = 0; rect_t frame = {0}; - void (*onDraw)(MenuItemClass* menuitem, int8_t line) = nullptr; - void (*onClick)() = nullptr; - MenuItemClass() {}; - MenuItemClass(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); - // MenuItemClass(uint8_t cicon, FSTR_P text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) : MenuItemClass(cicon, FTOP(text), ondraw, onclick){} - MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); + using CustomMenuItemClass::CustomMenuItemClass; + MenuItemClass(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); + MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); - virtual ~MenuItemClass(){}; - virtual void draw(int8_t line); - void redraw(); + void SetCaption(const char * const text = nullptr); }; class MenuItemPtrClass: public MenuItemClass { public: void *value = nullptr; using MenuItemClass::MenuItemClass; - MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val); - MenuItemPtrClass(uint8_t cicon, FSTR_P text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){} + MenuItemPtrClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val); + MenuItemPtrClass(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){} }; class MenuClass { @@ -111,12 +128,11 @@ public: virtual void draw(); virtual void onScroll(bool dir); void onClick(); - MenuItemClass* SelectedItem(); - static MenuItemClass** Items(); + CustomMenuItemClass* SelectedItem(); + static CustomMenuItemClass** Items(); }; extern MenuClass *CurrentMenu; extern MenuClass *PreviousMenu; -extern void (*onMenuDraw)(MenuClass* menu); // Menuitem Drawing functions ================================================= @@ -124,8 +140,12 @@ void Draw_Title(TitleClass* title); void Draw_Menu(MenuClass* menu); void Draw_Menu_Cursor(const int8_t line); void Erase_Menu_Cursor(const int8_t line); -void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false); +void Erase_Menu_Text(const int8_t line); +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false, bool selected=false); +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, FSTR_P label=nullptr, bool more=false, bool selected=false); void Draw_Chkb_Line(const uint8_t line, const bool checked); +void Show_Chkb_Line(const bool checked); +void Toogle_Chkb_Line(bool &checked); void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value=0); void onDrawMenuItem(MenuItemClass* menuitem, int8_t line); void onDrawSubMenu(MenuItemClass* menuitem, int8_t line); @@ -134,9 +154,11 @@ void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line); void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line); void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line); void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value); -void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line); -void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line); -void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line); +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp); +inline void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, UNITFDIGITS); }; +inline void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 2); }; +inline void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 3); }; +inline void onDrawPFloat4Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 4); }; void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked); void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line); @@ -153,22 +175,28 @@ void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)( // HMI user control functions ================================================= void HMI_Menu(); -void HMI_SetInt(); +void HMI_SetDraw(); +void HMI_SetNoDraw(); void HMI_SetPInt(); -void HMI_SetIntNoDraw(); -void HMI_SetFloat(); void HMI_SetPFloat(); // Menu auxiliary functions =================================================== +// Initialize menu +void InitMenu(); + // Create a new menu bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems); +bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems); + +// Invalidate CurrentMenu to prepare for full menu drawing +void InvalidateMenu(); //Update the Menu and Draw if it is valid void UpdateMenu(MenuClass* &menu); //Redraw the current Menu if it is valid -void ReDrawMenu(const bool force=false); +void ReDrawMenu(bool force = false); // Clear MenuItems array and free MenuItems elements void MenuItemsClear(); @@ -176,13 +204,17 @@ void MenuItemsClear(); // Prepare MenuItems array void MenuItemsPrepare(int8_t totalitems); +// Is the current menu = menu? +bool IsMenu(MenuClass* menu); + // Add elements to the MenuItems array -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); -inline MenuItemClass* MenuItemsAdd(uint8_t cicon, FSTR_P text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) { - return MenuItemsAdd(cicon, FTOP(text), ondraw, onclick); +CustomMenuItemClass* MenuItemAdd(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +MenuItemClass* MenuItemAdd(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +inline MenuItemClass* MenuItemAdd(uint8_t cicon, FSTR_P text = nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr) { + return MenuItemAdd(cicon, FTOP(text), ondraw, onclick); } -MenuItemClass* MenuItemsAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val); -inline MenuItemClass* MenuItemsAdd(uint8_t cicon, FSTR_P text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) { - return MenuItemsAdd(cicon, FTOP(text), ondraw, onclick, val); +MenuItemClass* MenuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val); +inline MenuItemClass* EditItemAdd(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) { + return EditItemAdd(cicon, FTOP(text), ondraw, onclick, val); } diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index 2511d33ff1..18cdffd00d 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -113,8 +113,8 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) { Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER)); #if USE_UBL_VIEWER DWINUI::ClearMainArea(); - BedLevelTools.viewer_print_value = true; - BedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); + bedLevelTools.viewer_print_value = true; + bedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); #else DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); #endif @@ -127,7 +127,7 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) { DWINUI::Draw_Button(BTN_Continue, 86, 305); #if USE_UBL_VIEWER - BedLevelTools.Set_Mesh_Viewer_Status(); + bedLevelTools.Set_Mesh_Viewer_Status(); #else char str_1[6], str_2[6] = ""; ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp index cb1f6c2dda..75917320a4 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.cpp +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -23,8 +23,8 @@ /** * DWIN Single var plot * Author: Miguel A. Risco-Castillo - * Version: 2.0 - * Date: 2022/01/31 + * Version: 2.1.2 + * Date: 2022/11/20 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -44,14 +44,9 @@ #include "../../../inc/MarlinConfigPre.h" -#ifdef DWIN_LCD_PROUI - -#include "dwin_defines.h" - -#if HAS_PIDPLOT +#if BOTH(DWIN_LCD_PROUI, HAS_PIDPLOT) #include "plot.h" - #include "../../../core/types.h" #include "../../marlinui.h" #include "dwin_lcd.h" @@ -74,7 +69,7 @@ void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) y2 = frame.y + frame.h - 1; r = round((y2) - ref * scale); DWINUI::Draw_Box(1, Plot_Bg_Color, frame); - for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) DWIN_Draw_VLine(Line_Color, i * 50 + frame.x, frame.y, frame.h); + for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) DWIN_Draw_VLine(Line_Color, i * 50 + frame.x, frame.y, frame.h); DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); } @@ -94,6 +89,4 @@ void PlotClass::Update(const float value) { grphpoints++; } -#endif // HAS_PIDPLOT - -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_PIDPLOT diff --git a/Marlin/src/lcd/e3v2/proui/plot.h b/Marlin/src/lcd/e3v2/proui/plot.h index 8522c530bd..ea15255fe5 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.h +++ b/Marlin/src/lcd/e3v2/proui/plot.h @@ -23,8 +23,8 @@ /** * DWIN Single var plot * Author: Miguel A. Risco-Castillo - * Version: 1.0 - * Date: 2022/01/30 + * Version: 2.1.2 + * Date: 2022/11/20 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as diff --git a/Marlin/src/lcd/e3v2/proui/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp index 5a7b6c9c41..fc07e3387d 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.cpp +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -23,8 +23,8 @@ /** * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.3.0 - * Date: 2022/02/24 + * Version: 1.4.2 + * Date: 2022/12/03 */ #include "../../../inc/MarlinConfigPre.h" @@ -79,4 +79,12 @@ void Goto_PrintStats() { HMI_SaveProcessID(WaitResponse); } +// Print Stats Reset popup +void Popup_ResetStats() { DWIN_Popup_ConfirmCancel(ICON_Info_0, GET_TEXT_F(MSG_RESET_STATS)); } +void OnClick_ResetStats() { + if (HMI_flag.select_flag) PrintStatsClass::Reset(); + HMI_ReturnScreen(); +} +void PrintStatsReset() { Goto_Popup(Popup_ResetStats, OnClick_ResetStats); } + #endif // DWIN_LCD_PROUI && PRINTCOUNTER diff --git a/Marlin/src/lcd/e3v2/proui/printstats.h b/Marlin/src/lcd/e3v2/proui/printstats.h index 705c923da4..4a38306886 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.h +++ b/Marlin/src/lcd/e3v2/proui/printstats.h @@ -24,8 +24,8 @@ /** * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.3.0 - * Date: 2022/02/24 + * Version: 1.4.2 + * Date: 2022/12/03 */ class PrintStatsClass { @@ -37,3 +37,4 @@ public: extern PrintStatsClass PrintStats; void Goto_PrintStats(); +void PrintStatsReset(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp index e3b95c4cd4..656c1f04d2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp @@ -52,7 +52,6 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .enabled(ENABLED(HAS_MULTI_HOTEND)) .tag(6) .button(BTN_POS(1,5), BTN_SIZE(1,1), GET_TEXT_F(MSG_OFFSETS_MENU)) - .tag(7) .button(BTN_POS(2,1), BTN_SIZE(1,1), GET_TEXT_F(MSG_STEPS_PER_MM)) .tag(8) .button(BTN_POS(2,2), BTN_SIZE(1,1), GET_TEXT_F(MSG_MAX_SPEED)) .tag(9) .button(BTN_POS(2,3), BTN_SIZE(1,1), GET_TEXT_F(MSG_ACCELERATION)) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 0a74ddd741..3ce7a5aa2b 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -82,6 +82,7 @@ namespace Language_en { LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); + LSTR MSG_Z_AFTER_HOME = _UxGT("Z After Homing"); LSTR MSG_FILAMENT_SET = _UxGT("Filament Settings"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); LSTR MSG_MANUAL_LEVELING = _UxGT("Manual Leveling"); @@ -133,6 +134,7 @@ namespace Language_en { LSTR MSG_PREHEAT_M_BEDONLY = _UxGT("Preheat $ Bed"); LSTR MSG_PREHEAT_M_SETTINGS = _UxGT("Preheat $ Conf"); #endif + LSTR MSG_PREHEAT_HOTEND = _UxGT("Preheat Hotend"); LSTR MSG_PREHEAT_CUSTOM = _UxGT("Preheat Custom"); LSTR MSG_COOLDOWN = _UxGT("Cooldown"); @@ -266,6 +268,7 @@ namespace Language_en { LSTR MSG_UBL_INVALID_SLOT = _UxGT("First Select a Mesh Slot"); LSTR MSG_MESH_LOADED = _UxGT("Mesh %i Loaded"); LSTR MSG_MESH_SAVED = _UxGT("Mesh %i Saved"); + LSTR MSG_MESH_ACTIVE = _UxGT("Mesh %i active"); LSTR MSG_UBL_NO_STORAGE = _UxGT("No Storage"); LSTR MSG_UBL_SAVE_ERROR = _UxGT("Err: UBL Save"); LSTR MSG_UBL_RESTORE_ERROR = _UxGT("Err: UBL Restore"); @@ -323,6 +326,7 @@ namespace Language_en { LSTR MSG_MOVE_01IN = _UxGT("Move 0.1in"); LSTR MSG_MOVE_05IN = _UxGT("Move 0.5in"); LSTR MSG_MOVE_1IN = _UxGT("Move 1.0in"); + LSTR MSG_LIVE_MOVE = _UxGT("Live Move"); LSTR MSG_SPEED = _UxGT("Speed"); LSTR MSG_BED_Z = _UxGT("Bed Z"); LSTR MSG_NOZZLE = _UxGT("Nozzle"); @@ -538,6 +542,7 @@ namespace Language_en { LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Wipe Retract"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Retract Speed"); LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Park Head"); + LSTR MSG_PARK_FAILED = _UxGT("Head cannot be parked"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Recover Speed"); LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Fan Speed"); LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Fan Time"); @@ -643,6 +648,7 @@ namespace Language_en { LSTR MSG_MESH_LEVELING = _UxGT("Mesh Leveling"); LSTR MSG_MESH_DONE = _UxGT("Mesh probing done"); LSTR MSG_INFO_STATS_MENU = _UxGT("Printer Stats"); + LSTR MSG_RESET_STATS = _UxGT("Reset Print Stats?"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Board Info"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistors"); LSTR MSG_INFO_EXTRUDERS = _UxGT("Extruders"); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index c5df604517..ff12703ca9 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1650,6 +1650,7 @@ void MarlinUI::init() { TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("UI Aborted"), FPSTR(DISMISS_STR))); LCD_MESSAGE(MSG_PRINT_ABORTED); TERN_(HAS_MARLINUI_MENU, return_to_status()); + TERN_(DWIN_LCD_PROUI, HMI_flag.abort_flag = true); } #if BOTH(HAS_MARLINUI_MENU, PSU_CONTROL) diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index dc2ba45764..96d22fdd38 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -29,6 +29,10 @@ #include "motion.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" +#endif + #if HAS_BED_PROBE enum ProbePtRaise : uint8_t { PROBE_PT_NONE, // No raise or stow after run_z_probe @@ -45,12 +49,14 @@ #define PROBE_TRIGGERED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) #endif -#ifdef Z_AFTER_HOMING - #define Z_POST_CLEARANCE Z_AFTER_HOMING +#if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + #define Z_POST_CLEARANCE HMI_data.z_after_homing; +#elif defined(Z_AFTER_HOMING) + #define Z_POST_CLEARANCE Z_AFTER_HOMING #elif defined(Z_HOMING_HEIGHT) - #define Z_POST_CLEARANCE Z_HOMING_HEIGHT + #define Z_POST_CLEARANCE Z_HOMING_HEIGHT #else - #define Z_POST_CLEARANCE 10 + #define Z_POST_CLEARANCE 10 #endif #if ENABLED(PREHEAT_BEFORE_LEVELING) @@ -155,7 +161,9 @@ public: #endif static void move_z_after_homing() { - #ifdef Z_AFTER_HOMING + #if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + do_z_clearance(HMI_data.z_after_homing, true); + #elif defined(Z_AFTER_HOMING) do_z_clearance(Z_AFTER_HOMING, true); #elif BOTH(Z_AFTER_PROBING, HAS_BED_PROBE) move_z_after_probing(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 9a7635fc51..1b6f157479 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -2527,7 +2527,7 @@ void MarlinSettings::postprocess() { #endif // - // Creality DWIN User Data + // DWIN User Data // #if ENABLED(DWIN_LCD_PROUI) { @@ -2852,7 +2852,7 @@ void MarlinSettings::postprocess() { #endif #if ENABLED(DWIN_LCD_PROUI) - status = !BedLevelTools.meshvalidate(); + status = !bedLevelTools.meshvalidate(); if (status) { bedlevel.invalidate(); LCD_MESSAGE(MSG_UBL_MESH_INVALID); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index cd76dac326..d01b4bc142 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -657,7 +657,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(HAS_FAN_LOGIC, fan_update_ms = next_temp_ms + fan_update_interval_ms); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); - TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PIDTEMPBED_START : PIDTEMP_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOPGM(STR_PID_AUTOTUNE); diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 07255f7e7f..3ec1183083 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -581,7 +581,7 @@ void CardReader::startOrResumeFilePrinting() { // void CardReader::endFilePrintNow(TERN_(SD_RESORT, const bool re_sort/*=false*/)) { TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0); - TERN_(HAS_DWIN_E3V2_BASIC, HMI_flag.print_finish = flag.sdprinting); + TERN_(DWIN_CREALITY_LCD, HMI_flag.print_finish = flag.sdprinting); flag.abort_sd_printing = false; if (isFileOpen()) file.close(); TERN_(SD_RESORT, if (re_sort) presort());