From 858916d628526b5d56c34c5c9663e3535bfc7788 Mon Sep 17 00:00:00 2001 From: Miguel Risco-Castillo Date: Fri, 23 Jun 2023 04:57:22 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Update=20DWIN=20ProUI=20(#26003)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 10 +- Marlin/src/feature/tmc_util.h | 8 +- Marlin/src/gcode/lcd/M73.cpp | 32 +- Marlin/src/gcode/probe/G30.cpp | 4 +- Marlin/src/inc/SanityCheck.h | 16 +- Marlin/src/lcd/e3v2/common/dwin_font.h | 12 +- Marlin/src/lcd/e3v2/common/limits.h | 8 +- Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp | 42 +- Marlin/src/lcd/e3v2/proui/bedlevel_tools.h | 13 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 1409 ++++++++++-------- Marlin/src/lcd/e3v2/proui/dwin.h | 58 +- Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp | 24 +- Marlin/src/lcd/e3v2/proui/dwin_lcd.h | 9 +- Marlin/src/lcd/e3v2/proui/dwinui.cpp | 43 +- Marlin/src/lcd/e3v2/proui/dwinui.h | 16 +- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 8 +- Marlin/src/lcd/e3v2/proui/endstop_diag.h | 8 +- Marlin/src/lcd/e3v2/proui/gcode_preview.cpp | 33 +- Marlin/src/lcd/e3v2/proui/gcode_preview.h | 2 +- Marlin/src/lcd/e3v2/proui/menus.cpp | 62 +- Marlin/src/lcd/e3v2/proui/menus.h | 34 +- Marlin/src/lcd/e3v2/proui/meshviewer.cpp | 156 +- Marlin/src/lcd/e3v2/proui/meshviewer.h | 14 +- Marlin/src/lcd/e3v2/proui/plot.cpp | 12 +- Marlin/src/lcd/e3v2/proui/plot.h | 6 +- Marlin/src/lcd/e3v2/proui/printstats.cpp | 6 +- Marlin/src/lcd/e3v2/proui/printstats.h | 2 +- Marlin/src/lcd/language/language_de.h | 12 +- Marlin/src/lcd/language/language_en.h | 30 +- Marlin/src/lcd/language/language_it.h | 10 +- Marlin/src/lcd/language/language_ru.h | 10 +- Marlin/src/lcd/language/language_sk.h | 10 +- Marlin/src/lcd/language/language_tr.h | 10 +- Marlin/src/module/stepper.cpp | 10 +- Marlin/src/module/temperature.cpp | 8 +- 35 files changed, 1227 insertions(+), 920 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 1c43af1884..3b8ee33730 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -310,8 +310,14 @@ void unified_bed_leveling::G29() { // Check for commands that require the printer to be homed if (may_move) { planner.synchronize(); - // Send 'N' to force homing before G29 (internal only) - if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes(); + #if ALL(DWIN_LCD_PROUI, ZHOME_BEFORE_LEVELING) + save_ubl_active_state_and_disable(); + gcode.process_subcommands_now(F("G28Z")); + restore_ubl_active_state_and_leave(); + #else + // Send 'N' to force homing before G29 (internal only) + if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes(); + #endif probe.use_probing_tool(); // Position bed horizontally and Z probe vertically. diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 4ba3835906..a0a72058aa 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -144,7 +144,7 @@ class TMCMarlin : public TMC, public TMCStorage { #endif #endif - #if HAS_MARLINUI_MENU + #if ANY(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) @@ -207,7 +207,7 @@ class TMCMarlin : public TMC220 } #endif - #if HAS_MARLINUI_MENU + #if ANY(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) @@ -269,7 +269,7 @@ class TMCMarlin : public TMC220 } #endif - #if HAS_MARLINUI_MENU + #if ANY(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) @@ -315,7 +315,7 @@ class TMCMarlin : public TMC266 } #endif - #if HAS_MARLINUI_MENU + #if ANY(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) void refresh_stepper_current() { rms_current(this->val_mA); } #if USE_SENSORLESS diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index 02d44ca00b..5ac2839beb 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -49,28 +49,20 @@ */ void GcodeSuite::M73() { - #if ENABLED(DWIN_LCD_PROUI) + #if ENABLED(SET_PROGRESS_PERCENT) + if (parser.seenval('P')) + ui.set_progress((PROGRESS_SCALE) > 1 + ? parser.value_float() * (PROGRESS_SCALE) + : parser.value_byte() + ); + #endif - DWIN_M73(); - - #else - - #if ENABLED(SET_PROGRESS_PERCENT) - if (parser.seenval('P')) - ui.set_progress((PROGRESS_SCALE) > 1 - ? parser.value_float() * (PROGRESS_SCALE) - : parser.value_byte() - ); - #endif - - #if ENABLED(SET_REMAINING_TIME) - if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong()); - #endif - - #if ENABLED(SET_INTERACTION_TIME) - if (parser.seenval('C')) ui.set_interaction_time(60 * parser.value_ulong()); - #endif + #if ENABLED(SET_REMAINING_TIME) + if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong()); + #endif + #if ENABLED(SET_INTERACTION_TIME) + if (parser.seenval('C')) ui.set_interaction_time(60 * parser.value_ulong()); #endif #if ENABLED(M73_REPORT) diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index 43fc27bfc1..c638e76c1a 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -70,7 +70,9 @@ void GcodeSuite::G30() { remember_feedrate_scaling_off(); - TERN_(DWIN_CREALITY_LCD_JYERSUI, process_subcommands_now(F("G28O"))); + #if ANY(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + process_subcommands_now(F("G28O")); + #endif const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index bda273b734..9fdd0d603e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2718,14 +2718,18 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #elif ENABLED(DWIN_LCD_PROUI) #if !HAS_MEDIA #error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled." - #elif ANY(PID_EDIT_MENU, PID_AUTOTUNE_MENU) - #error "DWIN_LCD_PROUI does not support PID_EDIT_MENU or PID_AUTOTUNE_MENU." - #elif ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU) - #error "DWIN_LCD_PROUI does not support MPC_EDIT_MENU or MPC_AUTOTUNE_MENU." - #elif ENABLED(LCD_BED_TRAMMING) - #error "DWIN_LCD_PROUI does not support LCD_BED_TRAMMING." #elif ALL(LCD_BED_LEVELING, PROBE_MANUALLY) #error "DWIN_LCD_PROUI does not support LCD_BED_LEVELING with PROBE_MANUALLY." + #elif ENABLED(MEDIASORT_MENU_ITEM) && DISABLED(SDCARD_SORT_ALPHA) + #error "MEDIASORT_MENU_ITEM requires SDCARD_SORT_ALPHA." + #elif ENABLED(RUNOUT_TUNE_ITEM) && DISABLED(HAS_FILAMENT_SENSOR) + #error "RUNOUT_TUNE_ITEM requires HAS_FILAMENT_SENSOR." + #elif ENABLED(PLR_TUNE_ITEM) && DISABLED(POWER_LOSS_RECOVERY) + #error "PLR_TUNE_ITEM requires POWER_LOSS_RECOVERY." + #elif ENABLED(JD_TUNE_ITEM) && DISABLED(HAS_JUNCTION_DEVIATION) + #error "JD_TUNE_ITEM requires HAS_JUNCTION_DEVIATION." + #elif ENABLED(ADVK_TUNE_ITEM) && DISABLED(LIN_ADVANCE) + #error "ADVK_TUNE_ITEM requires LIN_ADVANCE." #endif #endif diff --git a/Marlin/src/lcd/e3v2/common/dwin_font.h b/Marlin/src/lcd/e3v2/common/dwin_font.h index 10bb104d27..b92bfcf99c 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_font.h +++ b/Marlin/src/lcd/e3v2/common/dwin_font.h @@ -28,13 +28,15 @@ typedef uint8_t fontid_t; * 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28 * 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64 */ -#define font6x12 0x00 +#if DISABLED(TJC_DISPLAY) + #define font6x12 0x00 + #define font20x40 0x06 + #define font24x48 0x07 + #define font28x56 0x08 + #define font32x64 0x09 +#endif #define font8x16 0x01 #define font10x20 0x02 #define font12x24 0x03 #define font14x28 0x04 #define font16x32 0x05 -#define font20x40 0x06 -#define font24x48 0x07 -#define font28x56 0x08 -#define font32x64 0x09 diff --git a/Marlin/src/lcd/e3v2/common/limits.h b/Marlin/src/lcd/e3v2/common/limits.h index 4ac97b82bb..da75d9c982 100644 --- a/Marlin/src/lcd/e3v2/common/limits.h +++ b/Marlin/src/lcd/e3v2/common/limits.h @@ -91,4 +91,10 @@ constexpr xyze_float_t min_acceleration_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_A constexpr xyze_float_t min_steps_edit_values = LOGICAL_AXIS_ARRAY_1(MIN_STEPS_EDIT_VALUE), default_steps = DEFAULT_AXIS_STEPS_PER_UNIT, - max_steps_edit_values = default_steps * float(DEFAULT_MAX_MULTIPLIER); + max_steps_edit_values = + #ifdef MAX_STEPS_EDIT_VALUES + MAX_STEPS_EDIT_VALUES + #else + default_steps * float(DEFAULT_MAX_MULTIPLIER) + #endif + ; diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index 7892de2d69..435da10a2a 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -23,8 +23,8 @@ /** * Bed Level Tools for Pro UI * Extended by: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.1.0 - * Date: 2022/08/27 + * Version: 3.2.0 + * Date: 2023/05/03 * * Based on the original work of: Henri-J-Norden * https://github.com/Jyers/Marlin/pull/126 @@ -65,7 +65,7 @@ BedLevelToolsClass bedLevelTools; -#if ENABLED(USE_UBL_VIEWER) +#if ENABLED(USE_GRID_MESHVIEWER) bool BedLevelToolsClass::viewer_asymmetric_range = false; bool BedLevelToolsClass::viewer_print_value = false; #endif @@ -170,15 +170,20 @@ void BedLevelToolsClass::MoveToZ() { bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, true); } void BedLevelToolsClass::ProbeXY() { - const uint16_t Clear = Z_CLEARANCE_DEPLOY_PROBE; - sprintf_P(cmd, PSTR("G28O\nG0Z%i\nG30X%sY%s"), - Clear, + const uint16_t zclear = Z_CLEARANCE_DEPLOY_PROBE; + sprintf_P(cmd, PSTR("G0Z%i\nG30X%sY%s"), + zclear, 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); } +void BedLevelToolsClass::mesh_reset() { + ZERO(bedlevel.z_values); + TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level()); +} + // Accessors float BedLevelToolsClass::get_max_value() { float max = __FLT_MAX__ * -1; @@ -207,9 +212,11 @@ bool BedLevelToolsClass::meshvalidate() { return true; } -#if ENABLED(USE_UBL_VIEWER) +#if ENABLED(USE_GRID_MESHVIEWER) - 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*/) { + constexpr uint8_t meshfont = TERN(TJC_DISPLAY, font8x16, font6x12); + + 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; const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x; const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X); @@ -227,7 +234,6 @@ bool BedLevelToolsClass::meshvalidate() { } // Draw value square grid - char buf[8]; GRID_LOOP(x, y) { const auto start_x_px = padding_x + x * cell_width_px; const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width; @@ -246,20 +252,22 @@ bool BedLevelToolsClass::meshvalidate() { LCD_SERIAL.flushTX(); // Draw value text on + char buf[8]; + const uint8_t fs = DWINUI::fontWidth(meshfont); if (viewer_print_value) { - int8_t offset_x, offset_y = cell_height_px / 2 - 6; + int8_t offset_x, offset_y = cell_height_px / 2 - fs; if (isnan(bedlevel.z_values[x][y])) { // undefined - dwinDrawString(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); + dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); } else { // has value - if (GRID_MAX_POINTS_X < 10) + if (GRID_MAX_POINTS_X < (ENABLED(TJC_DISPLAY) ? 8 : 10)) sprintf_P(buf, PSTR("%s"), dtostrf(abs(bedlevel.z_values[x][y]), 1, 2, str_1)); else sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100)); - offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2; - if (!(GRID_MAX_POINTS_X < 10)) - dwinDrawString(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F(".")); - dwinDrawString(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf); + offset_x = cell_width_px / 2 - (fs/2) * (strlen(buf)) - 2; + if (!(GRID_MAX_POINTS_X < (ENABLED(TJC_DISPLAY) ? 8 : 10))) + dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y, F(".")); + dwinDrawString(false, meshfont, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y, buf); } safe_delay(10); LCD_SERIAL.flushTX(); @@ -286,6 +294,6 @@ bool BedLevelToolsClass::meshvalidate() { drawing_mesh = false; } -#endif // USE_UBL_VIEWER +#endif // USE_GRID_MESHVIEWER #endif // DWIN_LCD_PROUI && HAS_LEVELING diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 6e642f030c..67beddec61 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -23,8 +23,8 @@ /** * Bed Level Tools for Pro UI * Extended by: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.1.0 - * Date: 2022/08/27 + * Version: 3.2.0 + * Date: 2023/05/03 * * Based on the original work of: Henri-J-Norden * https://github.com/Jyers/Marlin/pull/126 @@ -47,14 +47,12 @@ #include "../../../inc/MarlinConfigPre.h" -//#define USE_UBL_VIEWER 1 - #define UBL_Z_OFFSET_MIN -3.0 #define UBL_Z_OFFSET_MAX 3.0 class BedLevelToolsClass { public: - #if ENABLED(USE_UBL_VIEWER) + #if ENABLED(USE_GRID_MESHVIEWER) static bool viewer_asymmetric_range; static bool viewer_print_value; #endif @@ -74,11 +72,12 @@ public: static void MoveToXY(); static void MoveToZ(); static void ProbeXY(); + static void mesh_reset(); static float get_max_value(); static float get_min_value(); static bool meshvalidate(); - #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); + #if ENABLED(USE_GRID_MESHVIEWER) + 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 }; diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 83105f2109..624ea23385 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.21.2 - * Date: 2022/12/02 + * Version: 3.25.3 + * Date: 2023/05/18 */ #include "../../../inc/MarlinConfig.h" @@ -33,22 +33,25 @@ #include "../../utf8.h" #include "../../marlinui.h" - -#include "../../../sd/cardreader.h" - #include "../../../MarlinCore.h" #include "../../../core/serial.h" #include "../../../core/macros.h" - #include "../../../module/temperature.h" #include "../../../module/printcounter.h" #include "../../../module/motion.h" -#include "../../../module/stepper.h" #include "../../../module/planner.h" - +#include "../../../module/stepper.h" #include "../../../gcode/gcode.h" #include "../../../gcode/queue.h" +#if HAS_MEDIA + #include "../../../sd/cardreader.h" +#endif + +#if NEED_HEX_PRINT + #include "../../../libs/hex_print.h" +#endif + #if HAS_FILAMENT_SENSOR #include "../../../feature/runout.h" #endif @@ -98,8 +101,11 @@ #include "../../../feature/leds/leds.h" #endif +#if HAS_TRINAMIC_CONFIG + #include "../../../feature/tmc_util.h" +#endif + #include "dwin.h" -#include "dwinui.h" #include "menus.h" #include "dwin_popup.h" @@ -143,6 +149,15 @@ // Load and Unload limits #define MAX_LOAD_UNLOAD 500 +// Juntion deviation limits +#define MIN_JD_MM 0.001 +#define MAX_JD_MM TERN(LIN_ADVANCE, 0.3f, 0.5f) + +#if HAS_TRINAMIC_CONFIG + #define MIN_TMC_CURRENT 100 + #define MAX_TMC_CURRENT 3000 +#endif + // Editable temperature limits #define MIN_ETEMP 0 #define MAX_ETEMP (thermalManager.hotend_maxtemp[0] - (HOTEND_OVERSHOOT)) @@ -151,7 +166,6 @@ #define DWIN_VAR_UPDATE_INTERVAL 1024 #define DWIN_UPDATE_INTERVAL 1024 -#define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20) #if HAS_MESH && HAS_BED_PROBE #define BABY_Z_VAR probe.offset.z @@ -188,23 +202,20 @@ typedef struct { } select_t; select_t select_page{0}, select_print{0}; -#if HAS_HOTEND - float last_E = 0; - #define E_MIN_POS (last_E - (EXTRUDE_MAXLENGTH)) - #define E_MAX_POS (last_E + (EXTRUDE_MAXLENGTH)) +#if ENABLED(LCD_BED_TRAMMING) + constexpr float bed_tramming_inset_lfbr[] = BED_TRAMMING_INSET_LFRB; #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; +#if ENABLED(LCD_BED_TRAMMING) + MenuClass *TrammingMenu = nullptr; +#endif MenuClass *MoveMenu = nullptr; MenuClass *ControlMenu = nullptr; MenuClass *AdvancedSettings = nullptr; @@ -223,8 +234,9 @@ MenuClass *FilamentMenu = nullptr; #if ENABLED(MESH_BED_LEVELING) MenuClass *ManualMesh = nullptr; #endif -#if HAS_HOTEND +#if HAS_PREHEAT MenuClass *PreheatMenu = nullptr; + MenuClass *PreheatHotendMenu = nullptr; #endif MenuClass *TemperatureMenu = nullptr; MenuClass *MaxSpeedMenu = nullptr; @@ -236,10 +248,10 @@ MenuClass *StepsMenu = nullptr; #if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU) MenuClass *HotendMPCMenu = nullptr; #endif -#if ENABLED(PIDTEMP) +#if ENABLED(PIDTEMP) && ANY(PID_EDIT_MENU, PID_AUTOTUNE_MENU) MenuClass *HotendPIDMenu = nullptr; #endif -#if ENABLED(PIDTEMPBED) +#if ENABLED(PIDTEMPBED) && ANY(PID_EDIT_MENU, PID_AUTOTUNE_MENU) MenuClass *BedPIDMenu = nullptr; #endif #if ENABLED(CASELIGHT_USES_BRIGHTNESS) @@ -263,6 +275,12 @@ MenuClass *StepsMenu = nullptr; MenuClass *EditMeshMenu = nullptr; #endif #endif +#if ENABLED(SHAPING_MENU) + MenuClass *InputShapingMenu = nullptr; +#endif +#if HAS_TRINAMIC_CONFIG + MenuClass *TrinamicConfigMenu = nullptr; +#endif // Updatable menuitems pointers MenuItemClass *HotendTargetItem = nullptr; @@ -541,6 +559,7 @@ void Draw_Print_Labels() { } void Draw_Print_ProgressBar() { + const uint8_t _percent_done = ui.get_progress_percent(); DWINUI::Draw_IconWB(ICON_Bar, 15, 93); dwinDrawRectangle(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); @@ -549,19 +568,22 @@ void Draw_Print_ProgressBar() { void Draw_Print_ProgressElapsed() { char buf[10]; - duration_t elapsed = print_job_timer.duration(); // print timer + duration_t elapsed = print_job_timer.duration(); // Print timer sprintf_P(buf, PSTR("%02i:%02i "), (uint16_t)(elapsed.value / 3600), ((uint16_t)elapsed.value % 3600) / 60); DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 47, 192, buf); } -void Draw_Print_ProgressRemain() { - char buf[10]; - sprintf_P(buf, PSTR("%02i:%02i "), (uint16_t)(_remain_time / 3600), ((uint16_t)_remain_time % 3600) / 60); - DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 181, 192, buf); -} +#if ENABLED(SHOW_REMAINING_TIME) + void Draw_Print_ProgressRemain() { + const uint32_t _remain_time = ui.get_remaining_time(); + char buf[10]; + sprintf_P(buf, PSTR("%02i:%02i "), (uint16_t)(_remain_time / 3600), ((uint16_t)_remain_time % 3600) / 60); + DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 181, 192, buf); + } +#endif void ICON_ResumeOrPause() { - if (checkkey == PrintProcess) printingIsPaused() ? ICON_Resume() : ICON_Pause(); + if (checkkey == PrintProcess) (print_job_timer.isPaused() || hmiFlag.pause_flag) ? ICON_Resume() : ICON_Pause(); } // Update filename on print @@ -584,13 +606,13 @@ void Draw_PrintProcess() { else Title.ShowCaption(GET_TEXT_F(MSG_PRINTING)); DWINUI::ClearMainArea(); - DWIN_Print_Header(SD_Printing() ? card.longest_filename() : nullptr); + DWIN_Print_Header(nullptr); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); - Draw_Print_ProgressRemain(); + TERN_(SHOW_REMAINING_TIME, Draw_Print_ProgressRemain()); ICON_Tune(); ICON_ResumeOrPause(); ICON_Stop(); @@ -608,31 +630,28 @@ void Goto_PrintProcess() { } void Draw_PrintDone() { - // show percent bar and value - _percent_done = 100; - _remain_time = 0; - + TERN_(SET_PROGRESS_PERCENT, ui.set_progress_done()); + TERN_(SET_REMAINING_TIME, ui.reset_remaining_time()); Title.ShowCaption(GET_TEXT_F(MSG_PRINT_DONE)); DWINUI::ClearMainArea(); DWIN_Print_Header(nullptr); - #if HAS_GCODE_PREVIEW - const bool isvalid = Preview_Valid(); - if (isvalid) { - dwinIconShow(0, 0, 1, 21, 100, 0x00); - DWINUI::Draw_Button(BTN_Continue, 86, 300); + const bool haspreview = Preview_Valid(); + if (haspreview) { + Preview_Show(); + DWINUI::Draw_Button(BTN_Continue, 86, 295); } #else - constexpr bool isvalid = false; + constexpr bool haspreview = false; #endif - if (!isvalid) { + if (!haspreview) { Draw_Print_ProgressBar(); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); Draw_Print_ProgressElapsed(); - Draw_Print_ProgressRemain(); + TERN_(SHOW_REMAINING_TIME, Draw_Print_ProgressRemain()); DWINUI::Draw_Button(BTN_Continue, 86, 273); } } @@ -674,7 +693,13 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, // Check for a position change static xyz_pos_t oldpos = { -1, -1, -1 }; - const float p = TERN(SHOW_REAL_POS, stepper.position(axis) / planner.settings.axis_steps_per_mm[axis], current_position[axis]); + const float p = ( + #if ALL(IS_FULL_CARTESIAN, SHOW_REAL_POS) + planner.get_axis_position_mm(axis) + #else + current_position[axis] + #endif + ); const bool changed = oldpos[axis] != p; if (changed) oldpos[axis] = p; @@ -689,34 +714,58 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, } } +void _draw_iconblink(bool &flag, const bool sensor, const uint8_t icon1, const uint8_t icon2, const uint16_t x, const uint16_t y) { + #if DISABLED(NO_BLINK_IND) + if (flag != sensor) { + flag = sensor; + if (!flag) { + dwinDrawBox(1, HMI_data.Background_Color, x, y, 20, 20); + DWINUI::Draw_Icon(icon1, x, y); + } + } + if (flag) { + dwinDrawBox(1, blink ? HMI_data.SplitLine_Color : HMI_data.Background_Color, x, y, 20, 20); + DWINUI::Draw_Icon(icon2, x, y); + } + #else + if (flag != sensor) { + flag = sensor; + dwinDrawBox(1, HMI_data.Background_Color, x, y, 20, 20); + DWINUI::Draw_Icon(flag ? icon2 : icon1, x, y); + } + #endif +} + 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; - dwinDrawRectangle(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) { - dwinDrawRectangle(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) { - dwinDrawRectangle(1, HMI_data.Background_Color, 186, 415, 205, 436); - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); - } - } - #endif + static bool _leveling_active = false; + _draw_iconblink(_leveling_active, planner.leveling_active, ICON_Zoffset, ICON_SetZOffset, 186, 416); #else DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); #endif } +void _draw_feedrate() { + #if ENABLED(SHOW_SPEED_IND) + int16_t _value; + if (blink) { + _value = feedrate_percentage; + DWINUI::Draw_String(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 116 + 4 * STAT_CHR_W + 2, 384, F(" %")); + } + else { + _value = CEIL(feedrate_mm_s * feedrate_percentage / 100); + dwinDrawBox(1, HMI_data.Background_Color, 116 + 5 * STAT_CHR_W + 2, 384, 20, 20); + } + DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 116 + 2 * STAT_CHR_W, 384, _value); + #else + static int16_t _feedrate = 100; + if (_feedrate != feedrate_percentage) { + _feedrate = feedrate_percentage; + DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 116 + 2 * STAT_CHR_W, 384, _feedrate); + } + #endif +} + void _draw_xyz_position(const bool force) { _update_axis_value(X_AXIS, 27, 459, force); _update_axis_value(Y_AXIS, 112, 459, force); @@ -724,6 +773,7 @@ void _draw_xyz_position(const bool force) { } void update_variable() { + _draw_xyz_position(false); #if HAS_HOTEND static celsius_t _hotendtemp = 0, _hotendtarget = 0; const celsius_t hc = thermalManager.wholeDegHotend(0), @@ -777,17 +827,11 @@ void update_variable() { DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 417, _bedtarget); #endif - static int16_t _feedrate = 100; - if (_feedrate != feedrate_percentage) { - _feedrate = feedrate_percentage; - DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 116 + 2 * STAT_CHR_W, 384, _feedrate); - } + _draw_feedrate(); #if HAS_FAN - if (_new_fanspeed) { - _fanspeed = thermalManager.fan_speed[0]; + if (_new_fanspeed) DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, _fanspeed); - } #endif static float _offset = 0; @@ -797,7 +841,6 @@ void update_variable() { } _draw_ZOffsetIcon(); - _draw_xyz_position(false); } /** @@ -806,43 +849,43 @@ void update_variable() { bool DWIN_lcd_sd_status = false; -void SetMediaAutoMount() { - Toggle_Chkb_Line(HMI_data.MediaAutoMount); -} +#if ENABLED(MEDIASORT_MENU_ITEM) + void SetMediaSort() { + Toggle_Chkb_Line(HMI_data.MediaSort); + card.setSortOn(HMI_data.MediaSort); + } +#endif + +void SetMediaAutoMount() { Toggle_Chkb_Line(HMI_data.MediaAutoMount); } inline uint16_t nr_sd_menu_items() { return _MIN(card.get_num_items() + !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 + size_t pos = strlen(src); // Index of ending nul // For files, remove the extension // which may be .gcode, .gco, or .g if (!card.flag.filenameIsDir) - while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0) + while (pos && src[pos] != '.') pos--; // Find last '.' (stop at 0) if (!pos) pos = strlen(src); // pos = 0 ('.' not found) restore pos size_t len = pos; // nul or '.' if (len > maxlen) { // Keep the name short - pos = len = maxlen; // move nul down - dst[--pos] = '.'; // insert dots + pos = len = maxlen; // Move nul down + dst[--pos] = '.'; // Insert dots dst[--pos] = '.'; dst[--pos] = '.'; } - dst[len] = '\0'; // end it + dst[len] = '\0'; // End it // Copy down to 0 while (pos--) dst[pos] = src[pos]; } -void Redraw_SD_List() { - InvalidateMenu(); - Draw_Print_File_Menu(); -} - void SDCard_Up() { card.cdup(); DWIN_lcd_sd_status = false; // On next DWIN_Update @@ -865,8 +908,10 @@ void onClickSDItem() { if (card.fileIsBinary()) return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); - else + else { + DWIN_Print_Header(card.longest_filename()); // Save filename return Goto_ConfirmToPrint(); + } } } @@ -892,7 +937,7 @@ void onClickSDItem() { static int8_t shift_amt = 0, shift_len = 0; if (reset) { last_itemselected = 0; - hasUpDir = !card.flag.workDirIsRoot; // is a SubDir + hasUpDir = !card.flag.workDirIsRoot; // Is a SubDir return; } const uint8_t selected = FileMenu->selected; @@ -961,9 +1006,12 @@ void HMI_SDCardUpdate() { if (hmiFlag.home_flag) return; if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); - if (IsMenu(FileMenu)) Redraw_SD_List(); + ResetMenu(FileMenu); + if (IsMenu(FileMenu)) { + CurrentMenu = nullptr; + Draw_Print_File_Menu(); + } if (!DWIN_lcd_sd_status && SD_Printing()) ui.abort_print(); // Media removed while printing - dwinUpdateLCD(); } } @@ -974,6 +1022,12 @@ void HMI_SDCardUpdate() { void DWIN_Draw_Dashboard() { dwinDrawRectangle(1, HMI_data.Background_Color, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1); + dwinDrawRectangle(1, HMI_data.SplitLine_Color, 0, 449, DWIN_WIDTH, 451); + + DWINUI::Draw_Icon(ICON_MaxSpeedX, 10, 456); + DWINUI::Draw_Icon(ICON_MaxSpeedY, 95, 456); + DWINUI::Draw_Icon(ICON_MaxSpeedZ, 180, 456); + _draw_xyz_position(true); #if HAS_HOTEND DWINUI::Draw_Icon(ICON_HotendTemp, 10, 383); @@ -995,7 +1049,7 @@ void DWIN_Draw_Dashboard() { DWINUI::Draw_Icon(ICON_Speed, 113, 383); DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 116 + 2 * STAT_CHR_W, 384, feedrate_percentage); - DWINUI::Draw_String(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 116 + 5 * STAT_CHR_W + 2, 384, F("%")); + IF_DISABLED(SHOW_SPEED_IND, DWINUI::Draw_String(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 116 + 5 * STAT_CHR_W + 2, 384, F("%"))); #if HAS_FAN DWINUI::Draw_Icon(ICON_FanSpeed, 187, 383); @@ -1004,17 +1058,8 @@ void DWIN_Draw_Dashboard() { #if HAS_ZOFFSET_ITEM DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); + DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, BABY_Z_VAR); #endif - - DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, BABY_Z_VAR); - - dwinDrawRectangle(1, HMI_data.SplitLine_Color, 0, 449, DWIN_WIDTH, 451); - - DWINUI::Draw_Icon(ICON_MaxSpeedX, 10, 456); - DWINUI::Draw_Icon(ICON_MaxSpeedY, 95, 456); - DWINUI::Draw_Icon(ICON_MaxSpeedZ, 180, 456); - _draw_xyz_position(true); - } void Draw_Info_Menu() { @@ -1091,8 +1136,8 @@ void HMI_MainMenu() { // Pause or Stop popup void onClick_PauseOrStop() { switch (select_print.now) { - case PRINT_PAUSE_RESUME: if (hmiFlag.select_flag) ui.pause_print(); break; // confirm pause - case PRINT_STOP: if (hmiFlag.select_flag) ui.abort_print(); break; // stop confirmed then abort print + case PRINT_PAUSE_RESUME: if (hmiFlag.select_flag) ui.pause_print(); break; // Confirm pause + case PRINT_STOP: if (hmiFlag.select_flag) ui.abort_print(); break; // Stop confirmed then abort print default: break; } return Goto_PrintProcess(); @@ -1125,7 +1170,7 @@ void HMI_Printing() { switch (select_print.now) { case PRINT_SETUP: Draw_Tune_Menu(); break; case PRINT_PAUSE_RESUME: - if (printingIsPaused()) { // if printer is already in pause + if (printingIsPaused()) { // If printer is already in pause ui.resume_print(); break; } @@ -1163,12 +1208,6 @@ void Draw_Main_Area() { } } -void HMI_ReturnScreen() { - checkkey = last_checkkey; - wait_for_user = false; - Draw_Main_Area(); -} - void HMI_WaitForUser() { EncoderState encoder_diffState = get_encoder_state(); if (encoder_diffState != ENCODER_DIFF_NO && !ui.backlight) { @@ -1197,7 +1236,7 @@ void HMI_Init() { #define BOOTSCREEN_TIMEOUT 1100 #endif DWINUI::Draw_Box(1, Color_Black, { 5, 220, DWIN_WIDTH - 5, DWINUI::fontHeight() }); - DWINUI::Draw_CenteredString(Color_White, 220, F("Professional Firmware ")); + DWINUI::Draw_CenteredString(Color_White, 220, F("ProUI starting up ")); for (uint16_t t = 15; t < 257; t += 11) { DWINUI::Draw_Icon(ICON_Bar, 15, 260); dwinDrawRectangle(1, HMI_data.Background_Color, t, 260, 257, 280); @@ -1220,7 +1259,11 @@ void EachMomentUpdate() { if (checkkey == ESDiagProcess) ESDiag.Update(); #endif #if SHOW_TUNING_GRAPH - if (checkkey == PidProcess) plot.Update((HMI_value.pidresult == PIDTEMP_START) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); + if (checkkey == PidProcess) { + TERN_(PIDTEMP, if (HMI_value.tempcontrol == PIDTEMP_START) plot.Update(thermalManager.wholeDegHotend(0))); + TERN_(PIDTEMPBED, if (HMI_value.tempcontrol == PIDTEMPBED_START) plot.Update(thermalManager.wholeDegBed())); + } + TERN_(MPCTEMP, if (checkkey == MPCProcess) plot.Update(thermalManager.wholeDegHotend(0))); #endif } @@ -1261,40 +1304,37 @@ void EachMomentUpdate() { DWIN_Print_Resume(); } - if (checkkey == PrintProcess) { // print process + if (checkkey == PrintProcess) { // Print process - duration_t elapsed = print_job_timer.duration(); // print timer + // Progress percent + static uint8_t _percent_done = 255; + if (_percent_done != ui.get_progress_percent()) { + _percent_done = ui.get_progress_percent(); + Draw_Print_ProgressBar(); + } - if (card.isPrinting() && !hmiFlag.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) && !hmiFlag.heat_flag && !hmiFlag.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; + // Remaining time + #if ENABLED(SHOW_REMAINING_TIME) + static uint32_t _remain_time = 0; + if (_remain_time != ui.get_remaining_time()) { + _remain_time = ui.get_remaining_time(); Draw_Print_ProgressRemain(); } - } + #endif - // 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; + // Elapsed print time + static uint16_t _printtime = 0; + const uint16_t min = (print_job_timer.duration() % 3600) / 60; + if (_printtime != min) { // 1 minute update + _printtime = min; Draw_Print_ProgressElapsed(); } - } #if ENABLED(POWER_LOSS_RECOVERY) - else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off + else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // Resume print before power off return Goto_PowerLossRecovery(); } - #endif // POWER_LOSS_RECOVERY + #endif dwinUpdateLCD(); } @@ -1321,6 +1361,7 @@ void EachMomentUpdate() { const char * const filename = card.diveToFile(true, dir, recovery.info.sd_filename); card.selectFileByName(filename); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 207, card.longest_filename()); + DWIN_Print_Header(card.longest_filename()); // Save filename Draw_Select_Highlight(hmiFlag.select_flag); dwinUpdateLCD(); } @@ -1332,6 +1373,7 @@ void EachMomentUpdate() { return Goto_Main_Menu(); } else { + HMI_SaveProcessID(NothingToDo); select_print.set(PRINT_SETUP); queue.inject(F("M1000")); } @@ -1345,7 +1387,6 @@ void EachMomentUpdate() { #endif // POWER_LOSS_RECOVERY - void DWIN_HandleScreen() { switch (checkkey) { case MainMenu: HMI_MainMenu(); break; @@ -1372,27 +1413,41 @@ void DWIN_HandleScreen() { } bool IDisPopUp() { // If ID is popup... - return (checkkey == NothingToDo) - || (checkkey == WaitResponse) - || (checkkey == Homing) - || (checkkey == Leveling) - || (checkkey == PidProcess) - || TERN0(HAS_ESDIAG, (checkkey == ESDiagProcess)) - || (checkkey == Popup); + switch (checkkey) { + case NothingToDo: + case WaitResponse: + case Popup: + case Homing: + case Leveling: + case PidProcess: + TERN_(HAS_ESDIAG, case ESDiagProcess:) + return true; + default: break; + } + return false; } void HMI_SaveProcessID(const uint8_t id) { - if (checkkey != id) { - if (!IDisPopUp()) last_checkkey = checkkey; // if previous is not a popup - if ((id == Popup) - || TERN0(HAS_ESDIAG, (id == ESDiagProcess)) - || (id == PrintDone) - || (id == Leveling) - || (id == WaitResponse)) wait_for_user = true; - checkkey = id; + if (checkkey == id) return; + if (!IDisPopUp()) last_checkkey = checkkey; // If previous is not a popup + checkkey = id; + switch (id) { + case Popup: + case WaitResponse: + case PrintDone: + case Leveling: + TERN_(HAS_ESDIAG, case ESDiagProcess:) + wait_for_user = true; + default: break; } } +void HMI_ReturnScreen() { + checkkey = last_checkkey; + wait_for_user = false; + Draw_Main_Area(); +} + void dwinHomingStart() { hmiFlag.home_flag = true; HMI_SaveProcessID(Homing); @@ -1402,7 +1457,10 @@ void dwinHomingStart() { void dwinHomingDone() { hmiFlag.home_flag = false; - HMI_ReturnScreen(); + if (last_checkkey == PrintDone) + Goto_PrintDone(); + else + HMI_ReturnScreen(); } void DWIN_LevelingStart() { @@ -1411,16 +1469,22 @@ void DWIN_LevelingStart() { 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)); #if ALL(AUTO_BED_LEVELING_UBL, PREHEAT_BEFORE_LEVELING) - #if HAS_HOTEND - if (thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP) - thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0); + #if HAS_BED_PROBE + if (!DEBUGGING(DRYRUN)) probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, HMI_data.BedLevT); + #else + #if HAS_HOTEND + if (!DEBUGGING(DRYRUN) && thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP) { + thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0); + thermalManager.wait_for_hotend(0); + } + #endif + #if HAS_HEATED_BED + if (!DEBUGGING(DRYRUN) && thermalManager.degTargetBed() < HMI_data.BedLevT) { + thermalManager.setTargetBed(HMI_data.BedLevT); + thermalManager.wait_for_bed_heating(); + } + #endif #endif - #if HAS_HEATED_BED - if (thermalManager.degTargetBed() < HMI_data.BedLevT) - thermalManager.setTargetBed(HMI_data.BedLevT); - #endif - TERN_(HAS_HOTEND, thermalManager.wait_for_hotend(0)); - TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating()); #endif #elif ENABLED(MESH_BED_LEVELING) Draw_ManualMesh_Menu(); @@ -1428,15 +1492,13 @@ void DWIN_LevelingStart() { } void DWIN_LevelingDone() { - TERN_(HAS_MESH, Goto_MeshViewer()); + TERN_(HAS_MESH, Goto_MeshViewer(true)); } #if HAS_MESH 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), cpos, tpos, dtostrf(zval, 1, 2, str_1)); - ui.set_status(msg); + ui.status_printf(0, F(S_FMT " %i/%i Z=%s"), GET_TEXT_F(MSG_PROBING_POINT), cpos, tpos, dtostrf(zval, 1, 2, str_1)); } #endif @@ -1452,7 +1514,7 @@ void DWIN_LevelingDone() { DWINUI::ClearMainArea(); Draw_Popup_Bkgd(); - switch (HMI_value.pidresult) { + switch (HMI_value.tempcontrol) { default: return; #if ENABLED(MPC_AUTOTUNE) case MPCTEMP_START: @@ -1469,7 +1531,7 @@ void DWIN_LevelingDone() { #endif } - switch (HMI_value.pidresult) { + switch (HMI_value.tempcontrol) { default: break; #if ANY(PIDTEMP, MPC_AUTOTUNE) TERN_(PIDTEMP, case PIDTEMP_START:) @@ -1484,7 +1546,7 @@ void DWIN_LevelingDone() { #endif } - switch (HMI_value.pidresult) { + switch (HMI_value.tempcontrol) { default: break; #if ENABLED(MPC_AUTOTUNE) case MPCTEMP_START: @@ -1526,7 +1588,7 @@ void DWIN_LevelingDone() { } void DWIN_PidTuning(tempcontrol_t result) { - HMI_value.pidresult = result; + HMI_value.tempcontrol = result; switch (result) { #if ENABLED(PIDTEMP) case PIDTEMP_START: @@ -1560,7 +1622,7 @@ void DWIN_LevelingDone() { checkkey = last_checkkey; DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), GET_TEXT_F(MSG_PID_TIMEOUT)); break; - case PID_DONE: + case AUTOTUNE_DONE: checkkey = last_checkkey; DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_BUTTON_DONE)); break; @@ -1575,7 +1637,7 @@ void DWIN_LevelingDone() { #if ENABLED(MPC_AUTOTUNE) void DWIN_MPCTuning(tempcontrol_t result) { - HMI_value.pidresult = result; + HMI_value.tempcontrol = result; switch (result) { case MPCTEMP_START: HMI_SaveProcessID(MPCProcess); @@ -1595,7 +1657,7 @@ void DWIN_LevelingDone() { DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), F(STR_MPC_AUTOTUNE_INTERRUPTED)); ui.reset_alert_level(); break; - case MPC_DONE: + case AUTOTUNE_DONE: checkkey = last_checkkey; DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_MPC_AUTOTUNE), GET_TEXT_F(MSG_BUTTON_DONE)); ui.reset_alert_level(); @@ -1612,10 +1674,8 @@ void DWIN_LevelingDone() { // Started a Print Job void DWIN_Print_Started() { TERN_(HAS_GCODE_PREVIEW, if (Host_Printing()) Preview_Invalidate()); - _percent_done = 0; - _remain_time = 0; - hmiFlag.percent_flag = false; - hmiFlag.remain_flag = false; + TERN_(SET_PROGRESS_PERCENT, ui.progress_reset()); + TERN_(SET_REMAINING_TIME, ui.reset_remaining_time()); hmiFlag.pause_flag = false; hmiFlag.abort_flag = false; select_print.reset(); @@ -1636,6 +1696,7 @@ void DWIN_Print_Resume() { // Ended print job void DWIN_Print_Finished() { TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel()); + hmiFlag.abort_flag = false; hmiFlag.pause_flag = false; wait_for_heatup = false; planner.finish_and_disable(); @@ -1648,23 +1709,6 @@ void DWIN_Print_Aborted() { DWIN_Print_Finished(); } -// Progress and remaining time update -void DWIN_M73() { - if (parser.seenval('P')) { - _percent_done = parser.value_byte(); - hmiFlag.percent_flag = true; - } - if (parser.seenval('R')) { - _remain_time = parser.value_ulong() * 60; - hmiFlag.remain_flag = true; - } - if (checkkey == PrintProcess) { - Draw_Print_ProgressBar(); - Draw_Print_ProgressRemain(); - Draw_Print_ProgressElapsed(); - } -} - #if HAS_FILAMENT_SENSOR // Filament Runout process void DWIN_FilamentRunout(const uint8_t extruder) { LCD_MESSAGE(MSG_RUNOUT_SENSOR); } @@ -1703,7 +1747,13 @@ void DWIN_SetDataDefaults() { #endif TERN_(PREHEAT_BEFORE_LEVELING, HMI_data.BedLevT = LEVELING_BED_TEMP); TERN_(BAUD_RATE_GCODE, SetBaud250K()); - HMI_data.FullManualTramming = false; + #if ALL(LCD_BED_TRAMMING, HAS_BED_PROBE) + HMI_data.FullManualTramming = DISABLED(BED_TRAMMING_USE_PROBE); + #endif + #if ENABLED(MEDIASORT_MENU_ITEM) + HMI_data.MediaSort = true; + card.setSortOn(true); + #endif HMI_data.MediaAutoMount = ENABLED(HAS_SD_EXTENDER); #if ALL(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) HMI_data.z_after_homing = DEF_Z_AFTER_HOMING; @@ -1712,6 +1762,8 @@ void DWIN_SetDataDefaults() { TERN_(LED_COLOR_PRESETS, leds.set_default()); ApplyLEDColor(); #endif + TERN_(ADAPTIVE_STEP_SMOOTHING, HMI_data.AdaptiveStepSmoothing = true); + TERN_(HAS_GCODE_PREVIEW, HMI_data.EnablePreview = true); } void DWIN_CopySettingsTo(char * const buff) { @@ -1738,7 +1790,7 @@ void DWIN_CopySettingsFrom(const char * const buff) { // Initialize or re-initialize the LCD void MarlinUI::init_lcd() { - delay(750); // wait to wakeup screen + delay(750); // Wait to wakeup screen const bool hs = dwinHandshake(); UNUSED(hs); dwinFrameSetDir(1); dwinJPGCacheTo1(Language_English); @@ -1747,22 +1799,21 @@ void MarlinUI::init_lcd() { void dwinInitScreen() { DWIN_SetColorDefaults(); - HMI_Init(); // draws boot screen + HMI_Init(); // Draws boot screen DWINUI::init(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWINUI::onTitleDraw = Draw_Title; InitMenu(); checkkey = 255; hash_changed = true; - last_E = 0; DWIN_DrawStatusLine(); DWIN_Draw_Dashboard(); Goto_Main_Menu(); } void MarlinUI::update() { - EachMomentUpdate(); // Status update HMI_SDCardUpdate(); // SD card update + EachMomentUpdate(); // Status update DWIN_HandleScreen(); // Rotary encoder update } @@ -1798,7 +1849,7 @@ void DWIN_RedrawScreen() { } #if ENABLED(ADVANCED_PAUSE_FEATURE) - void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button /*= 0*/) { + void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button/*=0*/) { HMI_SaveProcessID(button ? WaitResponse : NothingToDo); DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), fmsg, button); } @@ -1853,7 +1904,6 @@ void DWIN_RedrawScreen() { #endif // ADVANCED_PAUSE_FEATURE #if HAS_MESH - void DWIN_MeshViewer() { if (!leveling_is_valid()) DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_MESH_VIEWER), GET_TEXT_F(MSG_NO_VALID_MESH)); @@ -1862,8 +1912,7 @@ void DWIN_RedrawScreen() { MeshViewer.Draw(); } } - -#endif // HAS_MESH +#endif #if HAS_LOCKSCREEN @@ -1893,11 +1942,11 @@ void DWIN_RedrawScreen() { #if HAS_GCODE_PREVIEW + void SetPreview() { Toggle_Chkb_Line(HMI_data.EnablePreview); } + void onClick_ConfirmToPrint() { - Preview_Reset(); DWIN_ResetStatusLine(); if (hmiFlag.select_flag) { // Confirm - hmiFlag.heat_flag = true; Goto_Main_Menu(); return card.openAndPrintFile(card.filename); } @@ -1905,16 +1954,13 @@ void DWIN_RedrawScreen() { HMI_ReturnScreen(); } -#endif +#endif // HAS_GCODE_PREVIEW void Goto_ConfirmToPrint() { #if HAS_GCODE_PREVIEW - Goto_Popup(Preview_DrawFromSD, onClick_ConfirmToPrint); - #else - // Print SD file - hmiFlag.heat_flag = true; - card.openAndPrintFile(card.filename); + if (HMI_data.EnablePreview) return Goto_Popup(Preview_DrawFromSD, onClick_ConfirmToPrint); #endif + card.openAndPrintFile(card.filename); // Direct print SD file } #if HAS_ESDIAG @@ -1925,7 +1971,7 @@ void Goto_ConfirmToPrint() { #endif //============================================================================= -// NEW MENU SUBSYSTEM +// MENU SUBSYSTEM //============================================================================= // Tool functions @@ -1954,7 +2000,7 @@ void Goto_ConfirmToPrint() { void SaveMesh() { TERN(AUTO_BED_LEVELING_UBL, UBLMeshSave(), WriteEeprom()); } #endif -#endif +#endif // EEPROM_SETTINGS // Reset Printer void RebootPrinter() { @@ -1974,7 +2020,7 @@ void Goto_Info_Menu() { void DisableMotors() { queue.inject(F("M84")); } void AutoLev() { // Always reacquire the Z "home" position - queue.inject(F(TERN(AUTO_BED_LEVELING_UBL, "G28Z\nG29P1", "G28XYO\nG28Z\nG29"))); + queue.inject(F(TERN(AUTO_BED_LEVELING_UBL, "G29P1", "G29"))); } void AutoHome() { queue.inject_P(G28_STR); } @@ -1989,14 +2035,6 @@ void AutoHome() { queue.inject_P(G28_STR); } #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); - } -#endif - #if HAS_ZOFFSET_ITEM void ApplyZOffset() { TERN_(EEPROM_SETTINGS, settings.save()); } @@ -2013,31 +2051,31 @@ void AutoHome() { queue.inject_P(G28_STR); } SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); } - void SetMoveZto0() { - #if ENABLED(Z_SAFE_HOMING) - char cmd[54], str_1[5], str_2[5]; - sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nG0Z0F300\nM400"), - dtostrf(Z_SAFE_HOMING_X_POINT, 1, 1, str_1), - dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 1, str_2) - ); - gcode.process_subcommands_now(cmd); - #else - TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); - gcode.process_subcommands_now(F("G28Z\nG0Z0F300\nM400")); - #endif - ui.reset_status(); - DONE_BUZZ(true); - } - - #if !HAS_BED_PROBE - void HomeZandDisable() { - SetMoveZto0(); - DisableMotors(); - } - #endif - #endif // HAS_ZOFFSET_ITEM +void SetMoveZto0() { + #if ENABLED(Z_SAFE_HOMING) + char cmd[54], str_1[5], str_2[5]; + sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nG0Z0F300\nM400"), + dtostrf(Z_SAFE_HOMING_X_POINT, 1, 1, str_1), + dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 1, str_2) + ); + gcode.process_subcommands_now(cmd); + #else + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); + gcode.process_subcommands_now(F("G28Z\nG0Z0F300\nM400")); + #endif + ui.reset_status(); + DONE_BUZZ(true); +} + +#if DISABLED(HAS_BED_PROBE) + void HomeZandDisable() { + SetMoveZto0(); + DisableMotors(); + } +#endif + #if HAS_PREHEAT #define _DoPreheat(N) void DoPreheat##N() { ui.preheat_all(N-1); }\ void DoPreheatHotend##N() { ui.preheat_hotend(N-1); } @@ -2054,17 +2092,24 @@ void SetLanguage() { bool EnableLiveMove = false; void SetLiveMove() { Toggle_Chkb_Line(EnableLiveMove); } -void LiveMove() { +void AxisMove(AxisEnum axis) { + #if HAS_HOTEND + if (axis == E_AXIS && thermalManager.tooColdToExtrude(0)) { + gcode.process_subcommands_now(F("G92E0")); // Reset extruder position + return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); + } + #endif planner.synchronize(); + if (!planner.is_full()) planner.buffer_line(current_position, manual_feedrate_mm_s[axis]); +} +void LiveMove() { if (!EnableLiveMove) return; *MenuData.P_Float = MenuData.Value / MINUNITMULT; - if (!planner.is_full()) planner.buffer_line(current_position, manual_feedrate_mm_s[HMI_value.axis]); + AxisMove(HMI_value.axis); } 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]); + AxisMove(HMI_value.axis); } void SetMoveX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(X_MIN_POS, X_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } @@ -2073,30 +2118,12 @@ void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS #if HAS_HOTEND void SetMoveE() { - 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); + const float e_min = current_position.e - (EXTRUDE_MAXLENGTH), + e_max = current_position.e + (EXTRUDE_MAXLENGTH); + HMI_value.axis = E_AXIS; SetPFloatOnClick(e_min, e_max, UNITFDIGITS, ApplyMove, LiveMove); } #endif -#if DWIN_PID_TUNE - void SetPID(celsius_t t, heater_id_t h) { - char cmd[53] = ""; - char str_1[5] = "", str_2[5] = ""; - sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84\nM400"), - dtostrf(X_CENTER, 1, 1, str_1), - dtostrf(Y_CENTER, 1, 1, str_2) - ); - gcode.process_subcommands_now(cmd); - thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); - } - #if ENABLED(PIDTEMP) - void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); } - #endif - #if ENABLED(PIDTEMPBED) - void BedPID() { SetPID(HMI_data.BedPidT, H_BED); } - #endif -#endif - #if ENABLED(POWER_LOSS_RECOVERY) void SetPwrLossr() { Toggle_Chkb_Line(recovery.enabled); @@ -2210,39 +2237,6 @@ void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS void SetExtMinT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP, ApplyExtMinT); } #endif -void RestoreDefaultColors() { - DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); - DWIN_RedrawScreen(); -} - -void SelColor() { - MenuData.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; - HMI_value.Color[0] = GetRColor(*MenuData.P_Int); // Red - HMI_value.Color[1] = GetGColor(*MenuData.P_Int); // Green - HMI_value.Color[2] = GetBColor(*MenuData.P_Int); // Blue - Draw_GetColor_Menu(); -} - -void LiveRGBColor() { - HMI_value.Color[CurrentMenu->line() - 2] = MenuData.Value; - uint16_t color = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); - dwinDrawRectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); -} -void SetRGBColor() { - const uint8_t color = static_cast(CurrentMenu->SelectedItem())->icon; - SetIntOnClick(0, (color == 1) ? 63 : 31, HMI_value.Color[color], nullptr, LiveRGBColor); -} - -void DWIN_ApplyColor() { - *MenuData.P_Int = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); - Draw_SelectColors_Menu(); - hash_changed = true; - LCD_MESSAGE(MSG_COLORS_APPLIED); - DWIN_Draw_Dashboard(); -} - void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } #if HAS_HOTEND @@ -2292,172 +2286,187 @@ void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, []{ planner.refr // Bed Tramming -void TramXY(const uint8_t point, const float &margin, float &x, float &y) { - switch (point) { - case 0: - LCD_MESSAGE(MSG_LEVBED_FL); - x = y = margin; - break; - case 1: - LCD_MESSAGE(MSG_LEVBED_FR); - x = X_BED_SIZE - margin; y = margin; - break; - case 2: - LCD_MESSAGE(MSG_LEVBED_BR); - x = X_BED_SIZE - margin; y = Y_BED_SIZE - margin; - break; - case 3: - LCD_MESSAGE(MSG_LEVBED_BL); - x = margin; y = Y_BED_SIZE - margin; - break; - case 4: - LCD_MESSAGE(MSG_LEVBED_C); - x = X_CENTER; y = Y_CENTER; - break; +#if ENABLED(LCD_BED_TRAMMING) + + void TramXY(const uint8_t point, float &x, float &y) { + switch (point) { + case 0: + LCD_MESSAGE(MSG_TRAM_FL); + x = bed_tramming_inset_lfbr[0]; + y = bed_tramming_inset_lfbr[1]; + break; + case 1: + LCD_MESSAGE(MSG_TRAM_FR); + x = X_BED_SIZE - bed_tramming_inset_lfbr[2]; + y = bed_tramming_inset_lfbr[1]; + break; + case 2: + LCD_MESSAGE(MSG_TRAM_BR); + x = X_BED_SIZE - bed_tramming_inset_lfbr[2]; + y = Y_BED_SIZE - bed_tramming_inset_lfbr[3]; + break; + case 3: + LCD_MESSAGE(MSG_TRAM_BL); + x = bed_tramming_inset_lfbr[0]; + y = Y_BED_SIZE - bed_tramming_inset_lfbr[3]; + break; + #if ENABLED(BED_TRAMMING_INCLUDE_CENTER) + case 4: + LCD_MESSAGE(MSG_TRAM_C); + x = X_CENTER; y = Y_CENTER; + break; + #endif + } } -} -#if HAS_BED_PROBE + #if HAS_BED_PROBE - float Tram(const uint8_t point) { - char cmd[100] = ""; - static bool inLev = false; - float xpos = 0, ypos = 0, zval = 0, margin = 0; - char str_1[6] = "", str_2[6] = "", str_3[6] = ""; - if (inLev) return NAN; - margin = HMI_data.FullManualTramming ? 30 : PROBING_MARGIN; + float Tram(const uint8_t point) { + char cmd[100] = ""; + static bool inLev = false; + float xpos = 0, ypos = 0, zval = 0; + char str_1[6] = "", str_2[6] = "", str_3[6] = ""; + if (inLev) return NAN; - TramXY(point, margin, xpos, ypos); + TramXY(point, xpos, ypos); - if (HMI_data.FullManualTramming) { - sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%sY%sF5000\nG0Z0F300"), - dtostrf(xpos, 1, 1, str_1), - dtostrf(ypos, 1, 1, str_2) - ); + if (HMI_data.FullManualTramming) { + sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%sY%sF5000\nG0Z0F300"), + dtostrf(xpos, 1, 1, str_1), + dtostrf(ypos, 1, 1, str_2) + ); + queue.inject(cmd); + } + else { + // AUTO_BED_LEVELING_BILINEAR does not define MESH_INSET + #ifndef MESH_MIN_X + #define MESH_MIN_X (_MAX(X_MIN_BED + PROBING_MARGIN, X_MIN_POS)) + #endif + #ifndef MESH_MIN_Y + #define MESH_MIN_Y (_MAX(Y_MIN_BED + PROBING_MARGIN, Y_MIN_POS)) + #endif + #ifndef MESH_MAX_X + #define MESH_MAX_X (_MIN(X_MAX_BED - (PROBING_MARGIN), X_MAX_POS)) + #endif + #ifndef MESH_MAX_Y + #define MESH_MAX_Y (_MIN(Y_MAX_BED - (PROBING_MARGIN), Y_MAX_POS)) + #endif + + LIMIT(xpos, MESH_MIN_X, MESH_MAX_X); + LIMIT(ypos, MESH_MIN_Y, MESH_MAX_Y); + probe.stow(); + gcode.process_subcommands_now(F("M420S0\nG28O")); + inLev = true; + zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); + if (isnan(zval)) + LCD_MESSAGE(MSG_ZPROBE_OUT); + else { + sprintf_P(cmd, PSTR("X:%s, Y:%s, Z:%s"), + dtostrf(xpos, 1, 1, str_1), + dtostrf(ypos, 1, 1, str_2), + dtostrf(zval, 1, 2, str_3) + ); + ui.set_status(cmd); + } + inLev = false; + } + return zval; + } + + #else + + void Tram(const uint8_t point) { + float xpos = 0, ypos = 0; + TramXY(point, xpos, ypos); + + char cmd[100] = "", str_1[6] = "", str_2[6] = ""; + sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%sY%sF5000\nG0Z0F300"), dtostrf(xpos, 1, 1, str_1), dtostrf(ypos, 1, 1, str_2)); queue.inject(cmd); } - else { - // AUTO_BED_LEVELING_BILINEAR does not define MESH_INSET - #ifndef MESH_MIN_X - #define MESH_MIN_X (_MAX(X_MIN_BED + PROBING_MARGIN, X_MIN_POS)) - #endif - #ifndef MESH_MIN_Y - #define MESH_MIN_Y (_MAX(Y_MIN_BED + PROBING_MARGIN, Y_MIN_POS)) - #endif - #ifndef MESH_MAX_X - #define MESH_MAX_X (_MIN(X_MAX_BED - (PROBING_MARGIN), X_MAX_POS)) - #endif - #ifndef MESH_MAX_Y - #define MESH_MAX_Y (_MIN(Y_MAX_BED - (PROBING_MARGIN), Y_MAX_POS)) + + #endif + + inline void TramFL() { Tram(0); } + inline void TramFR() { Tram(1); } + inline void TramBR() { Tram(2); } + inline void TramBL() { Tram(3); } + #if ENABLED(BED_TRAMMING_INCLUDE_CENTER) + inline void TramC() { Tram(4); } + #endif + + #if HAS_BED_PROBE && HAS_MESH + + void Trammingwizard() { + if (HMI_data.FullManualTramming) { + LCD_MESSAGE_F("Disable manual tramming"); + return; + } + bed_mesh_t zval = {0}; + zval[0][0] = TramFL(); + checkkey = NothingToDo; + MeshViewer.DrawMesh(zval, 2, 2); + zval[1][0] = TramFR(); + MeshViewer.DrawMesh(zval, 2, 2); + zval[1][1] = TramBR(); + MeshViewer.DrawMesh(zval, 2, 2); + zval[0][1] = TramBL(); + MeshViewer.DrawMesh(zval, 2, 2); + + DWINUI::Draw_CenteredString(140, F("Calculating average")); + DWINUI::Draw_CenteredString(160, F("and relative heights")); + safe_delay(1000); + float avg = 0.0f; + for (uint8_t x = 0; x < 2; ++x) for (uint8_t y = 0; y < 2; ++y) avg += zval[x][y]; + avg /= 4.0f; + for (uint8_t x = 0; x < 2; ++x) for (uint8_t y = 0; y < 2; ++y) zval[x][y] -= avg; + MeshViewer.DrawMesh(zval, 2, 2); + ui.reset_status(); + + #ifndef BED_TRAMMING_PROBE_TOLERANCE + #define BED_TRAMMING_PROBE_TOLERANCE 0.05 #endif - LIMIT(xpos, MESH_MIN_X, MESH_MAX_X); - LIMIT(ypos, MESH_MIN_Y, MESH_MAX_Y); - probe.stow(); - gcode.process_subcommands_now(F("M420S0\nG28O")); - inLev = true; - zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); - if (isnan(zval)) - LCD_MESSAGE(MSG_ZPROBE_OUT); + if (ABS(MeshViewer.max - MeshViewer.min) < BED_TRAMMING_PROBE_TOLERANCE) { + DWINUI::Draw_CenteredString(140, F("Corners leveled")); + DWINUI::Draw_CenteredString(160, F("Tolerance achieved!")); + } else { - sprintf_P(cmd, PSTR("X:%s, Y:%s, Z:%s"), - dtostrf(xpos, 1, 1, str_1), - dtostrf(ypos, 1, 1, str_2), - dtostrf(zval, 1, 2, str_3) - ); - ui.set_status(cmd); - } - inLev = false; - } - return zval; - } - -#else - - void Tram(const uint8_t point) { - float xpos = 0, ypos = 0, margin = 30; - TramXY(point, margin, xpos, ypos); - - char cmd[100] = "", str_1[6] = "", str_2[6] = ""; - sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%sY%sF5000\nG0Z0F300"), dtostrf(xpos, 1, 1, str_1), dtostrf(ypos, 1, 1, str_2)); - queue.inject(cmd); - } - -#endif - -void TramFL() { Tram(0); } -void TramFR() { Tram(1); } -void TramBR() { Tram(2); } -void TramBL() { Tram(3); } -void TramC () { Tram(4); } - -#if HAS_BED_PROBE && HAS_MESH - - void Trammingwizard() { - if (HMI_data.FullManualTramming) { - LCD_MESSAGE_F("Disable manual tramming"); - return; - } - bed_mesh_t zval = {0}; - zval[0][0] = Tram(0); - checkkey = NothingToDo; - MeshViewer.DrawMesh(zval, 2, 2); - zval[1][0] = Tram(1); - MeshViewer.DrawMesh(zval, 2, 2); - zval[1][1] = Tram(2); - MeshViewer.DrawMesh(zval, 2, 2); - zval[0][1] = Tram(3); - MeshViewer.DrawMesh(zval, 2, 2); - - DWINUI::Draw_CenteredString(140, F("Calculating average")); - DWINUI::Draw_CenteredString(160, F("and relative heights")); - safe_delay(1000); - float avg = 0.0f; - for (uint8_t x = 0; x < 2; ++x) for (uint8_t y = 0; y < 2; ++y) avg += zval[x][y]; - avg /= 4.0f; - for (uint8_t x = 0; x < 2; ++x) for (uint8_t y = 0; y < 2; ++y) zval[x][y] -= avg; - MeshViewer.DrawMesh(zval, 2, 2); - ui.reset_status(); - - if (ABS(MeshViewer.max - MeshViewer.min) < 0.05f) { - DWINUI::Draw_CenteredString(140, F("Corners leveled")); - DWINUI::Draw_CenteredString(160, F("Tolerance achieved!")); - } - else { - uint8_t p = 0; - float max = 0; - FSTR_P plabel; - bool s = true; - for (uint8_t x = 0; x < 2; ++x) for (uint8_t y = 0; y < 2; ++y) { - const float d = ABS(zval[x][y]); - if (max < d) { - s = (zval[x][y] >= 0); - max = d; - p = x + 2 * y; + uint8_t p = 0; + float max = 0; + FSTR_P plabel; + bool s = true; + for (uint8_t x = 0; x < 2; ++x) for (uint8_t y = 0; y < 2; ++y) { + const float d = ABS(zval[x][y]); + if (max < d) { + s = (zval[x][y] >= 0); + max = d; + p = x + 2 * y; + } } + switch (p) { + case 0b00 : plabel = GET_TEXT_F(MSG_TRAM_FL); break; + case 0b01 : plabel = GET_TEXT_F(MSG_TRAM_FR); break; + case 0b10 : plabel = GET_TEXT_F(MSG_TRAM_BL); break; + case 0b11 : plabel = GET_TEXT_F(MSG_TRAM_BR); break; + default : plabel = F(""); break; + } + DWINUI::Draw_CenteredString(120, F("Corners not leveled")); + DWINUI::Draw_CenteredString(140, F("Knob adjustment required")); + DWINUI::Draw_CenteredString(Color_Green, 160, s ? F("Lower") : F("Raise")); + DWINUI::Draw_CenteredString(Color_Green, 180, plabel); } - switch (p) { - case 0b00 : plabel = GET_TEXT_F(MSG_LEVBED_FL); break; - case 0b01 : plabel = GET_TEXT_F(MSG_LEVBED_FR); break; - case 0b10 : plabel = GET_TEXT_F(MSG_LEVBED_BL); break; - case 0b11 : plabel = GET_TEXT_F(MSG_LEVBED_BR); break; - default : plabel = F(""); break; - } - DWINUI::Draw_CenteredString(120, F("Corners not leveled")); - DWINUI::Draw_CenteredString(140, F("Knob adjustment required")); - DWINUI::Draw_CenteredString(Color_Green, 160, s ? F("Lower") : F("Raise")); - DWINUI::Draw_CenteredString(Color_Green, 180, plabel); + DWINUI::Draw_Button(BTN_Continue, 86, 305); + checkkey = Menu; + HMI_SaveProcessID(WaitResponse); } - DWINUI::Draw_Button(BTN_Continue, 86, 305); - checkkey = Menu; - HMI_SaveProcessID(WaitResponse); - } - void SetManualTramming() { - Toggle_Chkb_Line(HMI_data.FullManualTramming); - } + void SetManualTramming() { + Toggle_Chkb_Line(HMI_data.FullManualTramming); + } -#endif // HAS_BED_PROBE && HAS_MESH + #endif // HAS_BED_PROBE && HAS_MESH + +#endif // LCD_BED_TRAMMING #if ENABLED(MESH_BED_LEVELING) @@ -2545,6 +2554,13 @@ void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, MenuData.Val #if HAS_HOTEND void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(min_jerk_edit_values.e, max_jerk_edit_values.e, UNITFDIGITS, planner.max_jerk.e, ApplyMaxJerk); } #endif +#elif HAS_JUNCTION_DEVIATION + void ApplyJDmm() { TERN_(LIN_ADVANCE, planner.recalculate_max_e_jerk()); } + void SetJDmm() { SetPFloatOnClick(MIN_JD_MM, MAX_JD_MM, 3, ApplyJDmm); } +#endif + +#if ENABLED(LIN_ADVANCE) + void SetLA_K() { SetPFloatOnClick(0, 10, 3); } #endif #if HAS_X_AXIS @@ -2558,37 +2574,7 @@ void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, MenuData.Val #endif #if HAS_HOTEND void SetStepsE() { HMI_value.axis = E_AXIS; SetPFloatOnClick( min_steps_edit_values.e, max_steps_edit_values.e, UNITFDIGITS); } - #if ENABLED(PIDTEMP) - void SetHotendPidT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP); } - #endif #endif -#if ENABLED(PIDTEMPBED) - void SetBedPidT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } -#endif - -#if DWIN_PID_TUNE - void SetPidCycles() { SetPIntOnClick(3, 50); } - void SetKp() { SetPFloatOnClick(0, 1000, 2); } - void ApplyPIDi() { - *MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2)); - TERN_(PIDTEMP, thermalManager.updatePID()); - } - void ApplyPIDd() { - *MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2)); - TERN_(PIDTEMP, thermalManager.updatePID()); - } - void SetKi() { - MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - const float value = unscalePID_i(*MenuData.P_Float); - SetFloatOnClick(0, 1000, 2, value, ApplyPIDi); - } - void SetKd() { - MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - const float value = unscalePID_d(*MenuData.P_Float); - SetFloatOnClick(0, 1000, 2, value, ApplyPIDd); - } -#endif - #if ENABLED(FWRETRACT) void Return_FWRetract_Menu() { (PreviousMenu == FilSetMenu) ? Draw_FilSet_Menu() : Draw_Tune_Menu(); } void SetRetractLength() { SetPFloatOnClick( 0, 10, UNITFDIGITS); } @@ -2680,11 +2666,6 @@ void onDrawAutoHome(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 174, 164, 223, 177); onDrawPFloat2Menu(menuitem, line); } - #else - void onDrawHomeOffset(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 43, 89, 98, 101); - onDrawMenuItem(menuitem, line); - } #endif #endif @@ -2737,11 +2718,6 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) { dwinDrawHLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); } -#if DWIN_PID_TUNE - void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } - void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast(menuitem)->value)); } -#endif - void onDrawSpeedItem(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 116, 164, 171, 176); onDrawPIntMenu(menuitem, line); @@ -3022,7 +2998,9 @@ void Draw_Prepare_Menu() { MENU_ITEM(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, Draw_FilamentMan_Menu); #endif MENU_ITEM(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, Draw_Move_Menu); - MENU_ITEM(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, Draw_Tramming_Menu); + #if ENABLED(LCD_BED_TRAMMING) + MENU_ITEM(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, Draw_Tramming_Menu); + #endif MENU_ITEM(ICON_CloseMotor, MSG_DISABLE_STEPPERS, onDrawDisableMotors, DisableMotors); #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) MENU_ITEM(ICON_Homing, MSG_HOMING, onDrawSubMenu, Draw_Homing_Menu); @@ -3039,8 +3017,6 @@ void Draw_Prepare_Menu() { 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 @@ -3054,24 +3030,30 @@ void Draw_Prepare_Menu() { UpdateMenu(PrepareMenu); } -void Draw_Tramming_Menu() { - checkkey = Menu; - if (SET_MENU(TrammingMenu, MSG_BED_TRAMMING, 8)) { - BACK_ITEM(Draw_Prepare_Menu); - #if HAS_BED_PROBE && HAS_MESH - MENU_ITEM(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); - EDIT_ITEM(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); - #elif !HAS_BED_PROBE && HAS_ZOFFSET_ITEM - MENU_ITEM_F(ICON_MoveZ0, "Home Z and disable", onDrawMenuItem, HomeZandDisable); - #endif - 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 ); +#if ENABLED(LCD_BED_TRAMMING) + + void Draw_Tramming_Menu() { + checkkey = Menu; + if (SET_MENU(TrammingMenu, MSG_BED_TRAMMING, 8)) { + BACK_ITEM(Draw_Prepare_Menu); + #if HAS_BED_PROBE && HAS_MESH + MENU_ITEM(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); + EDIT_ITEM(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); + #elif !HAS_BED_PROBE && HAS_ZOFFSET_ITEM + MENU_ITEM_F(ICON_MoveZ0, "Home Z and disable", onDrawMenuItem, HomeZandDisable); + #endif + MENU_ITEM(ICON_Axis, MSG_TRAM_FL, onDrawMenuItem, TramFL); + MENU_ITEM(ICON_Axis, MSG_TRAM_FR, onDrawMenuItem, TramFR); + MENU_ITEM(ICON_Axis, MSG_TRAM_BR, onDrawMenuItem, TramBR); + MENU_ITEM(ICON_Axis, MSG_TRAM_BL, onDrawMenuItem, TramBL); + #if ENABLED(BED_TRAMMING_INCLUDE_CENTER) + MENU_ITEM(ICON_Axis, MSG_TRAM_C, onDrawMenuItem, TramC); + #endif + } + UpdateMenu(TrammingMenu); } - UpdateMenu(TrammingMenu); -} + +#endif // LCD_BED_TRAMMING void Draw_Control_Menu() { checkkey = Menu; @@ -3103,7 +3085,7 @@ void Draw_Control_Menu() { void Draw_AdvancedSettings_Menu() { checkkey = Menu; - if (SET_MENU(AdvancedSettings, MSG_ADVANCED_SETTINGS, 19)) { + if (SET_MENU(AdvancedSettings, MSG_ADVANCED_SETTINGS, 22)) { BACK_ITEM(Goto_Main_Menu); #if ENABLED(EEPROM_SETTINGS) MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); @@ -3115,15 +3097,18 @@ void Draw_AdvancedSettings_Menu() { 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) + #if ENABLED(PIDTEMP) && ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU) MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID " Settings", onDrawSubMenu, Draw_HotendPID_Menu); #endif #if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU) MENU_ITEM_F(ICON_MPCNozzle, "MPC Settings", onDrawSubMenu, Draw_HotendMPC_Menu); #endif - #if ENABLED(PIDTEMPBED) + #if ENABLED(PIDTEMPBED) && ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU) MENU_ITEM_F(ICON_PIDBed, STR_BED_PID " Settings", onDrawSubMenu, Draw_BedPID_Menu); #endif + #if HAS_TRINAMIC_CONFIG + MENU_ITEM(ICON_TMCSet, MSG_TMC_DRIVERS, onDrawSubMenu, Draw_TrinamicConfig_menu); + #endif #if HAS_ESDIAG MENU_ITEM_F(ICON_ESDiag, "End-stops diag.", onDrawSubMenu, Draw_EndStopDiag); #endif @@ -3140,6 +3125,12 @@ void Draw_AdvancedSettings_Menu() { #if ENABLED(POWER_LOSS_RECOVERY) EDIT_ITEM(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); #endif + #if HAS_GCODE_PREVIEW + EDIT_ITEM(ICON_File, MSG_HAS_PREVIEW, onDrawChkbMenu, SetPreview, &HMI_data.EnablePreview); + #endif + #if ENABLED(MEDIASORT_MENU_ITEM) + EDIT_ITEM(ICON_File, MSG_MEDIA_SORT, onDrawChkbMenu, SetMediaSort, &HMI_data.MediaSort); + #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); @@ -3148,7 +3139,9 @@ void Draw_AdvancedSettings_Menu() { 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); + #if HAS_CUSTOM_COLORS + MENU_ITEM(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, Draw_SelectColors_Menu); + #endif } ui.reset_status(true); UpdateMenu(AdvancedSettings); @@ -3169,7 +3162,7 @@ void Draw_Move_Menu() { EDIT_ITEM(ICON_MoveZ, MSG_MOVE_Z, onDrawMoveZ, SetMoveZ, ¤t_position.z); #endif #if HAS_HOTEND - gcode.process_subcommands_now(F("G92E0")); // reset extruder position + gcode.process_subcommands_now(F("G92E0")); // Reset extruder position EDIT_ITEM(ICON_Extruder, MSG_MOVE_E, onDrawMoveE, SetMoveE, ¤t_position.e); #endif } @@ -3196,7 +3189,7 @@ void Draw_Move_Menu() { UpdateMenu(HomeOffMenu); } -#endif +#endif // HAS_HOME_OFFSET #if HAS_BED_PROBE @@ -3226,7 +3219,7 @@ void Draw_Move_Menu() { UpdateMenu(ProbeSetMenu); } -#endif +#endif // HAS_BED_PROBE void Draw_FilSet_Menu() { checkkey = Menu; @@ -3252,46 +3245,6 @@ void Draw_FilSet_Menu() { UpdateMenu(FilSetMenu); } -void Draw_SelectColors_Menu() { - checkkey = Menu; - if (SET_MENU(SelectColorMenu, MSG_COLORS_SELECT, 20)) { - BACK_ITEM(Draw_AdvancedSettings_Menu); - 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 (SET_MENU(GetColorMenu, MSG_COLORS_GET, 5)) { - BACK_ITEM(DWIN_ApplyColor); - 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); - dwinDrawRectangle(1, *MenuData.P_Int, 20, 315, DWIN_WIDTH - 20, 335); -} - #if ALL(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) void Draw_CaseLight_Menu() { @@ -3342,7 +3295,7 @@ void Draw_GetColor_Menu() { void Draw_Tune_Menu() { checkkey = Menu; - if (SET_MENU_R(TuneMenu, selrect({73, 2, 28, 12}), MSG_TUNE, 14)) { + if (SET_MENU_R(TuneMenu, selrect({73, 2, 28, 12}), MSG_TUNE, 17)) { BACK_ITEM(Goto_PrintProcess); EDIT_ITEM(ICON_Speed, MSG_SPEED, onDrawSpeedItem, SetSpeed, &feedrate_percentage); #if HAS_HOTEND @@ -3354,7 +3307,7 @@ void Draw_Tune_Menu() { #if HAS_FAN FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif - #if ALL(HAS_ZOFFSET_ITEM, HAS_BED_PROBE, BABYSTEPPING) + #if ALL(HAS_ZOFFSET_ITEM, HAS_BED_PROBE, BABYSTEP_ZPROBE_OFFSET, 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); @@ -3366,9 +3319,18 @@ void Draw_Tune_Menu() { #if HAS_FILAMENT_SENSOR EDIT_ITEM(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); #endif + #if ENABLED(PLR_TUNE_ITEM) + EDIT_ITEM(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); + #endif #if ENABLED(FWRETRACT) MENU_ITEM(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); #endif + #if ENABLED(JD_TUNE_ITEM) + EDIT_ITEM(ICON_JDmm, MSG_JUNCTION_DEVIATION, onDrawPFloat3Menu, SetJDmm, &planner.junction_deviation_mm); + #endif + #if ENABLED(ADVK_TUNE_ITEM) + EDIT_ITEM(ICON_MaxAccelerated, MSG_ADVANCE_K, onDrawPFloat3Menu, SetLA_K, &planner.extruder_advance_K[0]); + #endif #if HAS_LOCKSCREEN MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #endif @@ -3385,30 +3347,133 @@ void Draw_Tune_Menu() { UpdateMenu(TuneMenu); } +#if ENABLED(ADAPTIVE_STEP_SMOOTHING) + void SetAdaptiveStepSmoothing() { + Toggle_Chkb_Line(HMI_data.AdaptiveStepSmoothing); + } +#endif + +#if ENABLED(SHAPING_MENU) + void ApplyShapingFreq() { stepper.set_shaping_frequency(HMI_value.axis, MenuData.Value / 100); } + void ApplyShapingZeta() { stepper.set_shaping_damping_ratio(HMI_value.axis, MenuData.Value / 100); } + + #if ENABLED(INPUT_SHAPING_X) + void onDrawShapingXFreq(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, stepper.get_shaping_frequency(X_AXIS)); } + void onDrawShapingXZeta(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, stepper.get_shaping_damping_ratio(X_AXIS)); } + void SetShapingXFreq() { HMI_value.axis = X_AXIS; SetFloatOnClick(0, 200, 2, stepper.get_shaping_frequency(X_AXIS), ApplyShapingFreq); } + void SetShapingXZeta() { HMI_value.axis = X_AXIS; SetFloatOnClick(0, 1, 2, stepper.get_shaping_damping_ratio(X_AXIS), ApplyShapingZeta); } + #endif + + #if ENABLED(INPUT_SHAPING_Y) + void onDrawShapingYFreq(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, stepper.get_shaping_frequency(Y_AXIS)); } + void onDrawShapingYZeta(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, stepper.get_shaping_damping_ratio(Y_AXIS)); } + void SetShapingYFreq() { HMI_value.axis = Y_AXIS; SetFloatOnClick(0, 200, 2, stepper.get_shaping_frequency(Y_AXIS), ApplyShapingFreq); } + void SetShapingYZeta() { HMI_value.axis = Y_AXIS; SetFloatOnClick(0, 1, 2, stepper.get_shaping_damping_ratio(Y_AXIS), ApplyShapingZeta); } + #endif + + void Draw_InputShaping_menu() { + checkkey = Menu; + if (SET_MENU(InputShapingMenu, MSG_INPUT_SHAPING, 5)) { + BACK_ITEM(Draw_Motion_Menu); + #if ENABLED(INPUT_SHAPING_X) + MENU_ITEM(ICON_ShapingX, MSG_SHAPING_A_FREQ, onDrawShapingXFreq, SetShapingXFreq); + MENU_ITEM(ICON_ShapingX, MSG_SHAPING_A_ZETA, onDrawShapingXZeta, SetShapingXZeta); + #endif + #if ENABLED(INPUT_SHAPING_Y) + MENU_ITEM(ICON_ShapingY, MSG_SHAPING_B_FREQ, onDrawShapingYFreq, SetShapingYFreq); + MENU_ITEM(ICON_ShapingY, MSG_SHAPING_B_ZETA, onDrawShapingYZeta, SetShapingYZeta); + #endif + } + UpdateMenu(InputShapingMenu); + } +#endif + +#if HAS_TRINAMIC_CONFIG + #if AXIS_IS_TMC(X) + void SetXTMCCurrent() { SetPIntOnClick(MIN_TMC_CURRENT, MAX_TMC_CURRENT, []{ stepperX.refresh_stepper_current(); }); } + #endif + #if AXIS_IS_TMC(Y) + void SetYTMCCurrent() { SetPIntOnClick(MIN_TMC_CURRENT, MAX_TMC_CURRENT, []{ stepperY.refresh_stepper_current(); }); } + #endif + #if AXIS_IS_TMC(Z) + void SetZTMCCurrent() { SetPIntOnClick(MIN_TMC_CURRENT, MAX_TMC_CURRENT, []{ stepperZ.refresh_stepper_current(); }); } + #endif + #if AXIS_IS_TMC(E0) + void SetETMCCurrent() { SetPIntOnClick(MIN_TMC_CURRENT, MAX_TMC_CURRENT, []{ stepperE0.refresh_stepper_current(); }); } + #endif + + void Draw_TrinamicConfig_menu() { + checkkey = Menu; + if (SET_MENU(TrinamicConfigMenu, MSG_TMC_DRIVERS, 5)) { + BACK_ITEM(Draw_AdvancedSettings_Menu); + #if AXIS_IS_TMC(X) + EDIT_ITEM(ICON_TMCXSet, MSG_TMC_ACURRENT, onDrawPIntMenu, SetXTMCCurrent, &stepperX.val_mA); + #endif + #if AXIS_IS_TMC(Y) + EDIT_ITEM(ICON_TMCYSet, MSG_TMC_BCURRENT, onDrawPIntMenu, SetYTMCCurrent, &stepperY.val_mA); + #endif + #if AXIS_IS_TMC(Z) + EDIT_ITEM(ICON_TMCZSet, MSG_TMC_CCURRENT, onDrawPIntMenu, SetZTMCCurrent, &stepperZ.val_mA); + #endif + #if AXIS_IS_TMC(E0) + EDIT_ITEM(ICON_TMCESet, MSG_TMC_ECURRENT, onDrawPIntMenu, SetETMCCurrent, &stepperE0.val_mA); + #endif + } + UpdateMenu(TrinamicConfigMenu); + } +#endif + void Draw_Motion_Menu() { checkkey = Menu; - if (SET_MENU_R(MotionMenu, selrect({1, 16, 28, 13}), MSG_MOTION, 6)) { + if (SET_MENU_R(MotionMenu, selrect({1, 16, 28, 13}), MSG_MOTION, 10)) { BACK_ITEM(Draw_Control_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(ICON_MaxJerk, MSG_JERK, onDrawJerk, Draw_MaxJerk_Menu); + #elif HAS_JUNCTION_DEVIATION + EDIT_ITEM(ICON_JDmm, MSG_JUNCTION_DEVIATION, onDrawPFloat3Menu, SetJDmm, &planner.junction_deviation_mm); + #endif + #if ENABLED(LIN_ADVANCE) + EDIT_ITEM(ICON_MaxAccelerated, MSG_ADVANCE_K, onDrawPFloat3Menu, SetLA_K, &planner.extruder_advance_K[0]); + #endif + #if ENABLED(SHAPING_MENU) + MENU_ITEM(ICON_InputShaping, MSG_INPUT_SHAPING, onDrawSubMenu, Draw_InputShaping_menu); + #endif + #if ENABLED(ADAPTIVE_STEP_SMOOTHING) + EDIT_ITEM(ICON_UBLActive, MSG_STEP_SMOOTHING, onDrawChkbMenu, SetAdaptiveStepSmoothing, &HMI_data.AdaptiveStepSmoothing); #endif MENU_ITEM(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, Draw_Steps_Menu); EDIT_ITEM(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + EDIT_ITEM(ICON_Speed, MSG_SPEED, onDrawPIntMenu, SetSpeed, &feedrate_percentage); } UpdateMenu(MotionMenu); } +#if HAS_PREHEAT + void Draw_PreheatHotend_Menu() { + checkkey = Menu; + if (SET_MENU(PreheatHotendMenu, MSG_PREHEAT_HOTEND, 1 + PREHEAT_COUNT)) { + BACK_ITEM(Draw_FilamentMan_Menu); + #define _ITEM_PREHEAT_HE(N) MENU_ITEM(ICON_Preheat##N, MSG_PREHEAT_##N, onDrawMenuItem, DoPreheatHotend##N); + REPEAT_1(PREHEAT_COUNT, _ITEM_PREHEAT_HE) + } + UpdateMenu(PreheatHotendMenu); + } +#endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) void Draw_FilamentMan_Menu() { checkkey = Menu; - if (SET_MENU(FilamentMenu, MSG_FILAMENT_MAN, 5)) { + if (SET_MENU(FilamentMenu, MSG_FILAMENT_MAN, 6)) { BACK_ITEM(Draw_Prepare_Menu); #if ENABLED(NOZZLE_PARK_FEATURE) MENU_ITEM(ICON_Park, MSG_FILAMENT_PARK_ENABLED, onDrawMenuItem, ParkHead); #endif + #if HAS_PREHEAT + MENU_ITEM(ICON_SetEndTemp, MSG_PREHEAT_HOTEND, onDrawSubMenu, Draw_PreheatHotend_Menu); + #endif MENU_ITEM(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) MENU_ITEM(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, UnloadFilament); @@ -3573,32 +3638,93 @@ void Draw_Steps_Menu() { UpdateMenu(StepsMenu); } -#if ENABLED(PIDTEMP) +//============================================================================= +// UI editable custom colors +//============================================================================= - void Draw_HotendPID_Menu() { - checkkey = Menu; - if (SET_MENU_F(HotendPIDMenu, STR_HOTEND_PID " Settings", 8)) { - BACK_ITEM(Draw_AdvancedSettings_Menu); - 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(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); - #endif - } - UpdateMenu(HotendPIDMenu); +#if HAS_CUSTOM_COLORS + + void RestoreDefaultColors() { + DWIN_SetColorDefaults(); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + DWIN_RedrawScreen(); } -#endif + void SelColor() { + MenuData.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; + HMI_value.Color[0] = GetRColor(*MenuData.P_Int); // Red + HMI_value.Color[1] = GetGColor(*MenuData.P_Int); // Green + HMI_value.Color[2] = GetBColor(*MenuData.P_Int); // Blue + Draw_GetColor_Menu(); + } + + void LiveRGBColor() { + HMI_value.Color[CurrentMenu->line() - 2] = MenuData.Value; + uint16_t color = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); + dwinDrawRectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); + } + void SetRGBColor() { + const uint8_t color = static_cast(CurrentMenu->SelectedItem())->icon; + SetIntOnClick(0, (color == 1) ? 63 : 31, HMI_value.Color[color], nullptr, LiveRGBColor); + } + + void DWIN_ApplyColor() { + *MenuData.P_Int = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + Draw_SelectColors_Menu(); + hash_changed = true; + LCD_MESSAGE(MSG_COLORS_APPLIED); + DWIN_Draw_Dashboard(); + } + + void Draw_SelectColors_Menu() { + checkkey = Menu; + if (SET_MENU(SelectColorMenu, MSG_COLORS_SELECT, 20)) { + BACK_ITEM(Draw_AdvancedSettings_Menu); + 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 (SET_MENU(GetColorMenu, MSG_COLORS_GET, 5)) { + BACK_ITEM(DWIN_ApplyColor); + 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); + dwinDrawRectangle(1, *MenuData.P_Int, 20, 315, DWIN_WIDTH - 20, 335); + } + +#endif // HAS_CUSTOM_COLORS + +//============================================================================= +// Nozzle and Bed PID/MPC +//============================================================================= #if ANY(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU) - #if ENABLED(MPC_AUTOTUNE_MENU) - void HotendMPC() { thermalManager.MPC_autotune(active_extruder); } - #endif #if ENABLED(MPC_EDIT_MENU) void SetHeaterPower() { SetPFloatOnClick(1, 200, 1); } void SetBlkHeatCapacity() { SetPFloatOnClick(0, 40, 2); } @@ -3617,7 +3743,7 @@ void Draw_Steps_Menu() { MPC_t &mpc = thermalManager.temp_hotend[0].mpc; BACK_ITEM(Draw_AdvancedSettings_Menu); #if ENABLED(MPC_AUTOTUNE_MENU) - MENU_ITEM(ICON_MPCNozzle, MSG_MPC_AUTOTUNE, onDrawMenuItem, HotendMPC); + MENU_ITEM(ICON_MPCNozzle, MSG_MPC_AUTOTUNE, onDrawMenuItem, []{ thermalManager.MPC_autotune(active_extruder, Temperature::MPCTuningType::AUTO); }); #endif #if ENABLED(MPC_EDIT_MENU) EDIT_ITEM(ICON_MPCHeater, MSG_MPC_POWER, onDrawPFloatMenu, SetHeaterPower, &mpc.heater_power); @@ -3634,18 +3760,97 @@ void Draw_Steps_Menu() { #endif // MPC_EDIT_MENU || MPC_AUTOTUNE_MENU -#if ENABLED(PIDTEMPBED) +#if DWIN_PID_TUNE + void SetPID(celsius_t t, heater_id_t h) { + char cmd[53] = ""; + char str_1[5] = "", str_2[5] = ""; + sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84\nM400"), + dtostrf(X_CENTER, 1, 1, str_1), + dtostrf(Y_CENTER, 1, 1, str_2) + ); + gcode.process_subcommands_now(cmd); + thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); + } + void SetPidCycles() { SetPIntOnClick(3, 50); } +#endif + +#if ALL(HAS_PID_HEATING, PID_EDIT_MENU) + + void SetKp() { SetPFloatOnClick(0, 1000, 2); } + void ApplyPIDi() { + *MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2)); + TERN_(PIDTEMP, thermalManager.updatePID()); + } + void ApplyPIDd() { + *MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2)); + TERN_(PIDTEMP, thermalManager.updatePID()); + } + void SetKi() { + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + const float value = unscalePID_i(*MenuData.P_Float); + SetFloatOnClick(0, 1000, 2, value, ApplyPIDi); + } + void SetKd() { + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + const float value = unscalePID_d(*MenuData.P_Float); + SetFloatOnClick(0, 1000, 2, value, ApplyPIDd); + } + void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } + void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast(menuitem)->value)); } + +#endif // HAS_PID_HEATING && PID_EDIT_MENU + +#if ENABLED(PIDTEMP) && ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU) + + #if ENABLED(PID_AUTOTUNE_MENU) + void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); } + void SetHotendPidT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP); } + #endif + + void Draw_HotendPID_Menu() { + checkkey = Menu; + if (SET_MENU_F(HotendPIDMenu, STR_HOTEND_PID " Settings", 8)) { + BACK_ITEM(Draw_AdvancedSettings_Menu); + #if ENABLED(PID_AUTOTUNE_MENU) + MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID, onDrawMenuItem, HotendPID); + EDIT_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); + EDIT_ITEM(ICON_PIDCycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + #endif + #if ENABLED(PID_EDIT_MENU) + 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); + #endif + #if ENABLED(EEPROM_SETTINGS) + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); + #endif + } + UpdateMenu(HotendPIDMenu); + } + +#endif // PIDTEMP && (PID_AUTOTUNE_MENU || PID_EDIT_MENU) + +#if ENABLED(PIDTEMPBED) && ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU) + + #if ENABLED(PID_AUTOTUNE_MENU) + void BedPID() { SetPID(HMI_data.BedPidT, H_BED); } + void SetBedPidT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } + #endif void Draw_BedPID_Menu() { checkkey = Menu; if (SET_MENU_F(BedPIDMenu, STR_BED_PID " Settings", 8)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - 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(PID_AUTOTUNE_MENU) + MENU_ITEM_F(ICON_PIDBed, STR_BED_PID, onDrawMenuItem,BedPID); + EDIT_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); + EDIT_ITEM(ICON_PIDCycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + #endif + #if ENABLED(PID_EDIT_MENU) + 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); + #endif #if ENABLED(EEPROM_SETTINGS) MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif @@ -3653,7 +3858,9 @@ void Draw_Steps_Menu() { UpdateMenu(BedPIDMenu); } -#endif // PIDTEMPBED +#endif // PIDTEMPBED && (PID_AUTOTUNE_MENU || PID_EDIT_MENU) + +//============================================================================= #if HAS_BED_PROBE @@ -3694,7 +3901,7 @@ void Draw_Steps_Menu() { UpdateMenu(HomingMenu); } -#endif +#endif // INDIVIDUAL_AXIS_HOMING_SUBMENU #if ENABLED(FWRETRACT) @@ -3738,8 +3945,9 @@ void Draw_Steps_Menu() { 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 ResetMesh() { bedLevelTools.mesh_reset(); LCD_MESSAGE(MSG_MESH_RESET); } + void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, bedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); } 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 @@ -3760,13 +3968,13 @@ void Draw_Steps_Menu() { void UBLMeshTilt() { NOLESS(bedlevel.storage_slot, 0); - char buf[15]; + char buf[9]; if (bedLevelTools.tilt_grid > 1) { - sprintf_P(buf, PSTR("G28O\nG29 J%i"), bedLevelTools.tilt_grid); + sprintf_P(buf, PSTR("G29J%i"), bedLevelTools.tilt_grid); gcode.process_subcommands_now(buf); } else - gcode.process_subcommands_now(F("G28O\nG29J")); + gcode.process_subcommands_now(F("G29J")); LCD_MESSAGE(MSG_UBL_MESH_TILTED); } @@ -3793,7 +4001,7 @@ void Draw_Steps_Menu() { void Draw_MeshSet_Menu() { checkkey = Menu; - if (SET_MENU(MeshMenu, MSG_MESH_LEVELING, 13)) { + if (SET_MENU(MeshMenu, MSG_MESH_LEVELING, 14)) { BACK_ITEM(Draw_AdvancedSettings_Menu); #if ENABLED(PREHEAT_BEFORE_LEVELING) EDIT_ITEM(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); @@ -3812,6 +4020,7 @@ void Draw_Steps_Menu() { MENU_ITEM(ICON_UBLSmartFill, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); #endif #if ENABLED(MESH_EDIT_MENU) + MENU_ITEM(ICON_MeshReset, MSG_MESH_RESET, onDrawMenuItem, ResetMesh); MENU_ITEM(ICON_MeshEdit, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu); #endif MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 126f8232ac..bd1e802458 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -24,8 +24,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.21.2 - * Date: 2022/12/02 + * Version: 3.25.3 + * Date: 2023/05/18 */ #include "../../../inc/MarlinConfig.h" @@ -79,7 +79,6 @@ enum processID : uint8_t { enum tempcontrol_t : uint8_t { #if DWIN_PID_TUNE - PID_DONE, PIDTEMP_START, PIDTEMPBED_START, PID_BAD_HEATER_ID, @@ -87,11 +86,11 @@ enum processID : uint8_t { PID_TUNING_TIMEOUT, #endif #if ENABLED(MPC_AUTOTUNE) - MPC_DONE, MPCTEMP_START, MPC_TEMP_ERROR, - MPC_INTERRUPTED + MPC_INTERRUPTED, #endif + AUTOTUNE_DONE }; #endif @@ -141,6 +140,7 @@ typedef struct { #endif bool FullManualTramming = false; + bool MediaSort = true; bool MediaAutoMount = ENABLED(HAS_SD_EXTENDER); #if ALL(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) uint8_t z_after_homing = DEF_Z_AFTER_HOMING; @@ -148,6 +148,8 @@ typedef struct { #if ALL(LED_CONTROL_MENU, HAS_COLOR_LEDS) LEDColor Led_Color = Def_Leds_Color; #endif + bool AdaptiveStepSmoothing = true; + bool EnablePreview = true; } HMI_data_t; extern HMI_data_t HMI_data; @@ -155,8 +157,8 @@ static constexpr size_t eeprom_data_size = sizeof(HMI_data_t); typedef struct { int8_t Color[3]; // Color components - #if DWIN_PID_TUNE - tempcontrol_t pidresult = PID_DONE; + #if ANY(DWIN_PID_TUNE, MPCTEMP) + tempcontrol_t tempcontrol = AUTOTUNE_DONE; #endif uint8_t Select = 0; // Auxiliary selector variable AxisEnum axis = X_AXIS; // Axis Select @@ -167,17 +169,13 @@ typedef struct { 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 select_flag:1; // Popup button selected bool home_flag:1; // homing in course - bool heat_flag:1; // 0: heating done 1: during heating } HMI_flag_t; extern HMI_value_t HMI_value; extern HMI_flag_t hmiFlag; extern uint8_t checkkey; -extern millis_t dwin_heat_time; // Popups #if HAS_HOTEND || HAS_HEATED_BED @@ -206,12 +204,6 @@ void AutoHome(); REPEAT_1(PREHEAT_COUNT, _DOPREHEAT) #endif void DoCoolDown(); -#if ENABLED(PIDTEMP) - void HotendPID(); -#endif -#if ENABLED(PIDTEMPBED) - void BedPID(); -#endif #if ENABLED(BAUD_RATE_GCODE) void HMI_SetBaudRate(); void SetBaud115K(); @@ -236,7 +228,7 @@ void ParkHead(); #if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION) void HostShutDown(); #endif -#if !HAS_BED_PROBE +#if DISABLED(HAS_BED_PROBE) void HomeZandDisable(); #endif @@ -252,7 +244,6 @@ 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 -void HMI_SelectFile(); // File page void HMI_Printing(); // Print page void HMI_ReturnScreen(); // Return to previous screen before popups void HMI_WaitForUser(); @@ -278,10 +269,8 @@ void DWIN_Print_Aborted(); #if HAS_FILAMENT_SENSOR void DWIN_FilamentRunout(const uint8_t extruder); #endif -void DWIN_M73(); void DWIN_Print_Header(const char *text); void DWIN_SetColorDefaults(); -void DWIN_ApplyColor(); void DWIN_CopySettingsTo(char * const buff); void DWIN_CopySettingsFrom(const char * const buff); void DWIN_SetDataDefaults(); @@ -291,7 +280,6 @@ void DWIN_RebootScreen(); void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button=0); void Draw_Popup_FilamentPurge(); void Goto_FilamentPurge(); - void HMI_FilamentPurge(); #endif // Utility and extensions @@ -331,8 +319,6 @@ void Draw_FilSet_Menu(); void Draw_ParkPos_Menu(); #endif void Draw_PhySet_Menu(); -void Draw_SelectColors_Menu(); -void Draw_GetColor_Menu(); #if ALL(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) void Draw_CaseLight_Menu(); #endif @@ -369,16 +355,36 @@ void Draw_Steps_Menu(); void Draw_EditMesh_Menu(); #endif #endif +#if HAS_TRINAMIC_CONFIG + void Draw_TrinamicConfig_menu(); +#endif + +// Custom colors editing +#if HAS_CUSTOM_COLORS + void DWIN_ApplyColor(); + void Draw_SelectColors_Menu(); + void Draw_GetColor_Menu(); +#endif // PID #if DWIN_PID_TUNE #include "../../../module/temperature.h" void DWIN_StartM303(const bool seenC, const int c, const bool seenS, const heater_id_t hid, const celsius_t temp); void DWIN_PidTuning(tempcontrol_t result); - #if ENABLED(PIDTEMP) +#endif +#if ENABLED(PIDTEMP) + #if ENABLED(PID_AUTOTUNE_MENU) + void HotendPID(); + #endif + #if ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU) void Draw_HotendPID_Menu(); #endif - #if ENABLED(PIDTEMPBED) +#endif +#if ENABLED(PIDTEMPBED) + #if ENABLED(PID_AUTOTUNE_MENU) + void BedPID(); + #endif + #if ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU) void Draw_BedPID_Menu(); #endif #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp index a82acdb3e9..180b35e2ec 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp @@ -23,8 +23,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.10.1 - * Date: 2022/03/06 + * Version: 3.12.1 + * Date: 2023/01/22 */ #include "../../../inc/MarlinConfigPre.h" @@ -134,6 +134,26 @@ void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data) } } +// Draw an Icon from SRAM without background transparency for DACAI Screens support +void DACAI_ICON_Show(uint16_t x, uint16_t y, uint16_t addr) { + NOMORE(x, DWIN_WIDTH - 1); + NOMORE(y, DWIN_HEIGHT - 1); + size_t i = 0; + dwinByte(i, 0x70); + dwinWord(i, x); + dwinWord(i, y); + dwinWord(i, addr); + dwinSend(i); +} + +void dwinIconShow(uint16_t x, uint16_t y, uint16_t addr) { + #if ENABLED(DACAI_DISPLAY) + DACAI_ICON_Show(x, y, addr); + #else + dwinIconShow(0, 0, 1, x, y, addr); + #endif +} + // Write the contents of the 32KB SRAM data memory into the designated image memory space. // picID: Picture memory space location, 0x00-0x0F, each space is 32Kbytes void DWIN_SRAMToPic(uint8_t picID) { diff --git a/Marlin/src/lcd/e3v2/proui/dwin_lcd.h b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h index 6e0a254db4..8c9c063367 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h @@ -24,8 +24,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.10.1 - * Date: 2022/03/06 + * Version: 3.12.1 + * Date: 2023/01/22 */ #include "../common/dwin_api.h" @@ -71,6 +71,11 @@ void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t // data: address of the buffer with data void DWIN_WriteToMem(uint8_t mem, uint16_t addr, uint16_t length, uint8_t *data); +// Draw an Icon from SRAM +// x/y: Upper-left point +// addr: SRAM address +void dwinIconShow(uint16_t x, uint16_t y, uint16_t addr); + // Write the contents of the 32KB SRAM data memory into the designated image memory space. // picID: Picture memory space location, 0x00-0x0F, each space is 32Kbytes void DWIN_SRAMToPic(uint8_t picID); diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index 4ed6ce6783..235b30f9fa 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -23,8 +23,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.20.1 - * Date: 2022/10/25 + * Version: 3.21.1 + * Date: 2023/03/21 */ #include "../../../inc/MarlinConfig.h" @@ -32,7 +32,6 @@ #if ENABLED(DWIN_LCD_PROUI) #include "dwin_defines.h" -#include "dwin_lcd.h" #include "dwinui.h" xy_int_t DWINUI::cursor = { 0 }; @@ -60,16 +59,18 @@ void DWINUI::setFont(fontid_t fid) { fontid = fid; } // Get font character width uint8_t DWINUI::fontWidth(fontid_t fid) { switch (fid) { - case font6x12 : return 6; + #if DISABLED(TJC_DISPLAY) + case font6x12 : return 6; + case font20x40: return 20; + case font24x48: return 24; + case font28x56: return 28; + case font32x64: return 32; + #endif case font8x16 : return 8; case font10x20: return 10; case font12x24: return 12; case font14x28: return 14; case font16x32: return 16; - case font20x40: return 20; - case font24x48: return 24; - case font28x56: return 28; - case font32x64: return 32; default: return 0; } } @@ -77,16 +78,18 @@ uint8_t DWINUI::fontWidth(fontid_t fid) { // Get font character height uint8_t DWINUI::fontHeight(fontid_t fid) { switch (fid) { + #if DISABLED(TJC_DISPLAY) case font6x12 : return 12; + case font20x40: return 40; + case font24x48: return 48; + case font28x56: return 56; + case font32x64: return 64; + #endif case font8x16 : return 16; case font10x20: return 20; case font12x24: return 24; case font14x28: return 28; case font16x32: return 32; - case font20x40: return 40; - case font24x48: return 48; - case font28x56: return 56; - case font32x64: return 64; default: return 0; } } @@ -261,15 +264,13 @@ void DWINUI::Draw_Circle(uint16_t color, uint16_t x, uint16_t y, uint8_t r) { // y: ordinate of the center of the circle // r: circle radius void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) { - int a = 0, b = 0; - while (a <= b) { - b = SQRT(sq(r) - sq(a)); // b=sqrt(r*r-a*a); - if (a == 0) b--; - dwinDrawLine(bcolor, x-b,y-a,x+b,y-a); - dwinDrawLine(bcolor, x-a,y-b,x+a,y-b); - dwinDrawLine(bcolor, x-b,y+a,x+b,y+a); - dwinDrawLine(bcolor, x-a,y+b,x+a,y+b); - a++; + dwinDrawLine(bcolor, x - r, y, x + r, y); + uint16_t b = 1; + while (b <= r) { + uint16_t a = SQRT(sq(r) - sq(b)); + dwinDrawLine(bcolor, x - a, y + b, x + a, y + b); + dwinDrawLine(bcolor, x - a, y - b, x + a, y - b); + b += TERN(TJC_DISPLAY, 2, 1); } } diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h index fd59757d64..06daece9d0 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -24,8 +24,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.18.1 - * Date: 2022/07/05 + * Version: 3.21.1 + * Date: 2023/03/21 */ #include "../../../inc/MarlinConfigPre.h" @@ -68,7 +68,8 @@ #define ICON_HomeOffsetY ICON_StepY #define ICON_HomeOffsetZ ICON_StepZ #define ICON_HSMode ICON_StockConfiguration -#define ICON_InvertE0 ICON_StepE +#define ICON_InputShaping ICON_MaxAccelerated +#define ICON_JDmm ICON_MaxJerk #define ICON_Tram ICON_SetEndTemp #define ICON_Level ICON_HotendTemp #define ICON_Lock ICON_Cool @@ -82,6 +83,7 @@ #define ICON_MeshEditZ ICON_MoveZ #define ICON_MeshNext ICON_Axis #define ICON_MeshPoints ICON_SetEndTemp +#define ICON_MeshReset ICON_StockConfiguration #define ICON_MeshSave ICON_WriteEEPROM #define ICON_MeshViewer ICON_HotendTemp #define ICON_MoveZ0 ICON_HotendTemp @@ -132,8 +134,14 @@ #define ICON_SetPreheat8 ICON_SetCustomPreheat #define ICON_SetPreheat9 ICON_SetCustomPreheat #define ICON_SetPreheat10 ICON_SetCustomPreheat +#define ICON_ShapingX ICON_MoveX +#define ICON_ShapingY ICON_MoveY #define ICON_Sound ICON_Cool -#define ICON_TBSetup ICON_Contact +#define ICON_TMCSet ICON_PrintSize +#define ICON_TMCXSet ICON_MoveX +#define ICON_TMCYSet ICON_MoveY +#define ICON_TMCZSet ICON_MoveZ +#define ICON_TMCESet ICON_Extruder #define ICON_UBLActive ICON_HotendTemp #define ICON_UBLActive ICON_HotendTemp #define ICON_UBLSlot ICON_ResumeEEPROM diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 81baa0a2de..c6d014e53c 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -23,8 +23,8 @@ /** * DWIN Endstops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.3.3 - * Date: 2022/10/07 + * Version: 1.4.3 + * Date: 2023/05/10 */ #include "../../../inc/MarlinConfigPre.h" @@ -35,10 +35,8 @@ #include "../../../core/types.h" #include "../../marlinui.h" -#include "dwin_lcd.h" -#include "dwinui.h" -#include "dwin_popup.h" #include "dwin.h" +#include "dwin_popup.h" #if HAS_FILAMENT_SENSOR #include "../../../feature/runout.h" diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.h b/Marlin/src/lcd/e3v2/proui/endstop_diag.h index 33f1d10d2d..236262282e 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.h +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.h @@ -24,14 +24,14 @@ /** * DWIN End Stops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.3.2 - * Date: 2022/10/07 + * Version: 1.4.3 + * Date: 2023/05/10 */ class ESDiagClass { public: - void Draw(); - void Update(); + static void Draw(); + static void Update(); }; extern ESDiagClass ESDiag; diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index b87ed2101f..3dddbe6f61 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: 3.1.2 - * Date: 2022/09/03 + * version: 3.3.2 + * Date: 2023/06/18 */ #include "../../../inc/MarlinConfigPre.h" @@ -35,13 +35,14 @@ #include "../../marlinui.h" #include "../../../sd/cardreader.h" #include "../../../MarlinCore.h" // for wait_for_user -#include "dwin_lcd.h" -#include "dwinui.h" #include "dwin.h" #include "dwin_popup.h" #include "base64.hpp" #include "gcode_preview.h" +#define THUMBWIDTH 230 +#define THUMBHEIGHT 180 + typedef struct { char name[13] = ""; //8.3 + null uint32_t thumbstart = 0; @@ -104,7 +105,7 @@ void Get_Value(char *buf, const char * const key, float &value) { } bool Has_Preview() { - const char * tbstart = "; thumbnail begin 230x180"; + const char * tbstart = "; thumbnail begin " STRINGIFY(THUMBWIDTH) "x" STRINGIFY(THUMBHEIGHT); char * posptr = 0; uint8_t nbyte = 1; uint32_t indx = 0; @@ -187,6 +188,8 @@ bool Has_Preview() { card.closefile(); buf64[readed] = 0; + fileprop.thumbwidth = THUMBWIDTH; + fileprop.thumbheight = THUMBHEIGHT; fileprop.thumbsize = decode_base64(buf64, fileprop.thumbdata); card.closefile(); DWINUI::WriteToSRAM(0x00, fileprop.thumbsize, fileprop.thumbdata); delete[] fileprop.thumbdata; @@ -218,7 +221,7 @@ void Preview_DrawFromSD() { } DWINUI::Draw_Button(BTN_Print, 26, 290); DWINUI::Draw_Button(BTN_Cancel, 146, 290); - dwinIconShow(0, 0, 1, 21, 90, 0x00); + Preview_Show(); Draw_Select_Highlight(true, 290); dwinUpdateLCD(); } @@ -229,15 +232,17 @@ void Preview_DrawFromSD() { } void Preview_Invalidate() { - fileprop.thumbstart = 0; -} - -bool Preview_Valid() { - return !!fileprop.thumbstart; -} - -void Preview_Reset() { fileprop.thumbsize = 0; } +bool Preview_Valid() { + return !!fileprop.thumbsize; +} + +void Preview_Show() { + const uint8_t xpos = (DWIN_WIDTH - fileprop.thumbwidth) / 2; + const uint8_t ypos = (205 - fileprop.thumbheight) / 2 + 87; + dwinIconShow(xpos, ypos, 0x00); +} + #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 2452797d0c..b90180db29 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -31,4 +31,4 @@ void Preview_DrawFromSD(); void Preview_Invalidate(); bool Preview_Valid(); -void Preview_Reset(); +void Preview_Show(); diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp index 870a4248ce..54892b6acb 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.9.1 - * Date: 2022/12/02 + * Version: 1.10.1 + * Date: 2022/05/01 */ #include "../../../inc/MarlinConfigPre.h" @@ -32,8 +32,6 @@ #if ENABLED(DWIN_LCD_PROUI) #include "../common/encoder.h" -#include "dwin_lcd.h" -#include "dwinui.h" #include "dwin.h" #include "menus.h" @@ -58,11 +56,6 @@ void Draw_Title(TitleClass* title) { #endif } -void Draw_Menu(MenuClass* menu) { - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); - dwinDrawRectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); -} - 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}); @@ -79,7 +72,7 @@ void Erase_Menu_Text(const int8_t line) { 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*/) { +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); @@ -87,7 +80,7 @@ void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * dwinDrawHLine(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*/) { +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); } @@ -106,7 +99,7 @@ void Toggle_Chkb_Line(bool &checked) { Show_Chkb_Line(checked); } -void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value /*=0*/) { +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); } @@ -189,7 +182,7 @@ void DrawItemEdit(const bool selected) { // val: value / scaled value // LiveUpdate: live update function when the encoder changes // Apply: update function when the encoder is pressed -void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { +void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) { checkkey = process; MenuData.MinValue = lo; MenuData.MaxValue = hi; @@ -207,7 +200,7 @@ void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, // val: value // LiveUpdate: live update function when the encoder changes // 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*/) { +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); DrawItemEdit(true); } @@ -219,7 +212,7 @@ void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const // val: value // LiveUpdate: live update function when the encoder changes // Apply: update function when the encoder is pressed -void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { +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); DrawItemEdit(true); @@ -231,7 +224,7 @@ void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp // val: value // LiveUpdate: live update function when the encoder changes // Apply: update function when the encoder is pressed -void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { +void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) { SetValueOnClick(SetInt, lo, hi, val, Apply, LiveUpdate); } @@ -240,7 +233,7 @@ void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void ( // hi: high limit // LiveUpdate: live update function when the encoder changes // Apply: update function when the encoder is pressed -void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { +void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) { MenuData.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; const int32_t value = *MenuData.P_Int; SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate); @@ -252,7 +245,7 @@ void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() /*= null // hi: high limit // dp: decimal places // val: value -void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { +void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) { SetValueOnClick(SetFloat, lo, hi, dp, val, Apply, LiveUpdate); } @@ -261,7 +254,7 @@ void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val // hi: high limit // LiveUpdate: live update function when the encoder changes // Apply: update function when the encoder is pressed -void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { +void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)()/*=nullptr*/, void (*LiveUpdate)()/*=nullptr*/) { MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; SetValueOnClick(SetPFloat, lo, hi, dp, *MenuData.P_Float, Apply, LiveUpdate); } @@ -290,7 +283,7 @@ 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 = get_encoder_state(); + EncoderState encoder_diffState = TERN(SMOOTH_ENCODER_MENUITEMS, get_encoder_state(), encoderReceiveAnalyze()); if (encoder_diffState != ENCODER_DIFF_NO) { if (applyEncoder(encoder_diffState, MenuData.Value)) { encoderRate.enabled = false; @@ -354,7 +347,8 @@ MenuClass::MenuClass() { void MenuClass::draw() { MenuTitle.draw(); - Draw_Menu(this); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + dwinDrawRectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); for (int8_t i = 0; i < MenuItemCount; i++) MenuItems[i]->draw(i - topline); Draw_Menu_Cursor(line()); @@ -407,7 +401,7 @@ void CustomMenuItemClass::draw(int8_t line) { if (onDraw != nullptr) (*onDraw)(static_cast(this), line); }; -void CustomMenuItemClass::redraw(bool erase /*=false*/) { +void CustomMenuItemClass::redraw(bool erase/*=false*/) { const int8_t line = CurrentMenu->line(this->pos); if (erase) Erase_Menu_Text(line); draw(line); @@ -507,8 +501,8 @@ MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem on } void InitMenu() { + CurrentMenu = nullptr; PreviousMenu = nullptr; - InvalidateMenu(); } bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) { @@ -534,14 +528,18 @@ bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems) return NotCurrent; } -void InvalidateMenu() { - if (CurrentMenu) { - CurrentMenu->topline = 0; - CurrentMenu->selected = 0; - CurrentMenu = nullptr; +void ResetMenu(MenuClass* &menu) { + if (menu) { + menu->topline = 0; + menu->selected = 0; } } +void InvalidateMenu() { + ResetMenu(CurrentMenu); + CurrentMenu = nullptr; +} + void UpdateMenu(MenuClass* &menu) { if (!menu) return; if (CurrentMenu != menu) { @@ -551,9 +549,13 @@ void UpdateMenu(MenuClass* &menu) { menu->draw(); } -void ReDrawMenu(bool force /*= false*/) { - if (CurrentMenu && (force || checkkey==Menu)) CurrentMenu->draw(); +void ReDrawMenu(bool force/*=false*/) { + if (CurrentMenu && (force || checkkey == Menu)) CurrentMenu->draw(); if (force) DrawItemEdit(true); } +void ReDrawItem() { + static_cast(CurrentMenu->SelectedItem())->redraw(false); +} + #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h index 072bf7584d..f0855e7073 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.h +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -24,14 +24,17 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.9.1 - * Date: 2022/12/02 + * Version: 1.10.1 + * Date: 2022/05/01 */ #include "dwinui.h" #define MENU_CHAR_LIMIT 24 -#define MENU_MAX_ITEMS TERN(SDSORT_LIMIT, SDSORT_LIMIT, 64) + +#ifndef MENU_MAX_ITEMS + #define MENU_MAX_ITEMS 100 +#endif typedef struct { int32_t MaxValue = 0; // Auxiliar max integer/scaled float value @@ -123,7 +126,6 @@ extern MenuClass *PreviousMenu; // Menuitem Drawing functions ================================================= 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 Erase_Menu_Text(const int8_t line); @@ -150,13 +152,13 @@ void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line); // On click functions ========================================================= -void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); -void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); -void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); -void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); -void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); -void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); -void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr); +void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr); +void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr); +void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr); +void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr); +void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr); +void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)()=nullptr, void (*LiveUpdate)()=nullptr); // HMI user control functions ================================================= @@ -175,6 +177,9 @@ void InitMenu(); bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems); bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems); +// Reset top line and selected item +void ResetMenu(MenuClass* &menu); + // Invalidate CurrentMenu to prepare for full menu drawing void InvalidateMenu(); @@ -182,7 +187,10 @@ void InvalidateMenu(); void UpdateMenu(MenuClass* &menu); //Redraw the current Menu if it is valid -void ReDrawMenu(bool force = false); +void ReDrawMenu(bool force=false); + +//Redraw selected menu item +void ReDrawItem(); // Clear MenuItems array and free MenuItems elements void MenuItemsClear(); @@ -196,7 +204,7 @@ bool IsMenu(MenuClass* menu); // Add elements to the MenuItems array 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) { +inline MenuItemClass* MenuItemAdd(uint8_t cicon, FSTR_P text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr) { return MenuItemAdd(cicon, FTOP(text), ondraw, onclick); } 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); diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index 1f42004d3f..086795d943 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -23,8 +23,8 @@ /** * Mesh Viewer for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * version: 3.14.1 - * Date: 2022/04/11 + * version: 4.2.1 + * Date: 2023/05/05 */ #include "../../../inc/MarlinConfigPre.h" @@ -33,90 +33,99 @@ #include "../../../core/types.h" #include "../../marlinui.h" -#include "dwin_lcd.h" -#include "dwinui.h" #include "dwin.h" #include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" #include "meshviewer.h" -#if ENABLED(USE_UBL_VIEWER) +#if ENABLED(USE_GRID_MESHVIEWER) #include "bedlevel_tools.h" #endif +bool meshredraw; // Redraw mesh points +uint8_t sizex, sizey; // Mesh XY size +uint8_t rmax; // Maximum radius +#define margin 25 // XY Margins +#define rmin 5 // Minimum radius +#define zmin -20 // rmin at z=-0.20 +#define zmax 20 // rmax at z= 0.20 +#define width DWIN_WIDTH - 2 * margin +#define r(z) ((z - zmin) * (rmax - rmin) / (zmax - zmin) + rmin) +#define px(xp) (margin + (xp) * (width) / (sizex - 1)) +#define py(yp) (30 + DWIN_WIDTH - margin - (yp) * (width) / (sizey - 1)) + +constexpr uint8_t meshfont = TERN(TJC_DISPLAY, font8x16, font6x12); + MeshViewerClass MeshViewer; -void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8_t sizey) { - const int8_t mx = 25, my = 25; // Margins - const int16_t stx = (DWIN_WIDTH - 2 * mx) / (sizex - 1), // Steps - sty = (DWIN_WIDTH - 2 * my) / (sizey - 1); - const int8_t rmax = _MIN(mx - 2, stx / 2); - const int8_t rmin = 7; - int16_t zmesh[sizex][sizey]; - #define px(xp) (mx + (xp) * stx) - #define py(yp) (30 + DWIN_WIDTH - my - (yp) * sty) - #define rm(z) ((z - minz) * (rmax - rmin) / _MAX(1, (maxz - minz)) + rmin) - #define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 18, py(yp) - 6, zv) - #define DrawMeshHLine(yp) dwinDrawHLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx) - #define DrawMeshVLine(xp) dwinDrawVLine(HMI_data.SplitLine_Color, px(xp), py(sizey - 1), DWIN_WIDTH - 2 * my) - int16_t maxz =-32000; int16_t minz = 32000; - for (uint8_t y = 0; y < sizey; ++y) for (uint8_t x = 0; x < sizex; ++x) { - const float v = isnan(zval[x][y]) ? 0 : round(zval[x][y] * 100); - zmesh[x][y] = v; - NOLESS(maxz, v); - NOMORE(minz, v); - } - max = (float)maxz / 100; - min = (float)minz / 100; +float MeshViewerClass::max, MeshViewerClass::min; + +void MeshViewerClass::DrawMeshGrid(const uint8_t csizex, const uint8_t csizey) { + sizex = csizex; + sizey = csizey; + rmax = _MIN(margin - 2, 0.5 * (width) / (sizex - 1)); + min = 100; + max = -100; DWINUI::ClearMainArea(); dwinDrawRectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(sizex - 1), py(sizey - 1)); - for (uint8_t x = 1; x < sizex - 1; ++x) DrawMeshVLine(x); - for (uint8_t y = 1; y < sizey - 1; ++y) DrawMeshHLine(y); - for (uint8_t y = 0; y < sizey; ++y) { - hal.watchdog_refresh(); - for (uint8_t x = 0; x < sizex; ++x) { - uint16_t color = DWINUI::RainbowInt(zmesh[x][y], _MIN(-5, minz), _MAX(5, maxz)); - uint8_t radius = rm(zmesh[x][y]); - DWINUI::Draw_FillCircle(color, px(x), py(y), radius); - if (sizex < 9) { - if (zmesh[x][y] == 0) DWINUI::Draw_Float(font6x12, 1, 2, px(x) - 12, py(y) - 6, 0); - else DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 18, py(y) - 6, zval[x][y]); - } - else { - char str_1[9]; - str_1[0] = 0; - switch (zmesh[x][y]) { - case -999 ... -100: - DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 18, py(y) - 6, zval[x][y]); - break; - case -99 ... -1: - sprintf_P(str_1, PSTR("-.%02i"), -zmesh[x][y]); - break; - case 0: - dwinDrawString(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, py(y) - 6, "0"); - break; - case 1 ... 99: - sprintf_P(str_1, PSTR(".%02i"), zmesh[x][y]); - break; - case 100 ... 999: - DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 18, py(y) - 6, zval[x][y]); - break; - } - if (str_1[0]) - dwinDrawString(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 12, py(y) - 6, str_1); - } + for (uint8_t x = 1; x < sizex - 1; ++x) dwinDrawVLine(HMI_data.SplitLine_Color, px(x), py(sizey - 1), width); + for (uint8_t y = 1; y < sizey - 1; ++y) dwinDrawHLine(HMI_data.SplitLine_Color, px(0), py(y), width); +} + +void MeshViewerClass::DrawMeshPoint(const uint8_t x, const uint8_t y, const float z) { + const uint8_t fs = DWINUI::fontWidth(meshfont); + const int16_t v = isnan(z) ? 0 : round(z * 100); + NOLESS(max, z); + NOMORE(min, z); + const uint16_t color = DWINUI::RainbowInt(v, zmin, zmax); + DWINUI::Draw_FillCircle(color, px(x), py(y), r(_MAX(_MIN(v,zmax),zmin))); + TERN_(TJC_DISPLAY, delay(100)); + if (sizex < (ENABLED(TJC_DISPLAY) ? 8 : 9)) { + if (v == 0) DWINUI::Draw_Float(meshfont, 1, 2, px(x) - 2*fs, py(y) - fs, 0); + else DWINUI::Draw_Signed_Float(meshfont, 1, 2, px(x) - 3*fs, py(y) - fs, z); + } + else { + char str_1[9]; + str_1[0] = '\0'; + switch (v) { + case -999 ... -100: + DWINUI::Draw_Signed_Float(meshfont, 1, 1, px(x) - 3*fs, py(y) - fs, z); + break; + case -99 ... -1: + sprintf_P(str_1, PSTR("-.%02i"), -v); + break; + case 0: + dwinDrawString(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, py(y) - fs, "0"); + break; + case 1 ... 99: + sprintf_P(str_1, PSTR(".%02i"), v); + break; + case 100 ... 999: + DWINUI::Draw_Signed_Float(meshfont, 1, 1, px(x) - 3 * fs, py(y) - fs, z); + break; } + if (str_1[0]) + dwinDrawString(false, meshfont, DWINUI::textcolor, DWINUI::backcolor, px(x) - 2 * fs, py(y) - fs, str_1); } } -void MeshViewerClass::Draw(bool withsave /*= false*/) { +void MeshViewerClass::DrawMesh(const bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey) { + DrawMeshGrid(csizex, csizey); + for (uint8_t y = 0; y < csizey; ++y) { + hal.watchdog_refresh(); + for (uint8_t x = 0; x < csizex; ++x) DrawMeshPoint(x, y, zval[x][y]); + } +} + +void MeshViewerClass::Draw(const bool withsave/*=false*/, const bool redraw/*=true*/) { Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER)); - #if USE_UBL_VIEWER + #if ENABLED(USE_GRID_MESHVIEWER) DWINUI::ClearMainArea(); 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); + if (redraw) DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); + else DWINUI::Draw_Box(1, HMI_data.Background_Color, { 89, 305, 99, 38 }); #endif if (withsave) { DWINUI::Draw_Button(BTN_Save, 26, 305); @@ -126,19 +135,22 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) { else DWINUI::Draw_Button(BTN_Continue, 86, 305); - #if USE_UBL_VIEWER + #if ENABLED(USE_GRID_MESHVIEWER) bedLevelTools.Set_Mesh_Viewer_Status(); #else char str_1[6], str_2[6] = ""; - ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), - dtostrf(min, 1, 2, str_1), - dtostrf(max, 1, 2, str_2) - ); + ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), dtostrf(min, 1, 2, str_1), dtostrf(max, 1, 2, str_2)); #endif } -void Draw_MeshViewer() { MeshViewer.Draw(true); } +void Draw_MeshViewer() { MeshViewer.Draw(true, meshredraw); } + void onClick_MeshViewer() { if (hmiFlag.select_flag) SaveMesh(); HMI_ReturnScreen(); } -void Goto_MeshViewer() { if (leveling_is_valid()) Goto_Popup(Draw_MeshViewer, onClick_MeshViewer); else HMI_ReturnScreen(); } + +void Goto_MeshViewer(const bool redraw) { + meshredraw = redraw; + if (leveling_is_valid()) Goto_Popup(Draw_MeshViewer, onClick_MeshViewer); + else HMI_ReturnScreen(); +} #endif // DWIN_LCD_PROUI && HAS_MESH diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.h b/Marlin/src/lcd/e3v2/proui/meshviewer.h index 3aafe16984..1f45a83480 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.h +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -24,17 +24,19 @@ /** * Mesh Viewer for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * version: 3.14.1 - * Date: 2022/04/11 + * version: 4.2.1 + * Date: 2023/05/05 */ class MeshViewerClass { public: - float max, min; - void Draw(bool withsave = false); - void DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8_t sizey); + static float max, min; + static void DrawMeshGrid(const uint8_t csizex, const uint8_t csizey); + static void DrawMeshPoint(const uint8_t x, const uint8_t y, const float z); + static void Draw(const bool withsave=false, const bool redraw=true); + static void DrawMesh(const bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey); }; extern MeshViewerClass MeshViewer; -void Goto_MeshViewer(); +void Goto_MeshViewer(const bool redraw); diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp index 94f0dc055e..45341ae624 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.cpp +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -23,20 +23,18 @@ /** * DWIN Single var plot * Author: Miguel A. Risco-Castillo - * Version: 2.1.2 - * Date: 2022/11/20 + * Version: 2.2.3 + * Date: 2023/01/29 */ #include "../../../inc/MarlinConfig.h" #if ALL(DWIN_LCD_PROUI, SHOW_TUNING_GRAPH) -#include "plot.h" +#include "dwin.h" #include "../../../core/types.h" #include "../../marlinui.h" -#include "dwin_lcd.h" -#include "dwinui.h" -#include "dwin.h" +#include "plot.h" #define Plot_Bg_Color RGB( 1, 12, 8) @@ -46,7 +44,7 @@ uint16_t grphpoints, r, x2, y2 = 0; frame_rect_t grphframe = {0}; float scale = 0; -void PlotClass::Draw(const frame_rect_t &frame, const celsius_t max, const_float_t ref/*=0*/) { +void PlotClass::Draw(const frame_rect_t &frame, const_float_t max, const_float_t ref/*=0*/) { grphframe = frame; grphpoints = 0; scale = frame.h / max; diff --git a/Marlin/src/lcd/e3v2/proui/plot.h b/Marlin/src/lcd/e3v2/proui/plot.h index 14e7058b01..144ba0073b 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.h +++ b/Marlin/src/lcd/e3v2/proui/plot.h @@ -24,15 +24,15 @@ /** * DWIN Single var plot * Author: Miguel A. Risco-Castillo - * Version: 2.1.2 - * Date: 2022/11/20 + * Version: 2.2.3 + * Date: 2023/01/29 */ #include "dwinui.h" class PlotClass { public: - static void Draw(const frame_rect_t &frame, const celsius_t max, const_float_t ref=0); + static void Draw(const frame_rect_t &frame, const_float_t max, const_float_t ref=0); static void Update(const_float_t value); }; diff --git a/Marlin/src/lcd/e3v2/proui/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp index b99916dce1..093040ebf4 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.cpp +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -23,7 +23,7 @@ /** * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.4.2 + * Version: 1.4.0 * Date: 2022/12/03 */ @@ -37,10 +37,8 @@ #include "../../../MarlinCore.h" #include "../../marlinui.h" #include "../../../module/printcounter.h" -#include "dwin_lcd.h" -#include "dwinui.h" -#include "dwin_popup.h" #include "dwin.h" +#include "dwin_popup.h" PrintStatsClass PrintStats; diff --git a/Marlin/src/lcd/e3v2/proui/printstats.h b/Marlin/src/lcd/e3v2/proui/printstats.h index 4a38306886..aadb3e8dce 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.h +++ b/Marlin/src/lcd/e3v2/proui/printstats.h @@ -24,7 +24,7 @@ /** * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.4.2 + * Version: 1.4.0 * Date: 2022/12/03 */ diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 3f17ca1453..c78942bff6 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -68,12 +68,12 @@ namespace Language_de { LSTR MSG_FILAMENT_SET = _UxGT("Fila. Einstellungen"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); LSTR MSG_MANUAL_LEVELING = _UxGT("Manuell Nivellierung"); - LSTR MSG_LEVBED_FL = _UxGT("Vorne Links"); - LSTR MSG_LEVBED_FR = _UxGT("Vorne Rechts"); - LSTR MSG_LEVBED_C = _UxGT("Mitte"); - LSTR MSG_LEVBED_BL = _UxGT("Hinten Links"); - LSTR MSG_LEVBED_BR = _UxGT("Hinten Rechts"); - LSTR MSG_MANUAL_MESH = _UxGT("manuelles Netz"); + LSTR MSG_TRAM_FL = _UxGT("Vorne Links"); + LSTR MSG_TRAM_FR = _UxGT("Vorne Rechts"); + LSTR MSG_TRAM_C = _UxGT("Mitte"); + LSTR MSG_TRAM_BL = _UxGT("Hinten Links"); + LSTR MSG_TRAM_BR = _UxGT("Hinten Rechts"); + LSTR MSG_MANUAL_MESH = _UxGT("Manuelles Netz"); LSTR MSG_AUTO_MESH = _UxGT("Netz auto. erstellen"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Z-Achsen ausgleichen"); LSTR MSG_ITERATION = _UxGT("G34 Iteration: %i"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 1876b26038..c171338f19 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -64,6 +64,8 @@ namespace Language_en { LSTR MSG_MEDIA_READ_ERROR = MEDIA_TYPE_EN _UxGT(" read error"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB device removed"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("USB start failed"); + LSTR MSG_MEDIA_SORT = _UxGT("Sort ") MEDIA_TYPE_EN; + LSTR MSG_MEDIA_UPDATE = MEDIA_TYPE_EN _UxGT(" Update"); LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Subcall Overflow"); LSTR MSG_LCD_ENDSTOPS = _UxGT("Endstops"); // Max length 8 characters LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Soft Endstops"); @@ -86,11 +88,11 @@ namespace Language_en { LSTR MSG_FILAMENT_SET = _UxGT("Filament Settings"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); LSTR MSG_MANUAL_LEVELING = _UxGT("Manual Leveling"); - LSTR MSG_LEVBED_FL = _UxGT("Front Left"); - LSTR MSG_LEVBED_FR = _UxGT("Front Right"); - LSTR MSG_LEVBED_C = _UxGT("Center"); - LSTR MSG_LEVBED_BL = _UxGT("Back Left"); - LSTR MSG_LEVBED_BR = _UxGT("Back Right"); + LSTR MSG_TRAM_FL = _UxGT("Front Left"); + LSTR MSG_TRAM_FR = _UxGT("Front Right"); + LSTR MSG_TRAM_C = _UxGT("Center"); + LSTR MSG_TRAM_BL = _UxGT("Back Left"); + LSTR MSG_TRAM_BR = _UxGT("Back Right"); LSTR MSG_MANUAL_MESH = _UxGT("Manual Mesh"); LSTR MSG_AUTO_MESH = _UxGT("Auto Build Mesh"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-Align"); @@ -187,6 +189,7 @@ namespace Language_en { LSTR MSG_MESH_CENTER = _UxGT("Center Area"); LSTR MSG_MESH_EDIT_Z = _UxGT("Z Value"); LSTR MSG_MESH_CANCEL = _UxGT("Mesh cancelled"); + LSTR MSG_MESH_RESET = _UxGT("Mesh reset"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Custom Commands"); LSTR MSG_M48_TEST = _UxGT("M48 Probe Test"); LSTR MSG_M48_POINT = _UxGT("M48 Point"); @@ -364,7 +367,7 @@ namespace Language_en { LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autotune *"); LSTR MSG_PID_CYCLE = _UxGT("PID Cycles"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID tuning done"); - LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("PID Autotune failed!"); + LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("Autotune failed!"); LSTR MSG_BAD_HEATER_ID = _UxGT("Bad extruder."); LSTR MSG_TEMP_TOO_HIGH = _UxGT("Temperature too high."); LSTR MSG_TIMEOUT = _UxGT("Timeout."); @@ -395,6 +398,7 @@ namespace Language_en { LSTR MSG_VN_JERK = _UxGT("Max @ Jerk"); LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); + LSTR MSG_STEP_SMOOTHING = _UxGT("Step Smoothing"); LSTR MSG_MAX_SPEED = _UxGT("Max Speed (mm/s)"); LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Speed"); LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Speed"); @@ -418,6 +422,12 @@ namespace Language_en { LSTR MSG_SHAPING_DISABLE = _UxGT("Disable @ shaping"); LSTR MSG_SHAPING_FREQ = _UxGT("@ frequency"); LSTR MSG_SHAPING_ZETA = _UxGT("@ damping"); + LSTR MSG_SHAPING_A_FREQ = STR_A _UxGT(" frequency"); + LSTR MSG_SHAPING_B_FREQ = STR_B _UxGT(" frequency"); + LSTR MSG_SHAPING_A_ZETA = STR_A _UxGT(" damping "); + LSTR MSG_SHAPING_B_ZETA = STR_B _UxGT(" damping "); + LSTR MSG_SHAPING_X_ENABLE = _UxGT("Enable X shaping"); + LSTR MSG_SHAPING_Y_ENABLE = _UxGT("Enable Y shaping"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("XY Freq Limit"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min FR Factor"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); @@ -460,7 +470,7 @@ namespace Language_en { LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Err: EEPROM Version"); LSTR MSG_ERR_EEPROM_CORRUPT = _UxGT("Err: EEPROM Corrupt"); LSTR MSG_SETTINGS_STORED = _UxGT("Settings Stored"); - LSTR MSG_MEDIA_UPDATE = MEDIA_TYPE_EN _UxGT(" Update"); + LSTR MSG_HAS_PREVIEW = _UxGT("Has preview"); LSTR MSG_RESET_PRINTER = _UxGT("Reset Printer"); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Refresh"); LSTR MSG_INFO_SCREEN = _UxGT("Info Screen"); @@ -507,7 +517,7 @@ namespace Language_en { LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Object"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Object {"); LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Print Job"); - LSTR MSG_MEDIA_MENU = _UxGT("Print from ") MEDIA_TYPE_EN; + LSTR MSG_MEDIA_MENU = _UxGT("Select from ") MEDIA_TYPE_EN; LSTR MSG_TURN_OFF = _UxGT("Turn off the printer"); LSTR MSG_END_LOOPS = _UxGT("End Repeat Loops"); #else @@ -826,6 +836,10 @@ namespace Language_en { #endif LSTR MSG_TMC_DRIVERS = _UxGT("TMC Drivers"); LSTR MSG_TMC_CURRENT = _UxGT("Driver Current"); + LSTR MSG_TMC_ACURRENT = STR_A _UxGT("Driver Current"); + LSTR MSG_TMC_BCURRENT = STR_B _UxGT("Driver Current"); + LSTR MSG_TMC_CCURRENT = STR_C _UxGT("Driver Current"); + LSTR MSG_TMC_ECURRENT = _UxGT("E Driver Current"); LSTR MSG_TMC_HYBRID_THRS = _UxGT("Hybrid Threshold"); LSTR MSG_TMC_HOMING_THRS = _UxGT("Sensorless Homing"); LSTR MSG_TMC_STEPPING_MODE = _UxGT("Stepping Mode"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 55f1ac3b48..054a71d6c0 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -81,11 +81,11 @@ namespace Language_it { LSTR MSG_FILAMENT_SET = _UxGT("Impostaz.filamento"); LSTR MSG_FILAMENT_MAN = _UxGT("Gestione filamento"); LSTR MSG_MANUAL_LEVELING = _UxGT("Livel.manuale"); - LSTR MSG_LEVBED_FL = _UxGT("Davanti Sinistra"); - LSTR MSG_LEVBED_FR = _UxGT("Davanti Destra"); - LSTR MSG_LEVBED_C = _UxGT("Centro"); - LSTR MSG_LEVBED_BL = _UxGT("Dietro Sinistra"); - LSTR MSG_LEVBED_BR = _UxGT("Dietro Destra"); + LSTR MSG_TRAM_FL = _UxGT("Davanti Sinistra"); + LSTR MSG_TRAM_FR = _UxGT("Davanti Destra"); + LSTR MSG_TRAM_C = _UxGT("Centro"); + LSTR MSG_TRAM_BL = _UxGT("Dietro Sinistra"); + LSTR MSG_TRAM_BR = _UxGT("Dietro Destra"); LSTR MSG_MANUAL_MESH = _UxGT("Mesh Manuale"); LSTR MSG_AUTO_MESH = _UxGT("Generaz.Autom.Mesh"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Allineam.automat. Z"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index a8db7852cc..7e00467fa1 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -894,11 +894,11 @@ namespace Language_ru { LSTR MSG_FILAMENT_MAN = _UxGT("Управл.филаментом"); #endif LSTR MSG_MANUAL_LEVELING = _UxGT("Ручное выравнивание"); - LSTR MSG_LEVBED_FL = _UxGT("Передний левый"); - LSTR MSG_LEVBED_FR = _UxGT("Передний правый"); - LSTR MSG_LEVBED_C = _UxGT("Центр"); - LSTR MSG_LEVBED_BL = _UxGT("Задний левый"); - LSTR MSG_LEVBED_BR = _UxGT("Задний правый"); + LSTR MSG_TRAM_FL = _UxGT("Передний левый"); + LSTR MSG_TRAM_FR = _UxGT("Передний правый"); + LSTR MSG_TRAM_C = _UxGT("Центр"); + LSTR MSG_TRAM_BL = _UxGT("Задний левый"); + LSTR MSG_TRAM_BR = _UxGT("Задний правый"); LSTR MSG_MANUAL_MESH = _UxGT("Сетка вручную"); LSTR MSG_AUTO_MESH = _UxGT("Сетка автоматически"); LSTR MSG_ERR_M428_TOO_FAR = _UxGT("Ошибка: слишком далеко!"); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index cea40d2406..5499a24942 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -82,11 +82,11 @@ namespace Language_sk { LSTR MSG_FILAMENT_SET = _UxGT("Nastav. filamentu"); LSTR MSG_FILAMENT_MAN = _UxGT("Správa filamentu"); LSTR MSG_MANUAL_LEVELING = _UxGT("Ručné rovnanie"); - LSTR MSG_LEVBED_FL = _UxGT("Ľavý predný"); - LSTR MSG_LEVBED_FR = _UxGT("Pravý predný"); - LSTR MSG_LEVBED_C = _UxGT("Stred"); - LSTR MSG_LEVBED_BL = _UxGT("Ľavý zadný"); - LSTR MSG_LEVBED_BR = _UxGT("Pravý zadný"); + LSTR MSG_TRAM_FL = _UxGT("Ľavý predný"); + LSTR MSG_TRAM_FR = _UxGT("Pravý predný"); + LSTR MSG_TRAM_C = _UxGT("Stred"); + LSTR MSG_TRAM_BL = _UxGT("Ľavý zadný"); + LSTR MSG_TRAM_BR = _UxGT("Pravý zadný"); LSTR MSG_MANUAL_MESH = _UxGT("Ručná mriežka"); LSTR MSG_AUTO_MESH = _UxGT("Automat. mriežka"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Auto-zarovn. Z"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index 63c4185447..667db7b77a 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -71,11 +71,11 @@ namespace Language_tr { LSTR MSG_FILAMENT_SET = _UxGT("Filament Ayarları"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Yönetimi"); LSTR MSG_MANUAL_LEVELING = _UxGT("Manuel Seviyeleme"); - LSTR MSG_LEVBED_FL = _UxGT("Sol Ön"); - LSTR MSG_LEVBED_FR = _UxGT("Ön Sağ"); - LSTR MSG_LEVBED_C = _UxGT("Orta"); - LSTR MSG_LEVBED_BL = _UxGT("Arka Sol"); - LSTR MSG_LEVBED_BR = _UxGT("Arka Sağ"); + LSTR MSG_TRAM_FL = _UxGT("Sol Ön"); + LSTR MSG_TRAM_FR = _UxGT("Ön Sağ"); + LSTR MSG_TRAM_C = _UxGT("Orta"); + LSTR MSG_TRAM_BL = _UxGT("Arka Sol"); + LSTR MSG_TRAM_BR = _UxGT("Arka Sağ"); LSTR MSG_MANUAL_MESH = _UxGT("Manuel Mesh"); LSTR MSG_AUTO_MESH = _UxGT("Oto Mesh Oluştur"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Oto. Z-Hizalama"); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index c2915eb418..50b8323838 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2633,10 +2633,12 @@ hal_timer_t Stepper::block_phase_isr() { oversampling_factor = 0; // Assume no axis smoothing (via oversampling) // Decide if axis smoothing is possible uint32_t max_rate = current_block->nominal_rate; // Get the step event rate - while (max_rate < MIN_STEP_ISR_FREQUENCY) { // As long as more ISRs are possible... - max_rate <<= 1; // Try to double the rate - if (max_rate < MIN_STEP_ISR_FREQUENCY) // Don't exceed the estimated ISR limit - ++oversampling_factor; // Increase the oversampling (used for left-shift) + if (TERN1(DWIN_LCD_PROUI, HMI_data.AdaptiveStepSmoothing)) { + while (max_rate < MIN_STEP_ISR_FREQUENCY) { // As long as more ISRs are possible... + max_rate <<= 1; // Try to double the rate + if (max_rate < MIN_STEP_ISR_FREQUENCY) // Don't exceed the estimated ISR limit + ++oversampling_factor; // Increase the oversampling (used for left-shift) + } } #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a1bebca4a0..11788c3cb1 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -910,7 +910,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); - TERN_(DWIN_PID_TUNE, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_PID_TUNE, DWIN_PidTuning(AUTOTUNE_DONE)); goto EXIT_M303; } @@ -928,7 +928,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); - TERN_(DWIN_PID_TUNE, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_PID_TUNE, DWIN_PidTuning(AUTOTUNE_DONE)); EXIT_M303: TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = true); @@ -1305,7 +1305,7 @@ volatile bool Temperature::raw_temps_ready = false; } SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_FINISHED); - TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_DONE)); + TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(AUTOTUNE_DONE)); SERIAL_ECHOLNPGM("MPC_BLOCK_HEAT_CAPACITY ", mpc.block_heat_capacity); SERIAL_ECHOLNPGM("MPC_SENSOR_RESPONSIVENESS ", p_float_t(mpc.sensor_responsiveness, 4)); @@ -4391,7 +4391,7 @@ void Temperature::isr() { // If wait_for_heatup is set, temperature was reached, no cancel if (wait_for_heatup) { wait_for_heatup = false; - #if HAS_DWIN_E3V2_BASIC + #if ENABLED(DWIN_CREALITY_LCD) hmiFlag.heat_flag = 0; duration_t elapsed = print_job_timer.duration(); // Print timer dwin_heat_time = elapsed.value;