From 6af5cb295c2ddd8ffcf3a07bfc920106f3f62c20 Mon Sep 17 00:00:00 2001 From: GHGiampy <83699429+GHGiampy@users.noreply.github.com> Date: Sat, 5 Feb 2022 17:23:44 +0100 Subject: [PATCH 001/203] =?UTF-8?q?=F0=9F=94=A8=20Clean=20up=20upload.py?= =?UTF-8?q?=20(#23679)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/scripts/upload.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py index f6b25396ad..c7730d8f29 100644 --- a/buildroot/share/scripts/upload.py +++ b/buildroot/share/scripts/upload.py @@ -142,7 +142,7 @@ def Upload(source, target, env): upload_port = _GetUploadPort(env) # Serial port to use # Set local upload params - upload_firmware_target_name = os.path.basename(upload_firmware_source_name) # WARNING! Need rework on "binary_stream" to allow filename > 8.3 + upload_firmware_target_name = os.path.basename(upload_firmware_source_name) # Target firmware filename upload_timeout = 1000 # Communication timout, lossy/slow connections need higher values upload_blocksize = 512 # Transfer block size. 512 = Autodetect @@ -154,11 +154,11 @@ def Upload(source, target, env): # Set local upload params based on board type to change script behavior # "upload_delete_old_bins": delete all *.bin files in the root of SD Card upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', - 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', 'BOARD_CREALITY_V24S1'] # "upload_random_name": generate a random 8.3 firmware filename to upload upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', - 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support try: @@ -258,7 +258,7 @@ def Upload(source, target, env): print('Trigger firmware update...') protocol.send_ascii('M997', True) - protocol: protocol.shutdown() + protocol.shutdown() print('Firmware update completed') except KeyboardInterrupt: From 0564cb188f1a74dc9ecfb55b793f4225424a9ca4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 5 Feb 2022 10:30:17 -0600 Subject: [PATCH 002/203] =?UTF-8?q?=F0=9F=9A=B8=20Enhanced=20UI=20=3D>=20P?= =?UTF-8?q?rofessional=20UI=20-=20with=20updates=20(#23624)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/feature/pause.cpp | 2 +- Marlin/src/feature/runout.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 2 +- Marlin/src/gcode/bedlevel/ubl/M421.cpp | 2 +- Marlin/src/gcode/calibrate/G28.cpp | 2 +- Marlin/src/gcode/control/M997.cpp | 2 +- Marlin/src/gcode/feature/powerloss/M1000.cpp | 2 +- Marlin/src/gcode/lcd/M0_M1.cpp | 4 +- Marlin/src/gcode/lcd/M73.cpp | 2 +- Marlin/src/gcode/sd/M1001.cpp | 2 +- Marlin/src/gcode/stats/M75-M78.cpp | 2 +- Marlin/src/gcode/temp/M303.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 3 + Marlin/src/inc/SanityCheck.h | 2 + Marlin/src/lcd/e3v2/common/dwin_set.h | 11 +- Marlin/src/lcd/e3v2/creality/dwin.cpp | 3 - Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 4 - .../src/lcd/e3v2/{enhanced => proui}/dwin.cpp | 247 +++++++++++------- .../src/lcd/e3v2/{enhanced => proui}/dwin.h | 21 +- .../e3v2/{enhanced => proui}/dwin_defines.h | 11 +- .../lcd/e3v2/{enhanced => proui}/dwin_lcd.cpp | 4 +- .../lcd/e3v2/{enhanced => proui}/dwin_lcd.h | 4 +- .../e3v2/{enhanced => proui}/dwin_popup.cpp | 12 +- .../lcd/e3v2/{enhanced => proui}/dwin_popup.h | 16 +- .../lcd/e3v2/{enhanced => proui}/dwinui.cpp | 6 +- .../src/lcd/e3v2/{enhanced => proui}/dwinui.h | 41 ++- .../e3v2/{enhanced => proui}/endstop_diag.cpp | 8 +- .../e3v2/{enhanced => proui}/endstop_diag.h | 4 +- .../e3v2/{enhanced => proui}/lockscreen.cpp | 4 +- .../lcd/e3v2/{enhanced => proui}/lockscreen.h | 4 +- .../e3v2/{enhanced => proui}/meshviewer.cpp | 10 +- .../lcd/e3v2/{enhanced => proui}/meshviewer.h | 8 +- .../e3v2/{enhanced => proui}/printstats.cpp | 8 +- .../lcd/e3v2/{enhanced => proui}/printstats.h | 8 +- Marlin/src/lcd/marlinui.cpp | 4 +- Marlin/src/lcd/marlinui.h | 6 +- Marlin/src/module/probe.cpp | 2 +- Marlin/src/module/settings.cpp | 4 +- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 2 +- Marlin/src/sd/cardreader.cpp | 2 +- buildroot/tests/STM32F103RE_creality | 2 +- ini/features.ini | 2 +- platformio.ini | 2 +- 46 files changed, 319 insertions(+), 178 deletions(-) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwin.cpp (95%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwin.h (93%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwin_defines.h (94%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwin_lcd.cpp (98%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwin_lcd.h (96%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwin_popup.cpp (88%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwin_popup.h (83%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwinui.cpp (99%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/dwinui.h (92%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/endstop_diag.cpp (93%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/endstop_diag.h (90%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/lockscreen.cpp (95%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/lockscreen.h (92%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/meshviewer.cpp (94%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/meshviewer.h (87%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/printstats.cpp (94%) rename Marlin/src/lcd/e3v2/{enhanced => proui}/printstats.h (87%) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index e34c0d6c3c..420cc5186e 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -75,7 +75,7 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "lcd/e3v2/enhanced/dwin.h" + #include "lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "lcd/e3v2/jyersui/dwin.h" #endif diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 147164c166..69c25cbe33 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -58,7 +58,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" + #include "../lcd/e3v2/proui/dwin.h" #endif #include "../lcd/marlinui.h" diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 9317e3489a..8b78b53848 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -69,7 +69,7 @@ bool FilamentMonitorBase::enabled = true, #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" + #include "../lcd/e3v2/proui/dwin.h" #endif void event_filament_runout(const uint8_t extruder) { diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index eea5d4a7f2..fddca22c32 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -61,7 +61,7 @@ #elif ENABLED(DWIN_CREALITY_LCD) #include "../../../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" + #include "../../../lcd/e3v2/proui/dwin.h" #endif #if HAS_MULTI_HOTEND diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index eec89f73ac..090c15b057 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -41,7 +41,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" + #include "../../../lcd/e3v2/proui/dwin.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) diff --git a/Marlin/src/gcode/bedlevel/ubl/M421.cpp b/Marlin/src/gcode/bedlevel/ubl/M421.cpp index e6f0ef1f89..ac6f97b00a 100644 --- a/Marlin/src/gcode/bedlevel/ubl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/M421.cpp @@ -34,7 +34,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" + #include "../../../lcd/e3v2/proui/dwin.h" #endif /** diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index cda71a1c10..48f02d2a33 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -52,7 +52,7 @@ #elif ENABLED(DWIN_CREALITY_LCD) #include "../../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif #if HAS_L64XX // set L6470 absolute position registers to counts diff --git a/Marlin/src/gcode/control/M997.cpp b/Marlin/src/gcode/control/M997.cpp index 73d795bcef..359172faad 100644 --- a/Marlin/src/gcode/control/M997.cpp +++ b/Marlin/src/gcode/control/M997.cpp @@ -25,7 +25,7 @@ #if ENABLED(PLATFORM_M997_SUPPORT) #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif /** diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index b7fa45e2d0..6fb99226ce 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -34,7 +34,7 @@ #elif ENABLED(DWIN_CREALITY_LCD) #include "../../../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" + #include "../../../lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../../../lcd/e3v2/jyersui/dwin.h" // Temporary fix until it can be better implemented #endif diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 2bf3c94f1c..a9223dda47 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -36,8 +36,8 @@ #elif ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin_popup.h" - #include "../../lcd/e3v2/enhanced/dwin.h" + #include "../../lcd/e3v2/proui/dwin_popup.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index b7a9b3459e..c2c5485072 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -29,7 +29,7 @@ #include "../../sd/cardreader.h" #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif /** diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index ad549946f0..1579efd555 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -50,7 +50,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(HOST_ACTION_COMMANDS) diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 7d16899fd3..368edb65d9 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -30,7 +30,7 @@ #include "../../MarlinCore.h" // for startOrResumeJob #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif /** diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index a43575933b..7b56eb2d6b 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -31,7 +31,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif /** diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 5444841db3..f4b517dd23 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -494,6 +494,9 @@ #endif #define HAS_LCD_BRIGHTNESS 1 #define LCD_BRIGHTNESS_MAX 250 + #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #define LCD_BRIGHTNESS_DEFAULT 127 + #endif #endif #if IS_ULTRA_LCD diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 85070c7558..1177cbcd14 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -607,6 +607,8 @@ #error "LCD_SCREEN_ROT_180 is now LCD_SCREEN_ROTATE with a value of 180." #elif defined(LCD_SCREEN_ROT_270) #error "LCD_SCREEN_ROT_270 is now LCD_SCREEN_ROTATE with a value of 270." +#elif defined(DEFAULT_LCD_BRIGHTNESS) + #error "DEFAULT_LCD_BRIGHTNESS is now LCD_BRIGHTNESS_DEFAULT." #endif #if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) diff --git a/Marlin/src/lcd/e3v2/common/dwin_set.h b/Marlin/src/lcd/e3v2/common/dwin_set.h index 4fedd7a584..7f44386954 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_set.h +++ b/Marlin/src/lcd/e3v2/common/dwin_set.h @@ -25,7 +25,16 @@ #define Language_English 1 #define Language_Chinese 2 -#define ICON 7 // Icon set file 7.ICO +//#define USE_STOCK_DWIN_SET // Use the Creality stock DWIN_SET instead of Marlin's unified DWIN_SET by The-EG & thinkyhead +#ifdef USE_STOCK_DWIN_SET + #define ICON 9 // 9.ICO +#else + #define ICON 7 // 7.ICO +#endif + +#ifndef CORP_WEBSITE + #define CORP_WEBSITE WEBSITE_URL +#endif #define ICON_LOGO 0 #define ICON_Print_0 1 diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index f17d97cc7c..f20260e43d 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -91,9 +91,6 @@ #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL -#endif #define PAUSE_HEAT diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 1356c0e475..0eedddb500 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -82,10 +82,6 @@ #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL - #endif - #define DWIN_FONT_MENU font8x16 #define DWIN_FONT_STAT font10x20 #define DWIN_FONT_HEAD font10x20 diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp similarity index 95% rename from Marlin/src/lcd/e3v2/enhanced/dwin.cpp rename to Marlin/src/lcd/e3v2/proui/dwin.cpp index 58885e1c21..4d7f38171d 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -21,10 +21,12 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.9.1 - * Date: 2021/11/21 + * Enhanced DWIN implementation + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.2 + * date: 2022/01/19 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" @@ -83,6 +85,10 @@ #include "../../../feature/powerloss.h" #endif +#if HAS_GCODE_PREVIEW + #include "gcode_preview.h" +#endif + #if HAS_ESDIAG #include "endstop_diag.h" #endif @@ -113,10 +119,6 @@ #include "lockscreen.h" -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL -#endif - #define PAUSE_HEAT #define MENU_CHAR_LIMIT 24 @@ -169,7 +171,7 @@ enum SelectItem : uint8_t { PAGE_PRINT = 0, PAGE_PREPARE, PAGE_CONTROL, - PAGE_INFO_LEVELING, + PAGE_INFO_LEV_ADV, PAGE_COUNT, PRINT_SETUP = 0, @@ -310,11 +312,11 @@ void ICON_Button(const bool selected, const int iconid, const frame_rect_t &ico, DWIN_ICON_Show(true, false, false, ICON, iconid + selected, ico.x, ico.y); if (selected) DWINUI::Draw_Box(0, HMI_data.Highlight_Color, ico); if (HMI_IsChinese()) { - DWIN_Frame_AreaCopy(1, txt.x, txt.y[selected], txt.x + txt.w - 1, txt.y[selected] + txt.h - 1, ico.x + (ico.w - txt.w) / 2, (ico.y + ico.h - 28) - txt.h/2); + DWIN_Frame_AreaCopy(1, txt.x, txt.y[selected], txt.x + txt.w - 1, txt.y[selected] + txt.h - 1, ico.x + (ico.w - txt.w) / 2, (ico.y + ico.h - 25) - txt.h/2); } else { const uint16_t x = ico.x + (ico.w - strlen_P(FTOP(caption)) * DWINUI::fontWidth()) / 2, - y = (ico.y + ico.h - 28) - DWINUI::fontHeight() / 2; + y = (ico.y + ico.h - 20) - DWINUI::fontHeight() / 2; DWINUI::Draw_String(x, y, caption); } } @@ -324,7 +326,7 @@ void ICON_Button(const bool selected, const int iconid, const frame_rect_t &ico, // void ICON_Print() { constexpr frame_rect_t ico = { 17, 110, 110, 100 }; - constexpr text_info_t txt = { 1, { 405, 447 }, 27, 15 }; + constexpr text_info_t txt = { 1, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; ICON_Button(select_page.now == PAGE_PRINT, ICON_Print_0, ico, txt, GET_TEXT_F(MSG_BUTTON_PRINT)); } @@ -333,7 +335,7 @@ void ICON_Print() { // void ICON_Prepare() { constexpr frame_rect_t ico = { 145, 110, 110, 100 }; - constexpr text_info_t txt = { 31, { 405, 447 }, 27, 15 }; + constexpr text_info_t txt = { 31, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; ICON_Button(select_page.now == PAGE_PREPARE, ICON_Prepare_0, ico, txt, GET_TEXT_F(MSG_PREPARE)); } @@ -342,7 +344,7 @@ void ICON_Prepare() { // void ICON_Control() { constexpr frame_rect_t ico = { 17, 226, 110, 100 }; - constexpr text_info_t txt = { 61, { 405, 447 }, 27, 15 }; + constexpr text_info_t txt = { 61, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; ICON_Button(select_page.now == PAGE_CONTROL, ICON_Control_0, ico, txt, GET_TEXT_F(MSG_CONTROL)); } @@ -351,8 +353,8 @@ void ICON_Control() { // void ICON_StartInfo() { constexpr frame_rect_t ico = { 145, 226, 110, 100 }; - constexpr text_info_t txt = { 91, { 405, 447 }, 27, 15 }; - ICON_Button(select_page.now == PAGE_INFO_LEVELING, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_INFO)); + constexpr text_info_t txt = { 91, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_INFO_LEV_ADV, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_INFO)); } // @@ -360,8 +362,17 @@ void ICON_StartInfo() { // void ICON_Leveling() { constexpr frame_rect_t ico = { 145, 226, 110, 100 }; - constexpr text_info_t txt = { 211, { 405, 447 }, 27, 15 }; - ICON_Button(select_page.now == PAGE_INFO_LEVELING, ICON_Leveling_0, ico, txt, GET_TEXT_F(MSG_BUTTON_LEVEL)); + constexpr text_info_t txt = { 211, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_INFO_LEV_ADV, ICON_Leveling_0, ico, txt, GET_TEXT_F(MSG_BUTTON_LEVEL)); +} + +// +// Main Menu: "Advanced Settings" +// +void ICON_AdvSettings() { + constexpr frame_rect_t ico = { 145, 226, 110, 100 }; + constexpr text_info_t txt = { 91, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_INFO_LEV_ADV, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_ADVANCED)); } // @@ -369,7 +380,7 @@ void ICON_Leveling() { // void ICON_Tune() { constexpr frame_rect_t ico = { 8, 232, 80, 100 }; - constexpr text_info_t txt = { 121, { 405, 447 }, 27, 15 }; + constexpr text_info_t txt = { 121, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; ICON_Button(select_print.now == PRINT_SETUP, ICON_Setup_0, ico, txt, GET_TEXT_F(MSG_TUNE)); } @@ -378,7 +389,7 @@ void ICON_Tune() { // void ICON_Pause() { constexpr frame_rect_t ico = { 96, 232, 80, 100 }; - constexpr text_info_t txt = { 181, { 405, 447 }, 27, 15 }; + constexpr text_info_t txt = { 181, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Pause_0, ico, txt, GET_TEXT_F(MSG_BUTTON_PAUSE)); } @@ -387,7 +398,7 @@ void ICON_Pause() { // void ICON_Resume() { constexpr frame_rect_t ico = { 96, 232, 80, 100 }; - constexpr text_info_t txt = { 1, { 405, 447 }, 27, 15 }; + constexpr text_info_t txt = { 1, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Continue_0, ico, txt, GET_TEXT_F(MSG_BUTTON_RESUME)); } @@ -396,7 +407,7 @@ void ICON_Resume() { // void ICON_Stop() { constexpr frame_rect_t ico = { 184, 232, 80, 100 }; - constexpr text_info_t txt = { 151, { 405, 447 }, 27, 12 }; + constexpr text_info_t txt = { 151, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 12 }; ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt, GET_TEXT_F(MSG_BUTTON_STOP)); } @@ -453,18 +464,13 @@ void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const DWINUI::Draw_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); } -// The "Back" label is always on the first line -void Draw_Back_Label() { - if (HMI_IsChinese()) - DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); - else - DWIN_Frame_AreaCopy(1, 223, 179, 254, 189, LBLX, MBASE(0)); -} - // Draw "Back" line at the top void Draw_Back_First(const bool is_sel=true) { Draw_Menu_Line(0, ICON_Back); - Draw_Back_Label(); + if (HMI_IsChinese()) + DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); + else + DWINUI::Draw_String(LBLX, MBASE(0), GET_TEXT_F(MSG_BACK)); if (is_sel) Draw_Menu_Cursor(0); } @@ -489,15 +495,15 @@ inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { //PopUps void Popup_window_PauseOrStop() { if (HMI_IsChinese()) { - DWINUI::ClearMenuArea(); + DWINUI::ClearMenuArea(); Draw_Popup_Bkgd(); if (select_print.now == PRINT_PAUSE_RESUME) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); else if (select_print.now == PRINT_STOP) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); - DWINUI::Draw_Icon(ICON_Confirm_C, 26, 280); - DWINUI::Draw_Icon(ICON_Cancel_C, 146, 280); + DWINUI::Draw_IconWB(ICON_Confirm_C, 26, 280); + DWINUI::Draw_IconWB(ICON_Cancel_C, 146, 280); Draw_Select_Highlight(true); - DWIN_UpdateLCD(); + DWIN_UpdateLCD(); } else DWIN_Popup_ConfirmCancel(ICON_BLTouch, select_print.now == PRINT_PAUSE_RESUME ? GET_TEXT_F(MSG_PAUSE_PRINT) : GET_TEXT_F(MSG_STOP_PRINT)); @@ -513,7 +519,7 @@ void Popup_window_PauseOrStop() { DWINUI::Draw_Icon(ICON_TempTooLow, 102, 105); DWIN_Frame_AreaCopy(1, 103, 371, 136, 386, 69, 240); DWIN_Frame_AreaCopy(1, 170, 371, 270, 386, 102, 240); - DWINUI::Draw_Icon(ICON_Confirm_C, 86, 280); + DWINUI::Draw_IconWB(ICON_Confirm_C, 86, 280); DWIN_UpdateLCD(); } else @@ -527,8 +533,8 @@ void Popup_window_PauseOrStop() { DWINUI::ClearMenuArea(); Draw_Popup_Bkgd(); if (HMI_IsChinese()) { - if (toohigh) { - DWINUI::Draw_Icon(ICON_TempTooHigh, 102, 165); + if (toohigh) { + DWINUI::Draw_Icon(ICON_TempTooHigh, 102, 165); DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285); DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); @@ -637,7 +643,7 @@ void Draw_Print_Labels() { } void Draw_Print_ProgressBar() { - DWINUI::Draw_Icon(ICON_Bar, 15, 93); + DWINUI::Draw_IconWB(ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, HMI_data.Barfill_Color, 16 + _percent_done * 240 / 100, 93, 256, 113); DWINUI::Draw_Int(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 3, 117, 133, _percent_done); DWINUI::Draw_String(HMI_data.PercentTxt_Color, 142, 133, F("%")); @@ -707,7 +713,7 @@ void Draw_PrintDone() { Draw_Print_ProgressElapsed(); Draw_Print_ProgressRemain(); // show print done confirm - DWINUI::Draw_Icon(HMI_IsChinese() ? ICON_Confirm_C : ICON_Confirm_E, 86, 273); + DWINUI::Draw_IconWB(HMI_IsChinese() ? ICON_Confirm_C : ICON_Confirm_E, 86, 273); DWIN_UpdateLCD(); } @@ -721,7 +727,7 @@ void Draw_Main_Menu() { ICON_Print(); ICON_Prepare(); ICON_Control(); - TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); + ICON_AdvSettings(); DWIN_UpdateLCD(); } @@ -745,11 +751,11 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, if (force || changed || draw_qmark || draw_empty) { if (blink && draw_qmark) - DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F("--?--")); + DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" - ? -")); else if (blink && draw_empty) DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" ")); else - DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 1, x, y, p); + DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 2, x, y, p); } } @@ -911,8 +917,6 @@ void MarlinUI::refresh() { /* Nothing to see here */ } void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } #endif -#define ICON_Folder ICON_More - #if ENABLED(SCROLL_LONG_FILENAMES) char shift_name[LONG_FILENAME_LENGTH + 1]; @@ -1115,25 +1119,25 @@ void HMI_StartFrame(const bool with_update) { void Draw_Info_Menu() { DWINUI::ClearMenuArea(); Draw_Back_First(); - - DWINUI::Draw_CenteredString(122, F(MACHINE_SIZE)); - DWINUI::Draw_CenteredString(195, F(SHORT_BUILD_VERSION)); + if (HMI_IsChinese()) + Title.FrameCopy(30, 17, 28, 13); // "Info" + else + Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); if (HMI_IsChinese()) { - Title.FrameCopy(30, 17, 28, 13); // "Info" - DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102); // "Size" DWIN_Frame_AreaCopy(1, 1, 164, 56, 176, 108, 175); // "Firmware Version" DWIN_Frame_AreaCopy(1, 58, 164, 113, 176, 105, 248); // "Contact Details" + DWINUI::Draw_CenteredString(268, F(CORP_WEBSITE)); } else { - Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); - - DWIN_Frame_AreaCopy(1, 120, 150, 146, 161, 124, 102); // "Size" - DWIN_Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175); // "Firmware Version" - DWIN_Frame_AreaCopy(1, 1, 164, 96, 175, 89, 248); // "Contact details" + DWINUI::Draw_CenteredString(102, F("Size")); + DWINUI::Draw_CenteredString(175, F("Firmware version")); + DWINUI::Draw_CenteredString(248, F("Build Datetime")); + DWINUI::Draw_CenteredString(268, F(STRING_DISTRIBUTION_DATE)); } - DWINUI::Draw_CenteredString(268, F(CORP_WEBSITE)); + DWINUI::Draw_CenteredString(122, F(MACHINE_SIZE)); + DWINUI::Draw_CenteredString(195, F(SHORT_BUILD_VERSION)); LOOP_L_N(i, 3) { DWINUI::Draw_Icon(ICON_PrintSize + i, ICOX, 99 + i * 73); @@ -1162,7 +1166,7 @@ void HMI_MainMenu() { case PAGE_PRINT: ICON_Print(); break; case PAGE_PREPARE: ICON_Print(); ICON_Prepare(); break; case PAGE_CONTROL: ICON_Prepare(); ICON_Control(); break; - case PAGE_INFO_LEVELING: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; + case PAGE_INFO_LEV_ADV: ICON_Control(); ICON_AdvSettings(); break; } } } @@ -1171,8 +1175,8 @@ void HMI_MainMenu() { switch (select_page.now) { case PAGE_PRINT: ICON_Print(); ICON_Prepare(); break; case PAGE_PREPARE: ICON_Prepare(); ICON_Control(); break; - case PAGE_CONTROL: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; - case PAGE_INFO_LEVELING: TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; + case PAGE_CONTROL: ICON_Control(); ICON_AdvSettings(); break; + case PAGE_INFO_LEV_ADV: ICON_AdvSettings(); break; } } } @@ -1180,6 +1184,7 @@ void HMI_MainMenu() { switch (select_page.now) { case PAGE_PRINT: checkkey = SelectFile; + card.mount(); Draw_Print_File_Menu(); break; @@ -1187,14 +1192,7 @@ void HMI_MainMenu() { case PAGE_CONTROL: Draw_Control_Menu(); break; - case PAGE_INFO_LEVELING: - #if HAS_ONESTEP_LEVELING - queue.inject(F("G28Z\nG29")); // Force to get the current Z home position - #else - last_checkkey = MainMenu; - Goto_Info_Menu(); - #endif - break; + case PAGE_INFO_LEV_ADV: Draw_AdvancedSettings_Menu(); break; } } DWIN_UpdateLCD(); @@ -1469,6 +1467,9 @@ void Draw_Main_Area() { case FilamentPurge: Draw_Popup_FilamentPurge(); break; #endif case Locked: lockScreen.draw(); break; + #if HAS_GCODE_PREVIEW + case ConfirmToPrint: Draw_PreviewFromSD(); break; + #endif case Menu: case SetInt: case SetPInt: @@ -1496,14 +1497,12 @@ void HMI_Popup() { void HMI_Init() { HMI_SDCardInit(); - for (uint16_t t = 0; t <= 100; t += 2) { DWINUI::Draw_Icon(ICON_Bar, 15, 260); DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 15 + t * 242 / 100, 260, 257, 280); DWIN_UpdateLCD(); delay(20); } - HMI_SetLanguage(); } @@ -1623,15 +1622,15 @@ void EachMomentUpdate() { if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 115); DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 167); - DWINUI::Draw_Icon(ICON_Cancel_C, 26, 280); - DWINUI::Draw_Icon(ICON_Continue_C, 146, 280); + DWINUI::Draw_IconWB(ICON_Cancel_C, 26, 280); + DWINUI::Draw_IconWB(ICON_Continue_C, 146, 280); } else { DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 70, GET_TEXT_F(MSG_OUTAGE_RECOVERY)); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 147, F("It looks like the last")); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 167, F("file was interrupted.")); - DWINUI::Draw_Icon(ICON_Cancel_E, 26, 280); - DWINUI::Draw_Icon(ICON_Continue_E, 146, 280); + DWINUI::Draw_IconWB(ICON_Cancel_E, 26, 280); + DWINUI::Draw_IconWB(ICON_Continue_E, 146, 280); } SdFile *dir = nullptr; const char * const filename = card.diveToFile(true, dir, recovery.info.sd_filename); @@ -1698,6 +1697,9 @@ void DWIN_HandleScreen() { #if ENABLED(POWER_LOSS_RECOVERY) case PwrlossRec: HMI_PowerlossRecovery(); break; #endif + #if HAS_GCODE_PREVIEW + case ConfirmToPrint: HMI_ConfirmToPrint(); break; + #endif #if HAS_ESDIAG case ESDiagProcess: HMI_Popup(); break; #endif @@ -1747,7 +1749,7 @@ void DWIN_MeshLevelingStart() { #if HAS_ONESTEP_LEVELING HMI_SaveProcessID(Leveling); Title.ShowCaption(GET_TEXT_F(MSG_BED_LEVELING)); - DWIN_Draw_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT)); + DWIN_Show_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT), ICON_Cancel_E); #elif ENABLED(MESH_BED_LEVELING) Draw_ManualMesh_Menu(); #endif @@ -1924,7 +1926,8 @@ void DWIN_LoadSettings(const char *buff) { } void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) { - DWIN_Draw_Popup(ICON_BLTouch, lcd_error, lcd_component); + DWIN_Draw_Popup(ICON_BLTouch, F("Printer killed:"), lcd_error); + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 270, F("Turn off the printer")); DWIN_UpdateLCD(); } @@ -1969,8 +1972,8 @@ void DWIN_Redraw_screen() { void Draw_Popup_FilamentPurge() { DWIN_Draw_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), F("Purge or Continue?")); - DWINUI::Draw_Icon(ICON_Confirm_E, 26, 280); - DWINUI::Draw_Icon(ICON_Continue_E, 146, 280); + DWINUI::Draw_IconWB(ICON_Confirm_E, 26, 280); + DWINUI::Draw_IconWB(ICON_Continue_E, 146, 280); Draw_Select_Highlight(true); DWIN_UpdateLCD(); } @@ -2037,6 +2040,41 @@ void HMI_LockScreen() { if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); } +#if HAS_GCODE_PREVIEW + + void HMI_ConfirmToPrint() { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + if (encoder_diffState == ENCODER_DIFF_CW) + Draw_Select_Highlight(false); + else if (encoder_diffState == ENCODER_DIFF_CCW) + Draw_Select_Highlight(true); + else if (encoder_diffState == ENCODER_DIFF_ENTER) { + if (HMI_flag.select_flag) { // Confirm + card.openAndPrintFile(card.filename); + DWIN_Print_Started(true); + } + else { // Cancel + DWIN_ResetStatusLine(); + checkkey = SelectFile; + Draw_Print_File_Menu(); + } + } + DWIN_UpdateLCD(); + } + +#endif + +void Goto_ConfirmToPrint() { + #if HAS_GCODE_PREVIEW + HMI_SaveProcessID(ConfirmToPrint); + Draw_PreviewFromSD(); + #else + card.openAndPrintFile(card.filename); + DWIN_Print_Started(true); + #endif +} + #if HAS_ESDIAG void Draw_EndStopDiag() { HMI_SaveProcessID(ESDiagProcess); @@ -2308,8 +2346,9 @@ void SetPID(celsius_t t, heater_id_t h) { #endif #if HAS_LCD_BRIGHTNESS - void LiveBrightness() { ui.set_brightness(HMI_value.Value); } - void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, nullptr, LiveBrightness); } + void ApplyBrightness() { ui.set_brightness(HMI_value.Value); } + void LiveBrightness() { DWIN_LCD_Brightness(HMI_value.Value); } + void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, ApplyBrightness, LiveBrightness); } #endif #if ENABLED(CASE_LIGHT_MENU) @@ -2382,6 +2421,12 @@ void SetPID(celsius_t t, heater_id_t h) { #endif #endif +#if ENABLED(NOZZLE_PARK_FEATURE) + void SetParkPosX() { SetPIntOnClick(0, X_MAX_POS); } + void SetParkPosY() { SetPIntOnClick(0, Y_MAX_POS); } + void SetParkZRaise() { SetPIntOnClick(0, 50); } +#endif + #if HAS_FILAMENT_SENSOR void SetRunoutEnable() { runout.reset(); @@ -2490,9 +2535,11 @@ void Tram(uint8_t point) { static bool inLev = false; if (inLev) return; char str_1[6] = "", str_2[6] = "", str_3[6] = ""; + #define fmt "X:%s, Y:%s, Z:%s" float xpos = 0, ypos = 0, zval = 0; float margin = PROBING_MARGIN; #else + #define fmt "M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300" int16_t xpos = 0, ypos = 0; int16_t margin = 30; #endif @@ -2527,7 +2574,7 @@ void Tram(uint8_t point) { planner.synchronize(); inLev = true; zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); - sprintf_P(cmd, PSTR("X:%s, Y:%s, Z:%s"), + sprintf_P(cmd, PSTR(fmt), dtostrf(xpos, 1, 1, str_1), dtostrf(ypos, 1, 1, str_2), dtostrf(zval, 1, 2, str_3) @@ -2536,7 +2583,7 @@ void Tram(uint8_t point) { inLev = false; #else planner.synchronize(); - sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300"), xpos, ypos); + sprintf_P(cmd, PSTR(fmt), xpos, ypos); queue.inject(cmd); #endif } @@ -2957,7 +3004,7 @@ void onDrawSpeed(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedX(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(line)); // X + DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(line)); // X } onDrawPFloatMenu(menuitem, line); } @@ -2965,7 +3012,7 @@ void onDrawMaxSpeedX(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedY(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(line)); // Y + DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(line)); // Y } onDrawPFloatMenu(menuitem, line); } @@ -2973,7 +3020,7 @@ void onDrawMaxSpeedY(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(line) + 3); // Z + DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(line) + 3); // Z } onDrawPFloatMenu(menuitem, line); } @@ -2982,7 +3029,7 @@ void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedE(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(line)); // E + DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(line)); // E } onDrawPFloatMenu(menuitem, line); } @@ -2991,7 +3038,7 @@ void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { void onDrawAcc(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line) + 1); // ...Acceleration + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line) + 1); // ...Acceleration } onDrawSubMenu(menuitem, line); } @@ -3000,7 +3047,7 @@ void onDrawMaxAccelX(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 71, MBASE(line)); // X + DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 71, MBASE(line)); // X } onDrawPInt32Menu(menuitem, line); } @@ -3008,8 +3055,8 @@ void onDrawMaxAccelX(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelY(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 71, MBASE(line)); // Y + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 71, MBASE(line)); // Y } onDrawPInt32Menu(menuitem, line); } @@ -3017,8 +3064,8 @@ void onDrawMaxAccelY(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 71, MBASE(line)); // Z + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 71, MBASE(line)); // Z } onDrawPInt32Menu(menuitem, line); } @@ -3027,8 +3074,8 @@ void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelE(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 71, MBASE(line)); // E + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 71, MBASE(line)); // E } onDrawPInt32Menu(menuitem, line); } @@ -3039,7 +3086,7 @@ void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { void onDrawJerk(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(line) + 1); // ... + DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(line) + 1); // ... DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(line)); // ...Jerk } onDrawSubMenu(menuitem, line); @@ -3286,6 +3333,9 @@ void Draw_Prepare_Menu() { #if ENABLED(MESH_BED_LEVELING) MENU_ITEM(ICON_ManualMesh, GET_TEXT_F(MSG_MANUAL_MESH), onDrawSubMenu, Draw_ManualMesh_Menu); #endif + #if HAS_ONESTEP_LEVELING + MENU_ITEM(ICON_Level, GET_TEXT_F(MSG_AUTO_MESH), onDrawMenuItem, AutoLev); + #endif #if HAS_ZOFFSET_ITEM #if HAS_BED_PROBE MENU_ITEM(ICON_SetZOffset, GET_TEXT_F(MSG_PROBE_WIZARD), onDrawSubMenu, Draw_ZOffsetWiz_Menu); @@ -3334,12 +3384,12 @@ void Draw_Control_Menu() { if (CurrentMenu != ControlMenu) { CurrentMenu = ControlMenu; SetMenuTitle({103, 1, 28, 14}, GET_TEXT_F(MSG_CONTROL)); - DWINUI::MenuItemsPrepare(11); + DWINUI::MenuItemsPrepare(8); MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); #if ENABLED(CASE_LIGHT_MENU) #if ENABLED(CASELIGHT_USES_BRIGHTNESS) MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawSubMenu, Draw_CaseLight_Menu); - #else + #else MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight); #endif #endif @@ -3354,7 +3404,6 @@ void Draw_Control_Menu() { MENU_ITEM(ICON_ResumeEEPROM, GET_TEXT_F(MSG_RESTORE_DEFAULTS), onDrawResetEeprom, ResetEeprom); #endif MENU_ITEM(ICON_Reboot, GET_TEXT_F(MSG_RESET_PRINTER), onDrawMenuItem, RebootPrinter); - MENU_ITEM(ICON_AdvSet, GET_TEXT_F(MSG_ADVANCED_SETTINGS), onDrawSubMenu, Draw_AdvancedSettings_Menu); MENU_ITEM(ICON_Info, GET_TEXT_F(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_Info_Menu); } CurrentMenu->draw(); @@ -3367,7 +3416,7 @@ void Draw_AdvancedSettings_Menu() { CurrentMenu = AdvancedSettings; SetMenuTitle({0}, GET_TEXT_F(MSG_ADVANCED_SETTINGS)); // TODO: Chinese, English "Advanced Settings" JPG DWINUI::MenuItemsPrepare(15); - MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); + MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); #if HAS_HOME_OFFSET MENU_ITEM(ICON_HomeOffset, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawSubMenu, Draw_HomeOffset_Menu); #endif @@ -3601,7 +3650,7 @@ void Draw_Tune_Menu() { MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight); #elif ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) MENU_ITEM(ICON_LedControl, GET_TEXT_F(MSG_LEDS), onDrawLedStatus, SetLedStatus); - #endif + #endif EDIT_ITEM(ICON_Speed, GET_TEXT_F(MSG_SPEED), onDrawSpeedItem, SetSpeed, &feedrate_percentage); #if HAS_HOTEND HotendTargetItem = EDIT_ITEM(ICON_HotendTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h similarity index 93% rename from Marlin/src/lcd/e3v2/enhanced/dwin.h rename to Marlin/src/lcd/e3v2/proui/dwin.h index bbbe00aa9f..04ac1590eb 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -22,10 +22,12 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.9.1 - * Date: 2021/11/21 + * Enhanced DWIN implementation + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.9.2 + * date: 2021/11/21 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" @@ -62,6 +64,7 @@ enum processID : uint8_t { PwrlossRec, Reboot, Info, + ConfirmToPrint, // Popup Windows Homing, @@ -90,6 +93,8 @@ enum pidresult_t : uint8_t { typedef struct { int8_t Color[3]; // Color components + uint16_t pidgrphpoints = 0; + pidresult_t pidresult = PID_DONE; int8_t Preheat = 0; // Material Select 0: PLA, 1: ABS, 2: Custom AxisEnum axis = X_AXIS; // Axis Select int32_t MaxValue = 0; // Auxiliar max integer/scaled float value @@ -137,6 +142,7 @@ void Goto_PrintProcess(); void Goto_Main_Menu(); void Goto_Info_Menu(); void Goto_PowerLossRecovery(); +void Goto_ConfirmToPrint(); void Draw_Status_Area(const bool with_update); // Status Area void Draw_Main_Area(); // Redraw main area; void DWIN_Redraw_screen(); // Redraw all screen elements @@ -191,6 +197,9 @@ void HMI_LockScreen(); #if HAS_MESH void DWIN_MeshViewer(); #endif +#if HAS_GCODE_PREVIEW + void HMI_ConfirmToPrint(); +#endif #if HAS_ESDIAG void Draw_EndStopDiag(); #endif @@ -221,6 +230,10 @@ void Draw_Tramming_Menu(); #if HAS_FILAMENT_SENSOR void Draw_FilSet_Menu(); #endif +#if ENABLED(NOZZLE_PARK_FEATURE) + void Draw_ParkPos_Menu(); +#endif +void Draw_PhySet_Menu(); void Draw_SelectColors_Menu(); void Draw_GetColor_Menu(); #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h similarity index 94% rename from Marlin/src/lcd/e3v2/enhanced/dwin_defines.h rename to Marlin/src/lcd/e3v2/proui/dwin_defines.h index 907177ab32..3dc2408f4a 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -23,11 +23,16 @@ /** * DWIN general defines and data structs - * Author: Miguel A. Risco-Castillo - * Version: 3.9.1 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.9.2 * Date: 2021/11/21 + * + * Based on the original code provided by Creality under GPL */ +//#define NEED_HEX_PRINT 1 +//#define DEBUG_DWIN 1 + #include "../../../core/types.h" #include "../common/dwin_color.h" #if ENABLED(LED_CONTROL_MENU) @@ -53,8 +58,8 @@ #define Def_Indicator_Color Color_White #define Def_Coordinate_Color Color_White +//#define HAS_GCODE_PREVIEW 1 #define HAS_ESDIAG 1 -#define DEFAULT_LCD_BRIGHTNESS 127 #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) #define Def_Leds_Color LEDColorWhite() diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp similarity index 98% rename from Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp rename to Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp index 83cbc20718..105f1aaf1c 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp @@ -22,9 +22,11 @@ /** * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo + * Author: Miguel A. Risco-Castillo (MRISCOC) * Version: 3.8.1 * Date: 2021/11/09 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h similarity index 96% rename from Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h rename to Marlin/src/lcd/e3v2/proui/dwin_lcd.h index fc1b6d6756..623a94f09e 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h @@ -23,9 +23,11 @@ /** * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo + * Author: Miguel A. Risco-Castillo (MRISCOC) * Version: 3.8.1 * Date: 2021/11/09 + * + * Based on the original code provided by Creality under GPL */ #include "../common/dwin_api.h" diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp similarity index 88% rename from Marlin/src/lcd/e3v2/enhanced/dwin_popup.cpp rename to Marlin/src/lcd/e3v2/proui/dwin_popup.cpp index cf1ab8c0ad..34b05328d7 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_popup.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -22,9 +22,11 @@ /** * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.8.1 - * Date: 2021/11/06 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.10.1 + * Date: 2022/01/21 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" @@ -52,8 +54,8 @@ void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fm void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) { DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), fmsg2); - DWINUI::Draw_Icon(ICON_Confirm_E, 26, 280); - DWINUI::Draw_Icon(ICON_Cancel_E, 146, 280); + DWINUI::Draw_IconWB(ICON_Confirm_E, 26, 280); + DWINUI::Draw_IconWB(ICON_Cancel_E, 146, 280); Draw_Select_Highlight(true); DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin_popup.h b/Marlin/src/lcd/e3v2/proui/dwin_popup.h similarity index 83% rename from Marlin/src/lcd/e3v2/enhanced/dwin_popup.h rename to Marlin/src/lcd/e3v2/proui/dwin_popup.h index 65784a8c9f..2e952cc1b9 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_popup.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.h @@ -23,9 +23,11 @@ /** * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.8.1 - * Date: 2021/11/06 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.10.1 + * Date: 2022/01/21 + * + * Based on the original code provided by Creality under GPL */ #include "dwinui.h" @@ -47,7 +49,13 @@ void DWIN_Draw_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8 if (icon) DWINUI::Draw_Icon(icon, 101, 105); if (amsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, amsg1); if (amsg2) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 240, amsg2); - if (button) DWINUI::Draw_Icon(button, 86, 280); + if (button) DWINUI::Draw_IconWB(button, 86, 280); +} + +template +void DWIN_Show_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) { + DWIN_Draw_Popup(icon, amsg1, amsg2, button); + DWIN_UpdateLCD(); } template diff --git a/Marlin/src/lcd/e3v2/enhanced/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp similarity index 99% rename from Marlin/src/lcd/e3v2/enhanced/dwinui.cpp rename to Marlin/src/lcd/e3v2/proui/dwinui.cpp index 5017253740..d3cfc9a3e4 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -22,9 +22,11 @@ /** * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.8.1 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.8.2 * Date: 2021/11/09 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/lcd/e3v2/enhanced/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h similarity index 92% rename from Marlin/src/lcd/e3v2/enhanced/dwinui.h rename to Marlin/src/lcd/e3v2/proui/dwinui.h index 4f0dadc909..595c534356 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -23,9 +23,11 @@ /** * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.9.1 - * Date: 2021/11/21 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.1 + * Date: 2022/01/19 + * + * Based on the original code provided by Creality under GPL */ #include "dwin_lcd.h" @@ -34,6 +36,10 @@ #include "../common/dwin_color.h" // Extra Icons +#define ICON_AdvSet ICON_Language +#define ICON_BedSizeX ICON_PrintSize +#define ICON_BedSizeY ICON_PrintSize +#define ICON_Binary ICON_Contact #define ICON_Brightness ICON_Motion #define ICON_Cancel ICON_StockConfiguration #define ICON_CustomPreheat ICON_SetEndTemp @@ -45,6 +51,7 @@ #define ICON_FilSet ICON_ResumeEEPROM #define ICON_FilUnload ICON_ReadEEPROM #define ICON_Flow ICON_StepE +#define ICON_Folder ICON_More #define ICON_FWRetLength ICON_StepE #define ICON_FWRetSpeed ICON_Setspeed #define ICON_FWRetZRaise ICON_MoveZ @@ -52,28 +59,49 @@ #define ICON_HomeX ICON_MoveX #define ICON_HomeY ICON_MoveY #define ICON_HomeZ ICON_MoveZ +#define ICON_HomeOffset ICON_AdvSet +#define ICON_HomeOffsetX ICON_StepX +#define ICON_HomeOffsetY ICON_StepY +#define ICON_HomeOffsetZ ICON_StepZ #define ICON_HSMode ICON_StockConfiguration +#define ICON_InvertE0 ICON_StepE #define ICON_Tram ICON_SetEndTemp +#define ICON_Level ICON_HotendTemp #define ICON_Lock ICON_Cool #define ICON_ManualMesh ICON_HotendTemp +#define ICON_MaxPosX ICON_MoveX +#define ICON_MaxPosY ICON_MoveY +#define ICON_MaxPosZ ICON_MoveZ #define ICON_MeshNext ICON_Axis +#define ICON_MeshPoints ICON_SetEndTemp #define ICON_MeshSave ICON_WriteEEPROM #define ICON_MeshViewer ICON_HotendTemp #define ICON_MoveZ0 ICON_HotendTemp #define ICON_Park ICON_Motion +#define ICON_ParkPos ICON_AdvSet +#define ICON_ParkPosX ICON_StepX +#define ICON_ParkPosY ICON_StepY +#define ICON_ParkPosZ ICON_StepZ +#define ICON_PhySet ICON_PrintSize #define ICON_PIDbed ICON_SetBedTemp #define ICON_PIDcycles ICON_ResumeEEPROM #define ICON_PIDValue ICON_Contact #define ICON_PrintStats ICON_PrintTime #define ICON_PrintStatsReset ICON_RemainTime #define ICON_ProbeDeploy ICON_SetEndTemp +#define ICON_ProbeMargin ICON_PrintSize +#define ICON_ProbeOffsetX ICON_StepX +#define ICON_ProbeOffsetY ICON_StepY +#define ICON_ProbeOffsetZ ICON_StepZ #define ICON_ProbeSet ICON_SetEndTemp #define ICON_ProbeStow ICON_SetEndTemp #define ICON_ProbeTest ICON_SetEndTemp +#define ICON_ProbeZSpeed ICON_MaxSpeedZ #define ICON_Pwrlossr ICON_Motion #define ICON_Reboot ICON_ResumeEEPROM #define ICON_Runout ICON_MaxAccE #define ICON_Scolor ICON_MaxSpeed +#define ICON_SetBaudRate ICON_Setspeed #define ICON_SetCustomPreheat ICON_SetEndTemp #define ICON_Sound ICON_Cool #define ICON_CaseLight ICON_Motion @@ -247,6 +275,13 @@ namespace DWINUI { DWIN_ICON_Show(ICON, icon, x, y); } + // Draw an Icon from the library ICON with its background + // icon: Icon ID + // x/y: Upper-left point + inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) { + DWIN_ICON_Show(true, false, false, ICON, icon, x, y); + } + // Draw a positive integer // bShow: true=display background color; false=don't display background color // zeroFill: true=zero fill; false=no zero fill diff --git a/Marlin/src/lcd/e3v2/enhanced/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp similarity index 93% rename from Marlin/src/lcd/e3v2/enhanced/endstop_diag.cpp rename to Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 0f982c3a36..6232c89534 100644 --- a/Marlin/src/lcd/e3v2/enhanced/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -22,9 +22,11 @@ /** * DWIN End Stops diagnostic page - * Author: Miguel A. Risco-Castillo - * Version: 1.0 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.0.2 * Date: 2021/11/06 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" @@ -106,4 +108,4 @@ void ESDiagClass::Update() { DWIN_UpdateLCD(); } -#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_MESH +#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_ESDIAG diff --git a/Marlin/src/lcd/e3v2/enhanced/endstop_diag.h b/Marlin/src/lcd/e3v2/proui/endstop_diag.h similarity index 90% rename from Marlin/src/lcd/e3v2/enhanced/endstop_diag.h rename to Marlin/src/lcd/e3v2/proui/endstop_diag.h index 1864b95723..4694ddb141 100644 --- a/Marlin/src/lcd/e3v2/enhanced/endstop_diag.h +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.h @@ -23,9 +23,11 @@ /** * DWIN End Stops diagnostic page - * Author: Miguel A. Risco-Castillo + * Author: Miguel A. Risco-Castillo (MRISCOC) * Version: 1.0 * Date: 2021/11/06 + * + * Based on the original code provided by Creality under GPL */ class ESDiagClass { diff --git a/Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp similarity index 95% rename from Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp rename to Marlin/src/lcd/e3v2/proui/lockscreen.cpp index 8dc84dcc46..3f8339ad48 100644 --- a/Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -22,9 +22,11 @@ /** * Lock screen implementation for DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo + * Author: Miguel A. Risco-Castillo (MRISCOC) * Version: 2.1 * Date: 2021/11/09 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/lcd/e3v2/enhanced/lockscreen.h b/Marlin/src/lcd/e3v2/proui/lockscreen.h similarity index 92% rename from Marlin/src/lcd/e3v2/enhanced/lockscreen.h rename to Marlin/src/lcd/e3v2/proui/lockscreen.h index a51c82f34e..bf2fdb3f4b 100644 --- a/Marlin/src/lcd/e3v2/enhanced/lockscreen.h +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.h @@ -23,9 +23,11 @@ /** * Lock screen implementation for DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo + * Author: Miguel A. Risco-Castillo (MRISCOC) * Version: 2.1 * Date: 2021/11/09 + * + * Based on the original code provided by Creality under GPL */ #include "../common/encoder.h" diff --git a/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp similarity index 94% rename from Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp rename to Marlin/src/lcd/e3v2/proui/meshviewer.cpp index 1ecbbff0aa..0f63f77b99 100644 --- a/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -22,9 +22,11 @@ /** * DWIN Mesh Viewer - * Author: Miguel A. Risco-Castillo - * Version: 3.8.1 - * Date: 2021/11/06 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.9.1 + * Date: 2021/11/09 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" @@ -56,7 +58,7 @@ void MeshViewerClass::Draw() { #define DrawMeshHLine(yp) DWIN_Draw_HLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx) #define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(GRID_MAX_POINTS_Y - 1), DWIN_WIDTH - 2 * my) GRID_LOOP(x, y) { - const float v = Z_VALUES(x,y) * 100; + const float v = isnan(Z_VALUES(x,y)) ? 0 : round(Z_VALUES(x,y) * 100); zmesh[x][y] = v; NOLESS(maxz, v); NOMORE(minz, v); diff --git a/Marlin/src/lcd/e3v2/enhanced/meshviewer.h b/Marlin/src/lcd/e3v2/proui/meshviewer.h similarity index 87% rename from Marlin/src/lcd/e3v2/enhanced/meshviewer.h rename to Marlin/src/lcd/e3v2/proui/meshviewer.h index 6e7fe6fd82..acd5f0d5c4 100644 --- a/Marlin/src/lcd/e3v2/enhanced/meshviewer.h +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -23,9 +23,11 @@ /** * DWIN Mesh Viewer - * Author: Miguel A. Risco-Castillo - * Version: 3.8.1 - * Date: 2021/11/06 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.9.1 + * Date: 2021/11/09 + * + * Based on the original code provided by Creality under GPL */ class MeshViewerClass { diff --git a/Marlin/src/lcd/e3v2/enhanced/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp similarity index 94% rename from Marlin/src/lcd/e3v2/enhanced/printstats.cpp rename to Marlin/src/lcd/e3v2/proui/printstats.cpp index a32d698b96..ec14ebb8bf 100644 --- a/Marlin/src/lcd/e3v2/enhanced/printstats.cpp +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -22,9 +22,11 @@ /** * DWIN Print Stats page - * Author: Miguel A. Risco-Castillo - * Version: 1.0 - * Date: 2021/11/21 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.1 + * Date: 2022/01/09 + * + * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/lcd/e3v2/enhanced/printstats.h b/Marlin/src/lcd/e3v2/proui/printstats.h similarity index 87% rename from Marlin/src/lcd/e3v2/enhanced/printstats.h rename to Marlin/src/lcd/e3v2/proui/printstats.h index 5f62a4c268..f17e4dc9dd 100644 --- a/Marlin/src/lcd/e3v2/enhanced/printstats.h +++ b/Marlin/src/lcd/e3v2/proui/printstats.h @@ -23,9 +23,11 @@ /** * DWIN Print Stats page - * Author: Miguel A. Risco-Castillo - * Version: 1.0 - * Date: 2021/11/21 + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.1 + * Date: 2022/01/09 + * + * Based on the original code provided by Creality under GPL */ class PrintStatsClass { diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index fdb6df1808..3d579fbc97 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -49,7 +49,7 @@ MarlinUI ui; #include "e3v2/creality/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) #include "fontutils.h" - #include "e3v2/enhanced/dwin.h" + #include "e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "e3v2/jyersui/dwin.h" #endif @@ -104,7 +104,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif #if HAS_LCD_BRIGHTNESS - uint8_t MarlinUI::brightness = DEFAULT_LCD_BRIGHTNESS; + uint8_t MarlinUI::brightness = LCD_BRIGHTNESS_DEFAULT; bool MarlinUI::backlight = true; void MarlinUI::set_brightness(const uint8_t value) { diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 273abbe54a..5885866e5b 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -58,7 +58,7 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "e3v2/creality/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "e3v2/enhanced/dwin.h" + #include "e3v2/proui/dwin.h" #endif #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) @@ -263,8 +263,8 @@ public: #ifndef LCD_BRIGHTNESS_MAX #define LCD_BRIGHTNESS_MAX 255 #endif - #ifndef DEFAULT_LCD_BRIGHTNESS - #define DEFAULT_LCD_BRIGHTNESS LCD_BRIGHTNESS_MAX + #ifndef LCD_BRIGHTNESS_DEFAULT + #define LCD_BRIGHTNESS_DEFAULT LCD_BRIGHTNESS_MAX #endif static uint8_t brightness; static bool backlight; diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index cc3851597b..fdd6897192 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -80,7 +80,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" + #include "../lcd/e3v2/proui/dwin.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index ab498b7df3..7af91568bf 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -75,7 +75,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" + #include "../lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../lcd/e3v2/jyersui/dwin.h" #endif @@ -3028,7 +3028,7 @@ void MarlinSettings::reset() { // // LCD Brightness // - TERN_(HAS_LCD_BRIGHTNESS, ui.brightness = DEFAULT_LCD_BRIGHTNESS); + TERN_(HAS_LCD_BRIGHTNESS, ui.brightness = LCD_BRIGHTNESS_DEFAULT); // // Controller Fan diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index e59a9f49cb..1716ec79dd 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -52,7 +52,7 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" + #include "../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 59fdc4a3c9..ac11bd8b38 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -157,7 +157,7 @@ #if defined(TFT_BACKLIGHT_PWM) && !defined(MAPLE_STM32F1) #define HAS_LCD_BRIGHTNESS 1 - #define DEFAULT_LCD_BRIGHTNESS TFT_BACKLIGHT_PWM + #define LCD_BRIGHTNESS_DEFAULT TFT_BACKLIGHT_PWM #endif #if ENABLED(SDIO_SUPPORT) diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 8c1d08a460..9966773418 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -34,7 +34,7 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/e3v2/creality/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" + #include "../lcd/e3v2/proui/dwin.h" #endif #include "../module/planner.h" // for synchronize diff --git a/buildroot/tests/STM32F103RE_creality b/buildroot/tests/STM32F103RE_creality index 27fc26f0a0..257616ddd1 100755 --- a/buildroot/tests/STM32F103RE_creality +++ b/buildroot/tests/STM32F103RE_creality @@ -15,7 +15,7 @@ exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD -opt_enable DWIN_CREALITY_LCD_ENHANCED BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING +opt_enable DWIN_CREALITY_LCD_ENHANCED BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING BAUD_RATE_GCODE exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" diff --git a/ini/features.ini b/ini/features.ini index a1f80500e5..720748d7f0 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -46,7 +46,7 @@ SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https:/ SPI_EEPROM = src_filter=+ HAS_DWIN_E3V2|IS_DWIN_MARLINUI = src_filter=+ DWIN_CREALITY_LCD = src_filter=+ -DWIN_CREALITY_LCD_ENHANCED = src_filter=+ +DWIN_CREALITY_LCD_ENHANCED = src_filter=+ DWIN_CREALITY_LCD_JYERSUI = src_filter=+ IS_DWIN_MARLINUI = src_filter=+ HAS_GRAPHICAL_TFT = src_filter=+ diff --git a/platformio.ini b/platformio.ini index e1db73a4bd..8329cb494f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -51,7 +51,7 @@ lib_deps = default_src_filter = + - - + - - - - - - - - - - - - - + - - - - - - - - - - - From a8f3810f39cf33591aca369d174636336a707c07 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 6 Feb 2022 05:52:18 +1300 Subject: [PATCH 003/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20missing=20u8g=5Fes?= =?UTF-8?q?p32=5Fspi=20(#23562)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp | 99 +++++++++++++++++++++++ Marlin/src/lcd/dogm/HAL_LCD_com_defines.h | 5 ++ 2 files changed, 104 insertions(+) create mode 100644 Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp diff --git a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp new file mode 100644 index 0000000000..e454130d43 --- /dev/null +++ b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp @@ -0,0 +1,99 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * Copypaste of SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#ifdef ARDUINO_ARCH_ESP32 + +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(FYSETC_MINI_12864_2_1) + +#include +#include "Arduino.h" +#include "../shared/HAL_SPI.h" +#include "SPI.h" + +static SPISettings spiConfig; + +#define MDOGLCD_MOSI 23 +#define MDOGLCD_SCK 18 +#define MLCD_RESET_PIN 0 +#define MLCD_PINS_DC 4 +#define MDOGLCD_CS 21 +#define MDOGLCD_A0 4 + +#ifndef LCD_SPI_SPEED + #ifdef SD_SPI_SPEED + #define LCD_SPI_SPEED SD_SPI_SPEED // Assume SPI speed shared with SD + #else + #define LCD_SPI_SPEED SPI_FULL_SPEED // Use full speed if SD speed is not supplied + #endif +#endif + +uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT + if (msgInitCount) { + if (msg == U8G_COM_MSG_INIT) msgInitCount--; + if (msgInitCount) return -1; + } + + switch (msg) { + case U8G_COM_MSG_STOP: break; + + case U8G_COM_MSG_INIT: + OUT_WRITE(MDOGLCD_CS, HIGH); + OUT_WRITE(MDOGLCD_A0, HIGH); + OUT_WRITE(MLCD_RESET_PIN, HIGH); + u8g_Delay(5); + spiBegin(); + spiInit(LCD_SPI_SPEED); + break; + + case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ + WRITE(MDOGLCD_A0, arg_val ? HIGH : LOW); + break; + + case U8G_COM_MSG_CHIP_SELECT: /* arg_val == 0 means HIGH level of U8G_PI_CS */ + WRITE(MDOGLCD_CS, arg_val ? LOW : HIGH); + break; + + case U8G_COM_MSG_RESET: + WRITE(MLCD_RESET_PIN, arg_val); + break; + + case U8G_COM_MSG_WRITE_BYTE: + spiSend((uint8_t)arg_val); + break; + + case U8G_COM_MSG_WRITE_SEQ: + uint8_t *ptr = (uint8_t*) arg_ptr; + while (arg_val > 0) { + spiSend(*ptr++); + arg_val--; + } + break; + } + return 1; +} + +#endif // FYSETC_MINI_12864_2_1 +#endif // ARDUINO_ARCH_ESP32 diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index a30dd4ca17..e5c6524a9e 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -57,6 +57,11 @@ #define U8G_COM_HAL_SW_SPI_FN u8g_com_std_sw_spi_fn #define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn + #elif defined(ESP32) + + uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + #define U8G_COM_HAL_HW_SPI_FN u8g_eps_hw_spi_fn + #elif defined(__AVR__) uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); From dd4f93f90bd81eb6ea73031de05ed802dabb9d67 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 6 Feb 2022 00:23:02 +0000 Subject: [PATCH 004/203] [cron] Bump distribution date (2022-02-06) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 05d03d225d..1a27a0231f 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-05" +//#define STRING_DISTRIBUTION_DATE "2022-02-06" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 49601ff7aa..edd998a282 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-05" + #define STRING_DISTRIBUTION_DATE "2022-02-06" #endif /** From d987e23d5b47dc21e2c235969a6719c8f6673530 Mon Sep 17 00:00:00 2001 From: Bob Kuhn Date: Sun, 6 Feb 2022 08:35:18 -0600 Subject: [PATCH 005/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20init=20of=20delta?= =?UTF-8?q?=20safe=20height=20(for=20G29,=20G33,=20etc.)=20(#23622)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 4 ++++ Marlin/src/module/delta.cpp | 7 +++++++ Marlin/src/module/delta.h | 2 ++ Marlin/src/module/motion.cpp | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 420cc5186e..02cf6d28d3 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1339,6 +1339,10 @@ void setup() { SETUP_RUN(endstops.init()); // Init endstops and pullups + #if ENABLED(DELTA) && !HAS_SOFTWARE_ENDSTOPS + SETUP_RUN(refresh_delta_clip_start_height()); // Init safe delta height without soft endstops + #endif + SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts! #if HAS_SERVOS diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 2a4efb47da..cd40175da4 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -63,6 +63,13 @@ abc_float_t delta_diagonal_rod_trim; float delta_safe_distance_from_top(); +void refresh_delta_clip_start_height() { + delta_clip_start_height = TERN(HAS_SOFTWARE_ENDSTOPS, + soft_endstop.max.z, + DIFF_TERN(HAS_BED_PROBE, delta_height, probe.offset.z) + ) - delta_safe_distance_from_top(); +} + /** * Recalculate factors used for delta kinematics whenever * settings have been changed (e.g., by M665). diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index f1e43c7e4c..7cd42805c9 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -82,6 +82,8 @@ void inverse_kinematics(const xyz_pos_t &raw); */ float delta_safe_distance_from_top(); +void refresh_delta_clip_start_height(); + /** * Delta Forward Kinematics * diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 51f0681a15..4b0c6aba7d 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -743,7 +743,7 @@ void restore_feedrate_and_scaling() { delta_max_radius_2 = sq(delta_max_radius); break; case Z_AXIS: - delta_clip_start_height = soft_endstop.max[axis] - delta_safe_distance_from_top(); + refresh_delta_clip_start_height(); default: break; } From 029ff158bcdb820e3ae9bbf90f5cd13da0fe8345 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 7 Feb 2022 00:19:00 +0000 Subject: [PATCH 006/203] [cron] Bump distribution date (2022-02-07) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 1a27a0231f..09dc97342a 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-06" +//#define STRING_DISTRIBUTION_DATE "2022-02-07" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index edd998a282..151cc40d72 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-06" + #define STRING_DISTRIBUTION_DATE "2022-02-07" #endif /** From a8f95e325273f04fa8dd22df8c38de88f00a8fc5 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Mon, 7 Feb 2022 15:40:14 -0500 Subject: [PATCH 007/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Gen?= =?UTF-8?q?eric=20Maple=20STM32F103RC=20envs=20for=20devs=20(#23686)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/stm32f1-maple.ini | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 774c3b2efb..9ea848f1b6 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -111,6 +111,14 @@ extends = common_stm32f1 board = genericSTM32F103RE monitor_speed = 115200 +# +# Generic STM32F103RC environment +# +[env:STM32F103RC_maple] +extends = common_stm32f1 +board = genericSTM32F103RC +monitor_speed = 115200 + # # Creality (STM32F103RET6) # @@ -125,6 +133,20 @@ extra_scripts = ${common_stm32f1.extra_scripts} debug_tool = jlink upload_protocol = jlink +# +# Creality (STM32F103RCT6) +# +[env:STM32F103RC_creality_maple] +extends = env:STM32F103RC_maple +build_flags = ${common_stm32f1.build_flags} -DTEMP_TIMER_CHAN=4 +board_build.address = 0x08007000 +board_build.ldscript = creality.ld +extra_scripts = ${common_stm32f1.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/random-bin.py + buildroot/share/PlatformIO/scripts/custom_board.py +debug_tool = jlink +upload_protocol = jlink + # # BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # From 569f867ea98b7cea729dcbd469372e8f787bb113 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 8 Feb 2022 09:49:26 +1300 Subject: [PATCH 008/203] =?UTF-8?q?=F0=9F=9A=A8=20Cleaner=20errors=20for?= =?UTF-8?q?=20renamed=20envs=20(#23690)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/renamed.ini | 25 +++++++++++++++++++++++++ platformio.ini | 1 + 2 files changed, 26 insertions(+) create mode 100644 ini/renamed.ini diff --git a/ini/renamed.ini b/ini/renamed.ini new file mode 100644 index 0000000000..bc1e438d60 --- /dev/null +++ b/ini/renamed.ini @@ -0,0 +1,25 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# Renamed Environments # +# # +################################# + +# +# List of environment names that are no longer used +# + +[env:STM32F103RET6_creality_maple] +extends = env:STM32F103RE_maple + +[env:STM32F103RET6_creality] +extends = STM32F103Rx_creality +board = genericSTM32F103RE + +[env:STM32F103RET6_creality_xfer] +extends = STM32F103Rx_creality_xfer +board = genericSTM32F103RE diff --git a/platformio.ini b/platformio.ini index 8329cb494f..3a02b5ab18 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,6 +32,7 @@ extra_configs = ini/stm32h7.ini ini/stm32g0.ini ini/teensy.ini + ini/renamed.ini # # The 'common' section applies to most Marlin builds. From 3e93def08e4a765776ae7d2b94102943cd7dae01 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:22:18 -0500 Subject: [PATCH 009/203] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20Maple=20HAL=20comp?= =?UTF-8?q?ile=20errors=20(#23685)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/STM32F1/onboard_sd.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.cpp b/Marlin/src/HAL/STM32F1/onboard_sd.cpp index 582ee3853d..a3d8dcb2d5 100644 --- a/Marlin/src/HAL/STM32F1/onboard_sd.cpp +++ b/Marlin/src/HAL/STM32F1/onboard_sd.cpp @@ -38,8 +38,13 @@ #define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2 #endif -#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low -#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high +#if PIN_EXISTS(ONBOARD_SD_CS) && ONBOARD_SD_CS_PIN != SD_SS_PIN + #define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low + #define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high +#else + #define CS_LOW() + #define CS_HIGH() +#endif #define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX) #define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256) From c2fa7e594200a18856e61dcaaa8ef1a689a5121c Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:24:18 -0500 Subject: [PATCH 010/203] PLR accessors for Ext UI (#23687) --- Marlin/src/lcd/extui/ui_api.cpp | 9 +++++++++ Marlin/src/lcd/extui/ui_api.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index f2763c893f..f44e8bf720 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -94,6 +94,10 @@ #include "../../feature/caselight.h" #endif +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../feature/powerloss.h" +#endif + #if ENABLED(BABYSTEPPING) #include "../../feature/babystep.h" #endif @@ -674,6 +678,11 @@ namespace ExtUI { #endif #endif + #if ENABLED(POWER_LOSS_RECOVERY) + bool getPowerLossRecoveryEnabled() { return recovery.enabled; } + void setPowerLossRecoveryEnabled(const bool value) { recovery.enable(value); } + #endif + #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t extruder) { return (extruder < EXTRUDERS) ? planner.extruder_advance_K[extruder - E0] : 0; diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 59b509981b..6753c53740 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -315,6 +315,11 @@ namespace ExtUI { #endif #endif + #if ENABLED(POWER_LOSS_RECOVERY) + bool getPowerLossRecoveryEnabled(); + void setPowerLossRecoveryEnabled(const bool); + #endif + #if ENABLED(PIDTEMP) float getPIDValues_Kp(const extruder_t); float getPIDValues_Ki(const extruder_t); From 067faaceb19831c880a799e0285d0b1967192f4f Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 8 Feb 2022 00:29:22 +0000 Subject: [PATCH 011/203] [cron] Bump distribution date (2022-02-08) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 09dc97342a..497f49e284 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-07" +//#define STRING_DISTRIBUTION_DATE "2022-02-08" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 151cc40d72..d850015710 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-07" + #define STRING_DISTRIBUTION_DATE "2022-02-08" #endif /** From f84eb27c4c093ddc8db163a5d9860a234765dd12 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 8 Feb 2022 17:03:38 -0600 Subject: [PATCH 012/203] =?UTF-8?q?=F0=9F=94=A7=20Update=20MIXING=5FEXTRUD?= =?UTF-8?q?ER=20sanity=20checks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixing #23693 --- Marlin/src/inc/SanityCheck.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1177cbcd14..79c071cf00 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1226,14 +1226,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "For MIXING_EXTRUDER set MIXING_STEPPERS > 1 instead of EXTRUDERS > 1." #elif MIXING_STEPPERS < 2 #error "You must set MIXING_STEPPERS >= 2 for a mixing extruder." - #elif ENABLED(FILAMENT_SENSOR) - #error "MIXING_EXTRUDER is incompatible with FILAMENT_SENSOR. Comment out this line to use it anyway." + #elif ENABLED(FILAMENT_WIDTH_SENSOR) + #error "MIXING_EXTRUDER is incompatible with FILAMENT_WIDTH_SENSOR. Comment out this line to use it anyway." #elif ENABLED(SWITCHING_EXTRUDER) #error "Please select either MIXING_EXTRUDER or SWITCHING_EXTRUDER, not both." #elif ENABLED(SINGLENOZZLE) #error "MIXING_EXTRUDER is incompatible with SINGLENOZZLE." #elif ENABLED(DISABLE_INACTIVE_EXTRUDER) #error "MIXING_EXTRUDER is incompatible with DISABLE_INACTIVE_EXTRUDER." + #elif HAS_FILAMENT_RUNOUT_DISTANCE + #error "MIXING_EXTRUDER is incompatible with FILAMENT_RUNOUT_DISTANCE_MM." #endif #endif From 7763f9385d506ef79ef81ccb48a972ab56050fb1 Mon Sep 17 00:00:00 2001 From: Taylor Talkington Date: Tue, 8 Feb 2022 18:36:06 -0500 Subject: [PATCH 013/203] =?UTF-8?q?=E2=9C=A8=20Optional=20HOST=5FSTATUS=5F?= =?UTF-8?q?NOTIFICATIONS=20(#22833)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 11 +++++++---- Marlin/src/gcode/control/M111.cpp | 8 ++++++++ Marlin/src/inc/SanityCheck.h | 6 ------ Marlin/src/inc/Warnings.cpp | 10 ++++++++++ Marlin/src/lcd/marlinui.cpp | 7 +++++-- Marlin/src/module/printcounter.cpp | 1 - Marlin/src/module/settings.cpp | 23 ++++++++++++++++++++--- Marlin/src/module/temperature.cpp | 4 ++++ buildroot/tests/rambo | 2 +- 9 files changed, 55 insertions(+), 17 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index cf30684e89..f2676828ff 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3952,10 +3952,13 @@ */ //#define HOST_ACTION_COMMANDS #if ENABLED(HOST_ACTION_COMMANDS) - //#define HOST_PAUSE_M76 - //#define HOST_PROMPT_SUPPORT - //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start - //#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down + //#define HOST_PAUSE_M76 // Tell the host to pause in response to M76 + //#define HOST_PROMPT_SUPPORT // Initiate host prompts to get user feedback + #if ENABLED(HOST_PROMPT_SUPPORT) + //#define HOST_STATUS_NOTIFICATIONS // Send some status messages to the host as notifications + #endif + //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start + //#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down #endif /** diff --git a/Marlin/src/gcode/control/M111.cpp b/Marlin/src/gcode/control/M111.cpp index d6aeb77410..846bf70556 100644 --- a/Marlin/src/gcode/control/M111.cpp +++ b/Marlin/src/gcode/control/M111.cpp @@ -22,12 +22,20 @@ #include "../gcode.h" +#if ENABLED(HOST_ACTION_COMMANDS) + #include "../../feature/host_actions.h" +#endif + /** * M111: Set the debug level */ void GcodeSuite::M111() { if (parser.seenval('S')) marlin_debug_flags = parser.value_byte(); + #if EITHER(HOST_ACTION_COMMANDS, HOST_PROMPT_SUPPORT) + if (parser.seenval('H')) hostui.flag.bits = parser.value_byte(); + #endif + static PGMSTR(str_debug_1, STR_DEBUG_ECHO); static PGMSTR(str_debug_2, STR_DEBUG_INFO); static PGMSTR(str_debug_4, STR_DEBUG_ERRORS); diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 79c071cf00..f154592f4e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -611,12 +611,6 @@ #error "DEFAULT_LCD_BRIGHTNESS is now LCD_BRIGHTNESS_DEFAULT." #endif -#if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) - #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." -#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) - #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." -#endif - constexpr float arm[] = AXIS_RELATIVE_MODES; static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _LOGICAL_AXES_STR "elements."); diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index a22b33d7c9..95246343c7 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -59,6 +59,12 @@ #warning "Your Configuration provides no method to acquire user feedback!" #endif +#if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) + #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." +#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) + #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." +#endif + #ifndef NO_AUTO_ASSIGN_WARNING #if AUTO_ASSIGNED_X2_STEPPER @@ -541,6 +547,10 @@ #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225)." #endif +#if PRINTCOUNTER_SYNC + #warning "To prevent step loss, motion will pause for PRINTCOUNTER auto-save." +#endif + #if HOMING_Z_WITH_PROBE && IS_CARTESIAN && DISABLED(Z_SAFE_HOMING) #error "Z_SAFE_HOMING is recommended when homing with a probe. Enable Z_SAFE_HOMING or comment out this line to continue." #endif diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 3d579fbc97..27965c1bd4 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1363,7 +1363,7 @@ void MarlinUI::init() { void MarlinUI::set_status(const char * const cstr, const bool persist) { if (alert_level) return; - TERN_(HOST_PROMPT_SUPPORT, hostui.notify(cstr)); + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(cstr)); // Here we have a problem. The message is encoded in UTF8, so // arbitrarily cutting it will be a problem. We MUST be sure @@ -1435,7 +1435,7 @@ void MarlinUI::init() { if (level < alert_level) return; alert_level = level; - TERN_(HOST_PROMPT_SUPPORT, hostui.notify(fstr)); + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr)); // Since the message is encoded in UTF8 it must // only be cut on a character boundary. @@ -1473,6 +1473,9 @@ void MarlinUI::init() { va_start(args, FTOP(fmt)); vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, FTOP(fmt), args); va_end(args); + + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(status_message)); + finish_status(level > 0); } diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index 27dee76715..affb608780 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -43,7 +43,6 @@ Stopwatch print_job_timer; // Global Print Job Timer instance #if PRINTCOUNTER_SYNC #include "../module/planner.h" - #warning "To prevent step loss, motion will pause for PRINTCOUNTER auto-save." #endif // Service intervals diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 7af91568bf..8c2cd8813d 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -80,6 +80,10 @@ #include "../lcd/e3v2/jyersui/dwin.h" #endif +#if ENABLED(HOST_PROMPT_SUPPORT) + #include "../feature/host_actions.h" +#endif + #if HAS_SERVOS #include "servo.h" #endif @@ -652,6 +656,10 @@ void MarlinSettings::postprocess() { #define DEBUG_OUT EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) #include "../core/debug_out.h" +#if BOTH(EEPROM_CHITCHAT, HOST_PROMPT_SUPPORT) + #define HOST_EEPROM_CHITCHAT 1 +#endif + #if ENABLED(EEPROM_SETTINGS) #define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_ERROR_MSG(ERR); eeprom_error = true; } }while(0) @@ -1554,7 +1562,10 @@ void MarlinSettings::postprocess() { store_mesh(ubl.storage_slot); #endif - if (!eeprom_error) LCD_MESSAGE(MSG_SETTINGS_STORED); + if (!eeprom_error) { + LCD_MESSAGE(MSG_SETTINGS_STORED); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_SETTINGS_STORED))); + } TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreWritten(!eeprom_error)); @@ -1578,6 +1589,7 @@ void MarlinSettings::postprocess() { } DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_VERSION)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_VERSION))); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version()); eeprom_error = true; @@ -2468,12 +2480,14 @@ void MarlinSettings::postprocess() { eeprom_error = true; DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_CRC)); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_CRC))); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc()); } else if (!validating) { DEBUG_ECHO_START(); DEBUG_ECHO(version); DEBUG_ECHOLNPGM(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)working_crc, ")"); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(F("Stored settings retrieved"))); } if (!validating && !eeprom_error) postprocess(); @@ -2783,7 +2797,6 @@ void MarlinSettings::reset() { #endif #endif - TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_SetDataDefaults()); TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Reset_Settings()); @@ -3142,7 +3155,11 @@ void MarlinSettings::reset() { postprocess(); - DEBUG_ECHO_MSG("Hardcoded Default Settings Loaded"); + FSTR_P const hdsl = F("Hardcoded Default Settings Loaded"); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(hdsl)); + DEBUG_ECHO_START(); DEBUG_ECHOLNF(hdsl); + + TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); } #if DISABLED(DISABLE_M503) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1716ec79dd..4ccd984b0d 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -629,6 +629,7 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); return; } @@ -719,6 +720,7 @@ volatile bool Temperature::raw_temps_ready = false; SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); break; } @@ -756,12 +758,14 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT))); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); break; } if (cycles > ncycles && cycles > 2) { SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE))); #if EITHER(PIDTEMPBED, PIDTEMPCHAMBER) FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR)); diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index 92e8bc2b5f..e696dce96e 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -115,7 +115,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ FAN_MIN_PWM 50 FAN_KICKSTART_TIME 100 \ XY_FREQUENCY_LIMIT 15 opt_enable COREYX USE_XMAX_PLUG MIXING_EXTRUDER GRADIENT_MIX \ - BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY FILAMENT_WIDTH_SENSOR \ + BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER MENU_ADDAUTOSTART SDSUPPORT SDCARD_SORT_ALPHA \ ENDSTOP_NOISE_THRESHOLD FAN_SOFT_PWM \ FIX_MOUNTED_PROBE PROBING_ESTEPPERS_OFF PROBE_OFFSET_WIZARD \ From 2d04e5733aad05a3646ebc3b37ecde25d479589d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 8 Feb 2022 18:02:28 -0600 Subject: [PATCH 014/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Dro?= =?UTF-8?q?p=20hostui.flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/host_actions.cpp | 8 -------- Marlin/src/feature/host_actions.h | 8 -------- Marlin/src/gcode/control/M111.cpp | 8 -------- 3 files changed, 24 deletions(-) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index be7b055b55..c03a6bc597 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -39,10 +39,7 @@ HostUI hostui; -flag_t HostUI::flag; - void HostUI::action(FSTR_P const fstr, const bool eol) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); SERIAL_ECHOPGM("//action:"); SERIAL_ECHOF(fstr); @@ -96,21 +93,18 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { #endif void HostUI::notify(const char * const cstr) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("notification "), false); SERIAL_ECHOLN(cstr); } void HostUI::notify_P(PGM_P const pstr) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("notification "), false); SERIAL_ECHOLNPGM_P(pstr); } void HostUI::prompt(FSTR_P const ptype, const bool eol/*=true*/) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("prompt_"), false); SERIAL_ECHOF(ptype); @@ -118,7 +112,6 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { } void HostUI::prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char/*='\0'*/) { - if (!flag.bits) return; prompt(ptype, false); PORT_REDIRECT(SerialMask::All); SERIAL_CHAR(' '); @@ -127,7 +120,6 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { SERIAL_EOL(); } void HostUI::prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) { - if (!flag.bits) return; prompt_end(); host_prompt_reason = reason; prompt_plus(F("begin"), fstr, extra_char); diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index 78a7821eba..41d66b82ec 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -24,11 +24,6 @@ #include "../inc/MarlinConfigPre.h" #include "../HAL/shared/Marduino.h" -typedef union { - uint8_t bits; - struct { bool info:1, errors:1, debug:1; }; -} flag_t; - #if ENABLED(HOST_PROMPT_SUPPORT) enum PromptReason : uint8_t { @@ -45,9 +40,6 @@ typedef union { class HostUI { public: - static flag_t flag; - HostUI() { flag.bits = 0xFF; } - static void action(FSTR_P const fstr, const bool eol=true); #ifdef ACTION_ON_KILL diff --git a/Marlin/src/gcode/control/M111.cpp b/Marlin/src/gcode/control/M111.cpp index 846bf70556..d6aeb77410 100644 --- a/Marlin/src/gcode/control/M111.cpp +++ b/Marlin/src/gcode/control/M111.cpp @@ -22,20 +22,12 @@ #include "../gcode.h" -#if ENABLED(HOST_ACTION_COMMANDS) - #include "../../feature/host_actions.h" -#endif - /** * M111: Set the debug level */ void GcodeSuite::M111() { if (parser.seenval('S')) marlin_debug_flags = parser.value_byte(); - #if EITHER(HOST_ACTION_COMMANDS, HOST_PROMPT_SUPPORT) - if (parser.seenval('H')) hostui.flag.bits = parser.value_byte(); - #endif - static PGMSTR(str_debug_1, STR_DEBUG_ECHO); static PGMSTR(str_debug_2, STR_DEBUG_INFO); static PGMSTR(str_debug_4, STR_DEBUG_ERRORS); From 1e18ce6e5d919372409dd0ce0e2b9487a5a8dbdc Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 9 Feb 2022 00:23:37 +0000 Subject: [PATCH 015/203] [cron] Bump distribution date (2022-02-09) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 497f49e284..70169b6965 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-08" +//#define STRING_DISTRIBUTION_DATE "2022-02-09" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index d850015710..1674b4c1e0 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-08" + #define STRING_DISTRIBUTION_DATE "2022-02-09" #endif /** From 0a24f858f3009b358c3c0841654521146949261a Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Thu, 10 Feb 2022 05:46:53 +1300 Subject: [PATCH 016/203] =?UTF-8?q?=F0=9F=9A=B8=20Restore=20active=20tool?= =?UTF-8?q?=20after=20ABL=20G29=20(#23692)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 4 ++-- Marlin/src/gcode/bedlevel/G35.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 15395bcc8d..023d0c5b1d 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -316,7 +316,7 @@ void unified_bed_leveling::G29() { planner.synchronize(); // Send 'N' to force homing before G29 (internal only) if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes(); - TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); + TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true)); } // Invalidate one or more nearby mesh points, possibly all. @@ -663,7 +663,7 @@ void unified_bed_leveling::G29() { UNUSED(probe_deployed); #endif - TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index)); + TERN_(HAS_MULTI_HOTEND, if (old_tool_index != 0) tool_change(old_tool_index)); return; } diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 4dd1323a6c..dd828bf0c8 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -155,7 +155,7 @@ void GcodeSuite::G35() { // Restore the active tool after homing #if HAS_MULTI_HOTEND - tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER + if (old_tool_index != 0) tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER #endif #if BOTH(HAS_LEVELING, RESTORE_LEVELING_AFTER_G35) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index fddca22c32..9ec43fe49d 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -93,6 +93,10 @@ public: bool dryrun, reenable; + #if HAS_MULTI_HOTEND + uint8_t tool_index; + #endif + #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) int abl_probe_index; #endif @@ -263,7 +267,10 @@ G29_TYPE GcodeSuite::G29() { */ if (!g29_in_progress) { - TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); + #if HAS_MULTI_HOTEND + abl.tool_index = active_extruder; + if (active_extruder != 0) tool_change(0, true); + #endif #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) abl.abl_probe_index = -1; @@ -891,6 +898,8 @@ G29_TYPE GcodeSuite::G29() { TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling()); + TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index)); + report_current_position(); TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); From a323d6732bf691d29ce996b6bfd11cbcc3c9f0a7 Mon Sep 17 00:00:00 2001 From: MOHAMMAD RASIM Date: Wed, 9 Feb 2022 21:29:34 +0300 Subject: [PATCH 017/203] =?UTF-8?q?=F0=9F=9A=B8=20Fix,=20Improve=20Power-L?= =?UTF-8?q?oss=20Recovery=20(#22828)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/feature/powerloss.cpp | 43 ++++++++++++++------- Marlin/src/feature/powerloss.h | 4 +- Marlin/src/gcode/calibrate/G28.cpp | 11 ++++-- Marlin/src/gcode/feature/powerloss/M413.cpp | 5 +-- Marlin/src/inc/SanityCheck.h | 2 - Marlin/src/module/planner.cpp | 6 ++- Marlin/src/module/planner.h | 3 +- Marlin/src/module/stepper.cpp | 5 ++- 8 files changed, 51 insertions(+), 28 deletions(-) diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 723ec1903b..214c248d35 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -54,6 +54,10 @@ uint32_t PrintJobRecovery::cmd_sdpos, // = 0 #include "../module/temperature.h" #include "../core/serial.h" +#if HOMING_Z_WITH_PROBE + #include "../module/probe.h" +#endif + #if ENABLED(FWRETRACT) #include "fwretract.h" #endif @@ -178,7 +182,8 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW info.valid_foot = info.valid_head; // Machine state - info.current_position = current_position; + // info.sdpos and info.current_position are pre-filled from the Stepper ISR + info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s)); info.zraise = zraise; info.flag.raised = raised; // Was Z raised before power-off? @@ -265,6 +270,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW #endif +#endif // POWER_LOSS_PIN + +#if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY) + /** * An outage was detected by a sensor pin. * - If not SD printing, let the machine turn off on its own with no "KILL" screen @@ -273,7 +282,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW * - If backup power is available Retract E and Raise Z * - Go to the KILL screen */ - void PrintJobRecovery::_outage() { + void PrintJobRecovery::_outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated/*=false*/)) { #if ENABLED(BACKUP_POWER_SUPPLY) static bool lock = false; if (lock) return; // No re-entrance from idle() during retract_and_lift() @@ -301,10 +310,16 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW retract_and_lift(zraise); #endif - kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); + if (TERN0(DEBUG_POWER_LOSS_RECOVERY, simulated)) { + card.fileHasFinished(); + current_position.reset(); + sync_plan_position(); + } + else + kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); } -#endif +#endif // POWER_LOSS_PIN || DEBUG_POWER_LOSS_RECOVERY /** * Save the recovery info the recovery file @@ -390,14 +405,12 @@ void PrintJobRecovery::resume() { #if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS) #define HOMING_Z_DOWN 1 - #else - #define HOME_XY_ONLY 1 #endif float z_now = info.flag.raised ? z_raised : z_print; - // Reset E to 0 and set Z to the real position - #if HOME_XY_ONLY + #if !HOMING_Z_DOWN + // Set Z to the real position sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 3, str_1)); gcode.process_subcommands_now(cmd); #endif @@ -409,15 +422,15 @@ void PrintJobRecovery::resume() { gcode.process_subcommands_now(cmd); } - // Home XY with no Z raise, and also home Z here if Z isn't homing down below. - gcode.process_subcommands_now(F("G28R0" TERN_(HOME_XY_ONLY, "XY"))); // No raise during G28 + // Home XY with no Z raise + gcode.process_subcommands_now(F("G28R0XY")); // No raise during G28 #endif #if HOMING_Z_DOWN // Move to a safe XY position and home Z while avoiding the print. - constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS; - sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2)); + const xy_pos_t p = xy_pos_t(POWER_LOSS_ZHOME_POS) TERN_(HOMING_Z_WITH_PROBE, - probe.offset_xy); + sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28HZ"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2)); gcode.process_subcommands_now(cmd); #endif @@ -431,7 +444,7 @@ void PrintJobRecovery::resume() { sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1)); gcode.process_subcommands_now(cmd); - #if HOME_XY_ONLY + #if !HOMING_Z_DOWN // The physical Z was adjusted at power-off so undo the M420S1 correction to Z with G92.9. sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 1, str_1)); gcode.process_subcommands_now(cmd); @@ -513,12 +526,12 @@ void PrintJobRecovery::resume() { // Un-retract if there was a retract at outage #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0 - gcode.process_subcommands_now(F("G1E" STRINGIFY(POWER_LOSS_RETRACT_LEN) "F3000")); + gcode.process_subcommands_now(F("G1F3000E" STRINGIFY(POWER_LOSS_RETRACT_LEN))); #endif // Additional purge on resume if configured #if POWER_LOSS_PURGE_LEN - sprintf_P(cmd, PSTR("G1 E%d F3000"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN)); + sprintf_P(cmd, PSTR("G1F3000E%d"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN)); gcode.process_subcommands_now(cmd); #endif diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 50abad9222..4e97109bb7 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -216,9 +216,9 @@ class PrintJobRecovery { static void retract_and_lift(const_float_t zraise); #endif - #if PIN_EXISTS(POWER_LOSS) + #if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY) friend class GcodeSuite; - static void _outage(); + static void _outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated=false)); #endif }; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 48f02d2a33..606f6ad031 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -395,9 +395,10 @@ void GcodeSuite::G28() { TERN_(HOME_Z_FIRST, if (doZ) homeaxis(Z_AXIS)); - const float z_homing_height = parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT; + const bool seenR = parser.seenval('R'); + const float z_homing_height = seenR ? parser.value_linear_units() : Z_HOMING_HEIGHT; - if (z_homing_height && (LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { + if (z_homing_height && (seenR || LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { // Raise Z before homing any other axes and z is not already high enough (never lower z) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Raise Z (before homing) by ", z_homing_height); do_z_clearance(z_homing_height); @@ -451,7 +452,11 @@ void GcodeSuite::G28() { stepper.set_separate_multi_axis(false); #endif - TERN(Z_SAFE_HOMING, home_z_safely(), homeaxis(Z_AXIS)); + #if ENABLED(Z_SAFE_HOMING) + if (TERN1(POWER_LOSS_RECOVERY, !parser.seen_test('H'))) home_z_safely(); else homeaxis(Z_AXIS); + #else + homeaxis(Z_AXIS); + #endif probe.move_z_after_homing(); } #endif diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 0ccbfe6341..4807d3e8f9 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -48,9 +48,8 @@ void GcodeSuite::M413() { if (parser.seen_test('W')) recovery.save(true); if (parser.seen_test('P')) recovery.purge(); if (parser.seen_test('D')) recovery.debug(F("M413")); - #if PIN_EXISTS(POWER_LOSS) - if (parser.seen_test('O')) recovery._outage(); - #endif + if (parser.seen_test('O')) recovery._outage(true); + if (parser.seen_test('C')) recovery.check(); if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n")); if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n")); #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f154592f4e..38c2866ca1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3447,8 +3447,6 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(BACKUP_POWER_SUPPLY) && !PIN_EXISTS(POWER_LOSS) #error "BACKUP_POWER_SUPPLY requires a POWER_LOSS_PIN." - #elif BOTH(POWER_LOSS_RECOVER_ZHOME, Z_SAFE_HOMING) - #error "POWER_LOSS_RECOVER_ZHOME cannot be used with Z_SAFE_HOMING." #elif BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN) #error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time." #elif ENABLED(POWER_LOSS_RECOVER_ZHOME) && Z_HOME_TO_MAX diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 8d8f44dc78..f9ddcf8f13 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2809,9 +2809,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move, position = target; // Update the position + #if ENABLED(POWER_LOSS_RECOVERY) + block->sdpos = recovery.command_sdpos(); + block->start_position = position_float.asLogical(); + #endif + TERN_(HAS_POSITION_FLOAT, position_float = target_float); TERN_(GRADIENT_MIX, mixer.gradient_control(target_float.z)); - TERN_(POWER_LOSS_RECOVERY, block->sdpos = recovery.command_sdpos()); return true; // Movement was accepted diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 380c35755c..f29604bea8 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -244,6 +244,7 @@ typedef struct block_t { #if ENABLED(POWER_LOSS_RECOVERY) uint32_t sdpos; + xyze_pos_t start_position; #endif #if ENABLED(LASER_POWER_INLINE) @@ -252,7 +253,7 @@ typedef struct block_t { } block_t; -#if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL) +#if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL, POWER_LOSS_RECOVERY) #define HAS_POSITION_FLOAT 1 #endif diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index ae8a1ef078..5da06a5e50 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2151,7 +2151,10 @@ uint32_t Stepper::block_phase_isr() { cutter.apply_power(current_block->cutter_power); #endif - TERN_(POWER_LOSS_RECOVERY, recovery.info.sdpos = current_block->sdpos); + #if ENABLED(POWER_LOSS_RECOVERY) + recovery.info.sdpos = current_block->sdpos; + recovery.info.current_position = current_block->start_position; + #endif #if ENABLED(DIRECT_STEPPING) if (IS_PAGE(current_block)) { From ae96892612645c9b694186d463a8708fc3bce874 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 10 Feb 2022 00:20:36 +0000 Subject: [PATCH 018/203] [cron] Bump distribution date (2022-02-10) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 70169b6965..0831287429 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-09" +//#define STRING_DISTRIBUTION_DATE "2022-02-10" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 1674b4c1e0..3283615dc3 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-09" + #define STRING_DISTRIBUTION_DATE "2022-02-10" #endif /** From 191d25f917f518149756a3f29562674076d1def8 Mon Sep 17 00:00:00 2001 From: Mads Ynddal <5528170+Baekalfen@users.noreply.github.com> Date: Thu, 10 Feb 2022 18:58:36 +0100 Subject: [PATCH 019/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20XYZEval::set(XY,?= =?UTF-8?q?=20Z)=20and=20(XY,=20Z,=20E)=20(#23704)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix regression in #21953 Co-authored-by: Scott Lahteine --- Marlin/src/core/types.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index aee25a0dff..b95b595659 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -536,19 +536,9 @@ struct XYZEval { // Reset all to 0 FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =) 0; } - // Setters taking struct types and arrays - FI void set(const T px) { x = px; } - FI void set(const T px, const T py) { x = px; y = py; } - FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } - FI void set(const XYZval pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); } - #if HAS_Z_AXIS - FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k); } - #endif - #if LOGICAL_AXES > LINEAR_AXES - FI void set(const XYval pxy, const T pe) { set(pxy); e = pe; } - FI void set(const XYZval pxyz, const T pe) { set(pxyz); e = pe; } - FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, u = i, v = j, w = k); } - #endif + // Setters for some number of linear axes, not all + FI void set(const T px) { x = px; } + FI void set(const T px, const T py) { x = px; y = py; } #if HAS_I_AXIS FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } #endif @@ -558,6 +548,18 @@ struct XYZEval { #if HAS_K_AXIS FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } #endif + // Setters taking struct types and arrays + FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } + FI void set(const XYZval pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); } + #if HAS_Z_AXIS + FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k); } + #endif + FI void set(const XYval pxy, const T pz) { set(pxy); TERN_(HAS_Z_AXIS, z = pz); } + #if LOGICAL_AXES > LINEAR_AXES + FI void set(const XYval pxy, const T pz, const T pe) { set(pxy, pz); e = pe; } + FI void set(const XYZval pxyz, const T pe) { set(pxyz); e = pe; } + FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, u = i, v = j, w = k); } + #endif // Length reduced to one dimension FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k)); } From 5520aa3a10453d9245854aeed88583f11c34cab2 Mon Sep 17 00:00:00 2001 From: espr14 Date: Thu, 10 Feb 2022 20:28:38 +0100 Subject: [PATCH 020/203] =?UTF-8?q?=F0=9F=A9=B9=20Simplify=20quick=20homin?= =?UTF-8?q?g=20feedrate=20(#23714)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/gcode/calibrate/G28.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 606f6ad031..a38c567939 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -76,10 +76,9 @@ const int x_axis_home_dir = TOOL_X_HOME_DIR(active_extruder); - const float mlx = max_length(X_AXIS), - mly = max_length(Y_AXIS), - mlratio = mlx > mly ? mly / mlx : mlx / mly, - fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0); + // Use a higher diagonal feedrate so axes move at homing speed + const float minfr = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)), + fr_mm_s = HYPOT(minfr, minfr); #if ENABLED(SENSORLESS_HOMING) sensorless_t stealth_states { @@ -95,7 +94,7 @@ }; #endif - do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * Y_HOME_DIR, fr_mm_s); + do_blocking_move_to_xy(1.5 * max_length(X_AXIS) * x_axis_home_dir, 1.5 * max_length(Y_AXIS) * Y_HOME_DIR, fr_mm_s); endstops.validate_homing_move(); From 267a44c95cc09b6ca54c485320bdbccebe20af7a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 10 Feb 2022 13:58:50 -0600 Subject: [PATCH 021/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Wra?= =?UTF-8?q?p=20MMU1=20pins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/linux/pins_RAMPS_LINUX.h | 18 +++++++++-------- Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h | 10 ++++++---- Marlin/src/pins/rambo/pins_EINSY_RAMBO.h | 8 +++++--- Marlin/src/pins/rambo/pins_EINSY_RETRO.h | 8 +++++--- Marlin/src/pins/rambo/pins_MINIRAMBO.h | 10 ++++++---- Marlin/src/pins/rambo/pins_RAMBO.h | 8 +++++--- Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h | 4 +++- Marlin/src/pins/ramps/pins_RAMPS.h | 18 +++++++++-------- Marlin/src/pins/ramps/pins_RAMPS_S_12.h | 18 +++++++++-------- Marlin/src/pins/ramps/pins_TT_OSCAR.h | 20 ++++++++++--------- Marlin/src/pins/stm32f4/pins_LERDGE_S.h | 6 ++++-- Marlin/src/pins/stm32f4/pins_VAKE403D.h | 6 ++++-- 12 files changed, 79 insertions(+), 55 deletions(-) diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 372f967652..e2efdfa492 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -234,14 +234,16 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 40 // Z_CS_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 42 // E0_CS_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 44 // E1_CS_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 40 // Z_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 42 // E0_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 44 // E1_CS_PIN + #endif #endif /** diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index ee9d0e8c7a..b08ac536b3 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -258,11 +258,13 @@ // // Průša i3 MK2 Multiplexer Support // -#if SERIAL_PORT != 0 && SERIAL_PORT_2 != 0 - #define E_MUX0_PIN P0_03 // ( 0) Z_CS_PIN - #define E_MUX1_PIN P0_02 // ( 1) E0_CS_PIN +#if HAS_PRUSA_MMU1 + #if SERIAL_PORT != 0 && SERIAL_PORT_2 != 0 + #define E_MUX0_PIN P0_03 // ( 0) Z_CS_PIN + #define E_MUX1_PIN P0_02 // ( 1) E0_CS_PIN + #endif + #define E_MUX2_PIN P0_26 // (63) E1_CS_PIN #endif -#define E_MUX2_PIN P0_26 // (63) E1_CS_PIN /** * LCD / Controller diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index a7d1a62820..9150bf1365 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -163,9 +163,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#endif // // LCD / Controller diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index 165475dae8..8bc0a90c05 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -157,9 +157,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#endif // // LCD / Controller diff --git a/Marlin/src/pins/rambo/pins_MINIRAMBO.h b/Marlin/src/pins/rambo/pins_MINIRAMBO.h index ab25e2e692..31d44f2b34 100644 --- a/Marlin/src/pins/rambo/pins_MINIRAMBO.h +++ b/Marlin/src/pins/rambo/pins_MINIRAMBO.h @@ -130,10 +130,12 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#if !MB(MINIRAMBO_10A) - #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #if !MB(MINIRAMBO_10A) + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 + #endif #endif // diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index f27bced623..5484b193b9 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -186,9 +186,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 84 // 84 in MK2 Firmware +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 84 // 84 in MK2 Firmware +#endif // // LCD / Controller diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index 729a82b9c6..a7817c6f3a 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -105,7 +105,9 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX2_PIN -1 +#if HAS_PRUSA_MMU1 + #define E_MUX2_PIN -1 +#endif // // Misc. Functions diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 70da23af73..29caaf0533 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -412,14 +412,16 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 40 // Z_CS_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 42 // E0_CS_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 44 // E1_CS_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 40 // Z_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 42 // E0_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 44 // E1_CS_PIN + #endif #endif // diff --git a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h index e1ba91cde8..f41573b527 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h @@ -233,14 +233,16 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 29 // E2_STEP_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 28 // E2_DIR_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 39 // E2_ENABLE_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 29 // E2_STEP_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 28 // E2_DIR_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 39 // E2_ENABLE_PIN + #endif #endif ////////////////////////// diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index 277b1af2de..9d844ebcdc 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -252,15 +252,17 @@ // // Průša i3 MK2 Multiplexer Support // -//#ifndef E_MUX0_PIN -// #define E_MUX0_PIN 58 // Y_CS_PIN -//#endif -//#ifndef E_MUX1_PIN -// #define E_MUX1_PIN 53 // Z_CS_PIN -//#endif -//#ifndef E_MUX2_PIN -// #define E_MUX2_PIN 49 // En_CS_PIN -//#endif +#if 0 && HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 58 // Y_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 53 // Z_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 49 // En_CS_PIN + #endif +#endif ////////////////////////// // LCDs and Controllers // diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h index c904d57a1f..e4fc97170c 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h @@ -133,8 +133,10 @@ // // Průša i3 MK2 Multi Material Multiplexer Support // -//#define E_MUX0_PIN -1 -//#define E_MUX1_PIN -1 +#if HAS_PRUSA_MMU1 + //#define E_MUX0_PIN -1 + //#define E_MUX1_PIN -1 +#endif // // LED / Lighting diff --git a/Marlin/src/pins/stm32f4/pins_VAKE403D.h b/Marlin/src/pins/stm32f4/pins_VAKE403D.h index bb5507b29a..c6b24f9eca 100644 --- a/Marlin/src/pins/stm32f4/pins_VAKE403D.h +++ b/Marlin/src/pins/stm32f4/pins_VAKE403D.h @@ -150,8 +150,10 @@ // // Průša i3 MK2 Multi Material Multiplexer Support // -//#define E_MUX0_PIN PG3 -//#define E_MUX1_PIN PG4 +#if HAS_PRUSA_MMU1 + //#define E_MUX0_PIN PG3 + //#define E_MUX1_PIN PG4 +#endif #define LED_PIN PB14 // Alive #define PS_ON_PIN PE0 From f2d1770cee926d4b08c7d055ed92fb828d1f53d4 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 11 Feb 2022 04:02:45 +0800 Subject: [PATCH 022/203] =?UTF-8?q?=E2=9C=A8=20Pxmalion=20Core=20i3=20(#23?= =?UTF-8?q?711)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 1 + Marlin/src/pins/pins.h | 2 + Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h | 86 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 21c0eaaf30..4435452005 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -116,6 +116,7 @@ #define BOARD_LONGER3D_LK1_PRO 1160 // Longer LK1 PRO / Alfawise U20 Pro (PRO version) #define BOARD_LONGER3D_LKx_PRO 1161 // Longer LKx PRO / Alfawise Uxx Pro (PRO version) #define BOARD_ZRIB_V53 1162 // Zonestar zrib V5.3 (Chinese RAMPS replica) +#define BOARD_PXMALION_CORE_I3 1163 // Pxmalion Core I3 // // RAMBo and derivatives diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 4ba97a77a7..0afff4bd42 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -201,6 +201,8 @@ #include "ramps/pins_RAMPS_S_12.h" // ATmega2560 env:mega2560 #elif MB(LONGER3D_LK1_PRO, LONGER3D_LKx_PRO) #include "ramps/pins_LONGER3D_LKx_PRO.h" // ATmega2560 env:mega2560 +#elif MB(PXMALION_CORE_I3) + #include "ramps/pins_PXMALION_CORE_I3.h" // ATmega2560 env:mega2560 // // RAMBo and derivatives diff --git a/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h b/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h new file mode 100644 index 0000000000..12c40c7dca --- /dev/null +++ b/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h @@ -0,0 +1,86 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Pxmalion Core i3 - https://github.com/Pxmalion + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Core i3" +#endif + +// +// Servos +// +#define SERVO0_PIN 51 +#define SERVO1_PIN -1 +#define SERVO2_PIN -1 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 2 +#define Z_MIN_PIN 19 +#define Z_MAX_PIN 18 + +// TODO: Filament Runout Sensor +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN -1 +#endif + +// +// Steppers +// +#define X_CS_PIN -1 +#define Y_CS_PIN -1 +#define Z_CS_PIN -1 +#define E0_CS_PIN -1 +#define E1_CS_PIN -1 + +// +// Heaters / Fans +// +#define FET_ORDER_EFB +#ifndef MOSFET_A_PIN + #define MOSFET_A_PIN 8 +#endif +#ifndef MOSFET_B_PIN + #define MOSFET_B_PIN 7 +#endif +#ifndef MOSFET_C_PIN + #define MOSFET_C_PIN 9 +#endif + +// +// Misc. Functions +// +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN -1 // Analog Input +#endif + +#define PS_ON_PIN 11 + +#include "pins_RAMPS.h" From 3d2b2ca790d31d174e1d26e665e3c61b1a6c8996 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 10 Feb 2022 16:03:48 -0600 Subject: [PATCH 023/203] =?UTF-8?q?=F0=9F=8E=A8=20Misc.=20DGUS=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp | 28 +++++++++++-------- Marlin/src/lcd/extui/dgus/DGUSDisplay.h | 3 ++ .../src/lcd/extui/dgus/DGUSScreenHandler.cpp | 17 ++++++----- .../extui/dgus/fysetc/DGUSScreenHandler.cpp | 2 +- .../lcd/extui/dgus/fysetc/DGUSScreenHandler.h | 6 ++-- .../extui/dgus/hiprecy/DGUSScreenHandler.cpp | 2 +- .../extui/dgus/hiprecy/DGUSScreenHandler.h | 6 ++-- .../lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 4 +-- .../lcd/extui/dgus/mks/DGUSScreenHandler.h | 8 +++--- .../extui/dgus/origin/DGUSScreenHandler.cpp | 2 +- .../lcd/extui/dgus/origin/DGUSScreenHandler.h | 6 ++-- 11 files changed, 48 insertions(+), 36 deletions(-) diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp index 262dcea364..e2f11502e7 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp @@ -46,6 +46,12 @@ DGUSDisplay dgusdisplay; +#ifdef DEBUG_DGUSLCD_COMM + #define DEBUGLCDCOMM_ECHOPGM DEBUG_ECHOPGM +#else + #define DEBUGLCDCOMM_ECHOPGM(...) NOOP +#endif + // Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable constexpr uint8_t DGUS_HEADER1 = 0x5A; constexpr uint8_t DGUS_HEADER2 = 0xA5; @@ -154,19 +160,19 @@ void DGUSDisplay::ProcessRx() { case DGUS_IDLE: // Waiting for the first header byte receivedbyte = LCD_SERIAL.read(); - //DEBUG_ECHOPGM("< ",x); + //DEBUGLCDCOMM_ECHOPGM("< ", receivedbyte); if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN; break; case DGUS_HEADER1_SEEN: // Waiting for the second header byte receivedbyte = LCD_SERIAL.read(); - //DEBUG_ECHOPGM(" ",x); + //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte); rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE; break; case DGUS_HEADER2_SEEN: // Waiting for the length byte rx_datagram_len = LCD_SERIAL.read(); - DEBUG_ECHOPGM(" (", rx_datagram_len, ") "); + //DEBUGLCDCOMM_ECHOPGM(" (", rx_datagram_len, ") "); // Telegram min len is 3 (command and one word of payload) rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE; @@ -178,20 +184,20 @@ void DGUSDisplay::ProcessRx() { Initialized = true; // We've talked to it, so we defined it as initialized. uint8_t command = LCD_SERIAL.read(); - DEBUG_ECHOPGM("# ", command); + //DEBUGLCDCOMM_ECHOPGM("# ", command); uint8_t readlen = rx_datagram_len - 1; // command is part of len. unsigned char tmp[rx_datagram_len - 1]; unsigned char *ptmp = tmp; while (readlen--) { receivedbyte = LCD_SERIAL.read(); - DEBUG_ECHOPGM(" ", receivedbyte); + //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte); *ptmp++ = receivedbyte; } - DEBUG_ECHOPGM(" # "); + //DEBUGLCDCOMM_ECHOPGM(" # "); // mostly we'll get this: 5A A5 03 82 4F 4B -- ACK on 0x82, so discard it. if (command == DGUS_CMD_WRITEVAR && 'O' == tmp[0] && 'K' == tmp[1]) { - DEBUG_ECHOLNPGM(">"); + //DEBUGLCDCOMM_ECHOPGM(">"); rx_datagram_state = DGUS_IDLE; break; } @@ -253,16 +259,16 @@ void DGUSDisplay::loop() { rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE; uint8_t DGUSDisplay::rx_datagram_len = 0; -bool DGUSDisplay::Initialized = false; -bool DGUSDisplay::no_reentrance = false; +bool DGUSDisplay::Initialized = false, + DGUSDisplay::no_reentrance = false; // A SW memory barrier, to ensure GCC does not overoptimize loops #define sw_barrier() asm volatile("": : :"memory"); bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) { - // DEBUG_ECHOPGM("populate_VPVar ", VP); + //DEBUG_ECHOPGM("populate_VPVar ", VP); const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP); - // DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp); + //DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp); if (!pvp) return false; memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable)); return true; diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h index 3040225d07..17303c689b 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h @@ -29,6 +29,9 @@ #include // size_t +//#define DEBUG_DGUSLCD +//#define DEBUG_DGUSLCD_COMM + #if HAS_BED_PROBE #include "../../../module/probe.h" #endif diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 70bcca1859..9b25f8aeb1 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -55,14 +55,14 @@ void (*DGUSScreenHandler::confirm_action_cb)() = nullptr; #if ENABLED(SDSUPPORT) int16_t DGUSScreenHandler::top_file = 0, DGUSScreenHandler::file_to_print = 0; - static ExtUI::FileList filelist; + ExtUI::FileList filelist; #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) filament_data_t filament_data; #endif -void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { +void DGUSScreenHandler::sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { DGUS_VP_Variable ramcopy; if (populate_VPVar(VP_MSGSTR1, &ramcopy)) { ramcopy.memadr = (void*) line1; @@ -76,13 +76,15 @@ void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, con ramcopy.memadr = (void*) line3; l3inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); } - if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { - ramcopy.memadr = (void*) line4; - l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); - } + #ifdef VP_MSGSTR4 + if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { + ramcopy.memadr = (void*) line4; + l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); + } + #endif } -void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1, bool l2, bool l3, bool l4) { +void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1, bool l2, bool l3, bool l4) { if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first. PopToOldScreen(); @@ -344,6 +346,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); } + #endif // SDSUPPORT void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp index eba4b153f1..e7466bfe08 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h index d4fdf1d27e..0bdf06ed7d 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h @@ -37,15 +37,15 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); } static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); } - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. static void setstatusmessage(const char *msg); diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp index 88b3255b66..d64ac143b0 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h index d4fdf1d27e..0bdf06ed7d 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h @@ -37,15 +37,15 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); } static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); } - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. static void setstatusmessage(const char *msg); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 88f26ab42d..bfa070df87 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -48,7 +48,7 @@ #endif #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; #endif bool DGUSAutoTurnOff = false; @@ -65,7 +65,7 @@ void DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t *line1, const uint1 dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true); } -void DGUSScreenHandler::sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) { +void DGUSScreenHandler::sendinfoscreen_en_mks(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4) { dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h index 05a4b47b17..dbd124cbe9 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h @@ -37,19 +37,19 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); } static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); } - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); #if 0 static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4); - static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ; + static void sendinfoscreen_en_mks(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4); static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language); #endif diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp index fb08fbf849..aaa8b72e11 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h index d4fdf1d27e..0bdf06ed7d 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h @@ -37,15 +37,15 @@ public: // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); } static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); } - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); // "M117" Message -- msg is a RAM ptr. static void setstatusmessage(const char *msg); From be8f4f47f904377f44c3cf4f46b66e446136983d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 11 Feb 2022 00:19:49 +0000 Subject: [PATCH 024/203] [cron] Bump distribution date (2022-02-11) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 0831287429..8510907a3c 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-10" +//#define STRING_DISTRIBUTION_DATE "2022-02-11" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 3283615dc3..d44f48f599 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-10" + #define STRING_DISTRIBUTION_DATE "2022-02-11" #endif /** From df98bd26b33e5f80d39eb0addb64c3258ce5c09f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 11 Feb 2022 09:36:52 -0600 Subject: [PATCH 025/203] =?UTF-8?q?=F0=9F=92=A5=20Change=20'M42=20M'=20to?= =?UTF-8?q?=20'M42=20T'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/control/M42.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index 77c0ccc49b..8de3226924 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -52,7 +52,7 @@ void protected_pin_err() { * S Pin status from 0 - 255 * I Flag to ignore Marlin's pin protection * - * M Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN + * T Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN */ void GcodeSuite::M42() { const int pin_index = PARSED_PIN_INDEX('P', GET_PIN_MAP_INDEX(LED_PIN)); @@ -63,7 +63,7 @@ void GcodeSuite::M42() { if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err(); bool avoidWrite = false; - if (parser.seenval('M')) { + if (parser.seenval('T')) { switch (parser.value_byte()) { case 0: pinMode(pin, INPUT); avoidWrite = true; break; case 1: pinMode(pin, OUTPUT); break; From fb86b6b3e309a6e1273b0d6cb1bcb8159a0be0dc Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 12 Feb 2022 08:39:34 +1300 Subject: [PATCH 026/203] =?UTF-8?q?=F0=9F=9A=B8=20Align=20MKS=20UI=20heate?= =?UTF-8?q?d=20bed=20status=20with=20HAS=5FMULTI=5FHOTEND=20(#23718)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp index 1596944bd8..39f270840b 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp @@ -196,7 +196,7 @@ void lv_draw_ready_print() { buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 180, ICON_POS_Y, event_handler, ID_INFO_EXT); #endif #if HAS_HEATED_BED - buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", TERN(HAS_MULTI_HOTEND, 271, 210), ICON_POS_Y, event_handler, ID_INFO_BED); + buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", TERN(HAS_MULTI_HOTEND, 340, 210), ICON_POS_Y, event_handler, ID_INFO_BED); #endif TERN_(HAS_HOTEND, labelExt1 = lv_label_create_empty(scr)); From 26e4f70d7c0eec0f6d0f7ab2c3b780176d95c47f Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 12 Feb 2022 08:50:07 +1300 Subject: [PATCH 027/203] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20E3V2=20displ?= =?UTF-8?q?ay=20with=20BTT=20SKR=20Mini=20E3=20v3=20(#23719)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h index 7cbf9f9d58..2589a316b6 100644 --- a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h +++ b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h @@ -156,7 +156,7 @@ #define EXP1_09_PIN PA15 #define EXP1_03_PIN PD6 -#if EITHER(DWIN_CREALITY_LCD, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** * ------ ------ ------ * (ENT) |10 9 | (BEEP) |10 9 | |10 9 | From b4d3e1da34f5a4365d35b685d2d7e97d76dedf98 Mon Sep 17 00:00:00 2001 From: John Robertson Date: Fri, 11 Feb 2022 21:04:47 +0000 Subject: [PATCH 028/203] =?UTF-8?q?=E2=9C=A8=20More=20Nozzle=20Park=20move?= =?UTF-8?q?=20options=20(#23158)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 3 +-- Marlin/src/inc/SanityCheck.h | 4 ++++ Marlin/src/libs/nozzle.cpp | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d3c36ad485..752fd1370a 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1913,8 +1913,7 @@ #if ENABLED(NOZZLE_PARK_FEATURE) // Specify a park position as { X, Y, Z_raise } #define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MAX_POS - 10), 20 } - //#define NOZZLE_PARK_X_ONLY // X move only is required to park - //#define NOZZLE_PARK_Y_ONLY // Y move only is required to park + #define NOZZLE_PARK_MOVE 0 // Park motion: 0 = XY Move, 1 = X Only, 2 = Y Only, 3 = X before Y, 4 = Y before X #define NOZZLE_PARK_Z_RAISE_MIN 2 // (mm) Always raise Z by at least this distance #define NOZZLE_PARK_XY_FEEDRATE 100 // (mm/s) X and Y axes feedrate (also used for delta Z axis) #define NOZZLE_PARK_Z_FEEDRATE 5 // (mm/s) Z axis feedrate (not used for delta printers) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 38c2866ca1..8f6843eee9 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -609,6 +609,10 @@ #error "LCD_SCREEN_ROT_270 is now LCD_SCREEN_ROTATE with a value of 270." #elif defined(DEFAULT_LCD_BRIGHTNESS) #error "DEFAULT_LCD_BRIGHTNESS is now LCD_BRIGHTNESS_DEFAULT." +#elif defined(NOZZLE_PARK_X_ONLY) + #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 1." +#elif defined(NOZZLE_PARK_Y_ONLY) + #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 2." #endif constexpr float arm[] = AXIS_RELATIVE_MODES; diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index e277216ab4..5cd2014d7f 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -254,11 +254,18 @@ Nozzle nozzle; break; } - do_blocking_move_to_xy( - TERN(NOZZLE_PARK_Y_ONLY, current_position, park).x, - TERN(NOZZLE_PARK_X_ONLY, current_position, park).y, - fr_xy - ); + #ifndef NOZZLE_PARK_MOVE + #define NOZZLE_PARK_MOVE 0 + #endif + switch (NOZZLE_PARK_MOVE) { + case 0: do_blocking_move_to_xy(park, fr_xy); break; + case 1: do_blocking_move_to_x(park.x, fr_xy); break; + case 2: do_blocking_move_to_y(park.y, fr_xy); break; + case 3: do_blocking_move_to_x(park.x, fr_xy); + do_blocking_move_to_y(park.y, fr_xy); break; + case 4: do_blocking_move_to_y(park.y, fr_xy); + do_blocking_move_to_x(park.x, fr_xy); break; + } report_current_position(); } From cda46828613721c116a1fefce08cfbf1dd4cfcc2 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 12 Feb 2022 00:21:36 +0000 Subject: [PATCH 029/203] [cron] Bump distribution date (2022-02-12) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 8510907a3c..d38abd8037 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-11" +//#define STRING_DISTRIBUTION_DATE "2022-02-12" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index d44f48f599..a7df1f2893 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-11" + #define STRING_DISTRIBUTION_DATE "2022-02-12" #endif /** From cf013a7f3e8f8030e3ac092692988d4e53fd03c3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Feb 2022 12:55:00 -0600 Subject: [PATCH 030/203] =?UTF-8?q?=F0=9F=94=A7=20HAS=5FLCDPRINT=20conditi?= =?UTF-8?q?onal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_LCD.h | 4 ++++ Marlin/src/lcd/lcdprint.cpp | 4 ++-- ini/features.ini | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index f4b517dd23..34a160fc5c 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -517,6 +517,10 @@ #define HAS_DISPLAY 1 #endif +#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI + #define HAS_LCDPRINT 1 +#endif + #if ANY(HAS_DISPLAY, HAS_DWIN_E3V2, GLOBAL_STATUS_MESSAGE) #define HAS_STATUS_MESSAGE 1 #endif diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index 498b478b12..8ca0c8ee9e 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -26,7 +26,7 @@ #include "../inc/MarlinConfigPre.h" -#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI +#if HAS_LCDPRINT #include "marlinui.h" #include "lcdprint.h" @@ -103,4 +103,4 @@ int calculateWidth(PGM_P const pstr) { return n * MENU_FONT_WIDTH; } -#endif // HAS_WIRED_LCD +#endif // HAS_LCDPRINT diff --git a/ini/features.ini b/ini/features.ini index 720748d7f0..43eb58a606 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -34,7 +34,7 @@ I2C_AMMETER = peterus/INA226Lib@1.1.2 USES_LIQUIDCRYSTAL = LiquidCrystal=https://github.com/MarlinFirmware/New-LiquidCrystal/archive/1.5.1.zip USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 -HAS_WIRED_LCD = src_filter=+ +HAS_LCDPRINT = src_filter=+ HAS_MARLINUI_HD44780 = src_filter=+ HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.5.0 src_filter=+ From e8cc050e90252d45734552ae857cf8b6cb8580d0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Feb 2022 13:12:38 -0600 Subject: [PATCH 031/203] =?UTF-8?q?=F0=9F=93=9D=20Update=20conditionals=20?= =?UTF-8?q?descriptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_adv.h | 2 +- Marlin/src/inc/Conditionals_post.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 7b628d448e..82b32ba003 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -23,7 +23,7 @@ /** * Conditionals_adv.h - * Defines that depend on advanced configuration. + * Conditionals set before pins.h and which depend on Configuration_adv.h. */ #ifndef AXIS_RELATIVE_MODES diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 37f0a5cbe5..b107ad03ae 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -23,7 +23,7 @@ /** * Conditionals_post.h - * Defines that depend on configuration but are not editable. + * Internal defines that depend on Configurations and Pins but are not user-editable. */ #ifdef GITHUB_ACTIONS From 03516f05191b888b5378f0426bc86f41b6cb2d03 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sun, 13 Feb 2022 14:44:24 -0500 Subject: [PATCH 032/203] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20No=20ui.reinit=5Fl?= =?UTF-8?q?cd=20on=20any=20ExtUI=20(#23722)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/inc/Conditionals_post.h | 4 ++-- Marlin/src/lcd/marlinui.cpp | 6 ++---- Marlin/src/lcd/marlinui.h | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index b107ad03ae..fa273cd32e 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -459,8 +459,8 @@ #endif -#if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI) || !PIN_EXISTS(SD_DETECT) - #define NO_LCD_REINIT 1 // Suppress LCD re-initialization +#if PIN_EXISTS(SD_DETECT) && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI) + #define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion #endif /** diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 27965c1bd4..d0cc2a25b8 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -625,7 +625,7 @@ void MarlinUI::init() { next_filament_display = millis() + 5000UL; // Show status message for 5s #endif goto_screen(menu_main); - IF_DISABLED(NO_LCD_REINIT, init_lcd()); // May revive the LCD if static electricity killed it + reinit_lcd(); // Revive a noisy shared SPI LCD return; } @@ -1697,9 +1697,7 @@ void MarlinUI::init() { } } - #if PIN_EXISTS(SD_DETECT) && DISABLED(NO_LCD_REINIT) - init_lcd(); // Revive a noisy shared SPI LCD - #endif + reinit_lcd(); // Revive a noisy shared SPI LCD refresh(); diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 5885866e5b..17c2468737 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -209,6 +209,8 @@ public: static void init_lcd() {} #endif + static void reinit_lcd() { TERN_(REINIT_NOISY_LCD, init_lcd()); } + #if HAS_WIRED_LCD static bool detected(); #else From cd4c1be641809bb1a32f74d840b7726ad796798b Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 14 Feb 2022 00:20:02 +0000 Subject: [PATCH 033/203] [cron] Bump distribution date (2022-02-14) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index d38abd8037..1cb84b9966 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-12" +//#define STRING_DISTRIBUTION_DATE "2022-02-14" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index a7df1f2893..51558f0cd9 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-12" + #define STRING_DISTRIBUTION_DATE "2022-02-14" #endif /** From aae08e9b0d7338d0f2c3ee04469165b9a087c161 Mon Sep 17 00:00:00 2001 From: Giuseppe499 Date: Tue, 15 Feb 2022 20:21:05 +0100 Subject: [PATCH 034/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20XATC=20divide-by-z?= =?UTF-8?q?ero=20(#23743)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/abl/x_twist.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/feature/bedlevel/abl/x_twist.cpp b/Marlin/src/feature/bedlevel/abl/x_twist.cpp index c4a62c3595..000c1e2294 100644 --- a/Marlin/src/feature/bedlevel/abl/x_twist.cpp +++ b/Marlin/src/feature/bedlevel/abl/x_twist.cpp @@ -49,6 +49,7 @@ void XATC::print_points() { float lerp(const_float_t t, const_float_t a, const_float_t b) { return a + t * (b - a); } float XATC::compensation(const xy_pos_t &raw) { + if (NEAR_ZERO(spacing)) return 0; float t = (raw.x - start) / spacing; int i = FLOOR(t); LIMIT(i, 0, XATC_MAX_POINTS - 2); From 98a17cd60dc51f1b22b88101b526fd7f1b3f8787 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 15 Feb 2022 15:09:09 -0600 Subject: [PATCH 035/203] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Rename=20XATC=20z?= =?UTF-8?q?=5Fvalues=20=3D>=20z=5Foffset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/abl/x_twist.cpp | 10 +++++----- Marlin/src/feature/bedlevel/abl/x_twist.h | 4 ++-- Marlin/src/lcd/menu/menu_x_twist.cpp | 6 +++--- Marlin/src/module/settings.cpp | 5 +---- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Marlin/src/feature/bedlevel/abl/x_twist.cpp b/Marlin/src/feature/bedlevel/abl/x_twist.cpp index 000c1e2294..24fdbca950 100644 --- a/Marlin/src/feature/bedlevel/abl/x_twist.cpp +++ b/Marlin/src/feature/bedlevel/abl/x_twist.cpp @@ -28,15 +28,15 @@ XATC xatc; float XATC::spacing, XATC::start; -xatc_points_t XATC::z_values; +xatc_array_t XATC::z_offset; void XATC::print_points() { SERIAL_ECHOLNPGM(" X-Twist Correction:"); LOOP_L_N(x, XATC_MAX_POINTS) { SERIAL_CHAR(' '); - if (!isnan(z_values[x])) { - if (z_values[x] >= 0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(z_values[x], 3); + if (!isnan(z_offset[x])) { + if (z_offset[x] >= 0) SERIAL_CHAR('+'); + SERIAL_ECHO_F(z_offset[x], 3); } else { LOOP_L_N(i, 6) @@ -54,7 +54,7 @@ float XATC::compensation(const xy_pos_t &raw) { int i = FLOOR(t); LIMIT(i, 0, XATC_MAX_POINTS - 2); t -= i; - return lerp(t, z_values[i], z_values[i + 1]); + return lerp(t, z_offset[i], z_offset[i + 1]); } #endif // X_AXIS_TWIST_COMPENSATION diff --git a/Marlin/src/feature/bedlevel/abl/x_twist.h b/Marlin/src/feature/bedlevel/abl/x_twist.h index bbad9e73ef..9deb45a8b7 100644 --- a/Marlin/src/feature/bedlevel/abl/x_twist.h +++ b/Marlin/src/feature/bedlevel/abl/x_twist.h @@ -23,12 +23,12 @@ #include "../../../inc/MarlinConfigPre.h" -typedef float xatc_points_t[XATC_MAX_POINTS]; +typedef float xatc_array_t[XATC_MAX_POINTS]; class XATC { public: static float spacing, start; - static xatc_points_t z_values; + static xatc_array_t z_offset; static float compensation(const xy_pos_t &raw); static void print_points(); diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp index 288f16603a..fab3b5ae11 100644 --- a/Marlin/src/lcd/menu/menu_x_twist.cpp +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -77,7 +77,7 @@ void xatc_wizard_update_z_offset() { // void xatc_wizard_set_offset_and_go_to_next_point() { // Set Z-offset at probed point - xatc.z_values[manual_probe_index++] = probe.offset.z + current_position.z - measured_z; + xatc.z_offset[manual_probe_index++] = probe.offset.z + current_position.z - measured_z; // Go to next point ui.goto_screen(xatc_wizard_goto_next_point); } @@ -160,12 +160,12 @@ void xatc_wizard_goto_next_point() { else { // Compute the z-offset by averaging the values found with this wizard z_offset = 0; - LOOP_L_N(i, XATC_MAX_POINTS) z_offset += xatc.z_values[i]; + LOOP_L_N(i, XATC_MAX_POINTS) z_offset += xatc.z_offset[i]; z_offset /= XATC_MAX_POINTS; // Subtract the average from the values found with this wizard. // This way they are indipendent from the z-offset - LOOP_L_N(i, XATC_MAX_POINTS) xatc.z_values[i] -= z_offset; + LOOP_L_N(i, XATC_MAX_POINTS) xatc.z_offset[i] -= z_offset; ui.goto_screen(xatc_wizard_update_z_offset); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 8c2cd8813d..bcbe8fa985 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -863,10 +863,7 @@ void MarlinSettings::postprocess() { "Bilinear Z array is the wrong size." ); #if ENABLED(X_AXIS_TWIST_COMPENSATION) - static_assert( - sizeof(xatc.z_values) == (XATC_MAX_POINTS) * sizeof(xatc.z_values[0]), - "Z-offset mesh is the wrong size." - ); + static_assert(COUNT(xatc.z_offset) == XATC_MAX_POINTS, "XATC Z-offset mesh is the wrong size."); #endif #else const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0}; From e507aa09c51471465f6d802945c3be2459e1ee63 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 16 Feb 2022 00:19:06 +0000 Subject: [PATCH 036/203] [cron] Bump distribution date (2022-02-16) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 1cb84b9966..5c8fd4a5bc 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-14" +//#define STRING_DISTRIBUTION_DATE "2022-02-16" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 51558f0cd9..6d43943a8f 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-14" + #define STRING_DISTRIBUTION_DATE "2022-02-16" #endif /** From 5439da6775e2c1b64127480d8e6fa3106a8e7706 Mon Sep 17 00:00:00 2001 From: Simon Pilepich Date: Wed, 16 Feb 2022 13:46:09 +1100 Subject: [PATCH 037/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Upd?= =?UTF-8?q?ate=20MightyBoard=20FET=20pins=20(#23728)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h | 59 ++++++++------------ 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index eb92ab5cd0..f2a95baf01 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -144,56 +144,41 @@ //#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // -// Augmentation for auto-assigning plugs -// -// Two thermocouple connectors allows for either -// 2 extruders or 1 extruder and a heated bed. -// With no heated bed, an additional 24V fan is possible. +// FET Pin Mapping - FET 1 is closest to the input power connector // -#define MOSFET_A_PIN 6 // H3 EX1_HEAT_PIN -#define MOSFET_B_PIN 11 // B5 EX2_HEAT_PIN -#define MOSFET_C_PIN 45 // L4 HBP_PIN -#define MOSFET_D_PIN 44 // L5 EXTRA_FET_PIN +#define MOSFET_1_PIN 6 // Plug EX1 Pin 1-2 -> PH3 #15 -> Logical 06 +#define MOSFET_2_PIN 7 // Plug EX1 Pin 3-4 -> PH4 #16 -> Logical 07 +#define MOSFET_3_PIN 12 // Plug EX2 1-2 -> PB5 #25 -> Logical 12 +#define MOSFET_4_PIN 11 // Plug EX2 3-4 -> PB6 #24 -> Logical 11 +#define MOSFET_5_PIN 45 // Plug HBD 1-2 -> PL4 #39 -> Logical 45 +#define MOSFET_6_PIN 13 // Plug Extra 1-2 -> PL5 #40 -> Logical 44 (FET not soldered in all boards) // // Heaters / Fans (24V) // -#define HEATER_0_PIN MOSFET_A_PIN -#if FET_ORDER_EFB // Hotend, Fan, Bed - #define HEATER_BED_PIN MOSFET_C_PIN -#elif FET_ORDER_EEF // Hotend, Hotend, Fan - #define HEATER_1_PIN MOSFET_B_PIN -#elif FET_ORDER_EEB // Hotend, Hotend, Bed - #define HEATER_1_PIN MOSFET_B_PIN - #define HEATER_BED_PIN MOSFET_C_PIN -#elif FET_ORDER_EFF // Hotend, Fan, Fan - #define FAN1_PIN MOSFET_C_PIN +#define HEATER_0_PIN MOSFET_1_PIN // EX1 +#define HEATER_1_PIN MOSFET_3_PIN // EX2 +#define HEATER_BED_PIN MOSFET_5_PIN // HBP + +// EX1 FAN (Automatic Fans are disabled by default in Configuration_adv.h - comment that out for auto fans) +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN MOSFET_2_PIN +#else + #define FAN_PIN MOSFET_2_PIN #endif - -#ifndef FAN_PIN - #if EITHER(FET_ORDER_EFB, FET_ORDER_EFF) // Hotend, Fan, Bed or Hotend, Fan, Fan - #define FAN_PIN MOSFET_B_PIN - #elif EITHER(FET_ORDER_EEF, FET_ORDER_SF) // Hotend, Hotend, Fan or Spindle, Fan - #define FAN_PIN MOSFET_C_PIN - #else - #define FAN_PIN MOSFET_D_PIN - #endif -#endif - -#ifndef FAN1_PIN - #define FAN1_PIN 7 // H4 EX1_FAN_PIN -#endif - -#ifndef CONTROLLER_FAN_PIN - #define CONTROLLER_FAN_PIN 12 // B6 EX2_FAN_PIN +// EX2 FAN (Automatic Fans are disabled by default in Configuration_adv.h - comment that out for auto fans) +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN MOSFET_4_PIN +#else + #define FAN1_PIN MOSFET_4_PIN #endif // // Misc. Functions // -#define LED_PIN 13 // B7 +#define LED_PIN MOSFET_6_PIN // B7 #define CUTOFF_RESET_PIN 16 // H1 #define CUTOFF_TEST_PIN 17 // H0 #define CUTOFF_SR_CHECK_PIN 70 // G4 (TOSC1) From 10c0b9423d5b19dc5e6f8494e79be14cf0ae6b3c Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 17 Feb 2022 00:19:04 +0000 Subject: [PATCH 038/203] [cron] Bump distribution date (2022-02-17) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 5c8fd4a5bc..79f86ac74a 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-16" +//#define STRING_DISTRIBUTION_DATE "2022-02-17" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 6d43943a8f..ee58d529e5 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-16" + #define STRING_DISTRIBUTION_DATE "2022-02-17" #endif /** From 7b25b9ec5b6c731bc0e136442d61117fef7428f2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 17 Feb 2022 14:41:56 -0600 Subject: [PATCH 039/203] =?UTF-8?q?=F0=9F=90=9B=20Patch=20Creality=20RAMPS?= =?UTF-8?q?=20FET=20/=20FAN=20pins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improvement for multi-hotend setup by TH3D. --- Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h index def71fefc1..21dadd60ee 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -30,9 +30,8 @@ // // Heaters / Fans // - -// Power outputs EFBF or EFBE -#define MOSFET_D_PIN 7 +#define MOSFET_B_PIN 7 // For HEATER_1_PIN ("EEF" or "EEB") +#define FAN_PIN 9 #define FIL_RUNOUT_PIN 2 #if NUM_RUNOUT_SENSORS >= 2 From 2ba1153fd8b7ca17ce94fbf13b4c21618eb1e7af Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 18 Feb 2022 00:23:00 +0000 Subject: [PATCH 040/203] [cron] Bump distribution date (2022-02-18) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 79f86ac74a..f13abf77fb 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-17" +//#define STRING_DISTRIBUTION_DATE "2022-02-18" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index ee58d529e5..45bf3f47a4 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-17" + #define STRING_DISTRIBUTION_DATE "2022-02-18" #endif /** From 3ec5bbfb13a9a6fc2af5535bed4a40ba9c2b5e94 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 18 Feb 2022 13:37:22 +1300 Subject: [PATCH 041/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20HAS=5FTMC26X=20fea?= =?UTF-8?q?ture=20path=20(#23757)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/features.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ini/features.ini b/ini/features.ini index 43eb58a606..c52675ff2d 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -24,7 +24,7 @@ SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster src_filter=+ HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip - src_filter=+ + src_filter=+ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + + LIB_INTERNAL_MAX31865 = src_filter=+ From cba8d4f401b7de5c04c96e630d497af7041f908a Mon Sep 17 00:00:00 2001 From: jefflessard Date: Thu, 17 Feb 2022 19:44:41 -0500 Subject: [PATCH 042/203] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20TEMP=5FSENSOR=5FBO?= =?UTF-8?q?ARD=20warnings=20(#23754)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Warnings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 95246343c7..3545ee8b5d 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -59,9 +59,9 @@ #warning "Your Configuration provides no method to acquire user feedback!" #endif -#if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) +#if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_BOARD #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." -#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) +#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_BOARD #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." #endif From fee85b318eca9f410f1b49de22ee9e6f778a23ff Mon Sep 17 00:00:00 2001 From: GHGiampy <83699429+GHGiampy@users.noreply.github.com> Date: Fri, 18 Feb 2022 01:45:42 +0100 Subject: [PATCH 043/203] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20getLFNName?= =?UTF-8?q?=20parameter=20(#23752)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/sd/SdBaseFile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 64d0ad68bd..1c1e0c7d14 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -1140,8 +1140,8 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. uint16_t idx = (startOffset + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding - longFilename[idx] = utf16_ch & 0xFF; - longFilename[idx + 1] = (utf16_ch >> 8) & 0xFF; + lname[idx] = utf16_ch & 0xFF; + lname[idx + 1] = (utf16_ch >> 8) & 0xFF; #else // Replace all multibyte characters to '_' lname[startOffset + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); From 44eff9a23348dcc117fd1ea9b4b1ef0b54061808 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 17 Feb 2022 18:50:31 -0600 Subject: [PATCH 044/203] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20HAL=20a?= =?UTF-8?q?s=20singleton=20(#23357)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/HAL.cpp | 38 ++-- Marlin/src/HAL/AVR/HAL.h | 198 +++++++++++--------- Marlin/src/HAL/AVR/MarlinSerial.cpp | 4 +- Marlin/src/HAL/AVR/MarlinSerial.h | 6 +- Marlin/src/HAL/AVR/fast_pwm.cpp | 6 +- Marlin/src/HAL/AVR/math.h | 4 +- Marlin/src/HAL/AVR/timers.h | 6 +- Marlin/src/HAL/DUE/HAL.cpp | 43 +---- Marlin/src/HAL/DUE/HAL.h | 135 +++++++++----- Marlin/src/HAL/DUE/MarlinSerial.cpp | 4 +- Marlin/src/HAL/DUE/Tone.cpp | 2 +- Marlin/src/HAL/DUE/timers.h | 2 +- Marlin/src/HAL/ESP32/HAL.cpp | 35 ++-- Marlin/src/HAL/ESP32/HAL.h | 144 +++++++++------ Marlin/src/HAL/ESP32/Tone.cpp | 2 +- Marlin/src/HAL/ESP32/timers.cpp | 2 +- Marlin/src/HAL/ESP32/timers.h | 6 +- Marlin/src/HAL/LINUX/HAL.cpp | 37 ++-- Marlin/src/HAL/LINUX/HAL.h | 145 +++++++++------ Marlin/src/HAL/LINUX/arduino.cpp | 4 +- Marlin/src/HAL/LINUX/include/Arduino.h | 7 +- Marlin/src/HAL/LINUX/timers.h | 4 +- Marlin/src/HAL/LPC1768/HAL.cpp | 46 +++-- Marlin/src/HAL/LPC1768/HAL.h | 159 +++++++++------- Marlin/src/HAL/LPC1768/Servo.h | 3 +- Marlin/src/HAL/LPC1768/fast_pwm.cpp | 6 +- Marlin/src/HAL/LPC1768/main.cpp | 6 +- Marlin/src/HAL/LPC1768/timers.h | 2 +- Marlin/src/HAL/NATIVE_SIM/HAL.h | 173 +++++++++++------- Marlin/src/HAL/NATIVE_SIM/timers.h | 4 +- Marlin/src/HAL/SAMD51/HAL.cpp | 229 +++++++++++++++++++----- Marlin/src/HAL/SAMD51/HAL.h | 129 ++++++++----- Marlin/src/HAL/STM32/HAL.cpp | 28 ++- Marlin/src/HAL/STM32/HAL.h | 180 +++++++++++-------- Marlin/src/HAL/STM32/HAL_SPI.cpp | 8 +- Marlin/src/HAL/STM32/eeprom_flash.cpp | 8 +- Marlin/src/HAL/STM32/fast_pwm.cpp | 4 +- Marlin/src/HAL/STM32/pinsDebug.h | 6 +- Marlin/src/HAL/STM32/timers.h | 4 +- Marlin/src/HAL/STM32F1/HAL.cpp | 183 +++++++++---------- Marlin/src/HAL/STM32F1/HAL.h | 192 +++++++++++--------- Marlin/src/HAL/STM32F1/SPI.cpp | 8 + Marlin/src/HAL/STM32F1/SPI.h | 8 - Marlin/src/HAL/STM32F1/Servo.h | 3 +- Marlin/src/HAL/STM32F1/fast_pwm.cpp | 8 +- Marlin/src/HAL/STM32F1/timers.h | 2 +- Marlin/src/HAL/TEENSY31_32/HAL.cpp | 85 ++++----- Marlin/src/HAL/TEENSY31_32/HAL.h | 130 ++++++++++---- Marlin/src/HAL/TEENSY31_32/timers.h | 2 +- Marlin/src/HAL/TEENSY35_36/HAL.cpp | 114 ++++++------ Marlin/src/HAL/TEENSY35_36/HAL.h | 132 ++++++++++---- Marlin/src/HAL/TEENSY35_36/timers.h | 2 +- Marlin/src/HAL/TEENSY40_41/HAL.cpp | 194 ++++++++++---------- Marlin/src/HAL/TEENSY40_41/HAL.h | 147 ++++++++++----- Marlin/src/HAL/TEENSY40_41/timers.h | 2 +- Marlin/src/HAL/shared/HAL.cpp | 36 ++++ Marlin/src/HAL/shared/HAL_spi_L6470.cpp | 8 +- Marlin/src/HAL/shared/math_32bit.h | 2 +- Marlin/src/MarlinCore.cpp | 48 +++-- Marlin/src/feature/caselight.cpp | 2 +- Marlin/src/feature/controllerfan.cpp | 2 +- Marlin/src/feature/e_parser.h | 4 +- Marlin/src/feature/leds/leds.cpp | 10 +- Marlin/src/feature/spindle_laser.cpp | 8 +- Marlin/src/feature/spindle_laser.h | 2 +- Marlin/src/gcode/control/M42.cpp | 4 +- Marlin/src/gcode/gcode_d.cpp | 10 +- Marlin/src/inc/MarlinConfig.h | 1 + Marlin/src/inc/SanityCheck.h | 7 + Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 4 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 2 +- Marlin/src/module/endstops.cpp | 2 +- Marlin/src/module/planner.cpp | 8 +- Marlin/src/module/servo.cpp | 2 +- Marlin/src/module/servo.h | 2 +- Marlin/src/module/stepper.cpp | 26 +-- Marlin/src/module/temperature.cpp | 155 ++++++---------- ini/features.ini | 2 +- ini/native.ini | 4 +- 79 files changed, 1975 insertions(+), 1417 deletions(-) create mode 100644 Marlin/src/HAL/shared/HAL.cpp diff --git a/Marlin/src/HAL/AVR/HAL.cpp b/Marlin/src/HAL/AVR/HAL.cpp index 666802725b..7c39c5200b 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -36,7 +36,7 @@ // ------------------------ // Don't initialize/override variable (which would happen in .init4) -uint8_t reset_reason __attribute__((section(".noinit"))); +uint8_t MarlinHAL::reset_reason __attribute__((section(".noinit"))); // ------------------------ // Public functions @@ -45,22 +45,22 @@ uint8_t reset_reason __attribute__((section(".noinit"))); __attribute__((naked)) // Don't output function pro- and epilogue __attribute__((used)) // Output the function, even if "not used" __attribute__((section(".init3"))) // Put in an early user definable section -void HAL_save_reset_reason() { +void save_reset_reason() { #if ENABLED(OPTIBOOT_RESET_REASON) __asm__ __volatile__( A("STS %0, r2") - : "=m"(reset_reason) + : "=m"(hal.reset_reason) ); #else - reset_reason = MCUSR; + hal.reset_reason = MCUSR; #endif // Clear within 16ms since WDRF bit enables a 16ms watchdog timer -> Boot loop - MCUSR = 0; + hal.clear_reset_source(); wdt_disable(); } -void HAL_init() { +void MarlinHAL::init() { // Init Servo Pins #define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW) #if HAS_SERVO_0 @@ -79,7 +79,7 @@ void HAL_init() { init_pwm_timers(); // Init user timers to default frequency - 1000HZ } -void HAL_reboot() { +void MarlinHAL::reboot() { #if ENABLED(USE_WATCHDOG) while (1) { /* run out the watchdog */ } #else @@ -95,20 +95,20 @@ void HAL_reboot() { #else // !SDSUPPORT -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; + extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; - int freeMemory() { - int free_memory; - if ((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - return free_memory; + int freeMemory() { + int free_memory; + if ((int)__brkval == 0) + free_memory = ((int)&free_memory) - ((int)&__bss_end); + else + free_memory = ((int)&free_memory) - ((int)__brkval); + return free_memory; + } } -} #endif // !SDSUPPORT diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index f5cbcc9d51..e825b4def3 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -74,9 +74,9 @@ #define CRITICAL_SECTION_START() unsigned char _sreg = SREG; cli() #define CRITICAL_SECTION_END() SREG = _sreg #endif -#define ISRS_ENABLED() TEST(SREG, SREG_I) -#define ENABLE_ISRS() sei() -#define DISABLE_ISRS() cli() + +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment +#define PWM_FREQUENCY 1000 // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() // ------------------------ // Types @@ -84,16 +84,15 @@ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // ------------------------ -// Public Variables -// ------------------------ - -extern uint8_t reset_reason; - // Serial ports +// ------------------------ + #ifdef USBCON #include "../../core/serial_hook.h" typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; @@ -142,57 +141,15 @@ extern uint8_t reset_reason; #endif #endif -// ------------------------ -// Public functions -// ------------------------ - -void HAL_init(); - -//void cli(); - -//void _delay_ms(const int delay); - -inline void HAL_clear_reset_source() { } -inline uint8_t HAL_get_reset_source() { return reset_reason; } - -void HAL_reboot(); - -#pragma GCC diagnostic push -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic ignored "-Wunused-function" -#endif - -extern "C" int freeMemory(); - -#pragma GCC diagnostic pop - +// // ADC -#ifdef DIDR2 - #define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0) -#else - #define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind); -#endif - -inline void HAL_adc_init() { - ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07; - DIDR0 = 0; - #ifdef DIDR2 - DIDR2 = 0; - #endif -} - -#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC) -#ifdef MUX5 - #define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch) -#else - #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch) -#endif - +// #define HAL_ADC_VREF 5.0 #define HAL_ADC_RESOLUTION 10 -#define HAL_READ_ADC() ADC -#define HAL_ADC_READY() !TEST(ADCSRA, ADSC) +// +// Pin Mapping for M42, M43, M226 +// #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) @@ -206,30 +163,109 @@ inline void HAL_adc_init() { // AVR compatibility #define strtof strtod -#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment -#define PWM_FREQUENCY 1000 // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() +// ------------------------ +// Class Utilities +// ------------------------ -/** - * set_pwm_frequency - * Sets the frequency of the timer corresponding to the provided pin - * as close as possible to the provided desired frequency. Internally - * calculates the required waveform generation mode, prescaler and - * resolution values required and sets the timer registers accordingly. - * NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B) - * NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST FAN PWM Settings) - */ -void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif -/** - * set_pwm_duty - * Set the PWM duty cycle of the provided pin to the provided value - * Optionally allows inverting the duty cycle [default = false] - * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); +extern "C" int freeMemory(); -/* - * init_pwm_timers - * sets the default frequency for timers 2-5 to 1000HZ - */ -void init_pwm_timers(); +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return TEST(SREG, SREG_I); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask() {} + + // Reset + static uint8_t reset_reason; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() { MCUSR = 0; } + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + // Called by Temperature::init once at startup + static void adc_init() { + ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07; + DIDR0 = 0; + #ifdef DIDR2 + DIDR2 = 0; + #endif + } + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) { + #ifdef DIDR2 + if (ch > 7) { SBI(DIDR2, ch & 0x07); return; } + #endif + SBI(DIDR0, ch); + } + + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch) { + #ifdef MUX5 + ADCSRB = ch > 7 ? _BV(MUX5) : 0; + #else + ADCSRB = 0; + #endif + ADMUX = _BV(REFS0) | (ch & 0x07); + SBI(ADCSRA, ADSC); + } + + // Is the ADC ready for reading? + static bool adc_ready() { return !TEST(ADCSRA, ADSC); } + + // The current value of the ADC register + static __typeof__(ADC) adc_value() { return ADC; } + + /** + * init_pwm_timers + * Set the default frequency for timers 2-5 to 1000HZ + */ + static void init_pwm_timers(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + + /** + * Set the frequency of the timer for the given pin as close as + * possible to the provided desired frequency. Internally calculate + * the required waveform generation mode, prescaler, and resolution + * values and set timer registers accordingly. + * NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B) + * NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST_PWM_FAN Settings) + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +}; diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index cd8bf5e690..986462437c 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -486,7 +486,7 @@ void MarlinSerial::write(const uint8_t c) { const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Make room by polling if it is possible to transmit, and do so! while (i == tx_buffer.tail) { @@ -534,7 +534,7 @@ void MarlinSerial::flushTX() { if (!_written) return; // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Wait until everything was transmitted - We must do polling, as interrupts are disabled while (tx_buffer.head != tx_buffer.tail || !B_TXC) { diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 84c5ddd297..7eb76000d6 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -191,13 +191,13 @@ rx_framing_errors; static ring_buffer_pos_t rx_max_enqueued; - static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_head(); + FORCE_INLINE static ring_buffer_pos_t atomic_read_rx_head(); static volatile bool rx_tail_value_not_stable; static volatile uint16_t rx_tail_value_backup; - static FORCE_INLINE void atomic_set_rx_tail(ring_buffer_pos_t value); - static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_tail(); + FORCE_INLINE static void atomic_set_rx_tail(ring_buffer_pos_t value); + FORCE_INLINE static ring_buffer_pos_t atomic_read_rx_tail(); public: FORCE_INLINE static void store_rxd_char(); diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp index f8201d028e..0a384172c3 100644 --- a/Marlin/src/HAL/AVR/fast_pwm.cpp +++ b/Marlin/src/HAL/AVR/fast_pwm.cpp @@ -107,7 +107,7 @@ const Timer get_pwm_timer(const pin_t pin) { return Timer(); } -void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { const Timer timer = get_pwm_timer(pin); if (timer.isProtected || !timer.isPWM) return; // Don't proceed if protected timer or not recognized @@ -176,7 +176,7 @@ void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { _SET_ICRn(timer, res); // Set ICRn value (TOP) = res } -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { // If v is 0 or v_size (max), digitalWrite to LOW or HIGH. // Note that digitalWrite also disables PWM output for us (sets COM bit to 0) if (v == 0) @@ -201,7 +201,7 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255 } } -void init_pwm_timers() { +void MarlinHAL::init_pwm_timers() { // Init some timer frequencies to a default 1KHz const pin_t pwm_pin[] = { #ifdef __AVR_ATmega2560__ diff --git a/Marlin/src/HAL/AVR/math.h b/Marlin/src/HAL/AVR/math.h index 7ede4accc0..7dd1018ff1 100644 --- a/Marlin/src/HAL/AVR/math.h +++ b/Marlin/src/HAL/AVR/math.h @@ -35,7 +35,7 @@ // C B A is longIn1 // D C B A is longIn2 // -static FORCE_INLINE uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) { +FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) { uint8_t tmp1; uint8_t tmp2; uint16_t intRes; @@ -89,7 +89,7 @@ static FORCE_INLINE uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2 // uses: // r26 to store 0 // r27 to store the byte 1 of the 24 bit result -static FORCE_INLINE uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) { +FORCE_INLINE static uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) { uint8_t tmp; uint16_t intRes; __asm__ __volatile__ ( diff --git a/Marlin/src/HAL/AVR/timers.h b/Marlin/src/HAL/AVR/timers.h index ba3c4acd29..33c3880b6b 100644 --- a/Marlin/src/HAL/AVR/timers.h +++ b/Marlin/src/HAL/AVR/timers.h @@ -109,12 +109,12 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) { * (otherwise, characters will be lost due to UART overflow). * Then: Stepper, Endstops, Temperature, and -finally- all others. */ -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP -/* 18 cycles maximum latency */ #ifndef HAL_STEP_TIMER_ISR +/* 18 cycles maximum latency */ #define HAL_STEP_TIMER_ISR() \ extern "C" void TIMER1_COMPA_vect() __attribute__ ((signal, naked, used, externally_visible)); \ extern "C" void TIMER1_COMPA_vect_bottom() asm ("TIMER1_COMPA_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \ diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp index a3985652e7..bbd13dc05a 100644 --- a/Marlin/src/HAL/DUE/HAL.cpp +++ b/Marlin/src/HAL/DUE/HAL.cpp @@ -34,7 +34,7 @@ // Public Variables // ------------------------ -uint16_t HAL_adc_result; +uint16_t MarlinHAL::adc_result; // ------------------------ // Public functions @@ -42,8 +42,7 @@ uint16_t HAL_adc_result; TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); -// HAL initialization task -void HAL_init() { +void MarlinHAL::init() { // Initialize the USB stack #if ENABLED(SDSUPPORT) OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up @@ -52,21 +51,15 @@ void HAL_init() { TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler } -// HAL idle task -void HAL_idletask() { - // Perform USB stack housekeeping - usb_task_idle(); +void MarlinHAL::init_board() { + #ifdef BOARD_INIT + BOARD_INIT(); + #endif } -// Disable interrupts -void cli() { noInterrupts(); } +void MarlinHAL::idletask() { usb_task_idle(); } // Perform USB stack housekeeping -// Enable interrupts -void sei() { interrupts(); } - -void HAL_clear_reset_source() { } - -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { switch ((RSTC->RSTC_SR >> 8) & 0x07) { case 0: return RST_POWER_ON; case 1: return RST_BACKUP; @@ -77,12 +70,7 @@ uint8_t HAL_get_reset_source() { } } -void HAL_reboot() { rstc_start_software_reset(RSTC); } - -void _delay_ms(const int delay_ms) { - // Todo: port for Due? - delay(delay_ms); -} +void MarlinHAL::reboot() { rstc_start_software_reset(RSTC); } extern "C" { extern unsigned int _ebss; // end of bss section @@ -94,19 +82,6 @@ int freeMemory() { return (int)&free_memory - (heap_end ?: (int)&_ebss); } -// ------------------------ -// ADC -// ------------------------ - -void HAL_adc_start_conversion(const uint8_t ch) { - HAL_adc_result = analogRead(ch); -} - -uint16_t HAL_adc_get_result() { - // nop - return HAL_adc_result; -} - // Forward the default serial ports #if USING_HW_SERIAL0 DefaultSerial1 MSerial0(false, Serial); diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 96ab5d9808..9a02c9a0dc 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -38,6 +38,10 @@ #include "../../core/serial_hook.h" +// ------------------------ +// Serial ports +// ------------------------ + typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; @@ -97,60 +101,38 @@ extern DefaultSerial4 MSerial3; #include "MarlinSerial.h" #include "MarlinSerialUSB.h" -// On AVR this is in math.h? -#define square(x) ((x)*(x)) +// ------------------------ +// Types +// ------------------------ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +#define sei() noInterrupts() +#define cli() interrupts() -void cli(); // Disable interrupts -void sei(); // Enable interrupts - -void HAL_clear_reset_source(); // clear reset reason -uint8_t HAL_get_reset_source(); // get reset reason - -void HAL_reboot(); +#define CRITICAL_SECTION_START() const bool _irqon = hal.isr_state(); hal.isr_off() +#define CRITICAL_SECTION_END() if (_irqon) hal.isr_on() // // ADC // -extern uint16_t HAL_adc_result; // result of last ADC conversion +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 #ifndef analogInputToDigitalPin #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) #endif -#define HAL_ANALOG_SELECT(ch) - -inline void HAL_adc_init() {}//todo - -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true - -void HAL_adc_start_conversion(const uint8_t ch); -uint16_t HAL_adc_get_result(); - // -// PWM -// -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } - -// -// Pin Map +// Pin Mapping for M42, M43, M226 // #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin @@ -159,27 +141,18 @@ inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -void HAL_idletask(); -void HAL_init(); - -// -// Utility functions -// -void _delay_ms(const int delay); +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" #endif -int freeMemory(); - #pragma GCC diagnostic pop #ifdef __cplusplus @@ -189,3 +162,69 @@ char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s #ifdef __cplusplus } #endif + +// Return free RAM between end of heap (or end bss) and whatever is current +int freeMemory(); + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board(); // Called less early in setup() + static void reboot(); // Software reset + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } + + static void delay_ms(const int ms) { delay(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init() {} + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) {} + + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); } + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * No inverting the duty cycle in this HAL. + * No changing the maximum size of the provided value to enable finer PWM duty control in this HAL. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/DUE/MarlinSerial.cpp b/Marlin/src/HAL/DUE/MarlinSerial.cpp index fe62ff5607..638f7a1007 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerial.cpp @@ -406,7 +406,7 @@ size_t MarlinSerial::write(const uint8_t c) { const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Make room by polling if it is possible to transmit, and do so! while (i == tx_buffer.tail) { @@ -454,7 +454,7 @@ void MarlinSerial::flushTX() { if (!_written) return; // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Wait until everything was transmitted - We must do polling, as interrupts are disabled while (tx_buffer.head != tx_buffer.tail || !(HWUART->UART_SR & UART_SR_TXEMPTY)) { diff --git a/Marlin/src/HAL/DUE/Tone.cpp b/Marlin/src/HAL/DUE/Tone.cpp index 1ac81faaf0..4bc8142aba 100644 --- a/Marlin/src/HAL/DUE/Tone.cpp +++ b/Marlin/src/HAL/DUE/Tone.cpp @@ -35,7 +35,7 @@ static pin_t tone_pin; volatile static int32_t toggles; -void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) { +void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration/*=0*/) { tone_pin = _pin; toggles = 2 * frequency * duration / 1000; HAL_timer_start(MF_TIMER_TONE, 2 * frequency); diff --git a/Marlin/src/HAL/DUE/timers.h b/Marlin/src/HAL/DUE/timers.h index e2932ff36f..bcfd07e268 100644 --- a/Marlin/src/HAL/DUE/timers.h +++ b/Marlin/src/HAL/DUE/timers.h @@ -125,4 +125,4 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR; } -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 499582b8c1..adf5cecabe 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -52,7 +52,7 @@ // Externs // ------------------------ -portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; +portMUX_TYPE MarlinHAL::spinlock = portMUX_INITIALIZER_UNLOCKED; // ------------------------ // Local defines @@ -64,7 +64,7 @@ portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; // Public Variables // ------------------------ -uint16_t HAL_adc_result; +uint16_t MarlinHAL::adc_result; // ------------------------ // Private Variables @@ -95,20 +95,22 @@ volatile int numPWMUsed = 0, #endif #if ENABLED(USE_ESP32_EXIO) + HardwareSerial YSerial2(2); void Write_EXIO(uint8_t IO, uint8_t v) { - if (ISRS_ENABLED()) { - DISABLE_ISRS(); + if (hal.isr_state()) { + hal.isr_off(); YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100)); - ENABLE_ISRS(); + hal.isr_on(); } else YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100)); } + #endif -void HAL_init_board() { +void MarlinHAL::init_board() { #if ENABLED(USE_ESP32_TASK_WDT) esp_task_wdt_init(10, true); #endif @@ -154,27 +156,24 @@ void HAL_init_board() { #endif } -void HAL_idletask() { +void MarlinHAL::idletask() { #if BOTH(WIFISUPPORT, OTASUPPORT) OTA_handle(); #endif TERN_(ESP3D_WIFISUPPORT, esp3dlib.idletask()); } -void HAL_clear_reset_source() { } +uint8_t MarlinHAL::get_reset_source() { return rtc_get_reset_reason(1); } -uint8_t HAL_get_reset_source() { return rtc_get_reset_reason(1); } - -void HAL_reboot() { ESP.restart(); } - -void _delay_ms(int delay_ms) { delay(delay_ms); } +void MarlinHAL::reboot() { ESP.restart(); } // return free memory between end of heap (or end bss) and whatever is current -int freeMemory() { return ESP.getFreeHeap(); } +int MarlinHAL::freeMemory() { return ESP.getFreeHeap(); } // ------------------------ // ADC // ------------------------ + #define ADC1_CHANNEL(pin) ADC1_GPIO ## pin ## _CHANNEL adc1_channel_t get_channel(int pin) { @@ -196,7 +195,7 @@ void adc1_set_attenuation(adc1_channel_t chan, adc_atten_t atten) { } } -void HAL_adc_init() { +void MarlinHAL::adc_init() { // Configure ADC adc1_config_width(ADC_WIDTH_12Bit); @@ -228,11 +227,11 @@ void HAL_adc_init() { } } -void HAL_adc_start_conversion(const uint8_t adc_pin) { - const adc1_channel_t chan = get_channel(adc_pin); +void MarlinHAL::adc_start(const pin_t pin) { + const adc1_channel_t chan = get_channel(pin); uint32_t mv; esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv); - HAL_adc_result = mv * 1023.0 / 3300.0; + adc_result = mv * 1023.0 / 3300.0; // Change the attenuation level based on the new reading adc_atten_t atten; diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 78eebc8d82..df52e2186c 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -49,8 +49,6 @@ // Defines // ------------------------ -extern portMUX_TYPE spinlock; - #define MYSERIAL1 flushableSerial #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) @@ -65,9 +63,6 @@ extern portMUX_TYPE spinlock; #define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) #define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock) -#define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL) -#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock) -#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock) // ------------------------ // Types @@ -75,14 +70,8 @@ extern portMUX_TYPE spinlock; typedef int16_t pin_t; -#define HAL_SERVO_LIB Servo - -// ------------------------ -// Public Variables -// ------------------------ - -/** result of last ADC conversion */ -extern uint16_t HAL_adc_result; +class Servo; +typedef Servo hal_servo_t; // ------------------------ // Public functions @@ -91,59 +80,18 @@ extern uint16_t HAL_adc_result; // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -// clear reset reason -void HAL_clear_reset_source(); - -// reset reason -uint8_t HAL_get_reset_source(); - -void HAL_reboot(); - -void _delay_ms(int delay); - -#pragma GCC diagnostic push -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic ignored "-Wunused-function" -#endif - -int freeMemory(); - -#pragma GCC diagnostic pop - void analogWrite(pin_t pin, int value); -// ADC -#define HAL_ANALOG_SELECT(pin) - -void HAL_adc_init(); - -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true - -void HAL_adc_start_conversion(const uint8_t adc_pin); - -// PWM -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } - -// Pin Map +// +// Pin Mapping for M42, M43, M226 +// #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -#define BOARD_INIT() HAL_init_board() -void HAL_idletask(); -inline void HAL_init() {} -void HAL_init_board(); - #if ENABLED(USE_ESP32_EXIO) void Write_EXIO(uint8_t IO, uint8_t v); #endif @@ -188,3 +136,85 @@ FORCE_INLINE static void DELAY_CYCLES(uint32_t x) { } } + +// ------------------------ +// Class Utilities +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +int freeMemory(); + +#pragma GCC diagnostic pop + +void _delay_ms(const int ms); + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init() {} // Called early in setup() + static void init_board(); // Called less early in setup() + static void reboot(); // Restart the firmware + + // Interrupts + static portMUX_TYPE spinlock; + static bool isr_state() { return spinlock.owner == portMUX_FREE_VAL; } + static void isr_on() { if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock); } + static void isr_off() { portENTER_CRITICAL(&spinlock); } + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory(); + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * No inverting the duty cycle in this HAL. + * No changing the maximum size of the provided value to enable finer PWM duty control in this HAL. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/ESP32/Tone.cpp b/Marlin/src/HAL/ESP32/Tone.cpp index 9c16cdde80..839c612b6a 100644 --- a/Marlin/src/HAL/ESP32/Tone.cpp +++ b/Marlin/src/HAL/ESP32/Tone.cpp @@ -35,7 +35,7 @@ static pin_t tone_pin; volatile static int32_t toggles; -void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) { +void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration/*=0*/) { tone_pin = _pin; toggles = 2 * frequency * duration / 1000; HAL_timer_start(MF_TIMER_TONE, 2 * frequency); diff --git a/Marlin/src/HAL/ESP32/timers.cpp b/Marlin/src/HAL/ESP32/timers.cpp index df0065f453..c37ad2430c 100644 --- a/Marlin/src/HAL/ESP32/timers.cpp +++ b/Marlin/src/HAL/ESP32/timers.cpp @@ -81,7 +81,7 @@ void IRAM_ATTR timer_isr(void *para) { * @param timer_num timer number to initialize * @param frequency frequency of the timer */ -void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) { +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { const tTimerConfig timer = timer_config[timer_num]; timer_config_t config; diff --git a/Marlin/src/HAL/ESP32/timers.h b/Marlin/src/HAL/ESP32/timers.h index 266169848d..aa4e1551f0 100644 --- a/Marlin/src/HAL/ESP32/timers.h +++ b/Marlin/src/HAL/ESP32/timers.h @@ -127,7 +127,7 @@ extern const tTimerConfig timer_config[]; // Public functions // ------------------------ -void HAL_timer_start (const uint8_t timer_num, uint32_t frequency); +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t count); hal_timer_t HAL_timer_get_compare(const uint8_t timer_num); hal_timer_t HAL_timer_get_count(const uint8_t timer_num); @@ -136,5 +136,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num); void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/LINUX/HAL.cpp b/Marlin/src/HAL/LINUX/HAL.cpp index 0b679170ef..db43f42eaa 100644 --- a/Marlin/src/HAL/LINUX/HAL.cpp +++ b/Marlin/src/HAL/LINUX/HAL.cpp @@ -24,6 +24,10 @@ #include "../../inc/MarlinConfig.h" #include "../shared/Delay.h" +// ------------------------ +// Serial ports +// ------------------------ + MSerialT usb_serial(TERN0(EMERGENCY_PARSER, true)); // U8glib required functions @@ -37,42 +41,21 @@ extern "C" { //************************// // return free heap space -int freeMemory() { - return 0; -} +int freeMemory() { return 0; } // ------------------------ // ADC // ------------------------ -void HAL_adc_init() { +uint8_t MarlinHAL::active_ch = 0; -} - -void HAL_adc_enable_channel(const uint8_t ch) { - -} - -uint8_t active_ch = 0; -void HAL_adc_start_conversion(const uint8_t ch) { - active_ch = ch; -} - -bool HAL_adc_finished() { - return true; -} - -uint16_t HAL_adc_get_result() { - pin_t pin = analogInputToDigitalPin(active_ch); +uint16_t MarlinHAL::adc_value() { + const pin_t pin = analogInputToDigitalPin(active_ch); if (!VALID_PIN(pin)) return 0; - uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF); + const uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF); return data; // return 10bit value as Marlin expects } -void HAL_pwm_init() { - -} - -void HAL_reboot() { /* Reset the application state and GPIO */ } +void MarlinHAL::reboot() { /* Reset the application state and GPIO */ } #endif // __PLAT_LINUX__ diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index d7d3a92b73..43899c632d 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -21,34 +21,13 @@ */ #pragma once -#define CPU_32_BIT - -#define F_CPU 100000000UL -#define SystemCoreClock F_CPU #include #include #include - #undef min #undef max - #include -void _printf (const char *format, ...); -void _putc(uint8_t c); -uint8_t _getc(); - -//extern "C" volatile uint32_t _millis; - -//arduino: Print.h -#define DEC 10 -#define HEX 16 -#define OCT 8 -#define BIN 2 -//arduino: binary.h (weird defines) -#define B01 1 -#define B10 2 - #include "hardware/Clock.h" #include "../shared/Marduino.h" @@ -58,27 +37,56 @@ uint8_t _getc(); #include "watchdog.h" #include "serial.h" -#define SHARED_SERVOS HAS_SERVOS +// ------------------------ +// Defines +// ------------------------ -extern MSerialT usb_serial; -#define MYSERIAL1 usb_serial +#define CPU_32_BIT +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +#define F_CPU 100000000UL +#define SystemCoreClock F_CPU + +#define DELAY_CYCLES(x) Clock::delayCycles(x) #define CPU_ST7920_DELAY_1 600 #define CPU_ST7920_DELAY_2 750 #define CPU_ST7920_DELAY_3 750 +void _printf(const char *format, ...); +void _putc(uint8_t c); +uint8_t _getc(); + +//arduino: Print.h +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 +//arduino: binary.h (weird defines) +#define B01 1 +#define B10 2 + +// ------------------------ +// Serial ports +// ------------------------ + +extern MSerialT usb_serial; +#define MYSERIAL1 usb_serial + // // Interrupts // #define CRITICAL_SECTION_START() #define CRITICAL_SECTION_END() -#define ISRS_ENABLED() -#define ENABLE_ISRS() -#define DISABLE_ISRS() -inline void HAL_init() {} +// ADC +#define HAL_ADC_VREF 5.0 +#define HAL_ADC_RESOLUTION 10 + +// ------------------------ +// Class Utilities +// ------------------------ -// Utility functions #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" @@ -88,29 +96,66 @@ int freeMemory(); #pragma GCC diagnostic pop -// ADC -#define HAL_ADC_VREF 5.0 -#define HAL_ADC_RESOLUTION 10 -#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); -void HAL_adc_enable_channel(const uint8_t ch); -void HAL_adc_start_conversion(const uint8_t ch); -uint16_t HAL_adc_get_result(); +class MarlinHAL { +public: -// PWM -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Earliest possible init, before setup() + MarlinHAL() {} -// Reset source -inline void HAL_clear_reset_source(void) {} -inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Reset the application state and GPIO -void HAL_reboot(); // Reset the application state and GPIO + // Interrupts + static bool isr_state() { return true; } + static void isr_on() {} + static void isr_off() {} -/* ---------------- Delay in cycles */ -FORCE_INLINE static void DELAY_CYCLES(uint64_t x) { - Clock::delayCycles(x); -} + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask() {} + + // Reset + static constexpr uint8_t reset_reason = RST_POWER_ON; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint8_t active_ch; + + // Called by Temperature::init once at startup + static void adc_init() {} + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t) {} + + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch) { active_ch = ch; } + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to change the resolution or invert the duty cycle. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + + static void set_pwm_frequency(const pin_t, int) {} +}; diff --git a/Marlin/src/HAL/LINUX/arduino.cpp b/Marlin/src/HAL/LINUX/arduino.cpp index 4b56d02a38..075b4ccde2 100644 --- a/Marlin/src/HAL/LINUX/arduino.cpp +++ b/Marlin/src/HAL/LINUX/arduino.cpp @@ -31,9 +31,7 @@ void cli() { } // Disable void sei() { } // Enable // Time functions -void _delay_ms(const int delay_ms) { - delay(delay_ms); -} +void _delay_ms(const int ms) { delay(ms); } uint32_t millis() { return (uint32_t)Clock::millis(); diff --git a/Marlin/src/HAL/LINUX/include/Arduino.h b/Marlin/src/HAL/LINUX/include/Arduino.h index d4086e259a..f05aaed880 100644 --- a/Marlin/src/HAL/LINUX/include/Arduino.h +++ b/Marlin/src/HAL/LINUX/include/Arduino.h @@ -59,10 +59,9 @@ typedef uint8_t byte; #endif #define sq(v) ((v) * (v)) -#define square(v) sq(v) #define constrain(value, arg_min, arg_max) ((value) < (arg_min) ? (arg_min) :((value) > (arg_max) ? (arg_max) : (value))) -//Interrupts +// Interrupts void cli(); // Disable void sei(); // Enable void attachInterrupt(uint32_t pin, void (*callback)(), uint32_t mode); @@ -74,8 +73,8 @@ extern "C" { } // Time functions -extern "C" void delay(const int milis); -void _delay_ms(const int delay); +extern "C" void delay(const int ms); +void _delay_ms(const int ms); void delayMicroseconds(unsigned long); uint32_t millis(); diff --git a/Marlin/src/HAL/LINUX/timers.h b/Marlin/src/HAL/LINUX/timers.h index a98ceb6f39..2d2a95774c 100644 --- a/Marlin/src/HAL/LINUX/timers.h +++ b/Marlin/src/HAL/LINUX/timers.h @@ -92,5 +92,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num); void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index cee9cfc5f7..541848b08a 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -31,7 +31,7 @@ DefaultSerial1 USBSerial(false, UsbSerial); -uint32_t HAL_adc_reading = 0; +uint32_t MarlinHAL::adc_result = 0; // U8glib required functions extern "C" { @@ -41,8 +41,6 @@ extern "C" { void u8g_Delay(uint16_t val) { delay(val); } } -//************************// - // return free heap space int freeMemory() { char stack_end; @@ -54,7 +52,27 @@ int freeMemory() { return result; } -// scan command line for code +void MarlinHAL::reboot() { NVIC_SystemReset(); } + +uint8_t MarlinHAL::get_reset_source() { + #if ENABLED(USE_WATCHDOG) + if (watchdog_timed_out()) return RST_WATCHDOG; + #endif + return RST_POWER_ON; +} + +void MarlinHAL::clear_reset_source() { + TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag()); +} + +void flashFirmware(const int16_t) { + delay(500); // Give OS time to disconnect + USB_Connect(false); // USB clear connection + delay(1000); // Give OS time to notice + hal.reboot(); +} + +// For M42/M43, scan command line for pin code // return index into pin map array if found and the pin is valid. // return dval if not found or not a valid pin. int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { @@ -63,24 +81,4 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { return ind > -1 ? ind : dval; } -void flashFirmware(const int16_t) { - delay(500); // Give OS time to disconnect - USB_Connect(false); // USB clear connection - delay(1000); // Give OS time to notice - HAL_reboot(); -} - -void HAL_clear_reset_source(void) { - TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag()); -} - -uint8_t HAL_get_reset_source(void) { - #if ENABLED(USE_WATCHDOG) - if (watchdog_timed_out()) return RST_WATCHDOG; - #endif - return RST_POWER_ON; -} - -void HAL_reboot() { NVIC_SystemReset(); } - #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index f5e4326983..eefacae995 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -28,8 +28,6 @@ #define CPU_32_BIT -void HAL_init(); - #include #include #include @@ -47,12 +45,9 @@ extern "C" volatile uint32_t _millis; #include #include -// -// Default graphical display delays -// -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 +// ------------------------ +// Serial ports +// ------------------------ typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1; extern DefaultSerial1 USBSerial; @@ -114,26 +109,12 @@ extern DefaultSerial1 USBSerial; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() + +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() // -// Utility functions -// -#pragma GCC diagnostic push -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic ignored "-Wunused-function" -#endif - -int freeMemory(); - -#pragma GCC diagnostic pop - -// -// ADC API +// ADC // #define ADC_MEDIAN_FILTER_SIZE (23) // Higher values increase step delay (phase shift), @@ -152,20 +133,9 @@ int freeMemory(); #define HAL_ADC_RESOLUTION 12 // 15 bit maximum, raw temperature is stored as int16_t #define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL -using FilteredADC = LPC176x::ADC; -extern uint32_t HAL_adc_reading; -[[gnu::always_inline]] inline void HAL_adc_start_conversion(const pin_t pin) { - HAL_adc_reading = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits -} -[[gnu::always_inline]] inline uint16_t HAL_adc_get_result() { - return HAL_adc_reading; -} - -#define HAL_adc_init() -#define HAL_ANALOG_SELECT(pin) FilteredADC::enable_channel(pin) -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() (true) +// +// Pin Mapping for M42, M43, M226 +// // Test whether the pin is valid constexpr bool VALID_PIN(const pin_t pin) { @@ -192,32 +162,101 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval); // P0.6 thru P0.9 are for the onboard SD card #define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, -#define HAL_IDLETASK 1 -void HAL_idletask(); +// ------------------------ +// Defines +// ------------------------ #define PLATFORM_M997_SUPPORT void flashFirmware(const int16_t); #define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Hardware PWM pins run at the same frequency and all - * Software PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +// Default graphical display delays +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 -/** - * set_pwm_duty - * Set the PWM duty cycle of the provided pin to the provided value - * Optionally allows inverting the duty cycle [default = false] - * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); +// ------------------------ +// Class Utilities +// ------------------------ -// Reset source -void HAL_clear_reset_source(void); -uint8_t HAL_get_reset_source(void); +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif -void HAL_reboot(); +int freeMemory(); + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source(); + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + using FilteredADC = LPC176x::ADC; + + // Called by Temperature::init once at startup + static void adc_init() {} + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) { + FilteredADC::enable_channel(pin); + } + + // Begin ADC sampling on the given pin + static uint32_t adc_result; + static void adc_start(const pin_t pin) { + adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits + } + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return uint16_t(adc_result); } + + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + + /** + * Set the frequency of the timer corresponding to the provided pin + * All Hardware PWM pins will run at the same frequency and + * All Software PWM pins will run at the same frequency + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +}; diff --git a/Marlin/src/HAL/LPC1768/Servo.h b/Marlin/src/HAL/LPC1768/Servo.h index eb12fd20f4..f02f503a67 100644 --- a/Marlin/src/HAL/LPC1768/Servo.h +++ b/Marlin/src/HAL/LPC1768/Servo.h @@ -65,4 +65,5 @@ class libServo: public Servo { } }; -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; diff --git a/Marlin/src/HAL/LPC1768/fast_pwm.cpp b/Marlin/src/HAL/LPC1768/fast_pwm.cpp index ece115aa01..6d2b1a9002 100644 --- a/Marlin/src/HAL/LPC1768/fast_pwm.cpp +++ b/Marlin/src/HAL/LPC1768/fast_pwm.cpp @@ -21,16 +21,16 @@ */ #ifdef TARGET_LPC1768 -#include "../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfig.h" #include -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { if (!LPC176x::pin_is_valid(pin)) return; if (LPC176x::pwm_attach_pin(pin)) LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range } -void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { LPC176x::pwm_set_frequency(pin, f_desired); } diff --git a/Marlin/src/HAL/LPC1768/main.cpp b/Marlin/src/HAL/LPC1768/main.cpp index ef0dc42c78..419c99793f 100644 --- a/Marlin/src/HAL/LPC1768/main.cpp +++ b/Marlin/src/HAL/LPC1768/main.cpp @@ -48,7 +48,7 @@ void SysTick_Callback() { disk_timerproc(); } TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); -void HAL_init() { +void MarlinHAL::init() { // Init LEDs #if PIN_EXISTS(LED) @@ -130,7 +130,7 @@ void HAL_init() { const millis_t usb_timeout = millis() + 2000; while (!USB_Configuration && PENDING(millis(), usb_timeout)) { delay(50); - HAL_idletask(); + idletask(); #if PIN_EXISTS(LED) TOGGLE(LED_PIN); // Flash quickly during USB initialization #endif @@ -142,7 +142,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // If Marlin is using the SD card we need to lock it to prevent access from // a PC via USB. diff --git a/Marlin/src/HAL/LPC1768/timers.h b/Marlin/src/HAL/LPC1768/timers.h index 78e856db28..c6d7bc632e 100644 --- a/Marlin/src/HAL/LPC1768/timers.h +++ b/Marlin/src/HAL/LPC1768/timers.h @@ -170,4 +170,4 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { } } -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index 436b4b4daa..ee2e31fc7f 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -21,18 +21,10 @@ */ #pragma once -#define CPU_32_BIT -#define HAL_IDLETASK -void HAL_idletask(); - -#define F_CPU 100000000 -#define SystemCoreClock F_CPU #include #include - #undef min #undef max - #include #include "pinmapping.h" @@ -40,8 +32,6 @@ void _printf (const char *format, ...); void _putc(uint8_t c); uint8_t _getc(); -//extern "C" volatile uint32_t _millis; - //arduino: Print.h #define DEC 10 #define HEX 16 @@ -58,7 +48,23 @@ uint8_t _getc(); #include "watchdog.h" #include "serial.h" -#define SHARED_SERVOS HAS_SERVOS +// ------------------------ +// Defines +// ------------------------ + +#define CPU_32_BIT +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +#define F_CPU 100000000 +#define SystemCoreClock F_CPU + +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +// ------------------------ +// Serial ports +// ------------------------ extern MSerialT serial_stream_0; extern MSerialT serial_stream_1; @@ -98,49 +104,19 @@ extern MSerialT serial_stream_3; #endif #endif - -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - -// +// ------------------------ // Interrupts -// +// ------------------------ + #define CRITICAL_SECTION_START() #define CRITICAL_SECTION_END() -#define ISRS_ENABLED() -#define ENABLE_ISRS() -#define DISABLE_ISRS() - -inline void HAL_init() {} - -// Utility functions -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" -int freeMemory(); -#pragma GCC diagnostic pop +// ------------------------ // ADC +// ------------------------ + #define HAL_ADC_VREF 5.0 #define HAL_ADC_RESOLUTION 10 -#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true - -void HAL_adc_init(); -void HAL_adc_enable_channel(const uint8_t ch); -void HAL_adc_start_conversion(const uint8_t ch); -uint16_t HAL_adc_get_result(); - -// PWM -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } - -// Reset source -inline void HAL_clear_reset_source(void) {} -inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } - -void HAL_reboot(); /* ---------------- Delay in cycles */ @@ -159,29 +135,22 @@ constexpr inline std::size_t strlen_constexpr(const char* str) { // https://github.com/gcc-mirror/gcc/blob/5c7634a0e5f202935aa6c11b6ea953b8bf80a00a/libstdc%2B%2B-v3/include/bits/char_traits.h#L329 if (str != nullptr) { std::size_t i = 0; - while (str[i] != '\0') { - ++i; - } - + while (str[i] != '\0') ++i; return i; } - return 0; } constexpr inline int strncmp_constexpr(const char* lhs, const char* rhs, std::size_t count) { // https://github.com/gcc-mirror/gcc/blob/13b9cbfc32fe3ac4c81c4dd9c42d141c8fb95db4/libstdc%2B%2B-v3/include/bits/char_traits.h#L655 - if (lhs == nullptr || rhs == nullptr) { + if (lhs == nullptr || rhs == nullptr) return rhs != nullptr ? -1 : 1; - } - for (std::size_t i = 0; i < count; ++i) { - if (lhs[i] != rhs[i]) { + for (std::size_t i = 0; i < count; ++i) + if (lhs[i] != rhs[i]) return lhs[i] < rhs[i] ? -1 : 1; - } else if (lhs[i] == '\0') { + else if (lhs[i] == '\0') return 0; - } - } return 0; } @@ -193,14 +162,11 @@ constexpr inline const char* strstr_constexpr(const char* str, const char* targe do { char sc = {}; do { - if ((sc = *str++) == '\0') { - return nullptr; - } + if ((sc = *str++) == '\0') return nullptr; } while (sc != c); } while (strncmp_constexpr(str, target, len) != 0); --str; } - return str; } @@ -211,12 +177,87 @@ constexpr inline char* strstr_constexpr(char* str, const char* target) { do { char sc = {}; do { - if ((sc = *str++) == '\0') { - return nullptr; - } + if ((sc = *str++) == '\0') return nullptr; } while (sc != c); } while (strncmp_constexpr(str, target, len) != 0); --str; } return str; } + +// ------------------------ +// Class Utilities +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +int freeMemory(); + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return true; } + static void isr_on() {} + static void isr_off() {} + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static constexpr uint8_t reset_reason = RST_POWER_ON; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint8_t active_ch; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch); + + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch); + + // Is the ADC ready for reading? + static bool adc_ready(); + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/NATIVE_SIM/timers.h b/Marlin/src/HAL/NATIVE_SIM/timers.h index cedfdb62d6..be38d583b6 100644 --- a/Marlin/src/HAL/NATIVE_SIM/timers.h +++ b/Marlin/src/HAL/NATIVE_SIM/timers.h @@ -87,5 +87,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num); void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index a5febad83b..14b6a437dc 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -42,10 +42,6 @@ #endif #endif -// ------------------------ -// Local defines -// ------------------------ - #define GET_TEMP_0_ADC() TERN(HAS_TEMP_ADC_0, PIN_TO_ADC(TEMP_0_PIN), -1) #define GET_TEMP_1_ADC() TERN(HAS_TEMP_ADC_1, PIN_TO_ADC(TEMP_1_PIN), -1) #define GET_TEMP_2_ADC() TERN(HAS_TEMP_ADC_2, PIN_TO_ADC(TEMP_2_PIN), -1) @@ -61,17 +57,21 @@ #define GET_BOARD_ADC() TERN(HAS_TEMP_ADC_BOARD, PIN_TO_ADC(TEMP_BOARD_PIN), -1) #define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1) #define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1) +#define GET_JOY_ADC_X() TERN(HAS_JOY_ADC_X, PIN_TO_ADC(JOY_X_PIN), -1) +#define GET_JOY_ADC_Y() TERN(HAS_JOY_ADC_Y, PIN_TO_ADC(JOY_Y_PIN), -1) +#define GET_JOY_ADC_Z() TERN(HAS_JOY_ADC_Z, PIN_TO_ADC(JOY_Z_PIN), -1) #define IS_ADC_REQUIRED(n) ( \ GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \ || GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \ - || GET_BED_ADC() == n \ - || GET_CHAMBER_ADC() == n \ - || GET_PROBE_ADC() == n \ - || GET_COOLER_ADC() == n \ - || GET_BOARD_ADC() == n \ + || GET_BED_ADC() == n \ + || GET_CHAMBER_ADC() == n \ + || GET_PROBE_ADC() == n \ + || GET_COOLER_ADC() == n \ + || GET_BOARD_ADC() == n \ || GET_FILAMENT_WIDTH_ADC() == n \ - || GET_BUTTONS_ADC() == n \ + || GET_BUTTONS_ADC() == n \ + || GET_JOY_ADC_X() == n || GET_JOY_ADC_Y() == n || GET_JOY_ADC_Z() == n \ ) #if IS_ADC_REQUIRED(0) @@ -91,6 +91,118 @@ #define DMA_IS_REQUIRED 1 #endif +enum ADCIndex { + #if GET_TEMP_0_ADC() == 0 + TEMP_0, + #endif + #if GET_TEMP_1_ADC() == 0 + TEMP_1, + #endif + #if GET_TEMP_2_ADC() == 0 + TEMP_2, + #endif + #if GET_TEMP_3_ADC() == 0 + TEMP_3, + #endif + #if GET_TEMP_4_ADC() == 0 + TEMP_4, + #endif + #if GET_TEMP_5_ADC() == 0 + TEMP_5, + #endif + #if GET_TEMP_6_ADC() == 0 + TEMP_6, + #endif + #if GET_TEMP_7_ADC() == 0 + TEMP_7, + #endif + #if GET_BED_ADC() == 0 + TEMP_BED, + #endif + #if GET_CHAMBER_ADC() == 0 + TEMP_CHAMBER, + #endif + #if GET_PROBE_ADC() == 0 + TEMP_PROBE, + #endif + #if GET_COOLER_ADC() == 0 + TEMP_COOLER, + #endif + #if GET_BOARD_ADC() == 0 + TEMP_BOARD, + #endif + #if GET_FILAMENT_WIDTH_ADC() == 0 + FILWIDTH, + #endif + #if GET_BUTTONS_ADC() == 0 + ADC_KEY, + #endif + #if GET_JOY_ADC_X() == 0 + JOY_X, + #endif + #if GET_JOY_ADC_Y() == 0 + JOY_Y, + #endif + #if GET_JOY_ADC_Z() == 0 + JOY_Z, + #endif + #if GET_TEMP_0_ADC() == 1 + TEMP_0, + #endif + #if GET_TEMP_1_ADC() == 1 + TEMP_1, + #endif + #if GET_TEMP_2_ADC() == 1 + TEMP_2, + #endif + #if GET_TEMP_3_ADC() == 1 + TEMP_3, + #endif + #if GET_TEMP_4_ADC() == 1 + TEMP_4, + #endif + #if GET_TEMP_5_ADC() == 1 + TEMP_5, + #endif + #if GET_TEMP_6_ADC() == 1 + TEMP_6, + #endif + #if GET_TEMP_7_ADC() == 1 + TEMP_7, + #endif + #if GET_BED_ADC() == 1 + TEMP_BED, + #endif + #if GET_CHAMBER_ADC() == 1 + TEMP_CHAMBER, + #endif + #if GET_PROBE_ADC() == 1 + TEMP_PROBE, + #endif + #if GET_COOLER_ADC() == 1 + TEMP_COOLER, + #endif + #if GET_BOARD_ADC() == 1 + TEMP_BOARD, + #endif + #if GET_FILAMENT_WIDTH_ADC() == 1 + FILWIDTH, + #endif + #if GET_BUTTONS_ADC() == 1 + ADC_KEY, + #endif + #if GET_JOY_ADC_X() == 1 + JOY_X, + #endif + #if GET_JOY_ADC_Y() == 1 + JOY_Y, + #endif + #if GET_JOY_ADC_Z() == 1 + JOY_Z, + #endif + ADC_COUNT +}; + // ------------------------ // Types // ------------------------ @@ -108,12 +220,10 @@ // Private Variables // ------------------------ -uint16_t HAL_adc_result; - #if ADC_IS_REQUIRED // Pins used by ADC inputs. Order must be ADC0 inputs first then ADC1 - const uint8_t adc_pins[] = { + static constexpr uint8_t adc_pins[ADC_COUNT] = { // ADC0 pins #if GET_TEMP_0_ADC() == 0 TEMP_0_PIN, @@ -160,6 +270,15 @@ uint16_t HAL_adc_result; #if GET_BUTTONS_ADC() == 0 ADC_KEYPAD_PIN, #endif + #if GET_JOY_ADC_X() == 0 + JOY_X_PIN, + #endif + #if GET_JOY_ADC_Y() == 0 + JOY_Y_PIN, + #endif + #if GET_JOY_ADC_Z() == 0 + JOY_Z_PIN, + #endif // ADC1 pins #if GET_TEMP_0_ADC() == 1 TEMP_0_PIN, @@ -206,15 +325,23 @@ uint16_t HAL_adc_result; #if GET_BUTTONS_ADC() == 1 ADC_KEYPAD_PIN, #endif + #if GET_JOY_ADC_X() == 1 + JOY_X_PIN, + #endif + #if GET_JOY_ADC_Y() == 1 + JOY_Y_PIN, + #endif + #if GET_JOY_ADC_Z() == 1 + JOY_Z_PIN, + #endif }; - uint16_t HAL_adc_results[COUNT(adc_pins)]; + static uint16_t adc_results[ADC_COUNT]; #if ADC0_IS_REQUIRED - Adafruit_ZeroDMA adc0DMAProgram, - adc0DMARead; + Adafruit_ZeroDMA adc0DMAProgram, adc0DMARead; - const HAL_DMA_DAC_Registers adc0_dma_regs_list[] = { + static constexpr HAL_DMA_DAC_Registers adc0_dma_regs_list[ADC_COUNT] = { #if GET_TEMP_0_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_0_PIN) }, #endif @@ -260,16 +387,24 @@ uint16_t HAL_adc_result; #if GET_BUTTONS_ADC() == 0 { PIN_TO_INPUTCTRL(ADC_KEYPAD_PIN) }, #endif + #if GET_JOY_ADC_X() == 0 + { PIN_TO_INPUTCTRL(JOY_X_PIN) }, + #endif + #if GET_JOY_ADC_Y() == 0 + { PIN_TO_INPUTCTRL(JOY_Y_PIN) }, + #endif + #if GET_JOY_ADC_Z() == 0 + { PIN_TO_INPUTCTRL(JOY_Z_PIN) }, + #endif }; #define ADC0_AINCOUNT COUNT(adc0_dma_regs_list) #endif // ADC0_IS_REQUIRED #if ADC1_IS_REQUIRED - Adafruit_ZeroDMA adc1DMAProgram, - adc1DMARead; + Adafruit_ZeroDMA adc1DMAProgram, adc1DMARead; - const HAL_DMA_DAC_Registers adc1_dma_regs_list[] = { + static constexpr HAL_DMA_DAC_Registers adc1_dma_regs_list[ADC_COUNT] = { #if GET_TEMP_0_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_0_PIN) }, #endif @@ -315,6 +450,15 @@ uint16_t HAL_adc_result; #if GET_BUTTONS_ADC() == 1 { PIN_TO_INPUTCTRL(ADC_KEYPAD_PIN) }, #endif + #if GET_JOY_ADC_X() == 1 + { PIN_TO_INPUTCTRL(JOY_X_PIN) }, + #endif + #if GET_JOY_ADC_Y() == 1 + { PIN_TO_INPUTCTRL(JOY_Y_PIN) }, + #endif + #if GET_JOY_ADC_Z() == 1 + { PIN_TO_INPUTCTRL(JOY_Z_PIN) }, + #endif }; #define ADC1_AINCOUNT COUNT(adc1_dma_regs_list) @@ -326,9 +470,10 @@ uint16_t HAL_adc_result; // Private functions // ------------------------ -#if DMA_IS_REQUIRED +void MarlinHAL::dma_init() { + + #if DMA_IS_REQUIRED - void dma_init() { DmacDescriptor *descriptor; #if ADC0_IS_REQUIRED @@ -357,7 +502,7 @@ uint16_t HAL_adc_result; if (adc0DMARead.allocate() == DMA_STATUS_OK) { adc0DMARead.addDescriptor( (void *)&ADC0->RESULT.reg, // SRC - &HAL_adc_results, // DEST + &adc_results, // DEST ADC0_AINCOUNT, // CNT DMA_BEAT_SIZE_HWORD, false, // SRCINC @@ -394,7 +539,7 @@ uint16_t HAL_adc_result; if (adc1DMARead.allocate() == DMA_STATUS_OK) { adc1DMARead.addDescriptor( (void *)&ADC1->RESULT.reg, // SRC - &HAL_adc_results[ADC0_AINCOUNT], // DEST + &adc_results[ADC0_AINCOUNT], // DEST ADC1_AINCOUNT, // CNT DMA_BEAT_SIZE_HWORD, false, // SRCINC @@ -407,16 +552,16 @@ uint16_t HAL_adc_result; #endif DMAC->PRICTRL0.bit.RRLVLEN0 = true; // Activate round robin for DMA channels required by ADCs - } -#endif // DMA_IS_REQUIRED + #endif // DMA_IS_REQUIRED +} // ------------------------ // Public functions // ------------------------ // HAL initialization task -void HAL_init() { +void MarlinHAL::init() { TERN_(DMA_IS_REQUIRED, dma_init()); #if ENABLED(SDSUPPORT) #if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT) @@ -426,17 +571,9 @@ void HAL_init() { #endif } -// HAL idle task -/* -void HAL_idletask() { -} -*/ - -void HAL_clear_reset_source() { } - #pragma push_macro("WDT") #undef WDT // Required to be able to use '.bit.WDT'. Compiler wrongly replace struct field with WDT define -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { RSTC_RCAUSE_Type resetCause; resetCause.reg = REG_RSTC_RCAUSE; @@ -450,7 +587,7 @@ uint8_t HAL_get_reset_source() { } #pragma pop_macro("WDT") -void HAL_reboot() { NVIC_SystemReset(); } +void MarlinHAL::reboot() { NVIC_SystemReset(); } extern "C" { void * _sbrk(int incr); @@ -468,9 +605,11 @@ int freeMemory() { // ADC // ------------------------ -void HAL_adc_init() { +uint16_t MarlinHAL::adc_result; + +void MarlinHAL::adc_init() { #if ADC_IS_REQUIRED - memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results)); // Fill result with invalid values + memset(adc_results, 0xFF, sizeof(adc_results)); // Fill result with invalid values LOOP_L_N(pi, COUNT(adc_pins)) pinPeripheral(adc_pins[pi], PIO_ANALOG); @@ -505,17 +644,13 @@ void HAL_adc_init() { #endif // ADC_IS_REQUIRED } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +void MarlinHAL::adc_start(const pin_t pin) { #if ADC_IS_REQUIRED - LOOP_L_N(pi, COUNT(adc_pins)) { - if (adc_pin == adc_pins[pi]) { - HAL_adc_result = HAL_adc_results[pi]; - return; - } - } + LOOP_L_N(pi, COUNT(adc_pins)) + if (pin == adc_pins[pi]) { adc_result = adc_results[pi]; return; } #endif - HAL_adc_result = 0xFFFF; + adc_result = 0xFFFF; } #endif // __SAMD51__ diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index c262752a8d..3b09a885a5 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -89,51 +89,30 @@ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -#define cli() __disable_irq() // Disable interrupts -#define sei() __enable_irq() // Enable interrupts - -void HAL_clear_reset_source(); // clear reset reason -uint8_t HAL_get_reset_source(); // get reset reason - -void HAL_reboot(); +#define cli() __disable_irq() // Disable interrupts +#define sei() __enable_irq() // Enable interrupts // // ADC // -extern uint16_t HAL_adc_result; // Most recent ADC conversion - -#define HAL_ANALOG_SELECT(pin) - -void HAL_adc_init(); //#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values. #define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 // ... 12 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true - -void HAL_adc_start_conversion(const uint8_t adc_pin); // -// PWM -// -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } - -// -// Pin Map +// Pin Mapping for M42, M43, M226 // #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin @@ -142,35 +121,93 @@ inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -// Enable hooks into idle and setup for HAL -void HAL_init(); -/* -#define HAL_IDLETASK 1 -void HAL_idletask(); -*/ - -// -// Utility functions -// -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" #endif -int freeMemory(); - -#pragma GCC diagnostic pop - #ifdef __cplusplus extern "C" { #endif + char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s); + +extern "C" int freeMemory(); + #ifdef __cplusplus } #endif + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } + + static void delay_ms(const int ms) { delay(ms); } + + // Tasks, called from idle() + static void idletask() {} + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +private: + static void dma_init(); +}; diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index 0920a72ec1..324a78316a 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -53,16 +53,18 @@ // Public Variables // ------------------------ -uint16_t HAL_adc_result; +uint16_t MarlinHAL::adc_result; // ------------------------ // Public functions // ------------------------ -TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); +#if ENABLED(POSTMORTEM_DEBUGGING) + extern void install_min_serial(); +#endif // HAL initialization task -void HAL_init() { +void MarlinHAL::init() { // Ensure F_CPU is a constant expression. // If the compiler breaks here, it means that delay code that should compute at compile time will not work. // So better safe than sorry here. @@ -103,7 +105,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // Stm32duino currently doesn't have a "loop/idle" method CDC_resume_receive(); @@ -111,9 +113,9 @@ void HAL_idletask() { #endif } -void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } +void MarlinHAL::reboot() { NVIC_SystemReset(); } -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { return #ifdef RCC_FLAG_IWDGRST // Some sources may not exist... RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) ? RST_WATCHDOG : @@ -137,24 +139,14 @@ uint8_t HAL_get_reset_source() { ; } -void HAL_reboot() { NVIC_SystemReset(); } - -void _delay_ms(const int delay_ms) { delay(delay_ms); } +void MarlinHAL::clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } extern "C" { extern unsigned int _ebss; // end of bss section } -// ------------------------ -// ADC -// ------------------------ - -// TODO: Make sure this doesn't cause any delay -void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); } -uint16_t HAL_adc_get_result() { return HAL_adc_result; } - // Reset the system to initiate a firmware flash -WEAK void flashFirmware(const int16_t) { HAL_reboot(); } +WEAK void flashFirmware(const int16_t) { hal.reboot(); } // Maple Compatibility volatile uint32_t systick_uptime_millis = 0; diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 9429bb7e7c..f5e8c1187d 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -44,9 +44,9 @@ #define CPU_ST7920_DELAY_2 40 #define CPU_ST7920_DELAY_3 340 -// -// Serial Ports -// +// ------------------------ +// Serial ports +// ------------------------ #ifdef USBCON #include #include "../../core/serial_hook.h" @@ -115,17 +115,14 @@ #define analogInputToDigitalPin(p) (p) #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +// +// Interrupts +// +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() #define cli() __disable_irq() #define sei() __enable_irq() -// On AVR this is in math.h? -#define square(x) ((x)*(x)) - // ------------------------ // Types // ------------------------ @@ -136,56 +133,14 @@ typedef int16_t pin_t; #endif -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; #define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos() #define RESUME_SERVO_OUTPUT() libServo::resume_all_servos() // ------------------------ -// Public Variables -// ------------------------ - -// result of last ADC conversion -extern uint16_t HAL_adc_result; - -// ------------------------ -// Public functions -// ------------------------ - -// Memory related -#define __bss_end __bss_end__ - -// Enable hooks into setup for HAL -void HAL_init(); -#define HAL_IDLETASK 1 -void HAL_idletask(); - -// Clear reset reason -void HAL_clear_reset_source(); - -// Reset reason -uint8_t HAL_get_reset_source(); - -void HAL_reboot(); - -void _delay_ms(const int delay); - -extern "C" char* _sbrk(int incr); - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" - -static inline int freeMemory() { - volatile char top; - return &top - reinterpret_cast(_sbrk(0)); -} - -#pragma GCC diagnostic pop - -// // ADC -// - -#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT) +// ------------------------ #ifdef ADC_RESOLUTION #define HAL_ADC_RESOLUTION ADC_RESOLUTION @@ -194,16 +149,10 @@ static inline int freeMemory() { #endif #define HAL_ADC_VREF 3.3 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true - -inline void HAL_adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); } - -void HAL_adc_start_conversion(const uint8_t adc_pin); - -uint16_t HAL_adc_get_result(); +// +// Pin Mapping for M42, M43, M226 +// #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) @@ -226,17 +175,92 @@ extern volatile uint32_t systick_uptime_millis; #define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Timer PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +// ------------------------ +// Class Utilities +// ------------------------ -/** - * set_pwm_duty - * Set the PWM duty cycle of the provided pin to the provided value - * Optionally allows inverting the duty cycle [default = false] - * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); +// Memory related +#define __bss_end __bss_end__ + +extern "C" char* _sbrk(int incr); + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +static inline int freeMemory() { + volatile char top; + return &top - reinterpret_cast(_sbrk(0)); +} + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } + + static void delay_ms(const int ms) { delay(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source(); + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init() { + analogReadResolution(HAL_ADC_RESOLUTION); + } + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); } + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin) { adc_result = analogRead(pin); } + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally change the maximum size of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + + /** + * Set the frequency of the timer for the given pin. + * All Timer PWM pins run at the same frequency. + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); + +}; diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index 8ee4761647..40d320d5e8 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -102,9 +102,9 @@ static SPISettings spiConfig; // Soft SPI receive byte uint8_t spiRec() { - DISABLE_ISRS(); // No interrupts during byte receive + hal.isr_off(); // No interrupts during byte receive const uint8_t data = HAL_SPI_STM32_SpiTransfer_Mode_3(0xFF); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts return data; } @@ -116,9 +116,9 @@ static SPISettings spiConfig; // Soft SPI send byte void spiSend(uint8_t data) { - DISABLE_ISRS(); // No interrupts during byte send + hal.isr_off(); // No interrupts during byte send HAL_SPI_STM32_SpiTransfer_Mode_3(data); // Don't care what is received - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts } // Soft SPI send block diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 252b057362..7c8cc8dd21 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -174,9 +174,9 @@ bool PersistentStore::access_finish() { UNLOCK_FLASH(); TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); - DISABLE_ISRS(); + hal.isr_off(); status = HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError); - ENABLE_ISRS(); + hal.isr_on(); TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); if (status != HAL_OK) { DEBUG_ECHOLNPGM("HAL_FLASHEx_Erase=", status); @@ -229,9 +229,9 @@ bool PersistentStore::access_finish() { // output. Servo output still glitches with interrupts disabled, but recovers after the // erase. TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); - DISABLE_ISRS(); + hal.isr_off(); eeprom_buffer_flush(); - ENABLE_ISRS(); + hal.isr_on(); TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); eeprom_data_written = false; diff --git a/Marlin/src/HAL/STM32/fast_pwm.cpp b/Marlin/src/HAL/STM32/fast_pwm.cpp index 590c9dbe3d..a0d8ecc612 100644 --- a/Marlin/src/HAL/STM32/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32/fast_pwm.cpp @@ -29,7 +29,7 @@ // Array to support sticky frequency sets per timer static uint16_t timer_freq[TIMER_NUM]; -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { const uint16_t duty = invert ? v_size - v : v; if (PWM_PIN(pin)) { const PinName pin_name = digitalPinToPinName(pin); @@ -61,7 +61,7 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255 } } -void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer const PinName pin_name = digitalPinToPinName(pin); TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance diff --git a/Marlin/src/HAL/STM32/pinsDebug.h b/Marlin/src/HAL/STM32/pinsDebug.h index 73d850fc43..a7f022a0b6 100644 --- a/Marlin/src/HAL/STM32/pinsDebug.h +++ b/Marlin/src/HAL/STM32/pinsDebug.h @@ -115,7 +115,6 @@ const XrefInfo pin_xref[] PROGMEM = { #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) #define PRINT_PORT(ANUM) port_print(ANUM) #define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine -#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num // x is a variable used to search pin_array #define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital) @@ -123,6 +122,11 @@ const XrefInfo pin_xref[] PROGMEM = { #define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) #define MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin +// +// Pin Mapping for M43 +// +#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num + #ifndef M43_NEVER_TOUCH #define _M43_NEVER_TOUCH(Index) (Index >= 9 && Index <= 12) // SERIAL/USB pins: PA9(TX) PA10(RX) PA11(USB_DM) PA12(USB_DP) #ifdef KILL_PIN diff --git a/Marlin/src/HAL/STM32/timers.h b/Marlin/src/HAL/STM32/timers.h index aad543229e..6828998198 100644 --- a/Marlin/src/HAL/STM32/timers.h +++ b/Marlin/src/HAL/STM32/timers.h @@ -116,5 +116,5 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha } } -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index a0486da5b0..1d58b106ad 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -79,7 +79,7 @@ #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ // ------------------------ -// Public Variables +// Serial ports // ------------------------ #if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE @@ -112,74 +112,37 @@ #endif #endif -uint16_t HAL_adc_result; - // ------------------------ -// Private Variables +// ADC // ------------------------ -STM32ADC adc(ADC1); -const uint8_t adc_pins[] = { - OPTITEM(HAS_TEMP_ADC_0, TEMP_0_PIN) - OPTITEM(HAS_TEMP_ADC_1, TEMP_1_PIN) - OPTITEM(HAS_TEMP_ADC_2, TEMP_2_PIN) - OPTITEM(HAS_TEMP_ADC_3, TEMP_3_PIN) - OPTITEM(HAS_TEMP_ADC_4, TEMP_4_PIN) - OPTITEM(HAS_TEMP_ADC_5, TEMP_5_PIN) - OPTITEM(HAS_TEMP_ADC_6, TEMP_6_PIN) - OPTITEM(HAS_TEMP_ADC_7, TEMP_7_PIN) - OPTITEM(HAS_HEATED_BED, TEMP_BED_PIN) - OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN) - OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN) - OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN) - OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN) - OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN) - OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN) - OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN) - OPTITEM(HAS_JOY_ADC_Y, JOY_Y_PIN) - OPTITEM(HAS_JOY_ADC_Z, JOY_Z_PIN) - OPTITEM(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN) - OPTITEM(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN) -}; +// Watch out for recursion here! Our pin_t is signed, so pass through to Arduino -> analogRead(uint8_t) -enum TempPinIndex : char { - OPTITEM(HAS_TEMP_ADC_0, TEMP_0) - OPTITEM(HAS_TEMP_ADC_1, TEMP_1) - OPTITEM(HAS_TEMP_ADC_2, TEMP_2) - OPTITEM(HAS_TEMP_ADC_3, TEMP_3) - OPTITEM(HAS_TEMP_ADC_4, TEMP_4) - OPTITEM(HAS_TEMP_ADC_5, TEMP_5) - OPTITEM(HAS_TEMP_ADC_6, TEMP_6) - OPTITEM(HAS_TEMP_ADC_7, TEMP_7) - OPTITEM(HAS_HEATED_BED, TEMP_BED) - OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER) - OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE) - OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER) - OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD) - OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH) - OPTITEM(HAS_ADC_BUTTONS, ADC_KEY) - OPTITEM(HAS_JOY_ADC_X, JOY_X) - OPTITEM(HAS_JOY_ADC_Y, JOY_Y) - OPTITEM(HAS_JOY_ADC_Z, JOY_Z) - OPTITEM(POWER_MONITOR_CURRENT, POWERMON_CURRENT) - OPTITEM(POWER_MONITOR_VOLTAGE, POWERMON_VOLTS) - ADC_PIN_COUNT -}; +uint16_t analogRead(const pin_t pin) { + const bool is_analog = _GET_MODE(pin) == GPIO_INPUT_ANALOG; + return is_analog ? analogRead(uint8_t(pin)) : 0; +} -uint16_t HAL_adc_results[ADC_PIN_COUNT]; +// Wrapper to maple unprotected analogWrite +void analogWrite(const pin_t pin, int pwm_val8) { + if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8); +} + +uint16_t MarlinHAL::adc_result; // ------------------------ // Private functions // ------------------------ + static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); // only values 0..7 are used - reg_value = SCB->AIRCR; /* read old register configuration */ - reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */ + reg_value = SCB->AIRCR; // read old register configuration + reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); // clear bits to change reg_value = (reg_value | ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8)); /* Insert write key & priority group */ + (PriorityGroupTmp << 8)); // Insert write key & priority group SCB->AIRCR = reg_value; } @@ -187,6 +150,8 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { // Public functions // ------------------------ +void flashFirmware(const int16_t) { hal.reboot(); } + // // Leave PA11/PA12 intact if USBSerial is not used // @@ -206,7 +171,11 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); -void HAL_init() { +// ------------------------ +// MarlinHAL class +// ------------------------ + +void MarlinHAL::init() { NVIC_SetPriorityGrouping(0x3); #if PIN_EXISTS(LED) OUT_WRITE(LED_PIN, LOW); @@ -225,7 +194,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // If Marlin is using the SD card we need to lock it to prevent access from // a PC via USB. @@ -240,14 +209,7 @@ void HAL_idletask() { #endif } -void HAL_clear_reset_source() { } - -/** - * TODO: Check this and change or remove. - */ -uint8_t HAL_get_reset_source() { return RST_POWER_ON; } - -void _delay_ms(const int delay_ms) { delay(delay_ms); } +void MarlinHAL::reboot() { nvic_sys_reset(); } extern "C" { extern unsigned int _ebss; // end of bss section @@ -281,31 +243,76 @@ extern "C" { } */ -// ------------------------ +// // ADC -// ------------------------ +// + +enum ADCIndex : uint8_t { + OPTITEM(HAS_TEMP_ADC_0, TEMP_0) + OPTITEM(HAS_TEMP_ADC_1, TEMP_1) + OPTITEM(HAS_TEMP_ADC_2, TEMP_2) + OPTITEM(HAS_TEMP_ADC_3, TEMP_3) + OPTITEM(HAS_TEMP_ADC_4, TEMP_4) + OPTITEM(HAS_TEMP_ADC_5, TEMP_5) + OPTITEM(HAS_TEMP_ADC_6, TEMP_6) + OPTITEM(HAS_TEMP_ADC_7, TEMP_7) + OPTITEM(HAS_HEATED_BED, TEMP_BED) + OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER) + OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE) + OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER) + OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD) + OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH) + OPTITEM(HAS_ADC_BUTTONS, ADC_KEY) + OPTITEM(HAS_JOY_ADC_X, JOY_X) + OPTITEM(HAS_JOY_ADC_Y, JOY_Y) + OPTITEM(HAS_JOY_ADC_Z, JOY_Z) + OPTITEM(POWER_MONITOR_CURRENT, POWERMON_CURRENT) + OPTITEM(POWER_MONITOR_VOLTAGE, POWERMON_VOLTS) + ADC_COUNT +}; + +static uint16_t adc_results[ADC_COUNT]; + // Init the AD in continuous capture mode -void HAL_adc_init() { +void MarlinHAL::adc_init() { + static const uint8_t adc_pins[] = { + OPTITEM(HAS_TEMP_ADC_0, TEMP_0_PIN) + OPTITEM(HAS_TEMP_ADC_1, TEMP_1_PIN) + OPTITEM(HAS_TEMP_ADC_2, TEMP_2_PIN) + OPTITEM(HAS_TEMP_ADC_3, TEMP_3_PIN) + OPTITEM(HAS_TEMP_ADC_4, TEMP_4_PIN) + OPTITEM(HAS_TEMP_ADC_5, TEMP_5_PIN) + OPTITEM(HAS_TEMP_ADC_6, TEMP_6_PIN) + OPTITEM(HAS_TEMP_ADC_7, TEMP_7_PIN) + OPTITEM(HAS_HEATED_BED, TEMP_BED_PIN) + OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN) + OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN) + OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN) + OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN) + OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN) + OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN) + OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN) + OPTITEM(HAS_JOY_ADC_Y, JOY_Y_PIN) + OPTITEM(HAS_JOY_ADC_Z, JOY_Z_PIN) + OPTITEM(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN) + OPTITEM(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN) + }; + static STM32ADC adc(ADC1); // configure the ADC adc.calibrate(); - #if F_CPU > 72000000 - adc.setSampleRate(ADC_SMPR_71_5); // 71.5 ADC cycles - #else - adc.setSampleRate(ADC_SMPR_41_5); // 41.5 ADC cycles - #endif - adc.setPins((uint8_t *)adc_pins, ADC_PIN_COUNT); - adc.setDMA(HAL_adc_results, (uint16_t)ADC_PIN_COUNT, (uint32_t)(DMA_MINC_MODE | DMA_CIRC_MODE), nullptr); + adc.setSampleRate((F_CPU > 72000000) ? ADC_SMPR_71_5 : ADC_SMPR_41_5); // 71.5 or 41.5 ADC cycles + adc.setPins((uint8_t *)adc_pins, ADC_COUNT); + adc.setDMA(adc_results, uint16_t(ADC_COUNT), uint32_t(DMA_MINC_MODE | DMA_CIRC_MODE), nullptr); adc.setScanMode(); adc.setContinuous(); adc.startConversion(); } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +void MarlinHAL::adc_start(const pin_t pin) { #define __TCASE(N,I) case N: pin_index = I; break; #define _TCASE(C,N,I) TERN_(C, __TCASE(N, I)) - //TEMP_PINS pin_index; - TempPinIndex pin_index; - switch (adc_pin) { + ADCIndex pin_index; + switch (pin) { default: return; _TCASE(HAS_TEMP_ADC_0, TEMP_0_PIN, TEMP_0) _TCASE(HAS_TEMP_ADC_1, TEMP_1_PIN, TEMP_1) @@ -328,23 +335,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { _TCASE(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN, POWERMON_CURRENT) _TCASE(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN, POWERMON_VOLTS) } - HAL_adc_result = HAL_adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits + adc_result = adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits } -uint16_t HAL_adc_get_result() { return HAL_adc_result; } - -uint16_t analogRead(pin_t pin) { - const bool is_analog = _GET_MODE(pin) == GPIO_INPUT_ANALOG; - return is_analog ? analogRead(uint8_t(pin)) : 0; -} - -// Wrapper to maple unprotected analogWrite -void analogWrite(pin_t pin, int pwm_val8) { - if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8); -} - -void HAL_reboot() { nvic_sys_reset(); } - -void flashFirmware(const int16_t) { HAL_reboot(); } - #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index a766babe15..8fbb43c602 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -66,6 +66,10 @@ #endif #endif +// ------------------------ +// Serial ports +// ------------------------ + #ifdef SERIAL_USB typedef ForwardSerial1Class< USBSerial > DefaultSerial1; extern DefaultSerial1 MSerial0; @@ -141,11 +145,6 @@ #endif #endif -// Set interrupt grouping for this MCU -void HAL_init(); -#define HAL_IDLETASK 1 -void HAL_idletask(); - /** * TODO: review this to return 1 for pins that are not analog input */ @@ -158,15 +157,7 @@ void HAL_idletask(); #define NO_COMPILE_TIME_PWM #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); (void)__iCliRetVal() -#define CRITICAL_SECTION_END() if (!primask) (void)__iSeiRetVal() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() ((void)__iSeiRetVal()) -#define DISABLE_ISRS() ((void)__iCliRetVal()) - -// On AVR this is in math.h? -#define square(x) ((x)*(x)) - +// Reset Reason #define RST_POWER_ON 1 #define RST_EXTERNAL 2 #define RST_BROWN_OUT 4 @@ -182,60 +173,17 @@ void HAL_idletask(); typedef int8_t pin_t; // ------------------------ -// Public Variables +// Interrupts // ------------------------ -// Result of last ADC conversion -extern uint16_t HAL_adc_result; - -// ------------------------ -// Public functions -// ------------------------ - -// Disable interrupts +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); (void)__iCliRetVal() +#define CRITICAL_SECTION_END() if (!primask) (void)__iSeiRetVal() #define cli() noInterrupts() - -// Enable interrupts #define sei() interrupts() -// Memory related -#define __bss_end __bss_end__ - -// Clear reset reason -void HAL_clear_reset_source(); - -// Reset reason -uint8_t HAL_get_reset_source(); - -void HAL_reboot(); - -void _delay_ms(const int delay); - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" - -/* -extern "C" { - int freeMemory(); -} -*/ - -extern "C" char* _sbrk(int incr); - -static inline int freeMemory() { - volatile char top; - return &top - _sbrk(0); -} - -#pragma GCC diagnostic pop - -// +// ------------------------ // ADC -// - -#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT_ANALOG); - -void HAL_adc_init(); +// ------------------------ #ifdef ADC_RESOLUTION #define HAL_ADC_RESOLUTION ADC_RESOLUTION @@ -244,43 +192,115 @@ void HAL_adc_init(); #endif #define HAL_ADC_VREF 3.3 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); - -uint16_t analogRead(pin_t pin); // need HAL_ANALOG_SELECT() first -void analogWrite(pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!? +uint16_t analogRead(const pin_t pin); // need hal.adc_enable() first +void analogWrite(const pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!? +// +// Pin Mapping for M42, M43, M226 +// #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY) +#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY) #define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE) #define PLATFORM_M997_SUPPORT void flashFirmware(const int16_t); +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment #ifndef PWM_FREQUENCY #define PWM_FREQUENCY 1000 // Default PWM Frequency #endif -#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Timer PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +// ------------------------ +// Class Utilities +// ------------------------ -/** - * set_pwm_duty - * Set the PWM duty cycle of the provided pin to the provided value - * Optionally allows inverting the duty cycle [default = false] - * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] - * The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired. - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); +// Memory related +#define __bss_end __bss_end__ + +void _delay_ms(const int ms); + +extern "C" char* _sbrk(int incr); + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +static inline int freeMemory() { + volatile char top; + return &top - _sbrk(0); +} + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return !__get_primask(); } + static void isr_on() { ((void)__iSeiRetVal()); } + static void isr_off() { ((void)__iCliRetVal()); } + + static void delay_ms(const int ms) { delay(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static uint8_t get_reset_source() { return RST_POWER_ON; } + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) { pinMode(pin, INPUT_ANALOG); } + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally change the maximum size of the provided value to enable finer PWM duty control [default = 255] + * The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false); + + /** + * Set the frequency of the timer for the given pin. + * All Timer PWM pins run at the same frequency. + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); + +}; diff --git a/Marlin/src/HAL/STM32F1/SPI.cpp b/Marlin/src/HAL/STM32F1/SPI.cpp index 8bfa3d236a..1ce2c7d3fd 100644 --- a/Marlin/src/HAL/STM32F1/SPI.cpp +++ b/Marlin/src/HAL/STM32F1/SPI.cpp @@ -91,6 +91,14 @@ static const spi_pins board_spi_pins[] __FLASH__ = { static void *_spi3_this; #endif +/** + * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. + */ +static inline void waitSpiTxEnd(spi_dev *spi_d) { + while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1 + while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0 +} + /** * Constructor */ diff --git a/Marlin/src/HAL/STM32F1/SPI.h b/Marlin/src/HAL/STM32F1/SPI.h index 92f4226301..13f4d5ed6c 100644 --- a/Marlin/src/HAL/STM32F1/SPI.h +++ b/Marlin/src/HAL/STM32F1/SPI.h @@ -414,12 +414,4 @@ private: */ }; -/** - * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. - */ -static void waitSpiTxEnd(spi_dev *spi_d) { - while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1 - while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0 -} - extern SPIClass SPI; diff --git a/Marlin/src/HAL/STM32F1/Servo.h b/Marlin/src/HAL/STM32F1/Servo.h index b6143de81d..745a1c93f0 100644 --- a/Marlin/src/HAL/STM32F1/Servo.h +++ b/Marlin/src/HAL/STM32F1/Servo.h @@ -35,7 +35,8 @@ #define SERVO_DEFAULT_MIN_ANGLE 0 #define SERVO_DEFAULT_MAX_ANGLE 180 -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; class libServo { public: diff --git a/Marlin/src/HAL/STM32F1/fast_pwm.cpp b/Marlin/src/HAL/STM32F1/fast_pwm.cpp index 13411d9af0..297804a3ac 100644 --- a/Marlin/src/HAL/STM32F1/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32F1/fast_pwm.cpp @@ -21,11 +21,9 @@ */ #ifdef __STM32F1__ -#include "../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfig.h" #include -#include "HAL.h" -#include "timers.h" #define NR_TIMERS TERN(STM32_XL_DENSITY, 14, 8) // Maple timers, 14 for STM32_XL_DENSITY (F/G chips), 8 for HIGH density (C D E) @@ -38,7 +36,7 @@ inline uint8_t timer_and_index_for_pin(const pin_t pin, timer_dev **timer_ptr) { return 0; } -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { const uint16_t duty = invert ? v_size - v : v; if (PWM_PIN(pin)) { timer_dev *timer; UNUSED(timer); @@ -54,7 +52,7 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255 } } -void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer timer_dev *timer; UNUSED(timer); diff --git a/Marlin/src/HAL/STM32F1/timers.h b/Marlin/src/HAL/STM32F1/timers.h index f9ab6d13d3..0cd807fc84 100644 --- a/Marlin/src/HAL/STM32F1/timers.h +++ b/Marlin/src/HAL/STM32F1/timers.h @@ -188,7 +188,7 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { } } -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP // No command is available in framework to turn off ARPE bit, which is turned on by default in libmaple. // Needed here to reset ARPE=0 for stepper timer diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index f08cf799e9..b923ab77b1 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -31,6 +31,10 @@ #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -40,45 +44,9 @@ #endif USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result; - -static const uint8_t pin2sc1a[] = { - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13 - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9) - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33 - 0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13) - 26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0. -}; - -/* - // disable interrupts - void cli() { noInterrupts(); } - - // enable interrupts - void sei() { interrupts(); } -*/ - -void HAL_adc_init() { - analog_init(); - while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - NVIC_ENABLE_IRQ(IRQ_FTM1); -} - -void HAL_clear_reset_source() { } - -uint8_t HAL_get_reset_source() { - switch (RCM_SRS0) { - case 128: return RST_POWER_ON; break; - case 64: return RST_EXTERNAL; break; - case 32: return RST_WATCHDOG; break; - // case 8: return RST_LOSS_OF_LOCK; break; - // case 4: return RST_LOSS_OF_CLOCK; break; - // case 2: return RST_LOW_VOLTAGE; break; - } - return 0; -} - -void HAL_reboot() { _reboot_Teensyduino_(); } +// ------------------------ +// Class Utilities +// ------------------------ extern "C" { extern char __bss_end; @@ -95,8 +63,43 @@ extern "C" { } } -void HAL_adc_start_conversion(const uint8_t adc_pin) { ADC0_SC1A = pin2sc1a[adc_pin]; } +// ------------------------ +// MarlinHAL Class +// ------------------------ -uint16_t HAL_adc_get_result() { return ADC0_RA; } +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } + +uint8_t MarlinHAL::get_reset_source() { + switch (RCM_SRS0) { + case 128: return RST_POWER_ON; break; + case 64: return RST_EXTERNAL; break; + case 32: return RST_WATCHDOG; break; + // case 8: return RST_LOSS_OF_LOCK; break; + // case 4: return RST_LOSS_OF_CLOCK; break; + // case 2: return RST_LOW_VOLTAGE; break; + } + return 0; +} + +// ADC + +void MarlinHAL::adc_init() { + analog_init(); + while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish + NVIC_ENABLE_IRQ(IRQ_FTM1); +} + +void MarlinHAL::adc_start(const pin_t pin) { + static const uint8_t pin2sc1a[] = { + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13 + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9) + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33 + 0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13) + 26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0. + }; + ADC0_SC1A = pin2sc1a[pin]; +} + +uint16_t MarlinHAL::adc_value() { return ADC0_RA; } #endif // __MK20DX256__ diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 61d8b34604..50c0f411cf 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -36,12 +36,9 @@ #include -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - -//#undef MOTHERBOARD -//#define MOTHERBOARD BOARD_TEENSY31_32 +// ------------------------ +// Defines +// ------------------------ #define IS_32BIT_TEENSY 1 #define IS_TEENSY_31_32 1 @@ -49,6 +46,14 @@ #define IS_TEENSY32 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" #define Serial0 Serial @@ -72,31 +77,44 @@ extern USBSerialType USBSerial; #error "The required SERIAL_PORT must be from 0 to 3, or -1 for Native USB." #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ + +class libServo; +typedef libServo hal_servo_t; typedef int8_t pin_t; +// ------------------------ +// Interrupts +// ------------------------ + +uint32_t __get_PRIMASK(void); // CMSIS +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() + +// ------------------------ +// ADC +// ------------------------ + #ifndef analogInputToDigitalPin #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 -inline void HAL_init() {} +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -// Clear the reset reason -void HAL_clear_reset_source(); - -// Get the reason for the reset -uint8_t HAL_get_reset_source(); - -void HAL_reboot(); - -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -107,27 +125,63 @@ extern "C" int freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -// PWM + static void delay_ms(const int ms) { delay(ms); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Tasks, called from idle() + static void idletask() {} -// Pin Map + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t ch) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t ch); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/TEENSY31_32/timers.h b/Marlin/src/HAL/TEENSY31_32/timers.h index 3b073d63ab..9fcbb6f232 100644 --- a/Marlin/src/HAL/TEENSY31_32/timers.h +++ b/Marlin/src/HAL/TEENSY31_32/timers.h @@ -110,4 +110,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index 046c00b56e..54a5ad3855 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,6 +31,10 @@ #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -39,54 +43,9 @@ USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result, HAL_adc_select; - -static const uint8_t pin2sc1a[] = { - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13 - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9 - 255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only - 14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20 - 255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only - 10+128, 11+128, // 49-50 are A23-A24 - 255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only - 255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only - 3, 19+128, // 64-65 are A10-A11 - 23, 23+128,// 66-67 are A21-A22 (DAC pins) - 1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5) - 26, // 70 is Temperature Sensor - 18+128 // 71 is Vref -}; - -/* - // disable interrupts - void cli() { noInterrupts(); } - - // enable interrupts - void sei() { interrupts(); } -*/ - -void HAL_adc_init() { - analog_init(); - while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - while (ADC1_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - NVIC_ENABLE_IRQ(IRQ_FTM1); -} - -void HAL_clear_reset_source() { } - -uint8_t HAL_get_reset_source() { - switch (RCM_SRS0) { - case 128: return RST_POWER_ON; break; - case 64: return RST_EXTERNAL; break; - case 32: return RST_WATCHDOG; break; - // case 8: return RST_LOSS_OF_LOCK; break; - // case 4: return RST_LOSS_OF_CLOCK; break; - // case 2: return RST_LOW_VOLTAGE; break; - } - return 0; -} - -void HAL_reboot() { _reboot_Teensyduino_(); } +// ------------------------ +// Class Utilities +// ------------------------ extern "C" { extern char __bss_end; @@ -103,24 +62,69 @@ extern "C" { } } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +// ------------------------ +// MarlinHAL Class +// ------------------------ + +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } + +// Reset + +uint8_t MarlinHAL::get_reset_source() { + switch (RCM_SRS0) { + case 128: return RST_POWER_ON; break; + case 64: return RST_EXTERNAL; break; + case 32: return RST_WATCHDOG; break; + // case 8: return RST_LOSS_OF_LOCK; break; + // case 4: return RST_LOSS_OF_CLOCK; break; + // case 2: return RST_LOW_VOLTAGE; break; + } + return 0; +} + +// ADC + +int8_t MarlinHAL::adc_select; + +void MarlinHAL::adc_init() { + analog_init(); + while (ADC0_SC3 & ADC_SC3_CAL) { /* Wait for calibration to finish */ } + while (ADC1_SC3 & ADC_SC3_CAL) { /* Wait for calibration to finish */ } + NVIC_ENABLE_IRQ(IRQ_FTM1); +} + +void MarlinHAL::adc_start(const pin_t adc_pin) { + static const uint8_t pin2sc1a[] = { + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13 + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9 + 255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only + 14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20 + 255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only + 10+128, 11+128, // 49-50 are A23-A24 + 255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only + 255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only + 3, 19+128, // 64-65 are A10-A11 + 23, 23+128,// 66-67 are A21-A22 (DAC pins) + 1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5) + 26, // 70 is Temperature Sensor + 18+128 // 71 is Vref + }; const uint16_t pin = pin2sc1a[adc_pin]; if (pin == 0xFF) { - // Digital only - HAL_adc_select = -1; + adc_select = -1; // Digital only } else if (pin & 0x80) { - HAL_adc_select = 1; + adc_select = 1; ADC1_SC1A = pin & 0x7F; } else { - HAL_adc_select = 0; + adc_select = 0; ADC0_SC1A = pin; } } -uint16_t HAL_adc_get_result() { - switch (HAL_adc_select) { +uint16_t MarlinHAL::adc_value() { + switch (adc_select) { case 0: return ADC0_RA; case 1: return ADC1_RA; } diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 892eb2d3c5..e4c57f8d1e 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -37,10 +37,6 @@ #include #include -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - // ------------------------ // Defines // ------------------------ @@ -53,6 +49,17 @@ #define IS_TEENSY35 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +#undef sq +#define sq(x) ((x)*(x)) + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" #define Serial0 Serial @@ -76,34 +83,43 @@ extern USBSerialType USBSerial; #error "SERIAL_PORT must be from 0 to 3, or -1 for Native USB." #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ + +class libServo; +typedef libServo hal_servo_t; typedef int8_t pin_t; +// ------------------------ +// Interrupts +// ------------------------ + +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() + +// ------------------------ +// ADC +// ------------------------ + #ifndef analogInputToDigitalPin #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 -#undef sq -#define sq(x) ((x)*(x)) +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -inline void HAL_init() {} - -// Clear reset reason -void HAL_clear_reset_source(); - -// Reset reason -uint8_t HAL_get_reset_source(); - -void HAL_reboot(); - -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -114,27 +130,65 @@ extern "C" int freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + // Interrupts + static bool isr_state() { return true; } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -// PWM + static void delay_ms(const int ms) { delay(ms); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Tasks, called from idle() + static void idletask() {} -// Pin Map + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static int8_t adc_select; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/TEENSY35_36/timers.h b/Marlin/src/HAL/TEENSY35_36/timers.h index 6c342bbe0d..8af79d7392 100644 --- a/Marlin/src/HAL/TEENSY35_36/timers.h +++ b/Marlin/src/HAL/TEENSY35_36/timers.h @@ -109,4 +109,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index 270bee0dc9..68bd38f72f 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -33,6 +33,10 @@ #include "timers.h" #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -40,75 +44,42 @@ #endif USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result, HAL_adc_select; +// ------------------------ +// Class Utilities +// ------------------------ -static const uint8_t pin2sc1a[] = { - 0x07, // 0/A0 AD_B1_02 - 0x08, // 1/A1 AD_B1_03 - 0x0C, // 2/A2 AD_B1_07 - 0x0B, // 3/A3 AD_B1_06 - 0x06, // 4/A4 AD_B1_01 - 0x05, // 5/A5 AD_B1_00 - 0x0F, // 6/A6 AD_B1_10 - 0x00, // 7/A7 AD_B1_11 - 0x0D, // 8/A8 AD_B1_08 - 0x0E, // 9/A9 AD_B1_09 - 0x01, // 24/A10 AD_B0_12 - 0x02, // 25/A11 AD_B0_13 - 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 - 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 - 0x07, // 14/A0 AD_B1_02 - 0x08, // 15/A1 AD_B1_03 - 0x0C, // 16/A2 AD_B1_07 - 0x0B, // 17/A3 AD_B1_06 - 0x06, // 18/A4 AD_B1_01 - 0x05, // 19/A5 AD_B1_00 - 0x0F, // 20/A6 AD_B1_10 - 0x00, // 21/A7 AD_B1_11 - 0x0D, // 22/A8 AD_B1_08 - 0x0E, // 23/A9 AD_B1_09 - 0x01, // 24/A10 AD_B0_12 - 0x02, // 25/A11 AD_B0_13 - 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 - 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 - #ifdef ARDUINO_TEENSY41 - 0xFF, // 28 - 0xFF, // 29 - 0xFF, // 30 - 0xFF, // 31 - 0xFF, // 32 - 0xFF, // 33 - 0xFF, // 34 - 0xFF, // 35 - 0xFF, // 36 - 0xFF, // 37 - 0x81, // 38/A14 AD_B1_12 - only on ADC2, 1 - 0x82, // 39/A15 AD_B1_13 - only on ADC2, 2 - 0x09, // 40/A16 AD_B1_04 - 0x0A, // 41/A17 AD_B1_05 - #endif -}; +#define __bss_end _ebss -/* -// disable interrupts -void cli() { noInterrupts(); } +extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; -// enable interrupts -void sei() { interrupts(); } -*/ - -void HAL_adc_init() { - analog_init(); - while (ADC1_GC & ADC_GC_CAL) ; - while (ADC2_GC & ADC_GC_CAL) ; + // Doesn't work on Teensy 4.x + uint32_t freeMemory() { + uint32_t free_memory; + free_memory = ((uint32_t)&free_memory) - (((uint32_t)__brkval) ?: ((uint32_t)&__bss_end)); + return free_memory; + } } -void HAL_clear_reset_source() { - uint32_t reset_source = SRC_SRSR; - SRC_SRSR = reset_source; +// ------------------------ +// FastIO +// ------------------------ + +bool is_output(pin_t pin) { + const struct digital_pin_bitband_and_config_table_struct *p; + p = digital_pin_to_info_PGM + pin; + return (*(p->reg + 1) & p->mask); } -uint8_t HAL_get_reset_source() { +// ------------------------ +// MarlinHAL Class +// ------------------------ + +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } + +uint8_t MarlinHAL::get_reset_source() { switch (SRC_SRSR & 0xFF) { case 1: return RST_POWER_ON; break; case 2: return RST_SOFTWARE; break; @@ -121,57 +92,92 @@ uint8_t HAL_get_reset_source() { return 0; } -void HAL_reboot() { _reboot_Teensyduino_(); } - -#define __bss_end _ebss - -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; - - // Doesn't work on Teensy 4.x - uint32_t freeMemory() { - uint32_t free_memory; - if ((uint32_t)__brkval == 0) - free_memory = ((uint32_t)&free_memory) - ((uint32_t)&__bss_end); - else - free_memory = ((uint32_t)&free_memory) - ((uint32_t)__brkval); - return free_memory; - } +void MarlinHAL::clear_reset_source() { + uint32_t reset_source = SRC_SRSR; + SRC_SRSR = reset_source; } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +// ADC + +int8_t MarlinHAL::adc_select; + +void MarlinHAL::adc_init() { + analog_init(); + while (ADC1_GC & ADC_GC_CAL) { /* wait */ } + while (ADC2_GC & ADC_GC_CAL) { /* wait */ } +} + +void MarlinHAL::adc_start(const pin_t adc_pin) { + static const uint8_t pin2sc1a[] = { + 0x07, // 0/A0 AD_B1_02 + 0x08, // 1/A1 AD_B1_03 + 0x0C, // 2/A2 AD_B1_07 + 0x0B, // 3/A3 AD_B1_06 + 0x06, // 4/A4 AD_B1_01 + 0x05, // 5/A5 AD_B1_00 + 0x0F, // 6/A6 AD_B1_10 + 0x00, // 7/A7 AD_B1_11 + 0x0D, // 8/A8 AD_B1_08 + 0x0E, // 9/A9 AD_B1_09 + 0x01, // 24/A10 AD_B0_12 + 0x02, // 25/A11 AD_B0_13 + 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 + 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 + 0x07, // 14/A0 AD_B1_02 + 0x08, // 15/A1 AD_B1_03 + 0x0C, // 16/A2 AD_B1_07 + 0x0B, // 17/A3 AD_B1_06 + 0x06, // 18/A4 AD_B1_01 + 0x05, // 19/A5 AD_B1_00 + 0x0F, // 20/A6 AD_B1_10 + 0x00, // 21/A7 AD_B1_11 + 0x0D, // 22/A8 AD_B1_08 + 0x0E, // 23/A9 AD_B1_09 + 0x01, // 24/A10 AD_B0_12 + 0x02, // 25/A11 AD_B0_13 + 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 + 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 + #ifdef ARDUINO_TEENSY41 + 0xFF, // 28 + 0xFF, // 29 + 0xFF, // 30 + 0xFF, // 31 + 0xFF, // 32 + 0xFF, // 33 + 0xFF, // 34 + 0xFF, // 35 + 0xFF, // 36 + 0xFF, // 37 + 0x81, // 38/A14 AD_B1_12 - only on ADC2, 1 + 0x82, // 39/A15 AD_B1_13 - only on ADC2, 2 + 0x09, // 40/A16 AD_B1_04 + 0x0A, // 41/A17 AD_B1_05 + #endif + }; const uint16_t pin = pin2sc1a[adc_pin]; if (pin == 0xFF) { - HAL_adc_select = -1; // Digital only + adc_select = -1; // Digital only } else if (pin & 0x80) { - HAL_adc_select = 1; + adc_select = 1; ADC2_HC0 = pin & 0x7F; } else { - HAL_adc_select = 0; + adc_select = 0; ADC1_HC0 = pin; } } -uint16_t HAL_adc_get_result() { - switch (HAL_adc_select) { +uint16_t MarlinHAL::adc_value() { + switch (adc_select) { case 0: - while (!(ADC1_HS & ADC_HS_COCO0)) ; // wait + while (!(ADC1_HS & ADC_HS_COCO0)) { /* wait */ } return ADC1_R0; case 1: - while (!(ADC2_HS & ADC_HS_COCO0)) ; // wait + while (!(ADC2_HS & ADC_HS_COCO0)) { /* wait */ } return ADC2_R0; } return 0; } -bool is_output(pin_t pin) { - const struct digital_pin_bitband_and_config_table_struct *p; - p = digital_pin_to_info_PGM + pin; - return (*(p->reg + 1) & p->mask); -} - #endif // __IMXRT1062__ diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 2b730768a8..a21e652854 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -41,10 +41,6 @@ #include "../../feature/ethernet.h" #endif -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - // ------------------------ // Defines // ------------------------ @@ -55,7 +51,23 @@ #define IS_TEENSY41 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +#undef sq +#define sq(x) ((x)*(x)) + +// Don't place string constants in PROGMEM +#undef PSTR +#define PSTR(str) ({static const char *data = (str); &data[0];}) + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" + #define Serial0 Serial #define _DECLARE_SERIAL(X) \ typedef ForwardSerial1Class DefaultSerial##X; \ @@ -89,41 +101,47 @@ extern USBSerialType USBSerial; #endif #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ + +class libServo; +typedef libServo hal_servo_t; typedef int8_t pin_t; +// ------------------------ +// Interrupts +// ------------------------ + +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() + +// ------------------------ +// ADC +// ------------------------ + #ifndef analogInputToDigitalPin #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 +#define HAL_ADC_FILTERED // turn off ADC oversampling -#undef sq -#define sq(x) ((x)*(x)) +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) -// Don't place string constants in PROGMEM -#undef PSTR -#define PSTR(str) ({static const char *data = (str); &data[0];}) +// FastIO +bool is_output(pin_t pin); -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -FORCE_INLINE void HAL_idletask() {} -FORCE_INLINE void HAL_init() {} - -// Clear reset reason -void HAL_clear_reset_source(); - -// Reset reason -uint8_t HAL_get_reset_source(); - -void HAL_reboot(); - -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -134,30 +152,65 @@ extern "C" uint32_t freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_ADC_FILTERED // turn off ADC oversampling -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + // Interrupts + static bool isr_state() { return !__get_primask(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -// PWM + static void delay_ms(const int ms) { delay(ms); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Tasks, called from idle() + static void idletask() {} -// Pin Map + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source(); -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Free SRAM + static int freeMemory() { return ::freeMemory(); } -bool is_output(pin_t pin); + // + // ADC Methods + // + + static int8_t adc_select; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) {} + + // Begin ADC sampling on the given channel + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/TEENSY40_41/timers.h b/Marlin/src/HAL/TEENSY40_41/timers.h index 81cf67f7bc..77fe0953d3 100644 --- a/Marlin/src/HAL/TEENSY40_41/timers.h +++ b/Marlin/src/HAL/TEENSY40_41/timers.h @@ -114,4 +114,4 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); //void HAL_timer_isr_epilogue(const uint8_t timer_num) {} -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/shared/HAL.cpp b/Marlin/src/HAL/shared/HAL.cpp new file mode 100644 index 0000000000..4d92aedd9a --- /dev/null +++ b/Marlin/src/HAL/shared/HAL.cpp @@ -0,0 +1,36 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * HAL/shared/HAL.cpp + */ + +#include "../../inc/MarlinConfig.h" + +MarlinHAL hal; + +#if ENABLED(SOFT_RESET_VIA_SERIAL) + + // Global for use by e_parser.h + void HAL_reboot() { hal.reboot(); } + +#endif diff --git a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp index bd85dbe7bd..5d4ce89b27 100644 --- a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp +++ b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp @@ -92,9 +92,9 @@ uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) { // First device in chain has data sent last extDigitalWrite(ss_pin, LOW); - DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips) + hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) const uint8_t data_out = L6470_SpiTransfer_Mode_3(data); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts extDigitalWrite(ss_pin, HIGH); return data_out; @@ -107,9 +107,9 @@ uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain extDigitalWrite(ss_pin, LOW); for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted - DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips) + hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP)); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts if (i == chain_position) data_out = temp; } diff --git a/Marlin/src/HAL/shared/math_32bit.h b/Marlin/src/HAL/shared/math_32bit.h index 87e9e6406e..1fb233e3e8 100644 --- a/Marlin/src/HAL/shared/math_32bit.h +++ b/Marlin/src/HAL/shared/math_32bit.h @@ -26,6 +26,6 @@ /** * Math helper functions for 32 bit CPUs */ -static FORCE_INLINE uint32_t MultiU32X24toH32(uint32_t longIn1, uint32_t longIn2) { +FORCE_INLINE static uint32_t MultiU32X24toH32(uint32_t longIn1, uint32_t longIn2) { return ((uint64_t)longIn1 * longIn2 + 0x00800000) >> 24; } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 02cf6d28d3..482ad95cac 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -790,7 +790,7 @@ void idle(bool no_stepper_sleep/*=false*/) { #endif // Run HAL idle tasks - TERN_(HAL_IDLETASK, HAL_idletask()); + hal.idletask(); // Check network connection TERN_(HAS_ETHERNET, ethernet.check()); @@ -929,7 +929,7 @@ void minkill(const bool steppers_off/*=false*/) { watchdog_refresh(); // Reboot the board - HAL_reboot(); + hal.reboot(); #else @@ -1041,7 +1041,7 @@ inline void tmc_standby_setup() { * • L64XX Stepper Drivers (SPI) * • Stepper Driver Reset: DISABLE * • TMC Stepper Drivers (SPI) - * • Run BOARD_INIT if defined + * • Run hal.init_board() for additional pins setup * • ESP WiFi * - Get the Reset Reason and report it * - Print startup messages and diagnostics @@ -1119,8 +1119,8 @@ void setup() { tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable // Check startup - does nothing if bootloader sets MCUSR to 0 - const byte mcu = HAL_get_reset_source(); - HAL_clear_reset_source(); + const byte mcu = hal.get_reset_source(); + hal.clear_reset_source(); #if ENABLED(MARLIN_DEV_MODE) auto log_current_ms = [&](PGM_P const msg) { @@ -1181,23 +1181,20 @@ void setup() { JTAGSWD_RESET(); #endif - #if EITHER(DISABLE_DEBUG, DISABLE_JTAG) + // Disable any hardware debug to free up pins for IO + #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE) delay(10); - // Disable any hardware debug to free up pins for IO - #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE) - SETUP_LOG("JTAGSWD_DISABLE"); - JTAGSWD_DISABLE(); - #elif defined(JTAG_DISABLE) - SETUP_LOG("JTAG_DISABLE"); - JTAG_DISABLE(); - #else - #error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board." - #endif + SETUP_LOG("JTAGSWD_DISABLE"); + JTAGSWD_DISABLE(); + #elif ENABLED(DISABLE_JTAG) && defined(JTAG_DISABLE) + delay(10); + SETUP_LOG("JTAG_DISABLE"); + JTAG_DISABLE(); #endif TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime - SETUP_RUN(HAL_init()); + SETUP_RUN(hal.init()); // Init and disable SPI thermocouples; this is still needed #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0)) @@ -1243,19 +1240,16 @@ void setup() { SETUP_RUN(tmc_init_cs_pins()); #endif - #ifdef BOARD_INIT - SETUP_LOG("BOARD_INIT"); - BOARD_INIT(); - #endif + SETUP_RUN(hal.init_board()); SETUP_RUN(esp_wifi_init()); // Report Reset Reason - if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); - if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); + if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); + if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET); - if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); - if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); + if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); + if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); // Identify myself as Marlin x.x.x SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION); @@ -1266,7 +1260,7 @@ void setup() { ); #endif SERIAL_ECHO_MSG(" Compiled: " __DATE__); - SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE)); + SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE)); // Some HAL need precise delay adjustment calibrate_delay_loop(); @@ -1542,7 +1536,7 @@ void setup() { #endif #if ENABLED(USE_WATCHDOG) - SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call + SETUP_RUN(watchdog_init()); // Reinit watchdog after hal.get_reset_source call #endif #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index 57b2d0f83c..eb580a6d62 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -79,7 +79,7 @@ void CaseLight::update(const bool sflag) { #if CASELIGHT_USES_BRIGHTNESS if (pin_is_pwm()) - set_pwm_duty(pin_t(CASE_LIGHT_PIN), ( + hal.set_pwm_duty(pin_t(CASE_LIGHT_PIN), ( #if CASE_LIGHT_MAX_PWM == 255 n10ct #else diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 59ba665e11..f42bf52ae4 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -76,7 +76,7 @@ void ControllerFan::update() { thermalManager.soft_pwm_controller_speed = speed; #else if (PWM_PIN(CONTROLLER_FAN_PIN)) - set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); + hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); else WRITE(CONTROLLER_FAN_PIN, speed > 0); #endif diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index 1dee0cf755..fda1ba144b 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -41,7 +41,9 @@ extern bool wait_for_user, wait_for_heatup; void quickresume_stepper(); #endif -void HAL_reboot(); +#if ENABLED(SOFT_RESET_VIA_SERIAL) + void HAL_reboot(); +#endif class EmergencyParser { diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 715f51f442..2a53a7c884 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -129,11 +129,11 @@ void LEDLights::set_color(const LEDColor &incol // This variant uses 3-4 separate pins for the RGB(W) components. // If the pins can do PWM then their intensity will be set. - #define _UPDATE_RGBW(C,c) do { \ - if (PWM_PIN(RGB_LED_##C##_PIN)) \ - set_pwm_duty(pin_t(RGB_LED_##C##_PIN), c); \ - else \ - WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \ + #define _UPDATE_RGBW(C,c) do { \ + if (PWM_PIN(RGB_LED_##C##_PIN)) \ + hal.set_pwm_duty(pin_t(RGB_LED_##C##_PIN), c); \ + else \ + WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \ }while(0) #define UPDATE_RGBW(C,c) _UPDATE_RGBW(C, TERN1(CASE_LIGHT_USE_RGB_LED, caselight.on) ? incol.c : 0) UPDATE_RGBW(R,r); UPDATE_RGBW(G,g); UPDATE_RGBW(B,b); diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 9ca7cb948e..52bb471b0f 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -66,10 +66,10 @@ void SpindleLaser::init() { #endif #if ENABLED(SPINDLE_LASER_USE_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); - set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed + hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed #endif #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY); #endif #if ENABLED(AIR_EVACUATION) @@ -89,9 +89,9 @@ void SpindleLaser::init() { */ void SpindleLaser::_set_ocr(const uint8_t ocr) { #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY)); + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY)); #endif - set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); + hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); } void SpindleLaser::set_ocr(const uint8_t ocr) { diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 89e11fca08..e948d2d37b 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -103,7 +103,7 @@ public: static void init(); #if ENABLED(MARLIN_DEV_MODE) - static void refresh_frequency() { set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } + static void refresh_frequency() { hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } #endif // Modifying this function should update everywhere diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index 8de3226924..1b3a29d100 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -126,10 +126,10 @@ void GcodeSuite::M42() { extDigitalWrite(pin, pin_status); #ifdef ARDUINO_ARCH_STM32 - // A simple I/O will be set to 0 by set_pwm_duty() + // A simple I/O will be set to 0 by hal.set_pwm_duty() if (pin_status <= 1 && !PWM_PIN(pin)) return; #endif - set_pwm_duty(pin, pin_status); + hal.set_pwm_duty(pin, pin_status); } #endif // DIRECT_PIN_CONTROL diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 204455e65e..2dd1de0001 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -38,7 +38,7 @@ #include "../sd/cardreader.h" #include "../MarlinCore.h" // for kill -extern void dump_delay_accuracy_check(); +void dump_delay_accuracy_check(); /** * Dn: G-code for development and testing @@ -54,7 +54,7 @@ void GcodeSuite::D(const int16_t dcode) { for (;;) { /* loop forever (watchdog reset) */ } case 0: - HAL_reboot(); + hal.reboot(); break; case 10: @@ -74,7 +74,7 @@ void GcodeSuite::D(const int16_t dcode) { settings.reset(); settings.save(); #endif - HAL_reboot(); + hal.reboot(); } break; case 2: { // D2 Read / Write SRAM @@ -189,12 +189,12 @@ void GcodeSuite::D(const int16_t dcode) { SERIAL_ECHOLNPGM("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")"); thermalManager.disable_all_heaters(); delay(1000); // Allow time to print - DISABLE_ISRS(); + hal.isr_off(); // Use a low-level delay that does not rely on interrupts to function // Do not spin forever, to avoid thermal risks if heaters are enabled and // watchdog does not work. for (int i = 10000; i--;) DELAY_US(1000UL); - ENABLE_ISRS(); + hal.isr_on(); SERIAL_ECHOLNPGM("FAILURE: Watchdog did not trigger board reset."); } break; diff --git a/Marlin/src/inc/MarlinConfig.h b/Marlin/src/inc/MarlinConfig.h index 8fdb4b9bae..505a0682eb 100644 --- a/Marlin/src/inc/MarlinConfig.h +++ b/Marlin/src/inc/MarlinConfig.h @@ -29,6 +29,7 @@ #ifndef __MARLIN_DEPS__ #include "../HAL/HAL.h" + extern MarlinHAL hal; #endif #include "../pins/pins.h" diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8f6843eee9..9c74ce32db 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3891,3 +3891,10 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #undef _TEST_PWM #undef _LINEAR_AXES_STR #undef _LOGICAL_AXES_STR + +// JTAG support in the HAL +#if ENABLED(DISABLE_DEBUG) && !defined(JTAGSWD_DISABLE) + #error "DISABLE_DEBUG is not supported for the selected MCU/Board." +#elif ENABLED(DISABLE_JTAG) && !defined(JTAG_DISABLE) + #error "DISABLE_JTAG is not supported for the selected MCU/Board." +#endif diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index aafc4d8803..fc862e5439 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -282,9 +282,9 @@ void MarlinUI::init_lcd() { #if PIN_EXISTS(LCD_RESET) // Perform a clean hardware reset with needed delays OUT_WRITE(LCD_RESET_PIN, LOW); - _delay_ms(5); + hal.delay_ms(5); WRITE(LCD_RESET_PIN, HIGH); - _delay_ms(5); + hal.delay_ms(5); u8g.begin(); #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 4d7f38171d..d65fa9ec79 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -2206,7 +2206,7 @@ void RebootPrinter() { thermalManager.disable_all_heaters(); planner.finish_and_disable(); DWIN_RebootScreen(); - HAL_reboot(); + hal.reboot(); } void Goto_Info_Menu(){ diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index bce27dc88a..3dd6d8aeb6 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -1348,7 +1348,7 @@ void Endstops::update() { ES_REPORT_CHANGE(K_MAX); #endif SERIAL_ECHOLNPGM("\n"); - set_pwm_duty(pin_t(LED_PIN), local_LED_status); + hal.set_pwm_duty(pin_t(LED_PIN), local_LED_status); local_LED_status ^= 255; old_live_state_local = live_state_local; } diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index f9ddcf8f13..d2e11f62fe 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -703,7 +703,7 @@ void Planner::init() { // All other 32-bit MPUs can easily do inverse using hardware division, // so we don't need to reduce precision or to use assembly language at all. // This routine, for all other archs, returns 0x100000000 / d ~= 0xFFFFFFFF / d - static FORCE_INLINE uint32_t get_period_inverse(const uint32_t d) { + FORCE_INLINE static uint32_t get_period_inverse(const uint32_t d) { return d ? 0xFFFFFFFF / d : 0xFFFFFFFF; } #endif @@ -1260,7 +1260,7 @@ void Planner::recalculate() { #if ENABLED(FAN_SOFT_PWM) #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F); #else - #define _FAN_SET(F) set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); + #define _FAN_SET(F) hal.set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); #endif #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0) @@ -1397,8 +1397,8 @@ void Planner::check_axes_activity() { TERN_(AUTOTEMP, autotemp_task()); #if ENABLED(BARICUDA) - TERN_(HAS_HEATER_1, set_pwm_duty(pin_t(HEATER_1_PIN), tail_valve_pressure)); - TERN_(HAS_HEATER_2, set_pwm_duty(pin_t(HEATER_2_PIN), tail_e_to_p_pressure)); + TERN_(HAS_HEATER_1, hal.set_pwm_duty(pin_t(HEATER_1_PIN), tail_valve_pressure)); + TERN_(HAS_HEATER_2, hal.set_pwm_duty(pin_t(HEATER_2_PIN), tail_e_to_p_pressure)); #endif } diff --git a/Marlin/src/module/servo.cpp b/Marlin/src/module/servo.cpp index 231efe84e1..96d5ba9da8 100644 --- a/Marlin/src/module/servo.cpp +++ b/Marlin/src/module/servo.cpp @@ -30,7 +30,7 @@ #include "servo.h" -HAL_SERVO_LIB servo[NUM_SERVOS]; +hal_servo_t servo[NUM_SERVOS]; #if ENABLED(EDITABLE_SERVO_ANGLES) uint16_t servo_angles[NUM_SERVOS][2]; diff --git a/Marlin/src/module/servo.h b/Marlin/src/module/servo.h index 73dbbdddb7..cd55a317a2 100644 --- a/Marlin/src/module/servo.h +++ b/Marlin/src/module/servo.h @@ -112,5 +112,5 @@ #define MOVE_SERVO(I, P) servo[I].move(P) #define DETACH_SERVO(I) servo[I].detach() -extern HAL_SERVO_LIB servo[NUM_SERVOS]; +extern hal_servo_t servo[NUM_SERVOS]; void servo_init(); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 5da06a5e50..a96ed3a651 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1474,7 +1474,7 @@ void Stepper::isr() { #ifndef __AVR__ // Disable interrupts, to avoid ISR preemption while we reprogram the period // (AVR enters the ISR with global interrupts disabled, so no need to do it here) - DISABLE_ISRS(); + hal.isr_off(); #endif // Program timer compare for the maximum period, so it does NOT @@ -1492,7 +1492,7 @@ void Stepper::isr() { hal_timer_t min_ticks; do { // Enable ISRs to reduce USART processing latency - ENABLE_ISRS(); + hal.isr_on(); if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses @@ -1576,7 +1576,7 @@ void Stepper::isr() { * is less than the current count due to something preempting between the * read and the write of the new period value). */ - DISABLE_ISRS(); + hal.isr_off(); /** * Get the current tick value + margin @@ -1611,7 +1611,7 @@ void Stepper::isr() { HAL_timer_set_compare(MF_TIMER_STEP, hal_timer_t(next_isr_ticks)); // Don't forget to finally reenable interrupts - ENABLE_ISRS(); + hal.isr_on(); } #if MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE @@ -3260,33 +3260,33 @@ void Stepper::report_positions() { #elif HAS_MOTOR_CURRENT_PWM - #define _WRITE_CURRENT_PWM_DUTY(P) set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) + #define _WRITE_CURRENT_PWM(P) hal.set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) switch (driver) { case 0: #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) - _WRITE_CURRENT_PWM_DUTY(X); + _WRITE_CURRENT_PWM(X); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) - _WRITE_CURRENT_PWM_DUTY(Y); + _WRITE_CURRENT_PWM(Y); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - _WRITE_CURRENT_PWM_DUTY(XY); + _WRITE_CURRENT_PWM(XY); #endif break; case 1: #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - _WRITE_CURRENT_PWM_DUTY(Z); + _WRITE_CURRENT_PWM(Z); #endif break; case 2: #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - _WRITE_CURRENT_PWM_DUTY(E); + _WRITE_CURRENT_PWM(E); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) - _WRITE_CURRENT_PWM_DUTY(E0); + _WRITE_CURRENT_PWM(E0); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) - _WRITE_CURRENT_PWM_DUTY(E1); + _WRITE_CURRENT_PWM(E1); #endif break; } @@ -3308,7 +3308,7 @@ void Stepper::report_positions() { #ifdef __SAM3X8E__ #define _RESET_CURRENT_PWM_FREQ(P) NOOP #else - #define _RESET_CURRENT_PWM_FREQ(P) set_pwm_frequency(pin_t(P), MOTOR_CURRENT_PWM_FREQUENCY) + #define _RESET_CURRENT_PWM_FREQ(P) hal.set_pwm_frequency(pin_t(P), MOTOR_CURRENT_PWM_FREQUENCY) #endif #define INIT_CURRENT_PWM(P) do{ SET_PWM(MOTOR_CURRENT_PWM_## P ##_PIN); _RESET_CURRENT_PWM_FREQ(MOTOR_CURRENT_PWM_## P ##_PIN); }while(0) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 4ccd984b0d..19501bce6e 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -327,7 +327,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #define _INIT_FAN_PIN(P) do{ if (PWM_PIN(P)) SET_PWM(P); else _INIT_SOFT_FAN(P); }while(0) #endif #if ENABLED(FAST_PWM_FAN) - #define SET_FAST_PWM_FREQ(P) set_pwm_frequency(P, FAST_PWM_FAN_FREQUENCY) + #define SET_FAST_PWM_FREQ(P) hal.set_pwm_frequency(pin_t(P), FAST_PWM_FAN_FREQUENCY) #else #define SET_FAST_PWM_FREQ(P) NOOP #endif @@ -818,7 +818,7 @@ volatile bool Temperature::raw_temps_ready = false; } // Run HAL idle tasks - TERN_(HAL_IDLETASK, HAL_idletask()); + hal.idletask(); // Run UI update TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update()); @@ -907,7 +907,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #define _UPDATE_AUTO_FAN(P,D,A) do{ \ if (PWM_PIN(P##_AUTO_FAN_PIN) && A < 255) \ - set_pwm_duty(pin_t(P##_AUTO_FAN_PIN), D ? A : 0); \ + hal.set_pwm_duty(pin_t(P##_AUTO_FAN_PIN), D ? A : 0); \ else \ WRITE(P##_AUTO_FAN_PIN, D); \ }while(0) @@ -2321,74 +2321,33 @@ void Temperature::init() { TERN_(HAS_MAXTC_SW_SPI, max_tc_spi.init()); - HAL_adc_init(); + hal.adc_init(); + + TERN_(HAS_TEMP_ADC_0, hal.adc_enable(TEMP_0_PIN)); + TERN_(HAS_TEMP_ADC_1, hal.adc_enable(TEMP_1_PIN)); + TERN_(HAS_TEMP_ADC_2, hal.adc_enable(TEMP_2_PIN)); + TERN_(HAS_TEMP_ADC_3, hal.adc_enable(TEMP_3_PIN)); + TERN_(HAS_TEMP_ADC_4, hal.adc_enable(TEMP_4_PIN)); + TERN_(HAS_TEMP_ADC_5, hal.adc_enable(TEMP_5_PIN)); + TERN_(HAS_TEMP_ADC_6, hal.adc_enable(TEMP_6_PIN)); + TERN_(HAS_TEMP_ADC_7, hal.adc_enable(TEMP_7_PIN)); + TERN_(HAS_JOY_ADC_X, hal.adc_enable(JOY_X_PIN)); + TERN_(HAS_JOY_ADC_Y, hal.adc_enable(JOY_Y_PIN)); + TERN_(HAS_JOY_ADC_Z, hal.adc_enable(JOY_Z_PIN)); + TERN_(HAS_TEMP_ADC_BED, hal.adc_enable(TEMP_BED_PIN)); + TERN_(HAS_TEMP_ADC_CHAMBER, hal.adc_enable(TEMP_CHAMBER_PIN)); + TERN_(HAS_TEMP_ADC_PROBE, hal.adc_enable(TEMP_PROBE_PIN)); + TERN_(HAS_TEMP_ADC_COOLER, hal.adc_enable(TEMP_COOLER_PIN)); + TERN_(HAS_TEMP_ADC_BOARD, hal.adc_enable(TEMP_BOARD_PIN)); + TERN_(HAS_TEMP_ADC_REDUNDANT, hal.adc_enable(TEMP_REDUNDANT_PIN)); + TERN_(FILAMENT_WIDTH_SENSOR, hal.adc_enable(FILWIDTH_PIN)); + TERN_(HAS_ADC_BUTTONS, hal.adc_enable(ADC_KEYPAD_PIN)); + TERN_(POWER_MONITOR_CURRENT, hal.adc_enable(POWER_MONITOR_CURRENT_PIN)); + TERN_(POWER_MONITOR_VOLTAGE, hal.adc_enable(POWER_MONITOR_VOLTAGE_PIN)); - #if HAS_TEMP_ADC_0 - HAL_ANALOG_SELECT(TEMP_0_PIN); - #endif - #if HAS_TEMP_ADC_1 - HAL_ANALOG_SELECT(TEMP_1_PIN); - #endif - #if HAS_TEMP_ADC_2 - HAL_ANALOG_SELECT(TEMP_2_PIN); - #endif - #if HAS_TEMP_ADC_3 - HAL_ANALOG_SELECT(TEMP_3_PIN); - #endif - #if HAS_TEMP_ADC_4 - HAL_ANALOG_SELECT(TEMP_4_PIN); - #endif - #if HAS_TEMP_ADC_5 - HAL_ANALOG_SELECT(TEMP_5_PIN); - #endif - #if HAS_TEMP_ADC_6 - HAL_ANALOG_SELECT(TEMP_6_PIN); - #endif - #if HAS_TEMP_ADC_7 - HAL_ANALOG_SELECT(TEMP_7_PIN); - #endif - #if HAS_JOY_ADC_X - HAL_ANALOG_SELECT(JOY_X_PIN); - #endif - #if HAS_JOY_ADC_Y - HAL_ANALOG_SELECT(JOY_Y_PIN); - #endif - #if HAS_JOY_ADC_Z - HAL_ANALOG_SELECT(JOY_Z_PIN); - #endif #if HAS_JOY_ADC_EN SET_INPUT_PULLUP(JOY_EN_PIN); #endif - #if HAS_TEMP_ADC_BED - HAL_ANALOG_SELECT(TEMP_BED_PIN); - #endif - #if HAS_TEMP_ADC_CHAMBER - HAL_ANALOG_SELECT(TEMP_CHAMBER_PIN); - #endif - #if HAS_TEMP_ADC_PROBE - HAL_ANALOG_SELECT(TEMP_PROBE_PIN); - #endif - #if HAS_TEMP_ADC_COOLER - HAL_ANALOG_SELECT(TEMP_COOLER_PIN); - #endif - #if HAS_TEMP_ADC_BOARD - HAL_ANALOG_SELECT(TEMP_BOARD_PIN); - #endif - #if HAS_TEMP_ADC_REDUNDANT - HAL_ANALOG_SELECT(TEMP_REDUNDANT_PIN); - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - HAL_ANALOG_SELECT(FILWIDTH_PIN); - #endif - #if HAS_ADC_BUTTONS - HAL_ANALOG_SELECT(ADC_KEYPAD_PIN); - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - HAL_ANALOG_SELECT(POWER_MONITOR_CURRENT_PIN); - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - HAL_ANALOG_SELECT(POWER_MONITOR_VOLTAGE_PIN); - #endif HAL_timer_start(MF_TIMER_TEMP, TEMP_TIMER_FREQUENCY); ENABLE_TEMPERATURE_INTERRUPT(); @@ -3364,8 +3323,8 @@ void Temperature::isr() { * This gives each ADC 0.9765ms to charge up. */ #define ACCUMULATE_ADC(obj) do{ \ - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; \ - else obj.sample(HAL_READ_ADC()); \ + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; \ + else obj.sample(hal.adc_value()); \ }while(0) ADCSensorState next_sensor_state = adc_sensor_state < SensorsReady ? (ADCSensorState)(int(adc_sensor_state) + 1) : StartSampling; @@ -3397,115 +3356,115 @@ void Temperature::isr() { break; #if HAS_TEMP_ADC_0 - case PrepareTemp_0: HAL_START_ADC(TEMP_0_PIN); break; + case PrepareTemp_0: hal.adc_start(TEMP_0_PIN); break; case MeasureTemp_0: ACCUMULATE_ADC(temp_hotend[0]); break; #endif #if HAS_TEMP_ADC_BED - case PrepareTemp_BED: HAL_START_ADC(TEMP_BED_PIN); break; + case PrepareTemp_BED: hal.adc_start(TEMP_BED_PIN); break; case MeasureTemp_BED: ACCUMULATE_ADC(temp_bed); break; #endif #if HAS_TEMP_ADC_CHAMBER - case PrepareTemp_CHAMBER: HAL_START_ADC(TEMP_CHAMBER_PIN); break; + case PrepareTemp_CHAMBER: hal.adc_start(TEMP_CHAMBER_PIN); break; case MeasureTemp_CHAMBER: ACCUMULATE_ADC(temp_chamber); break; #endif #if HAS_TEMP_ADC_COOLER - case PrepareTemp_COOLER: HAL_START_ADC(TEMP_COOLER_PIN); break; + case PrepareTemp_COOLER: hal.adc_start(TEMP_COOLER_PIN); break; case MeasureTemp_COOLER: ACCUMULATE_ADC(temp_cooler); break; #endif #if HAS_TEMP_ADC_PROBE - case PrepareTemp_PROBE: HAL_START_ADC(TEMP_PROBE_PIN); break; + case PrepareTemp_PROBE: hal.adc_start(TEMP_PROBE_PIN); break; case MeasureTemp_PROBE: ACCUMULATE_ADC(temp_probe); break; #endif #if HAS_TEMP_ADC_BOARD - case PrepareTemp_BOARD: HAL_START_ADC(TEMP_BOARD_PIN); break; + case PrepareTemp_BOARD: hal.adc_start(TEMP_BOARD_PIN); break; case MeasureTemp_BOARD: ACCUMULATE_ADC(temp_board); break; #endif #if HAS_TEMP_ADC_REDUNDANT - case PrepareTemp_REDUNDANT: HAL_START_ADC(TEMP_REDUNDANT_PIN); break; + case PrepareTemp_REDUNDANT: hal.adc_start(TEMP_REDUNDANT_PIN); break; case MeasureTemp_REDUNDANT: ACCUMULATE_ADC(temp_redundant); break; #endif #if HAS_TEMP_ADC_1 - case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break; + case PrepareTemp_1: hal.adc_start(TEMP_1_PIN); break; case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break; #endif #if HAS_TEMP_ADC_2 - case PrepareTemp_2: HAL_START_ADC(TEMP_2_PIN); break; + case PrepareTemp_2: hal.adc_start(TEMP_2_PIN); break; case MeasureTemp_2: ACCUMULATE_ADC(temp_hotend[2]); break; #endif #if HAS_TEMP_ADC_3 - case PrepareTemp_3: HAL_START_ADC(TEMP_3_PIN); break; + case PrepareTemp_3: hal.adc_start(TEMP_3_PIN); break; case MeasureTemp_3: ACCUMULATE_ADC(temp_hotend[3]); break; #endif #if HAS_TEMP_ADC_4 - case PrepareTemp_4: HAL_START_ADC(TEMP_4_PIN); break; + case PrepareTemp_4: hal.adc_start(TEMP_4_PIN); break; case MeasureTemp_4: ACCUMULATE_ADC(temp_hotend[4]); break; #endif #if HAS_TEMP_ADC_5 - case PrepareTemp_5: HAL_START_ADC(TEMP_5_PIN); break; + case PrepareTemp_5: hal.adc_start(TEMP_5_PIN); break; case MeasureTemp_5: ACCUMULATE_ADC(temp_hotend[5]); break; #endif #if HAS_TEMP_ADC_6 - case PrepareTemp_6: HAL_START_ADC(TEMP_6_PIN); break; + case PrepareTemp_6: hal.adc_start(TEMP_6_PIN); break; case MeasureTemp_6: ACCUMULATE_ADC(temp_hotend[6]); break; #endif #if HAS_TEMP_ADC_7 - case PrepareTemp_7: HAL_START_ADC(TEMP_7_PIN); break; + case PrepareTemp_7: hal.adc_start(TEMP_7_PIN); break; case MeasureTemp_7: ACCUMULATE_ADC(temp_hotend[7]); break; #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) - case Prepare_FILWIDTH: HAL_START_ADC(FILWIDTH_PIN); break; + case Prepare_FILWIDTH: hal.adc_start(FILWIDTH_PIN); break; case Measure_FILWIDTH: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else filwidth.accumulate(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else filwidth.accumulate(hal.adc_value()); break; #endif #if ENABLED(POWER_MONITOR_CURRENT) case Prepare_POWER_MONITOR_CURRENT: - HAL_START_ADC(POWER_MONITOR_CURRENT_PIN); + hal.adc_start(POWER_MONITOR_CURRENT_PIN); break; case Measure_POWER_MONITOR_CURRENT: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else power_monitor.add_current_sample(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else power_monitor.add_current_sample(hal.adc_value()); break; #endif #if ENABLED(POWER_MONITOR_VOLTAGE) case Prepare_POWER_MONITOR_VOLTAGE: - HAL_START_ADC(POWER_MONITOR_VOLTAGE_PIN); + hal.adc_start(POWER_MONITOR_VOLTAGE_PIN); break; case Measure_POWER_MONITOR_VOLTAGE: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else power_monitor.add_voltage_sample(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else power_monitor.add_voltage_sample(hal.adc_value()); break; #endif #if HAS_JOY_ADC_X - case PrepareJoy_X: HAL_START_ADC(JOY_X_PIN); break; + case PrepareJoy_X: hal.adc_start(JOY_X_PIN); break; case MeasureJoy_X: ACCUMULATE_ADC(joystick.x); break; #endif #if HAS_JOY_ADC_Y - case PrepareJoy_Y: HAL_START_ADC(JOY_Y_PIN); break; + case PrepareJoy_Y: hal.adc_start(JOY_Y_PIN); break; case MeasureJoy_Y: ACCUMULATE_ADC(joystick.y); break; #endif #if HAS_JOY_ADC_Z - case PrepareJoy_Z: HAL_START_ADC(JOY_Z_PIN); break; + case PrepareJoy_Z: hal.adc_start(JOY_Z_PIN); break; case MeasureJoy_Z: ACCUMULATE_ADC(joystick.z); break; #endif @@ -3513,12 +3472,12 @@ void Temperature::isr() { #ifndef ADC_BUTTON_DEBOUNCE_DELAY #define ADC_BUTTON_DEBOUNCE_DELAY 16 #endif - case Prepare_ADC_KEY: HAL_START_ADC(ADC_KEYPAD_PIN); break; + case Prepare_ADC_KEY: hal.adc_start(ADC_KEYPAD_PIN); break; case Measure_ADC_KEY: - if (!HAL_ADC_READY()) + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // redo this state else if (ADCKey_count < ADC_BUTTON_DEBOUNCE_DELAY) { - raw_ADCKey_value = HAL_READ_ADC(); + raw_ADCKey_value = hal.adc_value(); if (raw_ADCKey_value <= 900UL * HAL_ADC_RANGE / 1024UL) { NOMORE(current_ADCKey_raw, raw_ADCKey_value); ADCKey_count++; diff --git a/ini/features.ini b/ini/features.ini index c52675ff2d..ead3f6327b 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -233,7 +233,7 @@ HAS_SERVOS = src_filter=+ + HAS_MICROSTEPS = src_filter=+ (ESP3D_)?WIFISUPPORT = AsyncTCP, ESP Async WebServer - ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master.zip + ESP3DLib=https://github.com/luc-github/ESP3DLib/archive/master-2.0.7.zip arduinoWebSockets=links2004/WebSockets@2.3.4 luc-github/ESP32SSDP@^1.1.1 lib_ignore=ESPAsyncTCP diff --git a/ini/native.ini b/ini/native.ini index 5355284992..3d196f3436 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -34,14 +34,14 @@ src_filter = ${common.default_src_filter} + [simulator_common] platform = native framework = -build_flags = ${common.build_flags} -std=gnu++17 -D__PLAT_NATIVE_SIM__ -DU8G_HAL_LINKS -I/usr/include/SDL2 -IMarlin -IMarlin/src/HAL/NATIVE_SIM/include -IMarlin/src/HAL/NATIVE_SIM/u8g +build_flags = ${common.build_flags} -std=gnu++17 -D__PLAT_NATIVE_SIM__ -DU8G_HAL_LINKS -I/usr/include/SDL2 -IMarlin -IMarlin/src/HAL/NATIVE_SIM/u8g src_build_flags = -Wall -Wno-expansion-to-defined -Wcast-align release_flags = -g0 -O3 -flto debug_build_flags = -fstack-protector-strong -g -g3 -ggdb lib_compat_mode = off src_filter = ${common.default_src_filter} + lib_deps = ${common.lib_deps} - MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/master.zip + MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/0.0.2.zip Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/marlin_sim_native.zip LiquidCrystal=https://github.com/p3p/LiquidCrystal/archive/master.zip extra_scripts = ${common.extra_scripts} From 28ceb1ed0f50f474adbcfa0690c1fa751e912281 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 19 Feb 2022 00:25:05 +0000 Subject: [PATCH 045/203] [cron] Bump distribution date (2022-02-19) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index f13abf77fb..93f951117c 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-18" +//#define STRING_DISTRIBUTION_DATE "2022-02-19" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 45bf3f47a4..e86ab345b8 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-18" + #define STRING_DISTRIBUTION_DATE "2022-02-19" #endif /** From a9682f2e975e63d4ba5b4e8a9486317849a5b8b1 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 22 Feb 2022 13:31:44 +1300 Subject: [PATCH 046/203] =?UTF-8?q?=F0=9F=93=8C=20Creality=20RAMPS=20optio?= =?UTF-8?q?nal=20SD=5FDETECT=5FPIN=20(#23740)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h index 21dadd60ee..679503e982 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -39,7 +39,12 @@ #endif #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN 49 // Always define onboard SD detect + #if SD_CONNECTION_IS(ONBOARD) + //#define HAS_ONBOARD_SD_DETECT // If the SD_DETECT_PIN is wired up + #endif + #if ENABLED(HAS_ONBOARD_SD_DETECT) || !SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN 49 + #endif #endif #ifndef PS_ON_PIN From 8f8427ec8f69705e09ca226d9f16da6b82634439 Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Tue, 22 Feb 2022 01:15:52 +0000 Subject: [PATCH 047/203] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Apply=20PTC=20on?= =?UTF-8?q?=20all=20probing=20(#23764)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/feature/probe_temp_comp.cpp | 9 +++++++++ Marlin/src/feature/probe_temp_comp.h | 11 +++++++++-- Marlin/src/gcode/bedlevel/abl/G29.cpp | 9 --------- Marlin/src/gcode/calibrate/G76_M871.cpp | 2 ++ Marlin/src/gcode/calibrate/M48.cpp | 12 +++++++++++- Marlin/src/gcode/probe/G30.cpp | 8 ++++++++ Marlin/src/lcd/menu/menu_probe_offset.cpp | 2 +- Marlin/src/module/probe.cpp | 9 ++++++++- 8 files changed, 48 insertions(+), 14 deletions(-) diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index 9a975d6763..b5f636e698 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -28,6 +28,7 @@ #include "probe_temp_comp.h" #include +#include "../module/temperature.h" ProbeTempComp ptc; @@ -62,6 +63,7 @@ constexpr temp_calib_t ProbeTempComp::cali_info[TSI_COUNT]; uint8_t ProbeTempComp::calib_idx; // = 0 float ProbeTempComp::init_measurement; // = 0.0 +bool ProbeTempComp::enabled = true; void ProbeTempComp::reset() { TERN_(PTC_PROBE, LOOP_L_N(i, PTC_PROBE_COUNT) z_offsets_probe[i] = z_offsets_probe_default[i]); @@ -169,6 +171,13 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { return true; } +void ProbeTempComp::apply_compensation(float &meas_z) { + if (!enabled) return; + TERN_(PTC_BED, compensate_measurement(TSI_BED, thermalManager.degBed(), meas_z)); + TERN_(PTC_PROBE, compensate_measurement(TSI_PROBE, thermalManager.degProbe(), meas_z)); + TERN_(PTC_HOTEND, compensate_measurement(TSI_EXT, thermalManager.degHotend(0), meas_z)); +} + void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z) { const uint8_t measurements = cali_info[tsi].measurements; const celsius_t start_temp = cali_info[tsi].start_temp, diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 1db7d04e89..42348db684 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -77,7 +77,6 @@ class ProbeTempComp { static void reset_index() { calib_idx = 0; }; static uint8_t get_index() { return calib_idx; } static void reset(); - static void clear_offsets(const TempSensorID tsi); static void clear_all_offsets() { TERN_(PTC_PROBE, clear_offsets(TSI_PROBE)); TERN_(PTC_BED, clear_offsets(TSI_BED)); @@ -88,10 +87,16 @@ class ProbeTempComp { static void prepare_new_calibration(const_float_t init_meas_z); static void push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z); static bool finish_calibration(const TempSensorID tsi); - static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z); + static void set_enabled(const bool ena) { enabled = ena; } + + // Apply all temperature compensation adjustments + static void apply_compensation(float &meas_z); private: static uint8_t calib_idx; + static bool enabled; + + static void clear_offsets(const TempSensorID tsi); /** * Base value. Temperature compensation values will be deltas @@ -104,6 +109,8 @@ class ProbeTempComp { * to allow generating values of higher temperatures. */ static bool linear_regression(const TempSensorID tsi, float &k, float &d); + + static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z); }; extern ProbeTempComp ptc; diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 9ec43fe49d..24c0268b9f 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -36,11 +36,6 @@ #include "../../../module/probe.h" #include "../../queue.h" -#if HAS_PTC - #include "../../../feature/probe_temp_comp.h" - #include "../../../module/temperature.h" -#endif - #if HAS_STATUS_MESSAGE #include "../../../lcd/marlinui.h" #endif @@ -658,10 +653,6 @@ G29_TYPE GcodeSuite::G29() { break; // Breaks out of both loops } - TERN_(PTC_BED, ptc.compensate_measurement(TSI_BED, thermalManager.degBed(), abl.measured_z)); - TERN_(PTC_PROBE, ptc.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), abl.measured_z)); - TERN_(PTC_HOTEND, ptc.compensate_measurement(TSI_EXT, thermalManager.degHotend(0), abl.measured_z)); - #if ENABLED(AUTO_BED_LEVELING_LINEAR) abl.mean += abl.measured_z; diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 21bb2c7590..ad13b20306 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -109,7 +109,9 @@ static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibra auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) { do_z_clearance(5.0); // Raise nozzle before probing + ptc.set_enabled(false); const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false + ptc.set_enabled(true); if (isnan(measured_z)) SERIAL_ECHOLNPGM("!Received NAN. Aborting."); else { diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 913ffe30d4..8b6ea0bf1f 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -35,11 +35,15 @@ #include "../../module/planner.h" #endif +#if HAS_PTC + #include "../../feature/probe_temp_comp.h" +#endif + /** * M48: Z probe repeatability measurement function. * * Usage: - * M48 + * M48 * P = Number of sampled points (4-50, default 10) * X = Sample X position * Y = Sample Y position @@ -47,6 +51,7 @@ * E = Engage Z probe for each reading * L = Number of legs of movement before probe * S = Schizoid (Or Star if you prefer) + * C = Enable probe temperature compensation (0 or 1, default 1) * * This function requires the machine to be homed before invocation. */ @@ -107,6 +112,8 @@ void GcodeSuite::M48() { set_bed_leveling_enabled(false); #endif + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); + // Work with reasonable feedrates remember_feedrate_scaling_off(); @@ -269,6 +276,9 @@ void GcodeSuite::M48() { // Re-enable bed level correction if it had been on TERN_(HAS_LEVELING, set_bed_leveling_enabled(was_enabled)); + // Re-enable probe temperature correction + TERN_(HAS_PTC, ptc.set_enabled(true)); + report_current_position(); } diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index f4152c76e9..474f1f252a 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -29,6 +29,10 @@ #include "../../module/probe.h" #include "../../feature/bedlevel/bedlevel.h" +#if HAS_PTC + #include "../../feature/probe_temp_comp.h" +#endif + /** * G30: Do a single Z probe at the current XY * @@ -37,6 +41,7 @@ * X Probe X position (default current X) * Y Probe Y position (default current Y) * E Engage the probe for each probe (default 1) + * C Enable probe temperature compensation (0 or 1, default 1) */ void GcodeSuite::G30() { @@ -51,7 +56,10 @@ void GcodeSuite::G30() { remember_feedrate_scaling_off(); const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; + + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); const float measured_z = probe.probe_at_point(pos, raise_after, 1); + TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index ae785fa641..79db47005d 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -62,7 +62,7 @@ void probe_offset_wizard_menu() { if (LCD_HEIGHT >= 4) STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT); - STATIC_ITEM_P(PSTR("Z="), SS_CENTER, ftostr42_52(current_position.z)); + STATIC_ITEM_P(PSTR("Z"), SS_CENTER, ftostr42_52(current_position.z)); STATIC_ITEM(MSG_ZPROBE_ZOFFSET, SS_LEFT, ftostr42_52(calculated_z_offset)); SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move_z( 1); }); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index fdd6897192..95776ffda1 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -77,6 +77,10 @@ #include "servo.h" #endif +#if HAS_PTC + #include "../feature/probe_temp_comp.h" +#endif + #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) @@ -801,7 +805,10 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S)); float measured_z = NAN; - if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z; + if (!deploy()) { + measured_z = run_z_probe(sanity_check) + offset.z; + TERN_(HAS_PTC, ptc.apply_compensation(measured_z)); + } if (!isnan(measured_z)) { const bool big_raise = raise_after == PROBE_PT_BIG_RAISE; if (big_raise || raise_after == PROBE_PT_RAISE) From 9530df4816ed409e79c7b0403613e663f0d63511 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 21 Feb 2022 19:54:03 -0600 Subject: [PATCH 048/203] =?UTF-8?q?=F0=9F=93=9D=20Update=20Toolchange=20FS?= =?UTF-8?q?=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 8 ++++---- Marlin/src/libs/nozzle.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index f2676828ff..2d1b14107d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2417,7 +2417,7 @@ #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) // Load / Unload #define TOOLCHANGE_FS_LENGTH 12 // (mm) Load / Unload length - #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart, fine tune by LCD/Gcode) + #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart. Adjust with LCD or M217 B. #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/min) (Unloading) #define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/min) (On SINGLENOZZLE or Bowden loading must be slowed down) @@ -2431,12 +2431,12 @@ #define TOOLCHANGE_FS_FAN_SPEED 255 // 0-255 #define TOOLCHANGE_FS_FAN_TIME 10 // (seconds) - // Swap uninitialized extruder with TOOLCHANGE_FS_PRIME_SPEED for all lengths (recover + prime) + // Swap uninitialized extruder (using TOOLCHANGE_FS_PRIME_SPEED feedrate) // (May break filament if not retracted beforehand.) //#define TOOLCHANGE_FS_INIT_BEFORE_SWAP - // Prime on the first T0 (If other, TOOLCHANGE_FS_INIT_BEFORE_SWAP applied) - // Enable it (M217 V[0/1]) before printing, to avoid unwanted priming on host connect + // Prime on the first T0 (For other tools use TOOLCHANGE_FS_INIT_BEFORE_SWAP) + // Enable with M217 V1 before printing to avoid unwanted priming on host connect //#define TOOLCHANGE_FS_PRIME_FIRST_USED /** diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 5cd2014d7f..4ca8fa2cae 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -263,7 +263,7 @@ Nozzle nozzle; case 2: do_blocking_move_to_y(park.y, fr_xy); break; case 3: do_blocking_move_to_x(park.x, fr_xy); do_blocking_move_to_y(park.y, fr_xy); break; - case 4: do_blocking_move_to_y(park.y, fr_xy); + case 4: do_blocking_move_to_y(park.y, fr_xy); do_blocking_move_to_x(park.x, fr_xy); break; } From 963049ddc39c77176e67d7eaad0d117a1e1b666a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 21 Feb 2022 19:55:19 -0600 Subject: [PATCH 049/203] =?UTF-8?q?=E2=9C=A8=20Dyze=20Design=20PT100=20Amp?= =?UTF-8?q?lifier=20Board=20(#23760)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 1 + Marlin/src/module/thermistor/thermistor_68.h | 54 ++++++++++++++++++++ Marlin/src/module/thermistor/thermistors.h | 3 ++ 3 files changed, 58 insertions(+) create mode 100644 Marlin/src/module/thermistor/thermistor_68.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 752fd1370a..6f7b1bdf4a 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -459,6 +459,7 @@ * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 * 66 : 4.7MΩ Dyze Design High Temperature Thermistor * 67 : 500kΩ SliceEngineering 450°C Thermistor + * 68 : PT100 amplifier board from Dyze Design * 70 : 100kΩ bq Hephestos 2 * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32 * 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor diff --git a/Marlin/src/module/thermistor/thermistor_68.h b/Marlin/src/module/thermistor/thermistor_68.h new file mode 100644 index 0000000000..270456dcb5 --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_68.h @@ -0,0 +1,54 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define REVERSE_TEMP_SENSOR_RANGE_68 1 + +// PT100 amplifier board from Dyze Design +const temp_entry_t temptable_68[] PROGMEM = { + { OV(273), 0 }, + { OV(294), 20 }, + { OV(315), 40 }, + { OV(336), 60 }, + { OV(356), 80 }, + { OV(376), 100 }, + { OV(396), 120 }, + { OV(416), 140 }, + { OV(436), 160 }, + { OV(455), 180 }, + { OV(474), 200 }, + { OV(494), 220 }, + { OV(513), 240 }, + { OV(531), 260 }, + { OV(550), 280 }, + { OV(568), 300 }, + { OV(587), 320 }, + { OV(605), 340 }, + { OV(623), 360 }, + { OV(641), 380 }, + { OV(658), 400 }, + { OV(676), 420 }, + { OV(693), 440 }, + { OV(710), 460 }, + { OV(727), 480 }, + { OV(744), 500 } +}; diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 3d9ef5062d..9f2ebce49a 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -156,6 +156,9 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(67) // R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor #include "thermistor_67.h" #endif +#if ANY_THERMISTOR_IS(68) // PT-100 with Dyze amplifier board + #include "thermistor_68.h" +#endif #if ANY_THERMISTOR_IS(12) // beta25 = 4700 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Personal calibration for Makibox hot bed" #include "thermistor_12.h" #endif From 6b96636b9b37e6d0d95699a9120afe48f4b640d0 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Mon, 21 Feb 2022 18:47:53 -0800 Subject: [PATCH 050/203] =?UTF-8?q?=F0=9F=94=A7=20Warning=20for=20MK3=5FFA?= =?UTF-8?q?N=5FPINS=20(#23727)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Warnings.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 3545ee8b5d..9d7b14d763 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -597,3 +597,10 @@ #ifdef __STM32F1__ #warning "Maple build environments are deprecated. Please use a non-Maple build environment. Report issues to the Marlin Firmware project." #endif + +/** + * Průša MK3/S/+ fan pin reassignment + */ +#if MB(BTT_BTT002_V1_0, EINSY_RAMBO) && DISABLED(NO_MK3_FAN_PINS_WARNING) + #warning "Define MK3_FAN_PINS to swap hotend and part cooling fan pins. (Define NO_MK3_FAN_PINS_WARNING to suppress this warning.)" +#endif From 92f85e877dbfb7a9ecdb139e5f2a6473c2868c97 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 21 Feb 2022 20:50:09 -0600 Subject: [PATCH 051/203] =?UTF-8?q?=F0=9F=94=A8=20Workspace=20file=20with?= =?UTF-8?q?=20recommendation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/extensions.json | 3 +++ buildroot/share/vscode/MarlinFirmware.code-workspace | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 buildroot/share/vscode/MarlinFirmware.code-workspace diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 7226831cb1..f495d14f53 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,5 +4,8 @@ "recommendations": [ "marlinfirmware.auto-build", "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" ] } diff --git a/buildroot/share/vscode/MarlinFirmware.code-workspace b/buildroot/share/vscode/MarlinFirmware.code-workspace new file mode 100644 index 0000000000..bd433b07f0 --- /dev/null +++ b/buildroot/share/vscode/MarlinFirmware.code-workspace @@ -0,0 +1,4 @@ +{ + "folders": [ { "path": "../../.." } ], + "extensions": { "recommendations": [ "marlinfirmware.auto-build" ] } +} From f03c3677394126e72fb7c2679891a67f1efe0332 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 22 Feb 2022 16:16:57 +1300 Subject: [PATCH 052/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20TMC26X=20CS=20pins?= =?UTF-8?q?=20init=20(#23778)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/core/drivers.h | 2 +- Marlin/src/feature/tmc_util.cpp | 126 ++++++++++++++++---------------- Marlin/src/feature/tmc_util.h | 4 +- ini/features.ini | 3 +- 5 files changed, 69 insertions(+), 68 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 482ad95cac..81dc7db4cc 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -145,7 +145,7 @@ #include "feature/encoder_i2c.h" #endif -#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF) +#if (HAS_TRINAMIC_CONFIG || HAS_TMC_SPI) && DISABLED(PSU_DEFAULT_OFF) #include "feature/tmc_util.h" #endif diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 0a76410274..2e66cc9201 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -128,7 +128,7 @@ // Test for a driver that uses SPI - this allows checking whether a _CS_ pin // is considered sensitive #define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \ - || AXIS_DRIVER_TYPE(A,TMC2660) \ + || AXIS_DRIVER_TYPE(A,TMC26X) || AXIS_DRIVER_TYPE(A,TMC2660) \ || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) ) #define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) ) diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index cf3fa3b7b0..c69772bebc 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -1178,69 +1178,6 @@ #endif // USE_SENSORLESS -#if HAS_TMC_SPI - #define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) - void tmc_init_cs_pins() { - #if AXIS_HAS_SPI(X) - SET_CS_PIN(X); - #endif - #if AXIS_HAS_SPI(Y) - SET_CS_PIN(Y); - #endif - #if AXIS_HAS_SPI(Z) - SET_CS_PIN(Z); - #endif - #if AXIS_HAS_SPI(X2) - SET_CS_PIN(X2); - #endif - #if AXIS_HAS_SPI(Y2) - SET_CS_PIN(Y2); - #endif - #if AXIS_HAS_SPI(Z2) - SET_CS_PIN(Z2); - #endif - #if AXIS_HAS_SPI(Z3) - SET_CS_PIN(Z3); - #endif - #if AXIS_HAS_SPI(Z4) - SET_CS_PIN(Z4); - #endif - #if AXIS_HAS_SPI(I) - SET_CS_PIN(I); - #endif - #if AXIS_HAS_SPI(J) - SET_CS_PIN(J); - #endif - #if AXIS_HAS_SPI(K) - SET_CS_PIN(K); - #endif - #if AXIS_HAS_SPI(E0) - SET_CS_PIN(E0); - #endif - #if AXIS_HAS_SPI(E1) - SET_CS_PIN(E1); - #endif - #if AXIS_HAS_SPI(E2) - SET_CS_PIN(E2); - #endif - #if AXIS_HAS_SPI(E3) - SET_CS_PIN(E3); - #endif - #if AXIS_HAS_SPI(E4) - SET_CS_PIN(E4); - #endif - #if AXIS_HAS_SPI(E5) - SET_CS_PIN(E5); - #endif - #if AXIS_HAS_SPI(E6) - SET_CS_PIN(E6); - #endif - #if AXIS_HAS_SPI(E7) - SET_CS_PIN(E7); - #endif - } -#endif // HAS_TMC_SPI - template static bool test_connection(TMC &st) { SERIAL_ECHOPGM("Testing "); @@ -1339,3 +1276,66 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) { } #endif // HAS_TRINAMIC_CONFIG + +#if HAS_TMC_SPI + #define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) + void tmc_init_cs_pins() { + #if AXIS_HAS_SPI(X) + SET_CS_PIN(X); + #endif + #if AXIS_HAS_SPI(Y) + SET_CS_PIN(Y); + #endif + #if AXIS_HAS_SPI(Z) + SET_CS_PIN(Z); + #endif + #if AXIS_HAS_SPI(X2) + SET_CS_PIN(X2); + #endif + #if AXIS_HAS_SPI(Y2) + SET_CS_PIN(Y2); + #endif + #if AXIS_HAS_SPI(Z2) + SET_CS_PIN(Z2); + #endif + #if AXIS_HAS_SPI(Z3) + SET_CS_PIN(Z3); + #endif + #if AXIS_HAS_SPI(Z4) + SET_CS_PIN(Z4); + #endif + #if AXIS_HAS_SPI(I) + SET_CS_PIN(I); + #endif + #if AXIS_HAS_SPI(J) + SET_CS_PIN(J); + #endif + #if AXIS_HAS_SPI(K) + SET_CS_PIN(K); + #endif + #if AXIS_HAS_SPI(E0) + SET_CS_PIN(E0); + #endif + #if AXIS_HAS_SPI(E1) + SET_CS_PIN(E1); + #endif + #if AXIS_HAS_SPI(E2) + SET_CS_PIN(E2); + #endif + #if AXIS_HAS_SPI(E3) + SET_CS_PIN(E3); + #endif + #if AXIS_HAS_SPI(E4) + SET_CS_PIN(E4); + #endif + #if AXIS_HAS_SPI(E5) + SET_CS_PIN(E5); + #endif + #if AXIS_HAS_SPI(E6) + SET_CS_PIN(E6); + #endif + #if AXIS_HAS_SPI(E7) + SET_CS_PIN(E7); + #endif + } +#endif // HAS_TMC_SPI diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 892d33768b..fc333b09dd 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -382,8 +382,8 @@ void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true)); #endif // USE_SENSORLESS +#endif // HAS_TRINAMIC_CONFIG + #if HAS_TMC_SPI void tmc_init_cs_pins(); #endif - -#endif // HAS_TRINAMIC_CONFIG diff --git a/ini/features.ini b/ini/features.ini index ead3f6327b..8ea1eb5049 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -18,7 +18,8 @@ POSTMORTEM_DEBUGGING = src_filter=+ + + + + + + + + + + + +HAS_T(RINAMIC_CONFIG|MC_SPI) = src_filter=+ HAS_STEALTHCHOP = src_filter=+ SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster From 60c89709df2705ae7e80bbe2e9b59b56d6ee8060 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 21 Feb 2022 23:07:09 -0600 Subject: [PATCH 053/203] =?UTF-8?q?=F0=9F=90=9B=20Ibid.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/features.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ini/features.ini b/ini/features.ini index 8ea1eb5049..627f094e07 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -18,7 +18,7 @@ POSTMORTEM_DEBUGGING = src_filter=+ + + + + + src_filter=+ + + + + HAS_T(RINAMIC_CONFIG|MC_SPI) = src_filter=+ HAS_STEALTHCHOP = src_filter=+ SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip From 432927df01ca0410dd5a9d00d17d7878095c2cd5 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 22 Feb 2022 06:06:52 +0000 Subject: [PATCH 054/203] [cron] Bump distribution date (2022-02-22) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 93f951117c..ee4b4a636b 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-19" +//#define STRING_DISTRIBUTION_DATE "2022-02-22" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index e86ab345b8..9c86aea477 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-19" + #define STRING_DISTRIBUTION_DATE "2022-02-22" #endif /** From 28f65301cfedf460f3a72a85fced49cbad18632f Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Thu, 24 Feb 2022 05:36:39 +1300 Subject: [PATCH 055/203] =?UTF-8?q?=F0=9F=94=A8=20More=20renamed.ini=20env?= =?UTF-8?q?s=20(#23786)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/renamed.ini | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/ini/renamed.ini b/ini/renamed.ini index bc1e438d60..abc8ee5c28 100644 --- a/ini/renamed.ini +++ b/ini/renamed.ini @@ -9,17 +9,41 @@ # # ################################# +# +# A platform that doesn't match anything in pins.h +# + +[renamed] +platform = native + # # List of environment names that are no longer used # [env:STM32F103RET6_creality_maple] -extends = env:STM32F103RE_maple +# Renamed to STM32F103RE_creality_maple +extends = renamed [env:STM32F103RET6_creality] -extends = STM32F103Rx_creality -board = genericSTM32F103RE +# Renamed to STM32F103RE_creality +extends = renamed [env:STM32F103RET6_creality_xfer] -extends = STM32F103Rx_creality_xfer -board = genericSTM32F103RE +# Renamed to STM32F103RE_creality_xfer +extends = renamed + +[env:STM32F103RC_btt_512K] +# Renamed to STM32F103RE_btt +extends = renamed + +[env:STM32F103RC_btt_512K_USB] +# Renamed to STM32F103RE_btt_USB +extends = renamed + +[env:STM32F103RC_btt_512K_maple] +# Renamed to STM32F103RE_btt_maple +extends = renamed + +[env:STM32F103RC_btt_512K_USB_maple] +# Renamed to STM32F103RE_btt_USB_maple +extends = renamed From 22b99a2e382034f951568dda8d2c70af06ddc47f Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 23 Feb 2022 18:03:44 +0000 Subject: [PATCH 056/203] [cron] Bump distribution date (2022-02-23) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index ee4b4a636b..d188ab5068 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-22" +//#define STRING_DISTRIBUTION_DATE "2022-02-23" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 9c86aea477..838b89c01d 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-22" + #define STRING_DISTRIBUTION_DATE "2022-02-23" #endif /** From 142042760796807d92800cc1bdf93a86f614bc88 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Feb 2022 18:47:57 -0600 Subject: [PATCH 057/203] =?UTF-8?q?=F0=9F=8E=A8=20=20Move=20PROPORTIONAL?= =?UTF-8?q?=5FFONT=5FRATIO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2d1b14107d..910e779b2a 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2337,6 +2337,15 @@ // For serial echo, the number of digits after the decimal point //#define SERIAL_FLOAT_PRECISION 4 +/** + * Set the number of proportional font spaces required to fill up a typical character space. + * This can help to better align the output of commands like `G29 O` Mesh Output. + * + * For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0. + * Otherwise, adjust according to your client and font. + */ +#define PROPORTIONAL_FONT_RATIO 1.0 + // @section extras /** @@ -3780,15 +3789,6 @@ //#define REPORT_FAN_CHANGE // Report the new fan speed when changed by M106 (and others) -/** - * Set the number of proportional font spaces required to fill up a typical character space. - * This can help to better align the output of commands like `G29 O` Mesh Output. - * - * For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0. - * Otherwise, adjust according to your client and font. - */ -#define PROPORTIONAL_FONT_RATIO 1.0 - /** * Spend 28 bytes of SRAM to optimize the G-code parser */ From 103b5f1ead5f610f95f19ad02327d73ea2767038 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 25 Feb 2022 06:07:00 +0000 Subject: [PATCH 058/203] [cron] Bump distribution date (2022-02-25) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index d188ab5068..40cef79e87 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-23" +//#define STRING_DISTRIBUTION_DATE "2022-02-25" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 838b89c01d..62cd2b23a2 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-23" + #define STRING_DISTRIBUTION_DATE "2022-02-25" #endif /** From 87c4cd20e514b9fc94450e9503e268cc014490e8 Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Sat, 26 Feb 2022 20:30:33 +0000 Subject: [PATCH 059/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20steps-to-mm=20with?= =?UTF-8?q?=20backlash=20(#23814)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/feature/backlash.cpp | 31 ++++++++++++++++++++++++++----- Marlin/src/feature/backlash.h | 9 ++++++++- Marlin/src/module/planner.cpp | 27 ++++++++++++++++++++------- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index 24c0f2ca0c..23458cf86c 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -29,6 +29,11 @@ #include "../module/motion.h" #include "../module/planner.h" +axis_bits_t Backlash::last_direction_bits; +#ifdef BACKLASH_SMOOTHING_MM + xyz_long_t Backlash::residual_error{0}; +#endif + #ifdef BACKLASH_DISTANCE_MM #if ENABLED(BACKLASH_GCODE) xyz_float_t Backlash::distance_mm = BACKLASH_DISTANCE_MM; @@ -61,7 +66,6 @@ Backlash backlash; */ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block) { - static axis_bits_t last_direction_bits; axis_bits_t changed_dir = last_direction_bits ^ dm; // Ignore direction change unless steps are taken in that direction #if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX) @@ -91,10 +95,6 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const // smoothing distance. Since the computation of this proportion involves a floating point // division, defer computation until needed. float segment_proportion = 0; - - // Residual error carried forward across multiple segments, so correction can be applied - // to segments where there is no direction change. - static xyz_long_t residual_error{0}; #else // No direction change, no correction. if (!changed_dir) return; @@ -153,6 +153,27 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const } } +int32_t Backlash::applied_steps(const AxisEnum axis) { + if (axis >= LINEAR_AXES) return 0; + + const bool reversing = TEST(last_direction_bits, axis); + + #ifdef BACKLASH_SMOOTHING_MM + const int32_t residual_error_axis = residual_error[axis]; + #else + constexpr int32_t residual_error_axis = 0; + #endif + + // At startup it is assumed the last move was forwards. So the applied + // steps will always be a non-positive number. + + if (!reversing) return -residual_error_axis; + + const float f_corr = float(correction) / 255.0f; + const int32_t full_error_axis = -f_corr * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; + return full_error_axis - residual_error_axis; +} + #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) #include "../module/probe.h" diff --git a/Marlin/src/feature/backlash.h b/Marlin/src/feature/backlash.h index 17504cc781..ef29012cb1 100644 --- a/Marlin/src/feature/backlash.h +++ b/Marlin/src/feature/backlash.h @@ -27,6 +27,12 @@ constexpr uint8_t all_on = 0xFF, all_off = 0x00; class Backlash { +private: + static axis_bits_t last_direction_bits; + #ifdef BACKLASH_SMOOTHING_MM + static xyz_long_t residual_error; + #endif + public: #if ENABLED(BACKLASH_GCODE) static xyz_float_t distance_mm; @@ -71,7 +77,8 @@ public: return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS); } - void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block); + static void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block); + static int32_t applied_steps(const AxisEnum axis); }; extern Backlash backlash; diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index d2e11f62fe..37b264a3c5 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1706,7 +1706,8 @@ void Planner::endstop_triggered(const AxisEnum axis) { } float Planner::triggered_position_mm(const AxisEnum axis) { - return stepper.triggered_position(axis) * mm_per_step[axis]; + const float result = DIFF_TERN(BACKLASH_COMPENSATION, stepper.triggered_position(axis), backlash.applied_steps(axis)); + return result * mm_per_step[axis]; } void Planner::finish_and_disable() { @@ -1728,8 +1729,8 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { // Protect the access to the position. const bool was_enabled = stepper.suspend(); - const int32_t p1 = stepper.position(CORE_AXIS_1), - p2 = stepper.position(CORE_AXIS_2); + const int32_t p1 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_1), backlash.applied_steps(CORE_AXIS_1)), + p2 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_2), backlash.applied_steps(CORE_AXIS_2)); if (was_enabled) stepper.wake_up(); @@ -1738,7 +1739,7 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { axis_steps = (axis == CORE_AXIS_2 ? CORESIGN(p1 - p2) : p1 + p2) * 0.5f; } else - axis_steps = stepper.position(axis); + axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.applied_steps(axis)); #elif EITHER(MARKFORGED_XY, MARKFORGED_YX) @@ -1755,11 +1756,12 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { axis_steps = ((axis == CORE_AXIS_1) ? p1 - p2 : p2); } else - axis_steps = stepper.position(axis); + axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.applied_steps(axis)); #else axis_steps = stepper.position(axis); + TERN_(BACKLASH_COMPENSATION, axis_steps -= backlash.applied_steps(axis)); #endif @@ -2841,6 +2843,9 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ block->flag = sync_flag; block->position = position; + #if ENABLED(BACKLASH_COMPENSATION) + LOOP_LINEAR_AXES(axis) block->position[axis] += backlash.applied_steps((AxisEnum)axis); + #endif #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107) FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; @@ -3108,13 +3113,21 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS]) ) ); + if (has_blocks_queued()) { //previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest. //previous_speed.reset(); buffer_sync_block(); } - else - stepper.set_position(position); + else { + #if ENABLED(BACKLASH_COMPENSATION) + abce_long_t stepper_pos = position; + LOOP_LINEAR_AXES(axis) stepper_pos[axis] += backlash.applied_steps((AxisEnum)axis); + stepper.set_position(stepper_pos); + #else + stepper.set_position(position); + #endif + } } void Planner::set_position_mm(const xyze_pos_t &xyze) { From 358ffddef80c50bdbce21407c7538041c9934f4b Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 27 Feb 2022 09:34:44 +1300 Subject: [PATCH 060/203] =?UTF-8?q?=F0=9F=90=9B=20ESP32=20=5Fdelay=5Fms,?= =?UTF-8?q?=20fix=20u8g=5Fesp32=5Fspi.cpp=20(#23810)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/ESP32/HAL.cpp | 2 ++ Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index adf5cecabe..4000dcc908 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -167,6 +167,8 @@ uint8_t MarlinHAL::get_reset_source() { return rtc_get_reset_reason(1); } void MarlinHAL::reboot() { ESP.restart(); } +void _delay_ms(int delay_ms) { delay(delay_ms); } + // return free memory between end of heap (or end bss) and whatever is current int MarlinHAL::freeMemory() { return ESP.getFreeHeap(); } diff --git a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp index e454130d43..0aa66ed2cf 100644 --- a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp +++ b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp @@ -30,6 +30,7 @@ #include #include "Arduino.h" #include "../shared/HAL_SPI.h" +#include "HAL.h" #include "SPI.h" static SPISettings spiConfig; From f7f29c6b5eb0d1b9a5cde7b4318dca506e3a5be5 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:45:33 +1300 Subject: [PATCH 061/203] =?UTF-8?q?=E2=9C=A8=20MKS=20Robin=20Nano=203.1=20?= =?UTF-8?q?(#23795)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 21 +++---- Marlin/src/pins/pins.h | 2 + .../boards/marlin_STM32F407VET6_CCM.json | 56 +++++++++++++++++++ ini/stm32f4.ini | 23 ++++++++ 4 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 4435452005..5ee99b533f 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -404,16 +404,17 @@ #define BOARD_MKS_ROBIN2 4226 // MKS_ROBIN2 (STM32F407ZE) #define BOARD_MKS_ROBIN_PRO_V2 4227 // MKS Robin Pro V2 (STM32F407VE) #define BOARD_MKS_ROBIN_NANO_V3 4228 // MKS Robin Nano V3 (STM32F407VG) -#define BOARD_MKS_MONSTER8 4229 // MKS Monster8 (STM32F407VG) -#define BOARD_ANET_ET4 4230 // ANET ET4 V1.x (STM32F407VG) -#define BOARD_ANET_ET4P 4231 // ANET ET4P V1.x (STM32F407VG) -#define BOARD_FYSETC_CHEETAH_V20 4232 // FYSETC Cheetah V2.0 -#define BOARD_TH3D_EZBOARD_V2 4233 // TH3D EZBoard v2.0 -#define BOARD_INDEX_REV03 4234 // Index PnP Controller REV03 (STM32F407VE/VG) -#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4235 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE) -#define BOARD_MKS_EAGLE 4236 // MKS Eagle (STM32F407VE) -#define BOARD_ARTILLERY_RUBY 4237 // Artillery Ruby (STM32F401RC) -#define BOARD_FYSETC_SPIDER_V2_2 4238 // FYSETC Spider V2.2 (STM32F446VE) +#define BOARD_MKS_ROBIN_NANO_V3_1 4229 // MKS Robin Nano V3.1 (STM32F407VE) +#define BOARD_MKS_MONSTER8 4230 // MKS Monster8 (STM32F407VG) +#define BOARD_ANET_ET4 4231 // ANET ET4 V1.x (STM32F407VG) +#define BOARD_ANET_ET4P 4232 // ANET ET4P V1.x (STM32F407VG) +#define BOARD_FYSETC_CHEETAH_V20 4233 // FYSETC Cheetah V2.0 +#define BOARD_TH3D_EZBOARD_V2 4234 // TH3D EZBoard v2.0 +#define BOARD_INDEX_REV03 4235 // Index PnP Controller REV03 (STM32F407VE/VG) +#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4236 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE) +#define BOARD_MKS_EAGLE 4237 // MKS Eagle (STM32F407VE) +#define BOARD_ARTILLERY_RUBY 4238 // Artillery Ruby (STM32F401RC) +#define BOARD_FYSETC_SPIDER_V2_2 4239 // FYSETC Spider V2.2 (STM32F446VE) // // ARM Cortex M7 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 0afff4bd42..88e7946edc 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -669,6 +669,8 @@ #include "stm32f4/pins_MKS_ROBIN_PRO_V2.h" // STM32F4 env:mks_robin_pro2 #elif MB(MKS_ROBIN_NANO_V3) #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3 env:mks_robin_nano_v3_usb_flash_drive env:mks_robin_nano_v3_usb_flash_drive_msc +#elif MB(MKS_ROBIN_NANO_V3_1) + #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3_1 env:mks_robin_nano_v3_1_usb_flash_drive env:mks_robin_nano_v3_1_usb_flash_drive_msc #elif MB(ANET_ET4) #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_OpenBLT #elif MB(ANET_ET4P) diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json b/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json new file mode 100644 index 0000000000..faf32c200e --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json @@ -0,0 +1,56 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F407xx -DSTM32F4", + "f_cpu": "168000000L", + "hwids": [ + [ + "0x1EAF", + "0x0003" + ], + [ + "0x0483", + "0x3748" + ] + ], + "mcu": "stm32f407vet6", + "product_line": "STM32F407xx", + "variant": "Generic_F4x7Vx" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32F407VE", + "openocd_extra_args": [ + "-c", + "reset_config none" + ], + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "stm32cube", + "libopencm3" + ], + "name": "STM32F407VE (128k RAM, 64k CCM RAM, 512k Flash", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32-high-performance-mcus/stm32f4-series/stm32f407-417/stm32f407vg.html", + "vendor": "Generic" +} diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index c7d70dd01d..9e6e213427 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -440,6 +440,29 @@ build_flags = ${env:mks_robin_nano_v3_usb_flash_drive.build_flags} -DUSBD_USE_CDC_MSC build_unflags = -DUSBD_USE_CDC +# +# MKS Robin Nano V3_1 +# +[env:mks_robin_nano_v3_1] +extends = env:mks_robin_nano_v3 +board = marlin_STM32F407VET6_CCM + +# +# MKS Robin Nano V3.1 with USB Flash Drive Support +# Currently, using a STM32duino fork, until USB Host get merged +# +[env:mks_robin_nano_v3_1_usb_flash_drive] +extends = env:mks_robin_nano_v3_usb_flash_drive +board = marlin_STM32F407VET6_CCM + +# +# MKS Robin Nano V3.1 with USB Flash Drive Support and Shared Media +# Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged +# +[env:mks_robin_nano_v3_1_usb_flash_drive_msc] +extends = env:mks_robin_nano_v3_usb_flash_drive_msc +board = marlin_STM32F407VET6_CCM + # # MKS Eagle # 5 TMC2209 uart mode on board From c2c257ace75292dcc5d815d259dc790349db0e7b Mon Sep 17 00:00:00 2001 From: sam <8531653+minteyay@users.noreply.github.com> Date: Sun, 27 Feb 2022 00:48:59 +0200 Subject: [PATCH 062/203] =?UTF-8?q?=F0=9F=93=BA=20BTT=20SKR=20Mini=20E3=20?= =?UTF-8?q?with=20Fysetc=20V2.1=20/=20MKS=20V3=20/=20BTT=20V1=20Mini=20128?= =?UTF-8?q?64=20(#23793)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stm32f1/pins_BTT_SKR_MINI_E3_common.h | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index a8ba9049ef..92d65babfa 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -235,9 +235,73 @@ #define TFTGLCD_CS PA9 #endif + + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #error "CAUTION! FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." + + /** + * FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 display pinout + * + * Board Display + * ------ ------ + * PB5 |10 9 | PA15 (BEEP) |10 9 | BTN_ENC + * PA9 | 8 7 | RESET LCD_CS | 8 7 | LCD A0 + * PA10 | 6 5 | PB9 LCD_RST | 6 5 | RED + * PB8 | 4 3 | PB15 (GREEN) | 4 3 | (BLUE) + * GND | 2 1 | 5V GND | 2 1 | 5V + * ------ ------ + * EXP1 EXP1 + * + * --- ------ + * RST | 1 | (MISO) |10 9 | SCK + * (RX2) PA2 | 2 | BTN_EN1 | 8 7 | (SS) + * (TX2) PA3 | 3 | BTN_EN2 | 6 5 | MOSI + * GND | 4 | (CD) | 4 3 | (RST) + * 5V | 5 | (GND) | 2 1 | (KILL) + * --- ------ + * TFT EXP2 + * + * Needs custom cable: + * + * Board Display + * + * EXP1-1 ----------- EXP1-1 + * EXP1-2 ----------- EXP1-2 + * EXP1-3 ----------- EXP2-6 + * EXP1-4 ----------- EXP1-5 + * EXP1-5 ----------- EXP2-8 + * EXP1-6 ----------- EXP1-6 + * EXP1-8 ----------- EXP1-8 + * EXP1-9 ----------- EXP1-9 + * EXP1-10 ----------- EXP1-7 + * + * TFT-2 ----------- EXP2-9 + * TFT-3 ----------- EXP2-5 + * + * for backlight configuration see steps 2 (V2.1) and 3 in https://wiki.fysetc.com/Mini12864_Panel/ + */ + + #define LCD_PINS_RS PA9 // CS + #define LCD_PINS_ENABLE PA3 // MOSI + #define LCD_BACKLIGHT_PIN -1 + #define NEOPIXEL_PIN PB8 + #define LCD_CONTRAST 255 + #define LCD_RESET_PIN PA10 + + #define DOGLCD_CS PA9 + #define DOGLCD_A0 PB5 + #define DOGLCD_SCK PA2 + #define DOGLCD_MOSI PA3 + + #define BTN_ENC PA15 + #define BTN_EN1 PB9 + #define BTN_EN2 PB15 + + #define FORCE_SOFT_SPI #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, TFTGLCD_PANEL_(SPI|I2C), FYSETC_MINI_12864_2_1, MKS_MINI_12864_V3, and BTT_MINI_12864_V1 are currently supported on the BIGTREE_SKR_MINI_E3." #endif #endif // HAS_WIRED_LCD From 12b038dde58a63c06b21f05c594419000c61dcdf Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:50:17 +1300 Subject: [PATCH 063/203] =?UTF-8?q?=F0=9F=94=A7=20SHOW=5FCUSTOM=5FBOOTSCRE?= =?UTF-8?q?EN=20sanity-check=20(#23807)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 9c74ce32db..7b335dc929 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -860,6 +860,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE) #error "SHOW_CUSTOM_BOOTSCREEN requires Graphical LCD or TOUCH_UI_FTDI_EVE." +#elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN) + #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN." #elif ENABLED(CUSTOM_STATUS_SCREEN_IMAGE) && !HAS_MARLINUI_U8GLIB #error "CUSTOM_STATUS_SCREEN_IMAGE requires a 128x64 DOGM B/W Graphical LCD." #endif From 0e7be8e8c4b1a7ca351ce19b462cac2d27fab82d Mon Sep 17 00:00:00 2001 From: "M. FURIC Franck" Date: Sat, 26 Feb 2022 23:54:04 +0100 Subject: [PATCH 064/203] =?UTF-8?q?=E2=9C=A8=20LCD=20Backlight=20Timer=20(?= =?UTF-8?q?#23768)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 2 +- Marlin/Configuration_adv.h | 5 ++++ Marlin/src/inc/SanityCheck.h | 8 ++++++ Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/language/language_fr.h | 1 + Marlin/src/lcd/marlinui.cpp | 24 ++++++++++++++-- Marlin/src/lcd/marlinui.h | 8 ++++++ Marlin/src/lcd/menu/menu_configuration.cpp | 4 +++ Marlin/src/module/settings.cpp | 32 ++++++++++++++++++++++ 9 files changed, 82 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6f7b1bdf4a..7162e74acb 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2820,7 +2820,7 @@ #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus - //#define TOUCH_IDLE_SLEEP 300 // (secs) Turn off the TFT backlight if set (5mn) + //#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn) #define TOUCH_SCREEN_CALIBRATION diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 910e779b2a..4a9cb77b8b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1277,6 +1277,11 @@ #define FEEDRATE_CHANGE_BEEP_FREQUENCY 440 #endif +// +// LCD Backlight Timeout +// +//#define LCD_BACKLIGHT_TIMEOUT 30 // (s) Timeout before turning off the backlight + #if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI) //#define PROBE_OFFSET_WIZARD // Add a Probe Z Offset calibration option to the LCD menu #if ENABLED(PROBE_OFFSET_WIZARD) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 7b335dc929..e847339e2a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2857,6 +2857,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif +#if LCD_BACKLIGHT_TIMEOUT + #if !HAS_ENCODER_ACTION + #error "LCD_BACKLIGHT_TIMEOUT requires an LCD with encoder or keypad." + #elif !PIN_EXISTS(LCD_BACKLIGHT) + #error "LCD_BACKLIGHT_TIMEOUT requires LCD_BACKLIGHT_PIN." + #endif +#endif + /** * Some boards forbid the use of -1 Native USB */ diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index d8d161701f..9925f225e3 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -402,6 +402,7 @@ namespace Language_en { LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness"); + LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD Sleep (s)"); LSTR MSG_STORE_EEPROM = _UxGT("Store Settings"); LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 2eb64fc2c2..02f9d2f549 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -335,6 +335,7 @@ namespace Language_fr { LSTR MSG_ADVANCE_K_E = _UxGT("Avance K *"); LSTR MSG_BRIGHTNESS = _UxGT("Luminosité LCD"); LSTR MSG_CONTRAST = _UxGT("Contraste LCD"); + LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("Veille LCD (s)"); LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config."); LSTR MSG_LOAD_EEPROM = _UxGT("Charger config."); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restaurer défauts"); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index d0cc2a25b8..d2884cc3f1 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -180,6 +180,15 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update #endif +#if LCD_BACKLIGHT_TIMEOUT + uint16_t MarlinUI::lcd_backlight_timeout; // Initialized by settings.load() + millis_t MarlinUI::backlight_off_ms = 0; + void MarlinUI::refresh_backlight_timeout() { + backlight_off_ms = lcd_backlight_timeout ? millis() + lcd_backlight_timeout * 1000UL : 0; + WRITE(LCD_BACKLIGHT_PIN, HIGH); + } +#endif + void MarlinUI::init() { init_lcd(); @@ -1033,14 +1042,18 @@ void MarlinUI::init() { reset_status_timeout(ms); + #if LCD_BACKLIGHT_TIMEOUT + refresh_backlight_timeout(); + #endif + refresh(LCDVIEW_REDRAW_NOW); #if LED_POWEROFF_TIMEOUT > 0 if (!powerManager.psu_on) leds.reset_timeout(ms); #endif - } + } // encoder activity - #endif + #endif // HAS_ENCODER_ACTION // This runs every ~100ms when idling often enough. // Instead of tracking changes just redraw the Status Screen once per second. @@ -1137,6 +1150,13 @@ void MarlinUI::init() { return_to_status(); #endif + #if LCD_BACKLIGHT_TIMEOUT + if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) { + WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off + backlight_off_ms = 0; + } + #endif + // Change state of drawing flag between screen updates if (!drawing_screen) switch (lcdDrawUpdate) { case LCDVIEW_CLEAR_CALL_REDRAW: diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 17c2468737..15e9f73d65 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -275,6 +275,14 @@ public: FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); } #endif + #if LCD_BACKLIGHT_TIMEOUT + #define LCD_BKL_TIMEOUT_MIN 1 + #define LCD_BKL_TIMEOUT_MAX (60*60*18) // 18 hours max within uint16_t + static uint16_t lcd_backlight_timeout; + static millis_t backlight_off_ms; + static void refresh_backlight_timeout(); + #endif + #if HAS_DWIN_E3V2_BASIC static void refresh(); #else diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 33e43b08eb..b4e9287bd4 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -541,6 +541,10 @@ void menu_configuration() { #if HAS_LCD_CONTRAST && LCD_CONTRAST_MIN < LCD_CONTRAST_MAX EDIT_ITEM_FAST(uint8, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true); #endif + #if LCD_BACKLIGHT_TIMEOUT && LCD_BKL_TIMEOUT_MIN < LCD_BKL_TIMEOUT_MAX + EDIT_ITEM(uint16_4, MSG_LCD_BKL_TIMEOUT, &ui.lcd_backlight_timeout, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX, ui.refresh_backlight_timeout); + #endif + #if ENABLED(FWRETRACT) SUBMENU(MSG_RETRACT, menu_config_retract); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index bcbe8fa985..66316edbbb 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -391,6 +391,13 @@ typedef struct SettingsDataStruct { // uint8_t lcd_brightness; // M256 B + // + // LCD_BACKLIGHT_TIMEOUT + // + #if LCD_BACKLIGHT_TIMEOUT + uint16_t lcd_backlight_timeout; // (G-code needed) + #endif + // // Controller fan settings // @@ -607,6 +614,10 @@ void MarlinSettings::postprocess() { // Moved as last update due to interference with Neopixel init TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast()); TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness()); + + #if LCD_BACKLIGHT_TIMEOUT + ui.refresh_backlight_timeout(); + #endif } #if BOTH(PRINTCOUNTER, EEPROM_SETTINGS) @@ -1108,6 +1119,13 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(lcd_brightness); } + // + // LCD Backlight Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + EEPROM_WRITE(ui.lcd_backlight_timeout); + #endif + // // Controller Fan // @@ -2015,6 +2033,13 @@ void MarlinSettings::postprocess() { TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.brightness = lcd_brightness); } + // + // LCD Backlight Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + EEPROM_READ(ui.lcd_backlight_timeout); + #endif + // // Controller Fan // @@ -3040,6 +3065,13 @@ void MarlinSettings::reset() { // TERN_(HAS_LCD_BRIGHTNESS, ui.brightness = LCD_BRIGHTNESS_DEFAULT); + // + // LCD Backlight Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + ui.lcd_backlight_timeout = LCD_BACKLIGHT_TIMEOUT; + #endif + // // Controller Fan // From 4b0e84d9f320d3e15f8f5c70542349e7f793299e Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 27 Feb 2022 00:25:43 +0000 Subject: [PATCH 065/203] [cron] Bump distribution date (2022-02-27) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 40cef79e87..5884952505 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-25" +//#define STRING_DISTRIBUTION_DATE "2022-02-27" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 62cd2b23a2..68ddf4a18c 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-25" + #define STRING_DISTRIBUTION_DATE "2022-02-27" #endif /** From 9ea6a588c36760b3d53d06748cfc58b4204580e7 Mon Sep 17 00:00:00 2001 From: kisslorand <50251547+kisslorand@users.noreply.github.com> Date: Mon, 28 Feb 2022 04:38:11 +0200 Subject: [PATCH 066/203] =?UTF-8?q?=E2=9C=A8=20M21=20P=20/=20S=20/=20U=20-?= =?UTF-8?q?=20Select=20Volume=20(#23780)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 5 ++++- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/gcode/host/M115.cpp | 5 +++++ Marlin/src/gcode/sd/M21_M22.cpp | 15 ++++++++++++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 4a9cb77b8b..e5379ed84f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1631,7 +1631,10 @@ // Enable if SD detect is rendered useless (e.g., by using an SD extender) //#define NO_SD_DETECT - // Multiple volume support - EXPERIMENTAL. + /** + * Multiple volume support - EXPERIMENTAL. + * Adds 'M21 Pm' / 'M21 S' / 'M21 U' to mount SD Card / USB Drive. + */ //#define MULTI_VOLUME #if ENABLED(MULTI_VOLUME) #define VOLUME_SD_ONBOARD diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 78dd0bc680..a150aca41d 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -91,7 +91,7 @@ * *** Print from Media (SDSUPPORT) *** * M20 - List SD card. (Requires SDSUPPORT) - * M21 - Init SD card. (Requires SDSUPPORT) + * M21 - Init SD card. (Requires SDSUPPORT) With MULTI_VOLUME select a drive with `M21 Pn` / 'M21 S' / 'M21 U'. * M22 - Release SD card. (Requires SDSUPPORT) * M23 - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT) * M24 - Start/resume SD print. (Requires SDSUPPORT) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 45e0061a5b..36731c23da 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -142,6 +142,11 @@ void GcodeSuite::M115() { // SDCARD (M20, M23, M24, etc.) cap_line(F("SDCARD"), ENABLED(SDSUPPORT)); + // MULTI_VOLUME (M21 S/M21 U) + #if ENABLED(SDSUPPORT) + cap_line(F("MULTI_VOLUME"), ENABLED(MULTI_VOLUME)); + #endif + // REPEAT (M808) cap_line(F("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS)); diff --git a/Marlin/src/gcode/sd/M21_M22.cpp b/Marlin/src/gcode/sd/M21_M22.cpp index c7f41f9c81..aec0de27ca 100644 --- a/Marlin/src/gcode/sd/M21_M22.cpp +++ b/Marlin/src/gcode/sd/M21_M22.cpp @@ -29,8 +29,21 @@ /** * M21: Init SD Card + * + * With MULTI_VOLUME: + * P0 or S - Change to the SD Card and mount it + * P1 or U - Change to the USB Drive and mount it */ -void GcodeSuite::M21() { card.mount(); } +void GcodeSuite::M21() { + #if ENABLED(MULTI_VOLUME) + const int8_t vol = parser.intval('P', -1); + if (vol == 0 || parser.seen_test('S')) // "S" for SD Card + card.changeMedia(&card.media_driver_sdcard); + else if (vol == 1 || parser.seen_test('U')) // "U" for USB + card.changeMedia(&card.media_driver_usbFlash); + #endif + card.mount(); +} /** * M22: Release SD Card From 1aa988c63c5803e6a54ad8c3e59a7bd610a51997 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 28 Feb 2022 06:07:09 +0000 Subject: [PATCH 067/203] [cron] Bump distribution date (2022-02-28) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 5884952505..d481674947 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-27" +//#define STRING_DISTRIBUTION_DATE "2022-02-28" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 68ddf4a18c..46ce0820c7 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-27" + #define STRING_DISTRIBUTION_DATE "2022-02-28" #endif /** From d09a2ee80a057de7e56b13c041f6a7beb8023515 Mon Sep 17 00:00:00 2001 From: Ludy Date: Tue, 1 Mar 2022 23:09:11 +0100 Subject: [PATCH 068/203] =?UTF-8?q?=F0=9F=8C=90=20Update=20German=20langua?= =?UTF-8?q?ge=20(#23832)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_de.h | 150 ++++++++++++++++++++- Marlin/src/lcd/language/language_jp_kana.h | 1 - 2 files changed, 143 insertions(+), 8 deletions(-) diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 6a5f504e91..bf408d436f 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -56,19 +56,42 @@ namespace Language_de { LSTR MSG_DISABLE_STEPPERS = _UxGT("Motoren deaktivieren"); // M84 :: Max length 19 characters LSTR MSG_DEBUG_MENU = _UxGT("Debug-Menü"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Statusbalken-Test"); + LSTR MSG_HOMING = _UxGT("Homing"); LSTR MSG_AUTO_HOME = _UxGT("Auto Home"); + LSTR MSG_AUTO_HOME_A = _UxGT("Home @"); LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); + LSTR MSG_FILAMENT_SET = _UxGT("Fila. Einstellungen"); + LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); + 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_AUTO_MESH = _UxGT("Netz auto. erstellen"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Z-Achsen ausgleichen"); + LSTR MSG_ITERATION = _UxGT("G34 Iteration: %i"); + LSTR MSG_DECREASING_ACCURACY = _UxGT("Genauigkeit sinkt!"); + LSTR MSG_ACCURACY_ACHIEVED = _UxGT("Genauigkeit erreicht"); LSTR MSG_LEVEL_BED_HOMING = _UxGT("XYZ homen"); LSTR MSG_LEVEL_BED_WAITING = _UxGT("Klick zum Starten"); LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Nächste Koordinate"); LSTR MSG_LEVEL_BED_DONE = _UxGT("Nivellieren fertig!"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Ausblendhöhe"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Setze Homeversatz"); + LSTR MSG_HOME_OFFSET_X = _UxGT("Homeversatz X"); + LSTR MSG_HOME_OFFSET_Y = _UxGT("Homeversatz Y"); + LSTR MSG_HOME_OFFSET_Z = _UxGT("Homeversatz Z"); + LSTR MSG_HOME_OFFSET_I = _UxGT("Homeversatz ") STR_I; + LSTR MSG_HOME_OFFSET_J = _UxGT("Homeversatz ") STR_J; + LSTR MSG_HOME_OFFSET_K = _UxGT("Homeversatz ") STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Homeversatz aktiv"); LSTR MSG_SET_ORIGIN = _UxGT("Setze Nullpunkte"); //"G92 X0 Y0 Z0" commented out in marlinui.cpp + LSTR MSG_TRAMMING_WIZARD = _UxGT("Tramming Assistent"); + LSTR MSG_SELECT_ORIGIN = _UxGT("Wählen Sie Ursprung"); + LSTR MSG_LAST_VALUE_SP = _UxGT("Letzter Wert "); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" Vorwärmen"); LSTR MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" Vorwärmen ~"); @@ -88,11 +111,21 @@ namespace Language_de { #endif LSTR MSG_PREHEAT_CUSTOM = _UxGT("benutzerdef. Heizen"); LSTR MSG_COOLDOWN = _UxGT("Abkühlen"); + LSTR MSG_CUTTER_FREQUENCY = _UxGT("Frequenz"); LSTR MSG_LASER_MENU = _UxGT("Laser"); - LSTR MSG_LASER_POWER = _UxGT("Laserleistung"); LSTR MSG_SPINDLE_MENU = _UxGT("Spindel-Steuerung"); + LSTR MSG_LASER_POWER = _UxGT("Laserleistung"); LSTR MSG_SPINDLE_POWER = _UxGT("Spindelleistung"); + LSTR MSG_LASER_TOGGLE = _UxGT("Laser umschalten"); + LSTR MSG_LASER_EVAC_TOGGLE = _UxGT("Gebläse umschalten"); + LSTR MSG_LASER_ASSIST_TOGGLE = _UxGT("Luftunterstützung"); + LSTR MSG_LASER_PULSE_MS = _UxGT("Test Impuls ms"); + LSTR MSG_LASER_FIRE_PULSE = _UxGT("Fire Impuls"); + LSTR MSG_FLOWMETER_FAULT = _UxGT("Feh. Kühlmittelfluss"); + LSTR MSG_SPINDLE_TOGGLE = _UxGT("Spindel umschalten"); + LSTR MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Vakuum umschalten"); + LSTR MSG_SPINDLE_FORWARD = _UxGT("Spindel vorwärts"); LSTR MSG_SPINDLE_REVERSE = _UxGT("Spindelrichtung"); LSTR MSG_SWITCH_PS_ON = _UxGT("Netzteil ein"); LSTR MSG_SWITCH_PS_OFF = _UxGT("Netzteil aus"); @@ -102,10 +135,17 @@ namespace Language_de { LSTR MSG_BED_LEVELING = _UxGT("Bett-Nivellierung"); LSTR MSG_LEVEL_BED = _UxGT("Bett nivellieren"); LSTR MSG_BED_TRAMMING = _UxGT("Bett ausrichten"); + LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Das Bett anpassen, bis zum auslösen."); + LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Ecken in der Toleranz. Bett ausger."); + LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Gute Punkte: "); + LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Letztes Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Nächste Ecke"); LSTR MSG_MESH_EDITOR = _UxGT("Netz Editor"); + LSTR MSG_MESH_VIEWER = _UxGT("Netzbetrachter"); LSTR MSG_EDIT_MESH = _UxGT("Netz bearbeiten"); + LSTR MSG_MESH_VIEW = _UxGT("Netz ansehen"); LSTR MSG_EDITING_STOPPED = _UxGT("Netzbearb. angeh."); + LSTR MSG_NO_VALID_MESH = _UxGT("Kein gültiges Netz"); LSTR MSG_PROBING_POINT = _UxGT("Messpunkt"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); @@ -121,6 +161,7 @@ namespace Language_de { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplizieren"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Spiegelkopie"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("vollstä. Kontrolle"); + LSTR MSG_IDEX_DUPE_GAP = _UxGT("X-Lücke duplizieren"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. Düse Z"); LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. Düse @"); LSTR MSG_UBL_DOING_G29 = _UxGT("G29 ausführen"); @@ -128,6 +169,7 @@ namespace Language_de { LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Berührungspunkt"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Netz manuell erst."); + LSTR MSG_UBL_MESH_WIZARD = _UxGT("UBL Netz Assistent"); LSTR MSG_UBL_BC_INSERT = _UxGT("Unterlegen & messen"); LSTR MSG_UBL_BC_INSERT2 = _UxGT("Messen"); LSTR MSG_UBL_BC_REMOVE = _UxGT("Entfernen & messen"); @@ -212,6 +254,10 @@ namespace Language_de { LSTR MSG_SET_LEDS_VIOLET = _UxGT("Violett"); LSTR MSG_SET_LEDS_WHITE = _UxGT("Weiß"); LSTR MSG_SET_LEDS_DEFAULT = _UxGT("Standard"); + LSTR MSG_LED_CHANNEL_N = _UxGT("Kanal ="); + LSTR MSG_LEDS2 = _UxGT("Lichter #2"); + LSTR MSG_NEO2_PRESETS = _UxGT("Licht #2 Voreinst."); + LSTR MSG_NEO2_BRIGHTNESS = _UxGT("Helligkeit"); LSTR MSG_CUSTOM_LEDS = _UxGT("Benutzerdefiniert"); LSTR MSG_INTENSITY_R = _UxGT("Intensität Rot"); LSTR MSG_INTENSITY_G = _UxGT("Intensität Grün"); @@ -224,6 +270,9 @@ namespace Language_de { LSTR MSG_MOVE_X = _UxGT("Bewege X"); LSTR MSG_MOVE_Y = _UxGT("Bewege Y"); LSTR MSG_MOVE_Z = _UxGT("Bewege Z"); + LSTR MSG_MOVE_I = _UxGT("Bewege ") STR_I; + LSTR MSG_MOVE_J = _UxGT("Bewege ") STR_J; + LSTR MSG_MOVE_K = _UxGT("Bewege ") STR_K; LSTR MSG_MOVE_E = _UxGT("Bewege Extruder"); LSTR MSG_MOVE_EN = _UxGT("Bewege Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend zu kalt"); @@ -232,7 +281,17 @@ namespace Language_de { LSTR MSG_MOVE_1MM = _UxGT(" 1,0 mm"); LSTR MSG_MOVE_10MM = _UxGT(" 10,0 mm"); LSTR MSG_MOVE_100MM = _UxGT("100,0 mm"); + LSTR MSG_MOVE_0001IN = _UxGT("0.001 in"); + LSTR MSG_MOVE_001IN = _UxGT("0.010 in"); + LSTR MSG_MOVE_01IN = _UxGT("0.100 in"); + LSTR MSG_MOVE_1IN = _UxGT("1.000 in"); LSTR MSG_SPEED = _UxGT("Geschw."); + LSTR MSG_MAXSPEED = _UxGT("Max Geschw. (mm/s)"); + LSTR MSG_MAXSPEED_X = _UxGT("Max ") STR_A _UxGT(" Geschw."); + LSTR MSG_MAXSPEED_Y = _UxGT("Max ") STR_B _UxGT(" Geschw."); + LSTR MSG_MAXSPEED_Z = _UxGT("Max ") STR_C _UxGT(" Geschw."); + LSTR MSG_MAXSPEED_E = _UxGT("Max ") STR_E _UxGT(" Geschw."); + LSTR MSG_MAXSPEED_A = _UxGT("Max @ Geschw."); LSTR MSG_BED_Z = _UxGT("Bett Z"); LSTR MSG_NOZZLE = _UxGT("Düse"); LSTR MSG_NOZZLE_N = _UxGT("Düse ~"); @@ -240,6 +299,10 @@ namespace Language_de { LSTR MSG_NOZZLE_STANDBY = _UxGT("Düse bereit"); LSTR MSG_BED = _UxGT("Bett"); LSTR MSG_CHAMBER = _UxGT("Gehäuse"); + LSTR MSG_COOLER = _UxGT("Laser-Kühlmittel"); + LSTR MSG_COOLER_TOGGLE = _UxGT("Kühler umschalten"); + LSTR MSG_FLOWMETER_SAFETY = _UxGT("Durchflusssicherheit"); + LSTR MSG_LASER = _UxGT("Laser"); LSTR MSG_FAN_SPEED = _UxGT("Lüfter"); LSTR MSG_FAN_SPEED_N = _UxGT("Lüfter ~"); LSTR MSG_STORED_FAN_N = _UxGT("Gespeich. Lüfter ~"); @@ -261,6 +324,7 @@ namespace Language_de { LSTR MSG_LCD_OFF = _UxGT("aus"); LSTR MSG_PID_AUTOTUNE = _UxGT("PID Autotune"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autotune *"); + LSTR MSG_PID_CYCLE = _UxGT("PID Zyklus"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID Tuning fertig"); LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge. Falscher Extruder"); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune fehlge. Temperatur zu hoch."); @@ -289,7 +353,6 @@ namespace Language_de { LSTR MSG_VMIN = _UxGT("V min "); LSTR MSG_VTRAV_MIN = _UxGT("V min Leerfahrt"); LSTR MSG_ACCELERATION = _UxGT("Beschleunigung"); - LSTR MSG_AMAX = _UxGT("A max "); // space intentional LSTR MSG_AMAX_A = _UxGT("A max ") STR_A; LSTR MSG_AMAX_B = _UxGT("A max ") STR_B; LSTR MSG_AMAX_C = _UxGT("A max ") STR_C; @@ -324,6 +387,8 @@ namespace Language_de { LSTR MSG_ADVANCE_K = _UxGT("Vorschubfaktor"); LSTR MSG_ADVANCE_K_E = _UxGT("Vorschubfaktor *"); LSTR MSG_CONTRAST = _UxGT("LCD-Kontrast"); + LSTR MSG_BRIGHTNESS = _UxGT("LCD Helligkeit"); + LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD-Ruhezustand (s)"); LSTR MSG_STORE_EEPROM = _UxGT("Konfig. speichern"); LSTR MSG_LOAD_EEPROM = _UxGT("Konfig. laden"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Standardwerte laden"); @@ -353,20 +418,32 @@ namespace Language_de { LSTR MSG_BUTTON_DONE = _UxGT("Fertig"); LSTR MSG_BUTTON_BACK = _UxGT("Zurück"); LSTR MSG_BUTTON_PROCEED = _UxGT("Weiter"); + LSTR MSG_BUTTON_SKIP = _UxGT("Überspringen"); + LSTR MSG_BUTTON_INFO = _UxGT("Info"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Level"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Pause"); + LSTR MSG_BUTTON_RESUME = _UxGT("Fortsetzen"); + LSTR MSG_BUTTON_ADVANCED = _UxGT("Erweitert"); LSTR MSG_PAUSING = _UxGT("Pause..."); LSTR MSG_PAUSE_PRINT = _UxGT("SD-Druck pausieren"); + LSTR MSG_ADVANCED_PAUSE = _UxGT("Erweiterte Pause"); LSTR MSG_RESUME_PRINT = _UxGT("SD-Druck fortsetzen"); + LSTR MSG_HOST_START_PRINT = _UxGT("Host-Druck starten"); LSTR MSG_STOP_PRINT = _UxGT("SD-Druck abbrechen"); + LSTR MSG_END_LOOPS = _UxGT("Wiederholung beenden"); LSTR MSG_PRINTING_OBJECT = _UxGT("Objekt drucken"); LSTR MSG_CANCEL_OBJECT = _UxGT("Objekt abbrechen"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Objekt abbrechen ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Wiederh. n. Stroma."); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Druckauftrag fortset."); LSTR MSG_MEDIA_MENU = _UxGT("Druck vom Medium"); LSTR MSG_NO_MEDIA = _UxGT("Kein Medium"); LSTR MSG_DWELL = _UxGT("Warten..."); LSTR MSG_USERWAIT = _UxGT("Klick zum Fortsetzen"); LSTR MSG_PRINT_PAUSED = _UxGT("Druck pausiert..."); LSTR MSG_PRINTING = _UxGT("Druckt..."); + LSTR MSG_STOPPING = _UxGT("Stoppen..."); + LSTR MSG_REMAINING_TIME = _UxGT("Verbleiben"); LSTR MSG_PRINT_ABORTED = _UxGT("Druck abgebrochen"); LSTR MSG_PRINT_DONE = _UxGT("Druck fertig"); LSTR MSG_NO_MOVE = _UxGT("Motoren angeschaltet"); @@ -416,6 +493,7 @@ namespace Language_de { LSTR MSG_BLTOUCH_STOW = _UxGT("Einfahren"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Ausfahren"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Modus"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("High Speed"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Modus"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Modus"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); @@ -431,33 +509,43 @@ namespace Language_de { LSTR MSG_MANUAL_DEPLOY = _UxGT("Z-Sonde ausfahren"); LSTR MSG_MANUAL_STOW = _UxGT("Z-Sonde einfahren"); LSTR MSG_HOME_FIRST = _UxGT("Vorher %s%s%s homen"); + LSTR MSG_ZPROBE_SETTINGS = _UxGT("Sondeneinstellungen"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Sondenversatz"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Sondenversatz X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Sondenversatz Y"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Sondenversatz Z"); + LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Bewege Düse zum Bett"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); + LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") STR_I; + LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") STR_J; + LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") STR_K; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Abbr. mit Endstopp"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("HEIZEN ERFOLGLOS"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("REDUND. TEMP-ABWEI."); LSTR MSG_THERMAL_RUNAWAY = " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("TEMP-FEHLER"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("BETT") " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("GEH.") " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); + LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Kühler Runaway"); + LSTR MSG_COOLING_FAILED = _UxGT("Kühlung fehlgeschla."); LSTR MSG_ERR_MAXTEMP = " " LCD_STR_THERMOMETER _UxGT(" ÜBERSCHRITTEN"); LSTR MSG_ERR_MINTEMP = " " LCD_STR_THERMOMETER _UxGT(" UNTERSCHRITTEN"); LSTR MSG_HALTED = _UxGT("DRUCKER GESTOPPT"); + LSTR MSG_PLEASE_WAIT = _UxGT("Bitte warten..."); LSTR MSG_PLEASE_RESET = _UxGT("Bitte neustarten"); - LSTR MSG_SHORT_DAY = _UxGT("t"); // One character only - LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character only + LSTR MSG_PREHEATING = _UxGT("vorheizen..."); LSTR MSG_HEATING = _UxGT("heizt..."); LSTR MSG_COOLING = _UxGT("kühlt..."); LSTR MSG_BED_HEATING = _UxGT("Bett heizt..."); LSTR MSG_BED_COOLING = _UxGT("Bett kühlt..."); + LSTR MSG_PROBE_HEATING = _UxGT("Sonde heizt..."); + LSTR MSG_PROBE_COOLING = _UxGT("Sonde kühlt..."); LSTR MSG_CHAMBER_HEATING = _UxGT("Gehäuse heizt..."); LSTR MSG_CHAMBER_COOLING = _UxGT("Gehäuse kühlt..."); + LSTR MSG_LASER_COOLING = _UxGT("Laser kühlt..."); LSTR MSG_DELTA_CALIBRATE = _UxGT("Delta kalibrieren"); LSTR MSG_DELTA_CALIBRATE_X = _UxGT("Kalibriere X"); LSTR MSG_DELTA_CALIBRATE_Y = _UxGT("Kalibriere Y"); @@ -475,8 +563,9 @@ namespace Language_de { LSTR MSG_3POINT_LEVELING = _UxGT("3-Punkt-Nivellierung"); LSTR MSG_LINEAR_LEVELING = _UxGT("Lineare Nivellierung"); LSTR MSG_BILINEAR_LEVELING = _UxGT("Bilineare Nivell."); - LSTR MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling"); + LSTR MSG_UBL_LEVELING = _UxGT("Einheit. Bettnivell."); LSTR MSG_MESH_LEVELING = _UxGT("Netz-Nivellierung"); + LSTR MSG_MESH_DONE = _UxGT("Nivellierung fertig"); LSTR MSG_INFO_STATS_MENU = _UxGT("Drucker-Statistik"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Board-Info"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistoren"); @@ -486,23 +575,39 @@ namespace Language_de { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: AUS"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: AN"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); + LSTR MSG_FAN_SPEED_FAULT = _UxGT("Fehler Lüftergeschw."); + LSTR MSG_CASE_LIGHT = _UxGT("Beleuchtung"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Helligkeit"); - LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Falscher Drucker"); #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Kein Medium eingelegt."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Bitte auf Neustart warten. "); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte das Hot-End vorheizen."); + LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Druckzähler zurücksetzen"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Gesamte Drucke"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Komplette Drucke"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Gesamte Druckzeit"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Längste Druckzeit"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Gesamt Extrudiert"); + LSTR MSG_COLORS_GET = _UxGT("Farbe"); + LSTR MSG_COLORS_SELECT = _UxGT("Farben auswählen"); + LSTR MSG_COLORS_APPLIED = _UxGT("Farben verwenden"); + LSTR MSG_COLORS_RED = _UxGT("Rot"); + LSTR MSG_COLORS_GREEN = _UxGT("Grün"); + LSTR MSG_COLORS_BLUE = _UxGT("Blau"); + LSTR MSG_COLORS_WHITE = _UxGT("Weiß"); + LSTR MSG_UI_LANGUAGE = _UxGT("UI Sprache"); + LSTR MSG_SOUND_ENABLE = _UxGT("Ton aktivieren"); + LSTR MSG_LOCKSCREEN = _UxGT("Bildschirm sperren"); #else LSTR MSG_INFO_PRINT_COUNT = _UxGT("Drucke"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Komplette"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Gesamte"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Längste"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extrud."); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte vorheizen"); #endif LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); @@ -528,6 +633,8 @@ namespace Language_de { LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Düse: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout-Sensor"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Runout-Weg mm"); + LSTR MSG_RUNOUT_ENABLE = _UxGT("Runout aktivieren"); + LSTR MSG_FANCHECK = _UxGT("Lüftergeschw. prüfen"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing gescheitert"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Probing gescheitert"); @@ -639,4 +746,33 @@ namespace Language_de { #endif LSTR MSG_REHEAT = _UxGT("Erneut aufheizen"); LSTR MSG_REHEATING = _UxGT("Erneut aufhei. ..."); + LSTR MSG_REHEATDONE = _UxGT("Aufwärmen fertig"); + + LSTR MSG_PROBE_WIZARD = _UxGT("Sonden-Assistent"); + LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Sonden-Bezug"); + LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Bewege zur Position"); + + LSTR MSG_XATC = _UxGT("X-Verdreh-Assistent"); + LSTR MSG_XATC_DONE = _UxGT("X-Verdreh-Assi fertig!"); + LSTR MSG_XATC_UPDATE_Z_OFFSET = _UxGT("Z-Versatz Sonde akt. auf "); + + LSTR MSG_SOUND = _UxGT("Ton"); + + LSTR MSG_TOP_LEFT = _UxGT("Oben Links"); + LSTR MSG_BOTTOM_LEFT = _UxGT("Unten Links"); + LSTR MSG_TOP_RIGHT = _UxGT("Oben Rechts"); + LSTR MSG_BOTTOM_RIGHT = _UxGT("Unten Rechts"); + LSTR MSG_CALIBRATION_COMPLETED = _UxGT("Kalibrierung beendet"); + LSTR MSG_CALIBRATION_FAILED = _UxGT("Kalibrierung geschei."); + + LSTR MSG_DRIVER_BACKWARD = _UxGT(" Driver zurück"); + + LSTR MSG_SD_CARD = _UxGT("SD Karte"); + LSTR MSG_USB_DISK = _UxGT("USB Disk"); + + LSTR MSG_HOST_SHUTDOWN = _UxGT("Host abschalten"); + + LSTR MSG_SHORT_DAY = _UxGT("t"); // One character only + LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character only + LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character only } diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index 3a876a07e3..164dca8fcf 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -137,7 +137,6 @@ namespace Language_jp_kana { LSTR MSG_VMIN = _UxGT("サイショウオクリソクド"); // "Vmin" LSTR MSG_VTRAV_MIN = _UxGT("サイショウイドウソクド"); // "VTrav min" LSTR MSG_ACCELERATION = _UxGT("カソクド mm/s") SUPERSCRIPT_TWO; // "Accel" - LSTR MSG_AMAX = _UxGT("サイダイカソクド "); // "Amax " LSTR MSG_A_RETRACT = _UxGT("ヒキコミカソクド"); // "A-retract" LSTR MSG_A_TRAVEL = _UxGT("イドウカソクド"); // "A-travel" LSTR MSG_TEMPERATURE = _UxGT("オンド"); // "Temperature" From 15de14dd89d9d6037e6e7e2286b051f4827f026d Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Wed, 2 Mar 2022 11:11:26 +1300 Subject: [PATCH 069/203] =?UTF-8?q?=F0=9F=94=A8=20Fix=20'renamed'=20env=20?= =?UTF-8?q?(platform=20=3D=20ststm32)=20(#23831)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/renamed.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ini/renamed.ini b/ini/renamed.ini index abc8ee5c28..b325476d2f 100644 --- a/ini/renamed.ini +++ b/ini/renamed.ini @@ -14,7 +14,8 @@ # [renamed] -platform = native +platform = ststm32 +board = genericSTM32F103RE # # List of environment names that are no longer used From 6b7868d943cd08b83af085ea0d507cc8433799c6 Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Tue, 1 Mar 2022 22:14:52 +0000 Subject: [PATCH 070/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20backlash=20applied?= =?UTF-8?q?=20steps=20when=20config=20changes=20(#23826)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23814 --- Marlin/src/feature/backlash.cpp | 76 ++++++++++++++++----------- Marlin/src/feature/backlash.h | 46 ++++++++++------ Marlin/src/gcode/calibrate/G425.cpp | 60 +++++++++++++-------- Marlin/src/gcode/calibrate/M425.cpp | 24 ++++----- Marlin/src/lcd/extui/ui_api.cpp | 12 ++--- Marlin/src/lcd/menu/menu_backlash.cpp | 13 +++-- Marlin/src/module/planner.cpp | 16 +++--- Marlin/src/module/settings.cpp | 37 ++++++------- 8 files changed, 167 insertions(+), 117 deletions(-) diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index 23458cf86c..84382cf856 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -30,9 +30,7 @@ #include "../module/planner.h" axis_bits_t Backlash::last_direction_bits; -#ifdef BACKLASH_SMOOTHING_MM - xyz_long_t Backlash::residual_error{0}; -#endif +xyz_long_t Backlash::residual_error{0}; #ifdef BACKLASH_DISTANCE_MM #if ENABLED(BACKLASH_GCODE) @@ -43,7 +41,7 @@ axis_bits_t Backlash::last_direction_bits; #endif #if ENABLED(BACKLASH_GCODE) - uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF; + uint8_t Backlash::correction = (BACKLASH_CORRECTION) * all_on; #ifdef BACKLASH_SMOOTHING_MM float Backlash::smoothing_mm = BACKLASH_SMOOTHING_MM; #endif @@ -87,7 +85,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const #endif last_direction_bits ^= changed_dir; - if (correction == 0) return; + if (!correction && !residual_error) return; #ifdef BACKLASH_SMOOTHING_MM // The segment proportion is a value greater than 0.0 indicating how much residual_error @@ -95,35 +93,28 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const // smoothing distance. Since the computation of this proportion involves a floating point // division, defer computation until needed. float segment_proportion = 0; - #else - // No direction change, no correction. - if (!changed_dir) return; - // No leftover residual error from segment to segment - xyz_long_t residual_error{0}; #endif - const float f_corr = float(correction) / 255.0f; + const float f_corr = float(correction) / all_on; LOOP_LINEAR_AXES(axis) { if (distance_mm[axis]) { - const bool reversing = TEST(dm,axis); + const bool reverse = TEST(dm, axis); // When an axis changes direction, add axis backlash to the residual error if (TEST(changed_dir, axis)) - residual_error[axis] += (reversing ? -f_corr : f_corr) * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; + residual_error[axis] += (reverse ? -f_corr : f_corr) * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; // Decide how much of the residual error to correct in this segment int32_t error_correction = residual_error[axis]; + if (reverse != (error_correction < 0)) + error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps + #ifdef BACKLASH_SMOOTHING_MM if (error_correction && smoothing_mm != 0) { - // Take up a portion of the residual_error in this segment, but only when - // the current segment travels in the same direction as the correction - if (reversing == (error_correction < 0)) { - if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm); - error_correction = CEIL(segment_proportion * error_correction); - } - else - error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps + // Take up a portion of the residual_error in this segment + if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm); + error_correction = CEIL(segment_proportion * error_correction); } #endif @@ -153,27 +144,52 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const } } -int32_t Backlash::applied_steps(const AxisEnum axis) { +int32_t Backlash::get_applied_steps(const AxisEnum axis) { if (axis >= LINEAR_AXES) return 0; - const bool reversing = TEST(last_direction_bits, axis); + const bool reverse = TEST(last_direction_bits, axis); - #ifdef BACKLASH_SMOOTHING_MM - const int32_t residual_error_axis = residual_error[axis]; - #else - constexpr int32_t residual_error_axis = 0; - #endif + const int32_t residual_error_axis = residual_error[axis]; // At startup it is assumed the last move was forwards. So the applied // steps will always be a non-positive number. - if (!reversing) return -residual_error_axis; + if (!reverse) return -residual_error_axis; - const float f_corr = float(correction) / 255.0f; + const float f_corr = float(correction) / all_on; const int32_t full_error_axis = -f_corr * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; return full_error_axis - residual_error_axis; } +class Backlash::StepAdjuster { + xyz_long_t applied_steps; +public: + StepAdjuster() { + LOOP_LINEAR_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis); + } + ~StepAdjuster() { + // after backlash compensation parameter changes, ensure applied step count does not change + LOOP_LINEAR_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis]; + } +}; + +void Backlash::set_correction_uint8(const uint8_t v) { + StepAdjuster adjuster; + correction = v; +} + +void Backlash::set_distance_mm(const AxisEnum axis, const float v) { + StepAdjuster adjuster; + distance_mm[axis] = v; +} + +#ifdef BACKLASH_SMOOTHING_MM + void Backlash::set_smoothing_mm(const float v) { + StepAdjuster adjuster; + smoothing_mm = v; + } +#endif + #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) #include "../module/probe.h" diff --git a/Marlin/src/feature/backlash.h b/Marlin/src/feature/backlash.h index ef29012cb1..0bace526e5 100644 --- a/Marlin/src/feature/backlash.h +++ b/Marlin/src/feature/backlash.h @@ -24,27 +24,22 @@ #include "../inc/MarlinConfigPre.h" #include "../module/planner.h" -constexpr uint8_t all_on = 0xFF, all_off = 0x00; - class Backlash { +public: + static constexpr uint8_t all_on = 0xFF, all_off = 0x00; + private: static axis_bits_t last_direction_bits; - #ifdef BACKLASH_SMOOTHING_MM - static xyz_long_t residual_error; - #endif + static xyz_long_t residual_error; -public: #if ENABLED(BACKLASH_GCODE) - static xyz_float_t distance_mm; static uint8_t correction; + static xyz_float_t distance_mm; #ifdef BACKLASH_SMOOTHING_MM static float smoothing_mm; #endif - - static void set_correction(const_float_t v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; } - static float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; } #else - static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF; + static constexpr uint8_t correction = (BACKLASH_CORRECTION) * all_on; static const xyz_float_t distance_mm; #ifdef BACKLASH_SMOOTHING_MM static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM; @@ -52,13 +47,13 @@ public: #endif #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) - private: - static xyz_float_t measured_mm; - static xyz_uint8_t measured_count; - public: - static void measure_with_probe(); + static xyz_float_t measured_mm; + static xyz_uint8_t measured_count; #endif + class StepAdjuster; + +public: static float get_measurement(const AxisEnum a) { UNUSED(a); // Return the measurement averaged over all readings @@ -78,7 +73,24 @@ public: } static void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block); - static int32_t applied_steps(const AxisEnum axis); + static int32_t get_applied_steps(const AxisEnum axis); + + #if ENABLED(BACKLASH_GCODE) + static void set_correction_uint8(const uint8_t v); + static uint8_t get_correction_uint8() { return correction; } + static void set_correction(const float v) { set_correction_uint8(_MAX(0, _MIN(1.0, v)) * all_on + 0.5f); } + static float get_correction() { return float(get_correction_uint8()) / all_on; } + static void set_distance_mm(const AxisEnum axis, const float v); + static float get_distance_mm(const AxisEnum axis) {return distance_mm[axis];} + #ifdef BACKLASH_SMOOTHING_MM + static void set_smoothing_mm(const float v); + static float get_smoothing_mm() {return smoothing_mm;} + #endif + #endif + + #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) + static void measure_with_probe(); + #endif }; extern Backlash backlash; diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 906f8cc419..a2dec64bc3 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -105,13 +105,27 @@ struct measurements_t { }; #if ENABLED(BACKLASH_GCODE) - #define TEMPORARY_BACKLASH_CORRECTION(value) REMEMBER(tbst, backlash.correction, value) + class restorer_correction { + const uint8_t val_; + public: + restorer_correction(const uint8_t temp_val) : val_(backlash.get_correction_uint8()) { backlash.set_correction_uint8(temp_val); } + ~restorer_correction() { backlash.set_correction_uint8(val_); } + }; + + #define TEMPORARY_BACKLASH_CORRECTION(value) restorer_correction restorer_tbst(value) #else #define TEMPORARY_BACKLASH_CORRECTION(value) #endif #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - #define TEMPORARY_BACKLASH_SMOOTHING(value) REMEMBER(tbsm, backlash.smoothing_mm, value) + class restorer_smoothing { + const float val_; + public: + restorer_smoothing(const float temp_val) : val_(backlash.get_smoothing_mm()) { backlash.set_smoothing_mm(temp_val); } + ~restorer_smoothing() { backlash.set_smoothing_mm(val_); } + }; + + #define TEMPORARY_BACKLASH_SMOOTHING(value) restorer_smoothing restorer_tbsm(value) #else #define TEMPORARY_BACKLASH_SMOOTHING(value) #endif @@ -524,7 +538,7 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { { // New scope for TEMPORARY_BACKLASH_CORRECTION - TEMPORARY_BACKLASH_CORRECTION(all_off); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_off); TEMPORARY_BACKLASH_SMOOTHING(0.0f); probe_sides(m, uncertainty); @@ -532,45 +546,45 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { #if ENABLED(BACKLASH_GCODE) #if HAS_X_CENTER - backlash.distance_mm.x = (m.backlash[LEFT] + m.backlash[RIGHT]) / 2; + backlash.set_distance_mm(X_AXIS, (m.backlash[LEFT] + m.backlash[RIGHT]) / 2); #elif ENABLED(CALIBRATION_MEASURE_LEFT) - backlash.distance_mm.x = m.backlash[LEFT]; + backlash.set_distance_mm(X_AXIS, m.backlash[LEFT]); #elif ENABLED(CALIBRATION_MEASURE_RIGHT) - backlash.distance_mm.x = m.backlash[RIGHT]; + backlash.set_distance_mm(X_AXIS, m.backlash[RIGHT]); #endif #if HAS_Y_CENTER - backlash.distance_mm.y = (m.backlash[FRONT] + m.backlash[BACK]) / 2; + backlash.set_distance_mm(Y_AXIS, (m.backlash[FRONT] + m.backlash[BACK]) / 2); #elif ENABLED(CALIBRATION_MEASURE_FRONT) - backlash.distance_mm.y = m.backlash[FRONT]; + backlash.set_distance_mm(Y_AXIS, m.backlash[FRONT]); #elif ENABLED(CALIBRATION_MEASURE_BACK) - backlash.distance_mm.y = m.backlash[BACK]; + backlash.set_distance_mm(Y_AXIS, m.backlash[BACK]); #endif - TERN_(HAS_Z_AXIS, if (AXIS_CAN_CALIBRATE(Z)) backlash.distance_mm.z = m.backlash[TOP]); + TERN_(HAS_Z_AXIS, if (AXIS_CAN_CALIBRATE(Z)) backlash.set_distance_mm(Z_AXIS, m.backlash[TOP])); #if HAS_I_CENTER - backlash.distance_mm.i = (m.backlash[IMINIMUM] + m.backlash[IMAXIMUM]) / 2; + backlash.set_distance_mm(I_AXIS, (m.backlash[IMINIMUM] + m.backlash[IMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_IMIN) - backlash.distance_mm.i = m.backlash[IMINIMUM]; + backlash.set_distance_mm(I_AXIS, m.backlash[IMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_IMAX) - backlash.distance_mm.i = m.backlash[IMAXIMUM]; + backlash.set_distance_mm(I_AXIS, m.backlash[IMAXIMUM]); #endif #if HAS_J_CENTER - backlash.distance_mm.j = (m.backlash[JMINIMUM] + m.backlash[JMAXIMUM]) / 2; + backlash.set_distance_mm(J_AXIS, (m.backlash[JMINIMUM] + m.backlash[JMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_JMIN) - backlash.distance_mm.j = m.backlash[JMINIMUM]; + backlash.set_distance_mm(J_AXIS, m.backlash[JMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_JMAX) - backlash.distance_mm.j = m.backlash[JMAXIMUM]; + backlash.set_distance_mm(J_AXIS, m.backlash[JMAXIMUM]); #endif #if HAS_K_CENTER - backlash.distance_mm.k = (m.backlash[KMINIMUM] + m.backlash[KMAXIMUM]) / 2; + backlash.set_distance_mm(K_AXIS, (m.backlash[KMINIMUM] + m.backlash[KMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_KMIN) - backlash.distance_mm.k = m.backlash[KMINIMUM]; + backlash.set_distance_mm(K_AXIS, m.backlash[KMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_KMAX) - backlash.distance_mm.k = m.backlash[KMAXIMUM]; + backlash.set_distance_mm(K_AXIS, m.backlash[KMAXIMUM]); #endif #endif // BACKLASH_GCODE @@ -581,7 +595,7 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { // allowed directions to take up any backlash { // New scope for TEMPORARY_BACKLASH_CORRECTION - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); const xyz_float_t move = LINEAR_AXIS_ARRAY( AXIS_CAN_CALIBRATE(X) * 3, AXIS_CAN_CALIBRATE(Y) * 3, AXIS_CAN_CALIBRATE(Z) * 3, @@ -611,7 +625,7 @@ inline void update_measurements(measurements_t &m, const AxisEnum axis) { * - Call calibrate_backlash() beforehand for best accuracy */ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const uint8_t extruder) { - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); TERN(HAS_MULTI_HOTEND, set_nozzle(m, extruder), UNUSED(extruder)); @@ -648,7 +662,7 @@ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const * uncertainty in - How far away from the object to begin probing */ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty) { - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); HOTEND_LOOP() calibrate_toolhead(m, uncertainty, e); @@ -674,7 +688,7 @@ inline void calibrate_all() { TERN_(HAS_HOTEND_OFFSET, reset_hotend_offsets()); - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); // Do a fast and rough calibration of the toolheads diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index 2d36e0d410..6b1f56fcf6 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -63,7 +63,7 @@ void GcodeSuite::M425() { LOOP_LINEAR_AXES(a) { if (axis_can_calibrate(a) && parser.seen(AXIS_CHAR(a))) { planner.synchronize(); - backlash.distance_mm[a] = parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a)); + backlash.set_distance_mm(AxisEnum(a), parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a))); noArgs = false; } } @@ -77,25 +77,25 @@ void GcodeSuite::M425() { #ifdef BACKLASH_SMOOTHING_MM if (parser.seen('S')) { planner.synchronize(); - backlash.smoothing_mm = parser.value_linear_units(); + backlash.set_smoothing_mm(parser.value_linear_units()); noArgs = false; } #endif if (noArgs) { SERIAL_ECHOPGM("Backlash Correction "); - if (!backlash.correction) SERIAL_ECHOPGM("in"); + if (!backlash.get_correction_uint8()) SERIAL_ECHOPGM("in"); SERIAL_ECHOLNPGM("active:"); SERIAL_ECHOLNPGM(" Correction Amount/Fade-out: F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)"); SERIAL_ECHOPGM(" Backlash Distance (mm): "); LOOP_LINEAR_AXES(a) if (axis_can_calibrate(a)) { SERIAL_CHAR(' ', AXIS_CHAR(a)); - SERIAL_ECHO(backlash.distance_mm[a]); + SERIAL_ECHO(backlash.get_distance_mm(AxisEnum(a))); SERIAL_EOL(); } #ifdef BACKLASH_SMOOTHING_MM - SERIAL_ECHOLNPGM(" Smoothing (mm): S", backlash.smoothing_mm); + SERIAL_ECHOLNPGM(" Smoothing (mm): S", backlash.get_smoothing_mm()); #endif #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) @@ -118,15 +118,15 @@ void GcodeSuite::M425_report(const bool forReplay/*=true*/) { SERIAL_ECHOLNPGM_P( PSTR(" M425 F"), backlash.get_correction() #ifdef BACKLASH_SMOOTHING_MM - , PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm) + , PSTR(" S"), LINEAR_UNIT(backlash.get_smoothing_mm()) #endif , LIST_N(DOUBLE(LINEAR_AXES), - SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x), - SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y), - SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z), - SP_I_STR, LINEAR_UNIT(backlash.distance_mm.i), - SP_J_STR, LINEAR_UNIT(backlash.distance_mm.j), - SP_K_STR, LINEAR_UNIT(backlash.distance_mm.k) + SP_X_STR, LINEAR_UNIT(backlash.get_distance_mm(X_AXIS)), + SP_Y_STR, LINEAR_UNIT(backlash.get_distance_mm(Y_AXIS)), + SP_Z_STR, LINEAR_UNIT(backlash.get_distance_mm(Z_AXIS)), + SP_I_STR, LINEAR_UNIT(backlash.get_distance_mm(I_AXIS)), + SP_J_STR, LINEAR_UNIT(backlash.get_distance_mm(J_AXIS)), + SP_K_STR, LINEAR_UNIT(backlash.get_distance_mm(K_AXIS)) ) ); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index f44e8bf720..bfcbc39d7b 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -861,16 +861,16 @@ namespace ExtUI { #endif #if ENABLED(BACKLASH_GCODE) - float getAxisBacklash_mm(const axis_t axis) { return backlash.distance_mm[axis]; } + float getAxisBacklash_mm(const axis_t axis) { return backlash.get_distance_mm((AxisEnum)axis); } void setAxisBacklash_mm(const_float_t value, const axis_t axis) - { backlash.distance_mm[axis] = constrain(value,0,5); } + { backlash.set_distance_mm((AxisEnum)axis, constrain(value,0,5)); } - float getBacklashCorrection_percent() { return ui8_to_percent(backlash.correction); } - void setBacklashCorrection_percent(const_float_t value) { backlash.correction = map(constrain(value, 0, 100), 0, 100, 0, 255); } + float getBacklashCorrection_percent() { return backlash.get_correction() * 100.0f; } + void setBacklashCorrection_percent(const_float_t value) { backlash.set_correction(constrain(value, 0, 100) / 100.0f); } #ifdef BACKLASH_SMOOTHING_MM - float getBacklashSmoothing_mm() { return backlash.smoothing_mm; } - void setBacklashSmoothing_mm(const_float_t value) { backlash.smoothing_mm = constrain(value, 0, 999); } + float getBacklashSmoothing_mm() { return backlash.get_smoothing_mm(); } + void setBacklashSmoothing_mm(const_float_t value) { backlash.set_smoothing_mm(constrain(value, 0, 999)); } #endif #endif diff --git a/Marlin/src/lcd/menu/menu_backlash.cpp b/Marlin/src/lcd/menu/menu_backlash.cpp index 5776234f72..faed8cf777 100644 --- a/Marlin/src/lcd/menu/menu_backlash.cpp +++ b/Marlin/src/lcd/menu/menu_backlash.cpp @@ -36,14 +36,20 @@ void menu_backlash() { START_MENU(); BACK_ITEM(MSG_MAIN); - EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &backlash.correction, all_off, all_on); + editable.uint8 = backlash.get_correction_uint8(); + EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &editable.uint8, backlash.all_off, backlash.all_on, []{ backlash.set_correction_uint8(editable.uint8); }); #if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX) #define _CAN_CALI AXIS_CAN_CALIBRATE #else #define _CAN_CALI(A) true #endif - #define EDIT_BACKLASH_DISTANCE(N) EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &backlash.distance_mm[_AXIS(N)], 0.0f, 9.9f); + + #define EDIT_BACKLASH_DISTANCE(N) do { \ + editable.decimal = backlash.get_distance_mm(_AXIS(N)); \ + EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &editable.decimal, 0.0f, 9.9f, []{ backlash.set_distance_mm(_AXIS(N), editable.decimal); }); \ + } while (0); + if (_CAN_CALI(A)) EDIT_BACKLASH_DISTANCE(A); #if HAS_Y_AXIS && _CAN_CALI(B) EDIT_BACKLASH_DISTANCE(B); @@ -62,7 +68,8 @@ void menu_backlash() { #endif #ifdef BACKLASH_SMOOTHING_MM - EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &backlash.smoothing_mm, 0.0f, 9.9f); + editable.decimal = backlash.get_smoothing_mm(); + EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &editable.decimal, 0.0f, 9.9f, []{ backlash.set_smoothing_mm(editable.decimal); }); #endif END_MENU(); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 37b264a3c5..51440aac26 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1706,7 +1706,7 @@ void Planner::endstop_triggered(const AxisEnum axis) { } float Planner::triggered_position_mm(const AxisEnum axis) { - const float result = DIFF_TERN(BACKLASH_COMPENSATION, stepper.triggered_position(axis), backlash.applied_steps(axis)); + const float result = DIFF_TERN(BACKLASH_COMPENSATION, stepper.triggered_position(axis), backlash.get_applied_steps(axis)); return result * mm_per_step[axis]; } @@ -1729,8 +1729,8 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { // Protect the access to the position. const bool was_enabled = stepper.suspend(); - const int32_t p1 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_1), backlash.applied_steps(CORE_AXIS_1)), - p2 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_2), backlash.applied_steps(CORE_AXIS_2)); + const int32_t p1 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_1), backlash.get_applied_steps(CORE_AXIS_1)), + p2 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_2), backlash.get_applied_steps(CORE_AXIS_2)); if (was_enabled) stepper.wake_up(); @@ -1739,7 +1739,7 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { axis_steps = (axis == CORE_AXIS_2 ? CORESIGN(p1 - p2) : p1 + p2) * 0.5f; } else - axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.applied_steps(axis)); + axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.get_applied_steps(axis)); #elif EITHER(MARKFORGED_XY, MARKFORGED_YX) @@ -1756,12 +1756,12 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { axis_steps = ((axis == CORE_AXIS_1) ? p1 - p2 : p2); } else - axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.applied_steps(axis)); + axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.get_applied_steps(axis)); #else axis_steps = stepper.position(axis); - TERN_(BACKLASH_COMPENSATION, axis_steps -= backlash.applied_steps(axis)); + TERN_(BACKLASH_COMPENSATION, axis_steps -= backlash.get_applied_steps(axis)); #endif @@ -2844,7 +2844,7 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ block->position = position; #if ENABLED(BACKLASH_COMPENSATION) - LOOP_LINEAR_AXES(axis) block->position[axis] += backlash.applied_steps((AxisEnum)axis); + LOOP_LINEAR_AXES(axis) block->position[axis] += backlash.get_applied_steps((AxisEnum)axis); #endif #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107) @@ -3122,7 +3122,7 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { else { #if ENABLED(BACKLASH_COMPENSATION) abce_long_t stepper_pos = position; - LOOP_LINEAR_AXES(axis) stepper_pos[axis] += backlash.applied_steps((AxisEnum)axis); + LOOP_LINEAR_AXES(axis) stepper_pos[axis] += backlash.get_applied_steps((AxisEnum)axis); stepper.set_position(stepper_pos); #else stepper.set_position(position); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 66316edbbb..f512d87b99 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1426,14 +1426,15 @@ void MarlinSettings::postprocess() { // { #if ENABLED(BACKLASH_GCODE) - const xyz_float_t &backlash_distance_mm = backlash.distance_mm; - const uint8_t &backlash_correction = backlash.correction; + xyz_float_t backlash_distance_mm; + LOOP_LINEAR_AXES(axis) backlash_distance_mm[axis] = backlash.get_distance_mm((AxisEnum)axis); + const uint8_t backlash_correction = backlash.get_correction_uint8(); #else const xyz_float_t backlash_distance_mm{0}; const uint8_t backlash_correction = 0; #endif #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - const float &backlash_smoothing_mm = backlash.smoothing_mm; + const float backlash_smoothing_mm = backlash.get_smoothing_mm(); #else const float backlash_smoothing_mm = 3; #endif @@ -2364,22 +2365,22 @@ void MarlinSettings::postprocess() { // Backlash Compensation // { - #if ENABLED(BACKLASH_GCODE) - const xyz_float_t &backlash_distance_mm = backlash.distance_mm; - const uint8_t &backlash_correction = backlash.correction; - #else - xyz_float_t backlash_distance_mm; - uint8_t backlash_correction; - #endif - #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - const float &backlash_smoothing_mm = backlash.smoothing_mm; - #else - float backlash_smoothing_mm; - #endif + xyz_float_t backlash_distance_mm; + uint8_t backlash_correction; + float backlash_smoothing_mm; + _FIELD_TEST(backlash_distance_mm); EEPROM_READ(backlash_distance_mm); EEPROM_READ(backlash_correction); EEPROM_READ(backlash_smoothing_mm); + + #if ENABLED(BACKLASH_GCODE) + LOOP_LINEAR_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, backlash_distance_mm[axis]); + backlash.set_correction_uint8(backlash_correction); + #ifdef BACKLASH_SMOOTHING_MM + backlash.set_smoothing_mm(backlash_smoothing_mm); + #endif + #endif } // @@ -2811,11 +2812,11 @@ void MarlinSettings::reset() { #endif #if ENABLED(BACKLASH_GCODE) - backlash.correction = (BACKLASH_CORRECTION) * 255; + backlash.set_correction(BACKLASH_CORRECTION); constexpr xyz_float_t tmp = BACKLASH_DISTANCE_MM; - backlash.distance_mm = tmp; + LOOP_LINEAR_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, tmp[axis]); #ifdef BACKLASH_SMOOTHING_MM - backlash.smoothing_mm = BACKLASH_SMOOTHING_MM; + backlash.set_smoothing_mm(BACKLASH_SMOOTHING_MM); #endif #endif From 7d7439c4b62e3d353bb20158c04d60defe89c694 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Wed, 2 Mar 2022 11:22:36 +1300 Subject: [PATCH 071/203] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20BLTouch=205V=20pin?= =?UTF-8?q?=20tolerance=20checks=20(#23823)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index e847339e2a..b34d982e75 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1574,10 +1574,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #else #define _IS_5V_TOLERANT(P) 1 // Assume 5V tolerance #endif - #if USES_Z_MIN_PROBE_PIN && !_IS_5V_TOLERANT(Z_MIN_PROBE_PIN) - #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PROBE_PIN." + #if USES_Z_MIN_PROBE_PIN + #if !_IS_5V_TOLERANT(Z_MIN_PROBE_PIN) + #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PROBE_PIN." + #endif #elif !_IS_5V_TOLERANT(Z_MIN_PIN) - #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PIN." + #if !MB(CHITU3D_V6) + #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PIN." + #endif #endif #undef _IS_5V_TOLERANT #undef _5V From 9ef01d43bb2f4384482ae8205ca6c80ebe388a52 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Tue, 1 Mar 2022 17:25:30 -0500 Subject: [PATCH 072/203] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20E3V2=20blank=20bg?= =?UTF-8?q?=20for=20S1=20compatibility=20(#23822)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp | 1 + Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 2 ++ Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp | 1 + Marlin/src/lcd/e3v2/proui/dwin.cpp | 2 ++ 4 files changed, 6 insertions(+) diff --git a/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp index fee22932d2..3d60e32a79 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp @@ -49,6 +49,7 @@ void DWIN_Startup() { #if DISABLED(SHOW_BOOTSCREEN) DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here #endif + DWIN_JPG_ShowAndCache(3); DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 0eedddb500..d384bae3e3 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -4989,6 +4989,8 @@ void MarlinUI::init_lcd() { DWIN_UpdateLCD(); delay(20); } + + DWIN_JPG_ShowAndCache(3); DWIN_JPG_CacheTo1(Language_English); CrealityDWIN.Redraw_Screen(); } diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp index ef390ac9dc..a4cefe4ab9 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp @@ -45,6 +45,7 @@ void DWIN_Startup() { const bool success = DWIN_Handshake(); if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error."); DWIN_Frame_SetDir(TERN(DWIN_MARLINUI_LANDSCAPE, 0, 1)); + DWIN_JPG_ShowAndCache(3); DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index d65fa9ec79..5af7fc294d 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -1836,6 +1836,7 @@ void DWIN_Startup() { DWINUI::onCursorErase = Erase_Menu_Cursor; DWINUI::onTitleDraw = Draw_Title; DWINUI::onMenuDraw = Draw_Menu; + DWIN_JPG_ShowAndCache(3); HMI_SetLanguage(); } @@ -1937,6 +1938,7 @@ void DWIN_RebootScreen() { DWINUI::Draw_CenteredString(Color_White, 220, GET_TEXT_F(MSG_PLEASE_WAIT_REBOOT)); DWIN_UpdateLCD(); delay(500); + DWIN_JPG_ShowAndCache(3); } void DWIN_Redraw_screen() { From c9fe822920f8df22553373b8ad066a33b80030f3 Mon Sep 17 00:00:00 2001 From: Julien Staub Date: Tue, 1 Mar 2022 23:42:20 +0100 Subject: [PATCH 073/203] =?UTF-8?q?=E2=9C=A8=20Weedo=2062A=20Tina2=20/=20M?= =?UTF-8?q?onoprice=20Cadet=20(#23817)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 1 + Marlin/src/pins/mega/pins_PICA.h | 1 + Marlin/src/pins/mega/pins_WEEDO_62A.h | 106 ++++++++++++++++++++++++++ Marlin/src/pins/pins.h | 2 + 4 files changed, 110 insertions(+) create mode 100644 Marlin/src/pins/mega/pins_WEEDO_62A.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 5ee99b533f..3ec24e7760 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -164,6 +164,7 @@ #define BOARD_MALYAN_M180 1327 // Malyan M180 Mainboard Version 2 (no display function, direct gcode only) #define BOARD_GT2560_V4_A20 1328 // Geeetech GT2560 Rev B for A20(M/T/D) #define BOARD_PROTONEER_CNC_SHIELD_V3 1329 // Mega controller & Protoneer CNC Shield V3.00 +#define BOARD_WEEDO_62A 1330 // WEEDO 62A board (TINA2, Monoprice Cadet, etc.) // // ATmega1281, ATmega2561 diff --git a/Marlin/src/pins/mega/pins_PICA.h b/Marlin/src/pins/mega/pins_PICA.h index 47c101711c..0e29d8dffe 100644 --- a/Marlin/src/pins/mega/pins_PICA.h +++ b/Marlin/src/pins/mega/pins_PICA.h @@ -51,6 +51,7 @@ #define SERVO0_PIN 3 #define SERVO1_PIN 4 #define SERVO2_PIN 5 + // // Limit Switches // diff --git a/Marlin/src/pins/mega/pins_WEEDO_62A.h b/Marlin/src/pins/mega/pins_WEEDO_62A.h new file mode 100644 index 0000000000..4b3bf6a43b --- /dev/null +++ b/Marlin/src/pins/mega/pins_WEEDO_62A.h @@ -0,0 +1,106 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Based on WEEDO 62A pin configuration + * Copyright (c) 2019 WEEDO3D Perron + */ + +#pragma once + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "WEEDO 62A" +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 40 +#define Y_MAX_PIN 41 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Steppers +// +#define X_STEP_PIN 26 +#define X_DIR_PIN 28 +#define X_ENABLE_PIN 24 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 + +#define E0_STEP_PIN 54 +#define E0_DIR_PIN 55 +#define E0_ENABLE_PIN 38 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // ANALOG NUMBERING +#define TEMP_BED_PIN 14 // ANALOG NUMBERING + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 // EXTRUDER 1 +#define HEATER_BED_PIN 8 // BED +#define FAN_PIN 4 // IO pin. Buffer needed + +// +// Misc. Functions +// +#define PS_ON_PIN 12 +#define LED_PIN 13 + +// +// SD Support +// +#if ENABLED(SDSUPPORT) + #define SDSS 53 + #define SD_DETECT_PIN 49 +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BEEPER_PIN 37 + + #define DOGLCD_A0 27 + #define DOGLCD_CS 29 + #define LCD_RESET_PIN 25 + #define LCD_CONTRAST_INIT 255 + + #define BTN_EN1 33 + #define BTN_EN2 31 + #define BTN_ENC 35 +#endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 88e7946edc..7f0eac8c88 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -287,6 +287,8 @@ #include "mega/pins_MALYAN_M180.h" // ATmega2560 env:mega2560 #elif MB(PROTONEER_CNC_SHIELD_V3) #include "mega/pins_PROTONEER_CNC_SHIELD_V3.h"// ATmega2560 env:mega2560 +#elif MB(WEEDO_62A) + #include "mega/pins_WEEDO_62A.h" // ATmega2560 env:mega2560 // // ATmega1281, ATmega2561 From fd1a5fe36692319bc41739833a0dbd9cae67c37a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 2 Mar 2022 00:26:24 +0000 Subject: [PATCH 074/203] [cron] Bump distribution date (2022-03-02) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index d481674947..04cabb79e2 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-02-28" +//#define STRING_DISTRIBUTION_DATE "2022-03-02" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 46ce0820c7..e37cb894e2 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-02-28" + #define STRING_DISTRIBUTION_DATE "2022-03-02" #endif /** From b07a34eb6bd8928aebef631554626aaa8c88c567 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 2 Mar 2022 16:04:17 -0600 Subject: [PATCH 075/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20M=5FState=5Fgrbl?= =?UTF-8?q?=20when=20G29=20calls=20G28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 33 +++++++++++++++++++-------- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 4 ++-- Marlin/src/gcode/calibrate/G28.cpp | 9 +++++--- Marlin/src/module/motion.h | 8 ++++--- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 24c0268b9f..a6ef6d2729 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -77,7 +77,12 @@ #endif #endif -#define G29_RETURN(b) return TERN_(G29_RETRY_AND_RECOVER, b) +#define G29_RETURN(retry) do{ \ + if (TERN(G29_RETRY_AND_RECOVER, !retry, true)) { \ + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false)); \ + } \ + return TERN_(G29_RETRY_AND_RECOVER, retry); \ +}while(0) // For manual probing values persist over multiple G29 class G29_State { @@ -218,12 +223,13 @@ public: G29_TYPE GcodeSuite::G29() { DEBUG_SECTION(log_G29, "G29", DEBUGGING(LEVELING)); + // Leveling state is persistent when done manually with multiple G29 commands TERN_(PROBE_MANUALLY, static) G29_State abl; - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); - + // Keep powered steppers from timing out reset_stepper_timeout(); + // Q = Query leveling and G29 state const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen_test('Q'); // G29 Q is also available if debugging @@ -232,11 +238,14 @@ G29_TYPE GcodeSuite::G29() { if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false); #endif + // A = Abort manual probing + // C = Generate fake probe points (DEBUG_LEVELING_FEATURE) const bool seenA = TERN0(PROBE_MANUALLY, parser.seen_test('A')), no_action = seenA || seenQ, faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action; - if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed + // O = Don't level if leveling is already active + if (!no_action && planner.leveling_active && parser.boolval('O')) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip"); G29_RETURN(false); } @@ -248,15 +257,20 @@ G29_TYPE GcodeSuite::G29() { // Don't allow auto-leveling without homing first if (homing_needed_error()) G29_RETURN(false); + // 3-point leveling gets points from the probe class #if ENABLED(AUTO_BED_LEVELING_3POINT) vector_3 points[3]; probe.get_three_points(points); #endif + // Storage for ABL Linear results #if ENABLED(AUTO_BED_LEVELING_LINEAR) struct linear_fit_data lsf_results; #endif + // Set and report "probing" state to host + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE, false)); + /** * On the initial G29 fetch command parameters. */ @@ -429,10 +443,10 @@ G29_TYPE GcodeSuite::G29() { if (!no_action) set_bed_leveling_enabled(false); // Deploy certain probes before starting probing - #if HAS_BED_PROBE - if (ENABLED(BLTOUCH)) - do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); - else if (probe.deploy()) { + #if ENABLED(BLTOUCH) + do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); + #elif HAS_BED_PROBE + if (probe.deploy()) { // (returns true on deploy failure) set_bed_leveling_enabled(abl.reenable); G29_RETURN(false); } @@ -483,6 +497,7 @@ G29_TYPE GcodeSuite::G29() { SERIAL_ECHOLNPGM("idle"); } + // For 'A' or 'Q' exit with success state if (no_action) G29_RETURN(false); if (abl.abl_probe_index == 0) { @@ -893,8 +908,6 @@ G29_TYPE GcodeSuite::G29() { report_current_position(); - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); - G29_RETURN(isnan(abl.measured_z)); } diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 090c15b057..4ffeec6eec 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -75,8 +75,6 @@ void GcodeSuite::G29() { } #endif - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); - static int mbl_probe_index = -1; MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport); @@ -85,6 +83,8 @@ void GcodeSuite::G29() { return; } + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); + int8_t ix, iy; ix = iy = 0; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index a38c567939..4d8891d55b 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -213,8 +213,6 @@ void GcodeSuite::G28() { TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_HOMING)); - #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; DualXMode IDEX_saved_mode = dual_x_carriage_mode; @@ -236,6 +234,11 @@ void GcodeSuite::G28() { return; } + #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) + const M_StateEnum old_grblstate = M_State_grbl; + set_and_report_grblstate(M_HOMING); + #endif + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StartHoming()); TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart()); @@ -557,7 +560,7 @@ void GcodeSuite::G28() { if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS))) SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP); - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(old_grblstate)); #if HAS_L64XX // Set L6470 absolute position registers to counts diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 9fe61aad33..2fbb4ce114 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -265,9 +265,11 @@ void report_current_position_projected(); void report_current_position_moving(); #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) - inline void set_and_report_grblstate(const M_StateEnum state) { - M_State_grbl = state; - report_current_grblstate_moving(); + inline void set_and_report_grblstate(const M_StateEnum state, const bool force=true) { + if (force || M_State_grbl != state) { + M_State_grbl = state; + report_current_grblstate_moving(); + } } #endif From 2e39bc30fd748b0ade7aafdab4827f942536cdcd Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Wed, 2 Mar 2022 22:13:46 +0000 Subject: [PATCH 076/203] =?UTF-8?q?=F0=9F=9A=B8=20Universal=20X=5FAXIS=5FT?= =?UTF-8?q?WIST=5FCOMPENSATION=20(#23828)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 3 +- Marlin/src/feature/bedlevel/bedlevel.h | 3 - .../feature/{bedlevel/abl => }/x_twist.cpp | 15 ++++- .../src/feature/{bedlevel/abl => }/x_twist.h | 5 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- Marlin/src/lcd/menu/menu_x_twist.cpp | 3 + Marlin/src/module/probe.cpp | 5 ++ Marlin/src/module/settings.cpp | 58 ++++++++++++------- ini/features.ini | 2 +- platformio.ini | 2 +- 10 files changed, 67 insertions(+), 31 deletions(-) rename Marlin/src/feature/{bedlevel/abl => }/x_twist.cpp (82%) rename Marlin/src/feature/{bedlevel/abl => }/x_twist.h (88%) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e5379ed84f..970be38667 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1299,7 +1299,7 @@ #if HAS_MARLINUI_MENU - #if BOTH(HAS_BED_PROBE, AUTO_BED_LEVELING_BILINEAR) + #if HAS_BED_PROBE // Add calibration in the Probe Offsets menu to compensate for X-axis twist. //#define X_AXIS_TWIST_COMPENSATION #if ENABLED(X_AXIS_TWIST_COMPENSATION) @@ -1311,6 +1311,7 @@ #define XATC_START_Z 0.0 #define XATC_MAX_POINTS 3 // Number of points to probe in the wizard #define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe + #define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points #endif #endif diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index c623c99b5c..63f032eee8 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -63,9 +63,6 @@ class TemporaryBedLevelingState { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) #include "abl/abl.h" - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - #include "abl/x_twist.h" - #endif #elif ENABLED(AUTO_BED_LEVELING_UBL) #include "ubl/ubl.h" #elif ENABLED(MESH_BED_LEVELING) diff --git a/Marlin/src/feature/bedlevel/abl/x_twist.cpp b/Marlin/src/feature/x_twist.cpp similarity index 82% rename from Marlin/src/feature/bedlevel/abl/x_twist.cpp rename to Marlin/src/feature/x_twist.cpp index 24fdbca950..deac1bceba 100644 --- a/Marlin/src/feature/bedlevel/abl/x_twist.cpp +++ b/Marlin/src/feature/x_twist.cpp @@ -19,16 +19,24 @@ * along with this program. If not, see . * */ -#include "../../../inc/MarlinConfig.h" +#include "../inc/MarlinConfig.h" #if ENABLED(X_AXIS_TWIST_COMPENSATION) -#include "../bedlevel.h" +#include "x_twist.h" XATC xatc; +bool XATC::enabled = true; float XATC::spacing, XATC::start; -xatc_array_t XATC::z_offset; +xatc_array_t XATC::z_offset; // Initialized by settings.load() + +void XATC::reset() { + constexpr float xzo[] = XATC_Z_OFFSETS; + static_assert(COUNT(xzo) == XATC_MAX_POINTS, "XATC_Z_OFFSETS is the wrong size."); + enabled = false; + COPY(z_offset, xzo); +} void XATC::print_points() { SERIAL_ECHOLNPGM(" X-Twist Correction:"); @@ -49,6 +57,7 @@ void XATC::print_points() { float lerp(const_float_t t, const_float_t a, const_float_t b) { return a + t * (b - a); } float XATC::compensation(const xy_pos_t &raw) { + if (!enabled) return 0; if (NEAR_ZERO(spacing)) return 0; float t = (raw.x - start) / spacing; int i = FLOOR(t); diff --git a/Marlin/src/feature/bedlevel/abl/x_twist.h b/Marlin/src/feature/x_twist.h similarity index 88% rename from Marlin/src/feature/bedlevel/abl/x_twist.h rename to Marlin/src/feature/x_twist.h index 9deb45a8b7..6a2ff27901 100644 --- a/Marlin/src/feature/bedlevel/abl/x_twist.h +++ b/Marlin/src/feature/x_twist.h @@ -21,15 +21,18 @@ */ #pragma once -#include "../../../inc/MarlinConfigPre.h" +#include "../inc/MarlinConfigPre.h" typedef float xatc_array_t[XATC_MAX_POINTS]; class XATC { + static bool enabled; public: static float spacing, start; static xatc_array_t z_offset; + static void reset(); + static void set_enabled(const bool ena) { enabled = ena; } static float compensation(const xy_pos_t &raw); static void print_points(); }; diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a6ef6d2729..20f2369b03 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -681,7 +681,7 @@ G29_TYPE GcodeSuite::G29() { #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) const float z = abl.measured_z + abl.Z_offset; - z_values[abl.meshCount.x][abl.meshCount.y] = z PLUS_TERN0(X_AXIS_TWIST_COMPENSATION, xatc.compensation(abl.probePos)); + z_values[abl.meshCount.x][abl.meshCount.y] = z; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, z)); #endif diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp index fab3b5ae11..ca385ebfeb 100644 --- a/Marlin/src/lcd/menu/menu_x_twist.cpp +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -27,6 +27,7 @@ #include "menu_addon.h" #include "../../module/planner.h" #include "../../feature/bedlevel/bedlevel.h" +#include "../../feature/x_twist.h" #include "../../module/motion.h" #include "../../gcode/queue.h" #include "../../module/probe.h" @@ -148,7 +149,9 @@ void xatc_wizard_goto_next_point() { // Deploy certain probes before starting probing TERN_(BLTOUCH, do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE)); + xatc.set_enabled(false); measured_z = probe.probe_at_point(x, XATC_Y_POSITION, PROBE_PT_STOW); + xatc.set_enabled(true); current_position += probe.offset_xy; current_position.z = XATC_START_Z - probe.offset.z + measured_z; line_to_current_position(MMM_TO_MMS(XY_PROBE_FEEDRATE)); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 95776ffda1..89d2769247 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -81,6 +81,10 @@ #include "../feature/probe_temp_comp.h" #endif +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + #include "../feature/x_twist.h" +#endif + #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) @@ -808,6 +812,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai if (!deploy()) { measured_z = run_z_probe(sanity_check) + offset.z; TERN_(HAS_PTC, ptc.apply_compensation(measured_z)); + TERN_(X_AXIS_TWIST_COMPENSATION, measured_z += xatc.compensation(npos + offset_xy)); } if (!isnan(measured_z)) { const bool big_raise = raise_after == PROBE_PT_BIG_RAISE; diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index f512d87b99..2c103b89b4 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -64,7 +64,7 @@ #if HAS_LEVELING #include "../feature/bedlevel/bedlevel.h" #if ENABLED(X_AXIS_TWIST_COMPENSATION) - #include "../feature/bedlevel/abl/x_twist.h" + #include "../feature/x_twist.h" #endif #endif @@ -269,13 +269,17 @@ typedef struct SettingsDataStruct { xy_pos_t bilinear_grid_spacing, bilinear_start; // G29 L F #if ENABLED(AUTO_BED_LEVELING_BILINEAR) bed_mesh_t z_values; // G29 - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - XATC xatc; // TBD - #endif #else float z_values[3][3]; #endif + // + // X_AXIS_TWIST_COMPENSATION + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + XATC xatc; // TBD + #endif + // // AUTO_BED_LEVELING_UBL // @@ -298,7 +302,7 @@ typedef struct SettingsDataStruct { int16_t z_offsets_bed[COUNT(ptc.z_offsets_bed)]; // M871 B I V #endif #if ENABLED(PTC_HOTEND) - int16_t z_offsets_hotend[COUNT(ptc.z_offsets_hotend)]; // M871 E I V + int16_t z_offsets_hotend[COUNT(ptc.z_offsets_hotend)]; // M871 E I V #endif #endif @@ -873,9 +877,6 @@ void MarlinSettings::postprocess() { sizeof(z_values) == (GRID_MAX_POINTS) * sizeof(z_values[0][0]), "Bilinear Z array is the wrong size." ); - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - static_assert(COUNT(xatc.z_offset) == XATC_MAX_POINTS, "XATC Z-offset mesh is the wrong size."); - #endif #else const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0}; #endif @@ -889,15 +890,20 @@ void MarlinSettings::postprocess() { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) EEPROM_WRITE(z_values); // 9-256 floats - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - EEPROM_WRITE(xatc); - #endif #else dummyf = 0; for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummyf); #endif } + // + // X Axis Twist Compensation + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + _FIELD_TEST(xatc); + EEPROM_WRITE(xatc); + #endif + // // Unified Bed Leveling // @@ -1785,9 +1791,6 @@ void MarlinSettings::postprocess() { EEPROM_READ(bilinear_grid_spacing); // 2 ints EEPROM_READ(bilinear_start); // 2 ints EEPROM_READ(z_values); // 9 to 256 floats - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - EEPROM_READ(xatc); - #endif } else // EEPROM data is stale #endif // AUTO_BED_LEVELING_BILINEAR @@ -1800,6 +1803,13 @@ void MarlinSettings::postprocess() { } } + // + // X Axis Twist Compensation + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + EEPROM_READ(xatc); + #endif + // // Unified Bed Leveling active state // @@ -2849,6 +2859,14 @@ void MarlinSettings::reset() { TERN_(ENABLE_LEVELING_FADE_HEIGHT, new_z_fade_height = (DEFAULT_LEVELING_FADE_HEIGHT)); TERN_(HAS_LEVELING, reset_bed_level()); + // + // X Axis Twist Compensation + // + TERN_(X_AXIS_TWIST_COMPENSATION, xatc.reset()); + + // + // Nozzle-to-probe Offset + // #if HAS_BED_PROBE constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET; static_assert(COUNT(dpo) == LINEAR_AXES, "NOZZLE_TO_PROBE_OFFSET must contain offsets for each linear axis X, Y, Z...."); @@ -3313,14 +3331,14 @@ void MarlinSettings::reset() { } } - // TODO: Create G-code for settings - //#if ENABLED(X_AXIS_TWIST_COMPENSATION) - // CONFIG_ECHO_START(); - // xatc.print_points(); - //#endif - #endif + // TODO: Create G-code for settings + //#if ENABLED(X_AXIS_TWIST_COMPENSATION) + // CONFIG_ECHO_START(); + // xatc.print_points(); + //#endif + #endif // HAS_LEVELING // diff --git a/ini/features.ini b/ini/features.ini index 627f094e07..4d394e0901 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -98,7 +98,7 @@ USB_FLASH_DRIVE_SUPPORT = src_filter=+ + AUTO_BED_LEVELING_BILINEAR = src_filter=+ AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ -X_AXIS_TWIST_COMPENSATION = src_filter=+ + +X_AXIS_TWIST_COMPENSATION = src_filter=+ + MESH_BED_LEVELING = src_filter=+ + AUTO_BED_LEVELING_UBL = src_filter=+ + UBL_HILBERT_CURVE = src_filter=+ diff --git a/platformio.ini b/platformio.ini index 3a02b5ab18..9b64bdd377 100644 --- a/platformio.ini +++ b/platformio.ini @@ -100,7 +100,6 @@ default_src_filter = + - - + - - - - - - - - - - - - @@ -151,6 +150,7 @@ default_src_filter = + - - + - - - - + - - - - From bb2f100fcdaef30958601ec90ebcaad0fcae8815 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 2 Mar 2022 17:50:55 -0600 Subject: [PATCH 077/203] =?UTF-8?q?=F0=9F=9A=B8=20Use=20Z=5FSTEPPER=5FALIG?= =?UTF-8?q?N=5FSTEPPER=5FXY=20to=20enable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 20 +++++++++-------- Marlin/src/feature/z_stepper_align.cpp | 4 ++-- Marlin/src/feature/z_stepper_align.h | 2 +- Marlin/src/gcode/calibrate/G34_M422.cpp | 30 ++++++++++++------------- Marlin/src/inc/Conditionals_adv.h | 5 +++-- Marlin/src/inc/SanityCheck.h | 6 +++-- Marlin/src/module/settings.cpp | 8 +++---- buildroot/tests/DUE | 2 +- 8 files changed, 41 insertions(+), 36 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 970be38667..55857f5dec 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -959,15 +959,17 @@ //#define Z_STEPPERS_ORIENTATION 0 #endif - // Provide Z stepper positions for more rapid convergence in bed alignment. - // Requires triple stepper drivers (i.e., set NUM_Z_STEPPER_DRIVERS to 3) - //#define Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - // Define Stepper XY positions for Z1, Z2, Z3 corresponding to - // the Z screw positions in the bed carriage. - // Define one position per Z stepper in stepper driver order. - #define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } } - #else + /** + * Z Stepper positions for more rapid convergence in bed alignment. + * Requires NUM_Z_STEPPER_DRIVERS to be 3 or 4. + * + * Define Stepper XY positions for Z1, Z2, Z3... corresponding to the screw + * positions in the bed carriage, with one position per Z stepper in stepper + * driver order. + */ + //#define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } } + + #ifndef Z_STEPPER_ALIGN_STEPPER_XY // Amplification factor. Used to scale the correction step up or down in case // the stepper (spindle) position is farther out than the test point. #define Z_STEPPER_ALIGN_AMP 1.0 // Use a value > 1.0 NOTE: This may cause instability! diff --git a/Marlin/src/feature/z_stepper_align.cpp b/Marlin/src/feature/z_stepper_align.cpp index 1b4eb44749..fdbd464ea1 100644 --- a/Marlin/src/feature/z_stepper_align.cpp +++ b/Marlin/src/feature/z_stepper_align.cpp @@ -35,7 +35,7 @@ ZStepperAlign z_stepper_align; xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPER_DRIVERS]; -#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) +#if HAS_Z_STEPPER_ALIGN_STEPPER_XY xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPER_DRIVERS]; #endif @@ -103,7 +103,7 @@ void ZStepperAlign::reset_to_default() { COPY(xy, xy_init); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY; static_assert( COUNT(stepper_xy_init) == NUM_Z_STEPPER_DRIVERS, diff --git a/Marlin/src/feature/z_stepper_align.h b/Marlin/src/feature/z_stepper_align.h index e1b235b52c..8a12cd18b0 100644 --- a/Marlin/src/feature/z_stepper_align.h +++ b/Marlin/src/feature/z_stepper_align.h @@ -31,7 +31,7 @@ class ZStepperAlign { public: static xy_pos_t xy[NUM_Z_STEPPER_DRIVERS]; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY static xy_pos_t stepper_xy[NUM_Z_STEPPER_DRIVERS]; #endif diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 328a40dbb4..fc4430885e 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -41,7 +41,7 @@ #include "../../module/tool_change.h" #endif -#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) +#if HAS_Z_STEPPER_ALIGN_STEPPER_XY #include "../../libs/least_squares_fit.h" #endif @@ -122,7 +122,7 @@ void GcodeSuite::G34() { break; } - const float z_auto_align_amplification = TERN(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP)); + const float z_auto_align_amplification = TERN(HAS_Z_STEPPER_ALIGN_STEPPER_XY, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP)); if (!WITHIN(ABS(z_auto_align_amplification), 0.5f, 2.0f)) { SERIAL_ECHOLNPGM("?(A)mplification out of bounds (0.5-2.0)."); break; @@ -179,7 +179,7 @@ void GcodeSuite::G34() { // Now, the Z origin lies below the build plate. That allows to probe deeper, before run_z_probe throws an error. // This hack is un-done at the end of G34 - either by re-homing, or by using the probed heights of the last iteration. - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N_1(NUM_Z_STEPPER_DRIVERS, 10000.0f); #else float last_z_align_level_indicator = 10000.0f; @@ -188,7 +188,7 @@ void GcodeSuite::G34() { z_maxdiff = 0.0f, amplification = z_auto_align_amplification; - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY bool adjustment_reverse = false; #endif @@ -256,7 +256,7 @@ void GcodeSuite::G34() { z_maxdiff = z_measured_max - z_measured_min; z_probe = Z_BASIC_CLEARANCE + z_measured_max + z_maxdiff; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY // Replace the initial values in z_measured with calculated heights at // each stepper position. This allows the adjustment algorithm to be // shared between both possible probing mechanisms. @@ -338,7 +338,7 @@ void GcodeSuite::G34() { return false; }; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY // Check if the applied corrections go in the correct direction. // Calculate the sum of the absolute deviations from the mean of the probe measurements. // Compare to the last iteration to ensure it's getting better. @@ -370,7 +370,7 @@ void GcodeSuite::G34() { float z_align_move = z_measured[zstepper] - z_measured_min; const float z_align_abs = ABS(z_align_move); - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY // Optimize one iteration's correction based on the first measurements if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification; @@ -394,7 +394,7 @@ void GcodeSuite::G34() { // Lock all steppers except one stepper.set_all_z_lock(true, zstepper); - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY // Decreasing accuracy was detected so move was inverted. // Will match reversed Z steppers on dual steppers. Triple will need more work to map. if (adjustment_reverse) { @@ -467,7 +467,7 @@ void GcodeSuite::G34() { * * S : Index of the probe point to set * - * With Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS: + * With Z_STEPPER_ALIGN_STEPPER_XY: * W : Index of the Z stepper position to set * The W and S parameters may not be combined. * @@ -488,18 +488,18 @@ void GcodeSuite::M422() { const bool is_probe_point = parser.seen('S'); - if (TERN0(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, is_probe_point && parser.seen('W'))) { + if (TERN0(HAS_Z_STEPPER_ALIGN_STEPPER_XY, is_probe_point && parser.seen('W'))) { SERIAL_ECHOLNPGM("?(S) and (W) may not be combined."); return; } xy_pos_t *pos_dest = ( - TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !is_probe_point ? z_stepper_align.stepper_xy :) + TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !is_probe_point ? z_stepper_align.stepper_xy :) z_stepper_align.xy ); - if (!is_probe_point && TERN1(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !parser.seen('W'))) { - SERIAL_ECHOLNPGM("?(S)" TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, " or (W)") " is required."); + if (!is_probe_point && TERN1(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !parser.seen('W'))) { + SERIAL_ECHOLNPGM("?(S)" TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, " or (W)") " is required."); return; } @@ -513,7 +513,7 @@ void GcodeSuite::M422() { } } else { - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY position_index = parser.intval('W') - 1; if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) { SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid."); @@ -551,7 +551,7 @@ void GcodeSuite::M422_report(const bool forReplay/*=true*/) { SP_Y_STR, z_stepper_align.xy[i].y ); } - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { report_echo_start(forReplay); SERIAL_ECHOLNPGM_P( diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 82b32ba003..d63395a719 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -630,7 +630,8 @@ #endif #if ENABLED(Z_STEPPER_AUTO_ALIGN) - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #ifdef Z_STEPPER_ALIGN_STEPPER_XY + #define HAS_Z_STEPPER_ALIGN_STEPPER_XY 1 #undef Z_STEPPER_ALIGN_AMP #endif #ifndef Z_STEPPER_ALIGN_AMP @@ -986,7 +987,7 @@ #endif // Flag whether least_squares_fit.cpp is used -#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) +#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, HAS_Z_STEPPER_ALIGN_STEPPER_XY) #define NEED_LSF 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b34d982e75..e8abf1b286 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -613,6 +613,8 @@ #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 1." #elif defined(NOZZLE_PARK_Y_ONLY) #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 2." +#elif defined(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS is now just Z_STEPPER_ALIGN_STEPPER_XY." #endif constexpr float arm[] = AXIS_RELATIVE_MODES; @@ -3479,10 +3481,10 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "Z_STEPPER_AUTO_ALIGN requires NUM_Z_STEPPER_DRIVERS greater than 1." #elif !HAS_BED_PROBE #error "Z_STEPPER_AUTO_ALIGN requires a Z-bed probe." - #elif ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #elif HAS_Z_STEPPER_ALIGN_STEPPER_XY static_assert(WITHIN(Z_STEPPER_ALIGN_AMP, 0.5, 2.0), "Z_STEPPER_ALIGN_AMP must be between 0.5 and 2.0."); #if NUM_Z_STEPPER_DRIVERS < 3 - #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS requires NUM_Z_STEPPER_DRIVERS to be 3 or 4." + #error "Z_STEPPER_ALIGN_STEPPER_XY requires NUM_Z_STEPPER_DRIVERS to be 3 or 4." #endif #endif #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 2c103b89b4..fed1f67755 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -341,11 +341,11 @@ typedef struct SettingsDataStruct { #endif // - // Z_STEPPER_AUTO_ALIGN, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS + // Z_STEPPER_AUTO_ALIGN, HAS_Z_STEPPER_ALIGN_STEPPER_XY // #if ENABLED(Z_STEPPER_AUTO_ALIGN) xy_pos_t z_stepper_align_xy[NUM_Z_STEPPER_DRIVERS]; // M422 S X Y - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY xy_pos_t z_stepper_align_stepper_xy[NUM_Z_STEPPER_DRIVERS]; // M422 W X Y #endif #endif @@ -1005,7 +1005,7 @@ void MarlinSettings::postprocess() { #if ENABLED(Z_STEPPER_AUTO_ALIGN) EEPROM_WRITE(z_stepper_align.xy); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY EEPROM_WRITE(z_stepper_align.stepper_xy); #endif #endif @@ -1924,7 +1924,7 @@ void MarlinSettings::postprocess() { #if ENABLED(Z_STEPPER_AUTO_ALIGN) EEPROM_READ(z_stepper_align.xy); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY EEPROM_READ(z_stepper_align.stepper_xy); #endif #endif diff --git a/buildroot/tests/DUE b/buildroot/tests/DUE index 5810b73bdc..9b968cbd8d 100755 --- a/buildroot/tests/DUE +++ b/buildroot/tests/DUE @@ -37,7 +37,7 @@ exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), ExtUI, S-Curve, many options restore_configs opt_set MOTHERBOARD BOARD_RADDS NUM_Z_STEPPER_DRIVERS 3 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \ - Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS Z_SAFE_HOMING + Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_STEPPER_XY Z_SAFE_HOMING pins_set ramps/RAMPS X_MAX_PIN -1 pins_set ramps/RAMPS Y_MAX_PIN -1 exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3" From 6aee2c755bb0468df1672d566897f2c6becab597 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 2 Mar 2022 17:58:23 -0600 Subject: [PATCH 078/203] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Use=20seen=5Ftest?= =?UTF-8?q?=20in=20`M422`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/calibrate/G34_M422.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index fc4430885e..61e817fe94 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -486,9 +486,9 @@ void GcodeSuite::M422() { return; } - const bool is_probe_point = parser.seen('S'); + const bool is_probe_point = parser.seen_test('S'); - if (TERN0(HAS_Z_STEPPER_ALIGN_STEPPER_XY, is_probe_point && parser.seen('W'))) { + if (TERN0(HAS_Z_STEPPER_ALIGN_STEPPER_XY, is_probe_point && parser.seen_test('W'))) { SERIAL_ECHOLNPGM("?(S) and (W) may not be combined."); return; } @@ -498,7 +498,7 @@ void GcodeSuite::M422() { z_stepper_align.xy ); - if (!is_probe_point && TERN1(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !parser.seen('W'))) { + if (!is_probe_point && TERN1(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !parser.seen_test('W'))) { SERIAL_ECHOLNPGM("?(S)" TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, " or (W)") " is required."); return; } From 445c3c651463ab30ebd0348fde66e2bbaa0424cd Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 3 Mar 2022 00:27:06 +0000 Subject: [PATCH 079/203] [cron] Bump distribution date (2022-03-03) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 04cabb79e2..f3bc739f95 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-02" +//#define STRING_DISTRIBUTION_DATE "2022-03-03" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index e37cb894e2..7d9bd44b1f 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-02" + #define STRING_DISTRIBUTION_DATE "2022-03-03" #endif /** From 755c196cfa92fa1b9e139d39e83e490305822212 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 4 Mar 2022 15:18:27 -0600 Subject: [PATCH 080/203] =?UTF-8?q?=F0=9F=9A=B8=2012345.6=20num-to-string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 2 +- Marlin/src/lcd/menu/menu_item.h | 2 +- Marlin/src/libs/numtostr.cpp | 6 +++--- Marlin/src/libs/numtostr.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index cac8ffd6ac..c9a44e0c64 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -674,7 +674,7 @@ void MarlinUI::draw_status_screen() { #if CUTTER_UNIT_IS(PERCENT) lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #elif CUTTER_UNIT_IS(RPM) - lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr51rj(float(cutter.unitPower) / 1000)); + lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr61rj(float(cutter.unitPower) / 1000)); lcd_put_wchar('K'); #else lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 1834b56a88..fcde9f5801 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -150,7 +150,7 @@ DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); DEFINE_MENU_EDIT_ITEM_TYPE(float4 ,float ,ftostr4sign , 1 ); // 1234 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) -DEFINE_MENU_EDIT_ITEM_TYPE(float51 ,float ,ftostr51rj , 10 ); // 1234.5 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float61 ,float ,ftostr61rj , 10 ); // 12345.6 right-justified DEFINE_MENU_EDIT_ITEM_TYPE(float31sign ,float ,ftostr31sign , 10 ); // +12.3 DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 ); // +123.4 DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 ); // +1234.5 diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index 1e1ac05710..f4d47983d2 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -377,10 +377,10 @@ const char* ftostr53sign(const_float_t f) { return conv; } -// Convert unsigned float to string with ____4.5, __34.5, _234.5, 1234.5 format -const char* ftostr51rj(const_float_t f) { +// Convert unsigned float to string with ____5.6, ___45.6, __345.6, _2345.6, 12345.6 format +const char* ftostr61rj(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[0] = ' '; + conv[0] = RJDIGIT(i, 100000); conv[1] = RJDIGIT(i, 10000); conv[2] = RJDIGIT(i, 1000); conv[3] = RJDIGIT(i, 100); diff --git a/Marlin/src/libs/numtostr.h b/Marlin/src/libs/numtostr.h index b058f3cdf6..1704d35e88 100644 --- a/Marlin/src/libs/numtostr.h +++ b/Marlin/src/libs/numtostr.h @@ -113,8 +113,8 @@ const char* ftostr52sign(const_float_t x); // Convert signed float to string with +12.345 format const char* ftostr53sign(const_float_t f); -// Convert unsigned float to string with 1234.5 format omitting trailing zeros -const char* ftostr51rj(const_float_t x); +// Convert unsigned float to string with 12345.6 format omitting trailing zeros +const char* ftostr61rj(const_float_t x); // Convert float to rj string with 123 or -12 format FORCE_INLINE const char* ftostr3(const_float_t x) { return i16tostr3rj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } From 687dc9ad4d89212ec4da8983e71b8772c03a1619 Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Fri, 4 Mar 2022 21:57:51 +0000 Subject: [PATCH 081/203] =?UTF-8?q?=F0=9F=A9=B9=20Improve=20and=20apply=20?= =?UTF-8?q?XATC=20reset()=20(#23840)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/x_twist.cpp | 7 +++++-- Marlin/src/lcd/menu/menu_x_twist.cpp | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/x_twist.cpp b/Marlin/src/feature/x_twist.cpp index deac1bceba..8910091239 100644 --- a/Marlin/src/feature/x_twist.cpp +++ b/Marlin/src/feature/x_twist.cpp @@ -24,18 +24,21 @@ #if ENABLED(X_AXIS_TWIST_COMPENSATION) #include "x_twist.h" +#include "../module/probe.h" XATC xatc; -bool XATC::enabled = true; +bool XATC::enabled; float XATC::spacing, XATC::start; xatc_array_t XATC::z_offset; // Initialized by settings.load() void XATC::reset() { constexpr float xzo[] = XATC_Z_OFFSETS; static_assert(COUNT(xzo) == XATC_MAX_POINTS, "XATC_Z_OFFSETS is the wrong size."); - enabled = false; COPY(z_offset, xzo); + xatc.spacing = (probe.max_x() - probe.min_x()) / (XATC_MAX_POINTS - 1); + xatc.start = probe.min_x(); + enabled = true; } void XATC::print_points() { diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp index ca385ebfeb..93f8de07ad 100644 --- a/Marlin/src/lcd/menu/menu_x_twist.cpp +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -189,8 +189,7 @@ void xatc_wizard_homing_done() { } if (ui.use_click()) { - xatc.spacing = (probe.max_x() - probe.min_x()) / (XATC_MAX_POINTS - 1); - xatc.start = probe.min_x(); + xatc.reset(); SET_SOFT_ENDSTOP_LOOSE(true); // Disable soft endstops for free Z movement From 0e1ecf1fe0868d5467aa8b61feeac22a857db6ec Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Fri, 4 Mar 2022 21:59:38 +0000 Subject: [PATCH 082/203] =?UTF-8?q?=F0=9F=90=9B=20Emergency=20Parser=20wit?= =?UTF-8?q?h=20STM32=20Mass=20Storage=20(#23827)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/STM32/HAL.cpp | 2 +- Marlin/src/HAL/STM32/usb_serial.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index 324a78316a..d28f506db9 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -89,7 +89,7 @@ void MarlinHAL::init() { SetTimerInterruptPriorities(); - #if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC + #if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC) USB_Hook_init(); #endif diff --git a/Marlin/src/HAL/STM32/usb_serial.cpp b/Marlin/src/HAL/STM32/usb_serial.cpp index b607275db5..0b2372f3a7 100644 --- a/Marlin/src/HAL/STM32/usb_serial.cpp +++ b/Marlin/src/HAL/STM32/usb_serial.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC +#if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC) #include "usb_serial.h" #include "../../feature/e_parser.h" From 87e19fe5e714feaebea4f91f6dbc8324d0eecc3f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 4 Mar 2022 16:07:38 -0600 Subject: [PATCH 083/203] =?UTF-8?q?=F0=9F=94=A7=20Mark=20Thermal=20Varianc?= =?UTF-8?q?e=20Monitor=20EXPERIMENTAL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 55857f5dec..2cccfce054 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -347,7 +347,11 @@ #endif #if ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_COOLER) - #define THERMAL_PROTECTION_VARIANCE_MONITOR // Detect a sensor malfunction preventing temperature updates + /** + * Thermal Protection Variance Monitor - EXPERIMENTAL. + * Kill the machine on a stuck temperature sensor. Disable if you get false positives. + */ + //#define THERMAL_PROTECTION_VARIANCE_MONITOR // Detect a sensor malfunction preventing temperature updates #endif #if ENABLED(PIDTEMP) From d2c503eea2b5373fa8af6577c8047014966ce0f4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 4 Mar 2022 16:55:01 -0600 Subject: [PATCH 084/203] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20num-to-string=20fo?= =?UTF-8?q?llowup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_advanced.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index d2c9b30c04..1bc9b9e88e 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -523,7 +523,7 @@ void menu_advanced_steps_per_mm() { START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - #define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float51, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); }) + #define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float61, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); }) LINEAR_AXIS_CODE( EDIT_QSTEPS(A), EDIT_QSTEPS(B), EDIT_QSTEPS(C), EDIT_QSTEPS(I), EDIT_QSTEPS(J), EDIT_QSTEPS(K) @@ -531,7 +531,7 @@ void menu_advanced_steps_per_mm() { #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ + EDIT_ITEM_FAST_N(float61, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ const uint8_t e = MenuItemBase::itemIndex; if (e == active_extruder) planner.refresh_positioning(); @@ -539,7 +539,7 @@ void menu_advanced_steps_per_mm() { planner.mm_per_step[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)]; }); #elif E_STEPPERS - EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); + EDIT_ITEM_FAST(float61, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); #endif END_MENU(); From 323ac9488ce0562611d0144ab8ba700d272c00c7 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 5 Mar 2022 00:25:32 +0000 Subject: [PATCH 085/203] [cron] Bump distribution date (2022-03-05) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index f3bc739f95..bd05df75c0 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-03" +//#define STRING_DISTRIBUTION_DATE "2022-03-05" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 7d9bd44b1f..4af25302be 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-03" + #define STRING_DISTRIBUTION_DATE "2022-03-05" #endif /** From c6a6d35f0dd4a8fa7b3fae30892df96b8f0f50ee Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Thu, 10 Mar 2022 15:20:13 -0800 Subject: [PATCH 086/203] =?UTF-8?q?=F0=9F=9A=B8=20TH3D=20EZBoard=20V2=20TM?= =?UTF-8?q?C=20slave=20addresses=20(#23857)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h index bd4798209e..fd6b960542 100644 --- a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h +++ b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h @@ -130,6 +130,20 @@ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif #endif // From 4b84b28c1435ff4520e0f8078f0a061aa27f6884 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 10 Mar 2022 17:25:09 -0600 Subject: [PATCH 087/203] =?UTF-8?q?=F0=9F=9A=B8=20Improve=20M422=20error?= =?UTF-8?q?=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/calibrate/G34_M422.cpp | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 61e817fe94..d1f82e7e98 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -493,7 +493,7 @@ void GcodeSuite::M422() { return; } - xy_pos_t *pos_dest = ( + xy_pos_t * const pos_dest = ( TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !is_probe_point ? z_stepper_align.stepper_xy :) z_stepper_align.xy ); @@ -504,24 +504,25 @@ void GcodeSuite::M422() { } // Get the Probe Position Index or Z Stepper Index - int8_t position_index; - if (is_probe_point) { - position_index = parser.intval('S') - 1; - if (!WITHIN(position_index, 0, int8_t(NUM_Z_STEPPER_DRIVERS) - 1)) { - SERIAL_ECHOLNPGM("?(S) Probe-position index invalid."); - return; - } - } + int8_t position_index = 1; + FSTR_P err_string = F("?(S) Probe-position"); + if (is_probe_point) + position_index = parser.intval('S'); else { #if HAS_Z_STEPPER_ALIGN_STEPPER_XY - position_index = parser.intval('W') - 1; - if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) { - SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid."); - return; - } + err_string = F("?(W) Z-stepper"); + position_index = parser.intval('W'); #endif } + if (!WITHIN(position_index, 1, NUM_Z_STEPPER_DRIVERS)) { + SERIAL_ECHOF(err_string); + SERIAL_ECHOLNPGM(" index invalid (1.." STRINGIFY(NUM_Z_STEPPER_DRIVERS) ")."); + return; + } + + --position_index; + const xy_pos_t pos = { parser.floatval('X', pos_dest[position_index].x), parser.floatval('Y', pos_dest[position_index].y) From 813b6af7247113d0cd96f4bf71c0c1a980590219 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 10 Mar 2022 17:35:03 -0600 Subject: [PATCH 088/203] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20'hdsl'=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/settings.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index fed1f67755..cd71344389 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3203,9 +3203,11 @@ void MarlinSettings::reset() { postprocess(); - FSTR_P const hdsl = F("Hardcoded Default Settings Loaded"); - TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(hdsl)); - DEBUG_ECHO_START(); DEBUG_ECHOLNF(hdsl); + #if EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) + FSTR_P const hdsl = F("Hardcoded Default Settings Loaded"); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(hdsl)); + DEBUG_ECHO_START(); DEBUG_ECHOLNF(hdsl); + #endif TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); } From 4e467e98c4c513faeea9f73a7c83f1bc1c7b8170 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 11 Mar 2022 00:28:58 +0000 Subject: [PATCH 089/203] [cron] Bump distribution date (2022-03-11) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index bd05df75c0..3bc9da0b3f 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-05" +//#define STRING_DISTRIBUTION_DATE "2022-03-11" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 4af25302be..07f09590b6 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-05" + #define STRING_DISTRIBUTION_DATE "2022-03-11" #endif /** From 48b5362cf02ff12c9e9fc4d5825ceebe457ea34b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 10 Mar 2022 22:07:47 -0600 Subject: [PATCH 090/203] =?UTF-8?q?=F0=9F=94=A7=20DWIN=5FCREALITY=5FLCD=5F?= =?UTF-8?q?ENHANCED=20=3D>=20DWIN=5FLCD=5FPROUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23624 --- Marlin/Configuration.h | 2 +- Marlin/Configuration_adv.h | 4 ++-- Marlin/src/MarlinCore.cpp | 4 ++-- Marlin/src/feature/pause.cpp | 10 ++++----- Marlin/src/feature/runout.cpp | 4 ++-- Marlin/src/gcode/bedlevel/abl/G29.cpp | 6 +++--- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 4 ++-- Marlin/src/gcode/bedlevel/ubl/M421.cpp | 4 ++-- Marlin/src/gcode/calibrate/G28.cpp | 2 +- Marlin/src/gcode/control/M997.cpp | 4 ++-- Marlin/src/gcode/feature/powerloss/M1000.cpp | 2 +- Marlin/src/gcode/lcd/M0_M1.cpp | 4 ++-- Marlin/src/gcode/lcd/M73.cpp | 4 ++-- Marlin/src/gcode/sd/M1001.cpp | 4 ++-- Marlin/src/gcode/stats/M75-M78.cpp | 6 +++--- Marlin/src/gcode/temp/M303.cpp | 6 +++--- Marlin/src/inc/Conditionals_LCD.h | 4 ++-- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 22 +++++++++++--------- Marlin/src/lcd/e3v2/proui/dwin.cpp | 4 ++-- Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp | 4 ++-- Marlin/src/lcd/e3v2/proui/dwin_popup.cpp | 4 ++-- Marlin/src/lcd/e3v2/proui/dwinui.cpp | 4 ++-- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 4 ++-- Marlin/src/lcd/e3v2/proui/lockscreen.cpp | 4 ++-- Marlin/src/lcd/e3v2/proui/meshviewer.cpp | 4 ++-- Marlin/src/lcd/e3v2/proui/printstats.cpp | 4 ++-- Marlin/src/lcd/marlinui.cpp | 8 +++---- Marlin/src/lcd/marlinui.h | 8 +++---- Marlin/src/module/probe.cpp | 4 ++-- Marlin/src/module/settings.cpp | 14 ++++++------- Marlin/src/module/temperature.cpp | 14 ++++++------- Marlin/src/sd/cardreader.cpp | 2 +- buildroot/tests/STM32F103RE_creality | 4 ++-- ini/features.ini | 2 +- 35 files changed, 94 insertions(+), 92 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7162e74acb..c2d5dced28 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2807,7 +2807,7 @@ // Ender-3 v2 OEM display. A DWIN display with Rotary Encoder. // //#define DWIN_CREALITY_LCD // Creality UI -//#define DWIN_CREALITY_LCD_ENHANCED // Enhanced UI +//#define DWIN_LCD_PROUI // Pro UI by MRiscoC //#define DWIN_CREALITY_LCD_JYERSUI // Jyers UI by Jacob Myers //#define DWIN_MARLINUI_PORTRAIT // MarlinUI (portrait orientation) //#define DWIN_MARLINUI_LANDSCAPE // MarlinUI (landscape orientation) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2cccfce054..04a8d63ef7 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1335,11 +1335,11 @@ #endif // HAS_MARLINUI_MENU -#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI) +#if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) //#define SOUND_MENU_ITEM // Add a mute option to the LCD menu #endif -#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) +#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) // The timeout (in ms) to return to the status screen from sub-menus //#define LCD_TIMEOUT_TO_STATUS 15000 diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 81dc7db4cc..cc928baff9 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -74,7 +74,7 @@ #include "lcd/e3v2/common/encoder.h" #if ENABLED(DWIN_CREALITY_LCD) #include "lcd/e3v2/creality/dwin.h" - #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #elif ENABLED(DWIN_LCD_PROUI) #include "lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "lcd/e3v2/jyersui/dwin.h" @@ -878,7 +878,7 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp // Echo the LCD message to serial for extra context if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); } - #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR)); #else UNUSED(lcd_error); UNUSED(lcd_component); diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 69c25cbe33..79780021cf 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -57,7 +57,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" #endif @@ -281,7 +281,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load // Show "Purge More" / "Resume" menu and wait for reply KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = false; - #if EITHER(HAS_MARLINUI_MENU, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) ui.pause_show_message(PAUSE_MESSAGE_OPTION); // Also sets PAUSE_RESPONSE_WAIT_FOR #else pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; @@ -549,7 +549,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(GET_TEXT_F(MSG_REHEATING))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATING)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATING)); // Re-enable the heaters if they timed out HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e); @@ -567,7 +567,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_REHEATDONE), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_REHEATDONE))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATDONE)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATDONE)); IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true); @@ -711,7 +711,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); TERN_(HAS_MARLINUI_MENU, ui.return_to_status()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, HMI_ReturnScreen()); + TERN_(DWIN_LCD_PROUI, HMI_ReturnScreen()); } #endif // ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 8b78b53848..98b6bd0510 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -68,7 +68,7 @@ bool FilamentMonitorBase::enabled = true, #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" #endif @@ -88,7 +88,7 @@ void event_filament_runout(const uint8_t extruder) { #endif TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getTool(extruder))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_FilamentRunout(extruder)); + TERN_(DWIN_LCD_PROUI, DWIN_FilamentRunout(extruder)); #if ANY(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS, MULTI_FILAMENT_SENSOR) const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, extruder); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 20f2369b03..a65d844771 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -55,7 +55,7 @@ #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../../../lcd/e3v2/proui/dwin.h" #endif @@ -427,7 +427,7 @@ G29_TYPE GcodeSuite::G29() { points[0].z = points[1].z = points[2].z = 0; // Probe at 3 arbitrary points #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshLevelingStart()); + TERN_(DWIN_LCD_PROUI, DWIN_MeshLevelingStart()); #endif if (!faux) { @@ -721,7 +721,7 @@ G29_TYPE GcodeSuite::G29() { #endif // AUTO_BED_LEVELING_3POINT - TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); + ui.reset_status(); // Stow the probe. No raise for FIX_MOUNTED_PROBE. if (probe.stow()) { diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 4ffeec6eec..309d21fe53 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -40,7 +40,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../../../lcd/e3v2/proui/dwin.h" #endif @@ -193,7 +193,7 @@ void GcodeSuite::G29() { if (parser.seenval('Z')) { mbl.z_values[ix][iy] = parser.value_linear_units(); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy])); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ix, iy, mbl.z_values[ix][iy])); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(ix, iy, mbl.z_values[ix][iy])); } else return echo_not_entered('Z'); diff --git a/Marlin/src/gcode/bedlevel/ubl/M421.cpp b/Marlin/src/gcode/bedlevel/ubl/M421.cpp index ac6f97b00a..c11a20ebf3 100644 --- a/Marlin/src/gcode/bedlevel/ubl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/M421.cpp @@ -33,7 +33,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../../../lcd/e3v2/proui/dwin.h" #endif @@ -69,7 +69,7 @@ void GcodeSuite::M421() { float &zval = ubl.z_values[ij.x][ij.y]; // Altering this Mesh Point zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); // N=NAN, Z=NEWVAL, or Q=ADDVAL TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval)); // Ping ExtUI in case it's showing the mesh - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ij.x, ij.y, zval)); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(ij.x, ij.y, zval)); } } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 4d8891d55b..dbbea79353 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -51,7 +51,7 @@ #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" #endif diff --git a/Marlin/src/gcode/control/M997.cpp b/Marlin/src/gcode/control/M997.cpp index 359172faad..74ed8b0d07 100644 --- a/Marlin/src/gcode/control/M997.cpp +++ b/Marlin/src/gcode/control/M997.cpp @@ -24,7 +24,7 @@ #if ENABLED(PLATFORM_M997_SUPPORT) -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" #endif @@ -33,7 +33,7 @@ */ void GcodeSuite::M997() { - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_RebootScreen()); + TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen()); flashFirmware(parser.intval('S')); diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index 6fb99226ce..1629a154bc 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -33,7 +33,7 @@ #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../../../lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../../../lcd/e3v2/jyersui/dwin.h" // Temporary fix until it can be better implemented diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index a9223dda47..af03fcb0b1 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -35,7 +35,7 @@ #include "../../lcd/marlinui.h" #elif ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin_popup.h" #include "../../lcd/e3v2/proui/dwin.h" #endif @@ -71,7 +71,7 @@ void GcodeSuite::M0_M1() { ExtUI::onUserConfirmRequired(parser.string_arg); // String in an SRAM buffer else ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_USERWAIT)); - #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #elif ENABLED(DWIN_LCD_PROUI) if (parser.string_arg) DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT)); else diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index c2c5485072..355445c573 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -28,7 +28,7 @@ #include "../../lcd/marlinui.h" #include "../../sd/cardreader.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" #endif @@ -40,7 +40,7 @@ */ void GcodeSuite::M73() { - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) DWIN_Progress_Update(); diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 1579efd555..87de89a682 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -49,7 +49,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" #endif @@ -109,7 +109,7 @@ void GcodeSuite::M1001() { #endif TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished()); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); // Re-select the last printed file in the UI TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file()); diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 368edb65d9..01630adc50 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -29,7 +29,7 @@ #include "../../MarlinCore.h" // for startOrResumeJob -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" #endif @@ -38,7 +38,7 @@ */ void GcodeSuite::M75() { startOrResumeJob(); - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); DWIN_Print_Started(false); #endif @@ -57,7 +57,7 @@ void GcodeSuite::M76() { */ void GcodeSuite::M77() { print_job_timer.stop(); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished()); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); } #if ENABLED(PRINTCOUNTER) diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index 7b56eb2d6b..c1e400511c 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -30,7 +30,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" #endif @@ -73,7 +73,7 @@ void GcodeSuite::M303() { default: SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); return; } @@ -83,7 +83,7 @@ void GcodeSuite::M303() { const celsius_t temp = seenS ? parser.value_celsius() : default_temp; const bool u = parser.boolval('U'); - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) if (seenC) HMI_data.PidCycles = c; if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; } #endif diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 34a160fc5c..9d9fddc8c1 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -473,7 +473,7 @@ #endif // Aliases for LCD features -#if EITHER(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED) +#if EITHER(DWIN_CREALITY_LCD, DWIN_LCD_PROUI) #define HAS_DWIN_E3V2_BASIC 1 #endif #if EITHER(HAS_DWIN_E3V2_BASIC, DWIN_CREALITY_LCD_JYERSUI) @@ -494,7 +494,7 @@ #endif #define HAS_LCD_BRIGHTNESS 1 #define LCD_BRIGHTNESS_MAX 250 - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) #define LCD_BRIGHTNESS_DEFAULT 127 #endif #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index fa273cd32e..547ca36e92 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3177,7 +3177,7 @@ * Advanced Pause - Filament Change */ #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) + #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) #define M600_PURGE_MORE_RESUMABLE 1 #endif #ifndef FILAMENT_CHANGE_SLOW_LOAD_LENGTH diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index e8abf1b286..83d37f22df 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -615,6 +615,8 @@ #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 2." #elif defined(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS is now just Z_STEPPER_ALIGN_STEPPER_XY." +#elif defined(DWIN_CREALITY_LCD_ENHANCED) + #error "DWIN_CREALITY_LCD_ENHANCED is now DWIN_LCD_PROUI." #endif constexpr float arm[] = AXIS_RELATIVE_MODES; @@ -846,7 +848,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." #endif #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) - #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." + #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." #endif #if ENABLED(USE_M73_REMAINING_TIME) && DISABLED(LCD_SET_PROGRESS_MANUALLY) @@ -1830,7 +1832,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * LCD_BED_LEVELING requirements */ #if ENABLED(LCD_BED_LEVELING) - #if NONE(HAS_MARLINUI_MENU, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if NONE(HAS_MARLINUI_MENU, DWIN_CREALITY_LCD, DWIN_LCD_PROUI) #error "LCD_BED_LEVELING is not supported by the selected LCD controller." #elif !(ENABLED(MESH_BED_LEVELING) || HAS_ABL_NOT_UBL) #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or AUTO_BED_LEVELING." @@ -2719,7 +2721,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \ + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) \ + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \ - + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \ + + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \ + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_GENERIC_12864_1_1) \ + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \ + COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \ @@ -2849,17 +2851,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY) #error "DWIN_CREALITY_LCD does not support LCD_BED_LEVELING with PROBE_MANUALLY." #endif -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #if DISABLED(SDSUPPORT) - #error "DWIN_CREALITY_LCD_ENHANCED requires SDSUPPORT to be enabled." + #error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled." #elif ENABLED(PID_EDIT_MENU) - #error "DWIN_CREALITY_LCD_ENHANCED does not support PID_EDIT_MENU." + #error "DWIN_LCD_PROUI does not support PID_EDIT_MENU." #elif ENABLED(PID_AUTOTUNE_MENU) - #error "DWIN_CREALITY_LCD_ENHANCED does not support PID_AUTOTUNE_MENU." + #error "DWIN_LCD_PROUI does not support PID_AUTOTUNE_MENU." #elif ENABLED(LEVEL_BED_CORNERS) - #error "DWIN_CREALITY_LCD_ENHANCED does not support LEVEL_BED_CORNERS." + #error "DWIN_LCD_PROUI does not support LEVEL_BED_CORNERS." #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY) - #error "DWIN_CREALITY_LCD_ENHANCED does not support LCD_BED_LEVELING with PROBE_MANUALLY." + #error "DWIN_LCD_PROUI does not support LCD_BED_LEVELING with PROBE_MANUALLY." #endif #endif @@ -3438,7 +3440,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel." #endif -#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) #error "LED_CONTROL_MENU requires an LCD controller that implements the menu." #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 5af7fc294d..9e08854aed 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -31,7 +31,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "dwin.h" #include "dwin_popup.h" @@ -3974,4 +3974,4 @@ void Draw_Steps_Menu() { } #endif -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp index 105f1aaf1c..b8bff35159 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp @@ -31,7 +31,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../inc/MarlinConfig.h" @@ -159,4 +159,4 @@ void DWIN_SRAMToPic(uint8_t picID) { // DWIN_Send(i); //} -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp index 34b05328d7..33f216fde6 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -31,7 +31,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "dwin.h" #include "dwin_popup.h" @@ -60,4 +60,4 @@ void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) { DWIN_UpdateLCD(); } -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index d3cfc9a3e4..1dbd531390 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -31,7 +31,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../inc/MarlinConfig.h" #include "dwin_lcd.h" @@ -453,4 +453,4 @@ MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, void value = val; }; -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 6232c89534..f04c079017 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -32,7 +32,7 @@ #include "../../../inc/MarlinConfigPre.h" #include "dwin_defines.h" -#if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_ESDIAG) +#if BOTH(DWIN_LCD_PROUI, HAS_ESDIAG) #include "endstop_diag.h" @@ -108,4 +108,4 @@ void ESDiagClass::Update() { DWIN_UpdateLCD(); } -#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_ESDIAG +#endif // DWIN_LCD_PROUI && HAS_ESDIAG diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp index 3f8339ad48..2ccdcc1207 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -31,7 +31,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../core/types.h" #include "dwin_lcd.h" @@ -75,4 +75,4 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) { DWIN_UpdateLCD(); } -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index 0f63f77b99..275a29cd38 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -31,7 +31,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_MESH) +#if BOTH(DWIN_LCD_PROUI, HAS_MESH) #include "meshviewer.h" @@ -109,4 +109,4 @@ void MeshViewerClass::Draw() { ); } -#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_MESH +#endif // DWIN_LCD_PROUI && HAS_MESH diff --git a/Marlin/src/lcd/e3v2/proui/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp index ec14ebb8bf..54c87f4be1 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.cpp +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -31,7 +31,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if BOTH(DWIN_CREALITY_LCD_ENHANCED, PRINTCOUNTER) +#if BOTH(DWIN_LCD_PROUI, PRINTCOUNTER) #include "printstats.h" @@ -75,4 +75,4 @@ void PrintStatsClass::Reset() { HMI_AudioFeedback(); } -#endif // DWIN_CREALITY_LCD_ENHANCED && PRINTCOUNTER +#endif // DWIN_LCD_PROUI && PRINTCOUNTER diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index d2884cc3f1..810d0db527 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -47,7 +47,7 @@ MarlinUI ui; #if ENABLED(DWIN_CREALITY_LCD) #include "e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "fontutils.h" #include "e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) @@ -69,7 +69,7 @@ MarlinUI ui; constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_STATUS_MESSAGE - #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) uint8_t MarlinUI::status_scroll_offset; // = 0 #endif char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; @@ -1522,13 +1522,13 @@ void MarlinUI::init() { #endif - #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) status_scroll_offset = 0; #endif TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message)); TERN_(DWIN_CREALITY_LCD, DWIN_StatusChanged(status_message)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_CheckStatusMessage()); + TERN_(DWIN_LCD_PROUI, DWIN_CheckStatusMessage()); TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Update_Status(status_message)); } diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 15e9f73d65..36cbb14c5c 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -57,7 +57,7 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "e3v2/proui/dwin.h" #endif @@ -333,7 +333,7 @@ public: #if HAS_STATUS_MESSAGE - #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) #if ENABLED(STATUS_MESSAGE_SCROLLING) #define MAX_MESSAGE_LENGTH _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH)) #else @@ -367,7 +367,7 @@ public: static void set_status(FSTR_P const fstr, const int8_t level=0); static void status_printf(const uint8_t level, FSTR_P const fmt, ...); - #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); #if DISABLED(LIGHTWEIGHT_UI) static void draw_status_message(const bool blink); @@ -619,7 +619,7 @@ public: static bool use_click() { return false; } #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI) + #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder); #else static void _pause_show_message() {} diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 89d2769247..8793ea49dc 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -87,7 +87,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" #endif @@ -316,7 +316,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe"))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR))); + TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.reset_status(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index cd71344389..e0b2eccbbd 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -74,7 +74,7 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../lcd/e3v2/jyersui/dwin.h" @@ -487,7 +487,7 @@ typedef struct SettingsDataStruct { // // Ender-3 V2 DWIN // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) uint8_t dwin_data[eeprom_data_size]; #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) uint8_t dwin_settings[CrealityDWIN.eeprom_data_size]; @@ -1465,7 +1465,7 @@ void MarlinSettings::postprocess() { // // Creality DWIN User Data // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) { char dwin_data[eeprom_data_size] = { 0 }; DWIN_StoreSettings(dwin_data); @@ -1610,7 +1610,7 @@ void MarlinSettings::postprocess() { stored_ver[1] = '\0'; } DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_VERSION)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_ERR_EEPROM_VERSION)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_VERSION))); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version()); @@ -2408,7 +2408,7 @@ void MarlinSettings::postprocess() { // // Creality DWIN User Data // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) { const char dwin_data[eeprom_data_size] = { 0 }; _FIELD_TEST(dwin_data); @@ -2512,7 +2512,7 @@ void MarlinSettings::postprocess() { else if (working_crc != stored_crc) { eeprom_error = true; DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_CRC)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_ERR_EEPROM_CRC)); TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_CRC))); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc()); } @@ -2830,7 +2830,7 @@ void MarlinSettings::reset() { #endif #endif - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_SetDataDefaults()); + TERN_(DWIN_LCD_PROUI, DWIN_SetDataDefaults()); TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Reset_Settings()); // diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 19501bce6e..4adf968919 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -51,7 +51,7 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" #endif @@ -623,12 +623,12 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(HAS_FAN_LOGIC, fan_update_ms = next_temp_ms + fan_update_interval_ms); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); return; } @@ -719,7 +719,7 @@ volatile bool Temperature::raw_temps_ready = false; if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) { SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); break; } @@ -756,7 +756,7 @@ volatile bool Temperature::raw_temps_ready = false; #endif if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) { TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TUNING_TIMEOUT)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT))); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); @@ -812,7 +812,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_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); goto EXIT_M303; } @@ -830,7 +830,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_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); EXIT_M303: TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true); diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 9966773418..41ec44d4b7 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -33,7 +33,7 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" #endif diff --git a/buildroot/tests/STM32F103RE_creality b/buildroot/tests/STM32F103RE_creality index 257616ddd1..6a15ec1221 100755 --- a/buildroot/tests/STM32F103RE_creality +++ b/buildroot/tests/STM32F103RE_creality @@ -15,8 +15,8 @@ exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD -opt_enable DWIN_CREALITY_LCD_ENHANCED BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING BAUD_RATE_GCODE -exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3" +opt_enable DWIN_LCD_PROUI BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING BAUD_RATE_GCODE +exec_test $1 $2 "Ender 3 v2 with Pro UI" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD diff --git a/ini/features.ini b/ini/features.ini index 4d394e0901..9a68f2470f 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -47,7 +47,7 @@ SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https:/ SPI_EEPROM = src_filter=+ HAS_DWIN_E3V2|IS_DWIN_MARLINUI = src_filter=+ DWIN_CREALITY_LCD = src_filter=+ -DWIN_CREALITY_LCD_ENHANCED = src_filter=+ +DWIN_LCD_PROUI = src_filter=+ DWIN_CREALITY_LCD_JYERSUI = src_filter=+ IS_DWIN_MARLINUI = src_filter=+ HAS_GRAPHICAL_TFT = src_filter=+ From b9ef0f486a91ac918ef3605ab76d298b3e09d49b Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 11 Mar 2022 21:52:35 +1300 Subject: [PATCH 091/203] =?UTF-8?q?=F0=9F=93=9D=20Update=20laser/spindle?= =?UTF-8?q?=20docs=20link=20(#23886)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 04a8d63ef7..83a8eaa0fb 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3455,7 +3455,7 @@ * You'll need to select a pin for the ON/OFF function and optionally choose a 0-5V * hardware PWM pin for the speed control and a pin for the rotation direction. * - * See https://marlinfw.org/docs/configuration/laser_spindle.html for more config details. + * See https://marlinfw.org/docs/configuration/2.0.9/laser_spindle.html for more config details. */ //#define SPINDLE_FEATURE //#define LASER_FEATURE From f516c9e5528c67b1fd3119fd9910e0f14ae267f2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 11 Mar 2022 02:56:24 -0600 Subject: [PATCH 092/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20UI=20include?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to ~2 --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a65d844771..68d8ecc26b 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -36,10 +36,6 @@ #include "../../../module/probe.h" #include "../../queue.h" -#if HAS_STATUS_MESSAGE - #include "../../../lcd/marlinui.h" -#endif - #if ENABLED(AUTO_BED_LEVELING_LINEAR) #include "../../../libs/least_squares_fit.h" #endif @@ -48,9 +44,7 @@ #include "../../../libs/vector_3.h" #endif -#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) -#include "../../../core/debug_out.h" - +#include "../../../lcd/marlinui.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) @@ -63,6 +57,9 @@ #include "../../../module/tool_change.h" #endif +#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +#include "../../../core/debug_out.h" + #if ABL_USES_GRID #if ENABLED(PROBE_Y_FIRST) #define PR_OUTER_VAR abl.meshCount.x From bd3ecc3ea07aaca3ad60441f64654b407f028714 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 12 Mar 2022 03:51:25 +1300 Subject: [PATCH 093/203] fix g29 (#23887) --- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 68d8ecc26b..33f45e1c9f 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -718,7 +718,7 @@ G29_TYPE GcodeSuite::G29() { #endif // AUTO_BED_LEVELING_3POINT - ui.reset_status(); + TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); // Stow the probe. No raise for FIX_MOUNTED_PROBE. if (probe.stow()) { From 79b38e0e14074b52e0aeb98b08a686a99a9b1aad Mon Sep 17 00:00:00 2001 From: Miguel Risco-Castillo Date: Fri, 11 Mar 2022 15:06:49 -0500 Subject: [PATCH 094/203] =?UTF-8?q?=F0=9F=9A=B8=20Update=20Ender3=20V2/S1?= =?UTF-8?q?=20Pro=20UI=20(#23878)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 8 +- Marlin/src/feature/pause.cpp | 3 +- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 2 + Marlin/src/gcode/config/M302.cpp | 5 + Marlin/src/gcode/sd/M524.cpp | 20 +- Marlin/src/gcode/stats/M75-M78.cpp | 3 +- Marlin/src/inc/Conditionals_LCD.h | 5 +- Marlin/src/lcd/e3v2/common/encoder.h | 20 + Marlin/src/lcd/e3v2/creality/dwin.cpp | 25 +- Marlin/src/lcd/e3v2/creality/dwin.h | 1 + Marlin/src/lcd/e3v2/proui/dwin.cpp | 1444 +++++++---------- Marlin/src/lcd/e3v2/proui/dwin.h | 100 +- Marlin/src/lcd/e3v2/proui/dwin_defines.h | 43 +- Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp | 56 +- Marlin/src/lcd/e3v2/proui/dwin_lcd.h | 26 +- Marlin/src/lcd/e3v2/proui/dwin_popup.cpp | 60 +- Marlin/src/lcd/e3v2/proui/dwin_popup.h | 27 +- Marlin/src/lcd/e3v2/proui/dwinui.cpp | 119 +- Marlin/src/lcd/e3v2/proui/dwinui.h | 126 +- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 11 +- Marlin/src/lcd/e3v2/proui/endstop_diag.h | 8 +- Marlin/src/lcd/e3v2/proui/lockscreen.cpp | 4 +- Marlin/src/lcd/e3v2/proui/lockscreen.h | 4 +- Marlin/src/lcd/e3v2/proui/menus.cpp | 370 +++++ Marlin/src/lcd/e3v2/proui/menus.h | 94 ++ Marlin/src/lcd/e3v2/proui/meshviewer.cpp | 68 +- Marlin/src/lcd/e3v2/proui/meshviewer.h | 17 +- Marlin/src/lcd/e3v2/proui/printstats.cpp | 16 +- Marlin/src/lcd/e3v2/proui/printstats.h | 12 +- Marlin/src/lcd/language/language_en.h | 6 +- Marlin/src/lcd/marlinui.cpp | 7 +- Marlin/src/lcd/marlinui.h | 14 +- Marlin/src/module/settings.cpp | 8 +- Marlin/src/module/stepper.cpp | 3 + Marlin/src/module/temperature.cpp | 2 +- .../stm32f1/pins_BTT_SKR_MINI_E3_common.h | 2 +- .../pins/stm32f1/pins_CREALITY_V24S1_301.h | 26 +- Marlin/src/sd/cardreader.cpp | 11 +- Marlin/src/sd/cardreader.h | 7 + buildroot/tests/STM32F103RE_creality | 5 +- 40 files changed, 1577 insertions(+), 1211 deletions(-) create mode 100644 Marlin/src/lcd/e3v2/proui/menus.cpp create mode 100644 Marlin/src/lcd/e3v2/proui/menus.h diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index cc928baff9..4117d3f382 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -822,7 +822,7 @@ void idle(bool no_stepper_sleep/*=false*/) { TERN_(USE_BEEPER, buzzer.tick()); // Handle UI input / draw events - TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update()); + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); // Run i2c Position Encoders #if ENABLED(I2C_POSITION_ENCODERS) @@ -1571,11 +1571,7 @@ void setup() { #endif #if HAS_DWIN_E3V2_BASIC - SETUP_LOG("E3V2 Init"); - Encoder_Configuration(); - HMI_Init(); - HMI_SetLanguageCache(); - HMI_StartFrame(true); + SETUP_RUN(DWIN_InitScreen()); #endif #if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 79780021cf..636ac32042 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -407,6 +407,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool #endif TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR))); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); // Indicate that the printer is paused ++did_pause_print; @@ -709,7 +710,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HAS_FILAMENT_SENSOR, runout.reset()); - TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); + TERN(DWIN_LCD_PROUI, DWIN_Print_Resume(), ui.reset_status()); TERN_(HAS_MARLINUI_MENU, ui.return_to_status()); TERN_(DWIN_LCD_PROUI, HMI_ReturnScreen()); } diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 309d21fe53..3767cef3cf 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -105,6 +105,7 @@ void GcodeSuite::G29() { if (!ui.wait_for_move) { queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2")); TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); + TERN_(DWIN_LCD_PROUI, DWIN_MeshLevelingStart()); return; } state = MeshNext; @@ -127,6 +128,7 @@ void GcodeSuite::G29() { // Save Z for the previous mesh position mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z)); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(_MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS), current_position.z)); SET_SOFT_ENDSTOP_LOOSE(false); } // If there's another point to sample, move there with optional lift. diff --git a/Marlin/src/gcode/config/M302.cpp b/Marlin/src/gcode/config/M302.cpp index e271dcd469..9f4d569d7b 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -27,6 +27,10 @@ #include "../gcode.h" #include "../../module/temperature.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin_defines.h" +#endif + /** * M302: Allow cold extrudes, or set the minimum extrude temperature * @@ -47,6 +51,7 @@ void GcodeSuite::M302() { if (seen_S) { thermalManager.extrude_min_temp = parser.value_celsius(); thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0); + TERN_(DWIN_LCD_PROUI, HMI_data.ExtMinT = thermalManager.extrude_min_temp); } if (parser.seen('P')) diff --git a/Marlin/src/gcode/sd/M524.cpp b/Marlin/src/gcode/sd/M524.cpp index e715915565..001a1e1842 100644 --- a/Marlin/src/gcode/sd/M524.cpp +++ b/Marlin/src/gcode/sd/M524.cpp @@ -27,15 +27,27 @@ #include "../gcode.h" #include "../../sd/cardreader.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" +#endif + /** * M524: Abort the current SD print job (started with M24) */ void GcodeSuite::M524() { - if (IS_SD_PRINTING()) - card.abortFilePrintSoon(); - else if (card.isMounted()) - card.closefile(); + #if ENABLED(DWIN_LCD_PROUI) + + HMI_flag.abort_flag = true; // The LCD will handle it + + #else + + if (IS_SD_PRINTING()) + card.abortFilePrintSoon(); + else if (card.isMounted()) + card.closefile(); + + #endif } diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 01630adc50..0ed1e66930 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -39,8 +39,8 @@ void GcodeSuite::M75() { startOrResumeJob(); #if ENABLED(DWIN_LCD_PROUI) - DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); DWIN_Print_Started(false); + if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); #endif } @@ -50,6 +50,7 @@ void GcodeSuite::M75() { void GcodeSuite::M76() { print_job_timer.pause(); TERN_(HOST_PAUSE_M76, hostui.pause()); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); } /** diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 9d9fddc8c1..33d9e46220 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -479,6 +479,9 @@ #if EITHER(HAS_DWIN_E3V2_BASIC, DWIN_CREALITY_LCD_JYERSUI) #define HAS_DWIN_E3V2 1 #endif +#if ENABLED(DWIN_LCD_PROUI) + #define DO_LIST_BIN_FILES 1 +#endif // E3V2 extras #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI @@ -513,7 +516,7 @@ #endif #endif -#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) +#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) #define HAS_DISPLAY 1 #endif diff --git a/Marlin/src/lcd/e3v2/common/encoder.h b/Marlin/src/lcd/e3v2/common/encoder.h index e5d9645ed4..3ab8c3bf42 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.h +++ b/Marlin/src/lcd/e3v2/common/encoder.h @@ -45,12 +45,32 @@ typedef enum { ENCODER_DIFF_ENTER = 3 // click } EncoderState; +#define ENCODER_WAIT_MS 20 + // Encoder initialization void Encoder_Configuration(); // Analyze encoder value and return state EncoderState Encoder_ReceiveAnalyze(); +inline EncoderState get_encoder_state() { + static millis_t Encoder_ms = 0; + const millis_t ms = millis(); + if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; + const EncoderState state = Encoder_ReceiveAnalyze(); + if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; + return state; +} + +template +inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { + if (encoder_diffState == ENCODER_DIFF_CW) + valref += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + valref -= EncoderRate.encoderMoveValue; + return encoder_diffState == ENCODER_DIFF_ENTER; +} + /*********************** Encoder LED ***********************/ #if PIN_EXISTS(LCD_LED) diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index f20260e43d..7dc06d00f2 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -471,15 +471,6 @@ void Draw_Back_First(const bool is_sel=true) { if (is_sel) Draw_Menu_Cursor(0); } -template -inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { - if (encoder_diffState == ENCODER_DIFF_CW) - valref += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - valref -= EncoderRate.encoderMoveValue; - return encoder_diffState == ENCODER_DIFF_ENTER; -} - // // Draw Menus // @@ -1296,15 +1287,6 @@ void Goto_MainMenu() { TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); } -inline EncoderState get_encoder_state() { - static millis_t Encoder_ms = 0; - const millis_t ms = millis(); - if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; - const EncoderState state = Encoder_ReceiveAnalyze(); - if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; - return state; -} - void HMI_Plan_Move(const feedRate_t fr_mm_s) { if (!planner.is_full()) { planner.synchronize(); @@ -4086,6 +4068,13 @@ void HMI_Init() { HMI_SetLanguage(); } +void DWIN_InitScreen() { + Encoder_Configuration(); + HMI_Init(); + HMI_SetLanguageCache(); + HMI_StartFrame(true); +} + void DWIN_Update() { EachMomentUpdate(); // Status update HMI_SDCardUpdate(); // SD card update diff --git a/Marlin/src/lcd/e3v2/creality/dwin.h b/Marlin/src/lcd/e3v2/creality/dwin.h index 3122a6fcba..3ccb70e52f 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.h +++ b/Marlin/src/lcd/e3v2/creality/dwin.h @@ -236,6 +236,7 @@ void HMI_MaxJerk(); // Maximum jerk speed submenu void HMI_Step(); // Transmission ratio void HMI_Init(); +void DWIN_InitScreen(); void DWIN_Update(); void EachMomentUpdate(); void DWIN_HandleScreen(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 9e08854aed..0a392cd563 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -21,19 +21,18 @@ */ /** - * Enhanced DWIN implementation + * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.11.2 - * date: 2022/01/19 - * - * Based on the original code provided by Creality under GPL + * Version: 3.15.2 + * Date: 2022/03/01 */ -#include "../../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(DWIN_LCD_PROUI) #include "dwin.h" +#include "menus.h" #include "dwin_popup.h" #include "../../fontutils.h" @@ -65,6 +64,10 @@ #include "../../../feature/host_actions.h" #endif +#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY) + #define HAS_ONESTEP_LEVELING 1 +#endif + #if HAS_MESH || HAS_ONESTEP_LEVELING #include "../../../feature/bedlevel/bedlevel.h" #endif @@ -77,8 +80,14 @@ #include "../../../feature/bltouch.h" #endif -#if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - #include "../../../feature/babystep.h" +#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) + #define HAS_ZOFFSET_ITEM 1 + #if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) + #define JUST_BABYSTEP 1 + #endif + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) + #include "../../../feature/babystep.h" + #endif #endif #if ENABLED(POWER_LOSS_RECOVERY) @@ -171,7 +180,7 @@ enum SelectItem : uint8_t { PAGE_PRINT = 0, PAGE_PREPARE, PAGE_CONTROL, - PAGE_INFO_LEV_ADV, + PAGE_ADVANCE, PAGE_COUNT, PRINT_SETUP = 0, @@ -192,14 +201,13 @@ typedef struct { select_t select_page{0}, select_file{0}, select_print{0}; uint8_t index_file = MROWS; -bool dwin_abort_flag = false; // Flag to reset feedrate, return to Home bool hash_changed = true; // Flag to know if message status was changed -constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; -constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; +constexpr float max_feedrate_edit_values[] = DEFAULT_MAX_FEEDRATE; +constexpr float max_acceleration_edit_values[] = DEFAULT_MAX_ACCELERATION; #if HAS_CLASSIC_JERK - constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; + constexpr float max_jerk_edit_values[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; #endif static uint8_t _percent_done = 0; @@ -208,18 +216,6 @@ static uint32_t _remain_time = 0; // Additional Aux Host Support static bool sdprint = false; -#if ENABLED(PAUSE_HEAT) - #if HAS_HOTEND - celsius_t resume_hotend_temp = 0; - #endif - #if HAS_HEATED_BED - celsius_t resume_bed_temp = 0; - #endif - #if HAS_FAN - uint16_t resume_fan = 0; - #endif -#endif - #if HAS_ZOFFSET_ITEM float dwin_zoffset = 0, last_zoffset = 0; #endif @@ -348,31 +344,13 @@ void ICON_Control() { ICON_Button(select_page.now == PAGE_CONTROL, ICON_Control_0, ico, txt, GET_TEXT_F(MSG_CONTROL)); } -// -// Main Menu: "Info" -// -void ICON_StartInfo() { - constexpr frame_rect_t ico = { 145, 226, 110, 100 }; - constexpr text_info_t txt = { 91, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; - ICON_Button(select_page.now == PAGE_INFO_LEV_ADV, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_INFO)); -} - -// -// Main Menu: "Level" -// -void ICON_Leveling() { - constexpr frame_rect_t ico = { 145, 226, 110, 100 }; - constexpr text_info_t txt = { 211, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; - ICON_Button(select_page.now == PAGE_INFO_LEV_ADV, ICON_Leveling_0, ico, txt, GET_TEXT_F(MSG_BUTTON_LEVEL)); -} - // // Main Menu: "Advanced Settings" // void ICON_AdvSettings() { constexpr frame_rect_t ico = { 145, 226, 110, 100 }; constexpr text_info_t txt = { 91, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; - ICON_Button(select_page.now == PAGE_INFO_LEV_ADV, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_ADVANCED)); + ICON_Button(select_page.now == PAGE_ADVANCE, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_ADVANCED)); } // @@ -415,14 +393,6 @@ void ICON_Stop() { // Drawing routines //----------------------------------------------------------------------------- -void Draw_Menu_Cursor(const int8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Cursor_color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); -} - -void Erase_Menu_Cursor(const int8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); -} - void Move_Highlight(const int8_t from, const int8_t newline) { Erase_Menu_Cursor(newline - from); Draw_Menu_Cursor(newline); @@ -430,7 +400,7 @@ void Move_Highlight(const int8_t from, const int8_t newline) { void Add_Menu_Line() { Move_Highlight(1, MROWS); - DWIN_Draw_Line(HMI_data.SplitLine_Color, 16, MBASE(MROWS + 1) - 20, 256, MBASE(MROWS + 1) - 19); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(MROWS + 1), 240); } void Scroll_Menu(const uint8_t dir) { @@ -449,21 +419,6 @@ void Erase_Menu_Text(const uint8_t line) { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); } -void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=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); - DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); -} - -void Draw_Chkb_Line(const uint8_t line, const bool checked) { - DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 16, MBASE(line) - 1, checked); -} - -void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const uint16_t value=0) { - DWINUI::Draw_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); -} - // Draw "Back" line at the top void Draw_Back_First(const bool is_sel=true) { Draw_Menu_Line(0, ICON_Back); @@ -474,24 +429,6 @@ void Draw_Back_First(const bool is_sel=true) { if (is_sel) Draw_Menu_Cursor(0); } -inline EncoderState get_encoder_state() { - static millis_t Encoder_ms = 0; - const millis_t ms = millis(); - if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; - const EncoderState state = Encoder_ReceiveAnalyze(); - if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; - return state; -} - -template -inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { - if (encoder_diffState == ENCODER_DIFF_CW) - valref += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - valref -= EncoderRate.encoderMoveValue; - return encoder_diffState == ENCODER_DIFF_ENTER; -} - //PopUps void Popup_window_PauseOrStop() { if (HMI_IsChinese()) { @@ -530,9 +467,10 @@ void Popup_window_PauseOrStop() { #if HAS_HOTEND || HAS_HEATED_BED void DWIN_Popup_Temperature(const bool toohigh) { - DWINUI::ClearMenuArea(); - Draw_Popup_Bkgd(); + HMI_SaveProcessID(WaitResponse); if (HMI_IsChinese()) { + DWINUI::ClearMenuArea(); + Draw_Popup_Bkgd(); if (toohigh) { DWINUI::Draw_Icon(ICON_TempTooHigh, 102, 165); DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285); @@ -545,23 +483,14 @@ void Popup_window_PauseOrStop() { DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } } - else { - DWIN_Draw_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low")); - } + else DWIN_Show_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low"), BTN_Continue); } #endif // Draw status line -void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text, const bool center = true) { - DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - if (text) { - if (center) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text); - else DWINUI::Draw_String(color, 0, STATUS_Y + 2, text); - } - DWIN_UpdateLCD(); -} -void DWIN_DrawStatusLine(const char *text, const bool center = true) { - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, text, center); +void DWIN_DrawStatusLine(const char *text) { + DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); + if (text) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, text); } // Clear & reset status line @@ -582,17 +511,15 @@ void DWIN_CheckStatusMessage() { }; void DWIN_DrawStatusMessage() { - const uint8_t max_status_chars = DWIN_WIDTH / DWINUI::fontWidth(); - #if ENABLED(STATUS_MESSAGE_SCROLLING) // Get the UTF8 character count of the string uint8_t slen = utf8_strlen(ui.status_message); // If the string fits the status line do not scroll it - if (slen <= max_status_chars) { + if (slen <= LCD_WIDTH) { if (hash_changed) { - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message); + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } } @@ -605,16 +532,16 @@ void DWIN_DrawStatusMessage() { const char *stat = MarlinUI::status_and_len(rlen); DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); DWINUI::MoveTo(0, STATUS_Y + 2); - DWINUI::Draw_String(stat, max_status_chars); + DWINUI::Draw_String(HMI_data.StatusTxt_Color, stat, LCD_WIDTH); // If the string doesn't completely fill the line... - if (rlen < max_status_chars) { - DWINUI::Draw_Char('.'); // Always at 1+ spaces left, draw a dot - uint8_t chars = max_status_chars - rlen; // Amount of space left in characters + if (rlen < LCD_WIDTH) { + DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); // Always at 1+ spaces left, draw a dot + uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters if (--chars) { // Draw a second dot if there's space - DWINUI::Draw_Char('.'); + DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); if (--chars) - DWINUI::Draw_String(ui.status_message, chars); // Print a second copy of the message + DWINUI::Draw_String(HMI_data.StatusTxt_Color, ui.status_message, chars); // Print a second copy of the message } } MarlinUI::advance_status_scroll(); @@ -623,8 +550,8 @@ void DWIN_DrawStatusMessage() { #else if (hash_changed) { - ui.status_message[max_status_chars] = 0; - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message); + ui.status_message[LCD_WIDTH] = 0; + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } @@ -643,7 +570,7 @@ void Draw_Print_Labels() { } void Draw_Print_ProgressBar() { - DWINUI::Draw_IconWB(ICON_Bar, 15, 93); + DWIN_ICON_Show(true, false, false, ICON, ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, HMI_data.Barfill_Color, 16 + _percent_done * 240 / 100, 93, 256, 113); DWINUI::Draw_Int(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 3, 117, 133, _percent_done); DWINUI::Draw_String(HMI_data.PercentTxt_Color, 142, 133, F("%")); @@ -663,10 +590,21 @@ void Draw_Print_ProgressRemain() { } void ICON_ResumeOrPause() { - if (printingIsPaused() || HMI_flag.pause_flag || HMI_flag.pause_action) - ICON_Resume(); - else - ICON_Pause(); + if (checkkey == PrintProcess) printingIsPaused() ? ICON_Resume() : ICON_Pause(); +} + +// Update filename on print +void DWIN_Print_Header(const char *text = nullptr) { + static char headertxt[31] = ""; // Print header text + if (text) { + const int8_t size = _MIN(30U, strlen_P(text)); + LOOP_L_N(i, size) headertxt[i] = text[i]; + headertxt[size] = '\0'; + } + if (checkkey == PrintProcess || checkkey == PrintDone) { + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 60, DWIN_WIDTH, 60+16); + DWINUI::Draw_CenteredString(60, headertxt); + } } void Draw_PrintProcess() { @@ -685,17 +623,16 @@ void Draw_PrintProcess() { ICON_Tune(); ICON_ResumeOrPause(); ICON_Stop(); - DWIN_UpdateLCD(); } void Goto_PrintProcess() { - if (checkkey == PrintProcess) { + if (checkkey == PrintProcess) ICON_ResumeOrPause(); - DWIN_UpdateLCD(); - return; + else { + checkkey = PrintProcess; + Draw_PrintProcess(); } - checkkey = PrintProcess; - Draw_PrintProcess(); + DWIN_UpdateLCD(); } void Draw_PrintDone() { @@ -713,8 +650,16 @@ void Draw_PrintDone() { Draw_Print_ProgressElapsed(); Draw_Print_ProgressRemain(); // show print done confirm - DWINUI::Draw_IconWB(HMI_IsChinese() ? ICON_Confirm_C : ICON_Confirm_E, 86, 273); - DWIN_UpdateLCD(); + DWINUI::Draw_Button(BTN_Confirm, 86, 273); +} + +void Goto_PrintDone() { + wait_for_user = true; + if (checkkey != PrintDone) { + checkkey = PrintDone; + Draw_PrintDone(); + DWIN_UpdateLCD(); + } } void Draw_Main_Menu() { @@ -724,18 +669,18 @@ void Draw_Main_Menu() { else Title.ShowCaption(MACHINE_NAME); DWINUI::Draw_Icon(ICON_LOGO, 71, 52); // CREALITY logo + DWIN_ResetStatusLine(); ICON_Print(); ICON_Prepare(); ICON_Control(); ICON_AdvSettings(); - DWIN_UpdateLCD(); } void Goto_Main_Menu() { if (checkkey == MainMenu) return; checkkey = MainMenu; - ui.reset_status(true); Draw_Main_Menu(); + DWIN_UpdateLCD(); } // Draw X, Y, Z and blink if in an un-homed or un-trusted state @@ -751,9 +696,9 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, if (force || changed || draw_qmark || draw_empty) { if (blink && draw_qmark) - DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" - ? -")); + DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" - ? -")); else if (blink && draw_empty) - DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" ")); + DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" ")); else DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 2, x, y, p); } @@ -766,9 +711,9 @@ void _draw_xyz_position(const bool force) { if (force || blink != _blink) { _blink = blink; //SERIAL_ECHOPGM(" (blink)"); - _update_axis_value(X_AXIS, 35, 459, blink, true); - _update_axis_value(Y_AXIS, 120, 459, blink, true); - _update_axis_value(Z_AXIS, 205, 459, blink, true); + _update_axis_value(X_AXIS, 27, 459, blink, true); + _update_axis_value(Y_AXIS, 112, 459, blink, true); + _update_axis_value(Z_AXIS, 197, 459, blink, true); } //SERIAL_EOL(); } @@ -852,7 +797,7 @@ void update_variable() { static float _offset = 0; if (BABY_Z_VAR != _offset) { _offset = BABY_Z_VAR; - DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, _offset); + DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, _offset); } #if HAS_MESH @@ -908,15 +853,6 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) void HMI_SDCardInit() { card.cdroot(); } -// Initialize or re-initialize the LCD -void MarlinUI::init_lcd() { DWIN_Startup(); } - -void MarlinUI::refresh() { /* Nothing to see here */ } - -#if HAS_LCD_BRIGHTNESS - void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } -#endif - #if ENABLED(SCROLL_LONG_FILENAMES) char shift_name[LONG_FILENAME_LENGTH + 1]; @@ -966,7 +902,8 @@ void Draw_SDItem(const uint16_t item, int16_t row=-1) { // Draw the file/folder with name aligned left char str[strlen(name) + 1]; make_name_without_ext(str, name); - Draw_Menu_Line(row, card.flag.filenameIsDir ? ICON_Folder : ICON_File, str); + const uint8_t icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; + Draw_Menu_Line(row, icon, str); } #if ENABLED(SCROLL_LONG_FILENAMES) @@ -1045,11 +982,8 @@ void HMI_SDCardUpdate() { Redraw_SD_List(); } else if (sdprint && card.isPrinting() && printingIsActive()) { - // TODO: Move card removed abort handling - // to CardReader::manage_media. - card.abortFilePrintSoon(); wait_for_heatup = wait_for_user = false; - dwin_abort_flag = true; // Reset feedrate, return to Home + HMI_flag.abort_flag = true; // Abort print } } DWIN_UpdateLCD(); @@ -1057,10 +991,10 @@ void HMI_SDCardUpdate() { } // -// The status area is always on-screen, except during -// full-screen modal dialogs. (TODO: Keep alive during dialogs) +// The Dashboard is always on-screen, except during +// full-screen modal dialogs. // -void Draw_Status_Area(const bool with_update) { +void DWIN_Draw_Dashboard() { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1); @@ -1095,7 +1029,7 @@ void Draw_Status_Area(const bool with_update) { DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); #endif - DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, BABY_Z_VAR); + DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, BABY_Z_VAR); DWIN_Draw_Rectangle(1, HMI_data.SplitLine_Color, 0, 449, DWIN_WIDTH, 451); @@ -1104,16 +1038,6 @@ void Draw_Status_Area(const bool with_update) { DWINUI::Draw_Icon(ICON_MaxSpeedZ, 180, 456); _draw_xyz_position(true); - if (with_update) { - DWIN_UpdateLCD(); - delay(5); - } -} - -void HMI_StartFrame(const bool with_update) { - Goto_Main_Menu(); - DWIN_DrawStatusLine(nullptr); - Draw_Status_Area(with_update); } void Draw_Info_Menu() { @@ -1143,8 +1067,6 @@ void Draw_Info_Menu() { DWINUI::Draw_Icon(ICON_PrintSize + i, ICOX, 99 + i * 73); DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MBASE(2) + i * 73, 240); } - - DWIN_UpdateLCD(); } void Draw_Print_File_Menu() { @@ -1166,7 +1088,7 @@ void HMI_MainMenu() { case PAGE_PRINT: ICON_Print(); break; case PAGE_PREPARE: ICON_Print(); ICON_Prepare(); break; case PAGE_CONTROL: ICON_Prepare(); ICON_Control(); break; - case PAGE_INFO_LEV_ADV: ICON_Control(); ICON_AdvSettings(); break; + case PAGE_ADVANCE: ICON_Control(); ICON_AdvSettings(); break; } } } @@ -1176,7 +1098,7 @@ void HMI_MainMenu() { case PAGE_PRINT: ICON_Print(); ICON_Prepare(); break; case PAGE_PREPARE: ICON_Prepare(); ICON_Control(); break; case PAGE_CONTROL: ICON_Control(); ICON_AdvSettings(); break; - case PAGE_INFO_LEV_ADV: ICON_AdvSettings(); break; + case PAGE_ADVANCE: ICON_AdvSettings(); break; } } } @@ -1185,14 +1107,12 @@ void HMI_MainMenu() { case PAGE_PRINT: checkkey = SelectFile; card.mount(); + delay(300); Draw_Print_File_Menu(); break; - case PAGE_PREPARE: Draw_Prepare_Menu(); break; - case PAGE_CONTROL: Draw_Control_Menu(); break; - - case PAGE_INFO_LEV_ADV: Draw_AdvancedSettings_Menu(); break; + case PAGE_ADVANCE: Draw_AdvancedSettings_Menu(); break; } } DWIN_UpdateLCD(); @@ -1277,7 +1197,7 @@ void HMI_SelectFile() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (select_file.now == 0) { // Back select_page.set(PAGE_PRINT); - Goto_Main_Menu(); + return Goto_Main_Menu(); } else if (hasUpDir && select_file.now == 1) { // CD-Up SDCard_Up(); @@ -1301,16 +1221,10 @@ void HMI_SelectFile() { HMI_flag.heat_flag = true; HMI_flag.print_finish = false; - card.openAndPrintFile(card.filename); - - #if HAS_FAN - // All fans on for Ender 3 v2 ? - // The slicer should manage this for us. - //for (uint8_t i = 0; i < FAN_COUNT; i++) - // thermalManager.fan_speed[i] = 255; - #endif - - DWIN_Print_Started(true); + if (card.fileIsBinary()) + return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); + else + return Goto_ConfirmToPrint(); } } @@ -1318,6 +1232,16 @@ void HMI_SelectFile() { DWIN_UpdateLCD(); } +// Pause or Stop popup +void onClick_PauseOrStop() { + switch (select_print.now) { + case PRINT_PAUSE_RESUME: if (HMI_flag.select_flag) HMI_flag.pause_flag = true; break; // confirm pause + case PRINT_STOP: if (HMI_flag.select_flag) HMI_flag.abort_flag = true; break; // stop confirmed then abort print + default: break; + } + return Goto_PrintProcess(); +} + // Printing void HMI_Printing() { EncoderState encoder_diffState = get_encoder_state(); @@ -1345,93 +1269,20 @@ void HMI_Printing() { switch (select_print.now) { case PRINT_SETUP: Draw_Tune_Menu(); break; case PRINT_PAUSE_RESUME: - if (HMI_flag.pause_flag) { - ICON_Pause(); - #if DISABLED(ADVANCED_PAUSE_FEATURE) - char cmd[40]; - cmd[0] = '\0'; - #if BOTH(HAS_HEATED_BED, PAUSE_HEAT) - if (resume_bed_temp) sprintf_P(cmd, PSTR("M190 S%i\n"), resume_bed_temp); - #endif - #if BOTH(HAS_HOTEND, PAUSE_HEAT) - if (resume_hotend_temp) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), resume_hotend_temp); - #endif - #if HAS_FAN - if (resume_fan) thermalManager.fan_speed[0] = resume_fan; - #endif - strcat_P(cmd, M24_STR); - queue.inject(cmd); - #endif + if (printingIsPaused()) { // if printer is already in pause + ui.resume_print(); + break; } - else { - HMI_flag.select_flag = true; - checkkey = PauseOrStop; - Popup_window_PauseOrStop(); - } - break; - + else + return Goto_Popup(Popup_window_PauseOrStop, onClick_PauseOrStop); case PRINT_STOP: - HMI_flag.select_flag = true; - checkkey = PauseOrStop; - Popup_window_PauseOrStop(); - break; - + return Goto_Popup(Popup_window_PauseOrStop, onClick_PauseOrStop); default: break; } } DWIN_UpdateLCD(); } -// Print done -void HMI_PrintDone() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - dwin_abort_flag = true; // Reset feedrate, return to Home - Goto_Main_Menu(); // Return to Main menu after print done - } -} - -// Pause or Stop popup -void HMI_PauseOrStop() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - - if (encoder_diffState == ENCODER_DIFF_CW) - Draw_Select_Highlight(false); - else if (encoder_diffState == ENCODER_DIFF_CCW) - Draw_Select_Highlight(true); - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (select_print.now == PRINT_PAUSE_RESUME) { - if (HMI_flag.select_flag) { - HMI_flag.pause_action = true; - ICON_Resume(); - queue.inject(F("M25")); - } - else { - // cancel pause - } - Goto_PrintProcess(); - } - else if (select_print.now == PRINT_STOP) { - if (HMI_flag.select_flag) { - checkkey = MainMenu; - if (HMI_flag.home_flag) planner.synchronize(); // Wait for planner moves to finish! - wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user - card.abortFilePrintSoon(); // Let the main loop handle SD abort - dwin_abort_flag = true; // Reset feedrate, return to Home - #ifdef ACTION_ON_CANCEL - hostui.cancel(); - #endif - DWIN_Draw_Popup(ICON_BLTouch, GET_TEXT_F(MSG_STOPPING), GET_TEXT_F(MSG_PLEASE_WAIT)); - } - else - Goto_PrintProcess(); // cancel stop - } - } - DWIN_UpdateLCD(); -} - #include "../../../libs/buzzer.h" void HMI_AudioFeedback(const bool success/*=true*/) { @@ -1452,24 +1303,11 @@ void Draw_Main_Area() { case SelectFile: Draw_Print_File_Menu(); break; case PrintProcess: Draw_PrintProcess(); break; case PrintDone: Draw_PrintDone(); break; - case Info: Draw_Info_Menu(); break; #if HAS_ESDIAG case ESDiagProcess: Draw_EndStopDiag(); break; #endif - #if ENABLED(PRINTCOUNTER) - case PrintStatsProcess: Draw_PrintStats(); break; - #endif - case PauseOrStop: Popup_window_PauseOrStop(); break; - #if ENABLED(POWER_LOSS_RECOVERY) - case PwrlossRec: Popup_PowerLossRecovery(); break; - #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case FilamentPurge: Draw_Popup_FilamentPurge(); break; - #endif + case Popup: popupDraw(); break; case Locked: lockScreen.draw(); break; - #if HAS_GCODE_PREVIEW - case ConfirmToPrint: Draw_PreviewFromSD(); break; - #endif case Menu: case SetInt: case SetPInt: @@ -1484,19 +1322,32 @@ void HMI_ReturnScreen() { checkkey = last_checkkey; wait_for_user = false; Draw_Main_Area(); - return; } -void HMI_Popup() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - HMI_ReturnScreen(); +void HMI_WaitForUser() { + get_encoder_state(); + if (!wait_for_user) { + switch (checkkey) { + case PrintDone: + select_page.reset(); + Goto_Main_Menu(); + break; + #if HAS_ONESTEP_LEVELING + case Leveling: + //TERN_(ProUI, ProEx.StopLeveling()); + HMI_ReturnScreen(); + break; + #endif + default: + HMI_ReturnScreen(); + break; + } } } void HMI_Init() { - HMI_SDCardInit(); + DWINUI::Draw_Box(1, Color_Black, {5, 220, DWIN_WIDTH-5, DWINUI::fontHeight()}); + DWINUI::Draw_CenteredString(Color_White, 220, F("Professional Firmware ")); for (uint16_t t = 0; t <= 100; t += 2) { DWINUI::Draw_Icon(ICON_Bar, 15, 260); DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 15 + t * 242 / 100, 260, 257, 280); @@ -1506,12 +1357,6 @@ void HMI_Init() { HMI_SetLanguage(); } -void DWIN_Update() { - EachMomentUpdate(); // Status update - HMI_SDCardUpdate(); // SD card update - DWIN_HandleScreen(); // Rotary encoder update -} - void EachMomentUpdate() { static millis_t next_var_update_ms = 0, next_rts_update_ms = 0, next_status_update_ms = 0; @@ -1538,52 +1383,45 @@ void EachMomentUpdate() { if (PENDING(ms, next_rts_update_ms)) return; next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL; - if (checkkey == PrintProcess) { - // if print done - if (HMI_flag.print_finish) { - HMI_flag.print_finish = false; - TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); - planner.finish_and_disable(); - checkkey = PrintDone; - Draw_PrintDone(); - } - else if (HMI_flag.pause_flag != printingIsPaused()) { - // print status update - HMI_flag.pause_flag = printingIsPaused(); - ICON_ResumeOrPause(); - } - } - - // pause after homing - if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) { - HMI_flag.pause_action = false; - #if ENABLED(PAUSE_HEAT) - TERN_(HAS_HOTEND, resume_hotend_temp = sdprint ? thermalManager.degTargetHotend(0) : thermalManager.wholeDegHotend(0)); - TERN_(HAS_HEATED_BED, resume_bed_temp = sdprint ? thermalManager.degTargetBed() : thermalManager.wholeDegBed()); - TERN_(HAS_FAN, resume_fan = thermalManager.fan_speed[0]); - #endif - IF_DISABLED(ADVANCED_PAUSE_FEATURE, thermalManager.disable_all_heaters()); - IF_DISABLED(PARK_HEAD_ON_PAUSE, queue.inject(F("G1 F1200 X0 Y0"))); - } - if (checkkey == PrintProcess) { // print process + // Print pause + if (HMI_flag.pause_flag && !HMI_flag.home_flag) { + HMI_flag.pause_flag = false; + if (!HMI_flag.pause_action) { + HMI_flag.pause_action = true; + return ui.pause_print(); + } + } + + // if print done + if (HMI_flag.print_finish && !HMI_flag.home_flag) { + HMI_flag.print_finish = false; + return DWIN_Print_Finished(); + } + + // if print was aborted + if (HMI_flag.abort_flag && !HMI_flag.home_flag) { // Print Stop + HMI_flag.abort_flag = false; + if (!HMI_flag.abort_action) { + HMI_flag.abort_action = true; + ui.abort_print(); + return Goto_PrintDone(); + } + } + duration_t elapsed = print_job_timer.duration(); // print timer if (sdprint && card.isPrinting()) { uint8_t percentDone = card.percentDone(); - static uint8_t last_percentValue = 101; - if (last_percentValue != percentDone) { // print percent - last_percentValue = percentDone; - if (percentDone) { + if (_percent_done != percentDone) { // print percent _percent_done = percentDone; Draw_Print_ProgressBar(); } - } // Estimate remaining time every 20 seconds static millis_t next_remain_time_update = 0; - if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) { + if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag && !HMI_flag.remain_flag) { _remain_time = (elapsed.value - dwin_heat_time) / (_percent_done * 0.01f) - (elapsed.value - dwin_heat_time); next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; Draw_Print_ProgressRemain(); @@ -1599,12 +1437,6 @@ void EachMomentUpdate() { } } - else if (dwin_abort_flag && !HMI_flag.home_flag) { // Print Stop - dwin_abort_flag = false; - dwin_zoffset = BABY_Z_VAR; - select_page.set(PAGE_PRINT); - Goto_Main_Menu(); - } #if ENABLED(POWER_LOSS_RECOVERY) else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off @@ -1629,8 +1461,8 @@ void EachMomentUpdate() { DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 70, GET_TEXT_F(MSG_OUTAGE_RECOVERY)); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 147, F("It looks like the last")); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 167, F("file was interrupted.")); - DWINUI::Draw_IconWB(ICON_Cancel_E, 26, 280); - DWINUI::Draw_IconWB(ICON_Continue_E, 146, 280); + DWINUI::Draw_Button(BTN_Cancel, 26, 280); + DWINUI::Draw_Button(BTN_Continue, 146, 280); } SdFile *dir = nullptr; const char * const filename = card.diveToFile(true, dir, recovery.info.sd_filename); @@ -1640,35 +1472,26 @@ void EachMomentUpdate() { DWIN_UpdateLCD(); } + void onClick_PowerLossRecovery() { + if (HMI_flag.select_flag) { + queue.inject(F("M1000C")); + select_page.reset(); + return Goto_Main_Menu(); + } + else { + select_print.set(PRINT_SETUP); + queue.inject(F("M1000")); + sdprint = true; + return Goto_PrintProcess(); + } + } + void Goto_PowerLossRecovery() { recovery.dwin_flag = false; LCD_MESSAGE_F(GET_TEXT_F(MSG_CONTINUE_PRINT_JOB)); - HMI_flag.select_flag = false; - Popup_PowerLossRecovery(); - last_checkkey = MainMenu; - checkkey = PwrlossRec; + Goto_Popup(Popup_PowerLossRecovery, onClick_PowerLossRecovery); } - void HMI_PowerlossRecovery() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (HMI_flag.select_flag) { - queue.inject(F("M1000C")); - select_page.reset(); - Goto_Main_Menu(); - } - else { - select_print.set(PRINT_SETUP); - queue.inject(F("M1000")); - sdprint = true; - Goto_PrintProcess(); - } - } - else - Draw_Select_Highlight(encoder_diffState != ENCODER_DIFF_CW); - DWIN_UpdateLCD(); - } #endif // POWER_LOSS_RECOVERY @@ -1682,49 +1505,39 @@ void DWIN_HandleScreen() { case SetFloat: HMI_SetFloat(); break; case SetPFloat: HMI_SetPFloat(); break; case SelectFile: HMI_SelectFile(); break; - case Homing: break; - case Leveling: break; case PrintProcess: HMI_Printing(); break; - case PrintDone: HMI_PrintDone(); break; - case PauseOrStop: HMI_PauseOrStop(); break; - case Info: HMI_Popup(); break; - case WaitResponse: HMI_Popup(); break; - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case FilamentPurge: HMI_FilamentPurge(); break; - #endif - case NothingToDo: break; + case Popup: HMI_Popup(); break; + case Leveling: //TERN_(ProUI, HMI_WaitForUser()); + break; case Locked: HMI_LockScreen(); break; - #if ENABLED(POWER_LOSS_RECOVERY) - case PwrlossRec: HMI_PowerlossRecovery(); break; - #endif - #if HAS_GCODE_PREVIEW - case ConfirmToPrint: HMI_ConfirmToPrint(); break; - #endif - #if HAS_ESDIAG - case ESDiagProcess: HMI_Popup(); break; - #endif - #if ENABLED(PRINTCOUNTER) - case PrintStatsProcess: HMI_Popup(); break; - #endif + case PrintDone: + TERN_(HAS_ESDIAG, case ESDiagProcess:) + case WaitResponse: HMI_WaitForUser(); break; + case Homing: + case PidProcess: + case NothingToDo: break; default: break; } } bool IDisPopUp() { // If ID is popup... - return (checkkey == NothingToDo) || - (checkkey == WaitResponse) || - (checkkey == Info) || - (checkkey == Homing) || - (checkkey == Leveling) || - TERN_(HAS_ESDIAG, (checkkey == ESDiagProcess) ||) - TERN_(PRINTCOUNTER, (checkkey == PrintStatsProcess) ||) - (checkkey == PauseOrStop) || - (checkkey == FilamentPurge); + return (checkkey == NothingToDo) + || (checkkey == WaitResponse) + || (checkkey == Homing) + || (checkkey == Leveling) + || (checkkey == PidProcess) + || TERN0(HAS_ESDIAG, (checkkey == ESDiagProcess)) + || (checkkey == Popup); } 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; } } @@ -1732,37 +1545,35 @@ void HMI_SaveProcessID(const uint8_t id) { void DWIN_StartHoming() { HMI_flag.home_flag = true; HMI_SaveProcessID(Homing); - Title.ShowCaption(GET_TEXT_F(MSG_LEVEL_BED_HOMING)); - DWIN_Draw_Popup(ICON_BLTouch, GET_TEXT_F(MSG_LEVEL_BED_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT)); + Title.ShowCaption(GET_TEXT_F(MSG_HOMING)); + DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT)); } void DWIN_CompletedHoming() { HMI_flag.home_flag = false; dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); - if (dwin_abort_flag) { - planner.finish_and_disable(); - } - HMI_ReturnScreen(); + if (HMI_flag.abort_action) DWIN_Print_Aborted(); else HMI_ReturnScreen(); } void DWIN_MeshLevelingStart() { #if HAS_ONESTEP_LEVELING HMI_SaveProcessID(Leveling); Title.ShowCaption(GET_TEXT_F(MSG_BED_LEVELING)); - DWIN_Show_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT), ICON_Cancel_E); + DWIN_Show_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT)); #elif ENABLED(MESH_BED_LEVELING) Draw_ManualMesh_Menu(); #endif } -void DWIN_CompletedLeveling() { TERN_(HAS_MESH, DWIN_MeshViewer()); } +void DWIN_CompletedLeveling() { + TERN_(HAS_ONESTEP_LEVELING, if (planner.leveling_active) Goto_MeshViewer()); +} #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { char msg[33] = ""; char str_1[6] = ""; - sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), xpos, ypos, - dtostrf(zval, 1, 2, str_1)); + sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), xpos, ypos, dtostrf(zval, 1, 2, str_1)); ui.set_status(msg); } #endif @@ -1800,67 +1611,63 @@ void DWIN_PidTuning(pidresult_t result) { } } -// Update filename on print -void DWIN_Print_Header(const char *text = nullptr) { - static char headertxt[31] = ""; // Print header text - - if (text) { - const int8_t size = _MIN((unsigned) 30, strlen_P(text)); - LOOP_L_N(i, size) headertxt[i] = text[i]; - headertxt[size] = '\0'; - } - if (checkkey == PrintProcess || checkkey == PrintDone) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 60, DWIN_WIDTH, 60+16); - DWINUI::Draw_CenteredString(60, headertxt); - } -} - -void Draw_Title(TitleClass* title) { - DWIN_Draw_Rectangle(1, HMI_data.TitleBg_color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); - if (title->frameid) - DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1); - else - DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); -} - -void Draw_Menu(MenuClass* menu) { - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); - DWIN_Draw_Rectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); - DWIN_ResetStatusLine(); -} - -// Startup routines -void DWIN_Startup() { - DWINUI::init(); - DWINUI::onCursorDraw = Draw_Menu_Cursor; - DWINUI::onCursorErase = Erase_Menu_Cursor; - DWINUI::onTitleDraw = Draw_Title; - DWINUI::onMenuDraw = Draw_Menu; - DWIN_JPG_ShowAndCache(3); - HMI_SetLanguage(); -} - // Started a Print Job void DWIN_Print_Started(const bool sd) { - sdprint = card.isPrinting() || sd; + sdprint = IS_SD_PRINTING() || sd; _percent_done = 0; _remain_time = 0; + HMI_flag.remain_flag = false; + HMI_flag.pause_flag = false; + HMI_flag.pause_action = false; + HMI_flag.abort_flag = false; + HMI_flag.abort_action = false; HMI_flag.print_finish = false; Goto_PrintProcess(); } +// Pause a print job +void DWIN_Print_Pause() { + ICON_ResumeOrPause(); +} + +// Resume print job +void DWIN_Print_Resume() { + HMI_flag.pause_action = false; + ICON_ResumeOrPause(); + if (printJobOngoing()) { + LCD_MESSAGE(MSG_RESUME_PRINT); + Goto_PrintProcess(); + } +} + // Ended print job void DWIN_Print_Finished() { - if (checkkey == PrintProcess || printingIsActive()) { + if (HMI_flag.abort_flag || checkkey == PrintDone) return; + TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel()); + HMI_flag.pause_flag = false; + wait_for_heatup = false; + planner.finish_and_disable(); thermalManager.cooldown(); - HMI_flag.print_finish = true; - } + Goto_PrintDone(); +} + +// Print was aborted +void DWIN_Print_Aborted() { + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Print_Aborted")); + HMI_flag.abort_action = false; + wait_for_heatup = false; + planner.finish_and_disable(); + thermalManager.cooldown(); + Goto_PrintDone(); } // Progress Bar update void DWIN_Progress_Update() { if (parser.seenval('P')) _percent_done = parser.byteval('P'); - if (parser.seenval('R')) _remain_time = parser.ulongval('R') * 60; + if (parser.seenval('R')) { + _remain_time = parser.ulongval('R') * 60; + HMI_flag.remain_flag = true; + } if (checkkey == PrintProcess) { Draw_Print_ProgressBar(); Draw_Print_ProgressRemain(); @@ -1896,11 +1703,18 @@ void DWIN_SetColorDefaults() { void DWIN_SetDataDefaults() { DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); - TERN_(HAS_HOTEND, HMI_data.HotendPidT = PREHEAT_1_TEMP_HOTEND); - TERN_(HAS_HEATED_BED, HMI_data.BedPidT = PREHEAT_1_TEMP_BED); - TERN_(HAS_HOTEND, HMI_data.PidCycles = 5); - TERN_(PREVENT_COLD_EXTRUSION, HMI_data.ExtMinT = EXTRUDE_MINTEMP); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + TERN_(HAS_HOTEND, HMI_data.HotendPidT = PREHEAT_1_TEMP_HOTEND); + TERN_(HAS_HEATED_BED, HMI_data.BedPidT = PREHEAT_1_TEMP_BED); + TERN_(HAS_HOTEND, HMI_data.PidCycles = 5); + #if ENABLED(PREVENT_COLD_EXTRUSION) + HMI_data.ExtMinT = EXTRUDE_MINTEMP; + ApplyExtMinT(); + #endif + #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + HMI_data.BedLevT = PREHEAT_1_TEMP_BED; + #endif + TERN_(BAUD_RATE_GCODE, SetBaud250K()); } void DWIN_StoreSettings(char *buff) { @@ -1912,9 +1726,10 @@ void DWIN_LoadSettings(const char *buff) { memcpy((void *)&HMI_data, buff, _MIN(sizeof(HMI_data), eeprom_data_size)); dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); if (HMI_data.Text_Color == HMI_data.Background_Color) DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT()); feedrate_percentage = 100; + TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate()); #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) // Apply Case light brightness caselight.brightness = HMI_data.CaseLight_Brightness; @@ -1926,6 +1741,37 @@ void DWIN_LoadSettings(const char *buff) { #endif } +// Initialize or re-initialize the LCD +void MarlinUI::init_lcd() { + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Startup")); + DWINUI::init(); + DWIN_JPG_CacheTo1(Language_English); + Encoder_Configuration(); +} + +void DWIN_InitScreen() { + HMI_Init(); // draws boot screen + DWINUI::onCursorDraw = Draw_Menu_Cursor; + DWINUI::onCursorErase = Erase_Menu_Cursor; + DWINUI::onTitleDraw = Draw_Title; + DWINUI::onMenuDraw = Draw_Menu; + DWIN_DrawStatusLine(nullptr); + DWIN_Draw_Dashboard(); + Goto_Main_Menu(); +} + +void MarlinUI::update() { + EachMomentUpdate(); // Status update + HMI_SDCardUpdate(); // SD card update + DWIN_HandleScreen(); // Rotary encoder update +} + +void MarlinUI::refresh() { /* Nothing to see here */ } + +#if HAS_LCD_BRIGHTNESS + void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } +#endif + void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) { DWIN_Draw_Popup(ICON_BLTouch, F("Printer killed:"), lcd_error); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 270, F("Turn off the printer")); @@ -1938,65 +1784,55 @@ void DWIN_RebootScreen() { DWINUI::Draw_CenteredString(Color_White, 220, GET_TEXT_F(MSG_PLEASE_WAIT_REBOOT)); DWIN_UpdateLCD(); delay(500); - DWIN_JPG_ShowAndCache(3); } void DWIN_Redraw_screen() { Draw_Main_Area(); - Draw_Status_Area(false); + hash_changed = true; + DWIN_DrawStatusMessage(); + DWIN_Draw_Dashboard(); } #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_Draw_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), fmsg, button); - ui.reset_status(true); + DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), fmsg, button); } void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) { + //if (mode == PAUSE_MODE_SAME) return; + pause_mode = mode; switch (message) { - case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; - case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; - case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; - case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), ICON_Continue_E); break; + case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 + case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) + case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break; case PAUSE_MESSAGE_INSERT: DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; - case PAUSE_MESSAGE_PURGE: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)); break; - case PAUSE_MESSAGE_OPTION: DWIN_Popup_FilamentPurge(); break; + case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 + case PAUSE_MESSAGE_PURGE: + #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) + DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_CONT_PURGE)); + #else + DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)); + #endif + break; + case PAUSE_MESSAGE_OPTION: Goto_FilamentPurge(); break; case PAUSE_MESSAGE_RESUME: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break; - case PAUSE_MESSAGE_HEAT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), ICON_Continue_E); break; + case PAUSE_MESSAGE_HEAT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), BTN_Continue); break; case PAUSE_MESSAGE_HEATING: LCD_MESSAGE(MSG_FILAMENT_CHANGE_HEATING); break; - case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; + case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; // Exit from Pause, Load and Unload default: break; } } void Draw_Popup_FilamentPurge() { DWIN_Draw_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), F("Purge or Continue?")); - DWINUI::Draw_IconWB(ICON_Confirm_E, 26, 280); - DWINUI::Draw_IconWB(ICON_Continue_E, 146, 280); + DWINUI::Draw_Button(BTN_Confirm, 26, 280); + DWINUI::Draw_Button(BTN_Continue, 146, 280); Draw_Select_Highlight(true); - DWIN_UpdateLCD(); } - // Handle responses such as: - // - Purge More, Continue - // - General "Continue" response - void DWIN_Popup_FilamentPurge() { - HMI_SaveProcessID(FilamentPurge); - pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; - Draw_Popup_FilamentPurge(); - } - - void HMI_FilamentPurge() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) - Draw_Select_Highlight(false); - else if (encoder_diffState == ENCODER_DIFF_CCW) - Draw_Select_Highlight(true); - else if (encoder_diffState == ENCODER_DIFF_ENTER) { + void onClick_FilamentPurge() { if (HMI_flag.select_flag) pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button else { @@ -2004,7 +1840,10 @@ void DWIN_Redraw_screen() { pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button } } - DWIN_UpdateLCD(); + + void Goto_FilamentPurge() { + pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; + Goto_Popup(Draw_Popup_FilamentPurge, onClick_FilamentPurge); } #endif // ADVANCED_PAUSE_FEATURE @@ -2042,39 +1881,10 @@ void HMI_LockScreen() { if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); } -#if HAS_GCODE_PREVIEW - - void HMI_ConfirmToPrint() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) - Draw_Select_Highlight(false); - else if (encoder_diffState == ENCODER_DIFF_CCW) - Draw_Select_Highlight(true); - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (HMI_flag.select_flag) { // Confirm - card.openAndPrintFile(card.filename); - DWIN_Print_Started(true); - } - else { // Cancel - DWIN_ResetStatusLine(); - checkkey = SelectFile; - Draw_Print_File_Menu(); - } - } - DWIN_UpdateLCD(); - } - -#endif void Goto_ConfirmToPrint() { - #if HAS_GCODE_PREVIEW - HMI_SaveProcessID(ConfirmToPrint); - Draw_PreviewFromSD(); - #else - card.openAndPrintFile(card.filename); - DWIN_Print_Started(true); - #endif + card.openAndPrintFile(card.filename); + DWIN_Print_Started(true); } #if HAS_ESDIAG @@ -2084,103 +1894,11 @@ void Goto_ConfirmToPrint() { } #endif -#if ENABLED(PRINTCOUNTER) - void Draw_PrintStats() { - HMI_SaveProcessID(PrintStatsProcess); - PrintStats.Draw(); - } -#endif - //============================================================================= // NEW MENU SUBSYSTEM //============================================================================= -// On click functions - -// Generic onclick event without draw anything -// process: process id HMI destiny -// lo: low limit -// hi: high limit -// dp: decimal places, 0 for integers -// 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) { - checkkey = process; - HMI_value.MinValue = lo; - HMI_value.MaxValue = hi; - HMI_value.dp = dp; - HMI_value.Apply = Apply; - HMI_value.LiveUpdate = LiveUpdate; - HMI_value.Value = val; - EncoderRate.enabled = true; -} - -// Generic onclick event for integer values -// process: process id HMI destiny -// lo: scaled low limit -// hi: scaled high limit -// 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) { - SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate); - Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, HMI_value.Value); -} - -// Generic onclick event for float values -// process: process id HMI destiny -// lo: scaled low limit -// hi: scaled high limit -// 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) { - const int32_t value = round(val * POW(10, dp)); - SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val); -} - -// Generic onclick event for integer values -// lo: scaled low limit -// hi: scaled high limit -// val: value -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -inline 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); -} - -// Generic onclick event for set pointer to 16 bit uinteger values -// lo: low limit -// 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) { - HMI_value.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; - const int32_t value = *HMI_value.P_Int; - SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate); -} - -// Generic onclick event for float values -// process: process id HMI destiny -// lo: low limit -// hi: high limit -// dp: decimal places -// val: value -inline 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); -} - -// Generic onclick event for set pointer to float values -// lo: low limit -// 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) { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - SetValueOnClick(SetPFloat, lo, hi, dp, *HMI_value.P_Float, Apply, LiveUpdate); -} +// Tool functions #if ENABLED(EEPROM_SETTINGS) void WriteEeprom() { @@ -2203,7 +1921,6 @@ void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)( // Reset Printer void RebootPrinter() { - dwin_abort_flag = true; wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user thermalManager.disable_all_heaters(); planner.finish_and_disable(); @@ -2212,8 +1929,8 @@ void RebootPrinter() { } void Goto_Info_Menu(){ - HMI_SaveProcessID(Info); Draw_Info_Menu(); + HMI_SaveProcessID(WaitResponse); } void Goto_Move_Menu() { @@ -2226,14 +1943,11 @@ void Goto_Move_Menu() { void DisableMotors() { queue.inject(F("M84")); } -void AutoLev() { queue.inject(F("G28Z\nG29")); } // Force to get the current Z home position +void AutoLev() { queue.inject(F("G28XYO\nG28Z\nG29")); } // Force to get the current Z home position void AutoHome() { queue.inject_P(G28_STR); } - void HomeX() { queue.inject(F("G28X")); } - void HomeY() { queue.inject(F("G28Y")); } - void HomeZ() { queue.inject(F("G28Z")); } void SetHome() { @@ -2247,7 +1961,7 @@ void SetHome() { void ApplyZOffset() { TERN_(EEPROM_SETTINGS, settings.save()); } void LiveZOffset() { last_zoffset = dwin_zoffset; - dwin_zoffset = HMI_value.Value / 100.0f; + dwin_zoffset = MenuData.Value / 100.0f; #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) if (BABYSTEP_ALLOWED()) babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset); #endif @@ -2257,6 +1971,24 @@ void SetHome() { SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); } #endif + + void SetMoveZto0() { + char cmd[48] = ""; + char str_1[5] = "", str_2[5] = ""; + sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300"), + #if ENABLED(MESH_BED_LEVELING) + dtostrf(0, 1, 1, str_1), + dtostrf(0, 1, 1, str_2) + #else + dtostrf(X_CENTER, 1, 1, str_1), + dtostrf(Y_CENTER, 1, 1, str_2) + #endif + ); + gcode.process_subcommands_now(cmd); + planner.synchronize(); + LCD_MESSAGE_F("Now adjust Z Offset"); + HMI_AudioFeedback(true); + } #endif #if HAS_PREHEAT @@ -2274,14 +2006,14 @@ void SetLanguage() { } void LiveMove() { - *HMI_value.P_Float = HMI_value.Value / MINUNITMULT; + *MenuData.P_Float = MenuData.Value / MINUNITMULT; if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, homing_feedrate(HMI_value.axis)); } } void ApplyMoveE() { - last_E = HMI_value.Value / MINUNITMULT; + last_E = MenuData.Value / MINUNITMULT; if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E)); @@ -2294,33 +2026,13 @@ void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS #if HAS_HOTEND void SetMoveE() { #if ENABLED(PREVENT_COLD_EXTRUSION) - if (thermalManager.tooColdToExtrude(0)) { - Popup_Window_ETempTooLow(); - return; - } + if (thermalManager.tooColdToExtrude(0)) + return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); #endif SetPFloatOnClick(last_E - (EXTRUDE_MAXLENGTH), last_E + (EXTRUDE_MAXLENGTH), UNITFDIGITS, ApplyMoveE); } #endif -void SetMoveZto0() { - char cmd[48] = ""; - char str_1[5] = "", str_2[5] = ""; - sprintf_P(cmd, PSTR("G28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300"), - #if ENABLED(MESH_BED_LEVELING) - dtostrf(0, 1, 1, str_1), - dtostrf(0, 1, 1, str_2) - #else - dtostrf(X_CENTER, 1, 1, str_1), - dtostrf(Y_CENTER, 1, 1, str_2) - #endif - ); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - LCD_MESSAGE_F("Now adjust Z Offset"); - HMI_AudioFeedback(true); -} - void SetPID(celsius_t t, heater_id_t h) { char cmd[48] = ""; char str_1[5] = "", str_2[5] = ""; @@ -2347,10 +2059,24 @@ void SetPID(celsius_t t, heater_id_t h) { } #endif +#if ENABLED(BAUD_RATE_GCODE) + void HMI_SetBaudRate() { + if (HMI_data.Baud115K) SetBaud115K(); else SetBaud250K(); + } + void SetBaudRate() { + HMI_SetBaudRate(); + Draw_Chkb_Line(CurrentMenu->line(), HMI_data.Baud115K); + DWIN_UpdateLCD(); + } + void SetBaud115K() { queue.inject(F("M575 P0 B115200")); HMI_data.Baud115K = true; } + void SetBaud250K() { queue.inject(F("M575 P0 B250000")); HMI_data.Baud115K = false; } +#endif + #if HAS_LCD_BRIGHTNESS - void ApplyBrightness() { ui.set_brightness(HMI_value.Value); } - void LiveBrightness() { DWIN_LCD_Brightness(HMI_value.Value); } + void ApplyBrightness() { ui.set_brightness(MenuData.Value); } + void LiveBrightness() { DWIN_LCD_Brightness(MenuData.Value); } void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, ApplyBrightness, LiveBrightness); } + void TurnOffBacklight() { HMI_SaveProcessID(WaitResponse); ui.set_brightness(0); DWIN_Redraw_screen(); } #endif #if ENABLED(CASE_LIGHT_MENU) @@ -2361,7 +2087,7 @@ void SetPID(celsius_t t, heater_id_t h) { DWIN_UpdateLCD(); } #if ENABLED(CASELIGHT_USES_BRIGHTNESS) - void LiveCaseLightBrightness() { HMI_data.CaseLight_Brightness = caselight.brightness = HMI_value.Value; caselight.update_brightness(); } + void LiveCaseLightBrightness() { HMI_data.CaseLight_Brightness = caselight.brightness = MenuData.Value; caselight.update_brightness(); } void SetCaseLightBrightness() { SetIntOnClick(0, 255, caselight.brightness, nullptr, LiveCaseLightBrightness); } #endif #endif @@ -2375,14 +2101,14 @@ void SetPID(celsius_t t, heater_id_t h) { } #endif #if ENABLED(HAS_COLOR_LEDS) - void LiveLedColorR() { leds.color.r = HMI_value.Value; HMI_data.Led_Color = leds.color; leds.update(); } + void LiveLedColorR() { leds.color.r = MenuData.Value; HMI_data.Led_Color = leds.color; leds.update(); } void SetLedColorR() { SetIntOnClick(0, 255, leds.color.r, nullptr, LiveLedColorR); } - void LiveLedColorG() { leds.color.g = HMI_value.Value; HMI_data.Led_Color = leds.color; leds.update(); } + void LiveLedColorG() { leds.color.g = MenuData.Value; HMI_data.Led_Color = leds.color; leds.update(); } void SetLedColorG() { SetIntOnClick(0, 255, leds.color.g, nullptr, LiveLedColorG); } - void LiveLedColorB() { leds.color.b = HMI_value.Value; HMI_data.Led_Color = leds.color; leds.update(); } + void LiveLedColorB() { leds.color.b = MenuData.Value; HMI_data.Led_Color = leds.color; leds.update(); } void SetLedColorB() { SetIntOnClick(0, 255, leds.color.b, nullptr, LiveLedColorB); } #if HAS_WHITE_LED - void LiveLedColorW() { leds.color.w = HMI_value.Value; HMI_data.Led_Color = leds.color; leds.update(); } + void LiveLedColorW() { leds.color.w = MenuData.Value; HMI_data.Led_Color = leds.color; leds.update(); } void SetLedColorW() { SetIntOnClick(0, 255, leds.color.w, nullptr, LiveLedColorW); } #endif #endif @@ -2397,7 +2123,7 @@ void SetPID(celsius_t t, heater_id_t h) { #endif #if HAS_HOME_OFFSET - void ApplyHomeOffset() { set_home_offset(HMI_value.axis, HMI_value.Value / MINUNITMULT); } + void ApplyHomeOffset() { set_home_offset(HMI_value.axis, MenuData.Value / MINUNITMULT); } void SetHomeOffsetX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(-50, 50, UNITFDIGITS, ApplyHomeOffset); } void SetHomeOffsetY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(-50, 50, UNITFDIGITS, ApplyHomeOffset); } void SetHomeOffsetZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick( -2, 2, UNITFDIGITS, ApplyHomeOffset); } @@ -2421,12 +2147,11 @@ void SetPID(celsius_t t, heater_id_t h) { DWIN_UpdateLCD(); } #endif -#endif -#if ENABLED(NOZZLE_PARK_FEATURE) - void SetParkPosX() { SetPIntOnClick(0, X_MAX_POS); } - void SetParkPosY() { SetPIntOnClick(0, Y_MAX_POS); } - void SetParkZRaise() { SetPIntOnClick(0, 50); } + #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + void SetBedLevT() { SetPIntOnClick(BED_MINTEMP, BED_MAX_TARGET); } + #endif + #endif #if HAS_FILAMENT_SENSOR @@ -2437,7 +2162,7 @@ void SetPID(celsius_t t, heater_id_t h) { DWIN_UpdateLCD(); } #if HAS_FILAMENT_RUNOUT_DISTANCE - void ApplyRunoutDistance() { runout.set_runout_distance(HMI_value.Value / MINUNITMULT); } + void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } void SetRunoutDistance() { SetFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), ApplyRunoutDistance); } #endif #endif @@ -2454,20 +2179,20 @@ void SetPID(celsius_t t, heater_id_t h) { void RestoreDefaultsColors() { DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWIN_Redraw_screen(); } void SelColor() { - HMI_value.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; - HMI_value.Color[0] = GetRColor(*HMI_value.P_Int); // Red - HMI_value.Color[1] = GetGColor(*HMI_value.P_Int); // Green - HMI_value.Color[2] = GetBColor(*HMI_value.P_Int); // Blue + 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] = HMI_value.Value; + HMI_value.Color[CurrentMenu->line() - 2] = MenuData.Value; uint16_t color = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); DWIN_Draw_Rectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); } @@ -2477,27 +2202,28 @@ void SetRGBColor() { } void DWIN_ApplyColor() { - *HMI_value.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); - Draw_Status_Area(false); + *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_F(GET_TEXT_F(MSG_COLORS_APPLIED)); + DWIN_Draw_Dashboard(); } void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } #if HAS_HOTEND - void ApplyHotendTemp() { thermalManager.setTargetHotend(HMI_value.Value, 0); } + void ApplyHotendTemp() { thermalManager.setTargetHotend(MenuData.Value, 0); } void SetHotendTemp() { SetIntOnClick(MIN_ETEMP, MAX_ETEMP, thermalManager.degTargetHotend(0), ApplyHotendTemp); } #endif #if HAS_HEATED_BED - void ApplyBedTemp() { thermalManager.setTargetBed(HMI_value.Value); } + void ApplyBedTemp() { thermalManager.setTargetBed(MenuData.Value); } void SetBedTemp() { SetIntOnClick(BED_MINTEMP, BED_MAX_TARGET, thermalManager.degTargetBed(), ApplyBedTemp); } #endif #if HAS_FAN - void ApplyFanSpeed() { thermalManager.set_fan_speed(0, HMI_value.Value); } + void ApplyFanSpeed() { thermalManager.set_fan_speed(0, MenuData.Value); } void SetFanSpeed() { SetIntOnClick(0, 255, thermalManager.fan_speed[0], ApplyFanSpeed); } #endif @@ -2531,17 +2257,15 @@ void ApplyFlow() { planner.refresh_e_factor(0); } void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, ApplyFlow); } // Bed Tramming -void Tram(uint8_t point) { +TERN(HAS_ONESTEP_LEVELING, float, void) Tram(uint8_t point) { char cmd[100] = ""; #if HAS_ONESTEP_LEVELING static bool inLev = false; - if (inLev) return; + float xpos = 0, ypos = 0, zval = 0, margin = 0; char str_1[6] = "", str_2[6] = "", str_3[6] = ""; - #define fmt "X:%s, Y:%s, Z:%s" - float xpos = 0, ypos = 0, zval = 0; - float margin = PROBING_MARGIN; + if (inLev) return NAN; + margin = HMI_data.FullManualTramming ? 30 : PROBING_MARGIN; #else - #define fmt "M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300" int16_t xpos = 0, ypos = 0; int16_t margin = 30; #endif @@ -2569,24 +2293,45 @@ void Tram(uint8_t point) { break; } + planner.synchronize(); + #if HAS_ONESTEP_LEVELING - planner.synchronize(); - probe.stow(); - gcode.process_subcommands_now(F("M420S0\nG28O")); - planner.synchronize(); - inLev = true; - zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); - sprintf_P(cmd, PSTR(fmt), - dtostrf(xpos, 1, 1, str_1), - dtostrf(ypos, 1, 1, str_2), - dtostrf(zval, 1, 2, str_3) - ); - ui.set_status(cmd); - inLev = false; + + if (HMI_data.FullManualTramming) { + planner.synchronize(); + 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 { + LIMIT(xpos, X_MIN_POS, (X_MAX_POS + probe.offset.x)); + LIMIT(ypos, Y_MIN_POS, (Y_MAX_POS + probe.offset.y)); + probe.stow(); + gcode.process_subcommands_now(F("M420S0\nG28O")); + planner.synchronize(); + inLev = true; + zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); + if (isnan(zval)) + ui.set_status(F("Position Not Reachable, check offsets")); + 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 - planner.synchronize(); - sprintf_P(cmd, PSTR(fmt), xpos, ypos); + + sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300"), xpos, ypos); queue.inject(cmd); + #endif } @@ -2596,11 +2341,72 @@ void TramBR() { Tram(2); } void TramBL() { Tram(3); } void TramC () { Tram(4); } +#if HAS_ONESTEP_LEVELING + + void Trammingwizard() { + bed_mesh_t zval = {0}; + if (HMI_data.FullManualTramming) { + ui.set_status(F("Disable manual tramming")); + return; + } + 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); + char str_1[6] = "", str_2[6] = ""; + ui.status_printf(0, F("Limits minZ: %s, maxZ: %s"), + dtostrf(MeshViewer.min, 1, 2, str_1), + dtostrf(MeshViewer.max, 1, 2, str_2) + ); + if (ABS(MeshViewer.max - MeshViewer.min) < 0.05) { + DWINUI::Draw_CenteredString(140,F("Corners leveled")); + DWINUI::Draw_CenteredString(160,F("Tolerance achieved!")); + } + else { + uint8_t p = 0; + float d, max = 0; + FSTR_P plabel; + LOOP_L_N(x,2) LOOP_L_N(y,2) { + d = ABS(zval[x][y] - MeshViewer.avg); + if (max < d) { + max = d; + p = x + 2 * y; + } + } + 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(130, F("Corners not leveled")); + DWINUI::Draw_CenteredString(150, F("Knob adjustment required")); + DWINUI::Draw_CenteredString(Color_Green, 170, plabel); + } + DWINUI::Draw_Button(BTN_Continue, 86, 305); + checkkey = Menu; + HMI_SaveProcessID(WaitResponse); + } + + void SetManualTramming() { + HMI_data.FullManualTramming = !HMI_data.FullManualTramming; + Draw_Chkb_Line(CurrentMenu->line(), HMI_data.FullManualTramming); + DWIN_UpdateLCD(); + } + +#endif // HAS_ONESTEP_LEVELING + #if ENABLED(MESH_BED_LEVELING) void ManualMeshStart(){ LCD_MESSAGE(MSG_UBL_BUILD_MESH_MENU); - gcode.process_subcommands_now(F("G28Z\nM211S0\nG29S1")); + gcode.process_subcommands_now(F("G28XYO\nG28Z\nM211S0\nG29S1")); planner.synchronize(); #ifdef MANUAL_PROBE_START_Z const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos); @@ -2609,7 +2415,7 @@ void TramC () { Tram(4); } } void LiveMeshMoveZ() { - *HMI_value.P_Float = HMI_value.Value / POW(10, 2); + *MenuData.P_Float = MenuData.Value / POW(10, 2); if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, homing_feedrate(Z_AXIS)); @@ -2642,29 +2448,29 @@ void TramC () { Tram(4); } #endif #endif -void ApplyMaxSpeed() { planner.set_max_feedrate(HMI_value.axis, HMI_value.Value / MINUNITMULT); } -void SetMaxSpeedX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[X_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[X_AXIS], ApplyMaxSpeed); } -void SetMaxSpeedY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[Y_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[Y_AXIS], ApplyMaxSpeed); } -void SetMaxSpeedZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[Z_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[Z_AXIS], ApplyMaxSpeed); } +void ApplyMaxSpeed() { planner.set_max_feedrate(HMI_value.axis, MenuData.Value / MINUNITMULT); } +void SetMaxSpeedX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[X_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[X_AXIS], ApplyMaxSpeed); } +void SetMaxSpeedY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[Y_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[Y_AXIS], ApplyMaxSpeed); } +void SetMaxSpeedZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[Z_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[Z_AXIS], ApplyMaxSpeed); } #if HAS_HOTEND - void SetMaxSpeedE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[E_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[E_AXIS], ApplyMaxSpeed); } + void SetMaxSpeedE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[E_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[E_AXIS], ApplyMaxSpeed); } #endif -void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, HMI_value.Value); } -void SetMaxAccelX() { HMI_value.axis = X_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[X_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[X_AXIS], ApplyMaxAccel); } -void SetMaxAccelY() { HMI_value.axis = Y_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[Y_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ApplyMaxAccel); } -void SetMaxAccelZ() { HMI_value.axis = Z_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[Z_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ApplyMaxAccel); } +void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, MenuData.Value); } +void SetMaxAccelX() { HMI_value.axis = X_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[X_AXIS], planner.settings.max_acceleration_mm_per_s2[X_AXIS], ApplyMaxAccel); } +void SetMaxAccelY() { HMI_value.axis = Y_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[Y_AXIS], planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ApplyMaxAccel); } +void SetMaxAccelZ() { HMI_value.axis = Z_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[Z_AXIS], planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ApplyMaxAccel); } #if HAS_HOTEND - void SetMaxAccelE() { HMI_value.axis = E_AXIS; SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[E_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[E_AXIS], ApplyMaxAccel); } + void SetMaxAccelE() { HMI_value.axis = E_AXIS; SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[E_AXIS], planner.settings.max_acceleration_mm_per_s2[E_AXIS], ApplyMaxAccel); } #endif #if HAS_CLASSIC_JERK - void ApplyMaxJerk() { planner.set_max_jerk(HMI_value.axis, HMI_value.Value / MINUNITMULT); } - void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[X_AXIS] * 2, UNITFDIGITS, planner.max_jerk[X_AXIS], ApplyMaxJerk); } - void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[Y_AXIS] * 2, UNITFDIGITS, planner.max_jerk[Y_AXIS], ApplyMaxJerk); } - void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[Z_AXIS] * 2, UNITFDIGITS, planner.max_jerk[Z_AXIS], ApplyMaxJerk); } + void ApplyMaxJerk() { planner.set_max_jerk(HMI_value.axis, MenuData.Value / MINUNITMULT); } + void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[X_AXIS], UNITFDIGITS, planner.max_jerk[X_AXIS], ApplyMaxJerk); } + void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Y_AXIS], UNITFDIGITS, planner.max_jerk[Y_AXIS], ApplyMaxJerk); } + void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Z_AXIS], UNITFDIGITS, planner.max_jerk[Z_AXIS], ApplyMaxJerk); } #if HAS_HOTEND - void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, default_max_jerk[E_AXIS] * 2, UNITFDIGITS, planner.max_jerk[E_AXIS], ApplyMaxJerk); } + void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[E_AXIS], UNITFDIGITS, planner.max_jerk[E_AXIS], ApplyMaxJerk); } #endif #endif @@ -2683,21 +2489,21 @@ void SetStepsZ() { HMI_value.axis = Z_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP void SetPidCycles() { SetPIntOnClick(3, 50); } void SetKp() { SetPFloatOnClick(0, 1000, 2); } void ApplyPIDi() { - *HMI_value.P_Float = scalePID_i(HMI_value.Value / POW(10, 2)); + *MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2)); thermalManager.updatePID(); } void ApplyPIDd() { - *HMI_value.P_Float = scalePID_d(HMI_value.Value / POW(10, 2)); + *MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2)); thermalManager.updatePID(); } void SetKi() { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - const float value = unscalePID_i(*HMI_value.P_Float); + 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() { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - const float value = unscalePID_d(*HMI_value.P_Float); + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + const float value = unscalePID_d(*MenuData.P_Float); SetFloatOnClick(0, 1000, 2, value, ApplyPIDd); } #endif @@ -2709,62 +2515,7 @@ void SetStepsZ() { HMI_value.axis = Z_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP void SetRecoverSpeed() { SetPFloatOnClick( 1, 90, UNITFDIGITS); }; #endif -// Menuitem Drawing functions ================================================= - -void onDrawMenuItem(MenuItemClass* menuitem, int8_t line) { - if (menuitem->icon) DWINUI::Draw_Icon(menuitem->icon, ICOX, MBASE(line) - 3); - if (menuitem->frameid) - DWIN_Frame_AreaCopy(menuitem->frameid, menuitem->frame.left, menuitem->frame.top, menuitem->frame.right, menuitem->frame.bottom, LBLX, MBASE(line)); - else if (menuitem->caption) - DWINUI::Draw_String(LBLX, MBASE(line) - 1, menuitem->caption); - DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); -} - -void onDrawSubMenu(MenuItemClass* menuitem, int8_t line) { - onDrawMenuItem(menuitem, line); - DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); -} - -void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, uint16_t value) { - onDrawMenuItem(menuitem, line); - Draw_Menu_IntValue(HMI_data.Background_Color, line, 4, value); -} - -void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line) { - const uint16_t value = *(uint16_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line) { - const uint8_t value = *(uint8_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) { - const uint32_t value = *(uint32_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) { - onDrawMenuItem(menuitem, line); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value); -} - -void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - const int8_t dp = UNITFDIGITS; - onDrawFloatMenu(menuitem, line, dp, value); -} - -void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - onDrawFloatMenu(menuitem, line, 2, value); -} - -void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) { - onDrawMenuItem(menuitem, line); - Draw_Chkb_Line(line, checked); -} +// Special Menuitem Drawing functions ================================================= void onDrawBack(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 129, 72, 156, 84); @@ -2882,6 +2633,10 @@ void onDrawLanguage(MenuItemClass* menuitem, int8_t line) { void onDrawPwrLossR(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, recovery.enabled); } #endif +#if ENABLED(BAUD_RATE_GCODE) + void onDrawBaudrate(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, HMI_data.Baud115K); } +#endif + #if ENABLED(CASE_LIGHT_MENU) void onDrawCaseLight(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, caselight.on); } #endif @@ -3172,137 +2927,9 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) { } #endif -// HMI Control functions ====================================================== - -// Generic menu control using the encoder -void HMI_Menu() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (CurrentMenu) { - if (encoder_diffState == ENCODER_DIFF_ENTER) - CurrentMenu->onClick(); - else - CurrentMenu->onScroll(encoder_diffState == ENCODER_DIFF_CW); - } -} - -// Get an integer value using the encoder without draw anything -// lo: low limit -// hi: high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_value.Value)) { - EncoderRate.enabled = false; - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.Value, lo, hi); - return 1; - } - return 0; -} - -// Get an integer value using the encoder -// lo: low limit -// hi: high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_value.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Int(HMI_data.Text_Color, HMI_data.Background_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, HMI_value.Value); - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.Value, lo, hi); - DWINUI::Draw_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, HMI_value.Value); - return 1; - } - return 0; -} - -// Set an integer using the encoder -void HMI_SetInt() { - int8_t val = HMI_GetInt(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; break; - case 1: if (HMI_value.LiveUpdate) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply) HMI_value.Apply(); break; - } -} - -// Set an integer without drawing -void HMI_SetIntNoDraw() { - int8_t val = HMI_GetIntNoDraw(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; break; - case 1: if (HMI_value.LiveUpdate) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply) HMI_value.Apply(); break; - } -} - -// Set an integer pointer variable using the encoder -void HMI_SetPInt() { - int8_t val = HMI_GetInt(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate) HMI_value.LiveUpdate(); break; - case 2: *HMI_value.P_Int = HMI_value.Value; if (HMI_value.Apply) HMI_value.Apply(); break; - } -} - -// Get a scaled float value using the encoder -// dp: decimal places -// lo: scaled low limit -// hi: scaled high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_value.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp)); - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.Value, lo, hi); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp)); - return 1; - } - return 0; -} - -// Set a scaled float using the encoder -void HMI_SetFloat() { - const int8_t val = HMI_GetFloat(HMI_value.dp, HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply) HMI_value.Apply(); break; - } -} - -// Set a scaled float pointer variable using the encoder -void HMI_SetPFloat() { - const int8_t val = HMI_GetFloat(HMI_value.dp, HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate) HMI_value.LiveUpdate(); break; - case 2: *HMI_value.P_Float = HMI_value.Value / POW(10, HMI_value.dp); if (HMI_value.Apply) HMI_value.Apply(); break; - } -} +#if HAS_ONESTEP_LEVELING + void onDrawManualTramming(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, HMI_data.FullManualTramming); } +#endif // Menu Creation and Drawing functions ====================================================== @@ -3359,6 +2986,7 @@ void Draw_Prepare_Menu() { MENU_ITEM(ICON_Cool, GET_TEXT_F(MSG_COOLDOWN), onDrawCooldown, DoCoolDown); MENU_ITEM(ICON_Language, PSTR(GET_TEXT_F(MSG_UI_LANGUAGE)), onDrawLanguage, SetLanguage); } + ui.reset_status(true); CurrentMenu->draw(); } @@ -3369,13 +2997,17 @@ void Draw_Tramming_Menu() { if (CurrentMenu != TrammingMenu) { CurrentMenu = TrammingMenu; SetMenuTitle({0}, GET_TEXT_F(MSG_BED_TRAMMING)); // TODO: Chinese, English "Bed Tramming" JPG - DWINUI::MenuItemsPrepare(6); + DWINUI::MenuItemsPrepare(8); MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_FL), onDrawMenuItem, TramFL); MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_FR), onDrawMenuItem, TramFR); MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_BR), onDrawMenuItem, TramBR); MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_BL), onDrawMenuItem, TramBL); MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_C ), onDrawMenuItem, TramC ); + #if HAS_ONESTEP_LEVELING + MENU_ITEM(ICON_ProbeSet, F("Bed tramming wizard"), onDrawMenuItem, Trammingwizard); + MENU_ITEM(ICON_ProbeSet, GET_TEXT_F(MSG_BED_TRAMMING_MANUAL), onDrawManualTramming, SetManualTramming); + #endif } CurrentMenu->draw(); } @@ -3386,7 +3018,7 @@ void Draw_Control_Menu() { if (CurrentMenu != ControlMenu) { CurrentMenu = ControlMenu; SetMenuTitle({103, 1, 28, 14}, GET_TEXT_F(MSG_CONTROL)); - DWINUI::MenuItemsPrepare(8); + DWINUI::MenuItemsPrepare(10); MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); #if ENABLED(CASE_LIGHT_MENU) #if ENABLED(CASELIGHT_USES_BRIGHTNESS) @@ -3408,6 +3040,7 @@ void Draw_Control_Menu() { MENU_ITEM(ICON_Reboot, GET_TEXT_F(MSG_RESET_PRINTER), onDrawMenuItem, RebootPrinter); MENU_ITEM(ICON_Info, GET_TEXT_F(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_Info_Menu); } + ui.reset_status(true); CurrentMenu->draw(); } @@ -3417,8 +3050,11 @@ void Draw_AdvancedSettings_Menu() { if (CurrentMenu != AdvancedSettings) { CurrentMenu = AdvancedSettings; SetMenuTitle({0}, GET_TEXT_F(MSG_ADVANCED_SETTINGS)); // TODO: Chinese, English "Advanced Settings" JPG - DWINUI::MenuItemsPrepare(15); + DWINUI::MenuItemsPrepare(17); MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); + #if ENABLED(EEPROM_SETTINGS) + MENU_ITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom); + #endif #if HAS_HOME_OFFSET MENU_ITEM(ICON_HomeOffset, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawSubMenu, Draw_HomeOffset_Menu); #endif @@ -3437,6 +3073,9 @@ void Draw_AdvancedSettings_Menu() { #if ENABLED(POWER_LOSS_RECOVERY) MENU_ITEM(ICON_Pwrlossr, GET_TEXT_F(MSG_OUTAGE_RECOVERY), onDrawPwrLossR, SetPwrLossr); #endif + #if ENABLED(BAUD_RATE_GCODE) + MENU_ITEM(ICON_SetBaudRate, F("115K baud"), onDrawBaudrate, SetBaudRate); + #endif #if HAS_LCD_BRIGHTNESS EDIT_ITEM(ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS), onDrawPInt8Menu, SetBrightness, &ui.brightness); #endif @@ -3451,11 +3090,12 @@ void Draw_AdvancedSettings_Menu() { MENU_ITEM(ICON_ESDiag, F("End-stops diag."), onDrawSubMenu, Draw_EndStopDiag); #endif #if ENABLED(PRINTCOUNTER) - MENU_ITEM(ICON_PrintStats, GET_TEXT_F(MSG_INFO_STATS_MENU), onDrawSubMenu, Draw_PrintStats); + MENU_ITEM(ICON_PrintStats, GET_TEXT_F(MSG_INFO_STATS_MENU), onDrawSubMenu, Goto_PrintStats); MENU_ITEM(ICON_PrintStatsReset, GET_TEXT_F(MSG_INFO_PRINT_COUNT_RESET), onDrawSubMenu, PrintStats.Reset); #endif MENU_ITEM(ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN), onDrawMenuItem, DWIN_LockScreen); } + ui.reset_status(true); CurrentMenu->draw(); } @@ -3502,11 +3142,14 @@ void Draw_Move_Menu() { if (CurrentMenu != ProbeSetMenu) { CurrentMenu = ProbeSetMenu; SetMenuTitle({0}, GET_TEXT_F(MSG_ZPROBE_SETTINGS)); // TODO: Chinese, English "Probe Settings" JPG - DWINUI::MenuItemsPrepare(8); + DWINUI::MenuItemsPrepare(9); MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); EDIT_ITEM(ICON_ProbeOffsetX, GET_TEXT_F(MSG_ZPROBE_XOFFSET), onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); EDIT_ITEM(ICON_ProbeOffsetY, GET_TEXT_F(MSG_ZPROBE_YOFFSET), onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); EDIT_ITEM(ICON_ProbeOffsetZ, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); + #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + EDIT_ITEM(ICON_Temperature, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); + #endif #ifdef BLTOUCH_HS_MODE MENU_ITEM(ICON_HSMode, F("Enable HS mode"), onDrawHSMode, SetHSMode); #endif @@ -3596,7 +3239,7 @@ void Draw_GetColor_Menu() { MENU_ITEM(2, GET_TEXT_F(MSG_COLORS_BLUE), onDrawGetColorItem, SetRGBColor); } CurrentMenu->draw(); - DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335); + DWIN_Draw_Rectangle(1, *MenuData.P_Int, 20, 315, DWIN_WIDTH - 20, 335); } #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) @@ -3646,7 +3289,7 @@ void Draw_Tune_Menu() { if (CurrentMenu != TuneMenu) { CurrentMenu = TuneMenu; SetMenuTitle({73, 2, 28, 12}, GET_TEXT_F(MSG_TUNE)); // TODO: Chinese, English "Tune" JPG - DWINUI::MenuItemsPrepare(14); + DWINUI::MenuItemsPrepare(16); MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_PrintProcess); #if ENABLED(CASE_LIGHT_MENU) MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight); @@ -3679,6 +3322,7 @@ void Draw_Tune_Menu() { MENU_ITEM(ICON_Lock, GET_TEXT_F(MSG_LOCKSCREEN), onDrawMenuItem, DWIN_LockScreen); #if HAS_LCD_BRIGHTNESS EDIT_ITEM(ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS), onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM(ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS_OFF), onDrawMenuItem, TurnOffBacklight); #endif } CurrentMenu->draw(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 04ac1590eb..9f49fa1825 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -22,32 +22,18 @@ #pragma once /** - * Enhanced DWIN implementation + * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.9.2 - * date: 2021/11/21 - * - * Based on the original code provided by Creality under GPL + * Version: 3.15.2 + * Date: 2022/03/01 */ -#include "../../../inc/MarlinConfigPre.h" +#include "dwin_defines.h" #include "dwinui.h" #include "../common/encoder.h" #include "../../../libs/BL24CXX.h" -#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY) - #define HAS_ONESTEP_LEVELING 1 -#endif - -#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) - #define JUST_BABYSTEP 1 -#endif - -#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) - #define HAS_ZOFFSET_ITEM 1 -#endif - -#include "dwin_defines.h" +#include "../../../inc/MarlinConfig.h" enum processID : uint8_t { // Process ID @@ -60,23 +46,16 @@ enum processID : uint8_t { SetPFloat, SelectFile, PrintProcess, - PrintDone, - PwrlossRec, - Reboot, - Info, - ConfirmToPrint, - - // Popup Windows - Homing, + Popup, Leveling, - PidProcess, - ESDiagProcess, - PrintStatsProcess, - PauseOrStop, - FilamentPurge, - WaitResponse, Locked, - NothingToDo, + Reboot, + PrintDone, + ESDiagProcess, + WaitResponse, + Homing, + PidProcess, + NothingToDo }; enum pidresult_t : uint8_t { @@ -93,24 +72,18 @@ enum pidresult_t : uint8_t { typedef struct { int8_t Color[3]; // Color components - uint16_t pidgrphpoints = 0; pidresult_t pidresult = PID_DONE; int8_t Preheat = 0; // Material Select 0: PLA, 1: ABS, 2: Custom AxisEnum axis = X_AXIS; // Axis Select - int32_t MaxValue = 0; // Auxiliar max integer/scaled float value - int32_t MinValue = 0; // Auxiliar min integer/scaled float value - int8_t dp = 0; // Auxiliar decimal places - int32_t Value = 0; // Auxiliar integer / scaled float value - int16_t *P_Int = nullptr; // Auxiliar pointer to 16 bit integer variable - float *P_Float = nullptr; // Auxiliar pointer to float variable - void (*Apply)() = nullptr; // Auxiliar apply function - void (*LiveUpdate)() = nullptr; // Auxiliar live update function } HMI_value_t; typedef struct { uint8_t language; + bool remain_flag:1; // remain was override by M73 bool pause_flag:1; // printing is paused bool pause_action:1; // flag a pause action + bool abort_flag:1; // printing is aborting + bool abort_action:1; // flag a aborting action bool print_finish:1; // print was finished bool select_flag:1; // Popup button selected bool home_flag:1; // homing in course @@ -126,9 +99,6 @@ extern millis_t dwin_heat_time; #if HAS_HOTEND || HAS_HEATED_BED void DWIN_Popup_Temperature(const bool toohigh); #endif -#if HAS_HOTEND - void Popup_Window_ETempTooLow(); -#endif #if ENABLED(POWER_LOSS_RECOVERY) void Popup_PowerLossRecovery(); #endif @@ -143,50 +113,64 @@ void Goto_Main_Menu(); void Goto_Info_Menu(); void Goto_PowerLossRecovery(); void Goto_ConfirmToPrint(); -void Draw_Status_Area(const bool with_update); // Status Area +void DWIN_Draw_Dashboard(const bool with_update); // Status Area void Draw_Main_Area(); // Redraw main area; void DWIN_Redraw_screen(); // Redraw all screen elements -void HMI_StartFrame(const bool with_update); // Prepare the menu view 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 ApplyExtMinT(); void HMI_SetLanguageCache(); // Set the languaje image cache +void RebootPrinter(); +#if ENABLED(BAUD_RATE_GCODE) + void HMI_SetBaudRate(); + void SetBaud115K(); + void SetBaud250K(); +#endif +#if ENABLED(EEPROM_SETTINGS) + void WriteEeprom(); + void ReadEeprom(); + void ResetEeprom(); +#endif -void HMI_Init(); -void HMI_Popup(); +void HMI_WaitForUser(); void HMI_SaveProcessID(const uint8_t id); void HMI_AudioFeedback(const bool success=true); void EachMomentUpdate(); void update_variable(); +void DWIN_InitScreen(); void DWIN_HandleScreen(); -void DWIN_Update(); void DWIN_CheckStatusMessage(); void DWIN_StartHoming(); void DWIN_CompletedHoming(); #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval); + void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); #endif void DWIN_MeshLevelingStart(); void DWIN_CompletedLeveling(); void DWIN_PidTuning(pidresult_t result); -void DWIN_Print_Started(const bool sd = false); +void DWIN_Print_Started(const bool sd=false); +void DWIN_Print_Pause(); +void DWIN_Print_Resume(); void DWIN_Print_Finished(); +void DWIN_Print_Aborted(); #if HAS_FILAMENT_SENSOR void DWIN_FilamentRunout(const uint8_t extruder); #endif void DWIN_Progress_Update(); void DWIN_Print_Header(const char *text); void DWIN_SetColorDefaults(); +void DWIN_ApplyColor(); void DWIN_StoreSettings(char *buff); void DWIN_LoadSettings(const char *buff); void DWIN_SetDataDefaults(); void DWIN_RebootScreen(); #if ENABLED(ADVANCED_PAUSE_FEATURE) + void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button=0); void Draw_Popup_FilamentPurge(); - void DWIN_Popup_FilamentPurge(); + void Goto_FilamentPurge(); void HMI_FilamentPurge(); #endif @@ -207,14 +191,6 @@ void HMI_LockScreen(); void Draw_PrintStats(); #endif -// HMI user control functions -void HMI_Menu(); -void HMI_SetInt(); -void HMI_SetPInt(); -void HMI_SetIntNoDraw(); -void HMI_SetFloat(); -void HMI_SetPFloat(); - // Menu drawing functions void Draw_Control_Menu(); void Draw_AdvancedSettings_Menu(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index 3dc2408f4a..5065bb94d7 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -22,18 +22,37 @@ #pragma once /** - * DWIN general defines and data structs + * DWIN general defines and data structs for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.9.2 - * Date: 2021/11/21 - * - * Based on the original code provided by Creality under GPL + * Version: 3.11.2 + * Date: 2022/02/28 */ -//#define NEED_HEX_PRINT 1 //#define DEBUG_DWIN 1 +//#define NEED_HEX_PRINT 1 + +#include "../../../inc/MarlinConfigPre.h" +#include + +#if DISABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + #error "INDIVIDUAL_AXIS_HOMING_SUBMENU is required with ProUI." +#endif +#if DISABLED(LCD_SET_PROGRESS_MANUALLY) + #error "LCD_SET_PROGRESS_MANUALLY is required with ProUI." +#endif +#if DISABLED(STATUS_MESSAGE_SCROLLING) + #error "STATUS_MESSAGE_SCROLLING is required with ProUI." +#endif +#if DISABLED(BAUD_RATE_GCODE) + #error "BAUD_RATE_GCODE is required with ProUI." +#endif +#if DISABLED(SOUND_MENU_ITEM) + #error "SOUND_MENU_ITEM is required with ProUI." +#endif +#if DISABLED(PRINTCOUNTER) + #error "PRINTCOUNTER is required with ProUI." +#endif -#include "../../../core/types.h" #include "../common/dwin_color.h" #if ENABLED(LED_CONTROL_MENU) #include "../../../feature/leds/leds.h" @@ -57,8 +76,8 @@ #define Def_Barfill_Color BarFill_Color #define Def_Indicator_Color Color_White #define Def_Coordinate_Color Color_White +#define Def_Button_Color RGB( 0, 23, 16) -//#define HAS_GCODE_PREVIEW 1 #define HAS_ESDIAG 1 #if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS) @@ -101,6 +120,9 @@ typedef struct { #if ENABLED(PREVENT_COLD_EXTRUSION) int16_t ExtMinT = EXTRUDE_MINTEMP; #endif + int16_t BedLevT = PREHEAT_1_TEMP_BED; + TERN_(BAUD_RATE_GCODE, bool Baud115K = false); + bool FullManualTramming = false; // Led #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) LEDColor Led_Color = Def_Leds_Color; @@ -113,3 +135,8 @@ typedef struct { static constexpr size_t eeprom_data_size = 64; extern HMI_data_t HMI_data; + +#if PREHEAT_1_TEMP_BED + #undef LEVELING_BED_TEMP + #define LEVELING_BED_TEMP HMI_data.BedLevT +#endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp index b8bff35159..3da3fc8086 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp @@ -21,12 +21,10 @@ */ /** - * DWIN UI Enhanced implementation + * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.8.1 - * Date: 2021/11/09 - * - * Based on the original code provided by Creality under GPL + * Version: 3.9.1 + * Date: 2022/02/08 */ #include "../../../inc/MarlinConfigPre.h" @@ -37,6 +35,54 @@ #include "dwin_lcd.h" +/*---------------------------------------- Numeric related functions ----------------------------------------*/ + +// Draw a numeric value +// bShow: true=display background color; false=don't display background color +// zeroFill: true=zero fill; false=no zero fill +// signedMode: 1=signed; 0=unsigned +// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// fNum: Number of decimal digits +// x/y: Upper-left coordinate +// value: Integer value +void DWIN_Draw_Value(uint8_t bShow, bool signedMode, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) { + size_t i = 0; + DWIN_Byte(i, 0x14); + // Bit 7: bshow + // Bit 6: 1 = signed; 0 = unsigned number; + // Bit 5: zeroFill + // Bit 4: zeroMode + // Bit 3-0: size + DWIN_Byte(i, (bShow * 0x80) | (signedMode * 0x40) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); + DWIN_Word(i, color); + DWIN_Word(i, bColor); + DWIN_Byte(i, signedMode && (value >= 0) ? iNum + 1 : iNum); + DWIN_Byte(i, fNum); + DWIN_Word(i, x); + DWIN_Word(i, y); + // Write a big-endian 64 bit integer + const size_t p = i + 1; + for (size_t count = 8; count--;) { // 7..0 + ++i; + DWIN_SendBuf[p + count] = value; + value >>= 8; + } + DWIN_Send(i); +} + +// Draw a numeric value +// value: positive unscaled float value +void DWIN_Draw_Value(uint8_t bShow, bool signedMode, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + const int32_t val = round(value * POW(10, fNum)); + DWIN_Draw_Value(bShow, signedMode, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val); +} + /*---------------------------------------- Picture related functions ----------------------------------------*/ // Display QR code diff --git a/Marlin/src/lcd/e3v2/proui/dwin_lcd.h b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h index 623a94f09e..cdffb96f2f 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h @@ -22,16 +22,32 @@ #pragma once /** - * DWIN UI Enhanced implementation + * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.8.1 - * Date: 2021/11/09 - * - * Based on the original code provided by Creality under GPL + * Version: 3.9.1 + * Date: 2022/02/08 */ #include "../common/dwin_api.h" +// Draw a numeric value +// bShow: true=display background color; false=don't display background color +// zeroFill: true=zero fill; false=no zero fill +// signedMode: 1=signed; 0=unsigned +// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space +// size: Font size +// color: Character color +// bColor: Background color +// iNum: Number of digits +// fNum: Number of decimal digits +// x/y: Upper-left coordinate +// value: Integer value +void DWIN_Draw_Value(uint8_t bShow, bool signedMode, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value); +// value: positive unscaled float value +void DWIN_Draw_Value(uint8_t bShow, bool signedMode, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, + uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + // Display QR code // The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix // QR_Pixel: The pixel size occupied by each point of the QR code: 0x01-0x0F (1-16) diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp index 33f216fde6..59b6c0d328 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -21,12 +21,10 @@ */ /** - * DWIN UI Enhanced implementation + * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.10.1 - * Date: 2022/01/21 - * - * Based on the original code provided by Creality under GPL + * Version: 3.11.1 + * Date: 2022/02/28 */ #include "../../../inc/MarlinConfigPre.h" @@ -34,30 +32,64 @@ #if ENABLED(DWIN_LCD_PROUI) #include "dwin.h" +#include "dwinui.h" #include "dwin_popup.h" -void Draw_Select_Highlight(const bool sel) { +#include "../../../MarlinCore.h" // for wait_for_user + +popupDrawFunc_t popupDraw = nullptr; +popupClickFunc_t popupClick = nullptr; +popupChangeFunc_t popupChange = nullptr; + +uint16_t HighlightYPos = 280; + +void Draw_Select_Highlight(const bool sel, const uint16_t ypos) { + HighlightYPos = ypos; HMI_flag.select_flag = sel; const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color, c2 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color; - DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318); - DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319); - DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318); - DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319); + DWIN_Draw_Rectangle(0, c1, 25, ypos - 1, 126, ypos + 38); + DWIN_Draw_Rectangle(0, c1, 24, ypos - 2, 127, ypos + 39); + DWIN_Draw_Rectangle(0, c2, 145, ypos - 1, 246, ypos + 38); + DWIN_Draw_Rectangle(0, c2, 144, ypos - 2, 247, ypos + 39); } void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) { HMI_SaveProcessID(WaitResponse); - DWIN_Draw_Popup(icon, fmsg1, fmsg2, ICON_Continue_E); // Button Continue + DWIN_Draw_Popup(icon, fmsg1, fmsg2, BTN_Continue); // Button Continue DWIN_UpdateLCD(); } void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) { DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), fmsg2); - DWINUI::Draw_IconWB(ICON_Confirm_E, 26, 280); - DWINUI::Draw_IconWB(ICON_Cancel_E, 146, 280); - Draw_Select_Highlight(true); + DWINUI::Draw_Button(BTN_Confirm, 26, 280); + DWINUI::Draw_Button(BTN_Cancel, 146, 280); + Draw_Select_Highlight(HMI_flag.select_flag); DWIN_UpdateLCD(); } +void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick/*=nullptr*/, const popupChangeFunc_t fnChange/*=nullptr*/) { + popupDraw = fnDraw; + popupClick = fnClick; + popupChange = fnChange; + HMI_SaveProcessID(Popup); + HMI_flag.select_flag = false; + popupDraw(); +} + +void HMI_Popup() { + if (!wait_for_user) { + if (popupClick) popupClick(); + return; + } + else { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_CW || encoder_diffState == ENCODER_DIFF_CCW) { + const bool change = encoder_diffState != ENCODER_DIFF_CW; + if (popupChange) popupChange(change); else Draw_Select_Highlight(change, HighlightYPos); + DWIN_UpdateLCD(); + } + } +} + #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.h b/Marlin/src/lcd/e3v2/proui/dwin_popup.h index 2e952cc1b9..0d86499475 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.h @@ -22,20 +22,26 @@ #pragma once /** - * DWIN UI Enhanced implementation + * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.10.1 - * Date: 2022/01/21 - * - * Based on the original code provided by Creality under GPL + * Version: 3.11.1 + * Date: 2022/02/28 */ #include "dwinui.h" #include "dwin.h" -// Popup windows +typedef void (*popupDrawFunc_t)(); +typedef void (*popupClickFunc_t)(); +typedef void (*popupChangeFunc_t)(const bool state); +extern popupDrawFunc_t popupDraw; -void Draw_Select_Highlight(const bool sel); +void Draw_Select_Highlight(const bool sel, const uint16_t ypos); +inline void Draw_Select_Highlight(const bool sel) { Draw_Select_Highlight(sel, 280); }; +void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2); +void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2); +void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick=nullptr, const popupChangeFunc_t fnChange=nullptr); +void HMI_Popup(); inline void Draw_Popup_Bkgd() { DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330); @@ -49,7 +55,7 @@ void DWIN_Draw_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8 if (icon) DWINUI::Draw_Icon(icon, 101, 105); if (amsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, amsg1); if (amsg2) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 240, amsg2); - if (button) DWINUI::Draw_IconWB(button, 86, 280); + if (button) DWINUI::Draw_Button(button, 86, 280); } template @@ -61,10 +67,7 @@ void DWIN_Show_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8 template void DWIN_Popup_Confirm(const uint8_t icon, T amsg1, U amsg2) { HMI_SaveProcessID(WaitResponse); - DWIN_Draw_Popup(icon, amsg1, amsg2, ICON_Confirm_E); // Button Confirm + DWIN_Draw_Popup(icon, amsg1, amsg2, BTN_Confirm); // Button Confirm DWIN_UpdateLCD(); } -void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2); - -void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2); diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index 1dbd531390..ddc494fc84 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -21,12 +21,10 @@ */ /** - * DWIN UI Enhanced implementation + * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.8.2 - * Date: 2021/11/09 - * - * Based on the original code provided by Creality under GPL + * Version: 3.15.1 + * Date: 2022/02/25 */ #include "../../../inc/MarlinConfigPre.h" @@ -51,7 +49,9 @@ xy_int_t DWINUI::cursor = { 0 }; uint16_t DWINUI::pencolor = Color_White; uint16_t DWINUI::textcolor = Def_Text_Color; uint16_t DWINUI::backcolor = Def_Background_Color; +uint16_t DWINUI::buttoncolor = Def_Button_Color; uint8_t DWINUI::font = font8x16; +FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); void (*DWINUI::onCursorErase)(const int8_t line)=nullptr; void (*DWINUI::onCursorDraw)(const int8_t line)=nullptr; @@ -59,18 +59,16 @@ void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr; void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr; void DWINUI::init() { - DEBUG_ECHOPGM("\r\nDWIN handshake "); - delay(750); // Delay here or init later in the boot process - const bool success = DWIN_Handshake(); - if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error."); + TERN_(DEBUG_DWIN, SERIAL_ECHOPGM("\r\nDWIN handshake ")); + delay(750); // Delay for wait to wakeup screen + const bool hs = DWIN_Handshake(); + TERN(DEBUG_DWIN, SERIAL_ECHOLNF(hs ? F("ok.") : F("error.")), UNUSED(hs)); DWIN_Frame_SetDir(1); - TERN(SHOW_BOOTSCREEN,,DWIN_Frame_Clear(Color_Bg_Black)); - DWIN_UpdateLCD(); - cursor.x = 0; - cursor.y = 0; + cursor.reset(); pencolor = Color_White; textcolor = Def_Text_Color; backcolor = Def_Background_Color; + buttoncolor = Def_Button_Color; font = font8x16; } @@ -124,9 +122,10 @@ uint16_t DWINUI::RowToY(uint8_t row) { } // Set text/number color -void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor) { +void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { textcolor = fgcolor; backcolor = bgcolor; + buttoncolor = alcolor; } void DWINUI::SetTextColor(uint16_t fgcolor) { textcolor = fgcolor; @@ -159,16 +158,22 @@ void DWINUI::MoveBy(xy_int_t point) { cursor += point; } -// Draw a Centered string using DWIN_WIDTH -void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { - const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * fontWidth(size)) / 2 - 1; +// Draw a Centered string using arbitrary x1 and x2 margins +void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { + const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1; DWIN_Draw_String(bShow, size, color, bColor, x, y, string); } +// // Draw a Centered string using DWIN_WIDTH +// void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { +// const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * fontWidth(size)) / 2 - 1; +// DWIN_Draw_String(bShow, size, color, bColor, x, y, string); +// } + // Draw a char at cursor position -void DWINUI::Draw_Char(const char c) { +void DWINUI::Draw_Char(uint16_t color, const char c) { const char string[2] = { c, 0}; - DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, 1); + DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, 1); MoveBy(fontWidth(font), 0); } @@ -185,21 +190,26 @@ void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rli MoveBy(strlen(string) * fontWidth(font), 0); } -// Draw a signed floating point number -// bShow: true=display background color; false=don't display background color -// zeroFill: true=zero fill; false=no zero fill -// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space -// size: Font size -// bColor: Background color -// iNum: Number of whole digits -// fNum: Number of decimal digits -// x/y: Upper-left point -// value: Float value -void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value < 0 ? -value : value); - DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, value < 0 ? F("-") : F(" ")); +// ------------------------- Buttons ------------------------------// + +void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { + DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2); + Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); } +void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { + switch (id) { + case BTN_Cancel : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break; + case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break; + case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break; + case BTN_Print : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break; + case BTN_Save : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break; + default: break; + } +} + +// -------------------------- Extra -------------------------------// + // Draw a circle // color: circle color // x: the abscissa of the center of the circle @@ -247,13 +257,12 @@ void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) { // color1 : Start color // color2 : End color uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) { - uint8_t B,G,R; - float n; - n = (float)(val-minv)/(maxv-minv); - R = (1-n)*GetRColor(color1) + n*GetRColor(color2); - G = (1-n)*GetGColor(color1) + n*GetGColor(color2); - B = (1-n)*GetBColor(color1) + n*GetBColor(color2); - return RGB(R,G,B); + uint8_t B, G, R; + const float n = (float)(val - minv) / (maxv - minv); + R = (1 - n) * GetRColor(color1) + n * GetRColor(color2); + G = (1 - n) * GetGColor(color1) + n * GetGColor(color2); + B = (1 - n) * GetBColor(color1) + n * GetBColor(color2); + return RGB(R, G, B); } // Color Interpolator through Red->Yellow->Green->Blue @@ -261,33 +270,27 @@ uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t colo // minv : Minimum value // maxv : Maximum value uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { - uint8_t B,G,R; - const uint8_t maxB = 28; - const uint8_t maxR = 28; - const uint8_t maxG = 38; + uint8_t B, G, R; + const uint8_t maxB = 28, maxR = 28, maxG = 38; const int16_t limv = _MAX(abs(minv), abs(maxv)); - float n; - if (minv>=0) { - n = (float)(val-minv)/(maxv-minv); - } else { - n = (float)val/limv; - } - n = _MIN(1, n); - n = _MAX(-1, n); + float n = minv >= 0 ? (float)(val - minv) / (maxv - minv) : (float)val / limv; + LIMIT(n, -1, 1); if (n < 0) { R = 0; - G = (1+n)*maxG; - B = (-n)*maxB; - } else if (n < 0.5) { - R = maxR*n*2; + G = (1 + n) * maxG; + B = (-n) * maxB; + } + else if (n < 0.5) { + R = maxR * n * 2; G = maxG; B = 0; - } else { + } + else { R = maxR; - G = maxG*(1-n); + G = maxG * (1 - n); B = 0; } - return RGB(R,G,B); + return RGB(R, G, B); } // Draw a checkbox diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h index 595c534356..1504dcd305 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -22,12 +22,10 @@ #pragma once /** - * DWIN UI Enhanced implementation + * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.11.1 - * Date: 2022/01/19 - * - * Based on the original code provided by Creality under GPL + * Version: 3.15.1 + * Date: 2022/02/25 */ #include "dwin_lcd.h" @@ -107,6 +105,13 @@ #define ICON_CaseLight ICON_Motion #define ICON_LedControl ICON_Motion +// Buttons +#define BTN_Continue 85 +#define BTN_Cancel 87 +#define BTN_Confirm 89 +#define BTN_Print 90 +#define BTN_Save 91 + // Extended and default UI Colors #define Color_Black 0 #define Color_Green RGB(0,63,0) @@ -119,7 +124,11 @@ #define DWIN_FONT_HEAD font10x20 #define DWIN_FONT_ALERT font10x20 #define STATUS_Y 354 -#define LCD_WIDTH (DWIN_WIDTH / 8) +#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 + +// Minimum unit (0.1) : multiple (10) +#define UNITFDIGITS 1 +#define MINUNITMULT POW(10, UNITFDIGITS) constexpr uint16_t TITLE_HEIGHT = 30, // Title bar height MLINE = 53, // Menu line height @@ -212,7 +221,9 @@ namespace DWINUI { extern uint16_t pencolor; extern uint16_t textcolor; extern uint16_t backcolor; + extern uint16_t buttoncolor; extern uint8_t font; + extern FSTR_P const Author; extern void (*onCursorErase)(const int8_t line); extern void (*onCursorDraw)(const int8_t line); @@ -240,7 +251,7 @@ namespace DWINUI { uint16_t RowToY(uint8_t row); // Set text/number color - void SetColors(uint16_t fgcolor, uint16_t bgcolor); + void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor); void SetTextColor(uint16_t fgcolor); void SetBackgroundColor(uint16_t bgcolor); @@ -268,6 +279,17 @@ namespace DWINUI { DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y); } + // Extend a frame box + // v: value to extend + inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) { + frame_rect_t t; + t.x = frame.x - v; + t.y = frame.y - v; + t.w = frame.w + 2 * v; + t.h = frame.h + 2 * v; + return t; + } + // Draw an Icon with transparent background from the library ICON // icon: Icon ID // x/y: Upper-left point @@ -293,26 +315,56 @@ namespace DWINUI { // x/y: Upper-left coordinate // value: Integer value inline void Draw_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, x, y, value); + DWIN_Draw_Value(bShow, 0, zeroFill, zeroMode, size, color, bColor, iNum, 0, x, y, value); } inline void Draw_Int(uint8_t iNum, long value) { - DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + DWIN_Draw_Value(false, 0, true, 0, font, textcolor, backcolor, iNum, 0, cursor.x, cursor.y, value); MoveBy(iNum * fontWidth(font), 0); } inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value); + DWIN_Draw_Value(false, 0, true, 0, font, textcolor, backcolor, iNum, 0, x, y, value); } inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(false, true, 0, font, color, backcolor, iNum, x, y, value); + DWIN_Draw_Value(false, 0, true, 0, font, color, backcolor, iNum, 0, x, y, value); } inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(true, true, 0, font, color, bColor, iNum, x, y, value); + DWIN_Draw_Value(true, 0, true, 0, font, color, bColor, iNum, 0, x, y, value); } inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(true, true, 0, size, color, bColor, iNum, x, y, value); + DWIN_Draw_Value(true, 0, true, 0, size, color, bColor, iNum, 0, x, y, value); } - // Draw a floating point number + // Draw a signed integer + // bShow: true=display background color; false=don't display background color + // zeroFill: true=zero fill; false=no zero fill + // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space + // size: Font size + // color: Character color + // bColor: Background color + // iNum: Number of digits + // x/y: Upper-left coordinate + // value: Integer value + inline void Draw_Signed_Int(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(bShow, 1, zeroFill, zeroMode, size, color, bColor, iNum, 0, x, y, value); + } + inline void Draw_Signed_Int(uint8_t iNum, long value) { + DWIN_Draw_Value(false, 1, true, 0, font, textcolor, backcolor, iNum, 0, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(font), 0); + } + inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(false, 1, true, 0, font, textcolor, backcolor, iNum, 0, x, y, value); + } + inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(false, 1, true, 0, font, color, backcolor, iNum, 0, x, y, value); + } + inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(true, 1, true, 0, font, color, bColor, iNum, 0, x, y, value); + } + inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + DWIN_Draw_Value(true, 1, true, 0, size, color, bColor, iNum, 0, x, y, value); + } + + // Draw a positive floating point number // bShow: true=display background color; false=don't display background color // zeroFill: true=zero fill; false=no zero fill // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space @@ -324,23 +376,23 @@ namespace DWINUI { // x/y: Upper-left point // value: Float value inline void Draw_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(bShow, 0, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + DWIN_Draw_Value(false, 0, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); MoveBy((iNum + fNum + 1) * fontWidth(font), 0); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + DWIN_Draw_Value(false, 0, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Float(uint16_t color, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, color, backcolor, iNum, fNum, x, y, value); + DWIN_Draw_Value(false, 0, true, 0, font, color, backcolor, iNum, fNum, x, y, value); } inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(true, true, 0, font, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(true, 0, true, 0, font, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(true, true, 0, size, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(true, 0, true, 0, size, color, bColor, iNum, fNum, x, y, value); } // Draw a signed floating point number @@ -348,31 +400,35 @@ namespace DWINUI { // zeroFill: true=zero fill; false=no zero fill // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space // size: Font size + // color: Character color // bColor: Background color // iNum: Number of whole digits // fNum: Number of decimal digits // x/y: Upper-left point // value: Float value - void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + inline void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + DWIN_Draw_Value(bShow, 1, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value); + } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + DWIN_Draw_Value(false, 1, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); MoveBy((iNum + fNum + 1) * fontWidth(font), 0); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + DWIN_Draw_Value(false, 1, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(false, true, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); + DWIN_Draw_Value(false, 1, true, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(true, true, 0, font, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(true, 1, true, 0, font, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(true, true, 0, size, color, bColor, iNum, fNum, x, y, value); + DWIN_Draw_Value(true, 1, true, 0, size, color, bColor, iNum, fNum, x, y, value); } // Draw a char at cursor position - void Draw_Char(const char c); + void Draw_Char(uint16_t color, const char c); + inline void Draw_Char(const char c) { Draw_Char(textcolor, c); } // Draw a string at cursor position // color: Character color @@ -425,7 +481,10 @@ namespace DWINUI { // bColor: Background color // y: Upper coordinate of the string // *string: The string - void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string); + void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); + inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { + Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); + } inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); } @@ -487,6 +546,17 @@ namespace DWINUI { // color2 : End color uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2); + // ------------------------- Buttons ------------------------------// + + void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption); + inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) { + Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption)); + } + inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) { + Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption); + } + void Draw_Button(uint8_t id, uint16_t x, uint16_t y); + // -------------------------- Extra -------------------------------// // Draw a circle filled with color diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index f04c079017..74eb94e751 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -21,15 +21,12 @@ */ /** - * DWIN End Stops diagnostic page + * DWIN End Stops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.0.2 - * Date: 2021/11/06 - * - * Based on the original code provided by Creality under GPL + * Version: 1.2.2 + * Date: 2022/02/24 */ -#include "../../../inc/MarlinConfigPre.h" #include "dwin_defines.h" #if BOTH(DWIN_LCD_PROUI, HAS_ESDIAG) @@ -72,7 +69,7 @@ void ESDiagClass::Draw() { Title.ShowCaption(F("End-stops Diagnostic")); DWINUI::ClearMenuArea(); Draw_Popup_Bkgd(); - DWINUI::Draw_Icon(ICON_Continue_E, 86, 250); + DWINUI::Draw_Button(BTN_Continue, 86, 250); DWINUI::cursor.y = 80; #define ES_LABEL(S) draw_es_label(F(STR_##S)) #if HAS_X_MIN diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.h b/Marlin/src/lcd/e3v2/proui/endstop_diag.h index 4694ddb141..316a1e1ed3 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.h +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.h @@ -22,12 +22,10 @@ #pragma once /** - * DWIN End Stops diagnostic page + * DWIN End Stops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.0 - * Date: 2021/11/06 - * - * Based on the original code provided by Creality under GPL + * Version: 1.2.3 + * Date: 2022/02/24 */ class ESDiagClass { diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp index 2ccdcc1207..2895c01544 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -21,12 +21,10 @@ */ /** - * Lock screen implementation for DWIN UI Enhanced implementation + * Lock screen implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) * Version: 2.1 * Date: 2021/11/09 - * - * Based on the original code provided by Creality under GPL */ #include "../../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.h b/Marlin/src/lcd/e3v2/proui/lockscreen.h index bf2fdb3f4b..ec967fe2db 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.h +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.h @@ -22,12 +22,10 @@ #pragma once /** - * Lock screen implementation for DWIN UI Enhanced implementation + * Lock screen implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) * Version: 2.1 * Date: 2021/11/09 - * - * Based on the original code provided by Creality under GPL */ #include "../common/encoder.h" diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp new file mode 100644 index 0000000000..6dfcb8595c --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/menus.cpp @@ -0,0 +1,370 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Menu functions for ProUI + * Author: Miguel A. Risco-Castillo + * Version: 1.2.1 + * Date: 2022/02/25 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_LCD_PROUI) + +#include "../common/encoder.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" +#include "menus.h" + +MenuData_t MenuData; + +// Menuitem Drawing functions ================================================= + +void Draw_Title(TitleClass* title) { + DWIN_Draw_Rectangle(1, HMI_data.TitleBg_color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); + if (title->frameid) + DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1); + else + DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); +} + +void Draw_Menu(MenuClass* menu) { + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + DWIN_Draw_Rectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); +} + +void Draw_Menu_Cursor(const int8_t line) { + DWIN_Draw_Rectangle(1, HMI_data.Cursor_color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); +} + +void Erase_Menu_Cursor(const int8_t line) { + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); +} + +void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * const label /*=nullptr*/, bool more /*=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); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); +} + +void Draw_Chkb_Line(const uint8_t line, const bool checked) { + DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 16, MBASE(line) - 1, checked); +} + +void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value /*=0*/) { + DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); +} + +void onDrawMenuItem(MenuItemClass* menuitem, int8_t line) { + if (menuitem->icon) DWINUI::Draw_Icon(menuitem->icon, ICOX, MBASE(line) - 3); + if (menuitem->frameid) + DWIN_Frame_AreaCopy(menuitem->frameid, menuitem->frame.left, menuitem->frame.top, menuitem->frame.right, menuitem->frame.bottom, LBLX, MBASE(line)); + else if (menuitem->caption) + DWINUI::Draw_String(LBLX, MBASE(line) - 1, menuitem->caption); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); +} + +void onDrawSubMenu(MenuItemClass* menuitem, int8_t line) { + onDrawMenuItem(menuitem, line); + DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); +} + +void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, int32_t value) { + onDrawMenuItem(menuitem, line); + Draw_Menu_IntValue(HMI_data.Background_Color, line, 4, value); +} + +void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line) { + const int16_t value = *(int16_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line) { + const uint8_t value = *(uint8_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) { + const uint32_t value = *(uint32_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) { + onDrawMenuItem(menuitem, line); + DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value); +} + +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { + const float value = *(float*)static_cast(menuitem)->value; + const int8_t dp = UNITFDIGITS; + onDrawFloatMenu(menuitem, line, dp, value); +} + +void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { + const float value = *(float*)static_cast(menuitem)->value; + onDrawFloatMenu(menuitem, line, 2, value); +} + +void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) { + onDrawMenuItem(menuitem, line); + Draw_Chkb_Line(line, checked); +} + +//----------------------------------------------------------------------------- +// On click functions +//----------------------------------------------------------------------------- + +// Generic onclick event without draw +// process: process id HMI destiny +// lo: low limit +// hi: high limit +// dp: decimal places, 0 for integers +// 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*/) { + checkkey = process; + MenuData.MinValue = lo; + MenuData.MaxValue = hi; + MenuData.dp = dp; + MenuData.Apply = Apply; + MenuData.LiveUpdate = LiveUpdate; + MenuData.Value = val; + EncoderRate.enabled = true; +} + +// Generic onclick event for integer values +// process: process id HMI destiny +// lo: scaled low limit +// hi: scaled high limit +// 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*/) { + SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate); + Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, MenuData.Value); +} + +// Generic onclick event for float values +// process: process id HMI destiny +// lo: scaled low limit +// hi: scaled high limit +// 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*/) { + const int32_t value = round(val * POW(10, dp)); + SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate); + DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val); +} + +// Generic onclick event for integer values +// lo: scaled low limit +// hi: scaled high limit +// 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*/) { + SetValueOnClick(SetInt, lo, hi, val, Apply, LiveUpdate); +} + +// Generic onclick event for set pointer to 16 bit uinteger values +// lo: low limit +// 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*/) { + MenuData.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; + const int32_t value = *MenuData.P_Int; + SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate); +} + +// Generic onclick event for float values +// process: process id HMI destiny +// lo: low limit +// 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*/) { + SetValueOnClick(SetFloat, lo, hi, dp, val, Apply, LiveUpdate); +} + +// Generic onclick event for set pointer to float values +// lo: low limit +// 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*/) { + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + SetValueOnClick(SetPFloat, lo, hi, dp, *MenuData.P_Float, Apply, LiveUpdate); +} + +// HMI Control functions ====================================================== + +// Generic menu control using the encoder +void HMI_Menu() { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + if (CurrentMenu) { + if (encoder_diffState == ENCODER_DIFF_ENTER) + CurrentMenu->onClick(); + else + CurrentMenu->onScroll(encoder_diffState == ENCODER_DIFF_CW); + } +} + +// Get an integer value using the encoder without draw anything +// lo: low limit +// hi: high limit +// Return value: +// 0 : no change +// 1 : live change +// 2 : apply change +int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (Apply_Encoder(encoder_diffState, MenuData.Value)) { + EncoderRate.enabled = false; + checkkey = Menu; + return 2; + } + LIMIT(MenuData.Value, lo, hi); + return 1; + } + return 0; +} + +// Get an integer value using the encoder +// lo: low limit +// hi: high limit +// Return value: +// 0 : no change +// 1 : live change +// 2 : apply change +int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (Apply_Encoder(encoder_diffState, MenuData.Value)) { + EncoderRate.enabled = false; + DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Background_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); + checkkey = Menu; + return 2; + } + LIMIT(MenuData.Value, lo, hi); + DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); + return 1; + } + return 0; +} + +// Set an integer using the encoder +void HMI_SetInt() { + int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; break; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Set an integer without drawing +void HMI_SetIntNoDraw() { + int8_t val = HMI_GetIntNoDraw(MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; break; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Set an integer pointer variable using the encoder +void HMI_SetPInt() { + int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: *MenuData.P_Int = MenuData.Value; if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Get a scaled float value using the encoder +// dp: decimal places +// lo: scaled low limit +// hi: scaled high limit +// Return value: +// 0 : no change +// 1 : live change +// 2 : apply change +int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { + EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + if (encoder_diffState != ENCODER_DIFF_NO) { + if (Apply_Encoder(encoder_diffState, MenuData.Value)) { + EncoderRate.enabled = false; + DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); + checkkey = Menu; + return 2; + } + LIMIT(MenuData.Value, lo, hi); + DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); + return 1; + } + return 0; +} + +// Set a scaled float using the encoder +void HMI_SetFloat() { + const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Set a scaled float pointer variable using the encoder +void HMI_SetPFloat() { + const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: *MenuData.P_Float = MenuData.Value / POW(10, MenuData.dp); if (MenuData.Apply) MenuData.Apply(); break; + } +} + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h new file mode 100644 index 0000000000..0147c1616b --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -0,0 +1,94 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * Menu functions for ProUI + * Author: Miguel A. Risco-Castillo + * Version: 1.2.1 + * Date: 2022/02/25 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "dwinui.h" + +typedef struct { + int32_t MaxValue = 0; // Auxiliar max integer/scaled float value + int32_t MinValue = 0; // Auxiliar min integer/scaled float value + int8_t dp = 0; // Auxiliar decimal places + int32_t Value = 0; // Auxiliar integer / scaled float value + int16_t *P_Int = nullptr; // Auxiliar pointer to 16 bit integer variable + float *P_Float = nullptr; // Auxiliar pointer to float variable + void (*Apply)() = nullptr; // Auxiliar apply function + void (*LiveUpdate)() = nullptr; // Auxiliar live update function +} MenuData_t; + +extern MenuData_t MenuData; + +// 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 Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false); +void Draw_Chkb_Line(const uint8_t line, const bool checked); +void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value=0); +void onDrawMenuItem(MenuItemClass* menuitem, int8_t line); +void onDrawSubMenu(MenuItemClass* menuitem, int8_t line); +void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, int32_t value); +void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line); +void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line); +void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line); +void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value); +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line); +void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line); +void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked); + +// 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); + +// HMI user control functions ================================================= +void HMI_Menu(); +void HMI_SetInt(); +void HMI_SetPInt(); +void HMI_SetIntNoDraw(); +void HMI_SetFloat(); +void HMI_SetPFloat(); diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index 275a29cd38..0b22ae98d5 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -21,12 +21,10 @@ */ /** - * DWIN Mesh Viewer + * Mesh Viewer for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.9.1 - * Date: 2021/11/09 - * - * Based on the original code provided by Creality under GPL + * version: 3.12.1 + * Date: 2022/02/24 */ #include "../../../inc/MarlinConfigPre.h" @@ -40,49 +38,53 @@ #include "dwin_lcd.h" #include "dwinui.h" #include "dwin.h" +#include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" MeshViewerClass MeshViewer; -void MeshViewerClass::Draw() { +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) / (GRID_MAX_POINTS_X - 1), // Steps - sty = (DWIN_WIDTH - 2 * my) / (GRID_MAX_POINTS_Y - 1); + 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[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y], maxz =-32000, minz = 32000; + 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) - 12, py(yp) - 6, zv) + #define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 18, py(yp) - 6, zv) #define DrawMeshHLine(yp) DWIN_Draw_HLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx) - #define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(GRID_MAX_POINTS_Y - 1), DWIN_WIDTH - 2 * my) - GRID_LOOP(x, y) { - const float v = isnan(Z_VALUES(x,y)) ? 0 : round(Z_VALUES(x,y) * 100); + #define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(sizey - 1), DWIN_WIDTH - 2 * my) + int16_t maxz =-32000; int16_t minz = 32000; avg = 0; + LOOP_L_N(y, sizey) LOOP_L_N(x, sizex) { + const float v = isnan(zval[x][y]) ? 0 : round(zval[x][y] * 100); zmesh[x][y] = v; + avg += v; NOLESS(maxz, v); NOMORE(minz, v); } - Title.ShowCaption(F("Mesh Viewer")); + max = (float)maxz / 100; + min = (float)minz / 100; + avg = avg / (100 * sizex * sizey); DWINUI::ClearMenuArea(); - DWINUI::Draw_Icon(ICON_Continue_E, 86, 305); - DWIN_Draw_Rectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(GRID_MAX_POINTS_X - 1), py(GRID_MAX_POINTS_Y - 1)); - LOOP_S_L_N(x, 1, GRID_MAX_POINTS_X - 1) DrawMeshVLine(x); - LOOP_S_L_N(y, 1, GRID_MAX_POINTS_Y - 1) DrawMeshHLine(y); - LOOP_L_N(y, GRID_MAX_POINTS_Y) { + DWIN_Draw_Rectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(sizex - 1), py(sizey - 1)); + LOOP_S_L_N(x, 1, sizex - 1) DrawMeshVLine(x); + LOOP_S_L_N(y, 1, sizey - 1) DrawMeshHLine(y); + LOOP_L_N(y, sizey) { watchdog_refresh(); - LOOP_L_N(x, GRID_MAX_POINTS_X) { + LOOP_L_N(x, sizex) { 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 (GRID_MAX_POINTS_X < 9) - DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 12, py(y) - 6, Z_VALUES(x,y)); + if (sizex < 9) + 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) - 12, py(y) - 6, Z_VALUES(x,y)); + 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]); @@ -94,7 +96,7 @@ void MeshViewerClass::Draw() { sprintf_P(str_1, PSTR(".%02i"), zmesh[x][y]); break; case 100 ... 999: - DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y)); + DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 18, py(y) - 6, zval[x][y]); break; } if (str_1[0]) @@ -102,11 +104,25 @@ void MeshViewerClass::Draw() { } } } +} + +void MeshViewerClass::Draw(bool withsave /*= false*/) { + Title.ShowCaption(F("Mesh Viewer")); + DrawMesh(Z_VALUES_ARR, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); + if (withsave) { + DWINUI::Draw_Button(BTN_Save, 26, 305); + DWINUI::Draw_Button(BTN_Continue, 146, 305); + Draw_Select_Highlight(HMI_flag.select_flag, 305); + } else DWINUI::Draw_Button(BTN_Continue, 86, 305); char str_1[6], str_2[6] = ""; ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), - dtostrf((float)minz / 100, 1, 2, str_1), - dtostrf((float)maxz / 100, 1, 2, str_2) + dtostrf(min, 1, 2, str_1), + dtostrf(max, 1, 2, str_2) ); } +void Draw_MeshViewer() { MeshViewer.Draw(true); } +void onClick_MeshViewer() { if (HMI_flag.select_flag) WriteEeprom(); HMI_ReturnScreen(); } +void Goto_MeshViewer() { 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 acd5f0d5c4..f914bab4ae 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.h +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -21,18 +21,23 @@ */ #pragma once +#include "../../../core/types.h" +#include "../../../feature/bedlevel/bedlevel.h" + /** - * DWIN Mesh Viewer + * Mesh Viewer for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.9.1 - * Date: 2021/11/09 - * - * Based on the original code provided by Creality under GPL + * version: 3.12.1 + * Date: 2022/02/24 */ class MeshViewerClass { public: - void Draw(); + float avg, max, min; + void Draw(bool withsave = false); + void DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8_t sizey); }; extern MeshViewerClass MeshViewer; + +void Goto_MeshViewer(); diff --git a/Marlin/src/lcd/e3v2/proui/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp index 54c87f4be1..d4ca4ca225 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.cpp +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -21,12 +21,10 @@ */ /** - * DWIN Print Stats page + * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.1 - * Date: 2022/01/09 - * - * Based on the original code provided by Creality under GPL + * Version: 1.3.0 + * Date: 2022/02/24 */ #include "../../../inc/MarlinConfigPre.h" @@ -36,6 +34,7 @@ #include "printstats.h" #include "../../../core/types.h" +#include "../../../MarlinCore.h" #include "../../marlinui.h" #include "../../../module/printcounter.h" #include "dwin_lcd.h" @@ -53,7 +52,7 @@ void PrintStatsClass::Draw() { Title.ShowCaption(GET_TEXT_F(MSG_INFO_STATS_MENU)); DWINUI::ClearMenuArea(); Draw_Popup_Bkgd(); - DWINUI::Draw_Icon(ICON_Continue_E, 86, 250); + DWINUI::Draw_Button(BTN_Continue, 86, 250); printStatistics ps = print_job_timer.getStats(); sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_PRINT_COUNT), ps.totalPrints); @@ -75,4 +74,9 @@ void PrintStatsClass::Reset() { HMI_AudioFeedback(); } +void Goto_PrintStats() { + PrintStats.Draw(); + HMI_SaveProcessID(WaitResponse); +} + #endif // DWIN_LCD_PROUI && PRINTCOUNTER diff --git a/Marlin/src/lcd/e3v2/proui/printstats.h b/Marlin/src/lcd/e3v2/proui/printstats.h index f17e4dc9dd..705c923da4 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.h +++ b/Marlin/src/lcd/e3v2/proui/printstats.h @@ -22,18 +22,18 @@ #pragma once /** - * DWIN Print Stats page + * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.1 - * Date: 2022/01/09 - * - * Based on the original code provided by Creality under GPL + * Version: 1.3.0 + * Date: 2022/02/24 */ class PrintStatsClass { public: - void Draw(); + static void Draw(); static void Reset(); }; extern PrintStatsClass PrintStats; + +void Goto_PrintStats(); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 9925f225e3..7fe5c22271 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -151,6 +151,7 @@ namespace Language_en { LSTR MSG_BED_LEVELING = _UxGT("Bed Leveling"); LSTR MSG_LEVEL_BED = _UxGT("Level Bed"); LSTR MSG_BED_TRAMMING = _UxGT("Bed Tramming"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Manual Tramming"); LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Adjust bed until the probe triggers."); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Corners within tolerance. Bed trammed."); LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Good Points: "); @@ -402,7 +403,7 @@ namespace Language_en { LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness"); - LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD Sleep (s)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Turn Off LCD"); LSTR MSG_STORE_EEPROM = _UxGT("Store Settings"); LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults"); @@ -429,6 +430,8 @@ namespace Language_en { LSTR MSG_BUTTON_RESET = _UxGT("Reset"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ignore"); LSTR MSG_BUTTON_CANCEL = _UxGT("Cancel"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Confirm"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Continue"); LSTR MSG_BUTTON_DONE = _UxGT("Done"); LSTR MSG_BUTTON_BACK = _UxGT("Back"); LSTR MSG_BUTTON_PROCEED = _UxGT("Proceed"); @@ -438,6 +441,7 @@ namespace Language_en { LSTR MSG_BUTTON_PAUSE = _UxGT("Pause"); LSTR MSG_BUTTON_RESUME = _UxGT("Resume"); LSTR MSG_BUTTON_ADVANCED = _UxGT("Advanced"); + LSTR MSG_BUTTON_SAVE = _UxGT("Save"); LSTR MSG_PAUSING = _UxGT("Pausing..."); LSTR MSG_PAUSE_PRINT = _UxGT("Pause Print"); LSTR MSG_ADVANCED_PAUSE = _UxGT("Advanced Pause"); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 810d0db527..f0677afd2d 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -48,7 +48,6 @@ MarlinUI ui; #if ENABLED(DWIN_CREALITY_LCD) #include "e3v2/creality/dwin.h" #elif ENABLED(DWIN_LCD_PROUI) - #include "fontutils.h" #include "e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "e3v2/jyersui/dwin.h" @@ -1441,8 +1440,10 @@ void MarlinUI::init() { else if (print_job_timer.needsService(3)) msg = FPSTR(service3); #endif - else if (!no_welcome) - msg = GET_TEXT_F(WELCOME_MSG); + else if (!no_welcome) msg = GET_TEXT_F(WELCOME_MSG); + + else if (ENABLED(DWIN_LCD_PROUI)) + msg = F(""); else return; diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 36cbb14c5c..83eb332105 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -367,15 +367,6 @@ public: static void set_status(FSTR_P const fstr, const int8_t level=0); static void status_printf(const uint8_t level, FSTR_P const fmt, ...); - #if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) - static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); - #if DISABLED(LIGHTWEIGHT_UI) - static void draw_status_message(const bool blink); - #endif - #else - static void kill_screen(FSTR_P const, FSTR_P const) {} - #endif - #if HAS_DISPLAY static void update(); @@ -489,11 +480,16 @@ public: #endif static void draw_kill_screen(); + static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); + #if DISABLED(LIGHTWEIGHT_UI) + static void draw_status_message(const bool blink); + #endif #else // No LCD static void update() {} static void return_to_status() {} + static void kill_screen(FSTR_P const, FSTR_P const) {} #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index e0b2eccbbd..2b2e335565 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1467,16 +1467,18 @@ void MarlinSettings::postprocess() { // #if ENABLED(DWIN_LCD_PROUI) { + _FIELD_TEST(dwin_data); char dwin_data[eeprom_data_size] = { 0 }; DWIN_StoreSettings(dwin_data); - _FIELD_TEST(dwin_data); EEPROM_WRITE(dwin_data); } - #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #endif + + #if ENABLED(DWIN_CREALITY_LCD_JYERSUI) { + _FIELD_TEST(dwin_settings); char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 }; CrealityDWIN.Save_Settings(dwin_settings); - _FIELD_TEST(dwin_settings); EEPROM_WRITE(dwin_settings); } #endif diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index a96ed3a651..f83104fe9c 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -497,6 +497,9 @@ void Stepper::enable_axis(const AxisEnum axis) { bool Stepper::disable_axis(const AxisEnum axis) { mark_axis_disabled(axis); + + TERN_(DWIN_LCD_PROUI, set_axis_untrusted(axis)); // MRISCOC workaround: https://github.com/MarlinFirmware/Marlin/issues/23095 + // If all the axes that share the enabled bit are disabled const bool can_disable = can_axis_disable(axis); if (can_disable) { diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 4adf968919..653b3179b0 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -821,7 +821,7 @@ volatile bool Temperature::raw_temps_ready = false; hal.idletask(); // Run UI update - TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update()); + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); } wait_for_heatup = false; diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index 92d65babfa..5b48d7cadb 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -235,7 +235,7 @@ #define TFTGLCD_CS PA9 #endif - + #elif ENABLED(FYSETC_MINI_12864_2_1) #error "CAUTION! FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h index 8616a8fb34..fb7198e57c 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h @@ -28,7 +28,11 @@ #include "env_validate.h" #if HAS_MULTI_HOTEND || E_STEPPERS > 1 - #error "Creality V4 only supports one hotend / E-stepper. Comment out this line to continue." + #error "Creality V24S1 only supports one hotend / E-stepper. Comment out this line to continue." +#endif + +#if BOTH(BLTOUCH, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #error "Disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN when using BLTOUCH with Creality V24S1-301." #endif #define BOARD_INFO_NAME "Creality V24S1-301" @@ -44,7 +48,7 @@ // // Limit Switches // -#define Z_STOP_PIN PC14 +#define Z_STOP_PIN PA15 #ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN PC14 // BLTouch IN @@ -63,4 +67,22 @@ #define HEATER_BED_PIN PA7 // HOT BED #define FAN1_PIN PC0 // extruder fan +// +// SD Card +// +#define ONBOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PA4 // SDSS + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + //#define HEATER_0_PIN -1 + //#define HEATER_BED_PIN -1 + #define FAN_PIN -1 + #define SPINDLE_LASER_ENA_PIN PA0 // FET 1 + #define SPINDLE_LASER_PWM_PIN PA0 // Bed FET + #define SPINDLE_DIR_PIN PA0 // FET 4 +#endif + #include "pins_CREALITY_V4.h" diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 41ec44d4b7..724de8f82a 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -195,7 +195,7 @@ char *createFilename(char * const buffer, const dir_t &p) { } // -// Return 'true' if the item is something Marlin can read +// Return 'true' if the item is a folder, G-code file or Binary file // bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/)) { //uint8_t pn0 = p.name[0]; @@ -212,14 +212,15 @@ bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, ) return false; flag.filenameIsDir = DIR_IS_SUBDIR(&p); // We know it's a File or Folder + setBinFlag(p.name[8] == 'B' && // List .bin files (a firmware file for flashing) + p.name[9] == 'I' && + p.name[10]== 'N'); return ( flag.filenameIsDir // All Directories are ok + || fileIsBinary() // BIN files are accepted || (!onlyBin && p.name[8] == 'G' && p.name[9] != '~') // Non-backup *.G* files are accepted - || ( onlyBin && p.name[8] == 'B' - && p.name[9] == 'I' - && p.name[10] == 'N') // BIN files are accepted ); } @@ -867,6 +868,7 @@ void CardReader::selectFileByIndex(const uint16_t nr) { strcpy(filename, sortshort[nr]); strcpy(longFilename, sortnames[nr]); flag.filenameIsDir = IS_DIR(nr); + setBinFlag(strcmp_P(strrchr(filename, '.'), PSTR(".BIN")) == 0); return; } #endif @@ -884,6 +886,7 @@ void CardReader::selectFileByName(const char * const match) { strcpy(filename, sortshort[nr]); strcpy(longFilename, sortnames[nr]); flag.filenameIsDir = IS_DIR(nr); + setBinFlag(strcmp_P(strrchr(filename, '.'), PSTR(".BIN")) == 0); return; } #endif diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 2b3dcd00fb..483ab81395 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -80,6 +80,9 @@ typedef struct { filenameIsDir:1, workDirIsRoot:1, abort_sd_printing:1 + #if DO_LIST_BIN_FILES + , filenameIsBin:1 + #endif #if ENABLED(BINARY_FILE_TRANSFER) , binary_mode:1 #endif @@ -218,6 +221,10 @@ public: static void removeJobRecoveryFile(); #endif + // Binary flag for the current file + static bool fileIsBinary() { return TERN0(DO_LIST_BIN_FILES, flag.filenameIsBin); } + static void setBinFlag(const bool bin) { TERN(DO_LIST_BIN_FILES, flag.filenameIsBin = bin, UNUSED(bin)); } + // Current Working Dir - Set by cd, cdup, cdroot, and diveToFile(true, ...) static char* getWorkDirName() { workDir.getDosName(filename); return filename; } static SdFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } diff --git a/buildroot/tests/STM32F103RE_creality b/buildroot/tests/STM32F103RE_creality index 6a15ec1221..6440c56792 100755 --- a/buildroot/tests/STM32F103RE_creality +++ b/buildroot/tests/STM32F103RE_creality @@ -15,8 +15,9 @@ exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD -opt_enable DWIN_LCD_PROUI BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING BAUD_RATE_GCODE -exec_test $1 $2 "Ender 3 v2 with Pro UI" "$3" +opt_enable BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING BAUD_RATE_GCODE \ + DWIN_LCD_PROUI SOUND_MENU_ITEM PRINTCOUNTER +exec_test $1 $2 "Ender 3 v2 with ProUI" "$3" use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD From b123fa763d93f7f622abd9bf1a15ec6638c6d1ef Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Fri, 11 Mar 2022 23:09:04 +0000 Subject: [PATCH 095/203] =?UTF-8?q?=F0=9F=90=9B=20Restore=20STM32=20/=20ST?= =?UTF-8?q?M32F1=2012-bit=20ADC=20(#23871)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/STM32F1/HAL.cpp | 2 +- ini/stm32-common.ini | 1 + ini/stm32g0.ini | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index 1d58b106ad..636dc742fc 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -335,7 +335,7 @@ void MarlinHAL::adc_start(const pin_t pin) { _TCASE(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN, POWERMON_CURRENT) _TCASE(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN, POWERMON_VOLTS) } - adc_result = adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits + adc_result = (adc_results[(int)pin_index] & 0xFFF) >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits } #endif // __STM32F1__ diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini index 54bc746ff4..1d3f858bf8 100644 --- a/ini/stm32-common.ini +++ b/ini/stm32-common.ini @@ -16,6 +16,7 @@ build_flags = ${common.build_flags} -std=gnu++14 -DHAL_STM32 -DUSBCON -DUSBD_USE_CDC -DTIM_IRQ_PRIO=13 + -DADC_RESOLUTION=12 build_unflags = -std=gnu++11 src_filter = ${common.default_src_filter} + + extra_scripts = ${common.extra_scripts} diff --git a/ini/stm32g0.ini b/ini/stm32g0.ini index 171945ffe2..e6094c1e31 100644 --- a/ini/stm32g0.ini +++ b/ini/stm32g0.ini @@ -30,7 +30,6 @@ board = marlin_STM32G0B1RE board_build.offset = 0x2000 board_upload.offset_address = 0x08002000 build_flags = ${stm32_variant.build_flags} - -DADC_RESOLUTION=12 -DPIN_SERIAL4_RX=PC_11 -DPIN_SERIAL4_TX=PC_10 -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024 -DTIMER_SERVO=TIM3 -DTIMER_TONE=TIM4 From df4e022a48667369fcc94dfda56505eb3ba2019f Mon Sep 17 00:00:00 2001 From: Giuseppe499 Date: Sat, 12 Mar 2022 00:12:03 +0100 Subject: [PATCH 096/203] =?UTF-8?q?=F0=9F=9A=B8=20Fix,=20extend=20X=20Axis?= =?UTF-8?q?=20Twist=20Compensation=20(#23745)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/core/serial.cpp | 8 ++ Marlin/src/core/serial.h | 1 + Marlin/src/core/utility.cpp | 4 +- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 4 +- Marlin/src/feature/mixing.cpp | 2 +- Marlin/src/feature/x_twist.cpp | 19 ++--- Marlin/src/gcode/calibrate/G33.cpp | 3 +- Marlin/src/gcode/gcode.h | 5 ++ Marlin/src/gcode/probe/M423.cpp | 99 +++++++++++++++++++++++++ Marlin/src/lcd/menu/menu_x_twist.cpp | 2 +- Marlin/src/libs/vector_3.cpp | 3 +- Marlin/src/module/settings.cpp | 22 +++--- ini/features.ini | 2 +- platformio.ini | 2 +- 14 files changed, 142 insertions(+), 34 deletions(-) create mode 100644 Marlin/src/gcode/probe/M423.cpp diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 2b1ae1f1fe..562cddbaa0 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -78,6 +78,14 @@ void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P( void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); } +void serial_offset(const_float_t v, const uint8_t sp/*=0*/) { + if (v == 0 && sp == 1) + SERIAL_CHAR(' '); + else if (v > 0 || (v == 0 && sp == 2)) + SERIAL_CHAR('+'); + SERIAL_DECIMAL(v); +} + void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) { if (pre) serial_print(pre); serial_print(onoff ? on : off); diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index aee4d4d43d..98e82b6d72 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -345,6 +345,7 @@ void serialprint_onoff(const bool onoff); void serialprintln_onoff(const bool onoff); void serialprint_truefalse(const bool tf); void serial_spaces(uint8_t count); +void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space (sp==1) or plus (sp==2) void print_bin(const uint16_t val); void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr); diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 19e7626744..59e59d4cb7 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -126,10 +126,8 @@ void safe_delay(millis_t ms) { #if ABL_PLANAR SERIAL_ECHOPGM("ABL Adjustment"); LOOP_LINEAR_AXES(a) { - const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]; SERIAL_CHAR(' ', AXIS_CHAR(a)); - if (v > 0) SERIAL_CHAR('+'); - SERIAL_DECIMAL(v); + serial_offset(planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]); } #else #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 964f1123fe..c162062f86 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -213,8 +213,8 @@ void unified_bed_leveling::display_map(const uint8_t map_type) { else if (isnan(f)) SERIAL_ECHOF(human ? F(" . ") : F("NAN")); else if (human || csv) { - if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) - SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits + if (human && f >= 0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) + SERIAL_DECIMAL(f); // Positive: 5 digits, Negative: 6 digits } if (csv && i < (GRID_MAX_POINTS_X) - 1) SERIAL_CHAR('\t'); diff --git a/Marlin/src/feature/mixing.cpp b/Marlin/src/feature/mixing.cpp index 9ebc90127f..b1a069e320 100644 --- a/Marlin/src/feature/mixing.cpp +++ b/Marlin/src/feature/mixing.cpp @@ -63,7 +63,7 @@ void Mixer::normalize(const uint8_t tool_index) { #ifdef MIXER_NORMALIZER_DEBUG SERIAL_ECHOPGM("Mixer: Old relation : [ "); MIXER_STEPPER_LOOP(i) { - SERIAL_ECHO_F(collector[i] / csum, 3); + SERIAL_DECIMAL(collector[i] / csum); SERIAL_CHAR(' '); } SERIAL_ECHOLNPGM("]"); diff --git a/Marlin/src/feature/x_twist.cpp b/Marlin/src/feature/x_twist.cpp index 8910091239..b5ad25cba8 100644 --- a/Marlin/src/feature/x_twist.cpp +++ b/Marlin/src/feature/x_twist.cpp @@ -36,8 +36,8 @@ void XATC::reset() { constexpr float xzo[] = XATC_Z_OFFSETS; static_assert(COUNT(xzo) == XATC_MAX_POINTS, "XATC_Z_OFFSETS is the wrong size."); COPY(z_offset, xzo); - xatc.spacing = (probe.max_x() - probe.min_x()) / (XATC_MAX_POINTS - 1); - xatc.start = probe.min_x(); + start = probe.min_x(); + spacing = (probe.max_x() - start) / (XATC_MAX_POINTS - 1); enabled = true; } @@ -45,14 +45,10 @@ void XATC::print_points() { SERIAL_ECHOLNPGM(" X-Twist Correction:"); LOOP_L_N(x, XATC_MAX_POINTS) { SERIAL_CHAR(' '); - if (!isnan(z_offset[x])) { - if (z_offset[x] >= 0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(z_offset[x], 3); - } - else { - LOOP_L_N(i, 6) - SERIAL_CHAR(i ? '=' : ' '); - } + if (!isnan(z_offset[x])) + serial_offset(z_offset[x]); + else + LOOP_L_N(i, 6) SERIAL_CHAR(i ? '=' : ' '); } SERIAL_EOL(); } @@ -63,8 +59,7 @@ float XATC::compensation(const xy_pos_t &raw) { if (!enabled) return 0; if (NEAR_ZERO(spacing)) return 0; float t = (raw.x - start) / spacing; - int i = FLOOR(t); - LIMIT(i, 0, XATC_MAX_POINTS - 2); + const int i = constrain(FLOOR(t), 0, XATC_MAX_POINTS - 2); t -= i; return lerp(t, z_offset[i], z_offset[i + 1]); } diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index a4b9aec01b..506f367947 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -98,8 +98,7 @@ void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) { void print_signed_float(FSTR_P const prefix, const_float_t f) { SERIAL_ECHOPGM(" "); SERIAL_ECHOF(prefix, AS_CHAR(':')); - if (f >= 0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(f, 2); + serial_offset(f); } /** diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index a150aca41d..6e331c1273 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -1195,6 +1195,11 @@ private: static void M1000(); #endif + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + static void M423(); + static void M423_report(const bool forReplay=true); + #endif + #if ENABLED(SDSUPPORT) static void M1001(); #endif diff --git a/Marlin/src/gcode/probe/M423.cpp b/Marlin/src/gcode/probe/M423.cpp new file mode 100644 index 0000000000..fde5aaaf87 --- /dev/null +++ b/Marlin/src/gcode/probe/M423.cpp @@ -0,0 +1,99 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * M423.cpp - X-Axis Twist Compensation + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + +#include "../gcode.h" +#include "../../feature/x_twist.h" +#include "../../module/probe.h" + +/** + * M423: Set a Z offset for X-Twist (added to the mesh on future G29). + * M423 [R] [A] [I] [X Z] + * + * R - Reset the twist compensation data + * A - Set the X twist starting X position + * E - Set the X twist ending X position + * I - Set the X twist X-spacing directly + * X - Index of a Z value in the list + * Z - A Z value to set + */ +void GcodeSuite::M423() { + + bool do_report = true; + float new_spacing = 0; + + if (parser.seen_test('R')) { + do_report = false; + xatc.reset(); + } + if (parser.seenval('A')) { + do_report = false; + xatc.start = parser.value_float(); + new_spacing = (probe.max_x() - xatc.start) / (XATC_MAX_POINTS - 1); + } + if (parser.seenval('E')) { + do_report = false; + new_spacing = (parser.value_float() - xatc.start) / (XATC_MAX_POINTS - 1); + } + else if (parser.seenval('I')) { + do_report = false; + new_spacing = parser.value_float(); + } + + if (new_spacing) xatc.spacing = new_spacing; + + if (parser.seenval('X')) { + do_report = false; + const int8_t x = parser.value_int(); + if (!WITHIN(x, 0, XATC_MAX_POINTS - 1)) + SERIAL_ECHOLNPGM("?(X) out of range (0..", XATC_MAX_POINTS - 1, ")."); + else { + if (parser.seenval('Z')) + xatc.z_offset[x] = parser.value_linear_units(); + else + SERIAL_ECHOLNPGM("?(Z) required."); + } + } + + if (do_report) M423_report(); + +} + +void GcodeSuite::M423_report(const bool forReplay/*=true*/) { + report_heading(forReplay, F("X-Twist Correction")); + SERIAL_ECHOLNPGM(" M423 A", xatc.start, " I", xatc.spacing); + LOOP_L_N(x, XATC_MAX_POINTS) { + const float z = xatc.z_offset[x]; + SERIAL_ECHOPGM(" M423 X", x, " Z"); + serial_offset(isnan(z) ? 0 : z); + SERIAL_EOL(); + } +} + +#endif // X_AXIS_TWIST_COMPENSATION diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp index 93f8de07ad..ce46053dfc 100644 --- a/Marlin/src/lcd/menu/menu_x_twist.cpp +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -153,7 +153,7 @@ void xatc_wizard_goto_next_point() { measured_z = probe.probe_at_point(x, XATC_Y_POSITION, PROBE_PT_STOW); xatc.set_enabled(true); current_position += probe.offset_xy; - current_position.z = XATC_START_Z - probe.offset.z + measured_z; + current_position.z = (XATC_START_Z) - probe.offset.z + measured_z; line_to_current_position(MMM_TO_MMS(XY_PROBE_FEEDRATE)); ui.wait_for_move = false; } diff --git a/Marlin/src/libs/vector_3.cpp b/Marlin/src/libs/vector_3.cpp index 614d2121b8..02945fe687 100644 --- a/Marlin/src/libs/vector_3.cpp +++ b/Marlin/src/libs/vector_3.cpp @@ -141,8 +141,7 @@ void matrix_3x3::debug(FSTR_P const title) { if (title) SERIAL_ECHOLNF(title); LOOP_L_N(i, 3) { LOOP_L_N(j, 3) { - if (vectors[i][j] >= 0.0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(vectors[i][j], 6); + serial_offset(vectors[i][j], 2); SERIAL_CHAR(' '); } SERIAL_EOL(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 2b2e335565..6eb17d5d2e 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,7 @@ typedef struct SettingsDataStruct { // X_AXIS_TWIST_COMPENSATION // #if ENABLED(X_AXIS_TWIST_COMPENSATION) - XATC xatc; // TBD + XATC xatc; // M423 X Z #endif // @@ -901,7 +901,9 @@ void MarlinSettings::postprocess() { // #if ENABLED(X_AXIS_TWIST_COMPENSATION) _FIELD_TEST(xatc); - EEPROM_WRITE(xatc); + EEPROM_WRITE(xatc.spacing); + EEPROM_WRITE(xatc.start); + EEPROM_WRITE(xatc.z_offset); #endif // @@ -1809,7 +1811,10 @@ void MarlinSettings::postprocess() { // X Axis Twist Compensation // #if ENABLED(X_AXIS_TWIST_COMPENSATION) - EEPROM_READ(xatc); + _FIELD_TEST(xatc); + EEPROM_READ(xatc.spacing); + EEPROM_READ(xatc.start); + EEPROM_READ(xatc.z_offset); #endif // @@ -3337,14 +3342,13 @@ void MarlinSettings::reset() { #endif - // TODO: Create G-code for settings - //#if ENABLED(X_AXIS_TWIST_COMPENSATION) - // CONFIG_ECHO_START(); - // xatc.print_points(); - //#endif - #endif // HAS_LEVELING + // + // X Axis Twist Compensation + // + TERN_(X_AXIS_TWIST_COMPENSATION, gcode.M423_report(forReplay)); + // // Editable Servo Angles // diff --git a/ini/features.ini b/ini/features.ini index 9a68f2470f..9150ff5451 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -98,7 +98,7 @@ USB_FLASH_DRIVE_SUPPORT = src_filter=+ + AUTO_BED_LEVELING_BILINEAR = src_filter=+ AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ -X_AXIS_TWIST_COMPENSATION = src_filter=+ + +X_AXIS_TWIST_COMPENSATION = src_filter=+ + + MESH_BED_LEVELING = src_filter=+ + AUTO_BED_LEVELING_UBL = src_filter=+ + UBL_HILBERT_CURVE = src_filter=+ diff --git a/platformio.ini b/platformio.ini index 9b64bdd377..0e50da2b73 100644 --- a/platformio.ini +++ b/platformio.ini @@ -150,7 +150,7 @@ default_src_filter = + - - + - - - - - - + - - - - - From 2d8ec4fe9e4f32c738119813bfc891d90c56c015 Mon Sep 17 00:00:00 2001 From: GatCode Date: Sat, 12 Mar 2022 00:56:31 +0100 Subject: [PATCH 097/203] =?UTF-8?q?=F0=9F=93=8C=20Fix,=20extend=20Index=20?= =?UTF-8?q?Rev03=20Mobo=20(#23851)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/inc/SanityCheck.h | 4 +- Marlin/src/pins/stm32f4/pins_INDEX_REV03.h | 94 ++++++++++++++++------ 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 83d37f22df..a94846275e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2183,9 +2183,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Test Sensor & Heater pin combos. * Pins and Sensor IDs must be set for each heater */ -#if !ANY_PIN(TEMP_0, TEMP_0_CS) +#if HAS_EXTRUDERS && !ANY_PIN(TEMP_0, TEMP_0_CS) #error "TEMP_0_PIN or TEMP_0_CS_PIN not defined for this board." -#elif !HAS_HEATER_0 && EXTRUDERS +#elif HAS_EXTRUDERS && !HAS_HEATER_0 #error "HEATER_0_PIN not defined for this board." #elif TEMP_SENSOR_0_IS_MAX_TC && !PIN_EXISTS(TEMP_0_CS) #error "TEMP_SENSOR_0 MAX thermocouple requires TEMP_0_CS_PIN." diff --git a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h b/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h index a9828c5bda..977f476343 100644 --- a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h +++ b/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h @@ -60,12 +60,12 @@ // None of these require limit switches by default, so we leave these commented // here for your reference. -// #define I_MIN_PIN PA8 -// #define I_MAX_PIN PA8 -// #define J_MIN_PIN PD13 -// #define J_MAX_PIN PD13 -// #define K_MIN_PIN PC9 -// #define K_MAX_PIN PC9 +//#define I_MIN_PIN PA8 +//#define I_MAX_PIN PA8 +//#define J_MIN_PIN PD13 +//#define J_MAX_PIN PD13 +//#define K_MIN_PIN PC9 +//#define K_MAX_PIN PC9 // // Steppers @@ -73,47 +73,81 @@ #define X_STEP_PIN PB15 #define X_DIR_PIN PB14 #define X_ENABLE_PIN PD9 -#define X_SERIAL_TX_PIN PD8 -#define X_SERIAL_RX_PIN PD8 #define Y_STEP_PIN PE15 #define Y_DIR_PIN PE14 #define Y_ENABLE_PIN PB13 -#define Y_SERIAL_TX_PIN PB12 -#define Y_SERIAL_RX_PIN PB12 #define Z_STEP_PIN PE7 #define Z_DIR_PIN PB1 #define Z_ENABLE_PIN PE9 -#define Z_SERIAL_TX_PIN PE8 -#define Z_SERIAL_RX_PIN PE8 #define I_STEP_PIN PC4 #define I_DIR_PIN PA4 #define I_ENABLE_PIN PB0 -#define I_SERIAL_TX_PIN PC5 -#define I_SERIAL_RX_PIN PC5 #define J_STEP_PIN PE11 #define J_DIR_PIN PE10 #define J_ENABLE_PIN PE13 -#define J_SERIAL_TX_PIN PE12 -#define J_SERIAL_RX_PIN PE12 -#define K_SERIAL_TX_PIN PA2 -#define K_SERIAL_RX_PIN PA2 #define K_STEP_PIN PD6 #define K_DIR_PIN PD7 #define K_ENABLE_PIN PA3 -// Reduce baud rate to improve software serial reliability -#define TMC_BAUD_RATE 19200 +#if HAS_TMC_SPI + /** + * Make sure to configure the jumpers on the back side of the Mobo according to + * this diagram: https://github.com/MarlinFirmware/Marlin/pull/23851 + */ + #error "SPI drivers require a custom jumper configuration, see comment above! Comment out this line to continue." -// Not required for this board. Fails to compile otherwise. -// PD0 is not connected on this board. -#define TEMP_0_PIN PD0 + #if AXIS_HAS_SPI(X) + #define X_CS_PIN PD8 + #endif + #if AXIS_HAS_SPI(Y) + #define Y_CS_PIN PB12 + #endif + #if AXIS_HAS_SPI(Z) + #define Z_CS_PIN PE8 + #endif + #if AXIS_HAS_SPI(I) + #define I_CS_PIN PC5 + #endif + #if AXIS_HAS_SPI(J) + #define J_CS_PIN PE12 + #endif + #if AXIS_HAS_SPI(K) + #define K_CS_PIN PA2 + #endif -// General use mosfets, useful for things like pumps and solenoids +#elif HAS_TMC_UART + + #define X_SERIAL_TX_PIN PD8 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PB12 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE8 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define I_SERIAL_TX_PIN PC5 + #define I_SERIAL_RX_PIN I_SERIAL_TX_PIN + + #define J_SERIAL_TX_PIN PE12 + #define J_SERIAL_RX_PIN J_SERIAL_TX_PIN + + #define K_SERIAL_TX_PIN PA2 + #define K_SERIAL_RX_PIN K_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + +#endif + +// +// Heaters / Fans +// #define FAN_PIN PE2 #define FAN1_PIN PE3 #define FAN2_PIN PE4 @@ -121,16 +155,26 @@ #define FAN_SOFT_PWM_REQUIRED -// Neopixel Rings +// +// Neopixel +// #define NEOPIXEL_PIN PC7 #define NEOPIXEL2_PIN PC8 +// // SPI +// #define MISO_PIN PB4 #define MOSI_PIN PB5 #define SCK_PIN PB3 +#define TMC_SW_MISO MISO_PIN +#define TMC_SW_MOSI MOSI_PIN +#define TMC_SW_SCK SCK_PIN + +// // I2C +// #define I2C_SDA_PIN PB7 #define I2C_SCL_PIN PB6 From 05636262863465e9b2b40a49eac2f9e1622ecb01 Mon Sep 17 00:00:00 2001 From: kisslorand <50251547+kisslorand@users.noreply.github.com> Date: Sat, 12 Mar 2022 02:21:08 +0200 Subject: [PATCH 098/203] =?UTF-8?q?=F0=9F=9A=B8=20M401=20H=20-=20Report=20?= =?UTF-8?q?BLTouch=20HS=20State=20(#23724)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/probe/M401_M402.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index 7cbae76f4b..3389574919 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -36,12 +36,18 @@ * M401: Deploy and activate the Z probe * * With BLTOUCH_HS_MODE: + * H Report the current BLTouch HS mode state and exit * S Set High Speed (HS) Mode and exit without deploy */ void GcodeSuite::M401() { - if (parser.seen('S')) { + const bool seenH = parser.seen_test('H'), + seenS = parser.seen('S'); + if (seenH || seenS) { #ifdef BLTOUCH_HS_MODE - bltouch.high_speed_mode = parser.value_bool(); + if (seenS) bltouch.high_speed_mode = parser.value_bool(); + SERIAL_ECHO_START(); + SERIAL_ECHOPGM("BLTouch HS mode "); + serialprintln_onoff(bltouch.high_speed_mode); #endif } else { From 8e87e4cb5eb5d92a7d7b7c8d40a285c2fc7fba2e Mon Sep 17 00:00:00 2001 From: BIGTREETECH <38851044+bigtreetech@users.noreply.github.com> Date: Sat, 12 Mar 2022 08:23:18 +0800 Subject: [PATCH 099/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20STM?= =?UTF-8?q?32G0Bx=20:=20Use=20PLLQ=20for=20USB=20clock=20(#23870)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../variant_MARLIN_STM32G0B1RE.cpp | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp index e53fb4182c..8af7150dc7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp @@ -115,11 +115,11 @@ extern "C" { * AHB Prescaler = 1 * APB1 Prescaler = 1 * PLL_M = 1 - * PLL_N = 16 - * PLL_R = 2 + * PLL_N = 24 + * PLL_R = 3 * PLL_P = 2 - * PLL_Q = 2 - * USB(Hz) = 48000000 (HSI48M) + * PLL_Q = 4 + * USB(Hz) = 48000000 (PLLQ) * @param None * @retval None */ @@ -129,22 +129,31 @@ WEAK void SystemClock_Config(void) RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; + // Reset clock registers (in case bootloader has changed them) + RCC->CR |= RCC_CR_HSION; + while (!(RCC->CR & RCC_CR_HSIRDY)) + ; + RCC->CFGR = 0x00000000; + RCC->CR = RCC_CR_HSION; + while (RCC->CR & RCC_CR_PLLRDY) + ; + RCC->PLLCFGR = 0x00001000; + /** Configure the main internal regulator output voltage */ HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_HSI48; + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; - RCC_OscInitStruct.PLL.PLLN = 16; + RCC_OscInitStruct.PLL.PLLN = 24; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; - RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; - RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4; + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV3; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); @@ -164,7 +173,7 @@ WEAK void SystemClock_Config(void) /** Initializes the peripherals clocks */ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; - PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); From 5bbb345b55692ca663fcddd87f64c63a304dbbe6 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 12 Mar 2022 00:43:48 +0000 Subject: [PATCH 100/203] [cron] Bump distribution date (2022-03-12) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 3bc9da0b3f..49daf8dd7f 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-11" +//#define STRING_DISTRIBUTION_DATE "2022-03-12" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 07f09590b6..76889cb40a 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-11" + #define STRING_DISTRIBUTION_DATE "2022-03-12" #endif /** From 66efa0b09b89b22eecc04ff370b1f4458f790116 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 12 Mar 2022 15:53:04 -0500 Subject: [PATCH 101/203] Initial commit - Flexible Runout Configuration M591 --- Marlin/src/feature/host_actions.cpp | 2 +- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/runout.cpp | 18 +- Marlin/src/feature/runout.h | 155 ++++++------------ Marlin/src/gcode/feature/pause/M600.cpp | 2 +- .../feature/runout/{M412.cpp => M591.cpp} | 70 +++++--- Marlin/src/gcode/gcode.cpp | 9 +- Marlin/src/gcode/gcode.h | 5 +- Marlin/src/gcode/host/M115.cpp | 2 +- Marlin/src/inc/Conditionals_adv.h | 3 - Marlin/src/inc/SanityCheck.h | 4 - Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 32 ++-- Marlin/src/lcd/e3v2/proui/dwin.cpp | 16 +- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 2 +- .../generic/filament_runout_screen.cpp | 21 +-- Marlin/src/lcd/extui/ui_api.cpp | 11 +- Marlin/src/lcd/extui/ui_api.h | 10 +- Marlin/src/lcd/menu/menu_advanced.cpp | 4 +- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_filament.cpp | 2 +- Marlin/src/module/endstops.cpp | 22 ++- Marlin/src/module/settings.cpp | 66 +++++--- Marlin/src/module/stepper.cpp | 4 +- 23 files changed, 221 insertions(+), 243 deletions(-) rename Marlin/src/gcode/feature/runout/{M412.cpp => M591.cpp} (53%) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index c03a6bc597..3385076701 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -177,7 +177,7 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { #endif #if HAS_FILAMENT_SENSOR if (runout.filament_ran_out) { // Disable a triggered sensor - runout.enabled = false; + runout.enabled[active_extruder] = false; runout.reset(); } #endif diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 2813337c63..2bb69fa9c6 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -140,7 +140,7 @@ uint8_t MMU2::get_current_tool() { } #if EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) - #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE) + #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != (runout.mode[0]==2 ? HIGH, LOW)) #endif void MMU2::mmu_loop() { diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 98b6bd0510..7791637699 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -32,9 +32,9 @@ FilamentMonitor runout; -bool FilamentMonitorBase::enabled = true, +bool FilamentMonitorBase::enabled[HOTENDS] = {true}, FilamentMonitorBase::filament_ran_out; // = false - +uint8_t FilamentMonitorBase::mode[HOTENDS] = FILAMENT_RUNOUT_DEFAULT_MODE; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif @@ -45,15 +45,11 @@ bool FilamentMonitorBase::enabled = true, #include "../core/debug_out.h" #endif -#if HAS_FILAMENT_RUNOUT_DISTANCE - float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM; - volatile float RunoutResponseDelayed::runout_mm_countdown[NUM_RUNOUT_SENSORS]; - #if ENABLED(FILAMENT_MOTION_SENSOR) - uint8_t FilamentSensorEncoder::motion_detected; - #endif -#else - int8_t RunoutResponseDebounced::runout_count[NUM_RUNOUT_SENSORS]; // = 0 -#endif + +float RunoutResponseDelayed::runout_distance_mm[HOTENDS] = FILAMENT_RUNOUT_DISTANCE_MM; +volatile float RunoutResponseDelayed::runout_mm_countdown[HOTENDS]; +uint8_t FilamentSensorCore::motion_detected; + // // Filament Runout event handler diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index e74d857a79..2844264481 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -47,16 +47,14 @@ void event_filament_runout(const uint8_t extruder); template class TFilamentMonitor; -class FilamentSensorEncoder; -class FilamentSensorSwitch; +class FilamentSensorCore; class RunoutResponseDelayed; -class RunoutResponseDebounced; /********************************* TEMPLATE SPECIALIZATION *********************************/ typedef TFilamentMonitor< - TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced), - TERN(FILAMENT_MOTION_SENSOR, FilamentSensorEncoder, FilamentSensorSwitch) + RunoutResponseDelayed, + FilamentSensorCore > FilamentMonitor; extern FilamentMonitor runout; @@ -65,7 +63,8 @@ extern FilamentMonitor runout; class FilamentMonitorBase { public: - static bool enabled, filament_ran_out; + static bool enabled[HOTENDS], filament_ran_out; + static uint8_t mode[HOTENDS]; #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -99,10 +98,8 @@ class TFilamentMonitor : public FilamentMonitorBase { response.filament_present(extruder); } - #if HAS_FILAMENT_RUNOUT_DISTANCE - static float& runout_distance() { return response.runout_distance_mm; } - static void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; } - #endif + static float& runout_distance(uint8_t extruder=0) { return response.runout_distance_mm[extruder]; } + static void set_runout_distance(const_float_t mm, uint8_t extruder=0) { response.runout_distance_mm[extruder] = mm; } // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. @@ -116,11 +113,11 @@ class TFilamentMonitor : public FilamentMonitorBase { // Give the response a chance to update its counter. static void run() { if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) { - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here + cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); sensor.run(); const uint8_t runout_flags = response.has_run_out(); - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, sei()); + sei(); #if MULTI_FILAMENT_SENSOR #if ENABLED(WATCH_ALL_RUNOUT_SENSORS) const bool ran_out = !!runout_flags; // any sensor triggers @@ -215,45 +212,49 @@ class FilamentSensorBase { static uint8_t poll_runout_states() { return poll_runout_pins() ^ uint8_t(0 #if NUM_RUNOUT_SENSORS >= 1 - | (FIL_RUNOUT1_STATE ? 0 : _BV(1 - 1)) + | ((runout.mode[0]==2) ? 0 : _BV(1 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 2 - | (FIL_RUNOUT2_STATE ? 0 : _BV(2 - 1)) + | ((runout.mode[1]==2) ? 0 : _BV(2 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 3 - | (FIL_RUNOUT3_STATE ? 0 : _BV(3 - 1)) + | ((runout.mode[2]==2) ? 0 : _BV(3 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 4 - | (FIL_RUNOUT4_STATE ? 0 : _BV(4 - 1)) + | ((runout.mode[3]==2) ? 0 : _BV(4 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 5 - | (FIL_RUNOUT5_STATE ? 0 : _BV(5 - 1)) + | ((runout.mode[4]==2) ? 0 : _BV(5 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 6 - | (FIL_RUNOUT6_STATE ? 0 : _BV(6 - 1)) + | ((runout.mode[5]==2) ? 0 : _BV(6 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 7 - | (FIL_RUNOUT7_STATE ? 0 : _BV(7 - 1)) + | ((runout.mode[6]==2) ? 0 : _BV(7 - 1)) #endif #if NUM_RUNOUT_SENSORS >= 8 - | (FIL_RUNOUT8_STATE ? 0 : _BV(8 - 1)) + | ((runout.mode[7]==2) ? 0 : _BV(8 - 1)) #endif ); } }; -#if ENABLED(FILAMENT_MOTION_SENSOR) - - /** - * This sensor uses a magnetic encoder disc and a Hall effect - * sensor (or a slotted disc and optical sensor). The state - * will toggle between 0 and 1 on filament movement. It can detect - * filament runout and stripouts or jams. - */ - class FilamentSensorEncoder : public FilamentSensorBase { - private: + class FilamentSensorCore : public FilamentSensorBase { + private: static uint8_t motion_detected; + static bool poll_runout_state(const uint8_t extruder) { + const uint8_t runout_states = poll_runout_states(); + #if MULTI_FILAMENT_SENSOR + if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) + && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) + ) return TEST(runout_states, extruder); // A specific extruder ran out + #else + UNUSED(extruder); + #endif + return !!runout_states; // Any extruder ran out + } + static void poll_motion_sensor() { static uint8_t old_state; const uint8_t new_state = poll_runout_pins(), @@ -274,6 +275,7 @@ class FilamentSensorBase { public: static void block_completed(const block_t * const b) { + if (runout.mode[active_extruder]!=7) return; // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. if (TEST(motion_detected, b->extruder)) @@ -283,54 +285,32 @@ class FilamentSensorBase { motion_detected = 0; } - static void run() { poll_motion_sensor(); } - }; - -#else - - /** - * This is a simple endstop switch in the path of the filament. - * It can detect filament runout, but not stripouts or jams. - */ - class FilamentSensorSwitch : public FilamentSensorBase { - private: - static bool poll_runout_state(const uint8_t extruder) { - const uint8_t runout_states = poll_runout_states(); - #if MULTI_FILAMENT_SENSOR - if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) - && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) - ) return TEST(runout_states, extruder); // A specific extruder ran out - #else - UNUSED(extruder); - #endif - return !!runout_states; // Any extruder ran out - } - - public: - static void block_completed(const block_t * const) {} - static void run() { - LOOP_L_N(s, NUM_RUNOUT_SENSORS) { - const bool out = poll_runout_state(s); - if (!out) filament_present(s); - #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) - static uint8_t was_out; // = 0 - if (out != TEST(was_out, s)) { - TBI(was_out, s); - SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); - } - #endif + if(runout.mode[active_extruder]==7) + { + poll_motion_sensor(); + } + else if(runout.mode[active_extruder]!=0) { + LOOP_L_N(s, NUM_RUNOUT_SENSORS) { + const bool out = poll_runout_state(s); + if (!out) filament_present(s); + #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) + static uint8_t was_out; // = 0 + if (out != TEST(was_out, s)) { + TBI(was_out, s); + SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); + } + #endif + } } } }; -#endif // !FILAMENT_MOTION_SENSOR + /********************************* RESPONSE TYPE *********************************/ -#if HAS_FILAMENT_RUNOUT_DISTANCE - // RunoutResponseDelayed triggers a runout event only if the length // of filament specified by FILAMENT_RUNOUT_DISTANCE_MM has been fed // during a runout condition. @@ -339,7 +319,7 @@ class FilamentSensorBase { static volatile float runout_mm_countdown[NUM_RUNOUT_SENSORS]; public: - static float runout_distance_mm; + static float runout_distance_mm[HOTENDS]; static void reset() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); @@ -365,7 +345,7 @@ class FilamentSensorBase { } static void filament_present(const uint8_t extruder) { - runout_mm_countdown[extruder] = runout_distance_mm; + runout_mm_countdown[extruder] = runout_distance_mm[extruder]; } static void block_completed(const block_t * const b) { @@ -378,36 +358,3 @@ class FilamentSensorBase { } }; -#else // !HAS_FILAMENT_RUNOUT_DISTANCE - - // RunoutResponseDebounced triggers a runout event after a runout - // condition has been detected runout_threshold times in a row. - - class RunoutResponseDebounced { - private: - static constexpr int8_t runout_threshold = FILAMENT_RUNOUT_THRESHOLD; - static int8_t runout_count[NUM_RUNOUT_SENSORS]; - - public: - static void reset() { - LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); - } - - static void run() { - LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] >= 0) runout_count[i]--; - } - - static uint8_t has_run_out() { - uint8_t runout_flags = 0; - LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] < 0) SBI(runout_flags, i); - return runout_flags; - } - - static void block_completed(const block_t * const) { } - - static void filament_present(const uint8_t extruder) { - runout_count[extruder] = runout_threshold; - } - }; - -#endif // !HAS_FILAMENT_RUNOUT_DISTANCE diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 1679c90687..0b5a4d8c03 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -88,7 +88,7 @@ void GcodeSuite::M600() { // In this case, for duplicating modes set DXC_ext to the extruder that ran out. #if MULTI_FILAMENT_SENSOR if (idex_is_duplicating()) - DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT2_STATE) ? 1 : 0; + DXC_ext = (READ(FIL_RUNOUT2_PIN) == (runout.mode[1]==2 ? HIGH, LOW) ? 1 : 0; #else DXC_ext = active_extruder; #endif diff --git a/Marlin/src/gcode/feature/runout/M412.cpp b/Marlin/src/gcode/feature/runout/M591.cpp similarity index 53% rename from Marlin/src/gcode/feature/runout/M412.cpp rename to Marlin/src/gcode/feature/runout/M591.cpp index bcf1e9f1b1..e80252677a 100644 --- a/Marlin/src/gcode/feature/runout/M412.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -27,18 +27,37 @@ #include "../../gcode.h" #include "../../../feature/runout.h" + +void GcodeSuite::M412() { + SERIAL_ECHOLNPGM_P("M412 is Deprecated, please us M591."); + M591(); +} /** - * M412: Enable / Disable filament runout detection + 591: Configure filament runout detection * * Parameters * R : Reset the runout sensor * S : Reset and enable/disable the runout sensor * H : Enable/disable host handling of filament runout - * D : Extra distance to continue after runout is triggered + * L : Extra distance to continue after runout is triggered or motion interval + * D : Alias for L + * P : Mode : + 0 = none + 1 = simple sensor (high signal when filament present) + 2 = simple sensor (low signal when filament present) + 7 = motion encoder sensor */ -void GcodeSuite::M412() { - if (parser.seen("RS" - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, "D") +void GcodeSuite::M591() { + #if HOTENDS > 1 + if(parser.seen("E")) + const uint8_t tool = parser.value_ushort(); + else + tool = active_extruder; + #else + const uint8_t tool = 0; + #endif + + if (parser.seen("RSDP" TERN_(HOST_ACTION_COMMANDS, "H") )) { #if ENABLED(HOST_ACTION_COMMANDS) @@ -46,18 +65,24 @@ void GcodeSuite::M412() { #endif const bool seenR = parser.seen_test('R'), seenS = parser.seen('S'); if (seenR || seenS) runout.reset(); - if (seenS) runout.enabled = parser.value_bool(); - #if HAS_FILAMENT_RUNOUT_DISTANCE - if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units()); - #endif + if (seenS) runout.enabled[tool] = parser.value_bool(); + if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units(), tool); + if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); + if (parser.seen('P')) { + uint8_t tmp_mode = parser.value_int(); + if(tmp_mode > 3 || tmp_mode==7) { + runout.mode[tool] = tmp_mode; + runout.reset(); + } + } + } else { SERIAL_ECHO_START(); SERIAL_ECHOPGM("Filament runout "); - serialprint_onoff(runout.enabled); - #if HAS_FILAMENT_RUNOUT_DISTANCE - SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(), "mm"); - #endif + serialprint_onoff(runout.enabled[active_extruder]); + SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(active_extruder), "mm"); + SERIAL_ECHOPGM(" ; Mode ", runout.mode[active_extruder]); #if ENABLED(HOST_ACTION_COMMANDS) SERIAL_ECHOPGM(" ; Host handling "); serialprint_onoff(runout.host_handling); @@ -66,16 +91,17 @@ void GcodeSuite::M412() { } } -void GcodeSuite::M412_report(const bool forReplay/*=true*/) { +void GcodeSuite::M591_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_FILAMENT_RUNOUT_SENSOR)); - SERIAL_ECHOPGM( - " M412 S", runout.enabled - #if HAS_FILAMENT_RUNOUT_DISTANCE - , " D", LINEAR_UNIT(runout.runout_distance()) - #endif - , " ; Sensor " - ); - serialprintln_onoff(runout.enabled); + LOOP_S_L_N(e, 1, HOTENDS) + SERIAL_ECHOPGM( + " M591 E", e + , " S", runout.enabled[e] + , " D", LINEAR_UNIT(runout.runout_distance(e)) + , " P", runout.mode[e] + , " ; " + ); + } #endif // HAS_FILAMENT_SENSOR diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index c365f8a67b..a31341d036 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -822,10 +822,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 407: M407(); break; // M407: Display measured filament diameter #endif - #if HAS_FILAMENT_SENSOR - case 412: M412(); break; // M412: Enable/Disable filament runout detection - #endif - #if HAS_MULTI_LANGUAGE case 414: M414(); break; // M414: Select multi language menu #endif @@ -892,6 +888,11 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 575: M575(); break; // M575: Set serial baudrate #endif + #if HAS_FILAMENT_SENSOR + case 412: M412(); break; // Alias to M591 + case 591: M591(); break; // M591 Configure filament runout detection + #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) case 600: M600(); break; // M600: Pause for Filament Change case 603: M603(); break; // M603: Configure Filament Change diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 6e331c1273..46f4a5ddce 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -230,7 +230,6 @@ * M406 - Disable Filament Sensor flow control. (Requires FILAMENT_WIDTH_SENSOR) * M407 - Display measured filament diameter in millimeters. (Requires FILAMENT_WIDTH_SENSOR) * M410 - Quickstop. Abort all planned moves. - * M412 - Enable / Disable Filament Runout Detection. (Requires FILAMENT_RUNOUT_SENSOR) * M413 - Enable / Disable Power-Loss Recovery. (Requires POWER_LOSS_RECOVERY) * M414 - Set language by index. (Requires LCD_LANGUAGE_2...) * M420 - Enable/Disable Leveling (with current values) S1=enable S0=disable (Requires MESH_BED_LEVELING or ABL) @@ -255,6 +254,7 @@ * M554 - Get or set IP gateway. (Requires enabled Ethernet port) * M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160) * M575 - Change the serial baud rate. (Requires BAUD_RATE_GCODE) + * M591 - Configure Filament Runout Detection. (Requires FILAMENT_RUNOUT_SENSOR) * M600 - Pause for filament change: "M600 X Y Z E L". (Requires ADVANCED_PAUSE_FEATURE) * M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE) * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) @@ -979,7 +979,8 @@ private: #if HAS_FILAMENT_SENSOR static void M412(); - static void M412_report(const bool forReplay=true); + static void M591(); + static void M591_report(const bool forReplay=true); #endif #if HAS_MULTI_LANGUAGE diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 36731c23da..50ff834d11 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -111,7 +111,7 @@ void GcodeSuite::M115() { // AUTOLEVEL (G29) cap_line(F("AUTOLEVEL"), ENABLED(HAS_AUTOLEVEL)); - // RUNOUT (M412, M600) + // RUNOUT (M591, M600) cap_line(F("RUNOUT"), ENABLED(FILAMENT_RUNOUT_SENSOR)); // Z_PROBE (G30) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index d63395a719..f0999df41f 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -548,9 +548,6 @@ #if NUM_RUNOUT_SENSORS > 1 #define MULTI_FILAMENT_SENSOR 1 #endif - #ifdef FILAMENT_RUNOUT_DISTANCE_MM - #define HAS_FILAMENT_RUNOUT_DISTANCE 1 - #endif #if ENABLED(MIXING_EXTRUDER) #define WATCH_ALL_RUNOUT_SENSORS #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a94846275e..78117dc482 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1000,8 +1000,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You can't enable FIL_RUNOUT7_PULLUP and FIL_RUNOUT7_PULLDOWN at the same time." #elif BOTH(FIL_RUNOUT8_PULLUP, FIL_RUNOUT8_PULLDOWN) #error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time." - #elif FILAMENT_RUNOUT_DISTANCE_MM < 0 - #error "FILAMENT_RUNOUT_DISTANCE_MM must be greater than or equal to zero." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with FILAMENT_RUNOUT_SENSOR."); #endif @@ -1238,8 +1236,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "MIXING_EXTRUDER is incompatible with SINGLENOZZLE." #elif ENABLED(DISABLE_INACTIVE_EXTRUDER) #error "MIXING_EXTRUDER is incompatible with DISABLE_INACTIVE_EXTRUDER." - #elif HAS_FILAMENT_RUNOUT_DISTANCE - #error "MIXING_EXTRUDER is incompatible with FILAMENT_RUNOUT_DISTANCE_MM." #endif #endif diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index d384bae3e3..1e70a0656c 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -2833,7 +2833,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define ADVANCED_UNLOAD (ADVANCED_LOAD + ENABLED(ADVANCED_PAUSE_FEATURE)) #define ADVANCED_COLD_EXTRUDE (ADVANCED_UNLOAD + ENABLED(PREVENT_COLD_EXTRUSION)) #define ADVANCED_FILSENSORENABLED (ADVANCED_COLD_EXTRUDE + ENABLED(FILAMENT_RUNOUT_SENSOR)) - #define ADVANCED_FILSENSORDISTANCE (ADVANCED_FILSENSORENABLED + ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE)) + #define ADVANCED_FILSENSORDISTANCE (ADVANCED_FILSENSORENABLED + 1) #define ADVANCED_POWER_LOSS (ADVANCED_FILSENSORDISTANCE + ENABLED(POWER_LOSS_RECOVERY)) #define ADVANCED_TOTAL ADVANCED_POWER_LOSS @@ -2923,24 +2923,22 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ADVANCED_FILSENSORENABLED: if (draw) { Draw_Menu_Item(row, ICON_Extruder, F("Filament Sensor")); - Draw_Checkbox(row, runout.enabled); + Draw_Checkbox(row, runout.enabled[0]); } else { - runout.enabled = !runout.enabled; - Draw_Checkbox(row, runout.enabled); + runout.enabled = !runout.enabled[0]; + Draw_Checkbox(row, runout.enabled[0]); } break; - #if ENABLED(HAS_FILAMENT_RUNOUT_DISTANCE) - case ADVANCED_FILSENSORDISTANCE: - if (draw) { - Draw_Menu_Item(row, ICON_MaxAccE, F("Runout Distance")); - Draw_Float(runout.runout_distance(), row, false, 10); - } - else - Modify_Value(runout.runout_distance(), 0, 999, 10); - break; - #endif + case ADVANCED_FILSENSORDISTANCE: + if (draw) { + Draw_Menu_Item(row, ICON_MaxAccE, F("Runout Distance")); + Draw_Float(runout.runout_distance(), row, false, 10); + } + else + Modify_Value(runout.runout_distance(), 0, 999, 10); + break; #endif // FILAMENT_RUNOUT_SENSOR #if ENABLED(POWER_LOSS_RECOVERY) @@ -3829,11 +3827,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case TUNE_FILSENSORENABLED: if (draw) { Draw_Menu_Item(row, ICON_Extruder, F("Filament Sensor")); - Draw_Checkbox(row, runout.enabled); + Draw_Checkbox(row, runout.enabled[0]); } else { - runout.enabled = !runout.enabled; - Draw_Checkbox(row, runout.enabled); + runout.enabled = !runout.enabled[0]; + Draw_Checkbox(row, runout.enabled[0]); } break; #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 0a392cd563..93302406d4 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -2157,14 +2157,12 @@ void SetPID(celsius_t t, heater_id_t h) { #if HAS_FILAMENT_SENSOR void SetRunoutEnable() { runout.reset(); - runout.enabled = !runout.enabled; - Draw_Chkb_Line(CurrentMenu->line(), runout.enabled); + runout.enabled[0] = !runout.enabled[0]; + Draw_Chkb_Line(CurrentMenu->line(), runout.enabled[0]); DWIN_UpdateLCD(); } - #if HAS_FILAMENT_RUNOUT_DISTANCE - void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } - void SetRunoutDistance() { SetFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), ApplyRunoutDistance); } - #endif + void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } + void SetRunoutDistance() { SetFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), ApplyRunoutDistance); } #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) @@ -2679,7 +2677,7 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) { } #if HAS_FILAMENT_SENSOR - void onDrawRunoutEnable(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, runout.enabled); } + void onDrawRunoutEnable(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, runout.enabled[0]); } #endif void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } @@ -3173,9 +3171,7 @@ void Draw_Move_Menu() { #if HAS_FILAMENT_SENSOR MENU_ITEM(ICON_Runout, GET_TEXT_F(MSG_RUNOUT_ENABLE), onDrawRunoutEnable, SetRunoutEnable); #endif - #if HAS_FILAMENT_RUNOUT_DISTANCE - EDIT_ITEM(ICON_Runout, F("Runout Distance"), onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); - #endif + EDIT_ITEM(ICON_Runout, F("Runout Distance"), onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); #if ENABLED(PREVENT_COLD_EXTRUSION) EDIT_ITEM(ICON_ExtrudeMinT, F("Extrude Min Temp."), onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); #endif diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 74eb94e751..ab42b2f1d8 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -100,7 +100,7 @@ void ESDiagClass::Update() { ES_REPORT(Z_MIN); #endif #if HAS_FILAMENT_SENSOR - draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE); + draw_es_state(READ(FIL_RUNOUT1_PIN) != (runout.mode[0]==2 ? HIGH, LOW); #endif DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp index 68948b0c5e..a885d69cf5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_runout_screen.cpp @@ -34,14 +34,13 @@ void FilamentRunoutScreen::onRedraw(draw_mode_t what) { w.heading( GET_TEXT_F(MSG_FILAMENT)); w.toggle( 2, GET_TEXT_F(MSG_RUNOUT_SENSOR), getFilamentRunoutEnabled()); - #if HAS_FILAMENT_RUNOUT_DISTANCE - w.heading(GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM)); - w.units(GET_TEXT_F(MSG_UNITS_MM)); - w.precision(0); - w.color(e_axis); - w.adjuster( 10, FPSTR(NUL_STR), getFilamentRunoutDistance_mm(), getFilamentRunoutEnabled()); - w.increments(); - #endif + w.heading(GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM)); + w.units(GET_TEXT_F(MSG_UNITS_MM)); + w.precision(0); + w.color(e_axis); + w.adjuster( 10, FPSTR(NUL_STR), getFilamentRunoutDistance_mm(), getFilamentRunoutEnabled()); + w.increments(); + } bool FilamentRunoutScreen::onTouchHeld(uint8_t tag) { @@ -49,10 +48,8 @@ bool FilamentRunoutScreen::onTouchHeld(uint8_t tag) { const float increment = getIncrement(); switch (tag) { case 2: setFilamentRunoutEnabled(!getFilamentRunoutEnabled()); break; - #if HAS_FILAMENT_RUNOUT_DISTANCE - case 10: UI_DECREMENT(FilamentRunoutDistance_mm); break; - case 11: UI_INCREMENT(FilamentRunoutDistance_mm); break; - #endif + case 10: UI_DECREMENT(FilamentRunoutDistance_mm); break; + case 11: UI_INCREMENT(FilamentRunoutDistance_mm); break; default: return false; } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index bfcbc39d7b..9656e86f97 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -651,15 +651,12 @@ namespace ExtUI { } #if HAS_FILAMENT_SENSOR - bool getFilamentRunoutEnabled() { return runout.enabled; } - void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; } + bool getFilamentRunoutEnabled(const extruder_t extruder/*=E0*/) { return runout.enabled[extruder]; } + void setFilamentRunoutEnabled(const bool value, const extruder_t extruder/*=E0*/) { runout.enabled[extruder] = value; } bool getFilamentRunoutState() { return runout.filament_ran_out; } void setFilamentRunoutState(const bool value) { runout.filament_ran_out = value; } - - #if HAS_FILAMENT_RUNOUT_DISTANCE - float getFilamentRunoutDistance_mm() { return runout.runout_distance(); } - void setFilamentRunoutDistance_mm(const_float_t value) { runout.set_runout_distance(constrain(value, 0, 999)); } - #endif + float getFilamentRunoutDistance_mm() { return runout.runout_distance(); } + void setFilamentRunoutDistance_mm(const_float_t value) { runout.set_runout_distance(constrain(value, 0, 999)); } #endif #if ENABLED(CASE_LIGHT_ENABLE) diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 6753c53740..3d87d0208e 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -294,15 +294,13 @@ namespace ExtUI { #endif #if HAS_FILAMENT_SENSOR - bool getFilamentRunoutEnabled(); - void setFilamentRunoutEnabled(const bool); + bool getFilamentRunoutEnabled(const extruder_t extruder=E0); + void setFilamentRunoutEnabled(const bool, const extruder_t extruder=E0); bool getFilamentRunoutState(); void setFilamentRunoutState(const bool); + float getFilamentRunoutDistance_mm(); + void setFilamentRunoutDistance_mm(const_float_t); - #if HAS_FILAMENT_RUNOUT_DISTANCE - float getFilamentRunoutDistance_mm(); - void setFilamentRunoutDistance_mm(const_float_t); - #endif #endif #if ENABLED(CASE_LIGHT_ENABLE) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 1bc9b9e88e..77728201c5 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -43,7 +43,7 @@ #include "../../module/temperature.h" #endif -#if HAS_FILAMENT_RUNOUT_DISTANCE +#if HAS_FILAMENT_SENSOR #include "../../feature/runout.h" #endif @@ -150,7 +150,7 @@ void menu_backlash(); #endif #endif - #if HAS_FILAMENT_RUNOUT_DISTANCE + #if HAS_FILAMENT_SENSOR editable.decimal = runout.runout_distance(); EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, []{ runout.set_runout_distance(editable.decimal); }, true diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index b4e9287bd4..9c4164f7b6 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -550,7 +550,7 @@ void menu_configuration() { #endif #if HAS_FILAMENT_SENSOR - EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset); + EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[active_extruder], runout.reset); #endif #if HAS_FANCHECK diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 9f432c405c..98278e7a6e 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -254,7 +254,7 @@ void menu_pause_option() { #if HAS_FILAMENT_SENSOR const bool still_out = runout.filament_ran_out; if (still_out) - EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset); + EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[active_extruder], runout.reset); #else constexpr bool still_out = false; #endif diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 3dd6d8aeb6..57476d89f6 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -47,6 +47,10 @@ #include "../feature/joystick.h" #endif +#if HAS_FILAMENT_SENSOR + #include "../feature/runout.h" +#endif + #if HAS_BED_PROBE #include "probe.h" #endif @@ -570,8 +574,8 @@ void _O2 Endstops::report_states() { #if USES_Z_MIN_PROBE_PIN print_es_state(PROBE_TRIGGERED(), F(STR_Z_PROBE)); #endif - #if MULTI_FILAMENT_SENSOR - #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; state = FIL_RUNOUT##N##_STATE; break; + #if HAS_FILAMENT_SENSOR + #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) { pin_t pin; uint8_t state; @@ -579,13 +583,23 @@ void _O2 Endstops::report_states() { default: continue; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) } + if(runout.mode[i]==1) + state = HIGH; + else + state = LOW; + SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); print_es_state(extDigitalRead(pin) != state); + SERIAL_ECHOPGM(": "); + if(runout.mode[i]==0) + SERIAL_ECHOLNF(F("Sensor Disabled")); + else if(extDigitalRead(pin) != state) + SERIAL_ECHOLNF(F("Fil Present")); + else + SERIAL_ECHOLNF(F("Fil Missing")); } #undef _CASE_RUNOUT - #elif HAS_FILAMENT_SENSOR - print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, F(STR_FILAMENT)); #endif TERN_(BLTOUCH, bltouch._reset_SW_mode()); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6eb17d5d2e..1dccdb905e 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -235,8 +235,9 @@ typedef struct SettingsDataStruct { // // FILAMENT_RUNOUT_SENSOR // - bool runout_sensor_enabled; // M412 S - float runout_distance_mm; // M412 D + bool runout_sensor_enabled[HOTENDS]; // M591 S + float runout_distance_mm[HOTENDS]; // M591 D + uint8_t runout_mode[HOTENDS]; // M591 P // // ENABLE_LEVELING_FADE_HEIGHT @@ -793,19 +794,20 @@ void MarlinSettings::postprocess() { // { #if HAS_FILAMENT_SENSOR - const bool &runout_sensor_enabled = runout.enabled; + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE(runout.enabled[e]); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE(runout.runout_distance(e)); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE(runout.mode[e]); #else - constexpr int8_t runout_sensor_enabled = -1; + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE((int8_t)-1)); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE((float)-0.0f)); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE((uint8_t)0)); #endif - _FIELD_TEST(runout_sensor_enabled); - EEPROM_WRITE(runout_sensor_enabled); - - #if HAS_FILAMENT_RUNOUT_DISTANCE - const float &runout_distance_mm = runout.runout_distance(); - #else - constexpr float runout_distance_mm = 0; - #endif - EEPROM_WRITE(runout_distance_mm); } // @@ -1711,20 +1713,27 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { - int8_t runout_sensor_enabled; + int8_t runout_sensor_enabled[HOTENDS]; _FIELD_TEST(runout_sensor_enabled); - EEPROM_READ(runout_sensor_enabled); + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_READ(runout_sensor_enabled); + float runout_distance_mm[HOTENDS]; + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_READ(runout_distance_mm[e]); + uint8_t runout_mode[HOTENDS]; + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_READ(runout_mode[e]); + #if HAS_FILAMENT_SENSOR - runout.enabled = runout_sensor_enabled < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled; + LOOP_S_L_N(e, 1, HOTENDS) + runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; + LOOP_S_L_N(e, 1, HOTENDS) + if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); + LOOP_S_L_N(e, 1, HOTENDS) + if (!validating) runout.mode[e] = runout_mode[e]; + runout.reset(); #endif - TERN_(HAS_FILAMENT_SENSOR, if (runout.enabled) runout.reset()); - - float runout_distance_mm; - EEPROM_READ(runout_distance_mm); - #if HAS_FILAMENT_RUNOUT_DISTANCE - if (!validating) runout.set_runout_distance(runout_distance_mm); - #endif } // @@ -2789,9 +2798,14 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - runout.enabled = FIL_RUNOUT_ENABLED_DEFAULT; + LOOP_S_L_N(e, 1, HOTENDS) + runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; + LOOP_S_L_N(e, 1, HOTENDS) + runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); + LOOP_S_L_N(e, 1, HOTENDS) + runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; + runout.reset(); - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM)); #endif // @@ -3481,7 +3495,7 @@ void MarlinSettings::reset() { // // Filament Runout Sensor // - TERN_(HAS_FILAMENT_SENSOR, gcode.M412_report(forReplay)); + TERN_(HAS_FILAMENT_SENSOR, gcode.M591_report(forReplay)); #if HAS_ETHERNET CONFIG_ECHO_HEADING("Ethernet"); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index f83104fe9c..46a17b6591 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -113,7 +113,7 @@ Stepper stepper; // Singleton #include "../feature/mixing.h" #endif -#if HAS_FILAMENT_RUNOUT_DISTANCE +#if HAS_FILAMENT_SENSOR #include "../feature/runout.h" #endif @@ -1948,7 +1948,7 @@ uint32_t Stepper::block_phase_isr() { PAGE_SEGMENT_UPDATE_POS(E); } #endif - TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.block_completed(current_block)); + TERN_(HAS_FILAMENT_SENSOR, runout.block_completed(current_block)); discard_current_block(); } else { From 91a094d8cb0f35c20f07cf862771ece427ca4754 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 12 Mar 2022 15:55:57 -0500 Subject: [PATCH 102/203] Update Configuration.h --- Marlin/Configuration.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index c2d5dced28..87fab7852b 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1469,6 +1469,7 @@ #define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500. #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. + #define FILAMENT_RUNOUT_DEFAULT_MODE {1} // Array set that will take the place of FIL_RUNOUT_STATE and FIL_RUNOUT_ENABLED_DEFAULT as this code matures #define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present. #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. @@ -1510,13 +1511,13 @@ // Commands to execute on filament runout. // With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c") - // NOTE: After 'M412 H1' the host handles filament runout and this script does not apply. + // NOTE: After 'M591 H1' the host handles filament runout and this script does not apply. #define FILAMENT_RUNOUT_SCRIPT "M600" // After a runout is detected, continue printing this length of filament // before executing the runout script. Useful for a sensor at the end of // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - //#define FILAMENT_RUNOUT_DISTANCE_MM 25 + //#define FILAMENT_RUNOUT_DISTANCE_MM {25} #ifdef FILAMENT_RUNOUT_DISTANCE_MM // Enable this option to use an encoder disc that toggles the runout pin From 623c6b720b0d9b14934fb8ccb895d421ab043cc9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 12 Mar 2022 15:58:28 -0600 Subject: [PATCH 103/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20ExtUI::onLevelingDone,=20match=20DWIN=20to=20ExtUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 1 + Marlin/src/gcode/bedlevel/abl/G29.cpp | 10 ++-- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 5 +- Marlin/src/gcode/calibrate/G28.cpp | 6 +-- Marlin/src/gcode/sd/M1001.cpp | 2 +- Marlin/src/lcd/e3v2/creality/dwin.cpp | 4 +- Marlin/src/lcd/e3v2/creality/dwin.h | 6 +-- Marlin/src/lcd/e3v2/proui/dwin.cpp | 8 ++-- Marlin/src/lcd/e3v2/proui/dwin.h | 8 ++-- .../extui/anycubic_chiron/chiron_extui.cpp | 11 +++-- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 48 +++++++++++-------- .../extui/anycubic_i3mega/anycubic_extui.cpp | 7 +-- Marlin/src/lcd/extui/dgus/dgus_extui.cpp | 7 +-- .../dgus_reloaded/dgus_reloaded_extui.cpp | 7 +-- Marlin/src/lcd/extui/example/example.cpp | 7 +-- .../ftdi_eve_touch_ui/ftdi_eve_extui.cpp | 7 +-- Marlin/src/lcd/extui/malyan/malyan_extui.cpp | 7 +-- .../src/lcd/extui/nextion/nextion_extui.cpp | 7 +-- Marlin/src/lcd/extui/ui_api.h | 7 +-- 19 files changed, 94 insertions(+), 71 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 023d0c5b1d..f62e83e070 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -1219,6 +1219,7 @@ void unified_bed_leveling::restore_ubl_active_state_and_leave() { } #endif set_bed_leveling_enabled(ubl_state_at_invocation); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 33f45e1c9f..1868c636ee 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -419,12 +419,13 @@ G29_TYPE GcodeSuite::G29() { planner.synchronize(); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); + #if ENABLED(AUTO_BED_LEVELING_3POINT) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling"); points[0].z = points[1].z = points[2].z = 0; // Probe at 3 arbitrary points #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); - TERN_(DWIN_LCD_PROUI, DWIN_MeshLevelingStart()); + TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LevelingStart()); #endif if (!faux) { @@ -577,6 +578,7 @@ G29_TYPE GcodeSuite::G29() { SERIAL_ECHOLNPGM("Grid probing done."); // Re-enable software endstops, if needed SET_SOFT_ENDSTOP_LOOSE(false); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } #elif ENABLED(AUTO_BED_LEVELING_3POINT) @@ -606,6 +608,8 @@ G29_TYPE GcodeSuite::G29() { abl.reenable = false; } + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); + } #endif // AUTO_BED_LEVELING_3POINT @@ -899,7 +903,7 @@ G29_TYPE GcodeSuite::G29() { process_subcommands_now(F(Z_PROBE_END_SCRIPT)); #endif - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling()); + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone()); TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index)); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 3767cef3cf..f262546d61 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -104,8 +104,8 @@ void GcodeSuite::G29() { mbl_probe_index = 0; if (!ui.wait_for_move) { queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2")); - TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); - TERN_(DWIN_LCD_PROUI, DWIN_MeshLevelingStart()); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); + TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); return; } state = MeshNext; @@ -168,6 +168,7 @@ void GcodeSuite::G29() { #endif TERN_(LCD_BED_LEVELING, ui.wait_for_move = false); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } break; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index dbbea79353..9361790d74 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -239,7 +239,7 @@ void GcodeSuite::G28() { set_and_report_grblstate(M_HOMING); #endif - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StartHoming()); + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingStart()); TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart()); planner.synchronize(); // Wait for planner moves to finish! @@ -552,8 +552,8 @@ void GcodeSuite::G28() { ui.refresh(); - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedHoming()); - TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete()); + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingDone()); + TERN_(EXTENSIBLE_UI, ExtUI::onHomingDone()); report_current_position(); diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 87de89a682..197177882c 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -108,7 +108,7 @@ void GcodeSuite::M1001() { process_subcommands_now(F(SD_FINISHED_RELEASECOMMAND)); #endif - TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished()); + TERN_(EXTENSIBLE_UI, ExtUI::onPrintDone()); TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); // Re-select the last printed file in the UI diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 7dc06d00f2..05ac38d226 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -4281,7 +4281,7 @@ void DWIN_HandleScreen() { } } -void DWIN_CompletedHoming() { +void DWIN_HomingDone() { HMI_flag.home_flag = false; dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); if (checkkey == Last_Prepare) { @@ -4297,7 +4297,7 @@ void DWIN_CompletedHoming() { } } -void DWIN_CompletedLeveling() { +void DWIN_LevelingDone() { if (checkkey == Leveling) Goto_MainMenu(); } diff --git a/Marlin/src/lcd/e3v2/creality/dwin.h b/Marlin/src/lcd/e3v2/creality/dwin.h index 3ccb70e52f..487f309ed9 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.h +++ b/Marlin/src/lcd/e3v2/creality/dwin.h @@ -243,7 +243,7 @@ void DWIN_HandleScreen(); void DWIN_StatusChanged(const char * const cstr=nullptr); void DWIN_StatusChanged(FSTR_P const fstr); -inline void DWIN_StartHoming() { HMI_flag.home_flag = true; } +inline void DWIN_HomingStart() { HMI_flag.home_flag = true; } -void DWIN_CompletedHoming(); -void DWIN_CompletedLeveling(); +void DWIN_HomingDone(); +void DWIN_LevelingDone(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 0a392cd563..95cb0b28b9 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -1542,20 +1542,20 @@ void HMI_SaveProcessID(const uint8_t id) { } } -void DWIN_StartHoming() { +void DWIN_HomingStart() { HMI_flag.home_flag = true; HMI_SaveProcessID(Homing); Title.ShowCaption(GET_TEXT_F(MSG_HOMING)); DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT)); } -void DWIN_CompletedHoming() { +void DWIN_HomingDone() { HMI_flag.home_flag = false; dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); if (HMI_flag.abort_action) DWIN_Print_Aborted(); else HMI_ReturnScreen(); } -void DWIN_MeshLevelingStart() { +void DWIN_LevelingStart() { #if HAS_ONESTEP_LEVELING HMI_SaveProcessID(Leveling); Title.ShowCaption(GET_TEXT_F(MSG_BED_LEVELING)); @@ -1565,7 +1565,7 @@ void DWIN_MeshLevelingStart() { #endif } -void DWIN_CompletedLeveling() { +void DWIN_LevelingDone() { TERN_(HAS_ONESTEP_LEVELING, if (planner.leveling_active) Goto_MeshViewer()); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 9f49fa1825..b61ed846df 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -142,13 +142,13 @@ void update_variable(); void DWIN_InitScreen(); void DWIN_HandleScreen(); void DWIN_CheckStatusMessage(); -void DWIN_StartHoming(); -void DWIN_CompletedHoming(); +void DWIN_HomingStart(); +void DWIN_HomingDone(); #if HAS_MESH void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); #endif -void DWIN_MeshLevelingStart(); -void DWIN_CompletedLeveling(); +void DWIN_LevelingStart(); +void DWIN_LevelingDone(); void DWIN_PidTuning(pidresult_t result); void DWIN_Print_Started(const bool sd=false); void DWIN_Print_Pause(); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp index 7a58963c11..b9fe8f967c 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp @@ -57,14 +57,16 @@ namespace ExtUI { void onPrintTimerStarted() { Chiron.TimerEvent(AC_timer_started); } void onPrintTimerPaused() { Chiron.TimerEvent(AC_timer_paused); } - void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); } + void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); } + void onPrintDone() {} + void onFilamentRunout(const extruder_t) { Chiron.FilamentRunout(); } + void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); } void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} void onFactoryReset() {} @@ -103,7 +105,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index c56d8aa7fb..fac0615cd6 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -86,13 +86,23 @@ void ChironTFT::Startup() { TFTSer.begin(115200); // wait for the TFT panel to initialise and finish the animation - delay_ms(250); + safe_delay(1000); // There are different panels for the Chiron with slightly different commands // So we need to know what we are working with. - // Panel type can be defined otherwise detect it automatically - if (panel_type == AC_panel_unknown) DetectPanelType(); + switch (panel_type) { + case AC_panel_new: + SERIAL_ECHOLNF(AC_msg_new_panel_set); + break; + case AC_panel_standard: + SERIAL_ECHOLNF(AC_msg_old_panel_set); + break; + default: + SERIAL_ECHOLNF(AC_msg_auto_panel_detection); + DetectPanelType(); + break; + } // Signal Board has reset SendtoTFTLN(AC_msg_main_board_has_reset); @@ -358,15 +368,14 @@ bool ChironTFT::ReadTFTCommand() { } int8_t ChironTFT::FindToken(char c) { - int8_t pos = 0; - do { + for (int8_t pos = 0; pos < command_len; pos++) { if (panel_command[pos] == c) { #if ACDEBUG(AC_INFO) SERIAL_ECHOLNPGM("Tpos:", pos, " ", c); #endif return pos; } - } while (++pos < command_len); + } #if ACDEBUG(AC_INFO) SERIAL_ECHOLNPGM("Not found: ", c); #endif @@ -623,18 +632,18 @@ void ChironTFT::PanelAction(uint8_t req) { SelectFile(); break; - case 14: { // A14 Start Printing + case 14: // A14 Start Printing // Allows printer to restart the job if we don't want to recover if (printer_state == AC_printer_resuming_from_power_outage) { injectCommands(F("M1000 C")); // Cancel recovery printer_state = AC_printer_idle; } #if ACDebugLevel >= 1 - SERIAL_ECHOLNPAIR_F("Print: ", selectedfile); + SERIAL_ECHOLNPGM("Print: ", selectedfile); #endif printFile(selectedfile); SendtoTFTLN(AC_msg_print_from_sd_card); - } break; + break; case 15: // A15 Resuming from outage if (printer_state == AC_printer_resuming_from_power_outage) { @@ -801,25 +810,22 @@ void ChironTFT::PanelProcess(uint8_t req) { } } break; - case 30: { // A30 Auto leveling + case 30: // A30 Auto leveling if (FindToken('S') != -1) { // Start probing New panel adds spaces.. // Ignore request if printing if (isPrinting()) SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling else { - - SendtoTFTLN(AC_msg_start_probing); injectCommands(F("G28\nG29")); printer_state = AC_printer_probing; } } - else { + else SendtoTFTLN(AC_msg_start_probing); // Just enter levelling menu - } - } break; + break; - case 31: { // A31 Adjust all Probe Points + case 31: // A31 Adjust all Probe Points // The tokens can occur in different places on the new panel so we need to find it. if (FindToken('C') != -1) { // Restore and apply original offsets @@ -907,18 +913,18 @@ void ChironTFT::PanelProcess(uint8_t req) { } } } - } break; + break; - case 32: { // A32 clean leveling beep flag + case 32: // A32 clean leveling beep flag // Ignore request if printing //if (isPrinting()) break; //injectCommands(F("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000")); //TFTSer.println(); - } break; + break; // A33 firmware info request see PanelInfo() - case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123 + case 34: // A34 Adjust single mesh point A34 C/S X1 Y1 V123 if (panel_command[3] == 'C') { // Restore original offsets injectCommands(F("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; @@ -950,7 +956,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } } - } break; + break; case 36: // A36 Auto leveling for new TFT bet that was a typo in the panel code! SendtoTFTLN(AC_msg_start_probing); diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp index c0e1b44578..da8f4e26a0 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp @@ -54,8 +54,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -95,7 +95,8 @@ namespace ExtUI { #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp index 04ba6b95c2..0041be8276 100644 --- a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp +++ b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp @@ -73,8 +73,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -113,7 +113,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp index 61b072a3f7..5c330bd6b4 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp @@ -83,8 +83,8 @@ namespace ExtUI { } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() { dgus_screen_handler.SettingsReset(); @@ -109,7 +109,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { dgus_screen_handler.MeshUpdate(xpos, ypos); diff --git a/Marlin/src/lcd/extui/example/example.cpp b/Marlin/src/lcd/extui/example/example.cpp index 8f38d2aba6..dd0f8e401e 100644 --- a/Marlin/src/lcd/extui/example/example.cpp +++ b/Marlin/src/lcd/extui/example/example.cpp @@ -59,8 +59,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -99,7 +99,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index f2ee1e5639..1c7b3621f2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -80,7 +80,7 @@ namespace ExtUI { } void onPrintTimerPaused() {} - void onPrintFinished() {} + void onPrintDone() {} void onFilamentRunout(const extruder_t extruder) { char lcd_msg[30]; @@ -90,7 +90,7 @@ namespace ExtUI { } void onHomingStart() {} - void onHomingComplete() {} + void onHomingDone() {} void onFactoryReset() { InterfaceSettingsScreen::defaultSettings(); } void onStoreSettings(char *buff) { InterfaceSettingsScreen::saveSettings(buff); } @@ -118,7 +118,8 @@ namespace ExtUI { } #if HAS_LEVELING && HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t x, const int8_t y, const_float_t val) { BedMeshViewScreen::onMeshUpdate(x, y, val); } void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { BedMeshViewScreen::onMeshUpdate(x, y, state); } #endif diff --git a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp index f323728e27..2d36a4e737 100644 --- a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp @@ -141,8 +141,8 @@ namespace ExtUI { void onFilamentRunout(const extruder_t extruder) {} void onUserConfirmRequired(const char * const) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} void onStoreSettings(char*) {} void onLoadSettings(const char*) {} @@ -151,7 +151,8 @@ namespace ExtUI { void onConfigurationStoreRead(bool) {} #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {} #endif diff --git a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp index c19d3aee46..c15175a28d 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp @@ -50,8 +50,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) { nextion.StatusChange(msg); } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() { nextion.PrintFinished(); } + void onHomingDone() {} + void onPrintDone() { nextion.PrintFinished(); } void onFactoryReset() {} @@ -90,7 +90,8 @@ namespace ExtUI { } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 6753c53740..b575684a03 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -172,7 +172,8 @@ namespace ExtUI { float getMeshPoint(const xy_uint8_t &pos); void setMeshPoint(const xy_uint8_t &pos, const_float_t zval); void moveToMeshPoint(const xy_uint8_t &pos, const_float_t z); - void onMeshLevelingStart(); + void onLevelingStart(); + void onLevelingDone(); void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); inline void onMeshUpdate(const xy_int8_t &pos, const_float_t zval) { onMeshUpdate(pos.x, pos.y, zval); } @@ -403,14 +404,14 @@ namespace ExtUI { void onPrintTimerStarted(); void onPrintTimerPaused(); void onPrintTimerStopped(); - void onPrintFinished(); + void onPrintDone(); void onFilamentRunout(const extruder_t extruder); void onUserConfirmRequired(const char * const msg); void onUserConfirmRequired(FSTR_P const fstr); void onStatusChanged(const char * const msg); void onStatusChanged(FSTR_P const fstr); void onHomingStart(); - void onHomingComplete(); + void onHomingDone(); void onSteppersDisabled(); void onSteppersEnabled(); void onFactoryReset(); From bff55ea6054498dc40a54f747cb54ceb84c2e8b0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 12 Mar 2022 15:59:01 -0600 Subject: [PATCH 104/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20UBL=20'G29=20Q1'?= =?UTF-8?q?=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index f62e83e070..0d00296b5b 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -367,13 +367,13 @@ void unified_bed_leveling::G29() { case 1: LOOP_L_N(x, GRID_MAX_POINTS_X) { // Create a diagonal line several Mesh cells thick that is raised + const uint8_t x2 = x + (x < (GRID_MAX_POINTS_Y) - 1 ? 1 : -1); z_values[x][x] += 9.999f; - z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick + z_values[x][x2] += 9.999f; // We want the altered line several mesh points thick #if ENABLED(EXTENSIBLE_UI) ExtUI::onMeshUpdate(x, x, z_values[x][x]); - ExtUI::onMeshUpdate(x, (x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1), z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1]); + ExtUI::onMeshUpdate(x, (x2), z_values[x][x2]); #endif - } break; From 0bf319c57a413e3cc1f279a994a9a1b607de5008 Mon Sep 17 00:00:00 2001 From: Ludy Date: Sun, 13 Mar 2022 00:36:23 +0100 Subject: [PATCH 105/203] =?UTF-8?q?=F0=9F=8C=90=20Fix,=20add=20some=20menu?= =?UTF-8?q?=20labels=20(#23895)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_de.h | 5 +++++ Marlin/src/lcd/language/language_en.h | 3 ++- Marlin/src/lcd/language/language_fr.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index bf408d436f..393d5b58bc 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -135,6 +135,7 @@ namespace Language_de { LSTR MSG_BED_LEVELING = _UxGT("Bett-Nivellierung"); LSTR MSG_LEVEL_BED = _UxGT("Bett nivellieren"); LSTR MSG_BED_TRAMMING = _UxGT("Bett ausrichten"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Manuelles ausrichten"); LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Das Bett anpassen, bis zum auslösen."); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Ecken in der Toleranz. Bett ausger."); LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Gute Punkte: "); @@ -389,6 +390,7 @@ namespace Language_de { LSTR MSG_CONTRAST = _UxGT("LCD-Kontrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Helligkeit"); LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD-Ruhezustand (s)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("LCD ausschalten"); LSTR MSG_STORE_EEPROM = _UxGT("Konfig. speichern"); LSTR MSG_LOAD_EEPROM = _UxGT("Konfig. laden"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Standardwerte laden"); @@ -415,6 +417,8 @@ namespace Language_de { LSTR MSG_BUTTON_RESET = _UxGT("Reseten"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ignorieren"); LSTR MSG_BUTTON_CANCEL = _UxGT("Abbrechen"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Bestätigen"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Fortsetzen"); LSTR MSG_BUTTON_DONE = _UxGT("Fertig"); LSTR MSG_BUTTON_BACK = _UxGT("Zurück"); LSTR MSG_BUTTON_PROCEED = _UxGT("Weiter"); @@ -424,6 +428,7 @@ namespace Language_de { LSTR MSG_BUTTON_PAUSE = _UxGT("Pause"); LSTR MSG_BUTTON_RESUME = _UxGT("Fortsetzen"); LSTR MSG_BUTTON_ADVANCED = _UxGT("Erweitert"); + LSTR MSG_BUTTON_SAVE = _UxGT("Speichern"); LSTR MSG_PAUSING = _UxGT("Pause..."); LSTR MSG_PAUSE_PRINT = _UxGT("SD-Druck pausieren"); LSTR MSG_ADVANCED_PAUSE = _UxGT("Erweiterte Pause"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 7fe5c22271..43bbd90210 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -403,7 +403,8 @@ namespace Language_en { LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness"); - LSTR MSG_BRIGHTNESS_OFF = _UxGT("Turn Off LCD"); + LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD Timeout (s)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Backlight Off"); LSTR MSG_STORE_EEPROM = _UxGT("Store Settings"); LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 02f9d2f549..ca3757f704 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -336,6 +336,7 @@ namespace Language_fr { LSTR MSG_BRIGHTNESS = _UxGT("Luminosité LCD"); LSTR MSG_CONTRAST = _UxGT("Contraste LCD"); LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("Veille LCD (s)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Éteindre l'écran LCD"); LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config."); LSTR MSG_LOAD_EEPROM = _UxGT("Charger config."); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restaurer défauts"); From 89a9c3a391101e4d2d8dbfbf0cdb261ad2d9592b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 12 Mar 2022 16:34:58 -0600 Subject: [PATCH 106/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20=20?= =?UTF-8?q?Add=20standard=20BUZZ=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/mmu/mmu2.cpp | 45 ++++++++++++------------- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 3 +- Marlin/src/gcode/geometry/M206_M428.cpp | 5 ++- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 14 ++------ Marlin/src/lcd/e3v2/proui/dwin.cpp | 12 +------ Marlin/src/lcd/menu/menu.cpp | 6 +--- Marlin/src/libs/buzzer.h | 5 +++ Marlin/src/module/printcounter.cpp | 2 +- Marlin/src/module/probe.cpp | 3 +- 9 files changed, 36 insertions(+), 59 deletions(-) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 2813337c63..28dea681ef 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -143,6 +143,8 @@ uint8_t MMU2::get_current_tool() { #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE) #endif +inline void ATTN_BUZZ(const bool two=false) { BUZZ(200, 404); if (two) { BUZZ(10, 0); BUZZ(200, 404); } } + void MMU2::mmu_loop() { switch (state) { @@ -525,7 +527,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -544,7 +546,7 @@ static void mmu2_not_responding() { active_extruder = 0; } #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -613,7 +615,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -633,7 +635,7 @@ static void mmu2_not_responding() { extruder = index; active_extruder = 0; #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -707,7 +709,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -726,7 +728,7 @@ static void mmu2_not_responding() { extruder = index; active_extruder = 0; #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -811,25 +813,21 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { if (turn_off_nozzle && resume_hotend_temp) { thermalManager.setTargetHotend(resume_hotend_temp, active_extruder); LCD_MESSAGE(MSG_HEATING); - BUZZ(200, 40); + ERR_BUZZ(); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(1000); } - if (move_axes && all_axes_homed()) { - LCD_MESSAGE(MSG_MMU2_RESUMING); - BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); + LCD_MESSAGE(MSG_MMU2_RESUMING); + ATTN_BUZZ(true); + if (move_axes && all_axes_homed()) { // Move XY to starting position, then Z do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE)); // Move Z_AXIS to saved position do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); } - else { - BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); - LCD_MESSAGE(MSG_MMU2_RESUMING); - } } } } @@ -898,7 +896,7 @@ void MMU2::load_filament(const uint8_t index) { command(MMU_CMD_L0 + index); manage_response(false, false); - BUZZ(200, 404); + ATTN_BUZZ(); } /** @@ -909,7 +907,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + ATTN_BUZZ(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -924,7 +922,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { extruder = index; active_extruder = 0; load_to_nozzle(); - BUZZ(200, 404); + ATTN_BUZZ(); } return success; } @@ -945,7 +943,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + ATTN_BUZZ(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -961,12 +959,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (recover) { LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); - BUZZ(200, 404); + ATTN_BUZZ(); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover"))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); - BUZZ(200, 404); - BUZZ(200, 404); + ATTN_BUZZ(true); command(MMU_CMD_R0); manage_response(false, false); @@ -979,7 +976,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { set_runout_valid(false); - BUZZ(200, 404); + ATTN_BUZZ(); stepper.disable_extruder(); @@ -994,7 +991,7 @@ bool MMU2::unload() { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + ATTN_BUZZ(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -1005,7 +1002,7 @@ bool MMU2::unload() { command(MMU_CMD_U0); manage_response(false, true); - BUZZ(200, 404); + ATTN_BUZZ(); // no active tool extruder = MMU2_NO_TOOL; diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index f262546d61..f06bfc0fdc 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -155,8 +155,7 @@ void GcodeSuite::G29() { mbl_probe_index = -1; SERIAL_ECHOLNPGM("Mesh probing done."); TERN_(HAS_STATUS_MESSAGE, LCD_MESSAGE(MSG_MESH_DONE)); - BUZZ(100, 659); - BUZZ(100, 698); + OKAY_BUZZ(); home_all_axes(); set_bed_leveling_enabled(true); diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 131dbecf33..b32d729969 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -92,7 +92,7 @@ void GcodeSuite::M428() { if (!WITHIN(diff[i], -20, 20)) { SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR); LCD_ALERTMESSAGE_F("Err: Too far!"); - BUZZ(200, 40); + ERR_BUZZ(); return; } } @@ -100,8 +100,7 @@ void GcodeSuite::M428() { LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]); report_current_position(); LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED); - BUZZ(100, 659); - BUZZ(100, 698); + OKAY_BUZZ(); } #endif // HAS_M206_COMMAND diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index d384bae3e3..51df15da73 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -4920,18 +4920,10 @@ void CrealityDWINClass::Screen_Update() { } void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) { - if (success) { - if (ui.buzzer_enabled) { - BUZZ(100, 659); - BUZZ( 10, 0); - BUZZ(100, 698); - } - else Update_Status("Success"); - } - else if (ui.buzzer_enabled) - BUZZ(40, 440); + if (ui.buzzer_enabled) + DONE_BUZZ(success); else - Update_Status("Failed"); + Update_Status(success ? "Success" : "Failed"); } void CrealityDWINClass::Save_Settings(char *buff) { diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 95cb0b28b9..66e90740fd 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -1285,17 +1285,7 @@ void HMI_Printing() { #include "../../../libs/buzzer.h" -void HMI_AudioFeedback(const bool success/*=true*/) { - #if HAS_BUZZER - if (success) { - BUZZ(100, 659); - BUZZ(10, 0); - BUZZ(100, 698); - } - else - BUZZ(40, 440); - #endif -} +void HMI_AudioFeedback(const bool success/*=true*/) { DONE_BUZZ(success); } void Draw_Main_Area() { switch (checkkey) { diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 2dca6c1b82..52c43ec5e9 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -276,11 +276,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { #if HAS_BUZZER void MarlinUI::completion_feedback(const bool good/*=true*/) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click... - if (good) { - BUZZ(100, 659); - BUZZ(100, 698); - } - else BUZZ(20, 440); + if (good) OKAY_BUZZ(); else ERR_BUZZ(); } #endif diff --git a/Marlin/src/libs/buzzer.h b/Marlin/src/libs/buzzer.h index db5e3ee4ca..9fc46ff629 100644 --- a/Marlin/src/libs/buzzer.h +++ b/Marlin/src/libs/buzzer.h @@ -127,3 +127,8 @@ #define BUZZ(d,f) NOOP #endif + +#define ERR_BUZZ() BUZZ(400, 40); +#define ATTN_BUZZ() do{ BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); }while(0) +#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0) +#define DONE_BUZZ(OK) do{ if (OK) OKAY_BUZZ(); else ERR_BUZZ(); }while(0) diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index affb608780..c35b722cf4 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -151,7 +151,7 @@ void PrintCounter::loadStats() { if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3)); #endif #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 - if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) BUZZ(200, 404); + if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) { BUZZ(200, 404); BUZZ(10, 0); } #else UNUSED(doBuzz); #endif diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 8793ea49dc..ee6323518a 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -306,8 +306,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { if (deploy != PROBE_TRIGGERED()) break; #endif - BUZZ(100, 659); - BUZZ(100, 698); + OKAY_BUZZ(); FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW); ui.return_to_status(); // To display the new status message From e354cd15b224a4e12d3c5ba63986a249ad055f83 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 12 Mar 2022 17:12:21 -0600 Subject: [PATCH 107/203] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20FSTR=20/=20PSTR=20?= =?UTF-8?q?usage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 13 ++++----- .../archim2-flash/flash_storage.cpp | 2 +- .../bioprinter/printing_dialog_box.cpp | 4 +-- .../ftdi_eve_lib/extended/command_processor.h | 6 ++-- .../ftdi_eve_lib/extended/text_box.cpp | 6 ++-- .../ftdi_eve_lib/extended/text_ellipsis.cpp | 29 +++++++++---------- .../ftdi_eve_lib/extended/unicode/unicode.cpp | 12 ++++---- .../base_numeric_adjustment_screen.cpp | 4 +-- .../generic/status_screen.cpp | 4 +-- Marlin/src/lcd/fontutils.h | 1 + Marlin/src/lcd/lcdprint.h | 3 ++ Marlin/src/lcd/menu/menu.h | 4 +-- 12 files changed, 43 insertions(+), 45 deletions(-) diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 51df15da73..3e777d4aaa 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -958,8 +958,8 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { static bool new_msg; static uint8_t msgscrl = 0; static char lastmsg[64]; - if (strcmp_P(lastmsg, statusmsg) != 0 || refresh) { - strcpy_P(lastmsg, statusmsg); + if (strcmp(lastmsg, statusmsg) != 0 || refresh) { + strcpy(lastmsg, statusmsg); msgscrl = 0; new_msg = true; } @@ -4695,10 +4695,7 @@ void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * option /* Main Functions */ void CrealityDWINClass::Update_Status(const char * const text) { - char header[4]; - LOOP_L_N(i, 3) header[i] = text[i]; - header[3] = '\0'; - if (strcmp_P(header, PSTR("")) == 0) { + if (strncmp_P(text, PSTR(""), 3) == 0) { LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i + 3]; filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0'; Draw_Print_Filename(true); @@ -4722,10 +4719,10 @@ void CrealityDWINClass::Start_Print(bool sd) { card.selectFileByName(fname); } #endif - strcpy_P(filename, card.longest_filename()); + strcpy(filename, card.longest_filename()); } else - strcpy_P(filename, "Host Print"); + strcpy_P(filename, PSTR("Host Print")); TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_Screen(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp index 8b0c0f877c..dbee1e034b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp @@ -421,7 +421,7 @@ bool UIFlashStorage::is_present = false; uint32_t addr; uint8_t buff[write_page_size]; - strcpy_P( (char*) buff, (const char*) filename); + strcpy_P((char*)buff, FTOP(filename)); MediaFileReader reader; if (!reader.open((char*) buff)) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp index f0c0a59d36..6d177c5a7b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp @@ -106,8 +106,8 @@ bool BioPrintingDialogBox::onTouchEnd(uint8_t tag) { } void BioPrintingDialogBox::setStatusMessage(FSTR_P message) { - char buff[strlen_P((const char*)message)+1]; - strcpy_P(buff, (const char*) message); + char buff[strlen_P(FTOP(message)) + 1]; + strcpy_P(buff, FTOP(message)); setStatusMessage(buff); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h index 24e93982c2..648ed5330a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h @@ -242,10 +242,10 @@ class CommandProcessor : public CLCD::CommandFifo { } CommandProcessor& toggle2(int16_t x, int16_t y, int16_t w, int16_t h, FSTR_P no, FSTR_P yes, bool state, uint16_t options = FTDI::OPT_3D) { - char text[strlen_P((const char *)no) + strlen_P((const char *)yes) + 2]; - strcpy_P(text, (const char *)no); + char text[strlen_P(FTOP(no)) + strlen_P(FTOP(yes)) + 2]; + strcpy_P(text, FTOP(no)); strcat(text, "\xFF"); - strcat_P(text, (const char *)yes); + strcat_P(text, FTOP(yes)); return toggle(x, y, w, h, text, state, options); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp index b4d8156b39..c75cdf1812 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp @@ -135,9 +135,9 @@ namespace FTDI { } } - void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P pstr, uint16_t options, uint8_t font) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P fstr, uint16_t options, uint8_t font) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); draw_text_box(cmd, x, y, w, h, (const char*) str, options, font); } } // namespace FTDI diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp index 698bcdb150..a6d014b56e 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp @@ -33,6 +33,7 @@ namespace FTDI { const bool use_utf8 = has_utf8_chars(str); #define CHAR_WIDTH(c) use_utf8 ? utf8_fm.get_char_width(c) : clcd_fm.char_widths[(uint8_t)c] #else + constexpr bool use_utf8 = false; #define CHAR_WIDTH(c) utf8_fm.get_char_width(c) #endif FontMetrics utf8_fm(font); @@ -53,21 +54,17 @@ namespace FTDI { breakPoint = (char*)next; } - if (lineWidth > w) { - *breakPoint = '\0'; - strcpy_P(breakPoint,PSTR("...")); - } + if (lineWidth > w) + strcpy_P(breakPoint, PSTR("...")); cmd.apply_text_alignment(x, y, w, h, options); - #if ENABLED(TOUCH_UI_USE_UTF8) - if (use_utf8) { - draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options); - } else - #endif - { - cmd.CLCD::CommandFifo::text(x, y, font, options); - cmd.CLCD::CommandFifo::str(str); - } + if (use_utf8) { + TERN_(TOUCH_UI_USE_UTF8, draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options)); + } + else { + cmd.CLCD::CommandFifo::text(x, y, font, options); + cmd.CLCD::CommandFifo::str(str); + } } /** @@ -80,9 +77,9 @@ namespace FTDI { _draw_text_with_ellipsis(cmd, x, y, w, h, tmp, options, font); } - void draw_text_with_ellipsis(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P pstr, uint16_t options, uint8_t font) { - char tmp[strlen_P((const char*)pstr) + 3]; - strcpy_P(tmp, (const char*)pstr); + void draw_text_with_ellipsis(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P fstr, uint16_t options, uint8_t font) { + char tmp[strlen_P(FTOP(fstr)) + 3]; + strcpy_P(tmp, FTOP(fstr)); _draw_text_with_ellipsis(cmd, x, y, w, h, tmp, options, font); } } // namespace FTDI diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp index ca25dea3ca..d428f686b7 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp @@ -191,9 +191,9 @@ return render_utf8_text(nullptr, 0, 0, str, fs, maxlen); } - uint16_t FTDI::get_utf8_text_width(FSTR_P pstr, font_size_t fs) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + uint16_t FTDI::get_utf8_text_width(FSTR_P fstr, font_size_t fs) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); return get_utf8_text_width(str, fs); } @@ -234,9 +234,9 @@ cmd.cmd(RESTORE_CONTEXT()); } - void FTDI::draw_utf8_text(CommandProcessor& cmd, int x, int y, FSTR_P pstr, font_size_t fs, uint16_t options) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + void FTDI::draw_utf8_text(CommandProcessor& cmd, int x, int y, FSTR_P fstr, font_size_t fs, uint16_t options) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); draw_utf8_text(cmd, x, y, (const char*) str, fs, options); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp index 4415ed50fc..ce3066ae41 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp @@ -245,8 +245,8 @@ void BaseNumericAdjustmentScreen::widgets_t::adjuster(uint8_t tag, FSTR_P label, } if (_what & FOREGROUND) { - char b[strlen_P(value)+1]; - strcpy_P(b,value); + char b[strlen(value) + 1]; + strcpy(b, value); adjuster_sram_val(tag, label, b, is_enabled); } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp index 4e76450683..7310577995 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp @@ -345,8 +345,8 @@ void StatusScreen::draw_status_message(draw_mode_t what, const char *message) { } void StatusScreen::setStatusMessage(FSTR_P message) { - char buff[strlen_P((const char * const)message)+1]; - strcpy_P(buff, (const char * const) message); + char buff[strlen_P(FTOP(message)) + 1]; + strcpy_P(buff, FTOP(message)); setStatusMessage((const char *) buff); } diff --git a/Marlin/src/lcd/fontutils.h b/Marlin/src/lcd/fontutils.h index 3901d4439f..21aee1e939 100644 --- a/Marlin/src/lcd/fontutils.h +++ b/Marlin/src/lcd/fontutils.h @@ -63,6 +63,7 @@ uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t /* Returns length of string in CHARACTERS, NOT BYTES */ uint8_t utf8_strlen(const char *pstart); uint8_t utf8_strlen_P(PGM_P pstart); +inline uint8_t utf8_strlen(FSTR_P fstart) { return utf8_strlen_P(FTOP(fstart)); } /* Returns start byte position of desired char number */ uint8_t utf8_byte_pos_by_char_num(const char *pstart, const uint8_t charnum); diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index c701a59568..d716d035ca 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -190,6 +190,9 @@ inline lcd_uint_t lcd_put_u8str_ind_P(const lcd_uint_t col, const lcd_uint_t row lcd_moveto(col, row); return lcd_put_u8str_ind_P(pstr, ind, inStr, maxlen); } +inline lcd_uint_t lcd_put_u8str_ind(FSTR_P const fstr, const int8_t ind, FSTR_P const inFstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { + return lcd_put_u8str_ind_P(FTOP(fstr), ind, FTOP(inFstr), maxlen); +} inline lcd_uint_t lcd_put_u8str_ind(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const fstr, const int8_t ind, FSTR_P const inFstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { return lcd_put_u8str_ind_P(col, row, FTOP(fstr), ind, FTOP(inFstr), maxlen); } diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 72826262f4..b111236d69 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -114,8 +114,8 @@ class MenuItem_confirm : public MenuItemBase { selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, FSTR_P const string, PGM_P const suff=nullptr ) { - char str[strlen_P((PGM_P)string) + 1]; - strcpy_P(str, (PGM_P)string); + char str[strlen_P(FTOP(string)) + 1]; + strcpy_P(str, FTOP(string)); select_screen(yes, no, yesFunc, noFunc, pref, str, suff); } // Shortcut for prompt with "NO"/ "YES" labels From 9c9300ff9dfa3f6b16c9a87be6ff1136ccc7e880 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 12 Mar 2022 23:47:47 +0000 Subject: [PATCH 108/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Chiron=20new=20TFT?= =?UTF-8?q?=20SD=20print=20after=20reset=20(#23855)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 6 ++-- .../extui/anycubic_chiron/FileNavigator.cpp | 4 +-- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 30 ++++++++++--------- .../extui/anycubic_chiron/chiron_tft_defs.h | 10 +++++-- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index f06bfc0fdc..74843235f4 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -118,9 +118,11 @@ void GcodeSuite::G29() { // For each G29 S2... if (mbl_probe_index == 0) { // Move close to the bed before the first point - do_blocking_move_to_z(0.4f + do_blocking_move_to_z( #ifdef MANUAL_PROBE_START_Z - + (MANUAL_PROBE_START_Z) - 0.4f + MANUAL_PROBE_START_Z + #else + 0.4f #endif ); } diff --git a/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp b/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp index f49b17acc1..0ef8186668 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp @@ -155,7 +155,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) { if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder // The new panel ignores entries that don't end in .GCO or .gcode so add and pad them. - if (paneltype == AC_panel_new) { + if (paneltype <= AC_panel_new) { TFTSer.println("<<.GCO"); Chiron.SendtoTFTLN(F(".. .gcode")); } @@ -177,7 +177,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) { void FileNavigator::sendFile(panel_type_t paneltype) { if (filelist.isDir()) { // Add mandatory tags for new panel otherwise lines are ignored. - if (paneltype == AC_panel_new) { + if (paneltype <= AC_panel_new) { TFTSer.print(filelist.shortFilename()); TFTSer.println(".GCO"); TFTSer.print(filelist.shortFilename()); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index fac0615cd6..fa85de2a8e 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -442,7 +442,7 @@ void ChironTFT::SendFileList(int8_t startindex) { } void ChironTFT::SelectFile() { - if (panel_type == AC_panel_new) { + if (panel_type <= AC_panel_new) { strncpy(selectedfile, panel_command + 4, command_len - 3); selectedfile[command_len - 4] = '\0'; } @@ -465,7 +465,7 @@ void ChironTFT::SelectFile() { break; default: // enter sub folder // for new panel remove the '.GCO' tag that was added to the end of the path - if (panel_type == AC_panel_new) + if (panel_type <= AC_panel_new) selectedfile[strlen(selectedfile) - 4] = '\0'; filenavigator.changeDIR(selectedfile); SendtoTFTLN(AC_msg_sd_file_open_failed); @@ -478,8 +478,8 @@ void ChironTFT::ProcessPanelRequest() { // Break these up into logical blocks // as its easier to navigate than one huge switch case! int8_t tpos = FindToken('A'); // Panel request are 'A0' - 'A36' - if (tpos != -1) { - const int8_t req = atoi(&panel_command[tpos+1]); + if (tpos >= 0) { + const int8_t req = atoi(&panel_command[tpos + 1]); // Information requests A0 - A8 and A33 if (req <= 8 || req == 33) PanelInfo(req); @@ -495,16 +495,18 @@ void ChironTFT::ProcessPanelRequest() { // This may be a response to a panel type detection query if (panel_type == AC_panel_unknown) { tpos = FindToken('S'); // old panel will respond to 'SIZE' with 'SXY 480 320' - if (tpos != -1) { - if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') { + if (tpos >= 0) { + if (panel_command[tpos + 1] == 'X' && panel_command[tpos + 2] =='Y') { panel_type = AC_panel_standard; SERIAL_ECHOLNF(AC_msg_old_panel_detected); } } else { - tpos = FindToken('['); // new panel will respond to 'J200' with '[0]=0' - if (tpos != -1) { - if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') { + // new panel will respond to 'J200' with '[0]=0' + // it seems only after a power cycle so detection assumes a new panel + tpos = FindToken('['); + if (tpos >= 0) { + if (panel_command[tpos + 1] == '0' && panel_command[tpos + 2] ==']') { panel_type = AC_panel_new; SERIAL_ECHOLNF(AC_msg_new_panel_detected); } @@ -811,7 +813,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } break; case 30: // A30 Auto leveling - if (FindToken('S') != -1) { // Start probing New panel adds spaces.. + if (FindToken('S') >= 0) { // Start probing New panel adds spaces.. // Ignore request if printing if (isPrinting()) SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling @@ -828,7 +830,7 @@ void ChironTFT::PanelProcess(uint8_t req) { case 31: // A31 Adjust all Probe Points // The tokens can occur in different places on the new panel so we need to find it. - if (FindToken('C') != -1) { // Restore and apply original offsets + if (FindToken('C') >= 0) { // Restore and apply original offsets if (!isPrinting()) { injectCommands(F("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; @@ -836,7 +838,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } - else if (FindToken('D') != -1) { // Save Z Offset tables and restore leveling state + else if (FindToken('D') >= 0) { // Save Z Offset tables and restore leveling state if (!isPrinting()) { setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made injectCommands(F("M500")); @@ -845,7 +847,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } - else if (FindToken('G') != -1) { // Get current offset + else if (FindToken('G') >= 0) { // Get current offset SendtoTFT(F("A31V ")); // When printing use the live z Offset position // we will use babystepping to move the print head @@ -859,7 +861,7 @@ void ChironTFT::PanelProcess(uint8_t req) { else { int8_t tokenpos = FindToken('S'); - if (tokenpos != -1) { // Set offset (adjusts all points by value) + if (tokenpos >= 0) { // Set offset (adjusts all points by value) float Zshift = atof(&panel_command[tokenpos+1]); setSoftEndstopState(false); // disable endstops // Allow temporary Z position nudging during print diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h index 0fd7770cdd..e3609b5408 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h @@ -89,6 +89,10 @@ #define AC_msg_mesh_changes_saved F("Mesh changes saved.") #define AC_msg_old_panel_detected F("Standard TFT panel detected!") #define AC_msg_new_panel_detected F("New TFT panel detected!") +#define AC_msg_auto_panel_detection F("Auto detect panel type (assuming new panel)") +#define AC_msg_old_panel_set F("Set for standard TFT panel.") +#define AC_msg_new_panel_set F("Set for new TFT panel.") + #define AC_msg_powerloss_recovery F("Resuming from power outage! select the same SD file then press resume") // Error messages must not contain spaces #define AC_msg_error_bed_temp F("Abnormal_bed_temp") @@ -161,10 +165,10 @@ namespace Anycubic { AC_menu_change_to_file, AC_menu_change_to_command }; - enum panel_type_t : uint8_t { + enum panel_type_t : uint8_t { // order is important here as we assume new panel if type is unknown AC_panel_unknown, - AC_panel_standard, - AC_panel_new + AC_panel_new, + AC_panel_standard }; enum last_error_t : uint8_t { AC_error_none, From 2f6a6f3b55a1a6d8febcda648fa5353cc25467c1 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sat, 12 Mar 2022 16:23:29 -0800 Subject: [PATCH 109/203] =?UTF-8?q?=F0=9F=94=A8=20Drop=20extraneous=20buil?= =?UTF-8?q?d=20flag=20(#23862)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/stm32f4.ini | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 9e6e213427..d7c160d639 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -298,9 +298,8 @@ extends = env:BIGTREE_OCTOPUS_PRO_V1_F429 platform_packages = ${stm_flash_drive.platform_packages} build_unflags = -DUSBD_USE_CDC build_flags = ${stm_flash_drive.build_flags} - -DSTM32F446_5VX -DUSE_USB_HS_IN_FS - -DUSE_USBHOST_HS -DUSBD_IRQ_PRIO=5 - -DUSBD_IRQ_SUBPRIO=6 + -DUSE_USB_HS_IN_FS -DUSE_USBHOST_HS + -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 -DUSBD_USE_CDC_MSC # From ea3d6ecea9f36640d2561d03b1c8d4e16f2a2001 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 13 Mar 2022 01:07:44 +0000 Subject: [PATCH 110/203] [cron] Bump distribution date (2022-03-13) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 49daf8dd7f..7866555842 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-12" +//#define STRING_DISTRIBUTION_DATE "2022-03-13" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 76889cb40a..0d44b6632a 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-12" + #define STRING_DISTRIBUTION_DATE "2022-03-13" #endif /** From a58d35d765c091ec4aab6af893e5b3ad353cb3d5 Mon Sep 17 00:00:00 2001 From: Mathew Winters Date: Sun, 13 Mar 2022 14:13:41 +1300 Subject: [PATCH 111/203] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20G12=20-=20Only=20r?= =?UTF-8?q?equire=20used=20axes=20to=20be=20homed=20(#23422)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/gcode/feature/clean/G12.cpp | 3 ++- Marlin/src/module/motion.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/feature/clean/G12.cpp b/Marlin/src/gcode/feature/clean/G12.cpp index a0b87b1abc..999a9b10bd 100644 --- a/Marlin/src/gcode/feature/clean/G12.cpp +++ b/Marlin/src/gcode/feature/clean/G12.cpp @@ -46,7 +46,8 @@ */ void GcodeSuite::G12() { // Don't allow nozzle cleaning without homing first - if (homing_needed_error()) return; + if (homing_needed_error(linear_bits & ~TERN0(NOZZLE_CLEAN_NO_Z, Z_AXIS) & ~TERN0(NOZZLE_CLEAN_NO_Y, Y_AXIS))) + return; #ifdef WIPE_SEQUENCE_COMMANDS if (!parser.seen_any()) { diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 2fbb4ce114..1dd6d8c4ed 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -404,7 +404,7 @@ void set_axis_is_at_home(const AxisEnum axis); constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted inline void homeaxis(const AxisEnum axis) {} inline void set_axis_never_homed(const AxisEnum) {} - inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; } + inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return 0; } inline bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; } inline void set_axis_unhomed(const AxisEnum axis) {} inline void set_axis_untrusted(const AxisEnum axis) {} From 639a2dc0b3cd46e236e531c799331ac3fade40d1 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 13 Mar 2022 13:48:18 -0400 Subject: [PATCH 112/203] M591 Cleanup and tweaks --- Marlin/src/gcode/feature/runout/M591.cpp | 2 +- Marlin/src/module/endstops.cpp | 15 ++++++----- Marlin/src/module/settings.cpp | 32 ++++++++++++------------ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index e80252677a..e4a7e5b59d 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -70,7 +70,7 @@ void GcodeSuite::M591() { if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('P')) { uint8_t tmp_mode = parser.value_int(); - if(tmp_mode > 3 || tmp_mode==7) { + if(tmp_mode < 3 || tmp_mode==7) { runout.mode[tool] = tmp_mode; runout.reset(); } diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 57476d89f6..4fae1d4ad2 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -583,21 +583,24 @@ void _O2 Endstops::report_states() { default: continue; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) } - if(runout.mode[i]==1) + if(runout.mode[i-1]==1) state = HIGH; else state = LOW; SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); - print_es_state(extDigitalRead(pin) != state); SERIAL_ECHOPGM(": "); - if(runout.mode[i]==0) - SERIAL_ECHOLNF(F("Sensor Disabled")); + if(runout.mode[i-1]==0) + SERIAL_ECHOLNF(F("DISABLED")); + else if(runout.mode[i-1]==7) { + SERIAL_ECHOF(F("MOTION : ")); + print_es_state(extDigitalRead(pin) != state); + } else if(extDigitalRead(pin) != state) - SERIAL_ECHOLNF(F("Fil Present")); + SERIAL_ECHOLNF(F("PRESENT")); else - SERIAL_ECHOLNF(F("Fil Missing")); + SERIAL_ECHOLNF(F("MISSING")); } #undef _CASE_RUNOUT #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 1dccdb905e..20f480faa2 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V86" +#define EEPROM_VERSION "V87" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -794,18 +794,18 @@ void MarlinSettings::postprocess() { // { #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.enabled[e]); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.runout_distance(e)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE(runout.mode[e]); #else - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((int8_t)-1)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((float)-0.0f)); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_WRITE((uint8_t)0)); #endif } @@ -1715,21 +1715,21 @@ void MarlinSettings::postprocess() { { int8_t runout_sensor_enabled[HOTENDS]; _FIELD_TEST(runout_sensor_enabled); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_sensor_enabled); float runout_distance_mm[HOTENDS]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_distance_mm[e]); uint8_t runout_mode[HOTENDS]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) EEPROM_READ(runout_mode[e]); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) if (!validating) runout.mode[e] = runout_mode[e]; runout.reset(); #endif @@ -2798,11 +2798,11 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); - LOOP_S_L_N(e, 1, HOTENDS) + LOOP_S_L_N(e, 0, HOTENDS) runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; runout.reset(); From 0c0ef9e54884ac84bf7700bc8dd6df92cf693b5c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Mar 2022 16:46:08 -0500 Subject: [PATCH 113/203] =?UTF-8?q?=F0=9F=9A=B8=20Test=20LIN=5FADVANCE=20i?= =?UTF-8?q?n=20a=20pins=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/esp32/pins_MRR_ESPE.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPE.h b/Marlin/src/pins/esp32/pins_MRR_ESPE.h index 60c8405dfe..9b9b54e3ae 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPE.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPE.h @@ -55,7 +55,9 @@ #define I2S_WS 26 #define I2S_BCK 25 #define I2S_DATA 27 -#undef LIN_ADVANCE // Currently, I2S stream does not work with linear advance +#if ENABLED(LIN_ADVANCE) + #error "I2S stream is currently incompatible with LIN_ADVANCE." +#endif // // Steppers From 4d40764802d9d131ae049a966786572a3a6f66d2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Mar 2022 16:59:43 -0500 Subject: [PATCH 114/203] =?UTF-8?q?=F0=9F=93=9D=20Fix=20DEFAULT=5FDUAL=5FX?= =?UTF-8?q?=5FCARRIAGE=5FMODE=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 83a8eaa0fb..8d9b4dfb3b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -822,7 +822,7 @@ // without modifying the firmware (through the "M218 T1 X???" command). // Remember: you should set the second extruder x-offset to 0 in your slicer. - // This is the default power-up mode which can be later using M605. + // This is the default power-up mode which can be changed later using M605 S. #define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE // Default x offset in duplication mode (typically set to half print bed width) From a9c30cb9c18142733c78cc820f21f83648beb5eb Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sun, 13 Mar 2022 18:00:35 -0400 Subject: [PATCH 115/203] =?UTF-8?q?=F0=9F=93=9D=20Fix=20X2=5FMAX=5FPOS=20c?= =?UTF-8?q?omment=20(#23873)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 19 +++++++++---------- Marlin/src/module/motion.cpp | 23 ++++++++++------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8d9b4dfb3b..d78e63100e 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -811,16 +811,15 @@ */ //#define DUAL_X_CARRIAGE #if ENABLED(DUAL_X_CARRIAGE) - #define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS - #define X1_MAX_POS X_BED_SIZE // Set a maximum so the first X-carriage can't hit the parked second X-carriage - #define X2_MIN_POS 80 // Set a minimum to ensure the second X-carriage can't hit the parked first X-carriage - #define X2_MAX_POS 353 // Set this to the distance between toolheads when both heads are homed - #define X2_HOME_DIR 1 // Set to 1. The second X-carriage always homes to the maximum endstop position - #define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS. - // However: In this mode the HOTEND_OFFSET_X value for the second extruder provides a software - // override for X2_HOME_POS. This also allow recalibration of the distance between the two endstops - // without modifying the firmware (through the "M218 T1 X???" command). - // Remember: you should set the second extruder x-offset to 0 in your slicer. + #define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS + #define X1_MAX_POS X_BED_SIZE // A max coordinate so the X1 carriage can't hit the parked X2 carriage + #define X2_MIN_POS 80 // A min coordinate so the X2 carriage can't hit the parked X1 carriage + #define X2_MAX_POS 353 // The max position of the X2 carriage, typically also the home position + #define X2_HOME_DIR 1 // Set to 1. The X2 carriage always homes to the max endstop position + #define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS. + // NOTE: For Dual X Carriage use M218 T1 Xn to override the X2_HOME_POS. + // This allows recalibration of endstops distance without a rebuild. + // Remember to set the second extruder's X-offset to 0 in your slicer. // This is the default power-up mode which can be changed later using M605 S. #define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 4b0c6aba7d..0f8e02db9e 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -125,9 +125,7 @@ xyze_pos_t destination; // {0} ); // Transpose from [XYZ][HOTENDS] to [HOTENDS][XYZ] HOTEND_LOOP() LOOP_ABC(a) hotend_offset[e][a] = tmp[a][e]; - #if ENABLED(DUAL_X_CARRIAGE) - hotend_offset[1].x = _MAX(X2_HOME_POS, X2_MAX_POS); - #endif + TERN_(DUAL_X_CARRIAGE, hotend_offset[1].x = _MAX(X2_HOME_POS, X2_MAX_POS)); } #endif @@ -1116,16 +1114,15 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { bool idex_mirrored_mode = false; // Used in mode 3 float x_home_pos(const uint8_t extruder) { - if (extruder == 0) - return X_HOME_POS; - else - /** - * In dual carriage mode the extruder offset provides an override of the - * second X-carriage position when homed - otherwise X2_HOME_POS is used. - * This allows soft recalibration of the second extruder home position - * without firmware reflash (through the M218 command). - */ - return hotend_offset[1].x > 0 ? hotend_offset[1].x : X2_HOME_POS; + if (extruder == 0) return X_HOME_POS; + + /** + * In dual carriage mode the extruder offset provides an override of the + * second X-carriage position when homed - otherwise X2_HOME_POS is used. + * This allows soft recalibration of the second extruder home position + * (with M218 T1 Xn) without firmware reflash. + */ + return hotend_offset[1].x > 0 ? hotend_offset[1].x : X2_HOME_POS; } void idex_set_mirrored_mode(const bool mirr) { From de87f5309da712a94da984d611bf1265bdce880c Mon Sep 17 00:00:00 2001 From: Julien Staub Date: Sun, 13 Mar 2022 23:09:32 +0100 Subject: [PATCH 116/203] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20ExtUI=20build=20wi?= =?UTF-8?q?th=20Host=20Keepalive=20disabled=20(#23898)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/ui_api.cpp | 6 ++++-- Marlin/src/lcd/extui/ui_api.h | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index bfcbc39d7b..0dad675cb7 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -389,8 +389,10 @@ namespace ExtUI { return !thermalManager.tooColdToExtrude(extruder - E0); } - GcodeSuite::MarlinBusyState getHostKeepaliveState() { return TERN0(HOST_KEEPALIVE_FEATURE, gcode.busy_state); } - bool getHostKeepaliveIsPaused() { return TERN0(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive_is_paused()); } + #if ENABLED(HOST_KEEPALIVE_FEATURE) + GcodeSuite::MarlinBusyState getHostKeepaliveState() { return gcode.busy_state; } + bool getHostKeepaliveIsPaused() { return gcode.host_keepalive_is_paused(); } + #endif #if HAS_SOFTWARE_ENDSTOPS bool getSoftEndstopState() { return soft_endstop._enabled; } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index b575684a03..248bffb6f4 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -83,8 +83,10 @@ namespace ExtUI { void injectCommands(char * const); bool commandsInQueue(); - GcodeSuite::MarlinBusyState getHostKeepaliveState(); - bool getHostKeepaliveIsPaused(); + #if ENABLED(HOST_KEEPALIVE_FEATURE) + GcodeSuite::MarlinBusyState getHostKeepaliveState(); + bool getHostKeepaliveIsPaused(); + #endif bool isHeaterIdle(const heater_t); bool isHeaterIdle(const extruder_t); From 40ed3c5f89c2784752682f191bbe715a08224fa0 Mon Sep 17 00:00:00 2001 From: Julien Staub Date: Sun, 13 Mar 2022 23:11:31 +0100 Subject: [PATCH 117/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20STM32F1=20HAL=20bu?= =?UTF-8?q?ild=20(#23897)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23357 --- Marlin/src/HAL/STM32F1/HAL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 8fbb43c602..ceb17b4884 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -177,7 +177,7 @@ typedef int8_t pin_t; // ------------------------ #define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); (void)__iCliRetVal() -#define CRITICAL_SECTION_END() if (!primask) (void)__iSeiRetVal() +#define CRITICAL_SECTION_END() if (!irqon) (void)__iSeiRetVal() #define cli() noInterrupts() #define sei() interrupts() From 9bc1d05df3cc2e4f942393cdcdc0a1f05b64ceed Mon Sep 17 00:00:00 2001 From: Mrnt Date: Sun, 13 Mar 2022 15:17:35 -0700 Subject: [PATCH 118/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20All?= =?UTF-8?q?ow=20DIGIPOT=20Rsx=20/=20Vrefmax=20override=20(#23885)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/digipot/digipot_mcp4018.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Marlin/src/feature/digipot/digipot_mcp4018.cpp b/Marlin/src/feature/digipot/digipot_mcp4018.cpp index 37853ff428..3f2ecbfcdc 100644 --- a/Marlin/src/feature/digipot/digipot_mcp4018.cpp +++ b/Marlin/src/feature/digipot/digipot_mcp4018.cpp @@ -31,9 +31,13 @@ // Settings for the I2C based DIGIPOT (MCP4018) based on WT150 -#define DIGIPOT_A4988_Rsx 0.250 -#define DIGIPOT_A4988_Vrefmax 1.666 -#define DIGIPOT_MCP4018_MAX_VALUE 127 +#ifndef DIGIPOT_A4988_Rsx + #define DIGIPOT_A4988_Rsx 0.250 +#endif +#ifndef DIGIPOT_A4988_Vrefmax + #define DIGIPOT_A4988_Vrefmax 1.666 +#endif +#define DIGIPOT_MCP4018_MAX_VALUE 127 #define DIGIPOT_A4988_Itripmax(Vref) ((Vref) / (8.0 * DIGIPOT_A4988_Rsx)) From f4b41fcc3fe2a953ca47c537f01a99df0ec555dd Mon Sep 17 00:00:00 2001 From: Jelmer van der Stel Date: Sun, 13 Mar 2022 23:20:30 +0100 Subject: [PATCH 119/203] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20DWIN=20E3V2=20disp?= =?UTF-8?q?lay=20issues=20by=20allowing=20re-init=20(#23879)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_post.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 547ca36e92..9942f14eee 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -459,7 +459,7 @@ #endif -#if PIN_EXISTS(SD_DETECT) && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI) +#if PIN_EXISTS(SD_DETECT) && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2) #define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion #endif From 0c15e8e751e23774d61f031ce97051f48b2dcf92 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 13 Mar 2022 18:57:24 -0400 Subject: [PATCH 120/203] Fix up pause trigger, adjust config options minor changes --- Marlin/Configuration.h | 14 +------ Marlin/src/feature/pause.cpp | 28 ++++++++++--- Marlin/src/feature/runout.cpp | 8 ++-- Marlin/src/feature/runout.h | 6 +-- Marlin/src/inc/Conditionals_LCD.h | 36 ++++++---------- Marlin/src/inc/Conditionals_adv.h | 10 ----- Marlin/src/inc/SanityCheck.h | 13 +++++- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 3 -- Marlin/src/module/settings.cpp | 42 +++++++++---------- 9 files changed, 76 insertions(+), 84 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 87fab7852b..865a975b2e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1466,46 +1466,36 @@ */ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500. - #define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. + #define FIL_RUNOUT_ENABLED_DEFAULT { true } // Default state for sensors E0, E1[, E2, E3] // Enable the sensor on startup. Override with M591 followed by M500. #define FILAMENT_RUNOUT_DEFAULT_MODE {1} // Array set that will take the place of FIL_RUNOUT_STATE and FIL_RUNOUT_ENABLED_DEFAULT as this code matures - #define FIL_RUNOUT_STATE LOW // Pin state indicating that filament is NOT present. #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. //#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder. // This is automatically enabled for MIXING_EXTRUDERs. // Override individually if the runout sensors vary - //#define FIL_RUNOUT1_STATE LOW //#define FIL_RUNOUT1_PULLUP //#define FIL_RUNOUT1_PULLDOWN - //#define FIL_RUNOUT2_STATE LOW //#define FIL_RUNOUT2_PULLUP //#define FIL_RUNOUT2_PULLDOWN - //#define FIL_RUNOUT3_STATE LOW //#define FIL_RUNOUT3_PULLUP //#define FIL_RUNOUT3_PULLDOWN - //#define FIL_RUNOUT4_STATE LOW //#define FIL_RUNOUT4_PULLUP //#define FIL_RUNOUT4_PULLDOWN - //#define FIL_RUNOUT5_STATE LOW //#define FIL_RUNOUT5_PULLUP //#define FIL_RUNOUT5_PULLDOWN - //#define FIL_RUNOUT6_STATE LOW //#define FIL_RUNOUT6_PULLUP //#define FIL_RUNOUT6_PULLDOWN - //#define FIL_RUNOUT7_STATE LOW //#define FIL_RUNOUT7_PULLUP //#define FIL_RUNOUT7_PULLDOWN - //#define FIL_RUNOUT8_STATE LOW //#define FIL_RUNOUT8_PULLUP //#define FIL_RUNOUT8_PULLDOWN @@ -1517,7 +1507,7 @@ // After a runout is detected, continue printing this length of filament // before executing the runout script. Useful for a sensor at the end of // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - //#define FILAMENT_RUNOUT_DISTANCE_MM {25} + #define FILAMENT_RUNOUT_DISTANCE_MM {15} #ifdef FILAMENT_RUNOUT_DISTANCE_MM // Enable this option to use an encoder disc that toggles the runout pin diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 636ac32042..7333613c83 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -209,12 +209,30 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load impatient_beep(max_beep_count); #if BOTH(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR) #if ENABLED(MULTI_FILAMENT_SENSOR) - #define _CASE_INSERTED(N) case N-1: if (READ(FIL_RUNOUT##N##_PIN) != FIL_RUNOUT##N##_STATE) wait_for_user = false; break; - switch (active_extruder) { - REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED) + #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; + LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) { + pin_t pin; + uint8_t state; + switch (i) { + default: continue; + REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) + } + if(runout.mode[i-1]==1) + state = HIGH; + else + state = LOW; + if(runout.mode[i-1]!=0 && runout.mode[i-1]!=7 && extDigitalRead(pin) != state) + wait_for_user = false; } - #else - if (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE) wait_for_user = false; + #undef _CASE_RUNOUT + #else { + uint8_t state; + if(runout.mode[active_extruder]==1) + state = HIGH; + else + state = LOW; + if (READ(FIL_RUNOUT_PIN) != state) wait_for_user = false; + } #endif #endif idle_no_sleep(); diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 7791637699..332890c0ef 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -32,9 +32,9 @@ FilamentMonitor runout; -bool FilamentMonitorBase::enabled[HOTENDS] = {true}, +bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS] = {true}, FilamentMonitorBase::filament_ran_out; // = false -uint8_t FilamentMonitorBase::mode[HOTENDS] = FILAMENT_RUNOUT_DEFAULT_MODE; // Initialized by settings.load +uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DEFAULT_MODE; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif @@ -46,8 +46,8 @@ uint8_t FilamentMonitorBase::mode[HOTENDS] = FILAMENT_RUNOUT_DEFAULT_MODE; // In #endif -float RunoutResponseDelayed::runout_distance_mm[HOTENDS] = FILAMENT_RUNOUT_DISTANCE_MM; -volatile float RunoutResponseDelayed::runout_mm_countdown[HOTENDS]; +float RunoutResponseDelayed::runout_distance_mm[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DISTANCE_MM; +volatile float RunoutResponseDelayed::runout_mm_countdown[NUM_RUNOUT_SENSORS]; uint8_t FilamentSensorCore::motion_detected; diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 2844264481..7867809232 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -63,8 +63,8 @@ extern FilamentMonitor runout; class FilamentMonitorBase { public: - static bool enabled[HOTENDS], filament_ran_out; - static uint8_t mode[HOTENDS]; + static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out; + static uint8_t mode[NUM_RUNOUT_SENSORS]; #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -319,7 +319,7 @@ class FilamentSensorBase { static volatile float runout_mm_countdown[NUM_RUNOUT_SENSORS]; public: - static float runout_distance_mm[HOTENDS]; + static float runout_distance_mm[NUM_RUNOUT_SENSORS]; static void reset() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 33d9e46220..e2b643ae73 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -832,11 +832,11 @@ /** * Fill in undefined Filament Sensor options */ +#ifndef NUM_RUNOUT_SENSORS + #define NUM_RUNOUT_SENSORS E_STEPPERS +#endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) #if NUM_RUNOUT_SENSORS >= 1 - #ifndef FIL_RUNOUT1_STATE - #define FIL_RUNOUT1_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT1_PULLUP #define FIL_RUNOUT1_PULLUP FIL_RUNOUT_PULLUP #endif @@ -845,9 +845,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 2 - #ifndef FIL_RUNOUT2_STATE - #define FIL_RUNOUT2_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT2_PULLUP #define FIL_RUNOUT2_PULLUP FIL_RUNOUT_PULLUP #endif @@ -856,9 +853,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 3 - #ifndef FIL_RUNOUT3_STATE - #define FIL_RUNOUT3_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT3_PULLUP #define FIL_RUNOUT3_PULLUP FIL_RUNOUT_PULLUP #endif @@ -867,9 +861,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 4 - #ifndef FIL_RUNOUT4_STATE - #define FIL_RUNOUT4_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT4_PULLUP #define FIL_RUNOUT4_PULLUP FIL_RUNOUT_PULLUP #endif @@ -878,9 +869,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 5 - #ifndef FIL_RUNOUT5_STATE - #define FIL_RUNOUT5_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT5_PULLUP #define FIL_RUNOUT5_PULLUP FIL_RUNOUT_PULLUP #endif @@ -889,9 +877,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 6 - #ifndef FIL_RUNOUT6_STATE - #define FIL_RUNOUT6_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT6_PULLUP #define FIL_RUNOUT6_PULLUP FIL_RUNOUT_PULLUP #endif @@ -900,9 +885,7 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 7 - #ifndef FIL_RUNOUT7_STATE - #define FIL_RUNOUT7_STATE FIL_RUNOUT_STATE - #endif + #ifndef FIL_RUNOUT7_PULLUP #define FIL_RUNOUT7_PULLUP FIL_RUNOUT_PULLUP #endif @@ -911,9 +894,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 8 - #ifndef FIL_RUNOUT8_STATE - #define FIL_RUNOUT8_STATE FIL_RUNOUT_STATE - #endif #ifndef FIL_RUNOUT8_PULLUP #define FIL_RUNOUT8_PULLUP FIL_RUNOUT_PULLUP #endif @@ -921,6 +901,14 @@ #define FIL_RUNOUT8_PULLDOWN FIL_RUNOUT_PULLDOWN #endif #endif + + #define HAS_FILAMENT_SENSOR 1 + #if NUM_RUNOUT_SENSORS > 1 + #define MULTI_FILAMENT_SENSOR 1 + #endif + #if ENABLED(MIXING_EXTRUDER) + #define WATCH_ALL_RUNOUT_SENSORS + #endif #endif // FILAMENT_RUNOUT_SENSOR // Homing to Min or Max diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index f0999df41f..d0004658ce 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -543,16 +543,6 @@ #define HAS_SERVICE_INTERVALS 1 #endif -#if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define HAS_FILAMENT_SENSOR 1 - #if NUM_RUNOUT_SENSORS > 1 - #define MULTI_FILAMENT_SENSOR 1 - #endif - #if ENABLED(MIXING_EXTRUDER) - #define WATCH_ALL_RUNOUT_SENSORS - #endif -#endif - // Probe Temperature Compensation #if !TEMP_SENSOR_PROBE #undef PTC_PROBE diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 78117dc482..9f7b9fb056 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -561,9 +561,9 @@ #error "SHORT_MANUAL_Z_MOVE is now FINE_MANUAL_MOVE, applying to Z on most printers." #elif defined(FIL_RUNOUT_INVERTING) #if FIL_RUNOUT_INVERTING - #error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_STATE HIGH." + #error "FIL_RUNOUT_INVERTING true is now FILAMENT_RUNOUT_DEFAULT_MODE {HIGH}." #else - #error "FIL_RUNOUT_INVERTING false is now FIL_RUNOUT_STATE LOW." + #error "FIL_RUNOUT_INVERTING false is now FILAMENT_RUNOUT_DEFAULT_MODE {LOW}." #endif #elif defined(ASSISTED_TRAMMING_MENU_ITEM) #error "ASSISTED_TRAMMING_MENU_ITEM is deprecated and should be removed." @@ -1002,7 +1002,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with FILAMENT_RUNOUT_SENSOR."); + #elif ANY(FIL_RUNOUT_STATE, FIL_RUNOUT1_STATE, FIL_RUNOUT2_STATE, FIL_RUNOUT3_STATE, FIL_RUNOUT4_STATE, FIL_RUNOUT5_STATE, FIL_RUNOUT6_STATE, FIL_RUNOUT7_STATE, FIL_RUNOUT8_STATE) + #error "FIL_RUNOUT#_STATE is Now set with FILAMENT_RUNOUT_DEFAULT_MODE" #endif + + constexpr uint8_t frdm[] = FILAMENT_RUNOUT_DEFAULT_MODE; + static_assert(COUNT(frdm) == NUM_RUNOUT_SENSORS, "FILAMENT_RUNOUT_DEFAULT_MODE must have NUM_RUNOUT_SENSORS values."); + constexpr bool fred[] = FIL_RUNOUT_ENABLED_DEFAULT; + static_assert(COUNT(fred) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_ENABLED_DEFAULT must have NUM_RUNOUT_SENSORS values."); + constexpr float frd[] = FILAMENT_RUNOUT_DISTANCE_MM; + static_assert(COUNT(frd) == NUM_RUNOUT_SENSORS, "FILAMENT_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); #endif /** diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index c56d8aa7fb..aa5bae62bc 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -80,9 +80,6 @@ void ChironTFT::Startup() { OUT_WRITE(OUTAGECON_PIN, HIGH); #endif - // Filament runout is handled by Marlin settings in Configuration.h - // opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present. - // opt_enable FIL_RUNOUT_PULLUP TFTSer.begin(115200); // wait for the TFT panel to initialise and finish the animation diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 20f480faa2..11084e325a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -235,9 +235,9 @@ typedef struct SettingsDataStruct { // // FILAMENT_RUNOUT_SENSOR // - bool runout_sensor_enabled[HOTENDS]; // M591 S - float runout_distance_mm[HOTENDS]; // M591 D - uint8_t runout_mode[HOTENDS]; // M591 P + bool runout_sensor_enabled[NUM_RUNOUT_SENSORS]; // M591 S + float runout_distance_mm[NUM_RUNOUT_SENSORS]; // M591 D + uint8_t runout_mode[NUM_RUNOUT_SENSORS]; // M591 P // // ENABLE_LEVELING_FADE_HEIGHT @@ -794,18 +794,18 @@ void MarlinSettings::postprocess() { // { #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.enabled[e]); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.runout_distance(e)); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.mode[e]); #else - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE((int8_t)-1)); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE((float)-0.0f)); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_WRITE((uint8_t)0)); #endif } @@ -1713,23 +1713,23 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { - int8_t runout_sensor_enabled[HOTENDS]; + int8_t runout_sensor_enabled[NUM_RUNOUT_SENSORS]; _FIELD_TEST(runout_sensor_enabled); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_READ(runout_sensor_enabled); - float runout_distance_mm[HOTENDS]; - LOOP_S_L_N(e, 0, HOTENDS) + float runout_distance_mm[NUM_RUNOUT_SENSORS]; + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_READ(runout_distance_mm[e]); - uint8_t runout_mode[HOTENDS]; - LOOP_S_L_N(e, 0, HOTENDS) + uint8_t runout_mode[NUM_RUNOUT_SENSORS]; + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) EEPROM_READ(runout_mode[e]); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) if (!validating) runout.mode[e] = runout_mode[e]; runout.reset(); #endif @@ -2798,11 +2798,11 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); - LOOP_S_L_N(e, 0, HOTENDS) + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; runout.reset(); From 26af3e70bc2e21aa0b54e717a25753b359071b46 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sun, 13 Mar 2022 19:51:12 -0400 Subject: [PATCH 121/203] Remove obsolete state from tests --- buildroot/tests/BIGTREE_GTR_V1_0 | 2 +- buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive | 1 - buildroot/tests/mega2560 | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/buildroot/tests/BIGTREE_GTR_V1_0 b/buildroot/tests/BIGTREE_GTR_V1_0 index 0a80a6b78c..19ed4b6964 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0 +++ b/buildroot/tests/BIGTREE_GTR_V1_0 @@ -13,7 +13,7 @@ opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ NUM_RUNOUT_SENSORS 8 FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 \ - FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 FIL_RUNOUT4_STATE HIGH FIL_RUNOUT8_STATE HIGH \ + FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ FILAMENT_RUNOUT_SCRIPT '"M600 T%c"' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH NEOPIXEL_LED Z_SAFE_HOMING NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE \ FILAMENT_RUNOUT_SENSOR FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP FILAMENT_CHANGE_RESUME_ON_INSERT PAUSE_REHEAT_FAST_RESUME diff --git a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive index 34bf77be27..48fbc10c8c 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive +++ b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive @@ -16,7 +16,6 @@ opt_enable SDSUPPORT USB_FLASH_DRIVE_SUPPORT USE_OTG_USB_HOST \ opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ - FIL_RUNOUT4_STATE HIGH FIL_RUNOUT8_STATE HIGH opt_enable FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP exec_test $1 $2 "GTT GTR | OTG USB Flash Drive | 8 Extruders | Auto-Fan | Mixed TMC Drivers | Runout Sensors (distinct)" "$3" diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 5ae9a2dbcf..f71ba0999e 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -53,7 +53,6 @@ restore_configs opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO NUM_SERVOS 1 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \ NUM_RUNOUT_SENSORS 5 FIL_RUNOUT2_PIN 44 FIL_RUNOUT3_PIN 45 FIL_RUNOUT4_PIN 46 FIL_RUNOUT5_PIN 47 \ - FIL_RUNOUT3_STATE HIGH opt_enable VIKI2 BOOT_MARLIN_LOGO_ANIMATED SDSUPPORT AUTO_REPORT_SD_STATUS \ Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE \ EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL AUTO_REPORT_POSITION \ From acade2890a563daea1a00629deed6c3d0ba6a420 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 14 Mar 2022 00:28:47 +0000 Subject: [PATCH 122/203] [cron] Bump distribution date (2022-03-14) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 7866555842..c3c8a7eeb9 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-13" +//#define STRING_DISTRIBUTION_DATE "2022-03-14" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 0d44b6632a..782bd47eb2 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-13" + #define STRING_DISTRIBUTION_DATE "2022-03-14" #endif /** From fc77afd93e331f4e82ade35437ed5ffb2987df8a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Mar 2022 19:57:01 -0500 Subject: [PATCH 123/203] misc. cleanup --- Marlin/Configuration.h | 21 +- Marlin/src/core/utility.cpp | 4 +- Marlin/src/feature/mmu/mmu2.cpp | 2 +- Marlin/src/feature/pause.cpp | 25 +- Marlin/src/feature/runout.cpp | 10 +- Marlin/src/feature/runout.h | 247 ++++++++---------- Marlin/src/gcode/feature/pause/M600.cpp | 2 +- Marlin/src/gcode/feature/runout/M591.cpp | 52 ++-- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/inc/Conditionals_LCD.h | 20 +- Marlin/src/inc/Conditionals_adv.h | 5 +- Marlin/src/inc/SanityCheck.h | 74 +++++- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 2 +- .../generic/endstop_state_screen.cpp | 12 +- Marlin/src/lcd/extui/ui_api.h | 1 - Marlin/src/module/endstops.cpp | 25 +- Marlin/src/module/settings.cpp | 84 +++--- buildroot/tests/BIGTREE_GTR_V1_0 | 6 +- .../tests/BIGTREE_GTR_V1_0_usb_flash_drive | 1 + buildroot/tests/DUE | 2 +- buildroot/tests/mega2560 | 7 +- buildroot/tests/rambo | 2 +- 22 files changed, 297 insertions(+), 309 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 865a975b2e..af31343880 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1466,13 +1466,12 @@ */ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) - #define FIL_RUNOUT_ENABLED_DEFAULT { true } // Default state for sensors E0, E1[, E2, E3] // Enable the sensor on startup. Override with M591 followed by M500. - - #define FILAMENT_RUNOUT_DEFAULT_MODE {1} // Array set that will take the place of FIL_RUNOUT_STATE and FIL_RUNOUT_ENABLED_DEFAULT as this code matures - #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. - //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. - //#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder. - // This is automatically enabled for MIXING_EXTRUDERs. + #define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591 followed by M500. + #define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor + #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. + //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. + //#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder. + // This is automatically enabled for MIXING_EXTRUDERs. // Override individually if the runout sensors vary //#define FIL_RUNOUT1_PULLUP @@ -1507,12 +1506,12 @@ // After a runout is detected, continue printing this length of filament // before executing the runout script. Useful for a sensor at the end of // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - #define FILAMENT_RUNOUT_DISTANCE_MM {15} + #define FIL_RUNOUT_DISTANCE_MM { 15 } - #ifdef FILAMENT_RUNOUT_DISTANCE_MM + #ifdef FIL_RUNOUT_DISTANCE_MM // Enable this option to use an encoder disc that toggles the runout pin - // as the filament moves. (Be sure to set FILAMENT_RUNOUT_DISTANCE_MM - // large enough to avoid false positives.) + // as the filament moves. (Be sure to make FIL_RUNOUT_DISTANCE_MM long + // enough to avoid false positives.) //#define FILAMENT_MOTION_SENSOR #endif #endif diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 59e59d4cb7..e3dab5aded 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -94,9 +94,9 @@ void safe_delay(millis_t ms) { SERIAL_ECHOPGM(" (Aligned With"); if (probe.offset_xy.y > 0) - SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back"))); + SERIAL_ECHOPGM(TERN(IS_SCARA, "-Distal", "-Back")); else if (probe.offset_xy.y < 0) - SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front"))); + SERIAL_ECHOPGM(TERN(IS_SCARA, "-Proximal", "-Front")); else if (probe.offset_xy.x != 0) SERIAL_ECHOPGM("-Center"); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 2bb69fa9c6..911464a5e2 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -140,7 +140,7 @@ uint8_t MMU2::get_current_tool() { } #if EITHER(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR) - #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != (runout.mode[0]==2 ? HIGH, LOW)) + #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != runout.out_state()) #endif void MMU2::mmu_loop() { diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 7333613c83..34ebcbc7f0 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -208,31 +208,22 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load while (wait_for_user) { impatient_beep(max_beep_count); #if BOTH(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR) - #if ENABLED(MULTI_FILAMENT_SENSOR) - #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; + #if MULTI_FILAMENT_SENSOR LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) { pin_t pin; - uint8_t state; switch (i) { default: continue; + #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) + #undef _CASE_RUNOUT } - if(runout.mode[i-1]==1) - state = HIGH; - else - state = LOW; - if(runout.mode[i-1]!=0 && runout.mode[i-1]!=7 && extDigitalRead(pin) != state) + const uint8_t rm = runout.mode[i - 1]; + if (rm != 0 && rm != 7 && extDigitalRead(pin) != runout.out_state(i - 1)) wait_for_user = false; } - #undef _CASE_RUNOUT - #else { - uint8_t state; - if(runout.mode[active_extruder]==1) - state = HIGH; - else - state = LOW; - if (READ(FIL_RUNOUT_PIN) != state) wait_for_user = false; - } + #else + if (READ(FIL_RUNOUT_PIN) != runout.out_state(active_extruder)) + wait_for_user = false; #endif #endif idle_no_sleep(); diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 332890c0ef..96238c0f80 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -32,9 +32,9 @@ FilamentMonitor runout; -bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS] = {true}, - FilamentMonitorBase::filament_ran_out; // = false -uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DEFAULT_MODE; // Initialized by settings.load +bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS], // Initialized by settings.load + FilamentMonitorBase::filament_ran_out; // = false +uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif @@ -45,12 +45,10 @@ uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DEFAULT_ #include "../core/debug_out.h" #endif - -float RunoutResponseDelayed::runout_distance_mm[NUM_RUNOUT_SENSORS] = FILAMENT_RUNOUT_DISTANCE_MM; +float RunoutResponseDelayed::runout_distance_mm[NUM_RUNOUT_SENSORS]; // Initialized by settings.load volatile float RunoutResponseDelayed::runout_mm_countdown[NUM_RUNOUT_SENSORS]; uint8_t FilamentSensorCore::motion_detected; - // // Filament Runout event handler // diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 7867809232..a898cb33de 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -64,7 +64,9 @@ extern FilamentMonitor runout; class FilamentMonitorBase { public: static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out; - static uint8_t mode[NUM_RUNOUT_SENSORS]; + static uint8_t mode[NUM_RUNOUT_SENSORS]; // 0:NONE 1:Switch NC 2:Switch NO 7:Motion Sensor + + static uint8_t out_state(const uint8_t e=0) { return mode[e] == 2 ? HIGH : LOW; } #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -94,12 +96,9 @@ class TFilamentMonitor : public FilamentMonitorBase { // Call this method when filament is present, // so the response can reset its counter. - static void filament_present(const uint8_t extruder) { - response.filament_present(extruder); - } - - static float& runout_distance(uint8_t extruder=0) { return response.runout_distance_mm[extruder]; } - static void set_runout_distance(const_float_t mm, uint8_t extruder=0) { response.runout_distance_mm[extruder] = mm; } + static void filament_present(const uint8_t e) { response.filament_present(e); } + static float& runout_distance(const uint8_t e=0) { return response.runout_distance_mm[e]; } + static void set_runout_distance(const_float_t mm, const uint8_t e=0) { response.runout_distance_mm[e] = mm; } // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. @@ -210,151 +209,125 @@ class FilamentSensorBase { // Return a bitmask of runout flag states (1 bits always indicates runout) static uint8_t poll_runout_states() { - return poll_runout_pins() ^ uint8_t(0 - #if NUM_RUNOUT_SENSORS >= 1 - | ((runout.mode[0]==2) ? 0 : _BV(1 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 2 - | ((runout.mode[1]==2) ? 0 : _BV(2 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 3 - | ((runout.mode[2]==2) ? 0 : _BV(3 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 4 - | ((runout.mode[3]==2) ? 0 : _BV(4 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 5 - | ((runout.mode[4]==2) ? 0 : _BV(5 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 6 - | ((runout.mode[5]==2) ? 0 : _BV(6 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 7 - | ((runout.mode[6]==2) ? 0 : _BV(7 - 1)) - #endif - #if NUM_RUNOUT_SENSORS >= 8 - | ((runout.mode[7]==2) ? 0 : _BV(8 - 1)) - #endif - ); + #define _OR_INVERT(N) | (runout.out_state(N) ? 0 : _BV(N)) + return poll_runout_pins() ^ uint8_t(0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_INVERT)); + #undef _OR_INVERT } }; - class FilamentSensorCore : public FilamentSensorBase { - private: - static uint8_t motion_detected; +class FilamentSensorCore : public FilamentSensorBase { + private: + static uint8_t motion_detected; - static bool poll_runout_state(const uint8_t extruder) { - const uint8_t runout_states = poll_runout_states(); - #if MULTI_FILAMENT_SENSOR - if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) - && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) - ) return TEST(runout_states, extruder); // A specific extruder ran out - #else - UNUSED(extruder); - #endif - return !!runout_states; // Any extruder ran out - } + static bool poll_runout_state(const uint8_t extruder) { + const uint8_t runout_states = poll_runout_states(); + #if MULTI_FILAMENT_SENSOR + if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) + && !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled) + ) return TEST(runout_states, extruder); // A specific extruder ran out + #else + UNUSED(extruder); + #endif + return !!runout_states; // Any extruder ran out + } - static void poll_motion_sensor() { - static uint8_t old_state; - const uint8_t new_state = poll_runout_pins(), - change = old_state ^ new_state; - old_state = new_state; + static void poll_motion_sensor() { + static uint8_t old_state; + const uint8_t new_state = poll_runout_pins(), + change = old_state ^ new_state; + old_state = new_state; - #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) - if (change) { - SERIAL_ECHOPGM("Motion detected:"); - LOOP_L_N(e, NUM_RUNOUT_SENSORS) - if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e); - SERIAL_EOL(); - } - #endif - - motion_detected |= change; - } - - public: - static void block_completed(const block_t * const b) { - if (runout.mode[active_extruder]!=7) return; - // If the sensor wheel has moved since the last call to - // this method reset the runout counter for the extruder. - if (TEST(motion_detected, b->extruder)) - filament_present(b->extruder); - - // Clear motion triggers for next block - motion_detected = 0; - } - - static void run() { - if(runout.mode[active_extruder]==7) - { - poll_motion_sensor(); + #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) + if (change) { + SERIAL_ECHOPGM("Motion detected:"); + LOOP_L_N(e, NUM_RUNOUT_SENSORS) + if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e); + SERIAL_EOL(); } - else if(runout.mode[active_extruder]!=0) { - LOOP_L_N(s, NUM_RUNOUT_SENSORS) { - const bool out = poll_runout_state(s); - if (!out) filament_present(s); - #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) - static uint8_t was_out; // = 0 - if (out != TEST(was_out, s)) { - TBI(was_out, s); - SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); - } - #endif - } + #endif + + motion_detected |= change; + } + + public: + static void block_completed(const block_t * const b) { + if (runout.mode[active_extruder] != 7) return; + + // If the sensor wheel has moved since the last call to + // this method reset the runout counter for the extruder. + if (TEST(motion_detected, b->extruder)) + filament_present(b->extruder); + + // Clear motion triggers for next block + motion_detected = 0; + } + + static void run() { + if (runout.mode[active_extruder] == 7) { + poll_motion_sensor(); + } + else if (runout.mode[active_extruder] != 0) { + LOOP_L_N(s, NUM_RUNOUT_SENSORS) { + const bool out = poll_runout_state(s); + if (!out) filament_present(s); + #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) + static uint8_t was_out; // = 0 + if (out != TEST(was_out, s)) { + TBI(was_out, s); + SERIAL_ECHOLNF(F("Filament Sensor "), AS_DIGIT(s), out ? F(" OUT") : F(" IN")); + } + #endif } } - }; - - + } +}; /********************************* RESPONSE TYPE *********************************/ - // RunoutResponseDelayed triggers a runout event only if the length - // of filament specified by FILAMENT_RUNOUT_DISTANCE_MM has been fed - // during a runout condition. - class RunoutResponseDelayed { - private: - static volatile float runout_mm_countdown[NUM_RUNOUT_SENSORS]; +// RunoutResponseDelayed triggers a runout event only if the length +// of filament specified by FIL_RUNOUT_DISTANCE_MM has been fed +// during a runout condition. +class RunoutResponseDelayed { + private: + static volatile float runout_mm_countdown[NUM_RUNOUT_SENSORS]; - public: - static float runout_distance_mm[NUM_RUNOUT_SENSORS]; + public: + static float runout_distance_mm[NUM_RUNOUT_SENSORS]; - static void reset() { - LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); - } + static void reset() { + LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); + } - static void run() { - #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) - static millis_t t = 0; - const millis_t ms = millis(); - if (ELAPSED(ms, t)) { - t = millis() + 1000UL; - LOOP_L_N(i, NUM_RUNOUT_SENSORS) - SERIAL_ECHOF(i ? F(", ") : F("Remaining mm: "), runout_mm_countdown[i]); - SERIAL_EOL(); - } - #endif - } - - static uint8_t has_run_out() { - uint8_t runout_flags = 0; - LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_mm_countdown[i] < 0) SBI(runout_flags, i); - return runout_flags; - } - - static void filament_present(const uint8_t extruder) { - runout_mm_countdown[extruder] = runout_distance_mm[extruder]; - } - - static void block_completed(const block_t * const b) { - if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state - // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. - const uint8_t e = b->extruder; - const int32_t steps = b->steps.e; - runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.mm_per_step[E_AXIS_N(e)]; + static void run() { + #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) + static millis_t t = 0; + const millis_t ms = millis(); + if (ELAPSED(ms, t)) { + t = millis() + 1000UL; + LOOP_L_N(i, NUM_RUNOUT_SENSORS) + SERIAL_ECHOF(i ? F(", ") : F("Remaining mm: "), runout_mm_countdown[i]); + SERIAL_EOL(); } - } - }; + #endif + } + static uint8_t has_run_out() { + uint8_t runout_flags = 0; + LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_mm_countdown[i] < 0) SBI(runout_flags, i); + return runout_flags; + } + + static void filament_present(const uint8_t extruder) { + runout_mm_countdown[extruder] = runout_distance_mm[extruder]; + } + + static void block_completed(const block_t * const b) { + if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state + // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. + const uint8_t e = b->extruder; + const int32_t steps = b->steps.e; + runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.mm_per_step[E_AXIS_N(e)]; + } + } +}; diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 0b5a4d8c03..e97cc25e99 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -88,7 +88,7 @@ void GcodeSuite::M600() { // In this case, for duplicating modes set DXC_ext to the extruder that ran out. #if MULTI_FILAMENT_SENSOR if (idex_is_duplicating()) - DXC_ext = (READ(FIL_RUNOUT2_PIN) == (runout.mode[1]==2 ? HIGH, LOW) ? 1 : 0; + DXC_ext = (READ(FIL_RUNOUT2_PIN) == runout.out_state(1)) ? 1 : 0; #else DXC_ext = active_extruder; #endif diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index e4a7e5b59d..0751de879a 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -27,13 +27,8 @@ #include "../../gcode.h" #include "../../../feature/runout.h" - -void GcodeSuite::M412() { - SERIAL_ECHOLNPGM_P("M412 is Deprecated, please us M591."); - M591(); -} /** - 591: Configure filament runout detection + * M591: Configure filament runout detection * * Parameters * R : Reset the runout sensor @@ -41,41 +36,33 @@ void GcodeSuite::M412() { * H : Enable/disable host handling of filament runout * L : Extra distance to continue after runout is triggered or motion interval * D : Alias for L - * P : Mode : - 0 = none - 1 = simple sensor (high signal when filament present) - 2 = simple sensor (low signal when filament present) - 7 = motion encoder sensor + * P : Mode 0 = NONE + * 1 = Switch NO (HIGH = filament present) + * 2 = Switch NC (LOW = filament present) + * 7 = Encoder / Motion Sensor */ void GcodeSuite::M591() { - #if HOTENDS > 1 - if(parser.seen("E")) - const uint8_t tool = parser.value_ushort(); - else - tool = active_extruder; - #else - const uint8_t tool = 0; - #endif - - if (parser.seen("RSDP" - TERN_(HOST_ACTION_COMMANDS, "H") - )) { + if (parser.seen("RSDP" TERN_(HOST_ACTION_COMMANDS, "H"))) { #if ENABLED(HOST_ACTION_COMMANDS) if (parser.seen('H')) runout.host_handling = parser.value_bool(); #endif const bool seenR = parser.seen_test('R'), seenS = parser.seen('S'); if (seenR || seenS) runout.reset(); + #if NUM_RUNOUT_SENSORS > 1 + const uint8_t tool = parser.ushortval('E', active_extruder); + #else + constexpr uint8_t tool = 0; + #endif if (seenS) runout.enabled[tool] = parser.value_bool(); if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('P')) { - uint8_t tmp_mode = parser.value_int(); - if(tmp_mode < 3 || tmp_mode==7) { + const uint8_t tmp_mode = parser.value_int(); + if (tmp_mode < 3 || tmp_mode == 7) { runout.mode[tool] = tmp_mode; runout.reset(); } } - } else { SERIAL_ECHO_START(); @@ -93,15 +80,16 @@ void GcodeSuite::M591() { void GcodeSuite::M591_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_FILAMENT_RUNOUT_SENSOR)); - LOOP_S_L_N(e, 1, HOTENDS) - SERIAL_ECHOPGM( - " M591 E", e - , " S", runout.enabled[e] + LOOP_S_L_N(e, 1, NUM_RUNOUT_SENSORS) + SERIAL_ECHOLNPGM( + " M591" + #if NUM_RUNOUT_SENSORS > 1 + " E", e, + #endif + " S", runout.enabled[e] , " D", LINEAR_UNIT(runout.runout_distance(e)) , " P", runout.mode[e] - , " ; " ); - } #endif // HAS_FILAMENT_SENSOR diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 46f4a5ddce..1e15756f24 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -978,7 +978,7 @@ private: #endif #if HAS_FILAMENT_SENSOR - static void M412(); + static void M412() { M591(); } static void M591(); static void M591_report(const bool forReplay=true); #endif diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e2b643ae73..fb52d1d2f2 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -832,10 +832,14 @@ /** * Fill in undefined Filament Sensor options */ -#ifndef NUM_RUNOUT_SENSORS - #define NUM_RUNOUT_SENSORS E_STEPPERS -#endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) + #define HAS_FILAMENT_SENSOR 1 + #ifndef NUM_RUNOUT_SENSORS + #define NUM_RUNOUT_SENSORS E_STEPPERS + #endif + #if ENABLED(MIXING_EXTRUDER) + #define WATCH_ALL_RUNOUT_SENSORS + #endif #if NUM_RUNOUT_SENSORS >= 1 #ifndef FIL_RUNOUT1_PULLUP #define FIL_RUNOUT1_PULLUP FIL_RUNOUT_PULLUP @@ -845,6 +849,7 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 2 + #define MULTI_FILAMENT_SENSOR 1 #ifndef FIL_RUNOUT2_PULLUP #define FIL_RUNOUT2_PULLUP FIL_RUNOUT_PULLUP #endif @@ -885,7 +890,6 @@ #endif #endif #if NUM_RUNOUT_SENSORS >= 7 - #ifndef FIL_RUNOUT7_PULLUP #define FIL_RUNOUT7_PULLUP FIL_RUNOUT_PULLUP #endif @@ -901,14 +905,6 @@ #define FIL_RUNOUT8_PULLDOWN FIL_RUNOUT_PULLDOWN #endif #endif - - #define HAS_FILAMENT_SENSOR 1 - #if NUM_RUNOUT_SENSORS > 1 - #define MULTI_FILAMENT_SENSOR 1 - #endif - #if ENABLED(MIXING_EXTRUDER) - #define WATCH_ALL_RUNOUT_SENSORS - #endif #endif // FILAMENT_RUNOUT_SENSOR // Homing to Min or Max diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index d0004658ce..2219f311e0 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -95,11 +95,12 @@ #undef PID_EXTRUSION_SCALING #undef LIN_ADVANCE #undef FILAMENT_RUNOUT_SENSOR + #undef FIL_RUNOUT_ENABLED + #undef FIL_RUNOUT_MODE + #undef FIL_RUNOUT_DISTANCE_MM #undef ADVANCED_PAUSE_FEATURE - #undef FILAMENT_RUNOUT_DISTANCE_MM #undef FILAMENT_LOAD_UNLOAD_GCODES #undef DISABLE_INACTIVE_EXTRUDER - #undef FILAMENT_LOAD_UNLOAD_GCODES #undef EXTRUDER_RUNOUT_PREVENT #undef PREVENT_COLD_EXTRUSION #undef PREVENT_LENGTHY_EXTRUDE diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 9f7b9fb056..f281038bae 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -561,9 +561,9 @@ #error "SHORT_MANUAL_Z_MOVE is now FINE_MANUAL_MOVE, applying to Z on most printers." #elif defined(FIL_RUNOUT_INVERTING) #if FIL_RUNOUT_INVERTING - #error "FIL_RUNOUT_INVERTING true is now FILAMENT_RUNOUT_DEFAULT_MODE {HIGH}." + #error "FIL_RUNOUT_INVERTING true is now FIL_RUNOUT_MODE {HIGH}." #else - #error "FIL_RUNOUT_INVERTING false is now FILAMENT_RUNOUT_DEFAULT_MODE {LOW}." + #error "FIL_RUNOUT_INVERTING false is now FIL_RUNOUT_MODE {LOW}." #endif #elif defined(ASSISTED_TRAMMING_MENU_ITEM) #error "ASSISTED_TRAMMING_MENU_ITEM is deprecated and should be removed." @@ -1002,16 +1002,68 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with FILAMENT_RUNOUT_SENSOR."); - #elif ANY(FIL_RUNOUT_STATE, FIL_RUNOUT1_STATE, FIL_RUNOUT2_STATE, FIL_RUNOUT3_STATE, FIL_RUNOUT4_STATE, FIL_RUNOUT5_STATE, FIL_RUNOUT6_STATE, FIL_RUNOUT7_STATE, FIL_RUNOUT8_STATE) - #error "FIL_RUNOUT#_STATE is Now set with FILAMENT_RUNOUT_DEFAULT_MODE" + #elif defined(FIL_RUNOUT_ENABLED_DEFAULT) + #error "FIL_RUNOUT_ENABLED_DEFAULT is now set with the FILAMENT_RUNOUT_ENABLED array." + #elif defined(FILAMENT_RUNOUT_DISTANCE_MM) + #error "FILAMENT_RUNOUT_DISTANCE_MM is now set with the FIL_RUNOUT_DISTANCE_MM array." + #elif defined(FIL_RUNOUT_STATE) || defined(FIL_RUNOUT2_STATE) || defined(FIL_RUNOUT3_STATE) || defined(FIL_RUNOUT4_STATE) || defined(FIL_RUNOUT5_STATE) || defined(FIL_RUNOUT6_STATE) || defined(FIL_RUNOUT7_STATE) || defined(FIL_RUNOUT8_STATE) + #ifdef FIL_RUNOUT_STATE + #if FIL_RUNOUT_STATE + #error "FIL_RUNOUT_STATE HIGH is now set with FIL_RUNOUT_MODE { 2 ... }." + #else + #error "FIL_RUNOUT_STATE LOW is now set with FIL_RUNOUT_MODE { 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT2_STATE + #if FIL_RUNOUT2_STATE + #error "FIL_RUNOUT2_STATE HIGH is now set with FIL_RUNOUT_MODE { n, 2 ... }." + #else + #error "FIL_RUNOUT2_STATE LOW is now set with FIL_RUNOUT_MODE { n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT3_STATE + #if FIL_RUNOUT3_STATE + #error "FIL_RUNOUT3_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, 2 ... }." + #else + #error "FIL_RUNOUT3_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT4_STATE + #if FIL_RUNOUT4_STATE + #error "FIL_RUNOUT4_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT4_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT5_STATE + #if FIL_RUNOUT5_STATE + #error "FIL_RUNOUT5_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT5_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT6_STATE + #if FIL_RUNOUT6_STATE + #error "FIL_RUNOUT6_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT6_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT7_STATE + #if FIL_RUNOUT7_STATE + #error "FIL_RUNOUT7_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT7_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, 1 ... }." + #endif + #endif + #ifdef FIL_RUNOUT8_STATE + #if FIL_RUNOUT8_STATE + #error "FIL_RUNOUT8_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, n, 2 ... }." + #else + #error "FIL_RUNOUT8_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, n, 1 ... }." + #endif + #endif #endif - - constexpr uint8_t frdm[] = FILAMENT_RUNOUT_DEFAULT_MODE; - static_assert(COUNT(frdm) == NUM_RUNOUT_SENSORS, "FILAMENT_RUNOUT_DEFAULT_MODE must have NUM_RUNOUT_SENSORS values."); - constexpr bool fred[] = FIL_RUNOUT_ENABLED_DEFAULT; - static_assert(COUNT(fred) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_ENABLED_DEFAULT must have NUM_RUNOUT_SENSORS values."); - constexpr float frd[] = FILAMENT_RUNOUT_DISTANCE_MM; - static_assert(COUNT(frd) == NUM_RUNOUT_SENSORS, "FILAMENT_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); #endif /** diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index ab42b2f1d8..2e4ab6a79c 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -100,7 +100,7 @@ void ESDiagClass::Update() { ES_REPORT(Z_MIN); #endif #if HAS_FILAMENT_SENSOR - draw_es_state(READ(FIL_RUNOUT1_PIN) != (runout.mode[0]==2 ? HIGH, LOW); + draw_es_state(READ(FIL_RUNOUT1_PIN) != runout.out_state()); #endif DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp index c7042e760e..fdc5764db9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp @@ -51,13 +51,7 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { #define PIN_ENABLED(X,Y,LABEL,PIN,INV) cmd.enabled(1).colors(READ(PIN##_PIN) != INV ? action_btn : normal_btn).PIN_BTN(X,Y,PIN,LABEL); #define PIN_DISABLED(X,Y,LABEL,PIN) cmd.enabled(0).PIN_BTN(X,Y,PIN,LABEL); - cmd.font( - #if ENABLED(TOUCH_UI_PORTRAIT) - font_large - #else - font_medium - #endif - ) + cmd.font(TERN(TOUCH_UI_PORTRAIT, font_large, font_medium)) .text(BTN_POS(1,1), BTN_SIZE(6,1), GET_TEXT_F(MSG_LCD_ENDSTOPS)) .font(font_tiny); #if HAS_X_MAX @@ -91,12 +85,12 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { PIN_DISABLED(5, 3, PSTR(STR_Z_MIN), Z_MIN) #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT) - PIN_ENABLED (1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT, FIL_RUNOUT1_STATE) + PIN_ENABLED (1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT, !runout.out_state()) #else PIN_DISABLED(1, 4, GET_TEXT_F(MSG_RUNOUT_1), FIL_RUNOUT) #endif #if BOTH(HAS_MULTI_EXTRUDER, FILAMENT_RUNOUT_SENSOR) && PIN_EXISTS(FIL_RUNOUT2) - PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, FIL_RUNOUT2_STATE) + PIN_ENABLED (3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2, !runout.out_state(1)) #else PIN_DISABLED(3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2) #endif diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 3d87d0208e..3ccf6dea70 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -300,7 +300,6 @@ namespace ExtUI { void setFilamentRunoutState(const bool); float getFilamentRunoutDistance_mm(); void setFilamentRunoutDistance_mm(const_float_t); - #endif #if ENABLED(CASE_LIGHT_ENABLE) diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 4fae1d4ad2..f41a6c9f87 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -575,34 +575,29 @@ void _O2 Endstops::report_states() { print_es_state(PROBE_TRIGGERED(), F(STR_Z_PROBE)); #endif #if HAS_FILAMENT_SENSOR - #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) { pin_t pin; - uint8_t state; switch (i) { default: continue; + #define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break; REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) + #undef _CASE_RUNOUT } - if(runout.mode[i-1]==1) - state = HIGH; - else - state = LOW; + const uint8_t rm = runout.mode[i - 1], + state = runout.out_state(i - 1); SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); SERIAL_ECHOPGM(": "); - if(runout.mode[i-1]==0) - SERIAL_ECHOLNF(F("DISABLED")); - else if(runout.mode[i-1]==7) { - SERIAL_ECHOF(F("MOTION : ")); - print_es_state(extDigitalRead(pin) != state); + if (rm == 0) + SERIAL_ECHOLNPGM("DISABLED"); + else if (rm == 7) { + SERIAL_ECHOPGM("MOTION : "); + print_es_state(extDigitalRead(pin) == state); } - else if(extDigitalRead(pin) != state) - SERIAL_ECHOLNF(F("PRESENT")); else - SERIAL_ECHOLNF(F("MISSING")); + SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == state ? PSTR("MISSING") : PSTR("PRESENT")); } - #undef _CASE_RUNOUT #endif TERN_(BLTOUCH, bltouch._reset_SW_mode()); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 11084e325a..7c10698ccc 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -112,9 +112,9 @@ #if HAS_FILAMENT_SENSOR #include "../feature/runout.h" - #ifndef FIL_RUNOUT_ENABLED_DEFAULT - #define FIL_RUNOUT_ENABLED_DEFAULT true - #endif + #define NRS NUM_RUNOUT_SENSORS +#else + #define NRS 1 #endif #if ENABLED(EXTRA_LIN_ADVANCE_K) @@ -235,9 +235,9 @@ typedef struct SettingsDataStruct { // // FILAMENT_RUNOUT_SENSOR // - bool runout_sensor_enabled[NUM_RUNOUT_SENSORS]; // M591 S - float runout_distance_mm[NUM_RUNOUT_SENSORS]; // M591 D - uint8_t runout_mode[NUM_RUNOUT_SENSORS]; // M591 P + bool runout_enabled[NRS]; // M591 S + float runout_distance_mm[NRS]; // M591 D + uint8_t runout_mode[NRS]; // M591 P // // ENABLE_LEVELING_FADE_HEIGHT @@ -793,20 +793,15 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { + _FIELD_TEST(runout_enabled); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE(runout.enabled[e]); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE(runout.runout_distance(e)); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE(runout.mode[e]); + LOOP_L_N(e, NRS) EEPROM_WRITE(runout.enabled[e]); + LOOP_L_N(e, NRS) EEPROM_WRITE(runout.runout_distance(e)); + LOOP_L_N(e, NRS) EEPROM_WRITE(runout.mode[e]); #else - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE((int8_t)-1)); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE((float)-0.0f)); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_WRITE((uint8_t)0)); + EEPROM_WRITE((int8_t)-1); + EEPROM_WRITE((float)-0.0f); + EEPROM_WRITE((uint8_t)0); #endif } @@ -1713,27 +1708,28 @@ void MarlinSettings::postprocess() { // Filament Runout Sensor // { - int8_t runout_sensor_enabled[NUM_RUNOUT_SENSORS]; - _FIELD_TEST(runout_sensor_enabled); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_READ(runout_sensor_enabled); - float runout_distance_mm[NUM_RUNOUT_SENSORS]; - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_READ(runout_distance_mm[e]); - uint8_t runout_mode[NUM_RUNOUT_SENSORS]; - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - EEPROM_READ(runout_mode[e]); + _FIELD_TEST(runout_enabled); + + int8_t runout_enabled[NRS]; + float runout_distance_mm[NRS]; + uint8_t runout_mode[NRS]; + + LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_enabled[e]); + LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_distance_mm[e]); + LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_mode[e]); #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - runout.enabled[e] = runout_sensor_enabled[e] < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled[e]; - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - if (!validating) runout.set_runout_distance(runout_distance_mm[e], e); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - if (!validating) runout.mode[e] = runout_mode[e]; - runout.reset(); + if (!validating) { + LOOP_S_L_N(e, 0, NRS) { + if (runout_enabled[e] >= 0) { + runout.enabled[e] = (runout_enabled[e] > 0); + runout.set_runout_distance(runout_distance_mm[e], e); + runout.mode[e] = runout_mode[e]; + } + } + runout.reset(); + } #endif - } // @@ -2798,13 +2794,15 @@ void MarlinSettings::reset() { // #if HAS_FILAMENT_SENSOR - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - runout.enabled[e] = FIL_RUNOUT_ENABLED_DEFAULT; - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM, e); - LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) - runout.mode[e] = FILAMENT_RUNOUT_DEFAULT_MODE; - + constexpr bool fred[] = FIL_RUNOUT_ENABLED; + constexpr uint8_t frm[] = FIL_RUNOUT_MODE; + constexpr float frd[] = FIL_RUNOUT_DISTANCE_MM; + static_assert(COUNT(fred) == NRS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(frm) == NRS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(frd) == NRS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); + COPY(runout.enabled, fred); + COPY(runout.mode, frm); + LOOP_L_N(e, NRS) runout.set_runout_distance(frd[e], e); runout.reset(); #endif diff --git a/buildroot/tests/BIGTREE_GTR_V1_0 b/buildroot/tests/BIGTREE_GTR_V1_0 index 19ed4b6964..a64f30b4f9 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0 +++ b/buildroot/tests/BIGTREE_GTR_V1_0 @@ -12,8 +12,10 @@ opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ # Not necessary to enable auto-fan for all extruders to hit problematic code paths opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ - NUM_RUNOUT_SENSORS 8 FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 \ - FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ + FIL_RUNOUT_ENABLED '{ true, true, true, true, true, true, true, true }' \ + FIL_RUNOUT_MODE '{ 1, 1, 1, 1, 1, 1, 1, 1 }' \ + FIL_RUNOUT_DISTANCE_MM '{ 0, 1, 5, 10, 5, 5, 5, 5 }' \ + FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ FILAMENT_RUNOUT_SCRIPT '"M600 T%c"' opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH NEOPIXEL_LED Z_SAFE_HOMING NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE \ FILAMENT_RUNOUT_SENSOR FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP FILAMENT_CHANGE_RESUME_ON_INSERT PAUSE_REHEAT_FAST_RESUME diff --git a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive index 48fbc10c8c..3e819ba85e 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive +++ b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive @@ -16,6 +16,7 @@ opt_enable SDSUPPORT USB_FLASH_DRIVE_SUPPORT USE_OTG_USB_HOST \ opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \ FIL_RUNOUT_PIN 3 FIL_RUNOUT2_PIN 4 FIL_RUNOUT3_PIN 5 FIL_RUNOUT4_PIN 6 FIL_RUNOUT5_PIN 7 FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 \ + FIL_RUNOUT_MODE '{ 2, 2, 2, 1, 2, 2, 2, 1 }' FIL_RUNOUT_DISTANCE_MM '{ 0, 1, 5, 10, 5, 5, 5, 5 }' opt_enable FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP exec_test $1 $2 "GTT GTR | OTG USB Flash Drive | 8 Extruders | Auto-Fan | Mixed TMC Drivers | Runout Sensors (distinct)" "$3" diff --git a/buildroot/tests/DUE b/buildroot/tests/DUE index 9b968cbd8d..7251cd8669 100755 --- a/buildroot/tests/DUE +++ b/buildroot/tests/DUE @@ -19,7 +19,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \ BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN \ NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \ - NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \ + NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR FIL_RUNOUT_DISTANCE_MM \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE CALIBRATION_GCODE \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index f71ba0999e..ad08b7487f 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -53,6 +53,7 @@ restore_configs opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO NUM_SERVOS 1 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \ NUM_RUNOUT_SENSORS 5 FIL_RUNOUT2_PIN 44 FIL_RUNOUT3_PIN 45 FIL_RUNOUT4_PIN 46 FIL_RUNOUT5_PIN 47 \ + FIL_RUNOUT_ENABLED '{ true, true, true, true, true }' FIL_RUNOUT_MODE '{ 1, 2, 7, 0, 1 }' FIL_RUNOUT_DISTANCE_MM '{ 15, 15, 15, 15, 15 }' opt_enable VIKI2 BOOT_MARLIN_LOGO_ANIMATED SDSUPPORT AUTO_REPORT_SD_STATUS \ Z_PROBE_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE AUTO_BED_LEVELING_3POINT DEBUG_LEVELING_FEATURE \ EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL AUTO_REPORT_POSITION \ @@ -66,9 +67,9 @@ exec_test $1 $2 "Multiple runout sensors (x5) | Distinct runout states" "$3" # Mixing Extruder with 5 steppers, Greek # restore_configs -opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO MIXING_STEPPERS 5 LCD_LANGUAGE ru \ - NUM_RUNOUT_SENSORS E_STEPPERS REDUNDANT_PART_COOLING_FAN 1 \ - FIL_RUNOUT2_PIN 16 FIL_RUNOUT3_PIN 17 FIL_RUNOUT4_PIN 4 FIL_RUNOUT5_PIN 5 +opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO MIXING_STEPPERS 5 LCD_LANGUAGE ru REDUNDANT_PART_COOLING_FAN 1 \ + FIL_RUNOUT2_PIN 16 FIL_RUNOUT3_PIN 17 FIL_RUNOUT4_PIN 4 FIL_RUNOUT5_PIN 5 \ + FIL_RUNOUT_ENABLED '{ true, true, true, true, true }' FIL_RUNOUT_MODE '{ 1, 2, 7, 0, 1 }' FIL_RUNOUT_DISTANCE_MM '{ 15, 15, 15, 15, 15 }' opt_enable MIXING_EXTRUDER GRADIENT_MIX GRADIENT_VTOOL CR10_STOCKDISPLAY \ USE_CONTROLLER_FAN CONTROLLER_FAN_EDITABLE CONTROLLER_FAN_IGNORE_Z \ FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index e696dce96e..f5b822f691 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -25,7 +25,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \ PID_PARAMS_PER_HOTEND PID_AUTOTUNE_MENU PID_EDIT_MENU LCD_SHOW_E_TOTAL \ PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 LEVEL_BED_CORNERS LEVEL_CENTER_TOO \ - NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FILAMENT_RUNOUT_DISTANCE_MM \ + NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FIL_RUNOUT_DISTANCE_MM \ ADVANCED_PAUSE_FEATURE FILAMENT_LOAD_UNLOAD_GCODES FILAMENT_UNLOAD_ALL_EXTRUDERS \ PASSWORD_FEATURE PASSWORD_ON_STARTUP PASSWORD_ON_SD_PRINT_MENU PASSWORD_AFTER_SD_PRINT_END PASSWORD_AFTER_SD_PRINT_ABORT \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DISTINCT_E_FACTORS \ From dd88eb56ee41fff10b91aa9174e1b63984e150f2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Mar 2022 20:44:01 -0500 Subject: [PATCH 124/203] Allow user to change --- Marlin/Configuration.h | 1 + buildroot/tests/rambo | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index af31343880..0d387aac63 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1466,6 +1466,7 @@ */ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) + //#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. #define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591 followed by M500. #define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index f5b822f691..ae9d8cb295 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -15,7 +15,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ TEMP_SENSOR_PROBE 1 TEMP_PROBE_PIN 12 \ TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 3 HEATER_CHAMBER_PIN 45 \ GRID_MAX_POINTS_X 16 AUTO_POWER_E_TEMP 80 \ - FANMUX0_PIN 53 + FANMUX0_PIN 53 NUM_RUNOUT_SENSORS 1 opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN USE_WATCHDOG opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \ FIX_MOUNTED_PROBE CODEPENDENT_XY_HOMING PIDTEMPBED PTC_PROBE PTC_BED \ From 07b2480d30ca70b7e8904fc114e8b409a7608da8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 13 Mar 2022 20:45:53 -0500 Subject: [PATCH 125/203] glue for CI test --- Marlin/src/inc/Conditionals_LCD.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index fb52d1d2f2..e6e92068be 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1411,3 +1411,28 @@ #if defined(NEOPIXEL_BKGD_INDEX_FIRST) && !defined(NEOPIXEL_BKGD_INDEX_LAST) #define NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_INDEX_FIRST #endif + +/*** TEMPORARY COMPATIBILITY ***/ + +#if HAS_FILAMENT_SENSOR + #ifndef FIL_RUNOUT_ENABLED + #if FIL_RUNOUT_ENABLED_DEFAULT + #define FIL_RUNOUT_ENABLED ARRAY_N_1(NUM_RUNOUT_SENSORS, true) + #else + #define FIL_RUNOUT_ENABLED ARRAY_N_1(NUM_RUNOUT_SENSORS, false) + #endif + #endif + #ifndef FIL_RUNOUT_MODE + #if FIL_RUNOUT_STATE + #define FIL_RUNOUT_MODE ARRAY_N_1(NUM_RUNOUT_SENSORS, 1) + #else + #define FIL_RUNOUT_MODE ARRAY_N_1(NUM_RUNOUT_SENSORS, 2) + #endif + #endif + #ifndef FIL_RUNOUT_DISTANCE_MM + #define FIL_RUNOUT_DISTANCE_MM ARRAY_N_1(NUM_RUNOUT_SENSORS, 10) + #endif + #undef FIL_RUNOUT_ENABLED_DEFAULT + #undef FIL_RUNOUT_STATE + #undef FILAMENT_RUNOUT_DISTANCE_MM +#endif From 0cedad36d17a65e0090bafe429675cdf6289aa7f Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Mon, 14 Mar 2022 09:29:53 -0400 Subject: [PATCH 126/203] Reorganize config options, remove obsolete option. --- Marlin/Configuration.h | 39 ++++++++++++++++-------------------- Marlin/src/inc/SanityCheck.h | 2 ++ 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0d387aac63..7700108136 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1459,7 +1459,7 @@ * Marlin knows a print job is running when: * 1. Running a print job from media started with M24. * 2. The Print Job Timer has been started with M75. - * 3. The heaters were turned on and PRINTJOB_TIMER_AUTOSTART is enabled. + * 3. The heaters were turned on with a wait command (M109) and PRINTJOB_TIMER_AUTOSTART is enabled. * * RAMPS-based boards use SERVO3_PIN for the first runout sensor. * For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc. @@ -1467,13 +1467,25 @@ //#define FILAMENT_RUNOUT_SENSOR #if ENABLED(FILAMENT_RUNOUT_SENSOR) //#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each. - #define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591 followed by M500. - #define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor - #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. - //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. + #define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591EnnSn followed by M500. + #define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor Override with M591EnPnn //#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder. // This is automatically enabled for MIXING_EXTRUDERs. + // Commands to execute on filament runout. + // With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c") + // NOTE: After 'M591 H1' the host handles filament runout and this script does not apply. + #define FILAMENT_RUNOUT_SCRIPT "M600" + + // In Mode 1 or 2, continue printing this length of filament after a run out occurs before executing the + // runout script. Useful for a sensor at the end of a feed tube or debounce on a flakey sensor. + // In Mode 7, extrusion distance to expect a change of state. + // Override with M591EnLnn + #define FIL_RUNOUT_DISTANCE_MM { 15 } + + #define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins. + //#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins. + // Override individually if the runout sensors vary //#define FIL_RUNOUT1_PULLUP //#define FIL_RUNOUT1_PULLDOWN @@ -1498,23 +1510,6 @@ //#define FIL_RUNOUT8_PULLUP //#define FIL_RUNOUT8_PULLDOWN - - // Commands to execute on filament runout. - // With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c") - // NOTE: After 'M591 H1' the host handles filament runout and this script does not apply. - #define FILAMENT_RUNOUT_SCRIPT "M600" - - // After a runout is detected, continue printing this length of filament - // before executing the runout script. Useful for a sensor at the end of - // a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead. - #define FIL_RUNOUT_DISTANCE_MM { 15 } - - #ifdef FIL_RUNOUT_DISTANCE_MM - // Enable this option to use an encoder disc that toggles the runout pin - // as the filament moves. (Be sure to make FIL_RUNOUT_DISTANCE_MM long - // enough to avoid false positives.) - //#define FILAMENT_MOTION_SENSOR - #endif #endif //=========================================================================== diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f281038bae..12f5770ab0 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1063,6 +1063,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "FIL_RUNOUT8_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, n, 1 ... }." #endif #endif + #elif ENABLED(FILAMENT_MOTION_SENSOR) + #error "FILAMENT_MOTION_SENSOR is now set with FIL_RUNOUT_MODE { 7 ... }." #endif #endif From 378fc12628f49599ed2d12e88981acf8ee683b68 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Tue, 15 Mar 2022 12:24:29 -0400 Subject: [PATCH 127/203] Add runout menu, small fixes --- Marlin/src/feature/runout.h | 4 +- Marlin/src/lcd/language/language_en.h | 5 +++ Marlin/src/lcd/menu/menu_advanced.cpp | 53 +++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index a898cb33de..72faaef449 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -103,7 +103,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. static void block_completed(const block_t * const b) { - if (enabled) { + if (enabled[active_extruder]) { response.block_completed(b); sensor.block_completed(b); } @@ -111,7 +111,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Give the response a chance to update its counter. static void run() { - if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) { + if (enabled[active_extruder] && mode[active_extruder]!=0 && !filament_ran_out && (printingIsActive() || did_pause_print)) { cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); sensor.run(); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 7fe5c22271..1e9a7298ba 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -651,6 +651,11 @@ namespace Language_en { LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Nozzle: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout Sensor"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Runout Dist mm"); + LSTR MSG_RUNOUT_MODE = _UxGT("Runout Mode"); + LSTR MSG_RUNOUT_MODE_HIGH = _UxGT("Sensor High"); + LSTR MSG_RUNOUT_MODE_LOW = _UxGT("Sensor Low"); + LSTR MSG_RUNOUT_MODE_MOTION = _UxGT("Motion Encoder"); + LSTR MSG_RUNOUT_MODE_NONE = _UxGT("No Sensor"); LSTR MSG_RUNOUT_ENABLE = _UxGT("Enable Runout"); LSTR MSG_FANCHECK = _UxGT("Fan Tacho Check"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing Failed"); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 77728201c5..1c4fbc9b97 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -97,6 +97,54 @@ void menu_backlash(); #endif +#if HAS_FILAMENT_SENSOR + + #define RUNOUT_EDIT_ITEMS(F) do{ \ + EDIT_ITEM_N(bool, F, MSG_RUNOUT_MODE_NONE, &runout.enabled[F]); \ + ACTION_ITEM_N(F, MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F);}); \ + ACTION_ITEM_N(F, MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F);}); \ + ACTION_ITEM_N(F, MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F);}); \ + ACTION_ITEM_N(F, MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F);}); \ + editable.decimal = runout.runout_distance(F); \ + EDIT_ITEM_FAST_N(float3, F, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ + []{ runout.set_runout_distance(editable.decimal, F); }, true \ + ); \ + }while(0) + + void set_runout_mode_none(uint8_t e) { runout.mode[e] = 0; } + void set_runout_mode_high(uint8_t e) { runout.mode[e] = 1; } + void set_runout_mode_low(uint8_t e) { runout.mode[e] = 2; } + void set_runout_mode_motion(uint8_t e) { runout.mode[e] = 7; } + + void menu_runout_config() { + START_MENU(); + BACK_ITEM(MSG_CONFIGURATION); + RUNOUT_EDIT_ITEMS(0); + #if NUM_RUNOUT_SENSORS > 1 + RUNOUT_EDIT_ITEMS(1); + #endif + #if NUM_RUNOUT_SENSORS > 2 + RUNOUT_EDIT_ITEMS(2); + #endif + #if NUM_RUNOUT_SENSORS > 3 + RUNOUT_EDIT_ITEMS(3); + #endif + #if NUM_RUNOUT_SENSORS > 4 + RUNOUT_EDIT_ITEMS(4); + #endif + #if NUM_RUNOUT_SENSORS > 5 + RUNOUT_EDIT_ITEMS(5); + #endif + #if NUM_RUNOUT_SENSORS > 6 + RUNOUT_EDIT_ITEMS(6); + #endif + #if NUM_RUNOUT_SENSORS > 7 + RUNOUT_EDIT_ITEMS(7); + #endif + END_MENU(); + } +#endif + #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE) // // Advanced Settings > Filament @@ -151,10 +199,7 @@ void menu_backlash(); #endif #if HAS_FILAMENT_SENSOR - editable.decimal = runout.runout_distance(); - EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, - []{ runout.set_runout_distance(editable.decimal); }, true - ); + SUBMENU(MSG_RUNOUT_MODE, menu_runout_config); #endif END_MENU(); From 489b75ae3ca2c957f22bc4bdde6346c51859e482 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Tue, 15 Mar 2022 12:46:57 -0400 Subject: [PATCH 128/203] Update menu_advanced.cpp --- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 1c4fbc9b97..ac2da4d8a6 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -100,7 +100,7 @@ void menu_backlash(); #if HAS_FILAMENT_SENSOR #define RUNOUT_EDIT_ITEMS(F) do{ \ - EDIT_ITEM_N(bool, F, MSG_RUNOUT_MODE_NONE, &runout.enabled[F]); \ + EDIT_ITEM_N(bool, F, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ ACTION_ITEM_N(F, MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F);}); \ ACTION_ITEM_N(F, MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F);}); \ ACTION_ITEM_N(F, MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F);}); \ From 653c847bfbcf2d816cd67fab3716d64d66a185e3 Mon Sep 17 00:00:00 2001 From: John Robertson Date: Thu, 17 Mar 2022 19:35:33 +0000 Subject: [PATCH 129/203] =?UTF-8?q?=F0=9F=90=9B=20MKS=20TinyBee=20-=202.5V?= =?UTF-8?q?=20ADC=20Vref=20(#23903)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/ESP32/HAL.cpp | 6 +++++- Marlin/src/pins/esp32/pins_MKS_TINYBEE.h | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 4000dcc908..c1a44a3dea 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -229,11 +229,15 @@ void MarlinHAL::adc_init() { } } +#ifndef ADC_REFERENCE_VOLTAGE + #define ADC_REFERENCE_VOLTAGE 3.3 +#endif + void MarlinHAL::adc_start(const pin_t pin) { const adc1_channel_t chan = get_channel(pin); uint32_t mv; esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv); - adc_result = mv * 1023.0 / 3300.0; + adc_result = mv * 1023.0f / float(ADC_REFERENCE_VOLTAGE) / 1000.0f; // Change the attenuation level based on the new reading adc_atten_t atten; diff --git a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h index 122dad2146..68b8ed4ac8 100644 --- a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h +++ b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h @@ -113,6 +113,11 @@ //#define E0_AUTO_FAN_PIN 148 // need to update Configuration_adv.h @section extruder //#define E1_AUTO_FAN_PIN 149 // need to update Configuration_adv.h @section extruder +// +// ADC Reference Voltage +// +#define ADC_REFERENCE_VOLTAGE 2.5 // 2.5V reference VDDA + // // MicroSD card // From 99413ae2f43429e1014efe81ae3d4cac94e37713 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 18 Mar 2022 00:01:51 +0000 Subject: [PATCH 130/203] [cron] Bump distribution date (2022-03-18) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index c3c8a7eeb9..254604a1d0 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-14" +//#define STRING_DISTRIBUTION_DATE "2022-03-18" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 782bd47eb2..a00587e6df 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-14" + #define STRING_DISTRIBUTION_DATE "2022-03-18" #endif /** From bf7176fba9bbc0e41e5dce80aa5094a0ce6522eb Mon Sep 17 00:00:00 2001 From: Ludy Date: Fri, 18 Mar 2022 02:55:33 +0100 Subject: [PATCH 131/203] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20redundant=20var=20?= =?UTF-8?q?declaration=20(#23913)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/drivers.h | 2 +- Marlin/src/gcode/feature/trinamic/M906.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M911-M914.cpp | 2 +- Marlin/src/gcode/feature/trinamic/M919.cpp | 2 +- Marlin/src/lcd/language/language_de.h | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 2e66cc9201..ac1f4a155d 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -200,4 +200,4 @@ #define HAS_L64XX_NOT_L6474 1 #endif -#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01)) +#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01)) diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index 164ff00179..c85d0be8a1 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -59,7 +59,7 @@ void GcodeSuite::M906() { #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) const int8_t index = parser.byteval('I', -1); - #else + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) constexpr int8_t index = -1; #endif diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 628ae40f48..b37c81733c 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -258,7 +258,7 @@ bool report = true; #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) const int8_t index = parser.byteval('I', -1); - #else + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) constexpr int8_t index = -1; #endif LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(axis_codes[i])) { diff --git a/Marlin/src/gcode/feature/trinamic/M919.cpp b/Marlin/src/gcode/feature/trinamic/M919.cpp index 4dce28f0ae..d4ba4f74ea 100644 --- a/Marlin/src/gcode/feature/trinamic/M919.cpp +++ b/Marlin/src/gcode/feature/trinamic/M919.cpp @@ -93,7 +93,7 @@ void GcodeSuite::M919() { #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) const int8_t index = parser.byteval('I'); - #else + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) constexpr int8_t index = -1; #endif diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 393d5b58bc..a6782bb0ac 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -388,7 +388,7 @@ namespace Language_de { LSTR MSG_ADVANCE_K = _UxGT("Vorschubfaktor"); LSTR MSG_ADVANCE_K_E = _UxGT("Vorschubfaktor *"); LSTR MSG_CONTRAST = _UxGT("LCD-Kontrast"); - LSTR MSG_BRIGHTNESS = _UxGT("LCD Helligkeit"); + LSTR MSG_BRIGHTNESS = _UxGT("LCD-Helligkeit"); LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD-Ruhezustand (s)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("LCD ausschalten"); LSTR MSG_STORE_EEPROM = _UxGT("Konfig. speichern"); @@ -401,7 +401,7 @@ namespace Language_de { LSTR MSG_SETTINGS_STORED = _UxGT("Einstell. gespei."); LSTR MSG_MEDIA_UPDATE = _UxGT("FW Update vom Medium"); LSTR MSG_RESET_PRINTER = _UxGT("Drucker neustarten"); - LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Aktualisieren"); + LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Aktualisieren"); LSTR MSG_INFO_SCREEN = _UxGT("Info"); LSTR MSG_PREPARE = _UxGT("Vorbereitung"); LSTR MSG_TUNE = _UxGT("Justierung"); From 631e35bfd6cec8d61eca31ac2945ff890ab8f2ed Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Fri, 18 Mar 2022 03:15:26 +0000 Subject: [PATCH 132/203] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Fix=20noisy=20ADC?= =?UTF-8?q?=20-=2016x=20oversampling=20with=2012-bit=20ADC=20(#23867)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 1 + Marlin/src/feature/joystick.cpp | 22 ++-- Marlin/src/lcd/marlinui.cpp | 14 +-- Marlin/src/module/temperature.cpp | 124 ++++++++++----------- Marlin/src/module/temperature.h | 57 +++++----- Marlin/src/module/thermistor/thermistors.h | 16 ++- 6 files changed, 117 insertions(+), 117 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index b95b595659..53d98e0e6d 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -128,6 +128,7 @@ typedef float feedRate_t; // celsius_t is the native unit of temperature. Signed to handle a disconnected thermistor value (-14). // For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100 // +typedef uint16_t raw_adc_t; typedef int16_t celsius_t; typedef float celsius_float_t; diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index 7f91c1549b..c68a2b8df9 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -68,13 +68,13 @@ Joystick joystick; void Joystick::report() { SERIAL_ECHOPGM("Joystick"); #if HAS_JOY_ADC_X - SERIAL_ECHOPGM_P(SP_X_STR, JOY_X(x.raw)); + SERIAL_ECHOPGM_P(SP_X_STR, JOY_X(x.getraw())); #endif #if HAS_JOY_ADC_Y - SERIAL_ECHOPGM_P(SP_Y_STR, JOY_Y(y.raw)); + SERIAL_ECHOPGM_P(SP_Y_STR, JOY_Y(y.getraw())); #endif #if HAS_JOY_ADC_Z - SERIAL_ECHOPGM_P(SP_Z_STR, JOY_Z(z.raw)); + SERIAL_ECHOPGM_P(SP_Z_STR, JOY_Z(z.getraw())); #endif #if HAS_JOY_ADC_EN SERIAL_ECHO_TERNARY(READ(JOY_EN_PIN), " EN=", "HIGH (dis", "LOW (en", "abled)"); @@ -91,29 +91,29 @@ Joystick joystick; if (READ(JOY_EN_PIN)) return; #endif - auto _normalize_joy = [](float &axis_jog, const int16_t raw, const int16_t (&joy_limits)[4]) { + auto _normalize_joy = [](float &axis_jog, const raw_adc_t raw, const raw_adc_t (&joy_limits)[4]) { if (WITHIN(raw, joy_limits[0], joy_limits[3])) { // within limits, check deadzone if (raw > joy_limits[2]) axis_jog = (raw - joy_limits[2]) / float(joy_limits[3] - joy_limits[2]); else if (raw < joy_limits[1]) - axis_jog = (raw - joy_limits[1]) / float(joy_limits[1] - joy_limits[0]); // negative value + axis_jog = int16_t(raw - joy_limits[1]) / float(joy_limits[1] - joy_limits[0]); // negative value // Map normal to jog value via quadratic relationship axis_jog = SIGN(axis_jog) * sq(axis_jog); } }; #if HAS_JOY_ADC_X - static constexpr int16_t joy_x_limits[4] = JOY_X_LIMITS; - _normalize_joy(norm_jog.x, JOY_X(x.raw), joy_x_limits); + static constexpr raw_adc_t joy_x_limits[4] = JOY_X_LIMITS; + _normalize_joy(norm_jog.x, JOY_X(x.getraw()), joy_x_limits); #endif #if HAS_JOY_ADC_Y - static constexpr int16_t joy_y_limits[4] = JOY_Y_LIMITS; - _normalize_joy(norm_jog.y, JOY_Y(y.raw), joy_y_limits); + static constexpr raw_adc_t joy_y_limits[4] = JOY_Y_LIMITS; + _normalize_joy(norm_jog.y, JOY_Y(y.getraw()), joy_y_limits); #endif #if HAS_JOY_ADC_Z - static constexpr int16_t joy_z_limits[4] = JOY_Z_LIMITS; - _normalize_joy(norm_jog.z, JOY_Z(z.raw), joy_z_limits); + static constexpr raw_adc_t joy_z_limits[4] = JOY_Z_LIMITS; + _normalize_joy(norm_jog.z, JOY_Z(z.getraw()), joy_z_limits); #endif } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index f0677afd2d..786a865049 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1176,7 +1176,7 @@ void MarlinUI::init() { #if HAS_ADC_BUTTONS typedef struct { - uint16_t ADCKeyValueMin, ADCKeyValueMax; + raw_adc_t ADCKeyValueMin, ADCKeyValueMax; uint8_t ADCKeyNo; } _stADCKeypadTable_; @@ -1203,10 +1203,10 @@ void MarlinUI::init() { #endif // Calculate the ADC value for the voltage divider with specified pull-down resistor value - #define ADC_BUTTON_VALUE(r) int(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) + #define ADC_BUTTON_VALUE(r) raw_adc_t(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) - static constexpr uint16_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, - adc_other_button = HAL_ADC_RANGE * 1000 / 1024; + static constexpr raw_adc_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, + adc_other_button = HAL_ADC_RANGE * 1000 / 1024; static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = { // VALUE_MIN, VALUE_MAX, KEY { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F1 }, // F1 @@ -1226,13 +1226,13 @@ void MarlinUI::init() { uint8_t get_ADC_keyValue() { if (thermalManager.ADCKey_count >= 16) { - const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw; + const raw_adc_t currentkpADCValue = thermalManager.current_ADCKey_raw; thermalManager.current_ADCKey_raw = HAL_ADC_RANGE; thermalManager.ADCKey_count = 0; if (currentkpADCValue < adc_other_button) LOOP_L_N(i, ADC_KEY_NUM) { - const uint16_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin), - hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax); + const raw_adc_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin), + hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax); if (WITHIN(currentkpADCValue, lo, hi)) return pgm_read_byte(&stADCKeyTable[i].ADCKeyNo); } } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 653b3179b0..a983275b8a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -437,8 +437,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_HEATED_BED bed_info_t Temperature::temp_bed; // = { 0 } // Init min and max temp with extreme values to prevent false errors during startup - int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, - Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, + Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); #endif @@ -448,8 +448,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_HEATED_CHAMBER millis_t next_cool_check_ms_2 = 0; celsius_float_t old_temp = 9999; - int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, - Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, + Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0}); IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms); #endif @@ -461,8 +461,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); bool flag_cooler_state; //bool flag_cooler_excess = false; celsius_float_t previous_temp = 9999; - int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, - Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, + Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; #if WATCH_COOLER cooler_watch_t Temperature::watch_cooler{0}; #endif @@ -477,8 +477,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_TEMP_BOARD board_info_t Temperature::temp_board; // = { 0 } #if ENABLED(THERMAL_PROTECTION_BOARD) - int16_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, - Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, + Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; #endif #endif @@ -508,6 +508,7 @@ volatile bool Temperature::raw_temps_ready = false; #endif #define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1) +#define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) #if HAS_HOTEND // Init mintemp and maxtemp with extreme values to prevent false errors during startup @@ -1689,8 +1690,8 @@ void Temperature::manage_heater() { m = (l + r) >> 1; \ if (!m) return celsius_t(pgm_read_word(&TBL[0].celsius)); \ if (m == l || m == r) return celsius_t(pgm_read_word(&TBL[LEN-1].celsius)); \ - int16_t v00 = pgm_read_word(&TBL[m-1].value), \ - v10 = pgm_read_word(&TBL[m-0].value); \ + raw_adc_t v00 = pgm_read_word(&TBL[m-1].value), \ + v10 = pgm_read_word(&TBL[m-0].value); \ if (raw < v00) r = m; \ else if (raw > v10) l = m; \ else { \ @@ -1784,7 +1785,7 @@ void Temperature::manage_heater() { SERIAL_EOL(); } - celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw) { + celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const raw_adc_t raw) { if (!WITHIN(t_index, 0, COUNT(user_thermistor) - 1)) return 25; @@ -1799,8 +1800,8 @@ void Temperature::manage_heater() { } // maximum adc value .. take into account the over sampling - const int adc_max = MAX_RAW_THERMISTOR_VALUE, - adc_raw = constrain(raw, 1, adc_max - 1); // constrain to prevent divide-by-zero + constexpr raw_adc_t adc_max = MAX_RAW_THERMISTOR_VALUE; + const raw_adc_t adc_raw = constrain(raw, 1, adc_max - 1); // constrain to prevent divide-by-zero const float adc_inverse = (adc_max - adc_raw) - 0.5f, resistance = t.series_res * (adc_raw + 0.5f) / adc_inverse, @@ -1820,7 +1821,7 @@ void Temperature::manage_heater() { #if HAS_HOTEND // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. - celsius_float_t Temperature::analog_to_celsius_hotend(const int16_t raw, const uint8_t e) { + celsius_float_t Temperature::analog_to_celsius_hotend(const raw_adc_t raw, const uint8_t e) { if (e >= HOTENDS) { SERIAL_ERROR_START(); SERIAL_ECHO(e); @@ -1836,11 +1837,11 @@ void Temperature::manage_heater() { #elif TEMP_SENSOR_0_IS_MAX_TC #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, - max31865_0.temperature((uint16_t)raw), + max31865_0.temperature(raw), max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) ); #else - return raw * 0.25; + return (int16_t)raw * 0.25; #endif #elif TEMP_SENSOR_0_IS_AD595 return TEMP_AD595(raw); @@ -1855,11 +1856,11 @@ void Temperature::manage_heater() { #elif TEMP_SENSOR_1_IS_MAX_TC #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, - max31865_1.temperature((uint16_t)raw), + max31865_1.temperature(raw), max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) ); #else - return raw * 0.25; + return (int16_t)raw * 0.25; #endif #elif TEMP_SENSOR_1_IS_AD595 return TEMP_AD595(raw); @@ -1943,7 +1944,7 @@ void Temperature::manage_heater() { #if HAS_HEATED_BED // For bed temperature measurement. - celsius_float_t Temperature::analog_to_celsius_bed(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_bed(const raw_adc_t raw) { #if TEMP_SENSOR_BED_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BED, raw); #elif TEMP_SENSOR_BED_IS_THERMISTOR @@ -1961,7 +1962,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_CHAMBER // For chamber temperature measurement. - celsius_float_t Temperature::analog_to_celsius_chamber(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_chamber(const raw_adc_t raw) { #if TEMP_SENSOR_CHAMBER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_CHAMBER, raw); #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR @@ -1979,7 +1980,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_COOLER // For cooler temperature measurement. - celsius_float_t Temperature::analog_to_celsius_cooler(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_cooler(const raw_adc_t raw) { #if TEMP_SENSOR_COOLER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_COOLER, raw); #elif TEMP_SENSOR_COOLER_IS_THERMISTOR @@ -1997,7 +1998,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_PROBE // For probe temperature measurement. - celsius_float_t Temperature::analog_to_celsius_probe(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_probe(const raw_adc_t raw) { #if TEMP_SENSOR_PROBE_IS_CUSTOM return user_thermistor_to_deg_c(CTI_PROBE, raw); #elif TEMP_SENSOR_PROBE_IS_THERMISTOR @@ -2015,7 +2016,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_BOARD // For motherboard temperature measurement. - celsius_float_t Temperature::analog_to_celsius_board(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_board(const raw_adc_t raw) { #if TEMP_SENSOR_BOARD_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BOARD, raw); #elif TEMP_SENSOR_BOARD_IS_THERMISTOR @@ -2033,13 +2034,13 @@ void Temperature::manage_heater() { #if HAS_TEMP_REDUNDANT // For redundant temperature measurement. - celsius_float_t Temperature::analog_to_celsius_redundant(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_redundant(const raw_adc_t raw) { #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM return user_thermistor_to_deg_c(CTI_REDUNDANT, raw); #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) - return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature((uint16_t)raw), raw * 0.25); + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) - return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature((uint16_t)raw), raw * 0.25); + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN); #elif TEMP_SENSOR_REDUNDANT_IS_AD595 @@ -2069,20 +2070,20 @@ void Temperature::updateTemperaturesFromRawValues() { watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt - TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0)); - TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1)); - TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE))); + TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].setraw(READ_MAX_TC(0))); + TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].setraw(READ_MAX_TC(1))); + TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE)))); #if HAS_HOTEND - HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); + HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].getraw(), e); #endif - TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw)); - TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw)); - TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.raw)); - TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw)); - TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.raw)); - TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.raw)); + TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.getraw())); + TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.getraw())); + TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.getraw())); + TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.getraw())); + TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.getraw())); + TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.getraw())); TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); @@ -2108,46 +2109,45 @@ void Temperature::updateTemperaturesFromRawValues() { }; LOOP_L_N(e, COUNT(temp_dir)) { - const int8_t tdir = temp_dir[e]; - if (tdir) { - const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp - if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e); + const raw_adc_t r = temp_hotend[e].getraw(); + const bool neg = temp_dir[e] < 0, pos = temp_dir[e] > 0; + if ((neg && r < temp_range[e].raw_max) || (pos && r > temp_range[e].raw_max)) + max_temp_error((heater_id_t)e); - const bool heater_on = temp_hotend[e].target > 0; - if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) { - #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 - if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) - #endif - min_temp_error((heater_id_t)e); - } + const bool heater_on = temp_hotend[e].target > 0; + if (heater_on && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) { #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 - else - consecutive_low_temperature_error[e] = 0; + if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) #endif + min_temp_error((heater_id_t)e); } + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 + else + consecutive_low_temperature_error[e] = 0; + #endif } #endif // HAS_HOTEND #define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) #if ENABLED(THERMAL_PROTECTION_BED) - if (TP_CMP(BED, temp_bed.raw, maxtemp_raw_BED)) max_temp_error(H_BED); - if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_BED); + if (TP_CMP(BED, temp_bed.getraw(), maxtemp_raw_BED)) max_temp_error(H_BED); + if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) min_temp_error(H_BED); #endif #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) - if (TP_CMP(CHAMBER, temp_chamber.raw, maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); - if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.raw)) min_temp_error(H_CHAMBER); + if (TP_CMP(CHAMBER, temp_chamber.getraw(), maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); + if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw())) min_temp_error(H_CHAMBER); #endif #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) - if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.raw, maxtemp_raw_COOLER)) max_temp_error(H_COOLER); - if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.raw)) min_temp_error(H_COOLER); + if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), maxtemp_raw_COOLER)) max_temp_error(H_COOLER); + if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.getraw())) min_temp_error(H_COOLER); #endif #if BOTH(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) - if (TP_CMP(BOARD, temp_board.raw, maxtemp_raw_BOARD)) max_temp_error(H_BOARD); - if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.raw)) min_temp_error(H_BOARD); + if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) max_temp_error(H_BOARD); + if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) min_temp_error(H_BOARD); #endif #undef TP_CMP @@ -2731,7 +2731,7 @@ void Temperature::disable_all_heaters() { * @param hindex the hotend we're referencing (if MULTI_MAX_TC) * @return integer representing the board's buffer, to be converted later if needed */ - int16_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { + raw_adc_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { #define MAXTC_HEAT_INTERVAL 250UL #if HAS_MAX31855 @@ -2750,7 +2750,7 @@ void Temperature::disable_all_heaters() { #if HAS_MULTI_MAX_TC // Needed to return the correct temp when this is called between readings - static int16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; + static raw_adc_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; #define THERMO_TEMP(I) max_tc_temp_previous[I] #define THERMO_SEL(A,B) (hindex ? (B) : (A)) #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) @@ -2779,7 +2779,7 @@ void Temperature::disable_all_heaters() { // Return last-read value between readings millis_t ms = millis(); if (PENDING(ms, next_max_tc_ms[hindex])) - return (int16_t)THERMO_TEMP(hindex); + return THERMO_TEMP(hindex); next_max_tc_ms[hindex] = ms + MAXTC_HEAT_INTERVAL; @@ -2876,7 +2876,7 @@ void Temperature::disable_all_heaters() { THERMO_TEMP(hindex) = max_tc_temp; - return (int16_t)max_tc_temp; + return max_tc_temp; } #endif // HAS_MAX_TC @@ -3017,7 +3017,7 @@ void Temperature::isr() { uint8_t pwm_count_tmp = pwm_count; #if HAS_ADC_BUTTONS - static unsigned int raw_ADCKey_value = 0; + static raw_adc_t raw_ADCKey_value = 0; static bool ADCKey_pressed = false; #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index eb2f4337c0..cb84f7e395 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -192,12 +192,16 @@ enum ADCSensorState : char { // A temperature sensor typedef struct TempInfo { - uint16_t acc; - int16_t raw; +private: + raw_adc_t acc; + raw_adc_t raw; +public: celsius_float_t celsius; inline void reset() { acc = 0; } - inline void sample(const uint16_t s) { acc += s; } + inline void sample(const raw_adc_t s) { acc += s; } inline void update() { raw = acc; } + void setraw(const raw_adc_t r) { raw = r; } + raw_adc_t getraw() { return raw; } } temp_info_t; #if HAS_TEMP_REDUNDANT @@ -287,9 +291,7 @@ struct HeaterWatch { #endif // Temperature sensor read value ranges -typedef struct { int16_t raw_min, raw_max; } raw_range_t; -typedef struct { celsius_t mintemp, maxtemp; } celsius_range_t; -typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t; +typedef struct { raw_adc_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t; #define THERMISTOR_ABS_ZERO_C -273.15f // bbbbrrrrr cold ! #define THERMISTOR_RESISTANCE_NOMINAL_C 25.0f // mmmmm comfortable @@ -492,7 +494,7 @@ class Temperature { static bed_watch_t watch_bed; #endif IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); - static int16_t mintemp_raw_BED, maxtemp_raw_BED; + static raw_adc_t mintemp_raw_BED, maxtemp_raw_BED; #endif #if HAS_HEATED_CHAMBER @@ -500,7 +502,7 @@ class Temperature { static chamber_watch_t watch_chamber; #endif TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms); - static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; + static raw_adc_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; #endif #if HAS_COOLER @@ -508,11 +510,11 @@ class Temperature { static cooler_watch_t watch_cooler; #endif static millis_t next_cooler_check_ms, cooler_fan_flush_ms; - static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER; + static raw_adc_t mintemp_raw_COOLER, maxtemp_raw_COOLER; #endif #if HAS_TEMP_BOARD && ENABLED(THERMAL_PROTECTION_BOARD) - static int16_t mintemp_raw_BOARD, maxtemp_raw_BOARD; + static raw_adc_t mintemp_raw_BOARD, maxtemp_raw_BOARD; #endif #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 @@ -566,7 +568,7 @@ class Temperature { static user_thermistor_t user_thermistor[USER_THERMISTORS]; static void M305_report(const uint8_t t_index, const bool forReplay=true); static void reset_user_thermistors(); - static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw); + static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const raw_adc_t raw); static bool set_pull_up_res(int8_t t_index, float value) { //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false; if (!WITHIN(value, 1, 1000000)) return false; @@ -594,25 +596,25 @@ class Temperature { #endif #if HAS_HOTEND - static celsius_float_t analog_to_celsius_hotend(const int16_t raw, const uint8_t e); + static celsius_float_t analog_to_celsius_hotend(const raw_adc_t raw, const uint8_t e); #endif #if HAS_HEATED_BED - static celsius_float_t analog_to_celsius_bed(const int16_t raw); + static celsius_float_t analog_to_celsius_bed(const raw_adc_t raw); #endif #if HAS_TEMP_CHAMBER - static celsius_float_t analog_to_celsius_chamber(const int16_t raw); + static celsius_float_t analog_to_celsius_chamber(const raw_adc_t raw); #endif #if HAS_TEMP_PROBE - static celsius_float_t analog_to_celsius_probe(const int16_t raw); + static celsius_float_t analog_to_celsius_probe(const raw_adc_t raw); #endif #if HAS_TEMP_COOLER - static celsius_float_t analog_to_celsius_cooler(const int16_t raw); + static celsius_float_t analog_to_celsius_cooler(const raw_adc_t raw); #endif #if HAS_TEMP_BOARD - static celsius_float_t analog_to_celsius_board(const int16_t raw); + static celsius_float_t analog_to_celsius_board(const raw_adc_t raw); #endif #if HAS_TEMP_REDUNDANT - static celsius_float_t analog_to_celsius_redundant(const int16_t raw); + static celsius_float_t analog_to_celsius_redundant(const raw_adc_t raw); #endif #if HAS_FAN @@ -707,8 +709,8 @@ class Temperature { } #if ENABLED(SHOW_TEMP_ADC_VALUES) - static int16_t rawHotendTemp(const uint8_t E_NAME) { - return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw); + static raw_adc_t rawHotendTemp(const uint8_t E_NAME) { + return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].getraw()); } #endif @@ -770,7 +772,7 @@ class Temperature { #if HAS_HEATED_BED #if ENABLED(SHOW_TEMP_ADC_VALUES) - static int16_t rawBedTemp() { return temp_bed.raw; } + static raw_adc_t rawBedTemp() { return temp_bed.getraw(); } #endif static celsius_float_t degBed() { return temp_bed.celsius; } static celsius_t wholeDegBed() { return static_cast(degBed() + 0.5f); } @@ -801,7 +803,7 @@ class Temperature { #if HAS_TEMP_PROBE #if ENABLED(SHOW_TEMP_ADC_VALUES) - static int16_t rawProbeTemp() { return temp_probe.raw; } + static raw_adc_t rawProbeTemp() { return temp_probe.getraw(); } #endif static celsius_float_t degProbe() { return temp_probe.celsius; } static celsius_t wholeDegProbe() { return static_cast(degProbe() + 0.5f); } @@ -812,7 +814,7 @@ class Temperature { #if HAS_TEMP_CHAMBER #if ENABLED(SHOW_TEMP_ADC_VALUES) - static int16_t rawChamberTemp() { return temp_chamber.raw; } + static raw_adc_t rawChamberTemp() { return temp_chamber.getraw(); } #endif static celsius_float_t degChamber() { return temp_chamber.celsius; } static celsius_t wholeDegChamber() { return static_cast(degChamber() + 0.5f); } @@ -835,7 +837,7 @@ class Temperature { #if HAS_TEMP_COOLER #if ENABLED(SHOW_TEMP_ADC_VALUES) - static int16_t rawCoolerTemp() { return temp_cooler.raw; } + static raw_adc_t rawCoolerTemp() { return temp_cooler.getraw(); } #endif static celsius_float_t degCooler() { return temp_cooler.celsius; } static celsius_t wholeDegCooler() { return static_cast(temp_cooler.celsius + 0.5f); } @@ -849,7 +851,7 @@ class Temperature { #if HAS_TEMP_BOARD #if ENABLED(SHOW_TEMP_ADC_VALUES) - static int16_t rawBoardTemp() { return temp_board.raw; } + static raw_adc_t rawBoardTemp() { return temp_board.getraw(); } #endif static celsius_float_t degBoard() { return temp_board.celsius; } static celsius_t wholeDegBoard() { return static_cast(temp_board.celsius + 0.5f); } @@ -857,8 +859,7 @@ class Temperature { #if HAS_TEMP_REDUNDANT #if ENABLED(SHOW_TEMP_ADC_VALUES) - static int16_t rawRedundantTemp() { return temp_redundant.raw; } - static int16_t rawRedundanTargetTemp() { return (*temp_redundant.target).raw; } + static raw_adc_t rawRedundantTemp() { return temp_redundant.getraw(); } #endif static celsius_float_t degRedundant() { return temp_redundant.celsius; } static celsius_float_t degRedundantTarget() { return (*temp_redundant.target).celsius; } @@ -991,7 +992,7 @@ class Temperature { #else #define READ_MAX_TC(N) read_max_tc() #endif - static int16_t read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); + static raw_adc_t read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); #endif #if HAS_AUTO_FAN diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 9f2ebce49a..a38b7f381f 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -27,22 +27,20 @@ #define THERMISTOR_TABLE_SCALE (HAL_ADC_RANGE / _BV(THERMISTOR_TABLE_ADC_RESOLUTION)) #if ENABLED(HAL_ADC_FILTERED) #define OVERSAMPLENR 1 -#elif HAL_ADC_RESOLUTION > 10 - #define OVERSAMPLENR (20 - HAL_ADC_RESOLUTION) #else #define OVERSAMPLENR 16 #endif -#define MAX_RAW_THERMISTOR_VALUE (HAL_ADC_RANGE * (OVERSAMPLENR) - 1) -// Currently Marlin stores all oversampled ADC values as int16_t, make sure the HAL settings do not overflow 15bit -#if MAX_RAW_THERMISTOR_VALUE > ((1 << 15) - 1) - #error "MAX_RAW_THERMISTOR_VALUE is too large for int16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION." +// Currently Marlin stores all oversampled ADC values as uint16_t, make sure the HAL settings do not overflow 16 bit +#if (HAL_ADC_RANGE) * (OVERSAMPLENR) > 1 << 16 + #error "MAX_RAW_THERMISTOR_VALUE is too large for uint16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION." #endif +#define MAX_RAW_THERMISTOR_VALUE (uint16_t(HAL_ADC_RANGE) * (OVERSAMPLENR) - 1) -#define OV_SCALE(N) (N) -#define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) +#define OV_SCALE(N) float(N) +#define OV(N) raw_adc_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) -typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; +typedef struct { raw_adc_t value; celsius_t celsius; } temp_entry_t; // Pt1000 and Pt100 handling // From 9b2c06045d6c9a561c45e1e5c1f386268dfdca49 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 18 Mar 2022 16:17:41 +1300 Subject: [PATCH 133/203] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20xatc=20EEPROM=20de?= =?UTF-8?q?bug=20(#23911)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/settings.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6eb17d5d2e..63bb93765b 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,9 @@ typedef struct SettingsDataStruct { // X_AXIS_TWIST_COMPENSATION // #if ENABLED(X_AXIS_TWIST_COMPENSATION) - XATC xatc; // M423 X Z + float xatc_spacing; // M423 X Z + float xatc_start; + xatc_array_t xatc_z_offset; #endif // @@ -900,7 +902,7 @@ void MarlinSettings::postprocess() { // X Axis Twist Compensation // #if ENABLED(X_AXIS_TWIST_COMPENSATION) - _FIELD_TEST(xatc); + _FIELD_TEST(xatc_spacing); EEPROM_WRITE(xatc.spacing); EEPROM_WRITE(xatc.start); EEPROM_WRITE(xatc.z_offset); @@ -1811,7 +1813,7 @@ void MarlinSettings::postprocess() { // X Axis Twist Compensation // #if ENABLED(X_AXIS_TWIST_COMPENSATION) - _FIELD_TEST(xatc); + _FIELD_TEST(xatc_spacing); EEPROM_READ(xatc.spacing); EEPROM_READ(xatc.start); EEPROM_READ(xatc.z_offset); From 1f1571f7265b7231e81b8957f50ceb4511aeb611 Mon Sep 17 00:00:00 2001 From: John Robertson Date: Fri, 18 Mar 2022 03:21:53 +0000 Subject: [PATCH 134/203] =?UTF-8?q?=E2=9C=A8=20ESP32=20-=20Hardware=20PWM?= =?UTF-8?q?=20for=20fan,=20cutter,=20servos=20(#23802)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 +- Marlin/src/HAL/ESP32/HAL.cpp | 101 ++++++++++++++++++++----- Marlin/src/HAL/ESP32/HAL.h | 25 ++++-- Marlin/src/HAL/ESP32/Servo.cpp | 18 ++--- Marlin/src/HAL/ESP32/Servo.h | 3 +- Marlin/src/HAL/ESP32/inc/SanityCheck.h | 8 +- 6 files changed, 116 insertions(+), 41 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d78e63100e..0a18e95ebc 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3464,7 +3464,7 @@ #define SPINDLE_LASER_USE_PWM // Enable if your controller supports setting the speed/power #if ENABLED(SPINDLE_LASER_USE_PWM) #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower - #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC) + #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32 and LPC) #endif //#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11 diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index c1a44a3dea..44be0b540a 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -73,9 +73,16 @@ uint16_t MarlinHAL::adc_result; esp_adc_cal_characteristics_t characteristics[ADC_ATTEN_MAX]; adc_atten_t attenuations[ADC1_CHANNEL_MAX] = {}; uint32_t thresholds[ADC_ATTEN_MAX]; -volatile int numPWMUsed = 0, - pwmPins[MAX_PWM_PINS], - pwmValues[MAX_PWM_PINS]; + +volatile int numPWMUsed = 0; +volatile struct { pin_t pin; int value; } pwmState[MAX_PWM_PINS]; + +pin_t chan_pin[CHANNEL_MAX_NUM + 1] = { 0 }; // PWM capable IOpins - not 0 or >33 on ESP32 + +struct { + uint32_t freq; // ledcReadFreq doesn't work if a duty hasn't been set yet! + uint16_t res; +} pwmInfo[(CHANNEL_MAX_NUM + 1) / 2]; // ------------------------ // Public functions @@ -254,25 +261,81 @@ void MarlinHAL::adc_start(const pin_t pin) { adc1_set_attenuation(chan, atten); } -void analogWrite(pin_t pin, int value) { - // Use ledc hardware for internal pins - if (pin < 34) { - static int cnt_channel = 1, pin_to_channel[40] = { 0 }; - if (pin_to_channel[pin] == 0) { - ledcAttachPin(pin, cnt_channel); - ledcSetup(cnt_channel, 490, 8); - ledcWrite(cnt_channel, value); - pin_to_channel[pin] = cnt_channel++; +// ------------------------ +// PWM +// ------------------------ + +int8_t channel_for_pin(const uint8_t pin) { + for (int i = 0; i <= CHANNEL_MAX_NUM; i++) + if (chan_pin[i] == pin) return i; + return -1; +} + +// get PWM channel for pin - if none then attach a new one +// return -1 if fail or invalid pin#, channel # (0-15) if success +int8_t get_pwm_channel(const pin_t pin, const uint32_t freq, const uint16_t res) { + if (!WITHIN(pin, 1, MAX_PWM_IOPIN)) return -1; // Not a hardware PWM pin! + int8_t cid = channel_for_pin(pin); + if (cid >= 0) return cid; + + // Find an empty adjacent channel (same timer & freq/res) + for (int i = 0; i <= CHANNEL_MAX_NUM; i++) { + if (chan_pin[i] == 0) { + if (chan_pin[i ^ 0x1] != 0) { + if (pwmInfo[i / 2].freq == freq && pwmInfo[i / 2].res == res) { + chan_pin[i] = pin; // Allocate PWM to this channel + ledcAttachPin(pin, i); + return i; + } + } + else if (cid == -1) // Pair of empty channels? + cid = i & 0xFE; // Save lower channel number } - ledcWrite(pin_to_channel[pin], value); + } + // not attached, is an empty timer slot avail? + if (cid >= 0) { + chan_pin[cid] = pin; + pwmInfo[cid / 2].freq = freq; + pwmInfo[cid / 2].res = res; + ledcSetup(cid, freq, res); + ledcAttachPin(pin, cid); + } + return cid; // -1 if no channel avail +} + +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=_BV(PWM_RESOLUTION)-1*/, const bool invert/*=false*/) { + const int8_t cid = get_pwm_channel(pin, PWM_FREQUENCY, PWM_RESOLUTION); + if (cid >= 0) { + uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, _BV(PWM_RESOLUTION)-1); + ledcWrite(cid, duty); + } +} + +int8_t MarlinHAL::set_pwm_frequency(const pin_t pin, const uint32_t f_desired) { + const int8_t cid = channel_for_pin(pin); + if (cid >= 0) { + if (f_desired == ledcReadFreq(cid)) return cid; // no freq change + ledcDetachPin(chan_pin[cid]); + chan_pin[cid] = 0; // remove old freq channel + } + return get_pwm_channel(pin, f_desired, PWM_RESOLUTION); // try for new one +} + +// use hardware PWM if avail, if not then ISR +void analogWrite(const pin_t pin, const uint16_t value, const uint32_t freq/*=PWM_FREQUENCY*/, const uint16_t res/*=8*/) { // always 8 bit resolution! + // Use ledc hardware for internal pins + const int8_t cid = get_pwm_channel(pin, freq, res); + if (cid >= 0) { + ledcWrite(cid, value); // set duty value return; } + // not a hardware PWM pin OR no PWM channels available int idx = -1; // Search Pin for (int i = 0; i < numPWMUsed; ++i) - if (pwmPins[i] == pin) { idx = i; break; } + if (pwmState[i].pin == pin) { idx = i; break; } // not found ? if (idx < 0) { @@ -281,7 +344,7 @@ void analogWrite(pin_t pin, int value) { // Take new slot for pin idx = numPWMUsed; - pwmPins[idx] = pin; + pwmState[idx].pin = pin; // Start timer on first use if (idx == 0) HAL_timer_start(MF_TIMER_PWM, PWM_TIMER_FREQUENCY); @@ -289,7 +352,7 @@ void analogWrite(pin_t pin, int value) { } // Use 7bit internal value - add 1 to have 100% high at 255 - pwmValues[idx] = (value + 1) / 2; + pwmState[idx].value = (value + 1) / 2; } // Handle PWM timer interrupt @@ -300,9 +363,9 @@ HAL_PWM_TIMER_ISR() { for (int i = 0; i < numPWMUsed; ++i) { if (count == 0) // Start of interval - WRITE(pwmPins[i], pwmValues[i] ? HIGH : LOW); - else if (pwmValues[i] == count) // End of duration - WRITE(pwmPins[i], LOW); + digitalWrite(pwmState[i].pin, pwmState[i].value ? HIGH : LOW); + else if (pwmState[i].value == count) // End of duration + digitalWrite(pwmState[i].pin, LOW); } // 128 for 7 Bit resolution diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index df52e2186c..8b26c3471d 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -64,6 +64,12 @@ #define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) #define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock) +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment +#define PWM_FREQUENCY 1000u // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() +#define PWM_RESOLUTION 10u // Default PWM bit resolution +#define CHANNEL_MAX_NUM 15u // max PWM channel # to allocate (7 to only use low speed, 15 to use low & high) +#define MAX_PWM_IOPIN 33u // hardware pwm pins < 34 + // ------------------------ // Types // ------------------------ @@ -83,7 +89,7 @@ typedef Servo hal_servo_t; void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -void analogWrite(pin_t pin, int value); +void analogWrite(const pin_t pin, const uint16_t value, const uint32_t freq=PWM_FREQUENCY, const uint16_t res=8); // // Pin Mapping for M42, M43, M226 @@ -209,12 +215,17 @@ public: static uint16_t adc_value() { return adc_result; } /** - * Set the PWM duty cycle for the pin to the given value. - * No inverting the duty cycle in this HAL. - * No changing the maximum size of the provided value to enable finer PWM duty control in this HAL. + * If not already allocated, allocate a hardware PWM channel + * to the pin and set the duty cycle.. + * Optionally invert the duty cycle [default = false] + * Optionally change the scale of the provided value to enable finer PWM duty control [default = 255] */ - static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { - analogWrite(pin, v); - } + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + + /** + * Allocate and set the frequency of a hardware PWM pin + * Returns -1 if no pin available. + */ + static int8_t set_pwm_frequency(const pin_t pin, const uint32_t f_desired); }; diff --git a/Marlin/src/HAL/ESP32/Servo.cpp b/Marlin/src/HAL/ESP32/Servo.cpp index fcf5848581..ca3950d07f 100644 --- a/Marlin/src/HAL/ESP32/Servo.cpp +++ b/Marlin/src/HAL/ESP32/Servo.cpp @@ -31,20 +31,18 @@ // so we only allocate servo channels up high to avoid side effects with regards to analogWrite (fans, leds, laser pwm etc.) int Servo::channel_next_free = 12; -Servo::Servo() { - channel = channel_next_free++; -} +Servo::Servo() {} int8_t Servo::attach(const int inPin) { - if (channel >= CHANNEL_MAX_NUM) return -1; if (inPin > 0) pin = inPin; - - ledcSetup(channel, 50, 16); // channel X, 50 Hz, 16-bit depth - ledcAttachPin(pin, channel); - return true; + channel = get_pwm_channel(pin, 50u, 16u); + return channel; // -1 if no PWM avail. } -void Servo::detach() { ledcDetachPin(pin); } +// leave channel connected to servo - set duty to zero +void Servo::detach() { + if (channel >= 0) ledcWrite(channel, 0); +} int Servo::read() { return degrees; } @@ -52,7 +50,7 @@ void Servo::write(int inDegrees) { degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE); int us = map(degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE); - ledcWrite(channel, duty); + if (channel >= 0) ledcWrite(channel, duty); // don't save duty for servos! } void Servo::move(const int value) { diff --git a/Marlin/src/HAL/ESP32/Servo.h b/Marlin/src/HAL/ESP32/Servo.h index 8542092d66..1dbb416a83 100644 --- a/Marlin/src/HAL/ESP32/Servo.h +++ b/Marlin/src/HAL/ESP32/Servo.h @@ -30,8 +30,7 @@ class Servo { MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo TAU_MSEC = 20, TAU_USEC = (TAU_MSEC * 1000), - MAX_COMPARE = _BV(16) - 1, // 65535 - CHANNEL_MAX_NUM = 16; + MAX_COMPARE = _BV(16) - 1; // 65535 public: Servo(); diff --git a/Marlin/src/HAL/ESP32/inc/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h index 8bbc68d871..052c7e9d12 100644 --- a/Marlin/src/HAL/ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h @@ -25,8 +25,8 @@ #error "EMERGENCY_PARSER is not yet implemented for ESP32. Disable EMERGENCY_PARSER to continue." #endif -#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on ESP32." +#if (ENABLED(SPINDLE_LASER_USE_PWM) && SPINDLE_LASER_FREQUENCY > 78125) || (ENABLED(FAST_PWM_FAN_FREQUENCY) && FAST_PWM_FAN_FREQUENCY > 78125) + #error "SPINDLE_LASER_FREQUENCY and FAST_PWM_FREQUENCY maximum value is 78125Hz for ESP32." #endif #if HAS_TMC_SW_SERIAL @@ -40,3 +40,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not yet supported on ESP32." #endif + +#if MB(MKS_TINYBEE) && ENABLED(FAST_PWM_FAN) + #error "FAST_PWM_FAN is not available on TinyBee." +#endif From a02a1def625bfb917d17cd290de93532408dc63f Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 18 Mar 2022 12:49:47 +0800 Subject: [PATCH 135/203] =?UTF-8?q?=F0=9F=93=8C=20PandaPi=20V2.9=20?= =?UTF-8?q?=E2=80=93=20Standalone=20mode=20(#23908)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 1 + Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h | 222 ++++++++++++++++++++ ini/stm32f1.ini | 11 + 4 files changed, 236 insertions(+) create mode 100644 Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 3ec24e7760..d1cc971e51 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -364,6 +364,7 @@ #define BOARD_ZONESTAR_ZM3E4 4061 // Zonestar ZM3E4 V1 (STM32F103VC) #define BOARD_ZONESTAR_ZM3E4V2 4062 // Zonestar ZM3E4 V2 (STM32F103VC) #define BOARD_ERYONE_ERY32_MINI 4063 // Eryone Ery32 mini (STM32F103VE) +#define BOARD_PANDA_PI_V29 4064 // Panda Pi V2.9 - Standalone (STM32F103RC) // // ARM Cortex-M4F diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 7f0eac8c88..426ce1e48e 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -601,6 +601,8 @@ #include "stm32f1/pins_ZM3E4_V2_0.h" // STM32F1 env:STM32F103VE_ZM3E4V2_USB env:STM32F103VE_ZM3E4V2_USB_maple #elif MB(ERYONE_ERY32_MINI) #include "stm32f1/pins_ERYONE_ERY32_MINI.h" // STM32F103VET6 env:ERYONE_ERY32_MINI_maple +#elif MB(PANDA_PI_V29) + #include "stm32f1/pins_PANDA_PI_V29.h" // STM32F103RCT6 env:PANDA_PI_V29 // // ARM Cortex-M4F diff --git a/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h new file mode 100644 index 0000000000..a3c68e644a --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h @@ -0,0 +1,222 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#define BOARD_INFO_NAME "PANDA PI V2.9" + +// Release PB3/PB4 (TMC_SW Pins) from JTAG pins +#define DISABLE_JTAG + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB +#endif + +// +// Servos +// +#define SERVO0_PIN PA11 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PA3 // X-STOP +#define Y_STOP_PIN PC9 // Y-STOP +#define Z_STOP_PIN PA1 // Z-STOP + +// +// Z Probe must be this pin +// +//#define Z_MIN_PROBE_PIN PA1 // PROBE + +// +// Filament Runout Sensor +// +//#ifndef FIL_RUNOUT_PIN +// #define FIL_RUNOUT_PIN PC2 // E0-STOP +//#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC12 +#define X_STEP_PIN PC11 +#define X_DIR_PIN PB6 + +#define Y_ENABLE_PIN PC12 +#define Y_STEP_PIN PB5 +#define Y_DIR_PIN PB4 + +#define Z_ENABLE_PIN PC12 +#define Z_STEP_PIN PB3 +#define Z_DIR_PIN PA15 + +#define E0_ENABLE_PIN PC12 +#define E0_STEP_PIN PB15 +#define E0_DIR_PIN PB14 + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB5 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB4 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB3 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD2 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB0 // Analog Input "TH0" +#define TEMP_BED_PIN PB1 // Analog Input "TB0" +#define TEMP_1_PIN PA2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB12 // "HE" +#define HEATER_BED_PIN PB13 // "HB" +#define FAN_PIN PA8 // "FAN0" +#define HEATER_1_PIN PA12 + +// +// SD Support +// +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card +#define SDSS ONBOARD_SD_CS_PIN + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif +#if SD_CONNECTION_IS(ONBOARD) + //#define SD_DETECT_PIN PA4 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BTN_ENC PA0 + #define BTN_EN1 PC4 + #define BTN_EN2 PC5 + + #define LCD_PINS_RS PC0 + #define LCD_PINS_ENABLE PC2 + #define LCD_PINS_D4 PC1 +#endif + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_E3_DIP.h' for details. Comment out this line to continue." + + /** FYSETC TFT TFT81050 display pinout + * + * Board Display + * ----- ----- + * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) + * (FREE) PB9 | 5 6 PA10 (SD_CS) (PB8) LCD_CS | 5 6 MOSI (SPI1-MOSI) + * RESET | 7 8 | PA9 (MOD_RESET) (PA15) SD_DET | 7 8 | RESET + * (BEEPER) PB6 | 9 10| PA15 (SD_DET) GND | 9 10| 5V + * ----- ----- + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * _________ + * EXP1-1 ----------- EXP1-10 + * EXP1-2 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-4 ----------- EXP1-5 + * SP11-3 ----------- EXP1-2 + * EXP1-6 ----------- EXP1-4 + * EXP1-7 ----------- EXP1-8 + * EXP1-8 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-10 ----------- EXP1-7 + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN PB6 + + #define CLCD_MOD_RESET PA9 + #define CLCD_SPI_CS PB8 + + #if SD_CONNECTION_IS(LCD) && BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + #define SD_DETECT_PIN PA15 + #define SD_SS_PIN PA10 + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN PC3 + +#endif diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 07b75e4e94..9002f81a81 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -73,6 +73,17 @@ build_flags = ${env:STM32F103RC_btt.build_flags} -DUSBD_USE_CDC_MSC build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC +# +# Panda Pi V2.9 - Standalone (STM32F103RC) +# Headless, without direct Pi control, but potentially hosting OctoPrint, stepdaemon, etc. +# +[env:PANDA_PI_V29] +extends = common_STM32F103RC_variant +build_flags = ${common_STM32F103RC_variant.build_flags} + -DTIMER_SERVO=TIM1 +board_build.offset = 0x5000 +board_upload.offset_address = 0x08005000 + # # MKS Robin (STM32F103ZET6) # Uses HAL STM32 to support Marlin UI for TFT screen with optional touch panel From 3c09cf2e5ed8d2fdfea5282a2299d92165fe9d13 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 19 Mar 2022 00:01:41 +0000 Subject: [PATCH 136/203] [cron] Bump distribution date (2022-03-19) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 254604a1d0..e173cfd4db 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-18" +//#define STRING_DISTRIBUTION_DATE "2022-03-19" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index a00587e6df..08a6af4f96 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-18" + #define STRING_DISTRIBUTION_DATE "2022-03-19" #endif /** From 032e5c99369a5d70f9ce1828fb78f2bbd5a6c2a1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 20 Mar 2022 19:12:19 -0500 Subject: [PATCH 137/203] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Misc.=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h index a3c68e644a..7f4aa563b0 100644 --- a/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h +++ b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h @@ -22,7 +22,7 @@ #pragma once #include "env_validate.h" - + #define BOARD_INFO_NAME "PANDA PI V2.9" // Release PB3/PB4 (TMC_SW Pins) from JTAG pins From a8cf2909f79105bfafce207cd3b914e63f5c8545 Mon Sep 17 00:00:00 2001 From: Fredrik Andersson Date: Mon, 21 Mar 2022 02:14:45 +0100 Subject: [PATCH 138/203] =?UTF-8?q?=E2=9C=A8=20Encoder=20button=20noise=20?= =?UTF-8?q?filter=20(#23925)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 83eb332105..b28687ee91 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -680,7 +680,31 @@ public: #endif static void update_buttons(); - static bool button_pressed() { return BUTTON_CLICK() || TERN(TOUCH_SCREEN, touch_pressed(), false); } + + #if HAS_ENCODER_NOISE + #ifndef ENCODER_SAMPLES + #define ENCODER_SAMPLES 10 + #endif + + /** + * Some printers may have issues with EMI noise especially using a motherboard with 3.3V logic levels + * it may cause the logical LOW to float into the undefined region and register as a logical HIGH + * causing it to errorenously register as if someone clicked the button and in worst case make the printer + * unusable in practice. + */ + static bool hw_button_pressed() { + LOOP_L_N(s, ENCODER_SAMPLES) { + if (!BUTTON_CLICK()) return false; + safe_delay(1); + } + return true; + } + #else + static bool hw_button_pressed() { return BUTTON_CLICK(); } + #endif + + static bool button_pressed() { return hw_button_pressed() || TERN0(TOUCH_SCREEN, touch_pressed()); } + #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) static void wait_for_release(); #endif From 10ce88f810f08675140edb6cf248c87ee549855e Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 21 Mar 2022 06:00:58 +0000 Subject: [PATCH 139/203] [cron] Bump distribution date (2022-03-21) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index e173cfd4db..459bbc1b80 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-19" +//#define STRING_DISTRIBUTION_DATE "2022-03-21" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 08a6af4f96..31f031561a 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-19" + #define STRING_DISTRIBUTION_DATE "2022-03-21" #endif /** From 2baf49af93a3bf69be0b77d3a92ee022cd5bfe41 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 15:30:29 -0500 Subject: [PATCH 140/203] =?UTF-8?q?=F0=9F=9A=B8=20Allow=20one=20servo=20wi?= =?UTF-8?q?th=20cutter=20on=20RAMPS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/ramps/pins_RAMPS.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 29caaf0533..c7ef0be99e 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -270,7 +270,7 @@ // M3/M4/M5 - Spindle/Laser Control // #if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN) - #if !NUM_SERVOS // Use servo connector if possible + #if NUM_SERVOS < 2 // Use servo connector if possible #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM #define SPINDLE_DIR_PIN 5 From e183e3814dd455869ee9dc4f09ff3721aed93333 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 23 Mar 2022 00:01:36 +0000 Subject: [PATCH 141/203] [cron] Bump distribution date (2022-03-23) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 459bbc1b80..b34a3c3c64 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-21" +//#define STRING_DISTRIBUTION_DATE "2022-03-23" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 31f031561a..ac7f37f12c 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-21" + #define STRING_DISTRIBUTION_DATE "2022-03-23" #endif /** From ef07c2c8dd431ce4976eba44143cb3686bdc0bf7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 18:11:01 -0500 Subject: [PATCH 142/203] =?UTF-8?q?=F0=9F=94=A8=20Allow=20I2CPE=5FENC=5Fn?= =?UTF-8?q?=5FINVERT=20set=20to=20false?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/encoder_i2c.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index 2ccd686a99..fa14c9ac71 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -489,7 +489,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_1_TICKS_REV); #endif #ifdef I2CPE_ENC_1_INVERT - encoders[i].set_inverted(I2CPE_ENC_1_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_1_INVERT)); #endif #ifdef I2CPE_ENC_1_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_1_EC_METHOD); @@ -518,7 +518,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_2_TICKS_REV); #endif #ifdef I2CPE_ENC_2_INVERT - encoders[i].set_inverted(I2CPE_ENC_2_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_2_INVERT)); #endif #ifdef I2CPE_ENC_2_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_2_EC_METHOD); @@ -547,7 +547,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_3_TICKS_REV); #endif #ifdef I2CPE_ENC_3_INVERT - encoders[i].set_inverted(I2CPE_ENC_3_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_3_INVERT)); #endif #ifdef I2CPE_ENC_3_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_3_EC_METHOD); @@ -576,7 +576,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_4_TICKS_REV); #endif #ifdef I2CPE_ENC_4_INVERT - encoders[i].set_inverted(I2CPE_ENC_4_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_4_INVERT)); #endif #ifdef I2CPE_ENC_4_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_4_EC_METHOD); @@ -605,7 +605,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_5_TICKS_REV); #endif #ifdef I2CPE_ENC_5_INVERT - encoders[i].set_inverted(I2CPE_ENC_5_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_5_INVERT)); #endif #ifdef I2CPE_ENC_5_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_5_EC_METHOD); @@ -634,7 +634,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_6_TICKS_REV); #endif #ifdef I2CPE_ENC_6_INVERT - encoders[i].set_inverted(I2CPE_ENC_6_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_6_INVERT)); #endif #ifdef I2CPE_ENC_6_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_6_EC_METHOD); From d3e3e6a4917969eba85f88e5de0366cc9a2eb4f1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 18:14:17 -0500 Subject: [PATCH 143/203] =?UTF-8?q?=F0=9F=A9=B9=20No=20PE=5FMAGNET=5FON=5F?= =?UTF-8?q?STATE=20without=20PARKING=5FEXTRUDER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/solenoid.cpp | 18 ++++++------------ Marlin/src/feature/solenoid.h | 1 - Marlin/src/gcode/control/M380_M381.cpp | 2 +- Marlin/src/gcode/gcode.h | 4 ++-- Marlin/src/module/tool_change.cpp | 2 +- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Marlin/src/feature/solenoid.cpp b/Marlin/src/feature/solenoid.cpp index b6795d1a1e..f78a529280 100644 --- a/Marlin/src/feature/solenoid.cpp +++ b/Marlin/src/feature/solenoid.cpp @@ -27,17 +27,11 @@ #include "solenoid.h" #include "../module/motion.h" // for active_extruder - -// PARKING_EXTRUDER options alter the default behavior of solenoids, this ensures compliance of M380-381 - -#if ENABLED(PARKING_EXTRUDER) - #include "../module/tool_change.h" -#endif +#include "../module/tool_change.h" // Used primarily with MANUAL_SOLENOID_CONTROL -static void set_solenoid(const uint8_t num, const bool active) { - const uint8_t value = active ? PE_MAGNET_ON_STATE : !PE_MAGNET_ON_STATE; - #define _SOL_CASE(N) case N: TERN_(HAS_SOLENOID_##N, OUT_WRITE(SOL##N##_PIN, value)); break; +static void set_solenoid(const uint8_t num, const uint8_t state) { + #define _SOL_CASE(N) case N: TERN_(HAS_SOLENOID_##N, OUT_WRITE(SOL##N##_PIN, state)); break; switch (num) { REPEAT(8, _SOL_CASE) default: SERIAL_ECHO_MSG(STR_INVALID_SOLENOID); break; @@ -49,9 +43,9 @@ static void set_solenoid(const uint8_t num, const bool active) { #endif } -void enable_solenoid(const uint8_t num) { set_solenoid(num, true); } -void disable_solenoid(const uint8_t num) { set_solenoid(num, false); } -void enable_solenoid_on_active_extruder() { } +// PARKING_EXTRUDER options alter the default behavior of solenoids to ensure compliance of M380-381 +void enable_solenoid(const uint8_t num) { set_solenoid(num, TERN1(PARKING_EXTRUDER, PE_MAGNET_ON_STATE)); } +void disable_solenoid(const uint8_t num) { set_solenoid(num, TERN0(PARKING_EXTRUDER, !PE_MAGNET_ON_STATE)); } void disable_all_solenoids() { #define _SOL_DISABLE(N) TERN_(HAS_SOLENOID_##N, disable_solenoid(N)); diff --git a/Marlin/src/feature/solenoid.h b/Marlin/src/feature/solenoid.h index 2ba4983fb0..3131aeb868 100644 --- a/Marlin/src/feature/solenoid.h +++ b/Marlin/src/feature/solenoid.h @@ -21,7 +21,6 @@ */ #pragma once -void enable_solenoid_on_active_extruder(); void disable_all_solenoids(); void enable_solenoid(const uint8_t num); void disable_solenoid(const uint8_t num); diff --git a/Marlin/src/gcode/control/M380_M381.cpp b/Marlin/src/gcode/control/M380_M381.cpp index 3f5b252465..6bcec891e2 100644 --- a/Marlin/src/gcode/control/M380_M381.cpp +++ b/Marlin/src/gcode/control/M380_M381.cpp @@ -37,7 +37,7 @@ void GcodeSuite::M380() { #if ENABLED(MANUAL_SOLENOID_CONTROL) enable_solenoid(parser.intval('S', active_extruder)); #else - enable_solenoid_on_active_extruder(); + enable_solenoid(active_extruder); #endif } diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 6e331c1273..61fe6cb9d9 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -219,8 +219,8 @@ * M350 - Set microstepping mode. (Requires digital microstepping pins.) * M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.) * M355 - Set Case Light on/off and set brightness. (Requires CASE_LIGHT_PIN) - * M380 - Activate solenoid on active extruder. (Requires EXT_SOLENOID) - * M381 - Disable all solenoids. (Requires EXT_SOLENOID) + * M380 - Activate solenoid on active tool (Requires EXT_SOLENOID) or the tool specified by 'S' (Requires MANUAL_SOLENOID_CONTROL). + * M381 - Disable solenoids on all tools (Requires EXT_SOLENOID) or the tool specified by 'S' (Requires MANUAL_SOLENOID_CONTROL). * M400 - Finish all moves. * M401 - Deploy and activate Z probe. (Requires a probe) * M402 - Deactivate and stow Z probe. (Requires a probe) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index f2767f2b5b..ceed05dcf3 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1292,7 +1292,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER) disable_all_solenoids(); - enable_solenoid_on_active_extruder(); + enable_solenoid(active_extruder); #endif #if HAS_PRUSA_MMU1 From c47c52c146a920f82d7b78e4782c8ce1d715e054 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 18:31:54 -0500 Subject: [PATCH 144/203] =?UTF-8?q?=F0=9F=94=A7=20No=20Switching=20Nozzle?= =?UTF-8?q?=20with=20MMU2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a94846275e..864f759982 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1157,6 +1157,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SWITCHING_NOZZLE and DUAL_X_CARRIAGE are incompatible." #elif ENABLED(SINGLENOZZLE) #error "SWITCHING_NOZZLE and SINGLENOZZLE are incompatible." + #elif HAS_PRUSA_MMU2 + #error "SWITCHING_NOZZLE and PRUSA_MMU2(S) are incompatible." #elif EXTRUDERS != 2 #error "SWITCHING_NOZZLE requires exactly 2 EXTRUDERS." #elif NUM_SERVOS < 1 From 58fcaebe76eabacbe79af3d26661ee1c33146bf2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 18:53:42 -0500 Subject: [PATCH 145/203] =?UTF-8?q?=F0=9F=94=A7=20Sanity-checks=20for=20PU?= =?UTF-8?q?LLDOWN,=20SINGLENOZZLE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 864f759982..74dd77c55c 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -783,11 +783,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if !defined(TARGET_LPC1768) && ANY( \ - ENDSTOPPULLDOWNS, \ - ENDSTOPPULLDOWN_XMAX, ENDSTOPPULLDOWN_YMAX, \ - ENDSTOPPULLDOWN_ZMAX, ENDSTOPPULLDOWN_XMIN, \ - ENDSTOPPULLDOWN_YMIN, ENDSTOPPULLDOWN_ZMIN \ - ) + ENDSTOPPULLDOWNS, ENDSTOPPULLDOWN_ZMIN_PROBE, \ + ENDSTOPPULLDOWN_XMAX, ENDSTOPPULLDOWN_YMAX, ENDSTOPPULLDOWN_ZMAX, \ + ENDSTOPPULLDOWN_XMIN, ENDSTOPPULLDOWN_YMIN, ENDSTOPPULLDOWN_ZMIN, \ + FIL_RUNOUT_PULLDOWN, \ + FIL_RUNOUT1_PULLDOWN, FIL_RUNOUT2_PULLDOWN, FIL_RUNOUT3_PULLDOWN, FIL_RUNOUT4_PULLDOWN, \ + FIL_RUNOUT5_PULLDOWN, FIL_RUNOUT6_PULLDOWN, FIL_RUNOUT7_PULLDOWN, FIL_RUNOUT8_PULLDOWN, \ + POWER_LOSS_PULLDOWN, CALIBRATION_PIN_PULLDOWN \ + ) #error "PULLDOWN pin mode is not available on the selected board." #endif @@ -1146,6 +1149,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(SINGLENOZZLE) #error "SINGLENOZZLE requires 2 or more EXTRUDERS." + #if ENABLED(PID_PARAMS_PER_HOTEND) + #error "PID_PARAMS_PER_HOTEND must be disabled when using any SINGLENOZZLE extruder." + #endif #endif From de8e4361104c31cab943cc321e2055c18272edd6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 19:08:00 -0500 Subject: [PATCH 146/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20neo.set=5Fbackground=5Fcolor(rgbw)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/leds/neopixel.cpp | 8 ++++---- Marlin/src/feature/leds/neopixel.h | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 3569cb180d..4f104234f1 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -44,14 +44,14 @@ Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIX #ifdef NEOPIXEL_BKGD_INDEX_FIRST - void Marlin_NeoPixel::set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - for (int background_led = NEOPIXEL_BKGD_INDEX_FIRST; background_led <= NEOPIXEL_BKGD_INDEX_LAST; background_led++) + void Marlin_NeoPixel::set_background_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w) { + for (int background_led = NEOPIXEL_BKGD_INDEX_FIRST; background_led <= NEOPIXEL_BKGD_INDEX_LAST; background_led++) set_pixel_color(background_led, adaneo1.Color(r, g, b, w)); } void Marlin_NeoPixel::reset_background_color() { constexpr uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR; - set_background_color(background_color[0], background_color[1], background_color[2], background_color[3]); + set_background_color(background_color); } #endif @@ -108,7 +108,7 @@ void Marlin_NeoPixel::init() { set_color(adaneo1.Color TERN(LED_USER_PRESET_STARTUP, (LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE), - (0, 0, 0, 0)) + (255, 255, 255, 255)) ); } diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 1a38ed1a19..d71aa25770 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -88,7 +88,8 @@ public: static void set_color(const uint32_t c); #ifdef NEOPIXEL_BKGD_INDEX_FIRST - static void set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w); + static void set_background_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w); + static void set_background_color(const uint8_t (&rgbw)[4]) { set_background_color(rgbw[0], rgbw[1], rgbw[2], rgbw[3]); } static void reset_background_color(); #endif From 98dcb9e614a4cc81d7f33d91f02de1d55bc7b3e6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 19:20:19 -0500 Subject: [PATCH 147/203] =?UTF-8?q?=F0=9F=94=A8=20Suppress=20MMU2=20resume?= =?UTF-8?q?=5Fposition=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/mmu/mmu2.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 28dea681ef..7a7e27f287 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -821,6 +821,9 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { LCD_MESSAGE(MSG_MMU2_RESUMING); ATTN_BUZZ(true); + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + if (move_axes && all_axes_homed()) { // Move XY to starting position, then Z do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE)); @@ -828,6 +831,8 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { // Move Z_AXIS to saved position do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); } + + #pragma GCC diagnostic pop } } } From 258a2ed112da097969d36187b53805df7f98a3ec Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 19:17:12 -0500 Subject: [PATCH 148/203] =?UTF-8?q?=F0=9F=8E=A8=20Apply=20=5FTERN=20where?= =?UTF-8?q?=20possible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/calibrate/G28.cpp | 28 +++--- .../src/gcode/feature/trinamic/M911-M914.cpp | 88 +++++-------------- Marlin/src/inc/SanityCheck.h | 4 +- Marlin/src/module/motion.cpp | 40 +++------ Marlin/src/module/stepper/trinamic.cpp | 55 +++--------- 5 files changed, 57 insertions(+), 158 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 9361790d74..681df55f20 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -82,15 +82,13 @@ #if ENABLED(SENSORLESS_HOMING) sensorless_t stealth_states { - LINEAR_AXIS_LIST(tmc_enable_stallguard(stepperX), tmc_enable_stallguard(stepperY), false, false, false, false) - , false - #if AXIS_HAS_STALLGUARD(X2) - || tmc_enable_stallguard(stepperX2) - #endif - , false - #if AXIS_HAS_STALLGUARD(Y2) - || tmc_enable_stallguard(stepperY2) - #endif + LINEAR_AXIS_LIST( + TERN0(X_SENSORLESS, tmc_enable_stallguard(stepperX)), + TERN0(Y_SENSORLESS, tmc_enable_stallguard(stepperY)), + false, false, false, false + ) + , TERN0(X2_SENSORLESS, tmc_enable_stallguard(stepperX2)) + , TERN0(Y2_SENSORLESS, tmc_enable_stallguard(stepperY2)) }; #endif @@ -101,14 +99,10 @@ current_position.set(0.0, 0.0); #if ENABLED(SENSORLESS_HOMING) && DISABLED(ENDSTOPS_ALWAYS_ON_DEFAULT) - tmc_disable_stallguard(stepperX, stealth_states.x); - tmc_disable_stallguard(stepperY, stealth_states.y); - #if AXIS_HAS_STALLGUARD(X2) - tmc_disable_stallguard(stepperX2, stealth_states.x2); - #endif - #if AXIS_HAS_STALLGUARD(Y2) - tmc_disable_stallguard(stepperY2, stealth_states.y2); - #endif + TERN_(X_SENSORLESS, tmc_disable_stallguard(stepperX, stealth_states.x)); + TERN_(X2_SENSORLESS, tmc_disable_stallguard(stepperX2, stealth_states.x2)); + TERN_(Y_SENSORLESS, tmc_disable_stallguard(stepperY, stealth_states.y)); + TERN_(Y2_SENSORLESS, tmc_disable_stallguard(stepperY2, stealth_states.y2)); #endif } diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index b37c81733c..57a77c0e5d 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -457,92 +457,48 @@ switch (i) { #if X_SENSORLESS case X_AXIS: - #if AXIS_HAS_STALLGUARD(X) - if (index < 2) stepperX.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(X2) - if (!(index & 1)) stepperX2.homing_threshold(value); - #endif + if (index < 2) stepperX.homing_threshold(value); + TERN_(X2_SENSORLESS, if (!(index & 1)) stepperX2.homing_threshold(value)); break; #endif #if Y_SENSORLESS case Y_AXIS: - #if AXIS_HAS_STALLGUARD(Y) - if (index < 2) stepperY.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(Y2) - if (!(index & 1)) stepperY2.homing_threshold(value); - #endif + if (index < 2) stepperY.homing_threshold(value); + TERN_(Y2_SENSORLESS, if (!(index & 1)) stepperY2.homing_threshold(value)); break; #endif #if Z_SENSORLESS case Z_AXIS: - #if AXIS_HAS_STALLGUARD(Z) - if (index < 2) stepperZ.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(Z2) - if (index == 0 || index == 2) stepperZ2.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - if (index == 0 || index == 3) stepperZ3.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - if (index == 0 || index == 4) stepperZ4.homing_threshold(value); - #endif + if (index < 2) stepperZ.homing_threshold(value); + TERN_(Z2_SENSORLESS, if (index == 0 || index == 2) stepperZ2.homing_threshold(value)); + TERN_(Z3_SENSORLESS, if (index == 0 || index == 3) stepperZ3.homing_threshold(value)); + TERN_(Z4_SENSORLESS, if (index == 0 || index == 4) stepperZ4.homing_threshold(value)); break; #endif - #if I_SENSORLESS && AXIS_HAS_STALLGUARD(I) + #if I_SENSORLESS case I_AXIS: stepperI.homing_threshold(value); break; #endif - #if J_SENSORLESS && AXIS_HAS_STALLGUARD(J) + #if J_SENSORLESS case J_AXIS: stepperJ.homing_threshold(value); break; #endif - #if K_SENSORLESS && AXIS_HAS_STALLGUARD(K) + #if K_SENSORLESS case K_AXIS: stepperK.homing_threshold(value); break; #endif } } if (report) { - #if X_SENSORLESS - #if AXIS_HAS_STALLGUARD(X) - tmc_print_sgt(stepperX); - #endif - #if AXIS_HAS_STALLGUARD(X2) - tmc_print_sgt(stepperX2); - #endif - #endif - #if Y_SENSORLESS - #if AXIS_HAS_STALLGUARD(Y) - tmc_print_sgt(stepperY); - #endif - #if AXIS_HAS_STALLGUARD(Y2) - tmc_print_sgt(stepperY2); - #endif - #endif - #if Z_SENSORLESS - #if AXIS_HAS_STALLGUARD(Z) - tmc_print_sgt(stepperZ); - #endif - #if AXIS_HAS_STALLGUARD(Z2) - tmc_print_sgt(stepperZ2); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - tmc_print_sgt(stepperZ3); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - tmc_print_sgt(stepperZ4); - #endif - #endif - #if I_SENSORLESS && AXIS_HAS_STALLGUARD(I) - tmc_print_sgt(stepperI); - #endif - #if J_SENSORLESS && AXIS_HAS_STALLGUARD(J) - tmc_print_sgt(stepperJ); - #endif - #if K_SENSORLESS && AXIS_HAS_STALLGUARD(K) - tmc_print_sgt(stepperK); - #endif + TERN_(X_SENSORLESS, tmc_print_sgt(stepperX)); + TERN_(X2_SENSORLESS, tmc_print_sgt(stepperX2)); + TERN_(Y_SENSORLESS, tmc_print_sgt(stepperY)); + TERN_(Y2_SENSORLESS, tmc_print_sgt(stepperY2)); + TERN_(Z_SENSORLESS, tmc_print_sgt(stepperZ)); + TERN_(Z2_SENSORLESS, tmc_print_sgt(stepperZ2)); + TERN_(Z3_SENSORLESS, tmc_print_sgt(stepperZ3)); + TERN_(Z4_SENSORLESS, tmc_print_sgt(stepperZ4)); + TERN_(I_SENSORLESS, tmc_print_sgt(stepperI)); + TERN_(J_SENSORLESS, tmc_print_sgt(stepperJ)); + TERN_(K_SENSORLESS, tmc_print_sgt(stepperK)); } } diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 74dd77c55c..617d117415 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1655,9 +1655,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Require pin options and pins to be defined */ #if ENABLED(SENSORLESS_PROBING) - #if ENABLED(DELTA) && !(AXIS_HAS_STALLGUARD(X) && AXIS_HAS_STALLGUARD(Y) && AXIS_HAS_STALLGUARD(Z)) + #if ENABLED(DELTA) && !(X_SENSORLESS && Y_SENSORLESS && Z_SENSORLESS) #error "SENSORLESS_PROBING requires TMC2130/2160/2209/5130/5160 drivers on X, Y, and Z." - #elif !AXIS_HAS_STALLGUARD(Z) + #elif !Z_SENSORLESS #error "SENSORLESS_PROBING requires a TMC2130/2160/2209/5130/5160 driver on Z." #endif #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 0f8e02db9e..7b1e0a3fb9 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1359,9 +1359,7 @@ void prepare_line_to_destination() { #if X_SENSORLESS case X_AXIS: stealth_states.x = tmc_enable_stallguard(stepperX); - #if AXIS_HAS_STALLGUARD(X2) - stealth_states.x2 = tmc_enable_stallguard(stepperX2); - #endif + TERN_(X2_SENSORLESS, stealth_states.x2 = tmc_enable_stallguard(stepperX2)); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS stealth_states.y = tmc_enable_stallguard(stepperY); #elif CORE_IS_XZ && Z_SENSORLESS @@ -1372,9 +1370,7 @@ void prepare_line_to_destination() { #if Y_SENSORLESS case Y_AXIS: stealth_states.y = tmc_enable_stallguard(stepperY); - #if AXIS_HAS_STALLGUARD(Y2) - stealth_states.y2 = tmc_enable_stallguard(stepperY2); - #endif + TERN_(Y2_SENSORLESS, stealth_states.y2 = tmc_enable_stallguard(stepperY2)); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS stealth_states.x = tmc_enable_stallguard(stepperX); #elif CORE_IS_YZ && Z_SENSORLESS @@ -1385,15 +1381,9 @@ void prepare_line_to_destination() { #if Z_SENSORLESS case Z_AXIS: stealth_states.z = tmc_enable_stallguard(stepperZ); - #if AXIS_HAS_STALLGUARD(Z2) - stealth_states.z2 = tmc_enable_stallguard(stepperZ2); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - stealth_states.z3 = tmc_enable_stallguard(stepperZ3); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - stealth_states.z4 = tmc_enable_stallguard(stepperZ4); - #endif + TERN_(Z2_SENSORLESS, stealth_states.z2 = tmc_enable_stallguard(stepperZ2)); + TERN_(Z3_SENSORLESS, stealth_states.z3 = tmc_enable_stallguard(stepperZ3)); + TERN_(Z4_SENSORLESS, stealth_states.z4 = tmc_enable_stallguard(stepperZ4)); #if CORE_IS_XZ && X_SENSORLESS stealth_states.x = tmc_enable_stallguard(stepperX); #elif CORE_IS_YZ && Y_SENSORLESS @@ -1445,9 +1435,7 @@ void prepare_line_to_destination() { #if X_SENSORLESS case X_AXIS: tmc_disable_stallguard(stepperX, enable_stealth.x); - #if AXIS_HAS_STALLGUARD(X2) - tmc_disable_stallguard(stepperX2, enable_stealth.x2); - #endif + TERN_(X2_SENSORLESS, tmc_disable_stallguard(stepperX2, enable_stealth.x2)); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS tmc_disable_stallguard(stepperY, enable_stealth.y); #elif CORE_IS_XZ && Z_SENSORLESS @@ -1458,9 +1446,7 @@ void prepare_line_to_destination() { #if Y_SENSORLESS case Y_AXIS: tmc_disable_stallguard(stepperY, enable_stealth.y); - #if AXIS_HAS_STALLGUARD(Y2) - tmc_disable_stallguard(stepperY2, enable_stealth.y2); - #endif + TERN_(Y2_SENSORLESS, tmc_disable_stallguard(stepperY2, enable_stealth.y2)); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS tmc_disable_stallguard(stepperX, enable_stealth.x); #elif CORE_IS_YZ && Z_SENSORLESS @@ -1471,15 +1457,9 @@ void prepare_line_to_destination() { #if Z_SENSORLESS case Z_AXIS: tmc_disable_stallguard(stepperZ, enable_stealth.z); - #if AXIS_HAS_STALLGUARD(Z2) - tmc_disable_stallguard(stepperZ2, enable_stealth.z2); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - tmc_disable_stallguard(stepperZ3, enable_stealth.z3); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - tmc_disable_stallguard(stepperZ4, enable_stealth.z4); - #endif + TERN_(Z2_SENSORLESS, tmc_disable_stallguard(stepperZ2, enable_stealth.z2)); + TERN_(Z3_SENSORLESS, tmc_disable_stallguard(stepperZ3, enable_stealth.z3)); + TERN_(Z4_SENSORLESS, tmc_disable_stallguard(stepperZ4, enable_stealth.z4)); #if CORE_IS_XZ && X_SENSORLESS tmc_disable_stallguard(stepperX, enable_stealth.x); #elif CORE_IS_YZ && Y_SENSORLESS diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index 7baa2108f0..af09623dc1 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -906,49 +906,18 @@ void reset_trinamic_drivers() { #endif #if USE_SENSORLESS - #if X_SENSORLESS - stepperX.homing_threshold(X_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(X2) - stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY)); - #endif - #endif - #if Y_SENSORLESS - stepperY.homing_threshold(Y_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(Y2) - stepperY2.homing_threshold(CAT(TERN(Y2_SENSORLESS, Y2, Y), _STALL_SENSITIVITY)); - #endif - #endif - #if Z_SENSORLESS - stepperZ.homing_threshold(Z_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(Z2) - stepperZ2.homing_threshold(CAT(TERN(Z2_SENSORLESS, Z2, Z), _STALL_SENSITIVITY)); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - stepperZ3.homing_threshold(CAT(TERN(Z3_SENSORLESS, Z3, Z), _STALL_SENSITIVITY)); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY)); - #endif - #endif - #if I_SENSORLESS - stepperI.homing_threshold(I_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(I) - stepperI.homing_threshold(CAT(TERN(I_SENSORLESS, I, I), _STALL_SENSITIVITY)); - #endif - #endif - #if J_SENSORLESS - stepperJ.homing_threshold(J_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(J) - stepperJ.homing_threshold(CAT(TERN(J_SENSORLESS, J, J), _STALL_SENSITIVITY)); - #endif - #endif - #if K_SENSORLESS - stepperK.homing_threshold(K_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(K) - stepperK.homing_threshold(CAT(TERN(K_SENSORLESS, K, K), _STALL_SENSITIVITY)); - #endif - #endif - #endif // USE SENSORLESS + TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY)); + TERN_(X2_SENSORLESS, stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY))); + TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY)); + TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(CAT(TERN(Y2_SENSORLESS, Y2, Y), _STALL_SENSITIVITY))); + TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY)); + TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(CAT(TERN(Z2_SENSORLESS, Z2, Z), _STALL_SENSITIVITY))); + TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(CAT(TERN(Z3_SENSORLESS, Z3, Z), _STALL_SENSITIVITY))); + TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY))); + TERN_(I_SENSORLESS, stepperI.homing_threshold(I_STALL_SENSITIVITY)); + TERN_(J_SENSORLESS, stepperJ.homing_threshold(J_STALL_SENSITIVITY)); + TERN_(K_SENSORLESS, stepperK.homing_threshold(K_STALL_SENSITIVITY)); + #endif #ifdef TMC_ADV TMC_ADV() From 92d3a038c20747999a402924640f7d0c4ef377f8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 19:56:07 -0500 Subject: [PATCH 149/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20PIO?= =?UTF-8?q?=20--silent=20in=20build=5Fexample?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/bin/build_example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/bin/build_example b/buildroot/bin/build_example index 8ebb58f972..cff8ea253e 100755 --- a/buildroot/bin/build_example +++ b/buildroot/bin/build_example @@ -24,6 +24,6 @@ cp "$SUB"/_Statusscreen.h Marlin/ 2>/dev/null echo "Building the firmware now..." HERE=`dirname "$0"` -$HERE/mftest -a -n1 || { echo "Failed"; exit 1; } +$HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; } echo "Success" From a63205a034180fdc515818ce8bad789b82da9d01 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 20:11:10 -0500 Subject: [PATCH 150/203] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20ADC=20math=20overf?= =?UTF-8?q?low?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 786a865049..11b523ff53 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1206,7 +1206,7 @@ void MarlinUI::init() { #define ADC_BUTTON_VALUE(r) raw_adc_t(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) static constexpr raw_adc_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, - adc_other_button = HAL_ADC_RANGE * 1000 / 1024; + adc_other_button = raw_adc_t(uint32_t(HAL_ADC_RANGE * 1000UL) / 1024UL); static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = { // VALUE_MIN, VALUE_MAX, KEY { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F1 }, // F1 From e458aa41fcbc817a21a0376e5dc36c0a0b755c47 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 20:11:58 -0500 Subject: [PATCH 151/203] =?UTF-8?q?=F0=9F=94=A8=20Fix=20'mftest=20-s'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/bin/mftest | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 77e53ff9ac..9aa5e12732 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -17,6 +17,7 @@ usage() { Usage: mftest [-t|--env=] [-n|--num=] [-m|--make] [-y|--build=] mftest [-a|--autobuild] mftest [-r|--rebuild] + mftest [-s|--silent] mftest [-u|--autoupload] [-n|--num=] OPTIONS @@ -30,7 +31,7 @@ OPTIONS -v --verbose Extra output for debugging. -s --silent Silence build output from PlatformIO. -env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41 +env shortcuts: tree due esp lin lp8|lpc8 lp9|lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41 " } @@ -52,7 +53,7 @@ TESTENV='-' CHOICE=0 DEBUG=0 -while getopts 'abhmruvyn:t:-:' OFLAG; do +while getopts 'abhmrsuvyn:t:-:' OFLAG; do case "${OFLAG}" in a) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;; h) EXIT_USAGE=1 ;; @@ -84,6 +85,7 @@ while getopts 'abhmruvyn:t:-:' OFLAG; do esac ;; rebuild) REBUILD=1 ; bugout "Rebuilding previous..." ;; + silent) SILENT_FLAG="-s" ;; make) USE_MAKE=1 ; bugout "Using make with Docker..." ;; debug|verbose) DEBUG=1 ; bugout "Debug ON" ;; build) case "$OVAL" in From 8ba6e8a74d1ddd963881dcd77e26a5dc0a7b6096 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 20:31:36 -0500 Subject: [PATCH 152/203] =?UTF-8?q?=F0=9F=8E=A8=20Clean=20up=20tool=20chan?= =?UTF-8?q?ge=20with=20tool=20sensor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/tool_change.cpp | 98 +++++++++++++++---------------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index ceed05dcf3..26815642db 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -385,65 +385,59 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif // PARKING_EXTRUDER -#if ENABLED(SWITCHING_TOOLHEAD) +#if ENABLED(TOOL_SENSOR) + + bool tool_sensor_disabled; // = false // Return a bitmask of tool sensor states inline uint8_t poll_tool_sensor_pins() { return (0 - #if ENABLED(TOOL_SENSOR) - #if PIN_EXISTS(TOOL_SENSOR1) - | (READ(TOOL_SENSOR1_PIN) << 0) - #endif - #if PIN_EXISTS(TOOL_SENSOR2) - | (READ(TOOL_SENSOR2_PIN) << 1) - #endif - #if PIN_EXISTS(TOOL_SENSOR3) - | (READ(TOOL_SENSOR3_PIN) << 2) - #endif - #if PIN_EXISTS(TOOL_SENSOR4) - | (READ(TOOL_SENSOR4_PIN) << 3) - #endif - #if PIN_EXISTS(TOOL_SENSOR5) - | (READ(TOOL_SENSOR5_PIN) << 4) - #endif - #if PIN_EXISTS(TOOL_SENSOR6) - | (READ(TOOL_SENSOR6_PIN) << 5) - #endif - #if PIN_EXISTS(TOOL_SENSOR7) - | (READ(TOOL_SENSOR7_PIN) << 6) - #endif - #if PIN_EXISTS(TOOL_SENSOR8) - | (READ(TOOL_SENSOR8_PIN) << 7) - #endif + #if PIN_EXISTS(TOOL_SENSOR1) + | (READ(TOOL_SENSOR1_PIN) << 0) + #endif + #if PIN_EXISTS(TOOL_SENSOR2) + | (READ(TOOL_SENSOR2_PIN) << 1) + #endif + #if PIN_EXISTS(TOOL_SENSOR3) + | (READ(TOOL_SENSOR3_PIN) << 2) + #endif + #if PIN_EXISTS(TOOL_SENSOR4) + | (READ(TOOL_SENSOR4_PIN) << 3) + #endif + #if PIN_EXISTS(TOOL_SENSOR5) + | (READ(TOOL_SENSOR5_PIN) << 4) + #endif + #if PIN_EXISTS(TOOL_SENSOR6) + | (READ(TOOL_SENSOR6_PIN) << 5) + #endif + #if PIN_EXISTS(TOOL_SENSOR7) + | (READ(TOOL_SENSOR7_PIN) << 6) + #endif + #if PIN_EXISTS(TOOL_SENSOR8) + | (READ(TOOL_SENSOR8_PIN) << 7) #endif ); } - #if ENABLED(TOOL_SENSOR) - - bool tool_sensor_disabled; // = false - - uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) { - static uint8_t sensor_tries; // = 0 - for (;;) { - if (poll_tool_sensor_pins() == _BV(tool_index)) { - sensor_tries = 0; - return tool_index; - } - else if (kill_on_error && (!tool_sensor_disabled || disable)) { - sensor_tries++; - if (sensor_tries > 10) kill(F("Tool Sensor error")); - safe_delay(5); - } - else { - sensor_tries++; - if (sensor_tries > 10) return -1; - safe_delay(5); - } + uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) { + static uint8_t sensor_tries; // = 0 + for (;;) { + if (poll_tool_sensor_pins() == _BV(tool_index)) { + sensor_tries = 0; + return tool_index; + } + else if (kill_on_error && (!tool_sensor_disabled || disable)) { + sensor_tries++; + if (sensor_tries > 10) kill(F("Tool Sensor error")); + safe_delay(5); + } + else { + sensor_tries++; + if (sensor_tries > 10) return -1; + safe_delay(5); } } - - #endif + } inline void switching_toolhead_lock(const bool locked) { #ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES @@ -496,9 +490,13 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. switching_toolhead_lock(true); } LCD_MESSAGE_F("TC Success"); - #endif + #endif // TOOL_SENSOR } +#endif // TOOL_SENSOR + +#if ENABLED(SWITCHING_TOOLHEAD) + inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (no_move) return; From a80a303cbe057b02e8d9cd29bc94c161e48784f1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 22:22:08 -0500 Subject: [PATCH 153/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20EXT?= =?UTF-8?q?RUDER=5FLOOP=20macro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/fwretract.cpp | 20 ++++++++++---------- Marlin/src/feature/fwretract.h | 2 +- Marlin/src/feature/powerloss.cpp | 10 +++++----- Marlin/src/gcode/config/M200-M205.cpp | 6 +++--- Marlin/src/gcode/control/M17_M18_M84.cpp | 6 +++--- Marlin/src/gcode/feature/advance/M900.cpp | 18 +++++++++--------- Marlin/src/gcode/feature/pause/M603.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 1 + Marlin/src/lcd/menu/menu_advanced.cpp | 20 ++++++++++---------- Marlin/src/lcd/menu/menu_configuration.cpp | 6 +++--- Marlin/src/lcd/menu/menu_mmu2.cpp | 10 +++++----- Marlin/src/lcd/menu/menu_tune.cpp | 8 ++++---- Marlin/src/module/planner.cpp | 2 +- Marlin/src/module/planner.h | 4 ++-- Marlin/src/module/settings.cpp | 8 ++++---- 15 files changed, 62 insertions(+), 61 deletions(-) diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 4077d8d1c2..bf47a6b2d5 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -73,10 +73,10 @@ void FWRetract::reset() { settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP; current_hop = 0.0; - LOOP_L_N(i, EXTRUDERS) { - retracted[i] = false; - E_TERN_(retracted_swap[i] = false); - current_retract[i] = 0.0; + EXTRUDER_LOOP() { + retracted[e] = false; + E_TERN_(retracted_swap[e] = false); + current_retract[e] = 0.0; } } @@ -111,10 +111,10 @@ void FWRetract::retract(const bool retracting E_OPTARG(bool swapping/*=false*/)) " swapping ", swapping, " active extruder ", active_extruder ); - LOOP_L_N(i, EXTRUDERS) { - SERIAL_ECHOLNPGM("retracted[", i, "] ", AS_DIGIT(retracted[i])); + EXTRUDER_LOOP() { + SERIAL_ECHOLNPGM("retracted[", e, "] ", AS_DIGIT(retracted[e])); #if HAS_MULTI_EXTRUDER - SERIAL_ECHOLNPGM("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i])); + SERIAL_ECHOLNPGM("retracted_swap[", e, "] ", AS_DIGIT(retracted_swap[e])); #endif } SERIAL_ECHOLNPGM("current_position.z ", current_position.z); @@ -184,10 +184,10 @@ void FWRetract::retract(const bool retracting E_OPTARG(bool swapping/*=false*/)) SERIAL_ECHOLNPGM("retracting ", AS_DIGIT(retracting)); SERIAL_ECHOLNPGM("swapping ", AS_DIGIT(swapping)); SERIAL_ECHOLNPGM("active_extruder ", active_extruder); - LOOP_L_N(i, EXTRUDERS) { - SERIAL_ECHOLNPGM("retracted[", i, "] ", AS_DIGIT(retracted[i])); + EXTRUDER_LOOP() { + SERIAL_ECHOLNPGM("retracted[", e, "] ", AS_DIGIT(retracted[e])); #if HAS_MULTI_EXTRUDER - SERIAL_ECHOLNPGM("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i])); + SERIAL_ECHOLNPGM("retracted_swap[", e, "] ", AS_DIGIT(retracted_swap[e])); #endif } SERIAL_ECHOLNPGM("current_position.z ", current_position.z); diff --git a/Marlin/src/feature/fwretract.h b/Marlin/src/feature/fwretract.h index d6d0432e3a..081ec44c05 100644 --- a/Marlin/src/feature/fwretract.h +++ b/Marlin/src/feature/fwretract.h @@ -64,7 +64,7 @@ public: static void reset(); static void refresh_autoretract() { - LOOP_L_N(i, EXTRUDERS) retracted[i] = false; + EXTRUDER_LOOP() retracted[e] = false; } static void enable_autoretract(const bool enable) { diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 214c248d35..74008ed55a 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -196,7 +196,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW #if DISABLED(NO_VOLUMETRICS) info.flag.volumetric_enabled = parser.volumetric_enabled; #if HAS_MULTI_EXTRUDER - for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e]; + EXTRUDER_LOOP() info.filament_size[e] = planner.filament_size[e]; #else if (parser.volumetric_enabled) info.filament_size[0] = planner.filament_size[active_extruder]; #endif @@ -461,7 +461,7 @@ void PrintJobRecovery::resume() { // Recover volumetric extrusion state #if DISABLED(NO_VOLUMETRICS) #if HAS_MULTI_EXTRUDER - for (int8_t e = 0; e < EXTRUDERS; e++) { + EXTRUDER_LOOP() { sprintf_P(cmd, PSTR("M200T%iD%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1)); gcode.process_subcommands_now(cmd); } @@ -511,7 +511,7 @@ void PrintJobRecovery::resume() { // Restore retract and hop state from an active `G10` command #if ENABLED(FWRETRACT) - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { if (info.retract[e] != 0.0) { fwretract.current_retract[e] = info.retract[e]; fwretract.retracted[e] = true; @@ -634,7 +634,7 @@ void PrintJobRecovery::resume() { #if DISABLED(NO_VOLUMETRICS) DEBUG_ECHOPGM("filament_size:"); - LOOP_L_N(i, EXTRUDERS) DEBUG_ECHOLNPGM(" ", info.filament_size[i]); + EXTRUDER_LOOP() DEBUG_ECHOLNPGM(" ", info.filament_size[e]); DEBUG_EOL(); #endif @@ -666,7 +666,7 @@ void PrintJobRecovery::resume() { #if ENABLED(FWRETRACT) DEBUG_ECHOPGM("retract: "); - for (int8_t e = 0; e < EXTRUDERS; e++) { + EXTRUDER_LOOP() { DEBUG_ECHO(info.retract[e]); if (e < EXTRUDERS - 1) DEBUG_CHAR(','); } diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index 9490e3c625..fb4c9b8af3 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -93,12 +93,12 @@ } #else SERIAL_ECHOLNPGM(" M200 S", parser.volumetric_enabled); - LOOP_L_N(i, EXTRUDERS) { + EXTRUDER_LOOP() { report_echo_start(forReplay); SERIAL_ECHOLNPGM( - " M200 T", i, " D", LINEAR_UNIT(planner.filament_size[i]) + " M200 T", e, " D", LINEAR_UNIT(planner.filament_size[e]) #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[i]) + , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[e]) #endif ); } diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 4683786f1f..3bc5582ce7 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -77,7 +77,7 @@ void do_enable(const axis_flags_t to_enable) { } } #if HAS_EXTRUDERS - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { const uint8_t a = INDEX_OF_AXIS(E_AXIS, e); if (TEST(shall_enable, a)) { stepper.ENABLE_EXTRUDER(e); @@ -161,7 +161,7 @@ void try_to_disable(const axis_flags_t to_disable) { DEBUG_ECHOLNPGM(" ... still_enabled=", hex_word(still_enabled)); } #if HAS_EXTRUDERS - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { const uint8_t a = INDEX_OF_AXIS(E_AXIS, e); if (TEST(to_disable.bits, a)) { DEBUG_ECHOPGM("Try to disable E", AS_DIGIT(e), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... "); @@ -194,7 +194,7 @@ void try_to_disable(const axis_flags_t to_disable) { } } #if HAS_EXTRUDERS - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { const uint8_t a = INDEX_OF_AXIS(E_AXIS, e); if (TEST(still_enabled, a)) { SERIAL_CHAR('E', '0' + e); diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 054ea3617f..8b59e88fb1 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -117,10 +117,10 @@ void GcodeSuite::M900() { #if EXTRUDERS < 2 SERIAL_ECHOLNPGM("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")"); #else - LOOP_L_N(i, EXTRUDERS) { - const bool slot = TEST(lin_adv_slot, i); - SERIAL_ECHOLNPGM("Advance T", i, " S", slot, " K", planner.extruder_advance_K[i], - "(S", !slot, " K", other_extruder_advance_K[i], ")"); + EXTRUDER_LOOP() { + const bool slot = TEST(lin_adv_slot, e); + SERIAL_ECHOLNPGM("Advance T", e, " S", slot, " K", planner.extruder_advance_K[e], + "(S", !slot, " K", other_extruder_advance_K[e], ")"); SERIAL_EOL(); } #endif @@ -132,9 +132,9 @@ void GcodeSuite::M900() { SERIAL_ECHOLNPGM("Advance K=", planner.extruder_advance_K[0]); #else SERIAL_ECHOPGM("Advance K"); - LOOP_L_N(i, EXTRUDERS) { - SERIAL_CHAR(' ', '0' + i, ':'); - SERIAL_DECIMAL(planner.extruder_advance_K[i]); + EXTRUDER_LOOP() { + SERIAL_CHAR(' ', '0' + e, ':'); + SERIAL_DECIMAL(planner.extruder_advance_K[e]); } SERIAL_EOL(); #endif @@ -150,9 +150,9 @@ void GcodeSuite::M900_report(const bool forReplay/*=true*/) { report_echo_start(forReplay); SERIAL_ECHOLNPGM(" M900 K", planner.extruder_advance_K[0]); #else - LOOP_L_N(i, EXTRUDERS) { + EXTRUDER_LOOP() { report_echo_start(forReplay); - SERIAL_ECHOLNPGM(" M900 T", i, " K", planner.extruder_advance_K[i]); + SERIAL_ECHOLNPGM(" M900 T", e, " K", planner.extruder_advance_K[e]); } #endif } diff --git a/Marlin/src/gcode/feature/pause/M603.cpp b/Marlin/src/gcode/feature/pause/M603.cpp index 6689749cfb..10d14012f8 100644 --- a/Marlin/src/gcode/feature/pause/M603.cpp +++ b/Marlin/src/gcode/feature/pause/M603.cpp @@ -72,7 +72,7 @@ void GcodeSuite::M603_report(const bool forReplay/*=true*/) { SERIAL_ECHOPGM(" M603 L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length), " ;"); say_units(); #else - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { report_echo_start(forReplay); SERIAL_ECHOPGM(" M603 T", e, " L", LINEAR_UNIT(fc_settings[e].load_length), " U", LINEAR_UNIT(fc_settings[e].unload_length), " ;"); say_units(); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 33d9e46220..e7473420cf 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -749,6 +749,7 @@ #endif // Helper macros for extruder and hotend arrays +#define EXTRUDER_LOOP() for (int8_t e = 0; e < EXTRUDERS; e++) #define HOTEND_LOOP() for (int8_t e = 0; e < HOTENDS; e++) #define ARRAY_BY_EXTRUDERS(V...) ARRAY_N(EXTRUDERS, V) #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_N_1(EXTRUDERS, v1) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 1bc9b9e88e..eb979a4319 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -109,8 +109,8 @@ void menu_backlash(); #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); #elif HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10); + EXTRUDER_LOOP() + EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif #endif @@ -120,16 +120,16 @@ void menu_backlash(); #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) EDIT_ITEM_FAST(float42_52, MSG_VOLUMETRIC_LIMIT, &planner.volumetric_extruder_limit[active_extruder], 0.0f, 20.0f, planner.calculate_volumetric_extruder_limits); #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_FAST_N(float42_52, n, MSG_VOLUMETRIC_LIMIT_E, &planner.volumetric_extruder_limit[n], 0.0f, 20.00f, planner.calculate_volumetric_extruder_limits); + EXTRUDER_LOOP() + EDIT_ITEM_FAST_N(float42_52, e, MSG_VOLUMETRIC_LIMIT_E, &planner.volumetric_extruder_limit[e], 0.0f, 20.00f, planner.calculate_volumetric_extruder_limits); #endif #endif if (parser.volumetric_enabled) { EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); + EXTRUDER_LOOP() + EDIT_ITEM_FAST_N(float43, e, MSG_FILAMENT_DIAM_E, &planner.filament_size[e], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); #endif } #endif @@ -139,14 +139,14 @@ void menu_backlash(); EDIT_ITEM_FAST(float4, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength); #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_FAST_N(float4, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength); + EXTRUDER_LOOP() + EDIT_ITEM_FAST_N(float4, e, MSG_FILAMENTUNLOAD_E, &fc_settings[e].unload_length, 0, extrude_maxlength); #endif EDIT_ITEM_FAST(float4, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength); #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_FAST_N(float4, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength); + EXTRUDER_LOOP() + EDIT_ITEM_FAST_N(float4, e, MSG_FILAMENTLOAD_E, &fc_settings[e].load_length, 0, extrude_maxlength); #endif #endif diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index b4e9287bd4..b6d518f505 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -145,9 +145,9 @@ void menu_advanced_settings(); EDIT_ITEM(uint8, MSG_TOOL_MIGRATION_END, &migration.last, 0, EXTRUDERS - 1); // Migrate to a chosen extruder - LOOP_L_N(s, EXTRUDERS) { - if (s != active_extruder) { - ACTION_ITEM_N_P(s, msg_migrate, []{ + EXTRUDER_LOOP() { + if (e != active_extruder) { + ACTION_ITEM_N_P(e, msg_migrate, []{ char cmd[12]; sprintf_P(cmd, PSTR("M217 T%i"), int(MenuItemBase::itemIndex)); queue.inject(cmd); diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index 4f3728b74e..a2412b0f6a 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -48,7 +48,7 @@ void _mmu2_load_filament(uint8_t index) { ui.reset_status(); } void action_mmu2_load_all() { - LOOP_L_N(i, EXTRUDERS) _mmu2_load_filament(i); + EXTRUDER_LOOP() _mmu2_load_filament(e); ui.return_to_status(); } @@ -56,14 +56,14 @@ void menu_mmu2_load_filament() { START_MENU(); BACK_ITEM(MSG_MMU2_MENU); ACTION_ITEM(MSG_MMU2_ALL, action_mmu2_load_all); - LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() ACTION_ITEM_N(e, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); }); END_MENU(); } void menu_mmu2_load_to_nozzle() { START_MENU(); BACK_ITEM(MSG_MMU2_MENU); - LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() ACTION_ITEM_N(e, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); }); END_MENU(); } @@ -89,7 +89,7 @@ void action_mmu2_unload_filament() { void menu_mmu2_eject_filament() { START_MENU(); BACK_ITEM(MSG_MMU2_MENU); - LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() ACTION_ITEM_N(e, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); }); END_MENU(); } @@ -130,7 +130,7 @@ void menu_mmu2_choose_filament() { #if LCD_HEIGHT > 2 STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_DEFAULT|SS_INVERT); #endif - LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_chosen(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() ACTION_ITEM_N(e, MSG_MMU2_FILAMENT_N, []{ action_mmu2_chosen(MenuItemBase::itemIndex); }); END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 854f36985f..7954edf5a1 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -199,8 +199,8 @@ void menu_tune() { EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); }); // Flow En: #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() + EDIT_ITEM_N(int3, e, MSG_FLOW_N, &planner.flow_percentage[e], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); #endif #endif @@ -211,8 +211,8 @@ void menu_tune() { #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); #elif HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10); + EXTRUDER_LOOP() + EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 51440aac26..a3caa199c1 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1505,7 +1505,7 @@ void Planner::check_axes_activity() { volumetric_extruder_feedrate_limit[e] = (lim && siz) ? lim / CIRCLE_AREA(siz * 0.5f) : 0; } void Planner::calculate_volumetric_extruder_limits() { - LOOP_L_N(e, EXTRUDERS) calculate_volumetric_extruder_limit(e); + EXTRUDER_LOOP() calculate_volumetric_extruder_limit(e); } #endif diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index f29604bea8..5b79e406f5 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -928,8 +928,8 @@ class Planner { #if HAS_LINEAR_E_JERK FORCE_INLINE static void recalculate_max_e_jerk() { const float prop = junction_deviation_mm * SQRT(0.5) / (1.0f - SQRT(0.5)); - LOOP_L_N(i, EXTRUDERS) - max_e_jerk[E_INDEX_N(i)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_INDEX_N(i)]); + EXTRUDER_LOOP() + max_e_jerk[E_INDEX_N(e)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_INDEX_N(e)]); } #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 63bb93765b..1f482afeb4 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3138,9 +3138,9 @@ void MarlinSettings::reset() { // #if ENABLED(LIN_ADVANCE) - LOOP_L_N(i, EXTRUDERS) { - planner.extruder_advance_K[i] = LIN_ADVANCE_K; - TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[i] = LIN_ADVANCE_K); + EXTRUDER_LOOP() { + planner.extruder_advance_K[e] = LIN_ADVANCE_K; + TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[e] = LIN_ADVANCE_K); } #endif @@ -3185,7 +3185,7 @@ void MarlinSettings::reset() { // Advanced Pause filament load & unload lengths // #if ENABLED(ADVANCED_PAUSE_FEATURE) - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { fc_settings[e].unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH; fc_settings[e].load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH; } From 6b47db3a68668022aa096d6983c89df3f926dc30 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 20:34:00 -0500 Subject: [PATCH 154/203] =?UTF-8?q?=F0=9F=8E=A8=20General=20cleanup,=20com?= =?UTF-8?q?ments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 1 + Marlin/src/gcode/host/M16.cpp | 3 +- Marlin/src/gcode/host/M360.cpp | 2 +- .../generic/max_acceleration_screen.cpp | 31 +++++++-------- .../generic/max_velocity_screen.cpp | 39 +++++++++---------- Marlin/src/module/probe.h | 9 +++++ Marlin/src/pins/pinsDebug.h | 1 + 7 files changed, 48 insertions(+), 38 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 53d98e0e6d..045ca3589f 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -118,6 +118,7 @@ typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t; #define LOOP_LINEAR_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LINEAR_AXES) #define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LOGICAL_AXES) #define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, DISTINCT_AXES) +#define LOOP_DISTINCT_E(VAR) LOOP_L_N(VAR, DISTINCT_E) // // feedRate_t is just a humble float diff --git a/Marlin/src/gcode/host/M16.cpp b/Marlin/src/gcode/host/M16.cpp index 03e734daaa..07b0c5ef57 100644 --- a/Marlin/src/gcode/host/M16.cpp +++ b/Marlin/src/gcode/host/M16.cpp @@ -26,6 +26,7 @@ #include "../gcode.h" #include "../../MarlinCore.h" +#include "../../lcd/marlinui.h" /** * M16: Expected Printer Check @@ -37,4 +38,4 @@ void GcodeSuite::M16() { } -#endif +#endif // EXPECTED_PRINTER_CHECK diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index 1feb57996a..b3a95a35aa 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -180,7 +180,7 @@ void GcodeSuite::M360() { // config_line(F("NumExtruder"), EXTRUDERS); #if HAS_EXTRUDERS - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { config_line_e(e, JERK_STR, TERN(HAS_LINEAR_E_JERK, planner.max_e_jerk[E_INDEX_N(e)], TERN(HAS_CLASSIC_JERK, planner.max_jerk.e, DEFAULT_EJERK))); config_line_e(e, F("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]); config_line_e(e, F("Acceleration"), planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp index 228bc5f96b..492b908776 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp @@ -44,10 +44,10 @@ void MaxAccelerationScreen::onRedraw(draw_mode_t what) { w.color(e_axis).adjuster( 8, F(STR_E0), getAxisMaxAcceleration_mm_s2(E0) ); w.color(e_axis).adjuster(10, F(STR_E1), getAxisMaxAcceleration_mm_s2(E1) ); #if DISTINCT_E > 2 - w.color(e_axis).adjuster(12, F(STR_E2), getAxisMaxAcceleration_mm_s2(E2) ); - #endif - #if DISTINCT_E > 3 - w.color(e_axis).adjuster(14, F(STR_E3), getAxisMaxAcceleration_mm_s2(E3) ); + w.color(e_axis).adjuster(12, F(STR_E2), getAxisMaxAcceleration_mm_s2(E2) ); + #if DISTINCT_E > 3 + w.color(e_axis).adjuster(14, F(STR_E3), getAxisMaxAcceleration_mm_s2(E3) ); + #endif #endif #endif w.increments(); @@ -65,19 +65,18 @@ bool MaxAccelerationScreen::onTouchHeld(uint8_t tag) { case 8: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E0); break; case 9: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E0); break; #if DISTINCT_E > 1 - case 10: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E1); break; - case 11: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E1); break; + case 10: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E1); break; + case 11: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E1); break; + #if DISTINCT_E > 2 + case 12: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E2); break; + case 13: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E2); break; + #if DISTINCT_E > 3 + case 14: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E3); break; + case 15: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E3); break; + #endif + #endif #endif - #if DISTINCT_E > 2 - case 12: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E2); break; - case 13: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E2); break; - #endif - #if DISTINCT_E > 3 - case 14: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E3); break; - case 15: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E3); break; - #endif - default: - return false; + default: return false; } return true; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp index 65dc947b7b..0111276211 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp @@ -46,9 +46,9 @@ void MaxVelocityScreen::onRedraw(draw_mode_t what) { w.color(e_axis) .adjuster( 10, F(STR_E1), getAxisMaxFeedrate_mm_s(E1) ); #if EXTRUDERS > 2 w.color(e_axis).adjuster( 12, F(STR_E2), getAxisMaxFeedrate_mm_s(E2) ); - #endif - #if EXTRUDERS > 3 - w.color(e_axis).adjuster( 14, F(STR_E3), getAxisMaxFeedrate_mm_s(E3) ); + #if EXTRUDERS > 3 + w.color(e_axis).adjuster( 14, F(STR_E3), getAxisMaxFeedrate_mm_s(E3) ); + #endif #endif #endif w.increments(); @@ -63,24 +63,23 @@ bool MaxVelocityScreen::onTouchHeld(uint8_t tag) { case 5: UI_INCREMENT(AxisMaxFeedrate_mm_s, Y); break; case 6: UI_DECREMENT(AxisMaxFeedrate_mm_s, Z); break; case 7: UI_INCREMENT(AxisMaxFeedrate_mm_s, Z); break; - #if DISTINCT_E > 0 - case 8: UI_DECREMENT(AxisMaxFeedrate_mm_s, E0); break; - case 9: UI_INCREMENT(AxisMaxFeedrate_mm_s, E0); break; + #if DISTINCT_E + case 8: UI_DECREMENT(AxisMaxFeedrate_mm_s, E0); break; + case 9: UI_INCREMENT(AxisMaxFeedrate_mm_s, E0); break; + #if DISTINCT_E > 1 + case 10: UI_DECREMENT(AxisMaxFeedrate_mm_s, E1); break; + case 11: UI_INCREMENT(AxisMaxFeedrate_mm_s, E1); break; + #if DISTINCT_E > 2 + case 12: UI_DECREMENT(AxisMaxFeedrate_mm_s, E2); break; + case 13: UI_INCREMENT(AxisMaxFeedrate_mm_s, E2); break; + #if DISTINCT_E > 3 + case 14: UI_DECREMENT(AxisMaxFeedrate_mm_s, E3); break; + case 15: UI_INCREMENT(AxisMaxFeedrate_mm_s, E3); break; + #endif + #endif + #endif #endif - #if DISTINCT_E > 1 - case 10: UI_DECREMENT(AxisMaxFeedrate_mm_s, E1); break; - case 11: UI_INCREMENT(AxisMaxFeedrate_mm_s, E1); break; - #endif - #if DISTINCT_E > 2 - case 12: UI_DECREMENT(AxisMaxFeedrate_mm_s, E2); break; - case 13: UI_INCREMENT(AxisMaxFeedrate_mm_s, E2); break; - #endif - #if DISTINCT_E > 3 - case 14: UI_DECREMENT(AxisMaxFeedrate_mm_s, E3); break; - case 15: UI_INCREMENT(AxisMaxFeedrate_mm_s, E3); break; - #endif - default: - return false; + default: return false; } SaveSettingsDialogBox::settingsChanged(); return true; diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 752e83f467..f2fca10a80 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -188,6 +188,15 @@ public: } #endif + /** + * The nozzle is only able to move within the physical bounds of the machine. + * If the PROBE has an OFFSET Marlin may need to apply additional limits so + * the probe can be prevented from going to unreachable points. + * + * e.g., If the PROBE is to the LEFT of the NOZZLE, it will be limited in how + * close it can get the RIGHT edge of the bed (unless the nozzle is able move + * far enough past the right edge). + */ static constexpr float _min_x(const xy_pos_t &probe_offset_xy=offset_xy) { return TERN(IS_KINEMATIC, (X_CENTER) - probe_radius(probe_offset_xy), diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index e5db7f7b54..b662f09ba9 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once #include "../inc/MarlinConfig.h" From 0b32c3900f68895d8a454d164e225dbcea608a83 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 22 Mar 2022 20:39:53 -0500 Subject: [PATCH 155/203] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Imp?= =?UTF-8?q?rove=20STATUS=5FBED=5FX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/dogm/dogm_Statusscreen.h | 1 + Marlin/src/lcd/dogm/status/combined.h | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index f17dd06365..8d0ab4efbe 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -37,6 +37,7 @@ #undef STATUS_HEATERS_X #undef STATUS_BED_X + /** * Custom _Statusscreen.h files can define: * - A custom logo image diff --git a/Marlin/src/lcd/dogm/status/combined.h b/Marlin/src/lcd/dogm/status/combined.h index ca18f21af6..070fe6b027 100644 --- a/Marlin/src/lcd/dogm/status/combined.h +++ b/Marlin/src/lcd/dogm/status/combined.h @@ -37,6 +37,7 @@ #if HOTENDS == 0 #define STATUS_HEATERS_WIDTH 96 + #define STATUS_BED_X 74 const unsigned char status_heaters_bmp[] PROGMEM = { B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000100,B00010000,B01000000, @@ -56,6 +57,7 @@ #elif HOTENDS == 1 #define STATUS_HEATERS_WIDTH 96 + #define STATUS_BED_X 74 const unsigned char status_heaters_bmp[] PROGMEM = { B00011111,B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000100,B00010000,B01000000, @@ -75,6 +77,7 @@ #elif HOTENDS == 2 #define STATUS_HEATERS_WIDTH 96 + #define STATUS_BED_X 74 const unsigned char status_heaters_bmp[] PROGMEM = { B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00000000,B00000000,B00000000,B00000100,B00010000,B01000000, @@ -104,6 +107,7 @@ #elif HOTENDS == 3 #define STATUS_HEATERS_WIDTH 96 + #define STATUS_BED_X 74 const unsigned char status_heaters_bmp[] PROGMEM = { B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00000100,B00010000,B01000000, @@ -133,6 +137,7 @@ #else // HOTENDS > 3 #define STATUS_HEATERS_WIDTH 120 + #define STATUS_BED_X 98 const unsigned char status_heaters_bmp[] PROGMEM = { B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00000100,B00010000,B01000000, @@ -161,7 +166,8 @@ #endif // HOTENDS - #define STATUS_BED_TEXT_X (STATUS_HEATERS_WIDTH - 10) + #define STATUS_BED_WIDTH 20 + #define STATUS_BED_TEXT_X (STATUS_BED_X + STATUS_BED_WIDTH / 2) #else // !HAS_HEATED_BED || HOTENDS > 3 From b44357db9df70559751b31f6a2e7483878253976 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 24 Mar 2022 00:01:46 +0000 Subject: [PATCH 156/203] [cron] Bump distribution date (2022-03-24) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index b34a3c3c64..8d04847bba 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-23" +//#define STRING_DISTRIBUTION_DATE "2022-03-24" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index ac7f37f12c..76801c5dc4 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-23" + #define STRING_DISTRIBUTION_DATE "2022-03-24" #endif /** From 0d3f79e6d6a570f87dc19c526324b819af8048a7 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 25 Mar 2022 12:06:28 +1300 Subject: [PATCH 157/203] =?UTF-8?q?=F0=9F=A9=B9=20Wrap=20endstop=5Fdiag.cp?= =?UTF-8?q?p=20(#23931)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 74eb94e751..0b450bd4c0 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -21,15 +21,19 @@ */ /** - * DWIN End Stops diagnostic page for PRO UI + * DWIN Endstops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) * Version: 1.2.2 * Date: 2022/02/24 */ +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_LCD_PROUI) + #include "dwin_defines.h" -#if BOTH(DWIN_LCD_PROUI, HAS_ESDIAG) +#if HAS_ESDIAG #include "endstop_diag.h" @@ -105,4 +109,5 @@ void ESDiagClass::Update() { DWIN_UpdateLCD(); } -#endif // DWIN_LCD_PROUI && HAS_ESDIAG +#endif // HAS_ESDIAG +#endif // DWIN_LCD_PROUI From e119d9bae9f07dd5088ff118fac4d090c2b5b28a Mon Sep 17 00:00:00 2001 From: Serhiy-K <52166448+Serhiy-K@users.noreply.github.com> Date: Fri, 25 Mar 2022 01:07:58 +0200 Subject: [PATCH 158/203] =?UTF-8?q?=F0=9F=8C=90=20Update=20Ukrainian=20lan?= =?UTF-8?q?guage=20(#23935)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_uk.h | 42 ++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 7afc2e031c..e4eef399fe 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -465,7 +465,15 @@ namespace Language_uk { LSTR MSG_FILAMENT_LOAD = _UxGT("Завантаж., мм"); LSTR MSG_ADVANCE_K = _UxGT("Kоеф. просув."); LSTR MSG_ADVANCE_K_E = _UxGT("Kоеф. просув. *"); - LSTR MSG_CONTRAST = _UxGT("Контраст екрану"); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_CONTRAST = _UxGT("Контраст екрану"); + LSTR MSG_BRIGHTNESS = _UxGT("Яскравість LCD"); + #else + LSTR MSG_CONTRAST = _UxGT("Контраст"); + LSTR MSG_BRIGHTNESS = _UxGT("Яскравість"); + #endif + LSTR MSG_LCD_BKL_TIMEOUT = _UxGT("LCD Таймаут, с"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Підсвітка вимк."); LSTR MSG_STORE_EEPROM = _UxGT("Зберегти в EEPROM"); LSTR MSG_LOAD_EEPROM = _UxGT("Зчитати з EEPROM"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("На базові параметри"); @@ -497,10 +505,17 @@ namespace Language_uk { LSTR MSG_BUTTON_RESET = _UxGT("Зкинути"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ігнорув."); LSTR MSG_BUTTON_CANCEL = _UxGT("Відміна"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Підтвер."); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Продовж."); LSTR MSG_BUTTON_DONE = _UxGT("Готово"); LSTR MSG_BUTTON_BACK = _UxGT("Назад"); - LSTR MSG_BUTTON_PROCEED = _UxGT("Продовжити"); - LSTR MSG_BUTTON_SKIP = _UxGT("Пропустити"); + LSTR MSG_BUTTON_PROCEED = _UxGT("Продовж."); + LSTR MSG_BUTTON_SKIP = _UxGT("Пропуск"); + LSTR MSG_BUTTON_INFO = _UxGT("Інфо"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Рівень"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Пауза"); + LSTR MSG_BUTTON_RESUME = _UxGT("Звіт"); + LSTR MSG_BUTTON_SAVE = _UxGT("Зберегти"); LSTR MSG_PAUSING = _UxGT("Призупинення..."); LSTR MSG_PAUSE_PRINT = _UxGT("Призупинити друк"); @@ -518,6 +533,8 @@ namespace Language_uk { LSTR MSG_USERWAIT = _UxGT("Продовжити..."); LSTR MSG_PRINT_PAUSED = _UxGT("Друк призупинено"); LSTR MSG_PRINTING = _UxGT("Друк..."); + LSTR MSG_STOPPING = _UxGT("Зупинка..."); + LSTR MSG_REMAINING_TIME = _UxGT("Залишилось"); LSTR MSG_PRINT_ABORTED = _UxGT("Друк скасовано"); LSTR MSG_PRINT_DONE = _UxGT("Друк завершено"); LSTR MSG_NO_MOVE = _UxGT("Немає руху."); @@ -702,15 +719,32 @@ namespace Language_uk { LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Завершено"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Екструдовано"); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Нагрійте хотенд"); + LSTR MSG_COLORS_GET = _UxGT("Отримати колір"); #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Носій не вставлений"); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Перезавантаження..."); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Кількість друків"); - LSTR MSG_INFO_PRINT_TIME = _UxGT("Весь час друку"); + LSTR MSG_INFO_PRINT_TIME = _UxGT("Час друку"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Найдовший час"); + LSTR MSG_COLORS_SELECT = _UxGT("Обрати кольори"); + LSTR MSG_COLORS_APPLIED = _UxGT("Кольори застосовані"); #else + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Немає носія"); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Перезавантаж..."); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Друків"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Загалом"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Найдовше"); + LSTR MSG_COLORS_SELECT = _UxGT("Кольори"); + LSTR MSG_COLORS_APPLIED = _UxGT("Кольори застос."); #endif + LSTR MSG_COLORS_RED = _UxGT("Червоний"); + LSTR MSG_COLORS_GREEN = _UxGT("Зелений"); + LSTR MSG_COLORS_BLUE = _UxGT("Синій"); + LSTR MSG_COLORS_WHITE = _UxGT("Білий"); + LSTR MSG_UI_LANGUAGE = _UxGT("Мова"); + LSTR MSG_SOUND_ENABLE = _UxGT("Дозволити звук"); + LSTR MSG_LOCKSCREEN = _UxGT("Блокувати екран"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Мін. ") LCD_STR_THERMOMETER; LSTR MSG_INFO_MAX_TEMP = _UxGT("Макс. ") LCD_STR_THERMOMETER; From d189cda61679369bb029a347afb5a860e18f5224 Mon Sep 17 00:00:00 2001 From: Oleg Belov Date: Fri, 25 Mar 2022 02:12:35 +0300 Subject: [PATCH 159/203] =?UTF-8?q?=F0=9F=93=8C=20Custom=20cable=20for=20M?= =?UTF-8?q?ini=2012864=20V1=20+=20SKR=20Mini=20E3=20V3.0=20(#23936)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h index 2589a316b6..2fddb68a7c 100644 --- a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h +++ b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h @@ -256,8 +256,51 @@ #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_V3_0.h' for details. Comment out this line to continue." + + /** + * + * Board Display + * ------ ------ + * (EN2) PB5 |10 9 | PA15(BTN_ENC) 5V |10 9 | GND + * (LCD_CS) PA9 | 8 7 | RST (RESET) -- | 8 7 | -- + * (LCD_A0) PA10 |#6 5 | PB9 (EN1) (DIN) | 6 5#| (RESET) + * (LCD_SCK)PB8 | 4 3 | PD6 (MOSI) (LCD_A0) | 4 3 | (LCD_CS) + * GND | 2 1 | 5V (BTN_ENC) | 2 1 | -- + * ------ ------ + * EXP1 EXP1 + * + * ------ + * -- |10 9 | -- + * --- (RESET) | 8 7 | -- + * | 3 | (MOSI) | 6 5#| (EN2) + * | 2 | (DIN) -- | 4 3 | (EN1) + * | 1 | (LCD_SCK)| 2 1 | -- + * --- ------ + * Neopixel EXP2 + * + * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on. + * + * Check twice index position!!! (marked as # here) + * On BTT boards pins from IDC10 connector are numbered in unusual order. + */ + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 PB9 + #define BTN_EN2 PB5 + #define BEEPER_PIN -1 + + #define DOGLCD_CS PA9 + #define DOGLCD_A0 PA10 + #define DOGLCD_SCK PB8 + #define DOGLCD_MOSI PD6 + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." #endif #endif // HAS_WIRED_LCD From 867e274172262a8e06088921c909b7ae6135dc4d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 25 Mar 2022 00:01:44 +0000 Subject: [PATCH 160/203] [cron] Bump distribution date (2022-03-25) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 8d04847bba..5723946380 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-24" +//#define STRING_DISTRIBUTION_DATE "2022-03-25" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 76801c5dc4..1c64d23871 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-24" + #define STRING_DISTRIBUTION_DATE "2022-03-25" #endif /** From 4a50d89bdb5415403f02c3427fa4ad235fd316d7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 24 Mar 2022 20:29:50 -0500 Subject: [PATCH 161/203] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Encoder=20noise=20?= =?UTF-8?q?followup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23925 --- Marlin/src/lcd/marlinui.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index b28687ee91..30c22188e4 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -689,8 +689,8 @@ public: /** * Some printers may have issues with EMI noise especially using a motherboard with 3.3V logic levels * it may cause the logical LOW to float into the undefined region and register as a logical HIGH - * causing it to errorenously register as if someone clicked the button and in worst case make the printer - * unusable in practice. + * causing it to erroneously register as if someone clicked the button and in worst case make the + * printer unusable in practice. */ static bool hw_button_pressed() { LOOP_L_N(s, ENCODER_SAMPLES) { From 6b55eec9bbc72db2777d3ff3577f2bf1ef13a613 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 17:04:06 -0500 Subject: [PATCH 162/203] =?UTF-8?q?=F0=9F=A9=B9=20Print=20English=20to=20s?= =?UTF-8?q?erial=20out?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/multi_language.h | 3 +++ Marlin/src/module/probe.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/src/core/multi_language.h b/Marlin/src/core/multi_language.h index 2106f946ac..a605a6f024 100644 --- a/Marlin/src/core/multi_language.h +++ b/Marlin/src/core/multi_language.h @@ -80,6 +80,9 @@ typedef const char Language_Str[]; #endif #define GET_TEXT_F(MSG) FPSTR(GET_TEXT(MSG)) +#define GET_EN_TEXT(MSG) GET_LANG(en)::MSG +#define GET_EN_TEXT_F(MSG) FPSTR(GET_EN_TEXT(MSG)) + #define GET_LANGUAGE_NAME(INDEX) GET_LANG(LCD_LANGUAGE_##INDEX)::LANGUAGE #define LANG_CHARSIZE GET_TEXT(CHARSIZE) #define USE_WIDE_GLYPH (LANG_CHARSIZE > 2) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index ee6323518a..c34178412f 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -311,7 +311,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW); ui.return_to_status(); // To display the new status message ui.set_status(ds_str, 99); - SERIAL_ECHOLNF(ds_str); + SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW)); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe"))); From 4ff063440d5bbf00b43c933caffe83940b58b4f0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 17:09:26 -0500 Subject: [PATCH 163/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20status=5Fprintf=20?= =?UTF-8?q?alert=20level?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.cpp | 39 ++++++++++++++++++++----------------- Marlin/src/lcd/marlinui.h | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 11b523ff53..9e27dc6006 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1487,9 +1487,12 @@ void MarlinUI::init() { #include - void MarlinUI::status_printf(const uint8_t level, FSTR_P const fmt, ...) { + void MarlinUI::status_printf(int8_t level, FSTR_P const fmt, ...) { + // Alerts block lower priority messages + if (level < 0) level = alert_level = 0; if (level < alert_level) return; alert_level = level; + va_list args; va_start(args, FTOP(fmt)); vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, FTOP(fmt), args); @@ -1551,7 +1554,22 @@ void MarlinUI::init() { #endif -#endif +#else // !HAS_STATUS_MESSAGE + + // + // Send the status line as a host notification + // + void MarlinUI::set_status(const char * const cstr, const bool) { + TERN(HOST_PROMPT_SUPPORT, hostui.notify(cstr), UNUSED(cstr)); + } + void MarlinUI::set_status(FSTR_P const fstr, const int8_t) { + TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); + } + void MarlinUI::status_printf(int8_t, FSTR_P const fstr, ...) { + TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); + } + +#endif // !HAS_STATUS_MESSAGE #if HAS_DISPLAY @@ -1663,22 +1681,7 @@ void MarlinUI::init() { #endif -#elif !HAS_STATUS_MESSAGE // && !HAS_DISPLAY - - // - // Send the status line as a host notification - // - void MarlinUI::set_status(const char * const cstr, const bool) { - TERN(HOST_PROMPT_SUPPORT, hostui.notify(cstr), UNUSED(cstr)); - } - void MarlinUI::set_status(FSTR_P const fstr, const int8_t) { - TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); - } - void MarlinUI::status_printf(const uint8_t, FSTR_P const fstr, ...) { - TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); - } - -#endif // !HAS_DISPLAY && !HAS_STATUS_MESSAGE +#endif // HAS_DISPLAY #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 30c22188e4..7a6b3992b4 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -365,7 +365,7 @@ public: static void set_status(const char * const cstr, const bool persist=false); static void set_status(FSTR_P const fstr, const int8_t level=0); - static void status_printf(const uint8_t level, FSTR_P const fmt, ...); + static void status_printf(int8_t level, FSTR_P const fmt, ...); #if HAS_DISPLAY From 8dfdf51678a4a3975df8250bedf3489fd4835796 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 17:09:55 -0500 Subject: [PATCH 164/203] =?UTF-8?q?=F0=9F=8E=A8=20Format,=20use=20status?= =?UTF-8?q?=20macros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 10 +++++----- Marlin/src/gcode/lcd/M117.cpp | 2 +- Marlin/src/gcode/temp/M140_M190.cpp | 5 ++--- Marlin/src/gcode/temp/M192.cpp | 2 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 4 ++-- Marlin/src/lcd/marlinui.cpp | 14 +++++++++++--- Marlin/src/lcd/marlinui.h | 4 ---- Marlin/src/module/motion.cpp | 9 ++------- Marlin/src/module/probe.cpp | 6 +++--- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 2 +- 11 files changed, 29 insertions(+), 31 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0a18e95ebc..d8e64294f0 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1339,13 +1339,13 @@ #endif #if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) - // The timeout (in ms) to return to the status screen from sub-menus - //#define LCD_TIMEOUT_TO_STATUS 15000 + // The timeout to return to the status screen from sub-menus + //#define LCD_TIMEOUT_TO_STATUS 15000 // (ms) #if ENABLED(SHOW_BOOTSCREEN) - #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) + #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) #if EITHER(HAS_MARLINUI_U8GLIB, TFT_COLOR_UI) - #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash) + #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash) #endif #endif @@ -3464,7 +3464,7 @@ #define SPINDLE_LASER_USE_PWM // Enable if your controller supports setting the speed/power #if ENABLED(SPINDLE_LASER_USE_PWM) #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower - #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32 and LPC) + #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32, and LPC) #endif //#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11 diff --git a/Marlin/src/gcode/lcd/M117.cpp b/Marlin/src/gcode/lcd/M117.cpp index f26694bd64..86023e12e3 100644 --- a/Marlin/src/gcode/lcd/M117.cpp +++ b/Marlin/src/gcode/lcd/M117.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M117() { if (parser.string_arg && parser.string_arg[0]) - ui.set_status(parser.string_arg); + ui.set_status(parser.string_arg, true); else ui.reset_status(); diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 7532defccd..d6992ba938 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -82,10 +82,9 @@ void GcodeSuite::M140_M190(const bool isM190) { if (!got_temp) return; thermalManager.setTargetBed(temp); + thermalManager.isHeatingBed() ? LCD_MESSAGE(MSG_BED_HEATING) : LCD_MESSAGE(MSG_BED_COOLING); - ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING)); - - // with PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it + // With PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190)); if (isM190) diff --git a/Marlin/src/gcode/temp/M192.cpp b/Marlin/src/gcode/temp/M192.cpp index a96e2d34a4..04b36a548c 100644 --- a/Marlin/src/gcode/temp/M192.cpp +++ b/Marlin/src/gcode/temp/M192.cpp @@ -49,7 +49,7 @@ void GcodeSuite::M192() { } const celsius_t target_temp = parser.value_celsius(); - ui.set_status(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT_F(MSG_PROBE_HEATING) : GET_TEXT_F(MSG_PROBE_COOLING)); + thermalManager.isProbeBelowTemp(target_temp) ? LCD_MESSAGE(MSG_PROBE_HEATING) : LCD_MESSAGE(MSG_PROBE_COOLING); thermalManager.wait_for_probe(target_temp, no_wait_for_cooling); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 66e90740fd..7b5f6955af 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -2304,7 +2304,7 @@ TERN(HAS_ONESTEP_LEVELING, float, void) Tram(uint8_t point) { inLev = true; zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); if (isnan(zval)) - ui.set_status(F("Position Not Reachable, check offsets")); + LCD_MESSAGE_F("Position Not Reachable, check offsets"); else { sprintf_P(cmd, PSTR("X:%s, Y:%s, Z:%s"), dtostrf(xpos, 1, 1, str_1), @@ -2336,7 +2336,7 @@ void TramC () { Tram(4); } void Trammingwizard() { bed_mesh_t zval = {0}; if (HMI_data.FullManualTramming) { - ui.set_status(F("Disable manual tramming")); + LCD_MESSAGE_F("Disable manual tramming"); return; } zval[0][0] = Tram(0); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 9e27dc6006..dc7ecf2246 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -593,7 +593,7 @@ void MarlinUI::init() { // share the same line on the display. // - #if DISABLED(PROGRESS_MSG_ONCE) || (PROGRESS_MSG_EXPIRE > 0) + #if DISABLED(PROGRESS_MSG_ONCE) || PROGRESS_MSG_EXPIRE > 0 #define GOT_MS const millis_t ms = millis(); #endif @@ -1420,6 +1420,7 @@ void MarlinUI::init() { #if SERVICE_INTERVAL_3 > 0 static PGMSTR(service3, "> " SERVICE_NAME_3 "!"); #endif + FSTR_P msg; if (printingIsPaused()) msg = GET_TEXT_F(MSG_PRINT_PAUSED); @@ -1450,13 +1451,18 @@ void MarlinUI::init() { set_status(msg, -1); } + /** + * Set Status with a fixed string and alert level. + * @param fstr A constant F-string to set as the status. + * @param level Alert level. Negative to ignore and reset the level. Non-zero never expires. + */ void MarlinUI::set_status(FSTR_P const fstr, int8_t level) { - PGM_P const pstr = FTOP(fstr); + // Alerts block lower priority messages if (level < 0) level = alert_level = 0; if (level < alert_level) return; alert_level = level; - TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr)); + PGM_P const pstr = FTOP(fstr); // Since the message is encoded in UTF8 it must // only be cut on a character boundary. @@ -1476,6 +1482,8 @@ void MarlinUI::init() { strncpy_P(status_message, pstr, maxLen); status_message[maxLen] = '\0'; + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr)); + finish_status(level > 0); } diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 7a6b3992b4..b9e2e9b692 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -39,10 +39,6 @@ #define HAS_ENCODER_ACTION 1 #endif -#if HAS_STATUS_MESSAGE - #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) -#endif - #if E_MANUAL > 1 #define MULTI_E_MANUAL 1 #endif diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 7b1e0a3fb9..d8df8e12e1 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -29,9 +29,8 @@ #include "stepper.h" #include "planner.h" #include "temperature.h" - #include "../gcode/gcode.h" - +#include "../lcd/marlinui.h" #include "../inc/MarlinConfig.h" #if IS_SCARA @@ -51,10 +50,6 @@ #include "../feature/bltouch.h" #endif -#if HAS_STATUS_MESSAGE - #include "../lcd/marlinui.h" -#endif - #if HAS_FILAMENT_SENSOR #include "../feature/runout.h" #endif @@ -1325,7 +1320,7 @@ void prepare_line_to_destination() { ); SERIAL_ECHO_START(); SERIAL_ECHOLN(msg); - TERN_(HAS_STATUS_MESSAGE, ui.set_status(msg)); + ui.set_status(msg); return true; } return false; diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index c34178412f..5b0bd77d0d 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -313,9 +313,9 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { ui.set_status(ds_str, 99); SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW)); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe"))); - TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR))); + TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, ds_str, FPSTR(CONTINUE_STR))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str)); + TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.reset_status(); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index a983275b8a..38cc3663d2 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -651,7 +651,7 @@ volatile bool Temperature::raw_temps_ready = false; // PID Tuning loop wait_for_heatup = true; // Can be interrupted with M108 - TERN_(HAS_STATUS_MESSAGE, ui.set_status(F("Wait for heat up..."))); + LCD_MESSAGE(MSG_HEATING); while (wait_for_heatup) { const millis_t ms = millis(); diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 724de8f82a..652a44e526 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -458,7 +458,7 @@ void CardReader::mount() { cdroot(); #if ENABLED(USB_FLASH_DRIVE_SUPPORT) || PIN_EXISTS(SD_DETECT) else if (marlin_state != MF_INITIALIZING) - ui.set_status(GET_TEXT_F(MSG_MEDIA_INIT_FAIL), -1); + LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL); #endif ui.refresh(); From fd742616ba6fd2db1607df197dea142cbf1a9d3f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 17:35:00 -0500 Subject: [PATCH 165/203] =?UTF-8?q?=F0=9F=9A=B8=20Clear=20"heating/cooling?= =?UTF-8?q?"=20message=20on=20temp=20reached?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/temp/M104_M109.cpp | 2 +- Marlin/src/gcode/temp/M140_M190.cpp | 5 +++++ Marlin/src/lcd/marlinui.cpp | 6 ++++++ Marlin/src/lcd/marlinui.h | 6 ++++++ Marlin/src/module/temperature.cpp | 10 +++++++++- Marlin/src/module/temperature.h | 4 ++-- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index baaac02100..331ceeb61d 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -126,7 +126,7 @@ void GcodeSuite::M104_M109(const bool isM109) { #endif if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) - thermalManager.set_heating_message(target_extruder); + thermalManager.set_heating_message(target_extruder, !isM109 && got_temp); } TERN_(AUTOTEMP, planner.autotemp_M104_M109()); diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index d6992ba938..c5e3c00029 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -89,6 +89,11 @@ void GcodeSuite::M140_M190(const bool isM190) { if (isM190) thermalManager.wait_for_bed(no_wait_for_cooling); + else + ui.set_status_reset_fn([]{ + const celsius_t c = thermalManager.degTargetBed(); + return c < 30 || thermalManager.degBedNear(c); + }); } #endif // HAS_HEATED_BED diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index dc7ecf2246..8906b01e5e 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -73,6 +73,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; uint8_t MarlinUI::alert_level; // = 0 + statusResetFunc_t MarlinUI::status_reset_callback; // = nullptr #endif #if ENABLED(LCD_SET_PROGRESS_MANUALLY) @@ -627,6 +628,9 @@ void MarlinUI::init() { #endif // BASIC_PROGRESS_BAR + if (status_reset_callback && (*status_reset_callback)()) + reset_status(); + #if HAS_MARLINUI_MENU if (use_click()) { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) @@ -1515,6 +1519,8 @@ void MarlinUI::init() { UNUSED(persist); + set_status_reset_fn(); + #if HAS_WIRED_LCD #if BASIC_PROGRESS_BAR || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index b9e2e9b692..17852a5039 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -59,6 +59,8 @@ #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) +typedef bool (*statusResetFunc_t)(); + #if HAS_WIRED_LCD enum LCDViewAction : uint8_t { @@ -352,11 +354,15 @@ public: static void reset_status(const bool no_welcome=false); static void set_alert_status(FSTR_P const fstr); static void reset_alert_level() { alert_level = 0; } + + static statusResetFunc_t status_reset_callback; + static void set_status_reset_fn(const statusResetFunc_t fn=nullptr) { status_reset_callback = fn; } #else static constexpr bool has_status() { return false; } static void reset_status(const bool=false) {} static void set_alert_status(FSTR_P const) {} static void reset_alert_level() {} + static void set_status_reset_fn(const statusResetFunc_t=nullptr) {} #endif static void set_status(const char * const cstr, const bool persist=false); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 38cc3663d2..6660d9a8f8 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3631,7 +3631,7 @@ void Temperature::isr() { #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE - void Temperature::set_heating_message(const uint8_t e) { + void Temperature::set_heating_message(const uint8_t e, const bool isM104/*=false*/) { const bool heating = isHeatingHotend(e); ui.status_printf(0, #if HAS_MULTI_HOTEND @@ -3641,6 +3641,14 @@ void Temperature::isr() { #endif , heating ? GET_TEXT(MSG_HEATING) : GET_TEXT(MSG_COOLING) ); + + if (isM104) { + static uint8_t wait_e; wait_e = e; + ui.set_status_reset_fn([]{ + const celsius_t c = degTargetHotend(wait_e); + return c < 30 || degHotendNear(wait_e, c); + }); + } } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index cb84f7e395..a4681ba02b 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -961,9 +961,9 @@ class Temperature { #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE - static void set_heating_message(const uint8_t e); + static void set_heating_message(const uint8_t e, const bool isM104=false); #else - static void set_heating_message(const uint8_t) {} + static void set_heating_message(const uint8_t, const bool=false) {} #endif #if HAS_MARLINUI_MENU && HAS_TEMPERATURE From b7ffcd6941e8d75fefc5c454ad0e334d554c4cea Mon Sep 17 00:00:00 2001 From: Robby Candra Date: Sat, 26 Mar 2022 06:34:20 +0700 Subject: [PATCH 166/203] =?UTF-8?q?=E2=9C=A8=20STATUS=5FMESSAGE=5FTIMEOUT?= =?UTF-8?q?=5FSEC=20(#23135)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 3 +++ Marlin/src/inc/Conditionals_adv.h | 4 ++++ Marlin/src/inc/Warnings.cpp | 4 ++++ Marlin/src/lcd/marlinui.cpp | 18 ++++++++++++++++-- Marlin/src/lcd/marlinui.h | 4 ++++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index d8e64294f0..86eef1a026 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1352,6 +1352,9 @@ // Scroll a longer status message into view //#define STATUS_MESSAGE_SCROLLING + // Apply a timeout to low-priority status messages + //#define STATUS_MESSAGE_TIMEOUT_SEC 30 // (seconds) + // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index d63395a719..8a85536aea 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -587,6 +587,10 @@ #define HAS_PRINT_PROGRESS 1 #endif +#if STATUS_MESSAGE_TIMEOUT_SEC > 0 + #define HAS_STATUS_MESSAGE_TIMEOUT 1 +#endif + #if ENABLED(SDSUPPORT) && SD_PROCEDURE_DEPTH #define HAS_MEDIA_SUBCALLS 1 #endif diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 9d7b14d763..97e8e76b38 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -574,6 +574,10 @@ #warning "Contrast cannot be changed when LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX." #endif +#if PROGRESS_MSG_EXPIRE > 0 && HAS_STATUS_MESSAGE_TIMEOUT + #warning "It is recommended not to combine PROGRESS_MSG_EXPIRE with STATUS_MESSAGE_TIMEOUT_SEC." +#endif + /** * FYSETC backlighting */ diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 8906b01e5e..7c97ef791d 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -73,6 +73,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; uint8_t MarlinUI::alert_level; // = 0 + #if HAS_STATUS_MESSAGE_TIMEOUT + millis_t MarlinUI::status_message_expire_ms; // = 0 + #endif statusResetFunc_t MarlinUI::status_reset_callback; // = nullptr #endif @@ -628,8 +631,17 @@ void MarlinUI::init() { #endif // BASIC_PROGRESS_BAR - if (status_reset_callback && (*status_reset_callback)()) - reset_status(); + bool did_expire = status_reset_callback && (*status_reset_callback)(); + + #if HAS_STATUS_MESSAGE_TIMEOUT + #ifndef GOT_MS + #define GOT_MS + const millis_t ms = millis(); + #endif + did_expire |= status_message_expire_ms && ELAPSED(ms, status_message_expire_ms); + #endif + + if (did_expire) reset_status(); #if HAS_MARLINUI_MENU if (use_click()) { @@ -1521,6 +1533,8 @@ void MarlinUI::init() { set_status_reset_fn(); + TERN_(HAS_STATUS_MESSAGE_TIMEOUT, status_message_expire_ms = persist ? 0 : millis() + (STATUS_MESSAGE_TIMEOUT_SEC) * 1000UL); + #if HAS_WIRED_LCD #if BASIC_PROGRESS_BAR || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 17852a5039..d9404541d2 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -344,6 +344,10 @@ public: static char status_message[]; static uint8_t alert_level; // Higher levels block lower levels + #if HAS_STATUS_MESSAGE_TIMEOUT + static millis_t status_message_expire_ms; // Reset some status messages after a timeout + #endif + #if ENABLED(STATUS_MESSAGE_SCROLLING) static uint8_t status_scroll_offset; static void advance_status_scroll(); From 80c4abc2e1756a01cb18e660d9266eeeebe71d79 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 26 Mar 2022 00:06:22 +0000 Subject: [PATCH 167/203] [cron] Bump distribution date (2022-03-26) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 5723946380..7c598cb101 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-25" +//#define STRING_DISTRIBUTION_DATE "2022-03-26" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 1c64d23871..32ddb7340d 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-25" + #define STRING_DISTRIBUTION_DATE "2022-03-26" #endif /** From f1471c1549f8143b171b7decc7646ba2e09a6aee Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 26 Mar 2022 14:03:43 +1300 Subject: [PATCH 168/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MMU2=20buzz=20(#23?= =?UTF-8?q?943)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to 89a9c3a391 --- Marlin/src/feature/mmu/mmu2.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 7a7e27f287..a469c988c9 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -143,7 +143,10 @@ uint8_t MMU2::get_current_tool() { #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE) #endif -inline void ATTN_BUZZ(const bool two=false) { BUZZ(200, 404); if (two) { BUZZ(10, 0); BUZZ(200, 404); } } +void mmu2_attn_buzz(const bool two=false) { + BUZZ(200, 404); + if (two) { BUZZ(10, 0); BUZZ(200, 404); } +} void MMU2::mmu_loop() { @@ -819,7 +822,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { } LCD_MESSAGE(MSG_MMU2_RESUMING); - ATTN_BUZZ(true); + mmu2_attn_buzz(true); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" @@ -901,7 +904,7 @@ void MMU2::load_filament(const uint8_t index) { command(MMU_CMD_L0 + index); manage_response(false, false); - ATTN_BUZZ(); + mmu2_attn_buzz(); } /** @@ -912,7 +915,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - ATTN_BUZZ(); + mmu2_attn_buzz(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -927,7 +930,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { extruder = index; active_extruder = 0; load_to_nozzle(); - ATTN_BUZZ(); + mmu2_attn_buzz(); } return success; } @@ -948,7 +951,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - ATTN_BUZZ(); + mmu2_attn_buzz(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -964,11 +967,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (recover) { LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); - ATTN_BUZZ(); + mmu2_attn_buzz(); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover"))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); - ATTN_BUZZ(true); + mmu2_attn_buzz(true); command(MMU_CMD_R0); manage_response(false, false); @@ -981,7 +984,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { set_runout_valid(false); - ATTN_BUZZ(); + mmu2_attn_buzz(); stepper.disable_extruder(); @@ -996,7 +999,7 @@ bool MMU2::unload() { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - ATTN_BUZZ(); + mmu2_attn_buzz(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -1007,7 +1010,7 @@ bool MMU2::unload() { command(MMU_CMD_U0); manage_response(false, true); - ATTN_BUZZ(); + mmu2_attn_buzz(); // no active tool extruder = MMU2_NO_TOOL; From 959c559c438e0da9e8597f1d4b9c46bdfa5b453e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 20:54:01 -0500 Subject: [PATCH 169/203] =?UTF-8?q?=F0=9F=94=A8=20Try=20out=20v3=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test-builds.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index e37f532402..75cd6ee05f 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -113,10 +113,10 @@ jobs: steps: - name: Check out the PR - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache pip - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} @@ -124,13 +124,13 @@ jobs: ${{ runner.os }}-pip- - name: Cache PlatformIO - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.platformio key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - name: Select Python 3.7 - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax. architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified From b1958a43fc2a4536df7402a5f2420d14dc8fb810 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 25 Mar 2022 21:16:00 -0500 Subject: [PATCH 170/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20pulldown=20sanity?= =?UTF-8?q?=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/inc/SanityCheck.h | 4 ++++ Marlin/src/HAL/DUE/inc/SanityCheck.h | 4 ++++ Marlin/src/HAL/ESP32/inc/SanityCheck.h | 4 ++++ Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h | 4 ++++ Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h | 4 ++++ Marlin/src/inc/Conditionals_post.h | 11 +++++++++++ Marlin/src/inc/SanityCheck.h | 12 ------------ 7 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index 5c1f01a8f4..15a5be4cd2 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -71,3 +71,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not supported on AVR boards." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on AVR boards." +#endif diff --git a/Marlin/src/HAL/DUE/inc/SanityCheck.h b/Marlin/src/HAL/DUE/inc/SanityCheck.h index 87b09cf292..75480acaf2 100644 --- a/Marlin/src/HAL/DUE/inc/SanityCheck.h +++ b/Marlin/src/HAL/DUE/inc/SanityCheck.h @@ -59,3 +59,7 @@ #if HAS_TMC_SW_SERIAL #error "TMC220x Software Serial is not supported on the DUE platform." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on DUE boards." +#endif diff --git a/Marlin/src/HAL/ESP32/inc/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h index 052c7e9d12..04d70ec14f 100644 --- a/Marlin/src/HAL/ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h @@ -44,3 +44,7 @@ #if MB(MKS_TINYBEE) && ENABLED(FAST_PWM_FAN) #error "FAST_PWM_FAN is not available on TinyBee." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on ESP32 boards." +#endif diff --git a/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h b/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h index 1efa76b1e9..dbce187673 100644 --- a/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h +++ b/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h @@ -40,3 +40,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.1/3.2." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on Teensy 3.1/3.2 boards." +#endif diff --git a/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h b/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h index eef2850550..3308707371 100644 --- a/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h +++ b/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h @@ -40,3 +40,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.5/3.6." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on Teensy 3.5/3.6 boards." +#endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 9942f14eee..dd175ac2cc 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3507,3 +3507,14 @@ #if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT) #define HAS_DRIVER_SAFE_POWER_PROTECT 1 #endif + +#if ANY(ENDSTOPPULLDOWNS, ENDSTOPPULLDOWN_ZMIN_PROBE, \ + ENDSTOPPULLDOWN_XMIN, ENDSTOPPULLDOWN_YMIN, ENDSTOPPULLDOWN_ZMIN, \ + ENDSTOPPULLDOWN_IMIN, ENDSTOPPULLDOWN_JMIN, ENDSTOPPULLDOWN_KMIN, \ + ENDSTOPPULLDOWN_XMAX, ENDSTOPPULLDOWN_YMAX, ENDSTOPPULLDOWN_ZMAX, \ + ENDSTOPPULLDOWN_IMAX, ENDSTOPPULLDOWN_JMAX, ENDSTOPPULLDOWN_KMAX, \ + POWER_LOSS_PULLDOWN, CALIBRATION_PIN_PULLDOWN, FIL_RUNOUT_PULLDOWN, \ + FIL_RUNOUT1_PULLDOWN, FIL_RUNOUT2_PULLDOWN, FIL_RUNOUT3_PULLDOWN, FIL_RUNOUT4_PULLDOWN, \ + FIL_RUNOUT5_PULLDOWN, FIL_RUNOUT6_PULLDOWN, FIL_RUNOUT7_PULLDOWN, FIL_RUNOUT8_PULLDOWN) + #define USING_PULLDOWNS 1 +#endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 617d117415..552a627093 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -782,18 +782,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if !defined(TARGET_LPC1768) && ANY( \ - ENDSTOPPULLDOWNS, ENDSTOPPULLDOWN_ZMIN_PROBE, \ - ENDSTOPPULLDOWN_XMAX, ENDSTOPPULLDOWN_YMAX, ENDSTOPPULLDOWN_ZMAX, \ - ENDSTOPPULLDOWN_XMIN, ENDSTOPPULLDOWN_YMIN, ENDSTOPPULLDOWN_ZMIN, \ - FIL_RUNOUT_PULLDOWN, \ - FIL_RUNOUT1_PULLDOWN, FIL_RUNOUT2_PULLDOWN, FIL_RUNOUT3_PULLDOWN, FIL_RUNOUT4_PULLDOWN, \ - FIL_RUNOUT5_PULLDOWN, FIL_RUNOUT6_PULLDOWN, FIL_RUNOUT7_PULLDOWN, FIL_RUNOUT8_PULLDOWN, \ - POWER_LOSS_PULLDOWN, CALIBRATION_PIN_PULLDOWN \ - ) - #error "PULLDOWN pin mode is not available on the selected board." -#endif - #if BOTH(ENDSTOPPULLUPS, ENDSTOPPULLDOWNS) #error "Enable only one of ENDSTOPPULLUPS or ENDSTOPPULLDOWNS." #elif BOTH(FIL_RUNOUT_PULLUP, FIL_RUNOUT_PULLDOWN) From 20b5615305639c9e33907a755cee1c22cc5aa664 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 26 Mar 2022 16:44:22 +1300 Subject: [PATCH 171/203] =?UTF-8?q?=E2=9C=A8=20Configurable=20FREEZE=20pin?= =?UTF-8?q?=20state=20(#23944)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 1 + Marlin/src/MarlinCore.cpp | 10 +++++++--- Marlin/src/inc/Conditionals_post.h | 14 +++----------- Marlin/src/inc/SanityCheck.h | 4 ++-- Marlin/src/module/stepper.cpp | 4 ++-- Marlin/src/module/stepper.h | 2 +- Marlin/src/pins/pinsDebug_list.h | 2 +- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 86eef1a026..195a0e8d16 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -4116,6 +4116,7 @@ //#define FREEZE_FEATURE #if ENABLED(FREEZE_FEATURE) //#define FREEZE_PIN 41 // Override the default (KILL) pin here + #define FREEZE_STATE LOW // State of pin indicating freeze #endif /** diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 4117d3f382..b1684d8928 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -476,7 +476,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { #endif #if HAS_FREEZE_PIN - Stepper::frozen = !READ(FREEZE_PIN); + Stepper::frozen = READ(FREEZE_PIN) ^ DISABLED(INVERT_FREEZE_PIN); #endif #if HAS_HOME @@ -1166,9 +1166,13 @@ void setup() { #endif #endif - #if HAS_FREEZE_PIN + #if ENABLED(FREEZE_FEATURE) SETUP_LOG("FREEZE_PIN"); - SET_INPUT_PULLUP(FREEZE_PIN); + #if FREEZE_STATE + SET_INPUT_PULLDOWN(FREEZE_PIN); + #else + SET_INPUT_PULLUP(FREEZE_PIN); + #endif #endif #if HAS_SUICIDE diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index dd175ac2cc..85ccb8088e 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2824,17 +2824,9 @@ #endif // User Interface -#if ENABLED(FREEZE_FEATURE) - #if !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL) - #define FREEZE_PIN KILL_PIN - #endif - #if PIN_EXISTS(FREEZE) - #define HAS_FREEZE_PIN 1 - #endif -#else - #undef FREEZE_PIN -#endif -#if PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN) +#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL) + #define FREEZE_PIN KILL_PIN +#elif PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN) #define HAS_KILL 1 #endif #if PIN_EXISTS(HOME) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 552a627093..405c9fd7ca 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1035,8 +1035,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Instant Freeze */ -#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE) - #error "FREEZE_FEATURE requires a FREEZE_PIN to be defined." +#if ENABLED(FREEZE_FEATURE) && !(PIN_EXISTS(FREEZE) && defined(FREEZE_STATE)) + #error "FREEZE_FEATURE requires both FREEZE_PIN and FREEZE_STATE." #endif /** diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index f83104fe9c..af64d9f8bf 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -189,7 +189,7 @@ bool Stepper::abort_current_block; uint32_t Stepper::acceleration_time, Stepper::deceleration_time; uint8_t Stepper::steps_per_isr; -#if HAS_FREEZE_PIN +#if ENABLED(FREEZE_FEATURE) bool Stepper::frozen; // = false #endif @@ -1643,7 +1643,7 @@ void Stepper::pulse_phase_isr() { if (!current_block) return; // Skipping step processing causes motion to freeze - if (TERN0(HAS_FREEZE_PIN, frozen)) return; + if (TERN0(FREEZE_FEATURE, frozen)) return; // Count of pending loops and events for this iteration const uint32_t pending_events = step_event_count - step_events_completed; diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 99aa714ca0..4c9fbb9556 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -336,7 +336,7 @@ class Stepper { static constexpr uint8_t last_moved_extruder = 0; #endif - #if HAS_FREEZE_PIN + #if ENABLED(FREEZE_FEATURE) static bool frozen; // Set this flag to instantly freeze motion #endif diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 2328a826ef..d7e84b9966 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -823,7 +823,7 @@ #if HAS_KILL REPORT_NAME_DIGITAL(__LINE__, KILL_PIN) #endif -#if HAS_FREEZE_PIN +#if PIN_EXISTS(FREEZE) REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN) #endif #if PIN_EXISTS(LCD_BACKLIGHT) From 692f42ee7d5773f66c6bb018ae55f3f74c83d5d9 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Sun, 27 Mar 2022 00:22:41 +0100 Subject: [PATCH 172/203] =?UTF-8?q?=E2=9C=A8=20Configurable=20FREEZE=20pin?= =?UTF-8?q?=20state=20(#23948)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index b1684d8928..be93bfcfb9 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -476,7 +476,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { #endif #if HAS_FREEZE_PIN - Stepper::frozen = READ(FREEZE_PIN) ^ DISABLED(INVERT_FREEZE_PIN); + stepper.frozen = READ(FREEZE_PIN) == FREEZE_STATE; #endif #if HAS_HOME From 6741f5182deb0dd24b6227c6c1238326ba6721a7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 26 Mar 2022 18:54:02 -0500 Subject: [PATCH 173/203] Simplify menu items, use enum --- Marlin/src/feature/pause.cpp | 4 ++-- Marlin/src/feature/runout.cpp | 2 +- Marlin/src/feature/runout.h | 19 +++++++++++++------ Marlin/src/lcd/menu/menu_advanced.cpp | 22 +++++++++++----------- Marlin/src/module/endstops.cpp | 8 ++++---- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 34ebcbc7f0..8aa1ff4f03 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -217,8 +217,8 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) #undef _CASE_RUNOUT } - const uint8_t rm = runout.mode[i - 1]; - if (rm != 0 && rm != 7 && extDigitalRead(pin) != runout.out_state(i - 1)) + const RunoutMode rm = runout.mode[i - 1]; + if (rm != RM_NONE && rm != RM_MOTION_SENSOR && extDigitalRead(pin) != runout.out_state(i - 1)) wait_for_user = false; } #else diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 96238c0f80..aae92d423f 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -34,7 +34,7 @@ FilamentMonitor runout; bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS], // Initialized by settings.load FilamentMonitorBase::filament_ran_out; // = false -uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load +RunoutMode FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 72faaef449..3149a21d37 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -61,12 +61,19 @@ extern FilamentMonitor runout; /*******************************************************************************************/ +enum RunoutMode : uint8_t { + RM_NONE, + RM_ACTIVE_LOW, + RM_ACTIVE_HIGH, + RM_MOTION_SENSOR = 7 +}; + class FilamentMonitorBase { public: static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out; - static uint8_t mode[NUM_RUNOUT_SENSORS]; // 0:NONE 1:Switch NC 2:Switch NO 7:Motion Sensor + static RunoutMode mode[NUM_RUNOUT_SENSORS]; - static uint8_t out_state(const uint8_t e=0) { return mode[e] == 2 ? HIGH : LOW; } + static uint8_t out_state(const uint8_t e=0) { return mode[e] == RM_ACTIVE_HIGH ? HIGH : LOW; } #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -111,7 +118,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Give the response a chance to update its counter. static void run() { - if (enabled[active_extruder] && mode[active_extruder]!=0 && !filament_ran_out && (printingIsActive() || did_pause_print)) { + if (enabled[active_extruder] && mode[active_extruder] != RM_NONE && !filament_ran_out && (printingIsActive() || did_pause_print)) { cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); sensor.run(); @@ -251,7 +258,7 @@ class FilamentSensorCore : public FilamentSensorBase { public: static void block_completed(const block_t * const b) { - if (runout.mode[active_extruder] != 7) return; + if (runout.mode[active_extruder] != RM_MOTION_SENSOR) return; // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. @@ -263,10 +270,10 @@ class FilamentSensorCore : public FilamentSensorBase { } static void run() { - if (runout.mode[active_extruder] == 7) { + if (runout.mode[active_extruder] == RM_MOTION_SENSOR) { poll_motion_sensor(); } - else if (runout.mode[active_extruder] != 0) { + else if (runout.mode[active_extruder] != RM_NONE) { LOOP_L_N(s, NUM_RUNOUT_SENSORS) { const bool out = poll_runout_state(s); if (!out) filament_present(s); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index ac2da4d8a6..6ceb4b8424 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -99,23 +99,23 @@ void menu_backlash(); #if HAS_FILAMENT_SENSOR + void set_runout_mode_none(const uint8_t e) { runout.mode[e] = RM_NONE; } + void set_runout_mode_high(const uint8_t e) { runout.mode[e] = RM_ACTIVE_HIGH; } + void set_runout_mode_low(const uint8_t e) { runout.mode[e] = RM_ACTIVE_LOW; } + void set_runout_mode_motion(const uint8_t e) { runout.mode[e] = RM_MOTION_SENSOR; } + #define RUNOUT_EDIT_ITEMS(F) do{ \ - EDIT_ITEM_N(bool, F, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F);}); \ + EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ + ACTION_ITEM(MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F); }); \ editable.decimal = runout.runout_distance(F); \ - EDIT_ITEM_FAST_N(float3, F, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ + EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ []{ runout.set_runout_distance(editable.decimal, F); }, true \ ); \ }while(0) - void set_runout_mode_none(uint8_t e) { runout.mode[e] = 0; } - void set_runout_mode_high(uint8_t e) { runout.mode[e] = 1; } - void set_runout_mode_low(uint8_t e) { runout.mode[e] = 2; } - void set_runout_mode_motion(uint8_t e) { runout.mode[e] = 7; } - void menu_runout_config() { START_MENU(); BACK_ITEM(MSG_CONFIGURATION); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index f41a6c9f87..c9bf1f4eb9 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -583,15 +583,15 @@ void _O2 Endstops::report_states() { REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) #undef _CASE_RUNOUT } - const uint8_t rm = runout.mode[i - 1], - state = runout.out_state(i - 1); + const RunoutMode rm = runout.mode[i - 1]; + const uint8_t state = runout.out_state(i - 1); SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); SERIAL_ECHOPGM(": "); - if (rm == 0) + if (rm == RM_NONE) SERIAL_ECHOLNPGM("DISABLED"); - else if (rm == 7) { + else if (rm == RM_MOTION_SENSOR) { SERIAL_ECHOPGM("MOTION : "); print_es_state(extDigitalRead(pin) == state); } From 4a54f8469e66a4f59c6284646885545d52f6e164 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 27 Mar 2022 00:01:26 +0000 Subject: [PATCH 174/203] [cron] Bump distribution date (2022-03-27) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 7c598cb101..f562113fac 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-26" +//#define STRING_DISTRIBUTION_DATE "2022-03-27" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 32ddb7340d..de258fc986 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-26" + #define STRING_DISTRIBUTION_DATE "2022-03-27" #endif /** From bdfe4ca4d154c61740eb4a1d2d33bc9f21dce404 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 26 Mar 2022 18:54:02 -0500 Subject: [PATCH 175/203] Simplify menu items, use enum, adjust settings --- Marlin/src/feature/pause.cpp | 4 +- Marlin/src/feature/runout.cpp | 2 +- Marlin/src/feature/runout.h | 19 ++++-- Marlin/src/gcode/feature/runout/M591.cpp | 24 ++++---- Marlin/src/lcd/menu/menu_advanced.cpp | 22 +++---- Marlin/src/module/endstops.cpp | 14 ++--- Marlin/src/module/settings.cpp | 77 +++++++++++------------- 7 files changed, 79 insertions(+), 83 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 34ebcbc7f0..8aa1ff4f03 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -217,8 +217,8 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) #undef _CASE_RUNOUT } - const uint8_t rm = runout.mode[i - 1]; - if (rm != 0 && rm != 7 && extDigitalRead(pin) != runout.out_state(i - 1)) + const RunoutMode rm = runout.mode[i - 1]; + if (rm != RM_NONE && rm != RM_MOTION_SENSOR && extDigitalRead(pin) != runout.out_state(i - 1)) wait_for_user = false; } #else diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 96238c0f80..aae92d423f 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -34,7 +34,7 @@ FilamentMonitor runout; bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS], // Initialized by settings.load FilamentMonitorBase::filament_ran_out; // = false -uint8_t FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load +RunoutMode FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load #if ENABLED(HOST_ACTION_COMMANDS) bool FilamentMonitorBase::host_handling; // = false #endif diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 72faaef449..57a7a0950d 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -61,12 +61,19 @@ extern FilamentMonitor runout; /*******************************************************************************************/ +enum RunoutMode : uint8_t { + RM_NONE, + RM_OUT_ON_LOW, + RM_OUT_ON_HIGH, + RM_MOTION_SENSOR +}; + class FilamentMonitorBase { public: static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out; - static uint8_t mode[NUM_RUNOUT_SENSORS]; // 0:NONE 1:Switch NC 2:Switch NO 7:Motion Sensor + static RunoutMode mode[NUM_RUNOUT_SENSORS]; - static uint8_t out_state(const uint8_t e=0) { return mode[e] == 2 ? HIGH : LOW; } + static uint8_t out_state(const uint8_t e=0) { return mode[e] == RM_OUT_ON_HIGH ? HIGH : LOW; } #if ENABLED(HOST_ACTION_COMMANDS) static bool host_handling; @@ -111,7 +118,7 @@ class TFilamentMonitor : public FilamentMonitorBase { // Give the response a chance to update its counter. static void run() { - if (enabled[active_extruder] && mode[active_extruder]!=0 && !filament_ran_out && (printingIsActive() || did_pause_print)) { + if (enabled[active_extruder] && mode[active_extruder] != RM_NONE && !filament_ran_out && (printingIsActive() || did_pause_print)) { cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); sensor.run(); @@ -251,7 +258,7 @@ class FilamentSensorCore : public FilamentSensorBase { public: static void block_completed(const block_t * const b) { - if (runout.mode[active_extruder] != 7) return; + if (runout.mode[active_extruder] != RM_MOTION_SENSOR) return; // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. @@ -263,10 +270,10 @@ class FilamentSensorCore : public FilamentSensorBase { } static void run() { - if (runout.mode[active_extruder] == 7) { + if (runout.mode[active_extruder] == RM_MOTION_SENSOR) { poll_motion_sensor(); } - else if (runout.mode[active_extruder] != 0) { + else if (runout.mode[active_extruder] != RM_NONE) { LOOP_L_N(s, NUM_RUNOUT_SENSORS) { const bool out = poll_runout_state(s); if (!out) filament_present(s); diff --git a/Marlin/src/gcode/feature/runout/M591.cpp b/Marlin/src/gcode/feature/runout/M591.cpp index 0751de879a..271e56ad53 100644 --- a/Marlin/src/gcode/feature/runout/M591.cpp +++ b/Marlin/src/gcode/feature/runout/M591.cpp @@ -39,7 +39,7 @@ * P : Mode 0 = NONE * 1 = Switch NO (HIGH = filament present) * 2 = Switch NC (LOW = filament present) - * 7 = Encoder / Motion Sensor + * 3 = Encoder / Motion Sensor */ void GcodeSuite::M591() { if (parser.seen("RSDP" TERN_(HOST_ACTION_COMMANDS, "H"))) { @@ -48,19 +48,17 @@ void GcodeSuite::M591() { #endif const bool seenR = parser.seen_test('R'), seenS = parser.seen('S'); if (seenR || seenS) runout.reset(); - #if NUM_RUNOUT_SENSORS > 1 - const uint8_t tool = parser.ushortval('E', active_extruder); - #else - constexpr uint8_t tool = 0; - #endif + const uint8_t tool = TERN0(MULTI_FILAMENT_SENSOR, parser.ushortval('E', active_extruder)); if (seenS) runout.enabled[tool] = parser.value_bool(); - if (parser.seen('D')) runout.set_runout_distance(parser.value_linear_units(), tool); - if (parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); + if (parser.seen('D') || parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool); if (parser.seen('P')) { - const uint8_t tmp_mode = parser.value_int(); - if (tmp_mode < 3 || tmp_mode == 7) { - runout.mode[tool] = tmp_mode; - runout.reset(); + const RunoutMode tmp_mode = (RunoutMode)parser.value_int(); + switch (tmp_mode) { + case RM_NONE ... RM_OUT_ON_HIGH: + case RM_MOTION_SENSOR: + runout.mode[tool] = tmp_mode; + runout.reset(); + default: break; } } } @@ -83,7 +81,7 @@ void GcodeSuite::M591_report(const bool forReplay/*=true*/) { LOOP_S_L_N(e, 1, NUM_RUNOUT_SENSORS) SERIAL_ECHOLNPGM( " M591" - #if NUM_RUNOUT_SENSORS > 1 + #if MULTI_FILAMENT_SENSOR " E", e, #endif " S", runout.enabled[e] diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index ac2da4d8a6..0b6d855974 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -99,23 +99,23 @@ void menu_backlash(); #if HAS_FILAMENT_SENSOR + void set_runout_mode_none(const uint8_t e) { runout.mode[e] = RM_NONE; } + void set_runout_mode_high(const uint8_t e) { runout.mode[e] = RM_OUT_ON_HIGH; } + void set_runout_mode_low(const uint8_t e) { runout.mode[e] = RM_OUT_ON_LOW; } + void set_runout_mode_motion(const uint8_t e) { runout.mode[e] = RM_MOTION_SENSOR; } + #define RUNOUT_EDIT_ITEMS(F) do{ \ - EDIT_ITEM_N(bool, F, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F);}); \ - ACTION_ITEM_N(F, MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F);}); \ + EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \ + ACTION_ITEM(MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F); }); \ + ACTION_ITEM(MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F); }); \ editable.decimal = runout.runout_distance(F); \ - EDIT_ITEM_FAST_N(float3, F, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ + EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \ []{ runout.set_runout_distance(editable.decimal, F); }, true \ ); \ }while(0) - void set_runout_mode_none(uint8_t e) { runout.mode[e] = 0; } - void set_runout_mode_high(uint8_t e) { runout.mode[e] = 1; } - void set_runout_mode_low(uint8_t e) { runout.mode[e] = 2; } - void set_runout_mode_motion(uint8_t e) { runout.mode[e] = 7; } - void menu_runout_config() { START_MENU(); BACK_ITEM(MSG_CONFIGURATION); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index f41a6c9f87..0b942784ca 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -583,20 +583,20 @@ void _O2 Endstops::report_states() { REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT) #undef _CASE_RUNOUT } - const uint8_t rm = runout.mode[i - 1], - state = runout.out_state(i - 1); + const RunoutMode rm = runout.mode[i - 1]; + const uint8_t outval = runout.out_state(i - 1); SERIAL_ECHOPGM(STR_FILAMENT); if (i > 1) SERIAL_CHAR(' ', '0' + i); SERIAL_ECHOPGM(": "); - if (rm == 0) - SERIAL_ECHOLNPGM("DISABLED"); - else if (rm == 7) { + if (rm == RM_NONE) + SERIAL_ECHOLNPGM(STR_OFF); + else if (rm == RM_MOTION_SENSOR) { SERIAL_ECHOPGM("MOTION : "); - print_es_state(extDigitalRead(pin) == state); + print_es_state(extDigitalRead(pin) == outval); } else - SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == state ? PSTR("MISSING") : PSTR("PRESENT")); + SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == outval ? PSTR("OUT") : PSTR("PRESENT")); } #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 7c10698ccc..ffb96cddf5 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -112,9 +112,6 @@ #if HAS_FILAMENT_SENSOR #include "../feature/runout.h" - #define NRS NUM_RUNOUT_SENSORS -#else - #define NRS 1 #endif #if ENABLED(EXTRA_LIN_ADVANCE_K) @@ -235,9 +232,11 @@ typedef struct SettingsDataStruct { // // FILAMENT_RUNOUT_SENSOR // - bool runout_enabled[NRS]; // M591 S - float runout_distance_mm[NRS]; // M591 D - uint8_t runout_mode[NRS]; // M591 P + #if HAS_FILAMENT_SENSOR + bool runout_enabled[NUM_RUNOUT_SENSORS]; // M591 S + float runout_distance_mm[NUM_RUNOUT_SENSORS]; // M591 D + uint8_t runout_mode[NUM_RUNOUT_SENSORS]; // M591 P + #endif // // ENABLE_LEVELING_FADE_HEIGHT @@ -781,29 +780,23 @@ void MarlinSettings::postprocess() { // // Hotend Offsets, if any // - { - #if HAS_HOTEND_OFFSET - // Skip hotend 0 which must be 0 - LOOP_S_L_N(e, 1, HOTENDS) - EEPROM_WRITE(hotend_offset[e]); - #endif - } + #if HAS_HOTEND_OFFSET + // Skip hotend 0 which must be 0 + LOOP_S_L_N(e, 1, HOTENDS) + EEPROM_WRITE(hotend_offset[e]); + #endif // // Filament Runout Sensor // + #if HAS_FILAMENT_SENSOR { _FIELD_TEST(runout_enabled); - #if HAS_FILAMENT_SENSOR - LOOP_L_N(e, NRS) EEPROM_WRITE(runout.enabled[e]); - LOOP_L_N(e, NRS) EEPROM_WRITE(runout.runout_distance(e)); - LOOP_L_N(e, NRS) EEPROM_WRITE(runout.mode[e]); - #else - EEPROM_WRITE((int8_t)-1); - EEPROM_WRITE((float)-0.0f); - EEPROM_WRITE((uint8_t)0); - #endif + LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.enabled[e]); + LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.runout_distance(e)); + LOOP_L_N(e, NUM_RUNOUT_SENSORS) EEPROM_WRITE(runout.mode[e]); } + #endif // // Global Leveling @@ -1707,30 +1700,28 @@ void MarlinSettings::postprocess() { // // Filament Runout Sensor // + #if HAS_FILAMENT_SENSOR { _FIELD_TEST(runout_enabled); - int8_t runout_enabled[NRS]; - float runout_distance_mm[NRS]; - uint8_t runout_mode[NRS]; + bool runout_enabled[NUM_RUNOUT_SENSORS]; + float runout_distance_mm[NUM_RUNOUT_SENSORS]; + RunoutMode runout_mode[NUM_RUNOUT_SENSORS]; - LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_enabled[e]); - LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_distance_mm[e]); - LOOP_S_L_N(e, 0, NRS) EEPROM_READ(runout_mode[e]); + EEPROM_READ(runout_enabled); + EEPROM_READ(runout_distance_mm); + EEPROM_READ(runout_mode); - #if HAS_FILAMENT_SENSOR - if (!validating) { - LOOP_S_L_N(e, 0, NRS) { - if (runout_enabled[e] >= 0) { - runout.enabled[e] = (runout_enabled[e] > 0); - runout.set_runout_distance(runout_distance_mm[e], e); - runout.mode[e] = runout_mode[e]; - } - } - runout.reset(); + if (!validating) { + LOOP_S_L_N(e, 0, NUM_RUNOUT_SENSORS) { + runout.enabled[e] = runout_enabled[e]; + runout.set_runout_distance(runout_distance_mm[e], e); + runout.mode[e] = runout_mode[e]; } - #endif + runout.reset(); + } } + #endif // // Global Leveling @@ -2797,12 +2788,12 @@ void MarlinSettings::reset() { constexpr bool fred[] = FIL_RUNOUT_ENABLED; constexpr uint8_t frm[] = FIL_RUNOUT_MODE; constexpr float frd[] = FIL_RUNOUT_DISTANCE_MM; - static_assert(COUNT(fred) == NRS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values."); - static_assert(COUNT(frm) == NRS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values."); - static_assert(COUNT(frd) == NRS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(fred) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(frm) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values."); + static_assert(COUNT(frd) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values."); COPY(runout.enabled, fred); COPY(runout.mode, frm); - LOOP_L_N(e, NRS) runout.set_runout_distance(frd[e], e); + LOOP_L_N(e, NUM_RUNOUT_SENSORS) runout.set_runout_distance(frd[e], e); runout.reset(); #endif From d95dca94b9db85fdad3297ff28af6132573c972c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 26 Mar 2022 21:58:19 -0500 Subject: [PATCH 176/203] =?UTF-8?q?=F0=9F=94=A8=20Update=20TMC26XStepper?= =?UTF-8?q?=20link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/features.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ini/features.ini b/ini/features.ini index 9150ff5451..8e45b71e42 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -24,7 +24,7 @@ HAS_STEALTHCHOP = src_filter=+ -HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip +HAS_TMC26X = TMC26XStepper=https://github.com/MarlinFirmware/TMC26XStepper/archive/master.zip src_filter=+ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + + From d806a668e856b1ea91e0c8311bf83e8b330c77d1 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 28 Mar 2022 00:01:49 +0000 Subject: [PATCH 177/203] [cron] Bump distribution date (2022-03-28) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index f562113fac..88407bab10 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-27" +//#define STRING_DISTRIBUTION_DATE "2022-03-28" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index de258fc986..70ccda9742 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-27" + #define STRING_DISTRIBUTION_DATE "2022-03-28" #endif /** From 46c820499018533d9165d7f608297f16ec9100b9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 27 Mar 2022 19:46:47 -0500 Subject: [PATCH 178/203] Extend enum --- Marlin/src/feature/runout.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 57a7a0950d..8002be156d 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -65,6 +65,10 @@ enum RunoutMode : uint8_t { RM_NONE, RM_OUT_ON_LOW, RM_OUT_ON_HIGH, + RM_RESERVED3, + RM_RESERVED4, + RM_RESERVED5, + RM_RESERVED6, RM_MOTION_SENSOR }; From bdc2b2b9653aeaef1922176b82a1d99c940cc5e7 Mon Sep 17 00:00:00 2001 From: David Forrest Date: Sun, 27 Mar 2022 21:19:02 -0400 Subject: [PATCH 179/203] =?UTF-8?q?=F0=9F=94=A8=20Fix=20Makefile=20GCC=20w?= =?UTF-8?q?arning=20(#23957)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Makefile b/Marlin/Makefile index eee1403b53..f1c89ff7f5 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -132,7 +132,7 @@ CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d\ ) CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d\ ) CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) ))) ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1) - @echo This version of GCC is likely broken. Enabling relocation workaround. + $(warning This GCC version $(CC_VER) is likely broken. Enabling relocation workaround.) RELOC_WORKAROUND = 1 endif From 59f2f4fd47deaea59b7a8f1a43e8a66e05f17ca6 Mon Sep 17 00:00:00 2001 From: Ludy Date: Mon, 28 Mar 2022 03:20:54 +0200 Subject: [PATCH 180/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MMU2=20buzz=20(#23?= =?UTF-8?q?950)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23943 --- Marlin/src/libs/buzzer.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/src/libs/buzzer.h b/Marlin/src/libs/buzzer.h index 9fc46ff629..73406c0591 100644 --- a/Marlin/src/libs/buzzer.h +++ b/Marlin/src/libs/buzzer.h @@ -129,6 +129,5 @@ #endif #define ERR_BUZZ() BUZZ(400, 40); -#define ATTN_BUZZ() do{ BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); }while(0) #define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0) #define DONE_BUZZ(OK) do{ if (OK) OKAY_BUZZ(); else ERR_BUZZ(); }while(0) From 0b669067b9e6b19432007fbe0ec22941ae215631 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 29 Mar 2022 00:31:43 +0000 Subject: [PATCH 181/203] [cron] Bump distribution date (2022-03-29) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 88407bab10..51767464fc 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-28" +//#define STRING_DISTRIBUTION_DATE "2022-03-29" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 70ccda9742..16681d07c6 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-28" + #define STRING_DISTRIBUTION_DATE "2022-03-29" #endif /** From 51d4c5abea02764e096e846f7fa2cff93cf75d90 Mon Sep 17 00:00:00 2001 From: John Lagonikas <39417467+zeleps@users.noreply.github.com> Date: Tue, 29 Mar 2022 11:13:45 +0300 Subject: [PATCH 182/203] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20parking=20ex?= =?UTF-8?q?truder=20compile=20(#23961)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to d3e3e6a491 --- Marlin/src/feature/solenoid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/solenoid.cpp b/Marlin/src/feature/solenoid.cpp index f78a529280..861e44ed05 100644 --- a/Marlin/src/feature/solenoid.cpp +++ b/Marlin/src/feature/solenoid.cpp @@ -38,7 +38,7 @@ static void set_solenoid(const uint8_t num, const uint8_t state) { } #if ENABLED(PARKING_EXTRUDER) - if (!active && active_extruder == num) // If active extruder's solenoid is disabled, carriage is considered parked + if (state == LOW && active_extruder == num) // If active extruder's solenoid is disabled, carriage is considered parked parking_extruder_set_parked(true); #endif } From 4edfb690dd7a3327bb80c1ffe6940b73554d0a53 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 29 Mar 2022 03:24:15 -0500 Subject: [PATCH 183/203] =?UTF-8?q?=F0=9F=92=9A=20Lock=20CI=20testing=20to?= =?UTF-8?q?=20PlatformIO=205.2.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test-builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml index 75cd6ee05f..069f36714d 100644 --- a/.github/workflows/test-builds.yml +++ b/.github/workflows/test-builds.yml @@ -137,7 +137,7 @@ jobs: - name: Install PlatformIO run: | - pip install -U https://github.com/platformio/platformio-core/archive/develop.zip + pip install -U https://github.com/platformio/platformio-core/archive/v5.2.5.zip platformio update - name: Run ${{ matrix.test-platform }} Tests From d6fcae40c4ded0901aae33f7a1a9d5049ab12b89 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 29 Mar 2022 03:38:25 -0500 Subject: [PATCH 184/203] =?UTF-8?q?=F0=9F=92=A5=20Rename=20ExtUI=20setting?= =?UTF-8?q?s=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp | 4 ++-- Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp | 4 ++-- Marlin/src/lcd/extui/dgus/dgus_extui.cpp | 4 ++-- Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp | 4 ++-- Marlin/src/lcd/extui/example/example.cpp | 4 ++-- Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp | 4 ++-- Marlin/src/lcd/extui/malyan/malyan_extui.cpp | 4 ++-- Marlin/src/lcd/extui/nextion/nextion_extui.cpp | 5 +++-- Marlin/src/lcd/extui/ui_api.h | 4 ++-- Marlin/src/module/printcounter.cpp | 2 +- Marlin/src/module/settings.cpp | 4 ++-- 11 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp index b9fe8f967c..75061c162a 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp @@ -94,12 +94,12 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp index da8f4e26a0..469202ee22 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp @@ -83,12 +83,12 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } diff --git a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp index 0041be8276..b041687a14 100644 --- a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp +++ b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp @@ -102,12 +102,12 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp index 5c330bd6b4..f6f2c0f89d 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp @@ -100,11 +100,11 @@ namespace ExtUI { void onPostprocessSettings() {} - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { dgus_screen_handler.ConfigurationStoreWritten(success); } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { dgus_screen_handler.ConfigurationStoreRead(success); } diff --git a/Marlin/src/lcd/extui/example/example.cpp b/Marlin/src/lcd/extui/example/example.cpp index dd0f8e401e..6ef20cf5f0 100644 --- a/Marlin/src/lcd/extui/example/example.cpp +++ b/Marlin/src/lcd/extui/example/example.cpp @@ -88,12 +88,12 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index 1c7b3621f2..2ce9ed027e 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -97,7 +97,7 @@ namespace ExtUI { void onLoadSettings(const char *buff) { InterfaceSettingsScreen::loadSettings(buff); } void onPostprocessSettings() {} // Called after loading or resetting stored settings - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE if (success && InterfaceSettingsScreen::backupEEPROM()) { SERIAL_ECHOLNPGM("EEPROM backed up to SPI Flash"); @@ -106,7 +106,7 @@ namespace ExtUI { UNUSED(success); #endif } - void onConfigurationStoreRead(bool) {} + void onSettingsLoaded(bool) {} void onPlayTone(const uint16_t frequency, const uint16_t duration) { sound.play_tone(frequency, duration); } diff --git a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp index 2d36a4e737..945ff472e1 100644 --- a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp @@ -147,8 +147,8 @@ namespace ExtUI { void onStoreSettings(char*) {} void onLoadSettings(const char*) {} void onPostprocessSettings() {} - void onConfigurationStoreWritten(bool) {} - void onConfigurationStoreRead(bool) {} + void onSettingsStored(bool) {} + void onSettingsLoaded(bool) {} #if HAS_MESH void onLevelingStart() {} diff --git a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp index c15175a28d..da54fac383 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp @@ -79,12 +79,12 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } @@ -117,6 +117,7 @@ namespace ExtUI { void onSteppersDisabled() {} void onSteppersEnabled() {} + } #endif // NEXTION_TFT diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 248bffb6f4..84b2ed8c6d 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -420,8 +420,8 @@ namespace ExtUI { void onStoreSettings(char *); void onLoadSettings(const char *); void onPostprocessSettings(); - void onConfigurationStoreWritten(bool success); - void onConfigurationStoreRead(bool success); + void onSettingsStored(bool success); + void onSettingsLoaded(bool success); #if ENABLED(POWER_LOSS_RECOVERY) void onPowerLossResume(); #endif diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index c35b722cf4..fbf5401d67 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -171,7 +171,7 @@ void PrintCounter::saveStats() { persistentStore.write_data(address + sizeof(uint8_t), (uint8_t*)&data, sizeof(printStatistics)); persistentStore.access_finish(); - TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreWritten(true)); + TERN_(EXTENSIBLE_UI, ExtUI::onSettingsStored(true)); } #if HAS_SERVICE_INTERVALS diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 1f482afeb4..02d1b26437 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1595,7 +1595,7 @@ void MarlinSettings::postprocess() { TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_SETTINGS_STORED))); } - TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreWritten(!eeprom_error)); + TERN_(EXTENSIBLE_UI, ExtUI::onSettingsStored(!eeprom_error)); return !eeprom_error; } @@ -2598,7 +2598,7 @@ void MarlinSettings::postprocess() { bool MarlinSettings::load() { if (validate()) { const bool success = _load(); - TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreRead(success)); + TERN_(EXTENSIBLE_UI, ExtUI::onSettingsLoaded(success)); return success; } reset(); From 0752082b85ce94cd81153145d7940fca96b3286a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 29 Mar 2022 03:48:37 -0500 Subject: [PATCH 185/203] =?UTF-8?q?=F0=9F=8E=A8=20=20INI=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/features.ini | 2 +- platformio.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ini/features.ini b/ini/features.ini index 8e45b71e42..a153b18530 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -199,11 +199,11 @@ AUTO_REPORT_POSITION = src_filter=+ REPETIER_GCODE_M360 = src_filter=+ HAS_GCODE_M876 = src_filter=+ HAS_RESUME_CONTINUE = src_filter=+ +LCD_SET_PROGRESS_MANUALLY = src_filter=+ HAS_STATUS_MESSAGE = src_filter=+ HAS_LCD_CONTRAST = src_filter=+ HAS_LCD_BRIGHTNESS = src_filter=+ HAS_BUZZER = src_filter=+ -LCD_SET_PROGRESS_MANUALLY = src_filter=+ TOUCH_SCREEN_CALIBRATION = src_filter=+ ARC_SUPPORT = src_filter=+ GCODE_MOTION_MODES = src_filter=+ diff --git a/platformio.ini b/platformio.ini index 0e50da2b73..952912b21d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -215,11 +215,11 @@ default_src_filter = + - - + - - - + - - - - - - - - - - - From 6015ee2531269e9382370babba63f883592a416a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 29 Mar 2022 04:22:04 -0500 Subject: [PATCH 186/203] =?UTF-8?q?=F0=9F=8E=A8=20=20Combine=20common=20LP?= =?UTF-8?q?C1768=20I2C=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/digipot_mcp4451_I2C_routines.c | 33 ++--------------- Marlin/src/HAL/LPC1768/include/i2c_util.c | 26 ++++++++++++++ Marlin/src/HAL/LPC1768/include/i2c_util.h | 5 +++ .../src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp | 36 +------------------ 4 files changed, 34 insertions(+), 66 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/include/digipot_mcp4451_I2C_routines.c b/Marlin/src/HAL/LPC1768/include/digipot_mcp4451_I2C_routines.c index f442ab71c0..c489c16e5e 100644 --- a/Marlin/src/HAL/LPC1768/include/digipot_mcp4451_I2C_routines.c +++ b/Marlin/src/HAL/LPC1768/include/digipot_mcp4451_I2C_routines.c @@ -29,7 +29,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if MB(MKS_SBASE) +#if ENABLED(DIGIPOT_MCP4451) && MB(MKS_SBASE) #ifdef __cplusplus extern "C" { @@ -37,35 +37,6 @@ #include "digipot_mcp4451_I2C_routines.h" -// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to -// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them. - -static uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) { - // Reset STA, STO, SI - I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC; - - // Enter to Master Transmitter mode - I2Cx->I2CONSET = I2C_I2CONSET_STA; - - // Wait for complete - while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI)); - I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; - return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); -} - -static void _I2C_Stop(LPC_I2C_TypeDef *I2Cx) { - // Make sure start bit is not active - if (I2Cx->I2CONSET & I2C_I2CONSET_STA) - I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; - - I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA; - I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; -} - -I2C_M_SETUP_Type transferMCfg; - -#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK) - uint8_t digipot_mcp4451_start(uint8_t sla) { // send slave address and write bit // Sometimes TX data ACK or NAK status is returned. That mean the start state didn't // happen which means only the value of the slave address was send. Keep looping until @@ -102,5 +73,5 @@ uint8_t digipot_mcp4451_send_byte(uint8_t data) { } #endif -#endif // MB(MKS_SBASE) +#endif // DIGIPOT_MCP4451 && MKS_SBASE #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/include/i2c_util.c b/Marlin/src/HAL/LPC1768/include/i2c_util.c index e52fb7c4de..4e24f23236 100644 --- a/Marlin/src/HAL/LPC1768/include/i2c_util.c +++ b/Marlin/src/HAL/LPC1768/include/i2c_util.c @@ -63,6 +63,32 @@ void configure_i2c(const uint8_t clock_option) { I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE); } +////////////////////////////////////////////////////////////////////////////////////// +// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to +// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them. + +uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) { + // Reset STA, STO, SI + I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC; + + // Enter to Master Transmitter mode + I2Cx->I2CONSET = I2C_I2CONSET_STA; + + // Wait for complete + while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI)); + I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; + return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); +} + +void _I2C_Stop(LPC_I2C_TypeDef *I2Cx) { + /* Make sure start bit is not active */ + if (I2Cx->I2CONSET & I2C_I2CONSET_STA) + I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; + + I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA; + I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; +} + #ifdef __cplusplus } #endif diff --git a/Marlin/src/HAL/LPC1768/include/i2c_util.h b/Marlin/src/HAL/LPC1768/include/i2c_util.h index a57f68a407..1f1c19f279 100644 --- a/Marlin/src/HAL/LPC1768/include/i2c_util.h +++ b/Marlin/src/HAL/LPC1768/include/i2c_util.h @@ -51,6 +51,11 @@ void configure_i2c(const uint8_t clock_option); +uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx); +void _I2C_Stop(LPC_I2C_TypeDef *I2Cx); + +#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK) + #ifdef __cplusplus } #endif diff --git a/Marlin/src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp b/Marlin/src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp index a48a820dc4..e714c3c16d 100644 --- a/Marlin/src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp @@ -36,40 +36,7 @@ extern int millis(); ////////////////////////////////////////////////////////////////////////////////////// -// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to -// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them. - -static uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) { - // Reset STA, STO, SI - I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC; - - // Enter to Master Transmitter mode - I2Cx->I2CONSET = I2C_I2CONSET_STA; - - // Wait for complete - while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI)); - I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; - return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); -} - -static void _I2C_Stop (LPC_I2C_TypeDef *I2Cx) { - /* Make sure start bit is not active */ - if (I2Cx->I2CONSET & I2C_I2CONSET_STA) - I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; - - I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA; - I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; -} - -////////////////////////////////////////////////////////////////////////////////////// - -#define I2CDEV_S_ADDR 0x78 // from SSD1306 //actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write - -#define BUFFER_SIZE 0x1 // only do single byte transfers with LCDs - -I2C_M_SETUP_Type transferMCfg; - -#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK) +#define I2CDEV_S_ADDR 0x78 // From SSD1306 (actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write) // Send slave address and write bit uint8_t u8g_i2c_start(const uint8_t sla) { @@ -115,7 +82,6 @@ uint8_t u8g_i2c_send_byte(uint8_t data) { void u8g_i2c_stop() { } - #ifdef __cplusplus } #endif From 49539463b8ed8b15286014b122f87962b7c0f6f4 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Tue, 29 Mar 2022 05:41:33 -0400 Subject: [PATCH 187/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MarlinUI=20on=20En?= =?UTF-8?q?der=203=20S1=20(#23949)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/e3v2/common/dwin_api.cpp | 42 ++++++++++++++++++++++ Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp | 2 +- Marlin/src/lcd/e3v2/marlinui/ui_common.cpp | 24 +++++++++---- 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 405c9fd7ca..665381207f 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -853,7 +853,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Custom Boot and Status screens */ -#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE) +#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI) #error "SHOW_CUSTOM_BOOTSCREEN requires Graphical LCD or TOUCH_UI_FTDI_EVE." #elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN) #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN." diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index f6780bba6c..89d7cb4144 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -25,6 +25,7 @@ #include "dwin_api.h" #include "dwin_set.h" +#include "dwin_font.h" #include "../../../inc/MarlinConfig.h" @@ -89,6 +90,40 @@ bool DWIN_Handshake() { } #endif +// Get font character width +uint8_t fontWidth(uint8_t cfont) { + switch (cfont) { + case font6x12 : return 6; + 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; + } +} + +// Get font character height +uint8_t fontHeight(uint8_t cfont) { + switch (cfont) { + case font6x12 : return 12; + 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; + } +} + // Set screen display direction // dir: 0=0°, 1=90°, 2=180°, 3=270° void DWIN_Frame_SetDir(uint8_t dir) { @@ -199,6 +234,8 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // *string: The string // rlimit: To limit the drawn string length void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) { + DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); + DWIN_UpdateLCD(); constexpr uint8_t widthAdjust = 0; size_t i = 0; DWIN_Byte(i, 0x11); @@ -213,6 +250,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, DWIN_Word(i, y); DWIN_Text(i, string, rlimit); DWIN_Send(i); + DWIN_UpdateLCD(); } // Draw a positive integer @@ -228,6 +266,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) { size_t i = 0; + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); DWIN_Byte(i, 0x14); // Bit 7: bshow // Bit 6: 1 = signed; 0 = unsigned number; @@ -258,6 +297,7 @@ void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t #endif DWIN_Send(i); + DWIN_UpdateLCD(); } // Draw a floating point number @@ -275,6 +315,7 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_ uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) { //uint8_t *fvalue = (uint8_t*)&value; size_t i = 0; + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); DWIN_Byte(i, 0x14); DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); DWIN_Word(i, color); @@ -291,6 +332,7 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_ DWIN_Byte(i, fvalue[0]); */ DWIN_Send(i); + DWIN_UpdateLCD(); } // Draw a floating point number diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp index a4cefe4ab9..7154270bff 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp @@ -45,8 +45,8 @@ void DWIN_Startup() { const bool success = DWIN_Handshake(); if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error."); DWIN_Frame_SetDir(TERN(DWIN_MARLINUI_LANDSCAPE, 0, 1)); - DWIN_JPG_ShowAndCache(3); DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here + DWIN_JPG_ShowAndCache(3); DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index f49d06d396..4e0174705e 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -84,6 +84,7 @@ void MarlinUI::init_lcd() { DWIN_Startup(); } // This LCD should clear where it will draw anew void MarlinUI::clear_lcd() { DWIN_ICON_AnimationControl(0x0000); // disable all icon animations + DWIN_JPG_ShowAndCache(3); DWIN_Frame_Clear(Color_Bg_Black); DWIN_UpdateLCD(); @@ -93,29 +94,39 @@ void MarlinUI::clear_lcd() { #if ENABLED(SHOW_BOOTSCREEN) void MarlinUI::show_bootscreen() { - clear_lcd(); dwin_string.set(F(SHORT_BUILD_VERSION)); + #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && !defined(CUSTOM_BOOTSCREEN_TIMEOUT) + #define CUSTOM_BOOTSCREEN_TIMEOUT 3000 + #endif + #if ENABLED(DWIN_MARLINUI_PORTRAIT) #define LOGO_CENTER ((LCD_PIXEL_WIDTH) / 2) #define INFO_CENTER LOGO_CENTER #define VERSION_Y 330 - DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2, 15); + #else + #define LOGO_CENTER (280 / 2) + #define INFO_CENTER ((LCD_PIXEL_WIDTH) - 200 / 2) + #define VERSION_Y 84 + #endif + + DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length() * 10) / 2, VERSION_Y, S(dwin_string.string())); + TERN_(SHOW_CUSTOM_BOOTSCREEN, safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT)); + clear_lcd(); + + DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2, 15); + #if ENABLED(DWIN_MARLINUI_PORTRAIT) DWIN_ICON_Show(BOOT_ICON, ICON_OpenSource, LOGO_CENTER - 174 / 2, 280); DWIN_ICON_Show(BOOT_ICON, ICON_GitHubURL, LOGO_CENTER - 180 / 2, 420); DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL, LOGO_CENTER - 100 / 2, 440); DWIN_ICON_Show(BOOT_ICON, ICON_Copyright, LOGO_CENTER - 126 / 2, 460); #else - #define LOGO_CENTER (280 / 2) - #define INFO_CENTER ((LCD_PIXEL_WIDTH) - 200 / 2) - #define VERSION_Y 84 DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2, 15); DWIN_ICON_Show(BOOT_ICON, ICON_OpenSource, INFO_CENTER - 174 / 2, 60); DWIN_ICON_Show(BOOT_ICON, ICON_GitHubURL, INFO_CENTER - 180 / 2, 130); DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL, INFO_CENTER - 100 / 2, 152); DWIN_ICON_Show(BOOT_ICON, ICON_Copyright, INFO_CENTER - 126 / 2, 200); #endif - DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length() * 10) / 2, VERSION_Y, S(dwin_string.string())); DWIN_UpdateLCD(); } @@ -170,6 +181,7 @@ void MarlinUI::draw_status_message(const bool blink) { dwin_font.solid = true; dwin_font.fg = Color_White; dwin_font.bg = Color_Bg_Black; + DWIN_Draw_Box(1, Color_Bg_Black, 0, (LCD_PIXEL_HEIGHT - (STAT_FONT_HEIGHT) - 1), 272, STAT_FONT_HEIGHT + 1); lcd_moveto_xy(0, LCD_PIXEL_HEIGHT - (STAT_FONT_HEIGHT) - 1); constexpr uint8_t max_status_chars = (LCD_PIXEL_WIDTH) / (STAT_FONT_WIDTH); From 2dbb28f5e47c9f2b4018dc8a0ece064ef62cdd71 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 30 Mar 2022 00:26:34 +0000 Subject: [PATCH 188/203] [cron] Bump distribution date (2022-03-30) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 51767464fc..0e3ee06055 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-29" +//#define STRING_DISTRIBUTION_DATE "2022-03-30" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 16681d07c6..140d9ba5c2 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-29" + #define STRING_DISTRIBUTION_DATE "2022-03-30" #endif /** From 72a9a02c17e59fa91e8284ca70f8d675498e9f0f Mon Sep 17 00:00:00 2001 From: Manianac <2092573+manianac@users.noreply.github.com> Date: Thu, 31 Mar 2022 17:23:52 -0700 Subject: [PATCH 189/203] =?UTF-8?q?=F0=9F=90=9B=20Use=20ADC=5FVREF=20for?= =?UTF-8?q?=20Filament=20Width=20ADC=20Vref=20(#23977)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/filwidth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/filwidth.h b/Marlin/src/feature/filwidth.h index e234380e98..9eb1e77762 100644 --- a/Marlin/src/feature/filwidth.h +++ b/Marlin/src/feature/filwidth.h @@ -67,7 +67,7 @@ public: } // Convert raw measurement to mm - static float raw_to_mm(const uint16_t v) { return v * 5.0f * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } + static float raw_to_mm(const uint16_t v) { return v * float(ADC_VREF) * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } static float raw_to_mm() { return raw_to_mm(raw); } // A scaled reading is ready From ae53033cea506209310fb014b304f3a07c59e9d7 Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Fri, 1 Apr 2022 03:13:16 +0100 Subject: [PATCH 190/203] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20and=20f?= =?UTF-8?q?ix=20ABL=20Bilinear=20(#23868)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/utility.cpp | 2 +- Marlin/src/feature/bedlevel/abl/abl.h | 45 ------- .../feature/bedlevel/abl/{abl.cpp => bbl.cpp} | 124 ++++++++++-------- Marlin/src/feature/bedlevel/abl/bbl.h | 72 ++++++++++ Marlin/src/feature/bedlevel/bedlevel.cpp | 19 +-- Marlin/src/feature/bedlevel/bedlevel.h | 4 +- .../bedlevel/mbl/mesh_bed_leveling.cpp | 4 +- Marlin/src/gcode/bedlevel/M420.cpp | 14 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 37 +++--- Marlin/src/gcode/bedlevel/abl/M421.cpp | 6 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 2 +- Marlin/src/module/planner.cpp | 4 +- Marlin/src/module/settings.cpp | 31 +++-- 13 files changed, 201 insertions(+), 163 deletions(-) delete mode 100644 Marlin/src/feature/bedlevel/abl/abl.h rename Marlin/src/feature/bedlevel/abl/{abl.cpp => bbl.cpp} (78%) create mode 100644 Marlin/src/feature/bedlevel/abl/bbl.h diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 59e59d4cb7..4e16e2693a 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -135,7 +135,7 @@ void safe_delay(millis_t ms) { const float rz = ubl.get_z_correction(current_position); #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) SERIAL_ECHOPGM("ABL Adjustment Z"); - const float rz = bilinear_z_offset(current_position); + const float rz = bbl.get_z_correction(current_position); #endif SERIAL_ECHO(ftostr43sign(rz, '+')); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) diff --git a/Marlin/src/feature/bedlevel/abl/abl.h b/Marlin/src/feature/bedlevel/abl/abl.h deleted file mode 100644 index 3d54c55695..0000000000 --- a/Marlin/src/feature/bedlevel/abl/abl.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * - * Based on Sprinter and grbl. - * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ -#pragma once - -#include "../../../inc/MarlinConfigPre.h" - -extern xy_pos_t bilinear_grid_spacing, bilinear_start; -extern xy_float_t bilinear_grid_factor; -extern bed_mesh_t z_values; -float bilinear_z_offset(const xy_pos_t &raw); - -void extrapolate_unprobed_bed_level(); -void print_bilinear_leveling_grid(); -void refresh_bed_level(); -#if ENABLED(ABL_BILINEAR_SUBDIVISION) - void print_bilinear_leveling_grid_virt(); - void bed_level_virt_interpolate(); -#endif - -#if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) - void bilinear_line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF); -#endif - -#define _GET_MESH_X(I) float(bilinear_start.x + (I) * bilinear_grid_spacing.x) -#define _GET_MESH_Y(J) float(bilinear_start.y + (J) * bilinear_grid_spacing.y) -#define Z_VALUES_ARR z_values diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/bbl.cpp similarity index 78% rename from Marlin/src/feature/bedlevel/abl/abl.cpp rename to Marlin/src/feature/bedlevel/abl/bbl.cpp index ece7481981..9dcd669128 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/bbl.cpp @@ -35,14 +35,19 @@ #include "../../../lcd/extui/ui_api.h" #endif -xy_pos_t bilinear_grid_spacing, bilinear_start; -xy_float_t bilinear_grid_factor; -bed_mesh_t z_values; +LevelingBilinear bbl; + +xy_pos_t LevelingBilinear::grid_spacing, + LevelingBilinear::grid_start; +xy_float_t LevelingBilinear::grid_factor; +bed_mesh_t LevelingBilinear::z_values; +xy_pos_t LevelingBilinear::cached_rel; +xy_int8_t LevelingBilinear::cached_g; /** * Extrapolate a single point from its neighbors */ -static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { +void LevelingBilinear::extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { if (!isnan(z_values[x][y])) return; if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Extrapolate ["); @@ -92,11 +97,26 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t #endif #endif +void LevelingBilinear::reset() { + grid_start.reset(); + grid_spacing.reset(); + GRID_LOOP(x, y) { + z_values[x][y] = NAN; + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0)); + } +} + +void LevelingBilinear::set_grid(const xy_pos_t& _grid_spacing, const xy_pos_t& _grid_start) { + grid_spacing = _grid_spacing; + grid_start = _grid_start; + grid_factor = grid_spacing.reciprocal(); +} + /** * Fill in the unprobed points (corners of circular print surface) * using linear extrapolation, away from the center. */ -void extrapolate_unprobed_bed_level() { +void LevelingBilinear::extrapolate_unprobed_bed_level() { #ifdef HALF_IN_X constexpr uint8_t ctrx2 = 0, xend = GRID_MAX_POINTS_X - 1; #else @@ -131,35 +151,31 @@ void extrapolate_unprobed_bed_level() { #endif extrapolate_one_point(x2, y2, -1, -1); // right-above - - } - } -void print_bilinear_leveling_grid() { +void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values /*= NULL*/) { + // print internal grid(s) or just the one passed as a parameter SERIAL_ECHOLNPGM("Bilinear Leveling Grid:"); - print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3, - [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; } - ); + print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3, _z_values ? *_z_values[0] : z_values[0]); + + #if ENABLED(ABL_BILINEAR_SUBDIVISION) + if (!_z_values) { + SERIAL_ECHOLNPGM("Subdivided with CATMULL ROM Leveling Grid:"); + print_2d_array(ABL_GRID_POINTS_VIRT_X, ABL_GRID_POINTS_VIRT_Y, 5, z_values_virt[0]); + } + #endif } #if ENABLED(ABL_BILINEAR_SUBDIVISION) - #define ABL_GRID_POINTS_VIRT_X GRID_MAX_CELLS_X * (BILINEAR_SUBDIVISIONS) + 1 - #define ABL_GRID_POINTS_VIRT_Y GRID_MAX_CELLS_Y * (BILINEAR_SUBDIVISIONS) + 1 #define ABL_TEMP_POINTS_X (GRID_MAX_POINTS_X + 2) #define ABL_TEMP_POINTS_Y (GRID_MAX_POINTS_Y + 2) - float z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y]; - xy_pos_t bilinear_grid_spacing_virt; - xy_float_t bilinear_grid_factor_virt; - - void print_bilinear_leveling_grid_virt() { - SERIAL_ECHOLNPGM("Subdivided with CATMULL ROM Leveling Grid:"); - print_2d_array(ABL_GRID_POINTS_VIRT_X, ABL_GRID_POINTS_VIRT_Y, 5, - [](const uint8_t ix, const uint8_t iy) { return z_values_virt[ix][iy]; } - ); - } + float LevelingBilinear::z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y]; + xy_pos_t LevelingBilinear::grid_spacing_virt; + xy_float_t LevelingBilinear::grid_factor_virt; #define LINEAR_EXTRAPOLATION(E, I) ((E) * 2 - (I)) - float bed_level_virt_coord(const uint8_t x, const uint8_t y) { + float LevelingBilinear::bed_level_virt_coord(const uint8_t x, const uint8_t y) { uint8_t ep = 0, ip = 1; if (x > (GRID_MAX_POINTS_X) + 1 || y > (GRID_MAX_POINTS_Y) + 1) { // The requested point requires extrapolating two points beyond the mesh. @@ -204,7 +220,7 @@ void print_bilinear_leveling_grid() { return z_values[x - 1][y - 1]; } - static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t) { + float LevelingBilinear::bed_level_virt_cmr(const float p[4], const uint8_t i, const float t) { return ( p[i-1] * -t * sq(1 - t) + p[i] * (2 - 5 * sq(t) + 3 * t * sq(t)) @@ -213,7 +229,7 @@ void print_bilinear_leveling_grid() { ) * 0.5f; } - static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) { + float LevelingBilinear::bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) { float row[4], column[4]; LOOP_L_N(i, 4) { LOOP_L_N(j, 4) { @@ -224,9 +240,9 @@ void print_bilinear_leveling_grid() { return bed_level_virt_cmr(row, 1, tx); } - void bed_level_virt_interpolate() { - bilinear_grid_spacing_virt = bilinear_grid_spacing / (BILINEAR_SUBDIVISIONS); - bilinear_grid_factor_virt = bilinear_grid_spacing_virt.reciprocal(); + void LevelingBilinear::bed_level_virt_interpolate() { + grid_spacing_virt = grid_spacing / (BILINEAR_SUBDIVISIONS); + grid_factor_virt = grid_spacing_virt.reciprocal(); LOOP_L_N(y, GRID_MAX_POINTS_Y) LOOP_L_N(x, GRID_MAX_POINTS_X) LOOP_L_N(ty, BILINEAR_SUBDIVISIONS) @@ -244,38 +260,40 @@ void print_bilinear_leveling_grid() { } #endif // ABL_BILINEAR_SUBDIVISION + // Refresh after other values have been updated -void refresh_bed_level() { - bilinear_grid_factor = bilinear_grid_spacing.reciprocal(); +void LevelingBilinear::refresh_bed_level() { TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); + cached_rel.x = cached_rel.y = -999.999; + cached_g.x = cached_g.y = -99; } #if ENABLED(ABL_BILINEAR_SUBDIVISION) - #define ABL_BG_SPACING(A) bilinear_grid_spacing_virt.A - #define ABL_BG_FACTOR(A) bilinear_grid_factor_virt.A + #define ABL_BG_SPACING(A) grid_spacing_virt.A + #define ABL_BG_FACTOR(A) grid_factor_virt.A #define ABL_BG_POINTS_X ABL_GRID_POINTS_VIRT_X #define ABL_BG_POINTS_Y ABL_GRID_POINTS_VIRT_Y #define ABL_BG_GRID(X,Y) z_values_virt[X][Y] #else - #define ABL_BG_SPACING(A) bilinear_grid_spacing.A - #define ABL_BG_FACTOR(A) bilinear_grid_factor.A + #define ABL_BG_SPACING(A) grid_spacing.A + #define ABL_BG_FACTOR(A) grid_factor.A #define ABL_BG_POINTS_X GRID_MAX_POINTS_X #define ABL_BG_POINTS_Y GRID_MAX_POINTS_Y #define ABL_BG_GRID(X,Y) z_values[X][Y] #endif // Get the Z adjustment for non-linear bed leveling -float bilinear_z_offset(const xy_pos_t &raw) { +float LevelingBilinear::get_z_correction(const xy_pos_t &raw) { static float z1, d2, z3, d4, L, D; - static xy_pos_t prev { -999.999, -999.999 }, ratio; + static xy_pos_t ratio; // Whole units for the grid line indices. Constrained within bounds. - static xy_int8_t thisg, nextg, lastg { -99, -99 }; + static xy_int8_t thisg, nextg; // XY relative to the probed area - xy_pos_t rel = raw - bilinear_start.asFloat(); + xy_pos_t rel = raw - grid_start.asFloat(); #if ENABLED(EXTRAPOLATE_BEYOND_GRID) #define FAR_EDGE_OR_BOX 2 // Keep using the last grid box @@ -283,8 +301,8 @@ float bilinear_z_offset(const xy_pos_t &raw) { #define FAR_EDGE_OR_BOX 1 // Just use the grid far edge #endif - if (prev.x != rel.x) { - prev.x = rel.x; + if (cached_rel.x != rel.x) { + cached_rel.x = rel.x; ratio.x = rel.x * ABL_BG_FACTOR(x); const float gx = constrain(FLOOR(ratio.x), 0, ABL_BG_POINTS_X - (FAR_EDGE_OR_BOX)); ratio.x -= gx; // Subtract whole to get the ratio within the grid box @@ -298,10 +316,10 @@ float bilinear_z_offset(const xy_pos_t &raw) { nextg.x = _MIN(thisg.x + 1, ABL_BG_POINTS_X - 1); } - if (prev.y != rel.y || lastg.x != thisg.x) { + if (cached_rel.y != rel.y || cached_g.x != thisg.x) { - if (prev.y != rel.y) { - prev.y = rel.y; + if (cached_rel.y != rel.y) { + cached_rel.y = rel.y; ratio.y = rel.y * ABL_BG_FACTOR(y); const float gy = constrain(FLOOR(ratio.y), 0, ABL_BG_POINTS_Y - (FAR_EDGE_OR_BOX)); ratio.y -= gy; @@ -315,8 +333,8 @@ float bilinear_z_offset(const xy_pos_t &raw) { nextg.y = _MIN(thisg.y + 1, ABL_BG_POINTS_Y - 1); } - if (lastg != thisg) { - lastg = thisg; + if (cached_g != thisg) { + cached_g = thisg; // Z at the box corners z1 = ABL_BG_GRID(thisg.x, thisg.y); // left-front d2 = ABL_BG_GRID(thisg.x, nextg.y) - z1; // left-back (delta) @@ -336,8 +354,8 @@ float bilinear_z_offset(const xy_pos_t &raw) { /* static float last_offset = 0; if (ABS(last_offset - offset) > 0.2) { - SERIAL_ECHOLNPGM("Sudden Shift at x=", rel.x, " / ", bilinear_grid_spacing.x, " -> thisg.x=", thisg.x); - SERIAL_ECHOLNPGM(" y=", rel.y, " / ", bilinear_grid_spacing.y, " -> thisg.y=", thisg.y); + SERIAL_ECHOLNPGM("Sudden Shift at x=", rel.x, " / ", grid_spacing.x, " -> thisg.x=", thisg.x); + SERIAL_ECHOLNPGM(" y=", rel.y, " / ", grid_spacing.y, " -> thisg.y=", thisg.y); SERIAL_ECHOLNPGM(" ratio.x=", ratio.x, " ratio.y=", ratio.y); SERIAL_ECHOLNPGM(" z1=", z1, " z2=", z2, " z3=", z3, " z4=", z4); SERIAL_ECHOLNPGM(" L=", L, " R=", R, " offset=", offset); @@ -350,13 +368,13 @@ float bilinear_z_offset(const xy_pos_t &raw) { #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) - #define CELL_INDEX(A,V) ((V - bilinear_start.A) * ABL_BG_FACTOR(A)) + #define CELL_INDEX(A,V) ((V - grid_start.A) * ABL_BG_FACTOR(A)) /** * Prepare a bilinear-leveled linear move on Cartesian, * splitting the move where it crosses grid borders. */ - void bilinear_line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits, uint16_t y_splits) { + void LevelingBilinear::line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits, uint16_t y_splits) { // Get current and destination cells for this line xy_int_t c1 { CELL_INDEX(x, current_position.x), CELL_INDEX(y, current_position.y) }, c2 { CELL_INDEX(x, destination.x), CELL_INDEX(y, destination.y) }; @@ -384,7 +402,7 @@ float bilinear_z_offset(const xy_pos_t &raw) { // Split on the X grid line CBI(x_splits, gc.x); end = destination; - destination.x = bilinear_start.x + ABL_BG_SPACING(x) * gc.x; + destination.x = grid_start.x + ABL_BG_SPACING(x) * gc.x; normalized_dist = (destination.x - current_position.x) / (end.x - current_position.x); destination.y = LINE_SEGMENT_END(y); } @@ -393,7 +411,7 @@ float bilinear_z_offset(const xy_pos_t &raw) { // Split on the Y grid line CBI(y_splits, gc.y); end = destination; - destination.y = bilinear_start.y + ABL_BG_SPACING(y) * gc.y; + destination.y = grid_start.y + ABL_BG_SPACING(y) * gc.y; normalized_dist = (destination.y - current_position.y) / (end.y - current_position.y); destination.x = LINE_SEGMENT_END(x); } @@ -409,11 +427,11 @@ float bilinear_z_offset(const xy_pos_t &raw) { destination.e = LINE_SEGMENT_END(e); // Do the split and look for more borders - bilinear_line_to_destination(scaled_fr_mm_s, x_splits, y_splits); + line_to_destination(scaled_fr_mm_s, x_splits, y_splits); // Restore destination from stack destination = end; - bilinear_line_to_destination(scaled_fr_mm_s, x_splits, y_splits); + line_to_destination(scaled_fr_mm_s, x_splits, y_splits); } #endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES diff --git a/Marlin/src/feature/bedlevel/abl/bbl.h b/Marlin/src/feature/bedlevel/abl/bbl.h new file mode 100644 index 0000000000..86da5aea10 --- /dev/null +++ b/Marlin/src/feature/bedlevel/abl/bbl.h @@ -0,0 +1,72 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "../../../inc/MarlinConfigPre.h" + +class LevelingBilinear { + static xy_pos_t grid_spacing, grid_start; + static xy_float_t grid_factor; + static bed_mesh_t z_values; + static xy_pos_t cached_rel; + static xy_int8_t cached_g; + + static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir); + + #if ENABLED(ABL_BILINEAR_SUBDIVISION) + #define ABL_GRID_POINTS_VIRT_X (GRID_MAX_CELLS_X * (BILINEAR_SUBDIVISIONS) + 1) + #define ABL_GRID_POINTS_VIRT_Y (GRID_MAX_CELLS_Y * (BILINEAR_SUBDIVISIONS) + 1) + + static float z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y]; + static xy_pos_t grid_spacing_virt; + static xy_float_t grid_factor_virt; + + static float bed_level_virt_coord(const uint8_t x, const uint8_t y); + static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t); + static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty); + static void bed_level_virt_interpolate(); + #endif + +public: + static void reset(); + static void set_grid(const xy_pos_t& _grid_spacing, const xy_pos_t& _grid_start); + static void extrapolate_unprobed_bed_level(); + static void print_leveling_grid(const bed_mesh_t* _z_values = NULL); + static void refresh_bed_level(); + static bool has_mesh() { return !!grid_spacing.x; } + static bed_mesh_t& get_z_values() { return z_values; } + static const xy_pos_t& get_grid_spacing() { return grid_spacing; } + static const xy_pos_t& get_grid_start() { return grid_start; } + static float get_mesh_x(int16_t i) { return grid_start.x + i * grid_spacing.x; } + static float get_mesh_y(int16_t j) { return grid_start.y + j * grid_spacing.y; } + static float get_z_correction(const xy_pos_t &raw); + + #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) + static void line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF); + #endif +}; + +extern LevelingBilinear bbl; + +#define _GET_MESH_X(I) bbl.get_mesh_x(I) +#define _GET_MESH_Y(J) bbl.get_mesh_y(J) +#define Z_VALUES_ARR bbl.get_z_values() diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 8e03632de4..2405905d4e 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -48,7 +48,7 @@ bool leveling_is_valid() { return TERN1(MESH_BED_LEVELING, mbl.has_mesh()) - && TERN1(AUTO_BED_LEVELING_BILINEAR, !!bilinear_grid_spacing.x) + && TERN1(AUTO_BED_LEVELING_BILINEAR, bbl.has_mesh()) && TERN1(AUTO_BED_LEVELING_UBL, ubl.mesh_is_valid()); } @@ -67,12 +67,6 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) { planner.synchronize(); - #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - // Force bilinear_z_offset to re-calculate next time - const xyz_pos_t reset { -9999.999, -9999.999, 0 }; - (void)bilinear_z_offset(reset); - #endif - if (planner.leveling_active) { // leveling from on to off if (DEBUGGING(LEVELING)) DEBUG_POS("Leveling ON", current_position); // change unleveled current_position to physical current_position without moving steppers. @@ -129,12 +123,7 @@ void reset_bed_level() { #if ENABLED(MESH_BED_LEVELING) mbl.reset(); #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - bilinear_start.reset(); - bilinear_grid_spacing.reset(); - GRID_LOOP(x, y) { - z_values[x][y] = NAN; - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0)); - } + bbl.reset(); #elif ABL_PLANAR planner.bed_level_matrix.set_to_identity(); #endif @@ -156,7 +145,7 @@ void reset_bed_level() { /** * Print calibration results for plotting or manual frame adjustment. */ - void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn) { + void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, const float *values) { #ifndef SCAD_MESH_OUTPUT LOOP_L_N(x, sx) { serial_spaces(precision + (x < 10 ? 3 : 2)); @@ -176,7 +165,7 @@ void reset_bed_level() { #endif LOOP_L_N(x, sx) { SERIAL_CHAR(' '); - const float offset = fn(x, y); + const float offset = values[x * sx + y]; if (!isnan(offset)) { if (offset >= 0) SERIAL_CHAR('+'); SERIAL_ECHO_F(offset, int(precision)); diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index 63f032eee8..f295da1d03 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -62,7 +62,7 @@ class TemporaryBedLevelingState { typedef float bed_mesh_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - #include "abl/abl.h" + #include "abl/bbl.h" #elif ENABLED(AUTO_BED_LEVELING_UBL) #include "ubl/ubl.h" #elif ENABLED(MESH_BED_LEVELING) @@ -81,7 +81,7 @@ class TemporaryBedLevelingState { /** * Print calibration results for plotting or manual frame adjustment. */ - void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn); + void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, const float *values); #endif diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp index 51cf28f890..fbc3f2785e 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp @@ -125,9 +125,7 @@ void mesh_bed_leveling::report_mesh() { SERIAL_ECHOPAIR_F(STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh. Z offset: ", z_offset, 5); SERIAL_ECHOLNPGM("\nMeasured points:"); - print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5, - [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; } - ); + print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5, z_values[0]); } #endif // MESH_BED_LEVELING diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 3c23e85a1d..c8325b1fc5 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -67,14 +67,17 @@ void GcodeSuite::M420() { const float x_min = probe.min_x(), x_max = probe.max_x(), y_min = probe.min_y(), y_max = probe.max_y(); #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - bilinear_start.set(x_min, y_min); - bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X), - (y_max - y_min) / (GRID_MAX_CELLS_Y)); + xy_pos_t start, spacing; + start.set(x_min, y_min); + spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X), + (y_max - y_min) / (GRID_MAX_CELLS_Y)); + bbl.set_grid(spacing, start); #endif GRID_LOOP(x, y) { Z_VALUES(x, y) = 0.001 * random(-200, 200); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y))); } + TERN_(AUTO_BED_LEVELING_BILINEAR, bbl.refresh_bed_level()); SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh "); SERIAL_ECHOPGM(" (", x_min); SERIAL_CHAR(','); SERIAL_ECHO(y_min); @@ -178,7 +181,7 @@ void GcodeSuite::M420() { Z_VALUES(x, y) -= zmean; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y))); } - TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); + TERN_(AUTO_BED_LEVELING_BILINEAR, bbl.refresh_bed_level()); } #endif @@ -199,8 +202,7 @@ void GcodeSuite::M420() { #else if (leveling_is_valid()) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - print_bilinear_leveling_grid(); - TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt()); + bbl.print_leveling_grid(); #elif ENABLED(MESH_BED_LEVELING) SERIAL_ECHOLNPGM("Mesh Bed Level data:"); mbl.report_mesh(); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 1868c636ee..61848c45bd 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -124,6 +124,7 @@ public: #if ENABLED(AUTO_BED_LEVELING_BILINEAR) float Z_offset; + bed_mesh_t z_values; #endif #if ENABLED(AUTO_BED_LEVELING_LINEAR) @@ -308,8 +309,8 @@ G29_TYPE GcodeSuite::G29() { if (!isnan(rx) && !isnan(ry)) { // Get nearest i / j from rx / ry - i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x; - j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y; + i = (rx - bbl.get_grid_start().x) / bbl.get_grid_spacing().x + 0.5f; + j = (ry - bbl.get_grid_start().y) / bbl.get_grid_spacing().y + 0.5f; LIMIT(i, 0, (GRID_MAX_POINTS_X) - 1); LIMIT(j, 0, (GRID_MAX_POINTS_Y) - 1); } @@ -318,8 +319,8 @@ G29_TYPE GcodeSuite::G29() { if (WITHIN(i, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(j, 0, (GRID_MAX_POINTS_Y) - 1)) { set_bed_leveling_enabled(false); - z_values[i][j] = rz; - TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); + Z_VALUES_ARR[i][j] = rz; + bbl.refresh_bed_level(); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, rz)); set_bed_leveling_enabled(abl.reenable); if (abl.reenable) report_current_position(); @@ -451,16 +452,12 @@ G29_TYPE GcodeSuite::G29() { #endif #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (TERN1(PROBE_MANUALLY, !no_action) - && (abl.gridSpacing != bilinear_grid_spacing || abl.probe_position_lf != bilinear_start) + if (!abl.dryrun + && (abl.gridSpacing != bbl.get_grid_spacing() || abl.probe_position_lf != bbl.get_grid_start()) ) { // Reset grid to 0.0 or "not probed". (Also disables ABL) reset_bed_level(); - // Initialize a grid with the given dimensions - bilinear_grid_spacing = abl.gridSpacing; - bilinear_start = abl.probe_position_lf; - // Can't re-enable (on error) until the new grid is written abl.reenable = false; } @@ -531,7 +528,7 @@ G29_TYPE GcodeSuite::G29() { #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) const float newz = abl.measured_z + abl.Z_offset; - z_values[abl.meshCount.x][abl.meshCount.y] = newz; + abl.z_values[abl.meshCount.x][abl.meshCount.y] = newz; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, newz)); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM_P(PSTR("Save X"), abl.meshCount.x, SP_Y_STR, abl.meshCount.y, SP_Z_STR, abl.measured_z + abl.Z_offset); @@ -682,7 +679,7 @@ G29_TYPE GcodeSuite::G29() { #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) const float z = abl.measured_z + abl.Z_offset; - z_values[abl.meshCount.x][abl.meshCount.y] = z; + abl.z_values[abl.meshCount.x][abl.meshCount.y] = z; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, z)); #endif @@ -753,12 +750,16 @@ G29_TYPE GcodeSuite::G29() { if (!isnan(abl.measured_z)) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (!abl.dryrun) extrapolate_unprobed_bed_level(); - print_bilinear_leveling_grid(); + if (abl.dryrun) + bbl.print_leveling_grid(&abl.z_values); + else { + bbl.set_grid(abl.gridSpacing, abl.probe_position_lf); + COPY(Z_VALUES_ARR, abl.z_values); + TERN_(IS_KINEMATIC, bbl.extrapolate_unprobed_bed_level()); + bbl.refresh_bed_level(); - refresh_bed_level(); - - TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt()); + bbl.print_leveling_grid(); + } #elif ENABLED(AUTO_BED_LEVELING_LINEAR) @@ -878,7 +879,7 @@ G29_TYPE GcodeSuite::G29() { // Unapply the offset because it is going to be immediately applied // and cause compensation movement in Z const float fade_scaling_factor = TERN(ENABLE_LEVELING_FADE_HEIGHT, planner.fade_scaling_factor_for_z(current_position.z), 1); - current_position.z -= fade_scaling_factor * bilinear_z_offset(current_position); + current_position.z -= fade_scaling_factor * bbl.get_z_correction(current_position); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(" corrected Z:", current_position.z); } diff --git a/Marlin/src/gcode/bedlevel/abl/M421.cpp b/Marlin/src/gcode/bedlevel/abl/M421.cpp index 182dc32515..0c12268cb1 100644 --- a/Marlin/src/gcode/bedlevel/abl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/abl/M421.cpp @@ -58,11 +58,11 @@ void GcodeSuite::M421() { sy = iy >= 0 ? iy : 0, ey = iy >= 0 ? iy : GRID_MAX_POINTS_Y - 1; LOOP_S_LE_N(x, sx, ex) { LOOP_S_LE_N(y, sy, ey) { - z_values[x][y] = zval + (hasQ ? z_values[x][y] : 0); - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); + Z_VALUES_ARR[x][y] = zval + (hasQ ? Z_VALUES_ARR[x][y] : 0); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES_ARR[x][y])); } } - TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); + bbl.refresh_bed_level(); } else SERIAL_ERROR_MSG(STR_ERR_MESH_XY); diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 3e777d4aaa..d0f9e2e1b3 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -3417,7 +3417,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Back, F("Back")); else { set_bed_leveling_enabled(level_state); - TERN_(AUTO_BED_LEVELING_BILINEAR, refresh_bed_level()); + TERN_(AUTO_BED_LEVELING_BILINEAR, bbl.refresh_bed_level()); Draw_Menu(Leveling, LEVELING_MANUAL); } break; diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index a3caa199c1..8c723aa06e 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1591,7 +1591,7 @@ void Planner::check_axes_activity() { #elif ENABLED(AUTO_BED_LEVELING_UBL) fade_scaling_factor ? fade_scaling_factor * ubl.get_z_correction(raw) : 0.0 #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - fade_scaling_factor ? fade_scaling_factor * bilinear_z_offset(raw) : 0.0 + fade_scaling_factor ? fade_scaling_factor * bbl.get_z_correction(raw) : 0.0 #endif ); @@ -1624,7 +1624,7 @@ void Planner::check_axes_activity() { #elif ENABLED(AUTO_BED_LEVELING_UBL) fade_scaling_factor ? fade_scaling_factor * ubl.get_z_correction(raw) : 0.0 #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - fade_scaling_factor ? fade_scaling_factor * bilinear_z_offset(raw) : 0.0 + fade_scaling_factor ? fade_scaling_factor * bbl.get_z_correction(raw) : 0.0 #endif ); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 02d1b26437..5d91a90c65 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -597,7 +597,7 @@ void MarlinSettings::postprocess() { TERN_(ENABLE_LEVELING_FADE_HEIGHT, set_z_fade_height(new_z_fade_height, false)); // false = no report - TERN_(AUTO_BED_LEVELING_BILINEAR, refresh_bed_level()); + TERN_(AUTO_BED_LEVELING_BILINEAR, bbl.refresh_bed_level()); TERN_(HAS_MOTOR_CURRENT_PWM, stepper.refresh_motor_power()); @@ -876,22 +876,26 @@ void MarlinSettings::postprocess() { { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) static_assert( - sizeof(z_values) == (GRID_MAX_POINTS) * sizeof(z_values[0][0]), + sizeof(Z_VALUES_ARR) == (GRID_MAX_POINTS) * sizeof(Z_VALUES_ARR[0][0]), "Bilinear Z array is the wrong size." ); - #else - const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0}; #endif const uint8_t grid_max_x = TERN(AUTO_BED_LEVELING_BILINEAR, GRID_MAX_POINTS_X, 3), grid_max_y = TERN(AUTO_BED_LEVELING_BILINEAR, GRID_MAX_POINTS_Y, 3); EEPROM_WRITE(grid_max_x); EEPROM_WRITE(grid_max_y); - EEPROM_WRITE(bilinear_grid_spacing); - EEPROM_WRITE(bilinear_start); + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + EEPROM_WRITE(bbl.get_grid_spacing()); + EEPROM_WRITE(bbl.get_grid_start()); + #else + const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0}; + EEPROM_WRITE(bilinear_grid_spacing); + EEPROM_WRITE(bilinear_start); + #endif #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - EEPROM_WRITE(z_values); // 9-256 floats + EEPROM_WRITE(Z_VALUES_ARR); // 9-256 floats #else dummyf = 0; for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummyf); @@ -1791,20 +1795,19 @@ void MarlinSettings::postprocess() { uint8_t grid_max_x, grid_max_y; EEPROM_READ_ALWAYS(grid_max_x); // 1 byte EEPROM_READ_ALWAYS(grid_max_y); // 1 byte + xy_pos_t spacing, start; + EEPROM_READ(spacing); // 2 ints + EEPROM_READ(start); // 2 ints #if ENABLED(AUTO_BED_LEVELING_BILINEAR) if (grid_max_x == (GRID_MAX_POINTS_X) && grid_max_y == (GRID_MAX_POINTS_Y)) { if (!validating) set_bed_leveling_enabled(false); - EEPROM_READ(bilinear_grid_spacing); // 2 ints - EEPROM_READ(bilinear_start); // 2 ints - EEPROM_READ(z_values); // 9 to 256 floats + bbl.set_grid(spacing, start); + EEPROM_READ(Z_VALUES_ARR); // 9 to 256 floats } else // EEPROM data is stale #endif // AUTO_BED_LEVELING_BILINEAR { // Skip past disabled (or stale) Bilinear Grid data - xy_pos_t bgs, bs; - EEPROM_READ(bgs); - EEPROM_READ(bs); for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummyf); } } @@ -3337,7 +3340,7 @@ void MarlinSettings::reset() { LOOP_L_N(px, GRID_MAX_POINTS_X) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" G29 W I", px, " J", py); - SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(z_values[px][py]), 5); + SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(Z_VALUES_ARR[px][py]), 5); } } } From 108cc4ba1621d149ad6a6a073e4a69fd53d2b202 Mon Sep 17 00:00:00 2001 From: grauerfuchs <42082416+grauerfuchs@users.noreply.github.com> Date: Thu, 31 Mar 2022 22:15:06 -0400 Subject: [PATCH 191/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MightyBoard=20Rev.?= =?UTF-8?q?=20E=20EX2,=20extra=20MOSFETs=20(#23976)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index f2a95baf01..13ffc94486 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -149,10 +149,10 @@ #define MOSFET_1_PIN 6 // Plug EX1 Pin 1-2 -> PH3 #15 -> Logical 06 #define MOSFET_2_PIN 7 // Plug EX1 Pin 3-4 -> PH4 #16 -> Logical 07 -#define MOSFET_3_PIN 12 // Plug EX2 1-2 -> PB5 #25 -> Logical 12 -#define MOSFET_4_PIN 11 // Plug EX2 3-4 -> PB6 #24 -> Logical 11 +#define MOSFET_3_PIN 11 // Plug EX2 1-2 -> PB6 #24 -> Logical 11 +#define MOSFET_4_PIN 12 // Plug EX2 3-4 -> PB5 #25 -> Logical 12 #define MOSFET_5_PIN 45 // Plug HBD 1-2 -> PL4 #39 -> Logical 45 -#define MOSFET_6_PIN 13 // Plug Extra 1-2 -> PL5 #40 -> Logical 44 (FET not soldered in all boards) +#define MOSFET_6_PIN 44 // Plug Extra 1-2 -> PL5 #40 -> Logical 44 (FET not soldered in all boards) // // Heaters / Fans (24V) From c7f03b820aed66e1c91c9fd8f9c2d1645694604f Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Thu, 31 Mar 2022 19:16:11 -0700 Subject: [PATCH 192/203] =?UTF-8?q?=F0=9F=93=8C=20SKR=20Mini=20V1.1=20TMC?= =?UTF-8?q?=20UART=20Pins=20(#23970)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index a92de805f7..4f52dfb4fc 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -80,6 +80,23 @@ #endif #endif +#if HAS_TMC_UART // Shared with EXP1 + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PC14 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + // // Heaters / Fans // From f15b1c16c9a743e9b4eafaf37c37ab2f919d1fe1 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 31 Mar 2022 22:18:32 -0400 Subject: [PATCH 193/203] =?UTF-8?q?=F0=9F=A9=B9=20SKR2=20Pins=20DIAG=20fla?= =?UTF-8?q?g=20(#23968)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23050 --- Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h index 4f5ed6c1b4..d526c75b63 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h @@ -23,6 +23,8 @@ #include "env_validate.h" +#define USES_DIAG_JUMPERS + // If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION // https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT //#define BTT_MOTOR_EXPANSION From 04ab653f5efd5b71c4fab401a8156885cb35d316 Mon Sep 17 00:00:00 2001 From: aegelsky Date: Fri, 1 Apr 2022 05:21:10 +0300 Subject: [PATCH 194/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MKS=20Gen.=20L=20-?= =?UTF-8?q?=20EEB=20(#23965)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/ramps/pins_MKS_GEN_L.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_L.h b/Marlin/src/pins/ramps/pins_MKS_GEN_L.h index 522a34cda1..4dca1ca187 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_L.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_L.h @@ -37,6 +37,12 @@ // Power outputs EFBF or EFBE #define MOSFET_D_PIN 7 +// Hotend, Hotend, Bed + Fan on D9 +#if FET_ORDER_EEB + #define MOSFET_B_PIN 7 + #define FAN_PIN 9 +#endif + // // CS Pins wired to avoid conflict with the LCD // See https://www.thingiverse.com/asset:66604 From 2786592b62aa0972496f25487ae5358ed2b613be Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Fri, 1 Apr 2022 04:22:26 +0200 Subject: [PATCH 195/203] =?UTF-8?q?=F0=9F=93=9D=20Obsolete=20freeze=20comm?= =?UTF-8?q?ent=20(#23964)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23944 --- Marlin/Configuration_adv.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 195a0e8d16..957222e7f7 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -4110,7 +4110,6 @@ /** * Instant freeze / unfreeze functionality - * Specified pin has pullup and connecting to ground will instantly pause motion. * Potentially useful for emergency stop that allows being resumed. */ //#define FREEZE_FEATURE From e5b651f407fcb743e2d00c45b0d361fb98230efb Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Fri, 1 Apr 2022 07:10:38 +0200 Subject: [PATCH 196/203] =?UTF-8?q?=E2=9C=A8=20Support=20for=20up=20to=209?= =?UTF-8?q?=20axes=20(linear,=20rotary)=20(#23112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 138 +++++-- Marlin/Configuration_adv.h | 145 ++++++- Marlin/src/HAL/AVR/endstop_interrupts.h | 45 +++ Marlin/src/HAL/DUE/endstop_interrupts.h | 6 + Marlin/src/HAL/ESP32/endstop_interrupts.h | 6 + Marlin/src/HAL/LPC1768/endstop_interrupts.h | 33 ++ Marlin/src/HAL/SAMD51/endstop_interrupts.h | 45 +++ Marlin/src/HAL/STM32/endstop_interrupts.h | 6 + Marlin/src/HAL/STM32F1/endstop_interrupts.h | 6 + .../src/HAL/TEENSY31_32/endstop_interrupts.h | 6 + .../src/HAL/TEENSY35_36/endstop_interrupts.h | 6 + Marlin/src/MarlinCore.cpp | 12 + Marlin/src/core/drivers.h | 5 + Marlin/src/core/language.h | 48 +++ Marlin/src/core/macros.h | 14 +- Marlin/src/core/serial.cpp | 8 +- Marlin/src/core/serial.h | 21 +- Marlin/src/core/types.h | 382 ++++++++++-------- Marlin/src/core/utility.cpp | 2 +- Marlin/src/core/utility.h | 9 +- Marlin/src/feature/backlash.cpp | 8 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 36 ++ Marlin/src/feature/encoder_i2c.cpp | 4 +- Marlin/src/feature/joystick.cpp | 2 +- Marlin/src/feature/powerloss.cpp | 6 +- Marlin/src/feature/stepper_driver_safety.cpp | 38 +- Marlin/src/feature/tmc_util.cpp | 57 +++ Marlin/src/feature/tmc_util.h | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 36 ++ Marlin/src/gcode/bedlevel/mbl/G29.cpp | 37 ++ Marlin/src/gcode/calibrate/G28.cpp | 130 +++--- Marlin/src/gcode/calibrate/G33.cpp | 10 +- Marlin/src/gcode/calibrate/G425.cpp | 136 ++++++- Marlin/src/gcode/calibrate/M425.cpp | 26 +- Marlin/src/gcode/calibrate/M666.cpp | 2 +- Marlin/src/gcode/config/M200-M205.cpp | 43 +- Marlin/src/gcode/config/M217.cpp | 43 +- Marlin/src/gcode/config/M92.cpp | 15 +- Marlin/src/gcode/control/M17_M18_M84.cpp | 31 +- Marlin/src/gcode/control/M605.cpp | 2 +- .../src/gcode/feature/digipot/M907-M910.cpp | 28 +- Marlin/src/gcode/feature/pause/G60.cpp | 8 +- Marlin/src/gcode/feature/pause/G61.cpp | 4 +- Marlin/src/gcode/feature/pause/M125.cpp | 18 +- Marlin/src/gcode/feature/pause/M600.cpp | 31 +- Marlin/src/gcode/feature/trinamic/M569.cpp | 29 +- Marlin/src/gcode/feature/trinamic/M906.cpp | 34 +- .../src/gcode/feature/trinamic/M911-M914.cpp | 83 +++- Marlin/src/gcode/gcode.cpp | 7 +- Marlin/src/gcode/gcode.h | 5 +- Marlin/src/gcode/geometry/G53-G59.cpp | 2 +- Marlin/src/gcode/geometry/G92.cpp | 10 +- Marlin/src/gcode/geometry/M206_M428.cpp | 31 +- Marlin/src/gcode/host/M114.cpp | 16 +- Marlin/src/gcode/host/M115.cpp | 4 +- Marlin/src/gcode/motion/G0_G1.cpp | 9 +- Marlin/src/gcode/motion/G2_G3.cpp | 74 +++- Marlin/src/gcode/motion/M290.cpp | 4 +- Marlin/src/gcode/parser.cpp | 2 +- Marlin/src/gcode/parser.h | 26 +- Marlin/src/gcode/probe/G38.cpp | 4 +- Marlin/src/inc/Conditionals_LCD.h | 103 ++++- Marlin/src/inc/Conditionals_adv.h | 63 +-- Marlin/src/inc/Conditionals_post.h | 257 +++++++++++- Marlin/src/inc/SanityCheck.h | 270 +++++++++++-- Marlin/src/inc/Version.h | 2 +- Marlin/src/inc/Warnings.cpp | 157 +++++++ .../lcd/extui/dgus_reloaded/DGUSTxHandler.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 30 ++ Marlin/src/lcd/extui/ui_api.h | 2 +- Marlin/src/lcd/language/language_en.h | 27 ++ Marlin/src/lcd/menu/menu_advanced.cpp | 28 +- Marlin/src/lcd/menu/menu_backlash.cpp | 9 + Marlin/src/lcd/menu/menu_motion.cpp | 36 ++ Marlin/src/lcd/menu/menu_tmc.cpp | 3 + Marlin/src/libs/L64XX/L64XX_Marlin.cpp | 6 +- Marlin/src/libs/L64XX/L64XX_Marlin.h | 2 +- Marlin/src/module/delta.cpp | 6 + Marlin/src/module/endstops.cpp | 278 ++++++++++++- Marlin/src/module/endstops.h | 8 +- Marlin/src/module/motion.cpp | 249 ++++++++++-- Marlin/src/module/motion.h | 59 ++- Marlin/src/module/planner.cpp | 295 +++++++++----- Marlin/src/module/planner.h | 6 +- Marlin/src/module/planner_bezier.cpp | 5 +- Marlin/src/module/probe.cpp | 7 +- Marlin/src/module/probe.h | 2 +- Marlin/src/module/scara.cpp | 2 +- Marlin/src/module/settings.cpp | 95 +++-- Marlin/src/module/stepper.cpp | 230 ++++++++++- Marlin/src/module/stepper.h | 27 +- Marlin/src/module/stepper/L64xx.cpp | 18 + Marlin/src/module/stepper/L64xx.h | 66 +++ Marlin/src/module/stepper/TMC26X.cpp | 18 + Marlin/src/module/stepper/TMC26X.h | 24 ++ Marlin/src/module/stepper/indirection.h | 124 ++++++ Marlin/src/module/stepper/trinamic.cpp | 101 ++++- Marlin/src/module/stepper/trinamic.h | 54 +++ Marlin/src/module/tool_change.cpp | 22 +- Marlin/src/module/tool_change.h | 2 +- Marlin/src/pins/pinsDebug_list.h | 117 ++++++ Marlin/src/pins/pins_postprocess.h | 369 +++++++++++++++++ Marlin/src/pins/sensitive_pins.h | 122 +++++- 103 files changed, 4539 insertions(+), 800 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index c2d5dced28..9237818c25 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -35,7 +35,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 02000903 +#define CONFIGURATION_H_VERSION 02010000 //=========================================================================== //============================= Getting Started ============================= @@ -150,9 +150,9 @@ //#define MACHINE_UUID "00000000-0000-0000-0000-000000000000" /** - * Define the number of coordinated linear axes. + * Define the number of coordinated axes. * See https://github.com/DerAndere1/Marlin/wiki - * Each linear axis gets its own stepper control and endstop: + * Each axis gets its own stepper control and endstop: * * Steppers: *_STEP_PIN, *_ENABLE_PIN, *_DIR_PIN, *_ENABLE_ON * Endstops: *_STOP_PIN, USE_*MIN_PLUG, USE_*MAX_PLUG @@ -161,31 +161,50 @@ * DEFAULT_MAX_ACCELERATION, AXIS_RELATIVE_MODES, * MICROSTEP_MODES, MANUAL_FEEDRATE * - * :[3, 4, 5, 6] + * :[3, 4, 5, 6, 7, 8, 9] */ -//#define LINEAR_AXES 3 +//#define NUM_AXES 3 /** - * Axis codes for additional axes: - * This defines the axis code that is used in G-code commands to - * reference a specific axis. - * 'A' for rotational axis parallel to X - * 'B' for rotational axis parallel to Y - * 'C' for rotational axis parallel to Z - * 'U' for secondary linear axis parallel to X - * 'V' for secondary linear axis parallel to Y - * 'W' for secondary linear axis parallel to Z - * Regardless of the settings, firmware-internal axis IDs are - * I (AXIS4), J (AXIS5), K (AXIS6). + * Additional Axis Settings + * + * Define AXISn_ROTATES for all axes that rotate or pivot. + * Rotational axis coordinates are expressed in degrees. + * + * AXISn_NAME defines the letter used to refer to the axis in (most) G-code commands. + * By convention the names and roles are typically: + * 'A' : Rotational axis parallel to X + * 'B' : Rotational axis parallel to Y + * 'C' : Rotational axis parallel to Z + * 'U' : Secondary linear axis parallel to X + * 'V' : Secondary linear axis parallel to Y + * 'W' : Secondary linear axis parallel to Z + * + * Regardless of these settings the axes are internally named I, J, K, U, V, W. */ -#if LINEAR_AXES >= 4 +#if NUM_AXES >= 4 #define AXIS4_NAME 'A' // :['A', 'B', 'C', 'U', 'V', 'W'] + #define AXIS4_ROTATES #endif -#if LINEAR_AXES >= 5 - #define AXIS5_NAME 'B' // :['A', 'B', 'C', 'U', 'V', 'W'] +#if NUM_AXES >= 5 + #define AXIS5_NAME 'B' // :['B', 'C', 'U', 'V', 'W'] + #define AXIS5_ROTATES #endif -#if LINEAR_AXES >= 6 - #define AXIS6_NAME 'C' // :['A', 'B', 'C', 'U', 'V', 'W'] +#if NUM_AXES >= 6 + #define AXIS6_NAME 'C' // :['C', 'U', 'V', 'W'] + #define AXIS6_ROTATES +#endif +#if NUM_AXES >= 7 + #define AXIS7_NAME 'U' // :['U', 'V', 'W'] + //#define AXIS7_ROTATES +#endif +#if NUM_AXES >= 8 + #define AXIS8_NAME 'V' // :['V', 'W'] + //#define AXIS8_ROTATES +#endif +#if NUM_AXES >= 9 + #define AXIS9_NAME 'W' // :['W'] + //#define AXIS9_ROTATES #endif // @section extruder @@ -793,12 +812,18 @@ //#define USE_IMIN_PLUG //#define USE_JMIN_PLUG //#define USE_KMIN_PLUG +//#define USE_UMIN_PLUG +//#define USE_VMIN_PLUG +//#define USE_WMIN_PLUG //#define USE_XMAX_PLUG //#define USE_YMAX_PLUG //#define USE_ZMAX_PLUG //#define USE_IMAX_PLUG //#define USE_JMAX_PLUG //#define USE_KMAX_PLUG +//#define USE_UMAX_PLUG +//#define USE_VMAX_PLUG +//#define USE_WMAX_PLUG // Enable pullup for all endstops to prevent a floating state #define ENDSTOPPULLUPS @@ -810,12 +835,18 @@ //#define ENDSTOPPULLUP_IMIN //#define ENDSTOPPULLUP_JMIN //#define ENDSTOPPULLUP_KMIN + //#define ENDSTOPPULLUP_UMIN + //#define ENDSTOPPULLUP_VMIN + //#define ENDSTOPPULLUP_WMIN //#define ENDSTOPPULLUP_XMAX //#define ENDSTOPPULLUP_YMAX //#define ENDSTOPPULLUP_ZMAX //#define ENDSTOPPULLUP_IMAX //#define ENDSTOPPULLUP_JMAX //#define ENDSTOPPULLUP_KMAX + //#define ENDSTOPPULLUP_UMAX + //#define ENDSTOPPULLUP_VMAX + //#define ENDSTOPPULLUP_WMAX //#define ENDSTOPPULLUP_ZMIN_PROBE #endif @@ -829,12 +860,18 @@ //#define ENDSTOPPULLDOWN_IMIN //#define ENDSTOPPULLDOWN_JMIN //#define ENDSTOPPULLDOWN_KMIN + //#define ENDSTOPPULLDOWN_UMIN + //#define ENDSTOPPULLDOWN_VMIN + //#define ENDSTOPPULLDOWN_WMIN //#define ENDSTOPPULLDOWN_XMAX //#define ENDSTOPPULLDOWN_YMAX //#define ENDSTOPPULLDOWN_ZMAX //#define ENDSTOPPULLDOWN_IMAX //#define ENDSTOPPULLDOWN_JMAX //#define ENDSTOPPULLDOWN_KMAX + //#define ENDSTOPPULLDOWN_UMAX + //#define ENDSTOPPULLDOWN_VMAX + //#define ENDSTOPPULLDOWN_WMAX //#define ENDSTOPPULLDOWN_ZMIN_PROBE #endif @@ -845,12 +882,18 @@ #define I_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define J_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define K_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define U_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define V_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define W_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define X_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Y_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Z_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define I_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define J_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define K_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define U_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define V_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. +#define W_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe. /** @@ -882,6 +925,9 @@ //#define I_DRIVER_TYPE A4988 //#define J_DRIVER_TYPE A4988 //#define K_DRIVER_TYPE A4988 +//#define U_DRIVER_TYPE A4988 +//#define V_DRIVER_TYPE A4988 +//#define W_DRIVER_TYPE A4988 #define E0_DRIVER_TYPE A4988 //#define E1_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988 @@ -933,16 +979,16 @@ //#define DISTINCT_E_FACTORS /** - * Default Axis Steps Per Unit (steps/mm) + * Default Axis Steps Per Unit (linear=steps/mm, rotational=steps/°) * Override with M92 - * X, Y, Z [, I [, J [, K]]], E0 [, E1[, E2...]] + * X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]] */ #define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 500 } /** - * Default Max Feed Rate (mm/s) + * Default Max Feed Rate (linear=mm/s, rotational=°/s) * Override with M203 - * X, Y, Z [, I [, J [, K]]], E0 [, E1[, E2...]] + * X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]] */ #define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 } @@ -952,10 +998,10 @@ #endif /** - * Default Max Acceleration (change/s) change = mm/s + * Default Max Acceleration (speed change with time) (linear=mm/(s^2), rotational=°/(s^2)) * (Maximum start speed for accelerated moves) * Override with M201 - * X, Y, Z [, I [, J [, K]]], E0 [, E1[, E2...]] + * X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]] */ #define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 } @@ -965,7 +1011,7 @@ #endif /** - * Default Acceleration (change/s) change = mm/s + * Default Acceleration (speed change with time) (linear=mm/(s^2), rotational=°/(s^2)) * Override with M204 * * M204 P Acceleration @@ -978,7 +1024,7 @@ /** * Default Jerk limits (mm/s) - * Override with M205 X Y Z E + * Override with M205 X Y Z . . . E * * "Jerk" specifies the minimum speed change that requires acceleration. * When changing speed and direction, if the difference is less than the @@ -992,6 +1038,9 @@ //#define DEFAULT_IJERK 0.3 //#define DEFAULT_JJERK 0.3 //#define DEFAULT_KJERK 0.3 + //#define DEFAULT_UJERK 0.3 + //#define DEFAULT_VJERK 0.3 + //#define DEFAULT_WJERK 0.3 //#define TRAVEL_EXTRA_XYJERK 0.0 // Additional jerk allowance for all travel moves @@ -1330,6 +1379,9 @@ //#define I_ENABLE_ON 0 //#define J_ENABLE_ON 0 //#define K_ENABLE_ON 0 +//#define U_ENABLE_ON 0 +//#define V_ENABLE_ON 0 +//#define W_ENABLE_ON 0 // Disable axis steppers immediately when they're not being stepped. // WARNING: When motors turn off there is a chance of losing position accuracy! @@ -1339,6 +1391,9 @@ //#define DISABLE_I false //#define DISABLE_J false //#define DISABLE_K false +//#define DISABLE_U false +//#define DISABLE_V false +//#define DISABLE_W false // Turn off the display blinking that warns about possible accuracy reduction //#define DISABLE_REDUCED_ACCURACY_WARNING @@ -1357,6 +1412,9 @@ //#define INVERT_I_DIR false //#define INVERT_J_DIR false //#define INVERT_K_DIR false +//#define INVERT_U_DIR false +//#define INVERT_V_DIR false +//#define INVERT_W_DIR false // @section extruder @@ -1395,6 +1453,9 @@ //#define I_HOME_DIR -1 //#define J_HOME_DIR -1 //#define K_HOME_DIR -1 +//#define U_HOME_DIR -1 +//#define V_HOME_DIR -1 +//#define W_HOME_DIR -1 // @section machine @@ -1402,7 +1463,7 @@ #define X_BED_SIZE 200 #define Y_BED_SIZE 200 -// Travel limits (mm) after homing, corresponding to endstop positions. +// Travel limits (linear=mm, rotational=°) after homing, corresponding to endstop positions. #define X_MIN_POS 0 #define Y_MIN_POS 0 #define Z_MIN_POS 0 @@ -1415,6 +1476,12 @@ //#define J_MAX_POS 50 //#define K_MIN_POS 0 //#define K_MAX_POS 50 +//#define U_MIN_POS 0 +//#define U_MAX_POS 50 +//#define V_MIN_POS 0 +//#define V_MAX_POS 50 +//#define W_MIN_POS 0 +//#define W_MAX_POS 50 /** * Software Endstops @@ -1434,6 +1501,9 @@ #define MIN_SOFTWARE_ENDSTOP_I #define MIN_SOFTWARE_ENDSTOP_J #define MIN_SOFTWARE_ENDSTOP_K + #define MIN_SOFTWARE_ENDSTOP_U + #define MIN_SOFTWARE_ENDSTOP_V + #define MIN_SOFTWARE_ENDSTOP_W #endif // Max software endstops constrain movement within maximum coordinate bounds @@ -1445,6 +1515,9 @@ #define MAX_SOFTWARE_ENDSTOP_I #define MAX_SOFTWARE_ENDSTOP_J #define MAX_SOFTWARE_ENDSTOP_K + #define MAX_SOFTWARE_ENDSTOP_U + #define MAX_SOFTWARE_ENDSTOP_V + #define MAX_SOFTWARE_ENDSTOP_W #endif #if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS) @@ -1759,6 +1832,9 @@ //#define MANUAL_I_HOME_POS 0 //#define MANUAL_J_HOME_POS 0 //#define MANUAL_K_HOME_POS 0 +//#define MANUAL_U_HOME_POS 0 +//#define MANUAL_V_HOME_POS 0 +//#define MANUAL_W_HOME_POS 0 /** * Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area. @@ -1774,7 +1850,7 @@ #define Z_SAFE_HOMING_Y_POINT Y_CENTER // Y point for Z homing #endif -// Homing speeds (mm/min) +// Homing speeds (linear=mm/min, rotational=°/min) #define HOMING_FEEDRATE_MM_M { (50*60), (50*60), (4*60) } // Validate that endstops are triggered on homing moves diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 957222e7f7..9c438e0406 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -30,7 +30,7 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 02000903 +#define CONFIGURATION_ADV_H_VERSION 02010000 //=========================================================================== //============================= Thermal Settings ============================ @@ -843,12 +843,12 @@ * the position of the toolhead relative to the workspace. */ -//#define SENSORLESS_BACKOFF_MM { 2, 2, 0 } // (mm) Backoff from endstops before sensorless homing +//#define SENSORLESS_BACKOFF_MM { 2, 2, 0 } // (linear=mm, rotational=°) Backoff from endstops before sensorless homing -#define HOMING_BUMP_MM { 5, 5, 2 } // (mm) Backoff from endstops after first bump +#define HOMING_BUMP_MM { 5, 5, 2 } // (linear=mm, rotational=°) Backoff from endstops after first bump #define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate) -//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing +//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (linear=mm, rotational=°) Backoff from endstops after homing //#define QUICK_HOME // If G28 contains XY do a diagonal move first //#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X @@ -1034,6 +1034,9 @@ #define INVERT_I_STEP_PIN false #define INVERT_J_STEP_PIN false #define INVERT_K_STEP_PIN false +#define INVERT_U_STEP_PIN false +#define INVERT_V_STEP_PIN false +#define INVERT_W_STEP_PIN false #define INVERT_E_STEP_PIN false /** @@ -1048,11 +1051,14 @@ #define DISABLE_INACTIVE_I true #define DISABLE_INACTIVE_J true #define DISABLE_INACTIVE_K true +#define DISABLE_INACTIVE_U true +#define DISABLE_INACTIVE_V true +#define DISABLE_INACTIVE_W true #define DISABLE_INACTIVE_E true // Default Minimum Feedrates for printing and travel moves -#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s) Minimum feedrate. Set with M205 S. -#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s) Minimum travel feedrate. Set with M205 T. +#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s. °/s for rotational-only moves) Minimum feedrate. Set with M205 S. +#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s. °/s for rotational-only moves) Minimum travel feedrate. Set with M205 T. // Minimum time that a segment needs to take as the buffer gets emptied #define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B. @@ -1088,7 +1094,7 @@ #if ENABLED(BACKLASH_COMPENSATION) // Define values for backlash distance and correction. // If BACKLASH_GCODE is enabled these values are the defaults. - #define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm) One value for each linear axis + #define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (linear=mm, rotational=°) One value for each linear axis #define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction // Add steps for motor direction changes on CORE kinematics @@ -1165,6 +1171,12 @@ //#define CALIBRATION_MEASURE_JMAX //#define CALIBRATION_MEASURE_KMIN //#define CALIBRATION_MEASURE_KMAX + //#define CALIBRATION_MEASURE_UMIN + //#define CALIBRATION_MEASURE_UMAX + //#define CALIBRATION_MEASURE_VMIN + //#define CALIBRATION_MEASURE_VMAX + //#define CALIBRATION_MEASURE_WMIN + //#define CALIBRATION_MEASURE_WMAX // Probing at the exact top center only works if the center is flat. If // probing on a screwhead or hollow washer, probe near the edges. @@ -2012,6 +2024,21 @@ // @section leveling +/** + * Use Safe Bed Leveling coordinates to move axes to a useful position before bed probing. + * For example, after homing a rotational axis the Z probe might not be perpendicular to the bed. + * Choose values the orient the bed horizontally and the Z-probe vertically. + */ +//#define SAFE_BED_LEVELING_START_X 0.0 +//#define SAFE_BED_LEVELING_START_Y 0.0 +//#define SAFE_BED_LEVELING_START_Z 0.0 +//#define SAFE_BED_LEVELING_START_I 0.0 +//#define SAFE_BED_LEVELING_START_J 0.0 +//#define SAFE_BED_LEVELING_START_K 0.0 +//#define SAFE_BED_LEVELING_START_U 0.0 +//#define SAFE_BED_LEVELING_START_V 0.0 +//#define SAFE_BED_LEVELING_START_W 0.0 + /** * Points to probe for all 3-point Leveling procedures. * Override if the automatically selected points are inadequate. @@ -2423,7 +2450,7 @@ /** * Extra G-code to run while executing tool-change commands. Can be used to use an additional - * stepper motor (I axis, see option LINEAR_AXES in Configuration.h) to drive the tool-changer. + * stepper motor (I axis, see option NUM_AXES in Configuration.h) to drive the tool-changer. */ //#define EVENT_GCODE_TOOLCHANGE_T0 "G28 A\nG1 A0" // Extra G-code to run while executing tool-change command T0 //#define EVENT_GCODE_TOOLCHANGE_T1 "G1 A10" // Extra G-code to run while executing tool-change command T1 @@ -2626,6 +2653,24 @@ #define K_MICROSTEPS 16 #endif + #if AXIS_DRIVER_TYPE_U(TMC26X) + #define U_MAX_CURRENT 1000 + #define U_SENSE_RESISTOR 91 + #define U_MICROSTEPS 16 + #endif + + #if AXIS_DRIVER_TYPE_V(TMC26X) + #define V_MAX_CURRENT 1000 + #define V_SENSE_RESISTOR 91 + #define V_MICROSTEPS 16 + #endif + + #if AXIS_DRIVER_TYPE_W(TMC26X) + #define W_MAX_CURRENT 1000 + #define W_SENSE_RESISTOR 91 + #define W_MICROSTEPS 16 + #endif + #if AXIS_DRIVER_TYPE_E0(TMC26X) #define E0_MAX_CURRENT 1000 #define E0_SENSE_RESISTOR 91 @@ -2814,6 +2859,33 @@ //#define K_HOLD_MULTIPLIER 0.5 #endif + #if AXIS_IS_TMC(U) + #define U_CURRENT 800 + #define U_CURRENT_HOME U_CURRENT + #define U_MICROSTEPS 8 + #define U_RSENSE 0.11 + #define U_CHAIN_POS -1 + //#define U_INTERPOLATE true + #endif + + #if AXIS_IS_TMC(V) + #define V_CURRENT 800 + #define V_CURRENT_HOME V_CURRENT + #define V_MICROSTEPS 8 + #define V_RSENSE 0.11 + #define V_CHAIN_POS -1 + //#define V_INTERPOLATE true + #endif + + #if AXIS_IS_TMC(W) + #define W_CURRENT 800 + #define W_CURRENT_HOME W_CURRENT + #define W_MICROSTEPS 8 + #define W_RSENSE 0.11 + #define W_CHAIN_POS -1 + //#define W_INTERPOLATE true + #endif + #if AXIS_IS_TMC(E0) #define E0_CURRENT 800 #define E0_MICROSTEPS 16 @@ -2901,6 +2973,9 @@ //#define I_CS_PIN -1 //#define J_CS_PIN -1 //#define K_CS_PIN -1 + //#define U_CS_PIN -1 + //#define V_CS_PIN -1 + //#define W_CS_PIN -1 //#define E0_CS_PIN -1 //#define E1_CS_PIN -1 //#define E2_CS_PIN -1 @@ -2943,6 +3018,9 @@ //#define I_SLAVE_ADDRESS 0 //#define J_SLAVE_ADDRESS 0 //#define K_SLAVE_ADDRESS 0 + //#define U_SLAVE_ADDRESS 0 + //#define V_SLAVE_ADDRESS 0 + //#define W_SLAVE_ADDRESS 0 //#define E0_SLAVE_ADDRESS 0 //#define E1_SLAVE_ADDRESS 0 //#define E2_SLAVE_ADDRESS 0 @@ -2970,6 +3048,9 @@ #define STEALTHCHOP_I #define STEALTHCHOP_J #define STEALTHCHOP_K + #define STEALTHCHOP_U + #define STEALTHCHOP_V + #define STEALTHCHOP_W #define STEALTHCHOP_E /** @@ -2996,9 +3077,12 @@ //#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z4 CHOPPER_TIMING_Z - //#define CHOPPER_TIMING_I CHOPPER_TIMING - //#define CHOPPER_TIMING_J CHOPPER_TIMING - //#define CHOPPER_TIMING_K CHOPPER_TIMING + //#define CHOPPER_TIMING_I CHOPPER_TIMING // For I Axis + //#define CHOPPER_TIMING_J CHOPPER_TIMING // For J Axis + //#define CHOPPER_TIMING_K CHOPPER_TIMING // For K Axis + //#define CHOPPER_TIMING_U CHOPPER_TIMING // For U Axis + //#define CHOPPER_TIMING_V CHOPPER_TIMING // For V Axis + //#define CHOPPER_TIMING_W CHOPPER_TIMING // For W Axis //#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below) //#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E @@ -3044,9 +3128,12 @@ #define Z2_HYBRID_THRESHOLD 3 #define Z3_HYBRID_THRESHOLD 3 #define Z4_HYBRID_THRESHOLD 3 - #define I_HYBRID_THRESHOLD 3 - #define J_HYBRID_THRESHOLD 3 - #define K_HYBRID_THRESHOLD 3 + #define I_HYBRID_THRESHOLD 3 // [linear=mm/s, rotational=°/s] + #define J_HYBRID_THRESHOLD 3 // [linear=mm/s, rotational=°/s] + #define K_HYBRID_THRESHOLD 3 // [linear=mm/s, rotational=°/s] + #define U_HYBRID_THRESHOLD 3 // [mm/s] + #define V_HYBRID_THRESHOLD 3 + #define W_HYBRID_THRESHOLD 3 #define E0_HYBRID_THRESHOLD 30 #define E1_HYBRID_THRESHOLD 30 #define E2_HYBRID_THRESHOLD 30 @@ -3096,6 +3183,9 @@ //#define I_STALL_SENSITIVITY 8 //#define J_STALL_SENSITIVITY 8 //#define K_STALL_SENSITIVITY 8 + //#define U_STALL_SENSITIVITY 8 + //#define V_STALL_SENSITIVITY 8 + //#define W_STALL_SENSITIVITY 8 //#define SPI_ENDSTOPS // TMC2130 only //#define IMPROVE_HOMING_RELIABILITY #endif @@ -3263,6 +3353,33 @@ #define K_SLEW_RATE 1 #endif + #if AXIS_IS_L64XX(U) + #define U_MICROSTEPS 128 + #define U_OVERCURRENT 2000 + #define U_STALLCURRENT 1500 + #define U_MAX_VOLTAGE 127 + #define U_CHAIN_POS -1 + #define U_SLEW_RATE 1 + #endif + + #if AXIS_IS_L64XX(V) + #define V_MICROSTEPS 128 + #define V_OVERCURRENT 2000 + #define V_STALLCURRENT 1500 + #define V_MAX_VOLTAGE 127 + #define V_CHAIN_POS -1 + #define V_SLEW_RATE 1 + #endif + + #if AXIS_IS_L64XX(W) + #define W_MICROSTEPS 128 + #define W_OVERCURRENT 2000 + #define W_STALLCURRENT 1500 + #define W_MAX_VOLTAGE 127 + #define W_CHAIN_POS -1 + #define W_SLEW_RATE 1 + #endif + #if AXIS_IS_L64XX(E0) #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 diff --git a/Marlin/src/HAL/AVR/endstop_interrupts.h b/Marlin/src/HAL/AVR/endstop_interrupts.h index 0ce8574c53..5511aa406f 100644 --- a/Marlin/src/HAL/AVR/endstop_interrupts.h +++ b/Marlin/src/HAL/AVR/endstop_interrupts.h @@ -213,6 +213,51 @@ void setup_endstop_interrupts() { pciSetup(K_MIN_PIN); #endif #endif + #if HAS_U_MAX + #if (digitalPinToInterrupt(U_MAX_PIN) != NOT_AN_INTERRUPT) + _ATTACH(U_MAX_PIN); + #else + static_assert(digitalPinHasPCICR(U_MAX_PIN), "U_MAX_PIN is not interrupt-capable"); + pciSetup(U_MAX_PIN); + #endif + #elif HAS_U_MIN + #if (digitalPinToInterrupt(U_MIN_PIN) != NOT_AN_INTERRUPT) + _ATTACH(U_MIN_PIN); + #else + static_assert(digitalPinHasPCICR(U_MIN_PIN), "U_MIN_PIN is not interrupt-capable"); + pciSetup(U_MIN_PIN); + #endif + #endif + #if HAS_V_MAX + #if (digitalPinToInterrupt(V_MAX_PIN) != NOT_AN_INTERRUPT) + _ATTACH(V_MAX_PIN); + #else + static_assert(digitalPinHasPCICR(V_MAX_PIN), "V_MAX_PIN is not interrupt-capable"); + pciSetup(V_MAX_PIN); + #endif + #elif HAS_V_MIN + #if (digitalPinToInterrupt(V_MIN_PIN) != NOT_AN_INTERRUPT) + _ATTACH(V_MIN_PIN); + #else + static_assert(digitalPinHasPCICR(V_MIN_PIN), "V_MIN_PIN is not interrupt-capable"); + pciSetup(V_MIN_PIN); + #endif + #endif + #if HAS_W_MAX + #if (digitalPinToInterrupt(W_MAX_PIN) != NOT_AN_INTERRUPT) + _ATTACH(W_MAX_PIN); + #else + static_assert(digitalPinHasPCICR(W_MAX_PIN), "W_MAX_PIN is not interrupt-capable"); + pciSetup(W_MAX_PIN); + #endif + #elif HAS_W_MIN + #if (digitalPinToInterrupt(W_MIN_PIN) != NOT_AN_INTERRUPT) + _ATTACH(W_MIN_PIN); + #else + static_assert(digitalPinHasPCICR(W_MIN_PIN), "W_MIN_PIN is not interrupt-capable"); + pciSetup(W_MIN_PIN); + #endif + #endif #if HAS_X2_MAX #if (digitalPinToInterrupt(X2_MAX_PIN) != NOT_AN_INTERRUPT) _ATTACH(X2_MAX_PIN); diff --git a/Marlin/src/HAL/DUE/endstop_interrupts.h b/Marlin/src/HAL/DUE/endstop_interrupts.h index 9c7e210488..c1bbcb121b 100644 --- a/Marlin/src/HAL/DUE/endstop_interrupts.h +++ b/Marlin/src/HAL/DUE/endstop_interrupts.h @@ -70,4 +70,10 @@ void setup_endstop_interrupts() { TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN)); TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN)); TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN)); + TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN)); + TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN)); + TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN)); + TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN)); + TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN)); + TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN)); } diff --git a/Marlin/src/HAL/ESP32/endstop_interrupts.h b/Marlin/src/HAL/ESP32/endstop_interrupts.h index 4725df921b..0536864610 100644 --- a/Marlin/src/HAL/ESP32/endstop_interrupts.h +++ b/Marlin/src/HAL/ESP32/endstop_interrupts.h @@ -65,4 +65,10 @@ void setup_endstop_interrupts() { TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN)); TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN)); TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN)); + TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN)); + TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN)); + TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN)); + TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN)); + TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN)); + TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN)); } diff --git a/Marlin/src/HAL/LPC1768/endstop_interrupts.h b/Marlin/src/HAL/LPC1768/endstop_interrupts.h index 23bd0cc982..e4ac17f608 100644 --- a/Marlin/src/HAL/LPC1768/endstop_interrupts.h +++ b/Marlin/src/HAL/LPC1768/endstop_interrupts.h @@ -155,4 +155,37 @@ void setup_endstop_interrupts() { #endif _ATTACH(K_MIN_PIN); #endif + #if HAS_U_MAX + #if !LPC1768_PIN_INTERRUPT_M(U_MAX_PIN) + #error "U_MAX_PIN is not INTERRUPT-capable." + #endif + _ATTACH(U_MAX_PIN); + #elif HAS_U_MIN + #if !LPC1768_PIN_INTERRUPT_M(U_MIN_PIN) + #error "U_MIN_PIN is not INTERRUPT-capable." + #endif + _ATTACH(U_MIN_PIN); + #endif + #if HAS_V_MAX + #if !LPC1768_PIN_INTERRUPT_M(V_MAX_PIN) + #error "V_MAX_PIN is not INTERRUPT-capable." + #endif + _ATTACH(V_MAX_PIN); + #elif HAS_V_MIN + #if !LPC1768_PIN_INTERRUPT_M(V_MIN_PIN) + #error "V_MIN_PIN is not INTERRUPT-capable." + #endif + _ATTACH(V_MIN_PIN); + #endif + #if HAS_W_MAX + #if !LPC1768_PIN_INTERRUPT_M(W_MAX_PIN) + #error "W_MAX_PIN is not INTERRUPT-capable." + #endif + _ATTACH(W_MAX_PIN); + #elif HAS_W_MIN + #if !LPC1768_PIN_INTERRUPT_M(W_MIN_PIN) + #error "W_MIN_PIN is not INTERRUPT-capable." + #endif + _ATTACH(W_MIN_PIN); + #endif } diff --git a/Marlin/src/HAL/SAMD51/endstop_interrupts.h b/Marlin/src/HAL/SAMD51/endstop_interrupts.h index 61a06c0d4b..2f02f404f5 100644 --- a/Marlin/src/HAL/SAMD51/endstop_interrupts.h +++ b/Marlin/src/HAL/SAMD51/endstop_interrupts.h @@ -60,6 +60,12 @@ #define MATCH_J_MIN_EILINE(P) TERN0(HAS_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN)) #define MATCH_K_MAX_EILINE(P) TERN0(HAS_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN)) #define MATCH_K_MIN_EILINE(P) TERN0(HAS_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN)) +#define MATCH_U_MAX_EILINE(P) TERN0(HAS_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN)) +#define MATCH_U_MIN_EILINE(P) TERN0(HAS_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN)) +#define MATCH_V_MAX_EILINE(P) TERN0(HAS_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN)) +#define MATCH_V_MIN_EILINE(P) TERN0(HAS_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN)) +#define MATCH_W_MAX_EILINE(P) TERN0(HAS_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN)) +#define MATCH_W_MIN_EILINE(P) TERN0(HAS_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN)) #define MATCH_Z2_MAX_EILINE(P) TERN0(HAS_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN)) #define MATCH_Z2_MIN_EILINE(P) TERN0(HAS_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN)) #define MATCH_Z3_MAX_EILINE(P) TERN0(HAS_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN)) @@ -75,6 +81,9 @@ && !MATCH_I_MAX_EILINE(P) && !MATCH_I_MIN_EILINE(P) \ && !MATCH_J_MAX_EILINE(P) && !MATCH_J_MIN_EILINE(P) \ && !MATCH_K_MAX_EILINE(P) && !MATCH_K_MIN_EILINE(P) \ + && !MATCH_U_MAX_EILINE(P) && !MATCH_U_MIN_EILINE(P) \ + && !MATCH_V_MAX_EILINE(P) && !MATCH_V_MIN_EILINE(P) \ + && !MATCH_W_MAX_EILINE(P) && !MATCH_W_MIN_EILINE(P) \ && !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \ && !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \ && !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \ @@ -199,4 +208,40 @@ void setup_endstop_interrupts() { #endif attachInterrupt(K_MIN_PIN, endstop_ISR, CHANGE); #endif + #if HAS_U_MAX + #if !AVAILABLE_EILINE(U_MAX_PIN) + #error "U_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(U_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_U_MIN + #if !AVAILABLE_EILINE(U_MIN_PIN) + #error "U_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(U_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_V_MAX + #if !AVAILABLE_EILINE(V_MAX_PIN) + #error "V_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(V_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_V_MIN + #if !AVAILABLE_EILINE(V_MIN_PIN) + #error "V_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(V_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_W_MAX + #if !AVAILABLE_EILINE(W_MAX_PIN) + #error "W_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(W_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_W_MIN + #if !AVAILABLE_EILINE(W_MIN_PIN) + #error "W_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(W_MIN_PIN, endstop_ISR, CHANGE); + #endif } diff --git a/Marlin/src/HAL/STM32/endstop_interrupts.h b/Marlin/src/HAL/STM32/endstop_interrupts.h index 90870881fe..d2f20ba1c7 100644 --- a/Marlin/src/HAL/STM32/endstop_interrupts.h +++ b/Marlin/src/HAL/STM32/endstop_interrupts.h @@ -52,4 +52,10 @@ void setup_endstop_interrupts() { TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN)); TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN)); TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN)); + TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN)); + TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN)); + TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN)); + TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN)); + TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN)); + TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN)); } diff --git a/Marlin/src/HAL/STM32F1/endstop_interrupts.h b/Marlin/src/HAL/STM32F1/endstop_interrupts.h index 4d7edb9496..a1ef8a8c3a 100644 --- a/Marlin/src/HAL/STM32F1/endstop_interrupts.h +++ b/Marlin/src/HAL/STM32F1/endstop_interrupts.h @@ -77,4 +77,10 @@ void setup_endstop_interrupts() { TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN)); TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN)); TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN)); + TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN)); + TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN)); + TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN)); + TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN)); + TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN)); + TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN)); } diff --git a/Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h b/Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h index 9c7e210488..c1bbcb121b 100644 --- a/Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h +++ b/Marlin/src/HAL/TEENSY31_32/endstop_interrupts.h @@ -70,4 +70,10 @@ void setup_endstop_interrupts() { TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN)); TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN)); TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN)); + TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN)); + TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN)); + TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN)); + TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN)); + TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN)); + TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN)); } diff --git a/Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h b/Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h index a300248885..48d3bbbfa1 100644 --- a/Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h +++ b/Marlin/src/HAL/TEENSY35_36/endstop_interrupts.h @@ -69,4 +69,10 @@ void setup_endstop_interrupts() { TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN)); TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN)); TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN)); + TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN)); + TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN)); + TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN)); + TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN)); + TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN)); + TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN)); } diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index be93bfcfb9..2570e6ebde 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -436,6 +436,9 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { TERN_(DISABLE_INACTIVE_I, stepper.disable_axis(I_AXIS)); TERN_(DISABLE_INACTIVE_J, stepper.disable_axis(J_AXIS)); TERN_(DISABLE_INACTIVE_K, stepper.disable_axis(K_AXIS)); + TERN_(DISABLE_INACTIVE_U, stepper.disable_axis(U_AXIS)); + TERN_(DISABLE_INACTIVE_V, stepper.disable_axis(V_AXIS)); + TERN_(DISABLE_INACTIVE_W, stepper.disable_axis(W_AXIS)); TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers()); TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled()); @@ -993,6 +996,15 @@ inline void tmc_standby_setup() { #if PIN_EXISTS(K_STDBY) SET_INPUT_PULLDOWN(K_STDBY_PIN); #endif + #if PIN_EXISTS(U_STDBY) + SET_INPUT_PULLDOWN(U_STDBY_PIN); + #endif + #if PIN_EXISTS(V_STDBY) + SET_INPUT_PULLDOWN(V_STDBY_PIN); + #endif + #if PIN_EXISTS(W_STDBY) + SET_INPUT_PULLDOWN(W_STDBY_PIN); + #endif #if PIN_EXISTS(E0_STDBY) SET_INPUT_PULLDOWN(E0_STDBY_PIN); #endif diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index ac1f4a155d..80262d513f 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -63,6 +63,9 @@ #define AXIS_DRIVER_TYPE_I(T) _AXIS_DRIVER_TYPE(I,T) #define AXIS_DRIVER_TYPE_J(T) _AXIS_DRIVER_TYPE(J,T) #define AXIS_DRIVER_TYPE_K(T) _AXIS_DRIVER_TYPE(K,T) +#define AXIS_DRIVER_TYPE_U(T) _AXIS_DRIVER_TYPE(U,T) +#define AXIS_DRIVER_TYPE_V(T) _AXIS_DRIVER_TYPE(V,T) +#define AXIS_DRIVER_TYPE_W(T) _AXIS_DRIVER_TYPE(W,T) #define AXIS_DRIVER_TYPE_X2(T) (EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) && _AXIS_DRIVER_TYPE(X2,T)) #define AXIS_DRIVER_TYPE_Y2(T) (ENABLED(Y_DUAL_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Y2,T)) @@ -87,6 +90,7 @@ #define HAS_DRIVER(T) ( AXIS_DRIVER_TYPE_X(T) || AXIS_DRIVER_TYPE_Y(T) || AXIS_DRIVER_TYPE_Z(T) \ || AXIS_DRIVER_TYPE_I(T) || AXIS_DRIVER_TYPE_J(T) || AXIS_DRIVER_TYPE_K(T) \ + || AXIS_DRIVER_TYPE_U(T) || AXIS_DRIVER_TYPE_V(T) || AXIS_DRIVER_TYPE_W(T) \ || AXIS_DRIVER_TYPE_X2(T) || AXIS_DRIVER_TYPE_Y2(T) || AXIS_DRIVER_TYPE_Z2(T) \ || AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) || HAS_E_DRIVER(T) ) @@ -161,6 +165,7 @@ || AXIS_HAS_##T(Y) || AXIS_HAS_##T(Y2) \ || AXIS_HAS_##T(Z) || AXIS_HAS_##T(Z2) || AXIS_HAS_##T(Z3) || AXIS_HAS_##T(Z4) \ || AXIS_HAS_##T(I) || AXIS_HAS_##T(J) || AXIS_HAS_##T(K) \ + || AXIS_HAS_##T(U) || AXIS_HAS_##T(V) || AXIS_HAS_##T(W) \ || E_AXIS_HAS(T) ) #if ANY_AXIS_HAS(STEALTHCHOP) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 8e0784f70d..89c0babc25 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -444,6 +444,54 @@ #define STR_K "" #endif +#if HAS_U_AXIS + #if AXIS7_NAME == 'U' + #define STR_U "U" + #define STR_U_MIN "u_min" + #define STR_U_MAX "u_max" + #elif AXIS7_NAME == 'V' + #define STR_U "V" + #define STR_U_MIN "v_min" + #define STR_U_MAX "v_max" + #elif AXIS7_NAME == 'W' + #define STR_U "W" + #define STR_U_MIN "w_min" + #define STR_U_MAX "w_max" + #else + #error "AXIS7_NAME can only be one of 'U', 'V', or 'W'." + #endif +#else + #define STR_U "" +#endif + +#if HAS_V_AXIS + #if AXIS8_NAME == 'V' + #define STR_V "V" + #define STR_V_MIN "v_min" + #define STR_V_MAX "v_max" + #elif AXIS8_NAME == 'W' + #define STR_V "W" + #define STR_V_MIN "w_min" + #define STR_V_MAX "w_max" + #else + #error "AXIS8_NAME can only be one of 'V', or 'W'." + #endif +#else + #define STR_V "" +#endif + +#if HAS_W_AXIS + #if AXIS9_NAME == 'W' + #define STR_W "W" + #define STR_W_MIN "w_min" + #define STR_W_MAX "w_max" + #else + #error "AXIS9_NAME can only be 'W'." + #endif +#else + #define STR_W "" +#endif + #if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) // Custom characters defined in the first 8 characters of the LCD diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 31808586cf..629486d85f 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -39,24 +39,36 @@ #define _ISTOP_ 0x04 #define _JSTOP_ 0x05 #define _KSTOP_ 0x06 +#define _USTOP_ 0x07 +#define _VSTOP_ 0x08 +#define _WSTOP_ 0x09 #define _XMIN_ 0x11 #define _YMIN_ 0x12 #define _ZMIN_ 0x13 #define _IMIN_ 0x14 #define _JMIN_ 0x15 #define _KMIN_ 0x16 +#define _UMIN_ 0x17 +#define _VMIN_ 0x18 +#define _WMIN_ 0x19 #define _XMAX_ 0x21 #define _YMAX_ 0x22 #define _ZMAX_ 0x23 #define _IMAX_ 0x24 #define _JMAX_ 0x25 #define _KMAX_ 0x26 +#define _UMAX_ 0x27 +#define _VMAX_ 0x28 +#define _WMAX_ 0x29 #define _XDIAG_ 0x31 #define _YDIAG_ 0x32 #define _ZDIAG_ 0x33 #define _IDIAG_ 0x34 #define _JDIAG_ 0x35 #define _KDIAG_ 0x36 +#define _UDIAG_ 0x37 +#define _VDIAG_ 0x38 +#define _WDIAG_ 0x39 #define _E0DIAG_ 0xE0 #define _E1DIAG_ 0xE1 #define _E2DIAG_ 0xE2 @@ -350,7 +362,7 @@ #define _LIST_N(N,V...) LIST_##N(V) #define LIST_N(N,V...) _LIST_N(N,V) -#define LIST_N_1(N,K) _LIST_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K) +#define LIST_N_1(N,K) _LIST_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K) #define ARRAY_N(N,V...) { _LIST_N(N,V) } #define ARRAY_N_1(N,K) { LIST_N_1(N,K) } diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 562cddbaa0..819b06968c 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -32,14 +32,18 @@ uint8_t marlin_debug_flags = MARLIN_DEBUG_NONE; // Commonly-used strings in serial output PGMSTR(NUL_STR, ""); PGMSTR(SP_P_STR, " P"); PGMSTR(SP_T_STR, " T"); PGMSTR(X_STR, "X"); PGMSTR(Y_STR, "Y"); PGMSTR(Z_STR, "Z"); PGMSTR(E_STR, "E"); +PGMSTR(U_STR, STR_U); PGMSTR(V_STR, STR_V); PGMSTR(W_STR, STR_W); PGMSTR(X_LBL, "X:"); PGMSTR(Y_LBL, "Y:"); PGMSTR(Z_LBL, "Z:"); PGMSTR(E_LBL, "E:"); +PGMSTR(U_LBL, STR_U ":"); PGMSTR(V_LBL, STR_V ":"); PGMSTR(W_LBL, STR_W ":"); PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C"); PGMSTR(SP_X_STR, " X"); PGMSTR(SP_Y_STR, " Y"); PGMSTR(SP_Z_STR, " Z"); PGMSTR(SP_E_STR, " E"); PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMSTR(SP_E_LBL, " E:"); PGMSTR(I_STR, STR_I); PGMSTR(J_STR, STR_J); PGMSTR(K_STR, STR_K); PGMSTR(I_LBL, STR_I ":"); PGMSTR(J_LBL, STR_J ":"); PGMSTR(K_LBL, STR_K ":"); PGMSTR(SP_I_STR, " " STR_I); PGMSTR(SP_J_STR, " " STR_J); PGMSTR(SP_K_STR, " " STR_K); +PGMSTR(SP_U_STR, " " STR_U); PGMSTR(SP_V_STR, " " STR_V); PGMSTR(SP_W_STR, " " STR_W); PGMSTR(SP_I_LBL, " " STR_I ":"); PGMSTR(SP_J_LBL, " " STR_J ":"); PGMSTR(SP_K_LBL, " " STR_K ":"); +PGMSTR(SP_U_LBL, " " STR_U ":"); PGMSTR(SP_V_LBL, " " STR_V ":"); PGMSTR(SP_W_LBL, " " STR_W ":"); // Hook Meatpack if it's enabled on the first leaf #if ENABLED(MEATPACK_ON_SERIAL_PORT_1) @@ -102,10 +106,10 @@ void print_bin(uint16_t val) { } } -void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) { +void print_pos(NUM_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) { if (prefix) serial_print(prefix); SERIAL_ECHOPGM_P( - LIST_N(DOUBLE(LINEAR_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k) + LIST_N(DOUBLE(NUM_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k, SP_U_STR, u, SP_V_STR, v, SP_W_STR, w) ); if (suffix) serial_print(suffix); else SERIAL_EOL(); } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 98e82b6d72..2998fe803f 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -29,17 +29,12 @@ #endif // Commonly-used strings in serial output -extern const char NUL_STR[], - SP_X_STR[], SP_Y_STR[], SP_Z_STR[], - SP_A_STR[], SP_B_STR[], SP_C_STR[], SP_E_STR[], - SP_X_LBL[], SP_Y_LBL[], SP_Z_LBL[], SP_E_LBL[], - SP_I_STR[], SP_J_STR[], SP_K_STR[], - SP_I_LBL[], SP_J_LBL[], SP_K_LBL[], - SP_P_STR[], SP_T_STR[], - X_STR[], Y_STR[], Z_STR[], E_STR[], - I_STR[], J_STR[], K_STR[], - X_LBL[], Y_LBL[], Z_LBL[], E_LBL[], - I_LBL[], J_LBL[], K_LBL[]; +extern const char NUL_STR[], SP_P_STR[], SP_T_STR[], + SP_A_STR[], SP_B_STR[], SP_C_STR[], + SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_I_STR[], SP_J_STR[], SP_K_STR[], SP_U_STR[], SP_V_STR[], SP_W_STR[], SP_E_STR[], + SP_X_LBL[], SP_Y_LBL[], SP_Z_LBL[], SP_I_LBL[], SP_J_LBL[], SP_K_LBL[], SP_U_LBL[], SP_V_LBL[], SP_W_LBL[], SP_E_LBL[], + X_STR[], Y_STR[], Z_STR[], I_STR[], J_STR[], K_STR[], U_STR[], V_STR[], W_STR[], E_STR[], + X_LBL[], Y_LBL[], Z_LBL[], I_LBL[], J_LBL[], K_LBL[], U_LBL[], V_LBL[], W_LBL[], E_LBL[]; // // Debugging flags for use by M111 @@ -348,10 +343,10 @@ void serial_spaces(uint8_t count); void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space (sp==1) or plus (sp==2) void print_bin(const uint16_t val); -void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr); +void print_pos(NUM_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr); inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) { - print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix); + print_pos(NUM_AXIS_ELEM(xyz), prefix, suffix); } #define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 045ca3589f..47a126f165 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -36,23 +36,33 @@ struct IF { typedef R type; }; template struct IF { typedef L type; }; -#define LINEAR_AXIS_GANG(V...) GANG_N(LINEAR_AXES, V) -#define LINEAR_AXIS_CODE(V...) CODE_N(LINEAR_AXES, V) -#define LINEAR_AXIS_LIST(V...) LIST_N(LINEAR_AXES, V) -#define LINEAR_AXIS_ARRAY(V...) { LINEAR_AXIS_LIST(V) } -#define LINEAR_AXIS_ARGS(T...) LINEAR_AXIS_LIST(T x, T y, T z, T i, T j, T k) -#define LINEAR_AXIS_ELEM(O) LINEAR_AXIS_LIST(O.x, O.y, O.z, O.i, O.j, O.k) -#define LINEAR_AXIS_DEFS(T,V) LINEAR_AXIS_LIST(T x=V, T y=V, T z=V, T i=V, T j=V, T k=V) +#define NUM_AXIS_GANG(V...) GANG_N(NUM_AXES, V) +#define NUM_AXIS_CODE(V...) CODE_N(NUM_AXES, V) +#define NUM_AXIS_LIST(V...) LIST_N(NUM_AXES, V) +#define NUM_AXIS_ARRAY(V...) { NUM_AXIS_LIST(V) } +#define NUM_AXIS_ARGS(T...) NUM_AXIS_LIST(T x, T y, T z, T i, T j, T k, T u, T v, T w) +#define NUM_AXIS_ELEM(O) NUM_AXIS_LIST(O.x, O.y, O.z, O.i, O.j, O.k, O.u, O.v, O.w) +#define NUM_AXIS_DEFS(T,V) NUM_AXIS_LIST(T x=V, T y=V, T z=V, T i=V, T j=V, T k=V, T u=V, T v=V, T w=V) -#define LOGICAL_AXIS_GANG(E,V...) LINEAR_AXIS_GANG(V) GANG_ITEM_E(E) -#define LOGICAL_AXIS_CODE(E,V...) LINEAR_AXIS_CODE(V) CODE_ITEM_E(E) -#define LOGICAL_AXIS_LIST(E,V...) LINEAR_AXIS_LIST(V) LIST_ITEM_E(E) +#define LOGICAL_AXIS_GANG(E,V...) NUM_AXIS_GANG(V) GANG_ITEM_E(E) +#define LOGICAL_AXIS_CODE(E,V...) NUM_AXIS_CODE(V) CODE_ITEM_E(E) +#define LOGICAL_AXIS_LIST(E,V...) NUM_AXIS_LIST(V) LIST_ITEM_E(E) #define LOGICAL_AXIS_ARRAY(E,V...) { LOGICAL_AXIS_LIST(E,V) } -#define LOGICAL_AXIS_ARGS(T...) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k) -#define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k) -#define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V) +#define LOGICAL_AXIS_ARGS(T...) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k, T u, T v, T w) +#define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k, O.u, O.v, O.w) +#define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V, T u=V, T v=V, T w=V) -#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", STR_I, STR_J, STR_K) +#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", STR_I, STR_J, STR_K, STR_U, STR_V, STR_W) + +#define XYZ_GANG(V...) GANG_N(PRIMARY_LINEAR_AXES, V) +#define XYZ_CODE(V...) CODE_N(PRIMARY_LINEAR_AXES, V) + +#define SECONDARY_AXIS_GANG(V...) GANG_N(SECONDARY_AXES, V) +#define SECONDARY_AXIS_CODE(V...) CODE_N(SECONDARY_AXES, V) + +#if HAS_ROTATIONAL_AXES + #define ROTATIONAL_AXIS_GANG(V...) GANG_N(ROTATIONAL_AXES, V) +#endif #if HAS_EXTRUDERS #define LIST_ITEM_E(N) , N @@ -64,7 +74,7 @@ struct IF { typedef L type; }; #define GANG_ITEM_E(N) #endif -#define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L) +#define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L || AXIS7_NAME == L || AXIS8_NAME == L || AXIS9_NAME == L) // // Enumerated axis indices @@ -76,7 +86,7 @@ struct IF { typedef L type; }; enum AxisEnum : uint8_t { // Linear axes may be controlled directly or indirectly - LINEAR_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS) + NUM_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS, U_AXIS, V_AXIS, W_AXIS) // Extruder axes may be considered distinctly #define _EN_ITEM(N) , E##N##_AXIS @@ -110,12 +120,13 @@ enum AxisEnum : uint8_t { }; typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t; +typedef IF<(NUM_AXES > 8), uint16_t, uint8_t>::type linear_axis_bits_t; // // Loop over axes // #define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS) -#define LOOP_LINEAR_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LINEAR_AXES) +#define LOOP_NUM_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, NUM_AXES) #define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LOGICAL_AXES) #define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, DISTINCT_AXES) #define LOOP_DISTINCT_E(VAR) LOOP_L_N(VAR, DISTINCT_E) @@ -260,10 +271,10 @@ struct XYval { FI void set(const T px, const T py) { x = px; y = py; } FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } #endif - #if LINEAR_AXES > XY - FI void set(const T (&arr)[LINEAR_AXES]) { x = arr[0]; y = arr[1]; } + #if NUM_AXES > XY + FI void set(const T (&arr)[NUM_AXES]) { x = arr[0]; y = arr[1]; } #endif - #if LOGICAL_AXES > LINEAR_AXES + #if LOGICAL_AXES > NUM_AXES FI void set(const T (&arr)[LOGICAL_AXES]) { x = arr[0]; y = arr[1]; } #if DISTINCT_AXES > LOGICAL_AXES FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; } @@ -385,60 +396,69 @@ struct XYval { template struct XYZval { union { - struct { T LINEAR_AXIS_ARGS(); }; - struct { T LINEAR_AXIS_LIST(a, b, c, u, v, w); }; - T pos[LINEAR_AXES]; + struct { T NUM_AXIS_ARGS(); }; + struct { T NUM_AXIS_LIST(a, b, c, _i, _j, _k, _u, _v, _w); }; + T pos[NUM_AXES]; }; // Set all to 0 - FI void reset() { LINEAR_AXIS_GANG(x =, y =, z =, i =, j =, k =) 0; } + FI void reset() { NUM_AXIS_GANG(x =, y =, z =, i =, j =, k =, u =, v =, w =) 0; } // Setters taking struct types and arrays FI void set(const T px) { x = px; } FI void set(const T px, const T py) { x = px; y = py; } FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } - FI void set(const XYval pxy, const T pz) { LINEAR_AXIS_CODE(x = pxy.x, y = pxy.y, z = pz, NOOP, NOOP, NOOP); } + FI void set(const XYval pxy, const T pz) { NUM_AXIS_CODE(x = pxy.x, y = pxy.y, z = pz, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP); } FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } #if HAS_Z_AXIS - FI void set(const T (&arr)[LINEAR_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); } - FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k ); } + FI void set(const T (&arr)[NUM_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } + FI void set(NUM_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w ); } #endif - #if LOGICAL_AXES > LINEAR_AXES - FI void set(const T (&arr)[LOGICAL_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); } - FI void set(LOGICAL_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k ); } + #if LOGICAL_AXES > NUM_AXES + FI void set(const T (&arr)[LOGICAL_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } + FI void set(LOGICAL_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w ); } #if DISTINCT_AXES > LOGICAL_AXES - FI void set(const T (&arr)[DISTINCT_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); } + FI void set(const T (&arr)[DISTINCT_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } #endif #endif #if HAS_I_AXIS - FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } + FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } #endif #if HAS_J_AXIS - FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } + FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } #endif #if HAS_K_AXIS FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } #endif + #if HAS_U_AXIS + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; } + #endif + #if HAS_V_AXIS + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } + #endif + #if HAS_W_AXIS + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm, const T po) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; v = pv; } + #endif // Length reduced to one dimension - FI T magnitude() const { return (T)sqrtf(LINEAR_AXIS_GANG(x*x, + y*y, + z*z, + i*i, + j*j, + k*k)); } + FI T magnitude() const { return (T)sqrtf(NUM_AXIS_GANG(x*x, + y*y, + z*z, + i*i, + j*j, + k*k, + u*u, + v*v, + w*w)); } // Pointer to the data as a simple array FI operator T* () { return pos; } // If any element is true then it's true - FI operator bool() { return LINEAR_AXIS_GANG(x, || y, || z, || i, || j, || k); } + FI operator bool() { return NUM_AXIS_GANG(x, || y, || z, || i, || j, || k, || u, || v, || w); } // Explicit copy and copies with conversion FI XYZval copy() const { XYZval o = *this; return o; } - FI XYZval ABS() const { return LINEAR_AXIS_ARRAY(T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k))); } - FI XYZval asInt() { return LINEAR_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); } - FI XYZval asInt() const { return LINEAR_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); } - FI XYZval asLong() { return LINEAR_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); } - FI XYZval asLong() const { return LINEAR_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); } - FI XYZval ROUNDL() { return LINEAR_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); } - FI XYZval ROUNDL() const { return LINEAR_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); } - FI XYZval asFloat() { return LINEAR_AXIS_ARRAY(static_cast(x), static_cast(y), static_cast(z), static_cast(i), static_cast(j), static_cast(k)); } - FI XYZval asFloat() const { return LINEAR_AXIS_ARRAY(static_cast(x), static_cast(y), static_cast(z), static_cast(i), static_cast(j), static_cast(k)); } - FI XYZval reciprocal() const { return LINEAR_AXIS_ARRAY(_RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k)); } + FI XYZval ABS() const { return NUM_AXIS_ARRAY(T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k)), T(_ABS(u)), T(_ABS(v)), T(_ABS(w))); } + FI XYZval asInt() { return NUM_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k), int16_t(u), int16_t(v), int16_t(w)); } + FI XYZval asInt() const { return NUM_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k), int16_t(u), int16_t(v), int16_t(w)); } + FI XYZval asLong() { return NUM_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k), int32_t(u), int32_t(v), int32_t(w)); } + FI XYZval asLong() const { return NUM_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k), int32_t(u), int32_t(v), int32_t(w)); } + FI XYZval ROUNDL() { return NUM_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k)), int32_t(LROUND(u)), int32_t(LROUND(v)), int32_t(LROUND(w))); } + FI XYZval ROUNDL() const { return NUM_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k)), int32_t(LROUND(u)), int32_t(LROUND(v)), int32_t(LROUND(w))); } + FI XYZval asFloat() { return NUM_AXIS_ARRAY(static_cast(x), static_cast(y), static_cast(z), static_cast(i), static_cast(j), static_cast(k), static_cast(u), static_cast(v), static_cast(w)); } + FI XYZval asFloat() const { return NUM_AXIS_ARRAY(static_cast(x), static_cast(y), static_cast(z), static_cast(i), static_cast(j), static_cast(k), static_cast(u), static_cast(v), static_cast(w)); } + FI XYZval reciprocal() const { return NUM_AXIS_ARRAY(_RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k), _RECIP(u), _RECIP(v), _RECIP(w)); } // Marlin workspace shifting is done with G92 and M206 FI XYZval asLogical() const { XYZval o = asFloat(); toLogical(o); return o; } @@ -449,78 +469,78 @@ struct XYZval { FI operator const XYval&() const { return *(const XYval*)this; } // Cast to a type with more fields by making a new object - FI operator XYZEval() const { return LINEAR_AXIS_ARRAY(x, y, z, i, j, k); } + FI operator XYZEval() const { return NUM_AXIS_ARRAY(x, y, z, i, j, k, u, v, w); } // Accessor via an AxisEnum (or any integer) [index] FI T& operator[](const int n) { return pos[n]; } FI const T& operator[](const int n) const { return pos[n]; } // Assignment operator overrides do the expected thing - FI XYZval& operator= (const T v) { set(ARRAY_N_1(LINEAR_AXES, v)); return *this; } + FI XYZval& operator= (const T v) { set(ARRAY_N_1(NUM_AXES, v)); return *this; } FI XYZval& operator= (const XYval &rs) { set(rs.x, rs.y ); return *this; } - FI XYZval& operator= (const XYZEval &rs) { set(LINEAR_AXIS_ELEM(rs)); return *this; } + FI XYZval& operator= (const XYZEval &rs) { set(NUM_AXIS_ELEM(rs)); return *this; } // Override other operators to get intuitive behaviors - FI XYZval operator+ (const XYval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator+ (const XYval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator- (const XYval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator- (const XYval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator* (const XYval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator* (const XYval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator/ (const XYval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator/ (const XYval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator+ (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; } - FI XYZval operator+ (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; } - FI XYZval operator- (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; } - FI XYZval operator- (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; } - FI XYZval operator* (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; } - FI XYZval operator* (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; } - FI XYZval operator/ (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; } - FI XYZval operator/ (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; } - FI XYZval operator+ (const XYZEval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; } - FI XYZval operator+ (const XYZEval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; } - FI XYZval operator- (const XYZEval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; } - FI XYZval operator- (const XYZEval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; } - FI XYZval operator* (const XYZEval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; } - FI XYZval operator* (const XYZEval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; } - FI XYZval operator/ (const XYZEval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; } - FI XYZval operator/ (const XYZEval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; } - FI XYZval operator* (const float &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; } - FI XYZval operator* (const float &v) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; } - FI XYZval operator* (const int &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; } - FI XYZval operator* (const int &v) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; } - FI XYZval operator/ (const float &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; } - FI XYZval operator/ (const float &v) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; } - FI XYZval operator/ (const int &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; } - FI XYZval operator/ (const int &v) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; } - FI XYZval operator>>(const int &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; } - FI XYZval operator>>(const int &v) { XYZval ls = *this; LINEAR_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; } - FI XYZval operator<<(const int &v) const { XYZval ls = *this; LINEAR_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; } - FI XYZval operator<<(const int &v) { XYZval ls = *this; LINEAR_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; } - FI const XYZval operator-() const { XYZval o = *this; LINEAR_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k); return o; } - FI XYZval operator-() { XYZval o = *this; LINEAR_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k); return o; } + FI XYZval operator+ (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator+ (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator- (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator- (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator* (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator* (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator/ (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator/ (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator+ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZval operator+ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZval operator- (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZval operator- (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZval operator* (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZval operator* (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZval operator/ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZval operator/ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZval operator+ (const XYZEval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZval operator+ (const XYZEval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZval operator- (const XYZEval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZval operator- (const XYZEval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZval operator* (const XYZEval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZval operator* (const XYZEval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZval operator/ (const XYZEval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZval operator/ (const XYZEval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZval operator* (const float &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } + FI XYZval operator* (const float &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } + FI XYZval operator* (const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } + FI XYZval operator* (const int &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } + FI XYZval operator/ (const float &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } + FI XYZval operator/ (const float &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } + FI XYZval operator/ (const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } + FI XYZval operator/ (const int &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } + FI XYZval operator>>(const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZval operator>>(const int &v) { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZval operator<<(const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI XYZval operator<<(const int &v) { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI const XYZval operator-() const { XYZval o = *this; NUM_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k, o.u = -u, o.v = -v, o.w = -w); return o; } + FI XYZval operator-() { XYZval o = *this; NUM_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k, o.u = -u, o.v = -v, o.w = -w); return o; } // Modifier operators - FI XYZval& operator+=(const XYval &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; } - FI XYZval& operator-=(const XYval &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; } - FI XYZval& operator*=(const XYval &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; } - FI XYZval& operator/=(const XYval &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; } - FI XYZval& operator+=(const XYZval &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; } - FI XYZval& operator-=(const XYZval &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; } - FI XYZval& operator*=(const XYZval &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; } - FI XYZval& operator/=(const XYZval &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; } - FI XYZval& operator+=(const XYZEval &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; } - FI XYZval& operator-=(const XYZEval &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; } - FI XYZval& operator*=(const XYZEval &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; } - FI XYZval& operator/=(const XYZEval &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; } - FI XYZval& operator*=(const float &v) { LINEAR_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; } - FI XYZval& operator*=(const int &v) { LINEAR_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; } - FI XYZval& operator>>=(const int &v) { LINEAR_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k)); return *this; } - FI XYZval& operator<<=(const int &v) { LINEAR_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k)); return *this; } + FI XYZval& operator+=(const XYval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; } + FI XYZval& operator-=(const XYval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; } + FI XYZval& operator*=(const XYval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; } + FI XYZval& operator/=(const XYval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; } + FI XYZval& operator+=(const XYZval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } + FI XYZval& operator-=(const XYZval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } + FI XYZval& operator*=(const XYZval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } + FI XYZval& operator/=(const XYZval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } + FI XYZval& operator+=(const XYZEval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } + FI XYZval& operator-=(const XYZEval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } + FI XYZval& operator*=(const XYZEval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } + FI XYZval& operator/=(const XYZEval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } + FI XYZval& operator*=(const float &v) { NUM_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } + FI XYZval& operator*=(const int &v) { NUM_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } + FI XYZval& operator>>=(const int &v) { NUM_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } + FI XYZval& operator<<=(const int &v) { NUM_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYZEval &rs) { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); } - FI bool operator==(const XYZEval &rs) const { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); } + FI bool operator==(const XYZEval &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } + FI bool operator==(const XYZEval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } FI bool operator!=(const XYZEval &rs) { return !operator==(rs); } FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } }; @@ -532,56 +552,66 @@ template struct XYZEval { union { struct { T LOGICAL_AXIS_ARGS(); }; - struct { T LOGICAL_AXIS_LIST(_e, a, b, c, u, v, w); }; + struct { T LOGICAL_AXIS_LIST(_e, a, b, c, _i, _j, _k, _u, _v, _w); }; T pos[LOGICAL_AXES]; }; // Reset all to 0 - FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =) 0; } + FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =, u =, v =, w =) 0; } // Setters for some number of linear axes, not all - FI void set(const T px) { x = px; } - FI void set(const T px, const T py) { x = px; y = py; } + FI void set(const T px) { x = px; } + FI void set(const T px, const T py) { x = px; y = py; } #if HAS_I_AXIS - FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } + FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } #endif #if HAS_J_AXIS - FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } + FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } #endif #if HAS_K_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } #endif + #if HAS_U_AXIS + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; } + #endif + #if HAS_V_AXIS + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } + #endif + #if HAS_W_AXIS + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm, const T po) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pm; v = pv; } + #endif + // Setters taking struct types and arrays - FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } - FI void set(const XYZval pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); } + FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } + FI void set(const XYZval pxyz) { set(NUM_AXIS_ELEM(pxyz)); } #if HAS_Z_AXIS - FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k); } + FI void set(NUM_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); } #endif - FI void set(const XYval pxy, const T pz) { set(pxy); TERN_(HAS_Z_AXIS, z = pz); } - #if LOGICAL_AXES > LINEAR_AXES + FI void set(const XYval pxy, const T pz) { set(pxy); TERN_(HAS_Z_AXIS, z = pz); } + #if LOGICAL_AXES > NUM_AXES FI void set(const XYval pxy, const T pz, const T pe) { set(pxy, pz); e = pe; } - FI void set(const XYZval pxyz, const T pe) { set(pxyz); e = pe; } - FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, u = i, v = j, w = k); } + FI void set(const XYZval pxyz, const T pe) { set(pxyz); e = pe; } + FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); } #endif // Length reduced to one dimension - FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k)); } + FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k, + u*u, + v*v, + w*w)); } // Pointer to the data as a simple array FI operator T* () { return pos; } // If any element is true then it's true - FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k); } + FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); } // Explicit copy and copies with conversion - FI XYZEval copy() const { XYZEval o = *this; return o; } - FI XYZEval ABS() const { return LOGICAL_AXIS_ARRAY(T(_ABS(e)), T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k))); } - FI XYZEval asInt() { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); } - FI XYZEval asInt() const { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); } - FI XYZEval asLong() { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); } - FI XYZEval asLong() const { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); } - FI XYZEval ROUNDL() { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); } - FI XYZEval ROUNDL() const { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); } - FI XYZEval asFloat() { return LOGICAL_AXIS_ARRAY(static_cast(e), static_cast(x), static_cast(y), static_cast(z), static_cast(i), static_cast(j), static_cast(k)); } - FI XYZEval asFloat() const { return LOGICAL_AXIS_ARRAY(static_cast(e), static_cast(x), static_cast(y), static_cast(z), static_cast(i), static_cast(j), static_cast(k)); } - FI XYZEval reciprocal() const { return LOGICAL_AXIS_ARRAY(_RECIP(e), _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k)); } + FI XYZEval copy() const { XYZEval v = *this; return v; } + FI XYZEval ABS() const { return LOGICAL_AXIS_ARRAY(T(_ABS(e)), T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k)), T(_ABS(u)), T(_ABS(v)), T(_ABS(w))); } + FI XYZEval asInt() { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k), int16_t(u), int16_t(v), int16_t(w)); } + FI XYZEval asInt() const { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k), int16_t(u), int16_t(v), int16_t(w)); } + FI XYZEval asLong() { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k), int32_t(u), int32_t(v), int32_t(w)); } + FI XYZEval asLong() const { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k), int32_t(u), int32_t(v), int32_t(w)); } + FI XYZEval ROUNDL() { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k)), int32_t(LROUND(u)), int32_t(LROUND(v)), int32_t(LROUND(w))); } + FI XYZEval ROUNDL() const { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k)), int32_t(LROUND(u)), int32_t(LROUND(v)), int32_t(LROUND(w))); } + FI XYZEval asFloat() { return LOGICAL_AXIS_ARRAY(static_cast(e), static_cast(x), static_cast(y), static_cast(z), static_cast(i), static_cast(j), static_cast(k), static_cast(u), static_cast(v), static_cast(w)); } + FI XYZEval asFloat() const { return LOGICAL_AXIS_ARRAY(static_cast(e), static_cast(x), static_cast(y), static_cast(z), static_cast(i), static_cast(j), static_cast(k), static_cast(u), static_cast(v), static_cast(w)); } + FI XYZEval reciprocal() const { return LOGICAL_AXIS_ARRAY(_RECIP(e), _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k), _RECIP(u), _RECIP(v), _RECIP(w)); } // Marlin workspace shifting is done with G92 and M206 FI XYZEval asLogical() const { XYZEval o = asFloat(); toLogical(o); return o; } @@ -598,9 +628,9 @@ struct XYZEval { FI const T& operator[](const int n) const { return pos[n]; } // Assignment operator overrides do the expected thing - FI XYZEval& operator= (const T v) { set(LIST_N_1(LINEAR_AXES, v)); return *this; } + FI XYZEval& operator= (const T v) { set(LIST_N_1(NUM_AXES, v)); return *this; } FI XYZEval& operator= (const XYval &rs) { set(rs.x, rs.y); return *this; } - FI XYZEval& operator= (const XYZval &rs) { set(LINEAR_AXIS_ELEM(rs)); return *this; } + FI XYZEval& operator= (const XYZval &rs) { set(NUM_AXIS_ELEM(rs)); return *this; } // Override other operators to get intuitive behaviors FI XYZEval operator+ (const XYval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } @@ -611,57 +641,57 @@ struct XYZEval { FI XYZEval operator* (const XYval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } FI XYZEval operator/ (const XYval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } FI XYZEval operator/ (const XYval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEval operator+ (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; } - FI XYZEval operator+ (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; } - FI XYZEval operator- (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; } - FI XYZEval operator- (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; } - FI XYZEval operator* (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; } - FI XYZEval operator* (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; } - FI XYZEval operator/ (const XYZval &rs) const { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; } - FI XYZEval operator/ (const XYZval &rs) { XYZval ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; } - FI XYZEval operator+ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; } - FI XYZEval operator+ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; } - FI XYZEval operator- (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; } - FI XYZEval operator- (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; } - FI XYZEval operator* (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; } - FI XYZEval operator* (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; } - FI XYZEval operator/ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; } - FI XYZEval operator/ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; } - FI XYZEval operator* (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; } - FI XYZEval operator* (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; } - FI XYZEval operator* (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; } - FI XYZEval operator* (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; } - FI XYZEval operator/ (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; } - FI XYZEval operator/ (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; } - FI XYZEval operator/ (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; } - FI XYZEval operator/ (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; } - FI XYZEval operator>>(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; } - FI XYZEval operator>>(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; } - FI XYZEval operator<<(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; } - FI XYZEval operator<<(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; } - FI const XYZEval operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k); } - FI XYZEval operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k); } + FI XYZEval operator+ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator+ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator- (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator- (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator* (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator* (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator/ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator/ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator+ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator+ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator- (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator- (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator* (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator* (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator/ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator/ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator* (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } + FI XYZEval operator* (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } + FI XYZEval operator* (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } + FI XYZEval operator* (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } + FI XYZEval operator/ (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } + FI XYZEval operator/ (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } + FI XYZEval operator/ (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } + FI XYZEval operator/ (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } + FI XYZEval operator>>(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZEval operator>>(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZEval operator<<(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI XYZEval operator<<(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI const XYZEval operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } + FI XYZEval operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } // Modifier operators FI XYZEval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } FI XYZEval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } FI XYZEval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } FI XYZEval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } - FI XYZEval& operator+=(const XYZval &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; } - FI XYZEval& operator-=(const XYZval &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; } - FI XYZEval& operator*=(const XYZval &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; } - FI XYZEval& operator/=(const XYZval &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; } - FI XYZEval& operator+=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; } - FI XYZEval& operator-=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; } - FI XYZEval& operator*=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; } - FI XYZEval& operator/=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; } - FI XYZEval& operator*=(const T &v) { LOGICAL_AXIS_CODE(e *= v, x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; } - FI XYZEval& operator>>=(const int &v) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k)); return *this; } - FI XYZEval& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k)); return *this; } + FI XYZEval& operator+=(const XYZval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } + FI XYZEval& operator-=(const XYZval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } + FI XYZEval& operator*=(const XYZval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } + FI XYZEval& operator/=(const XYZval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } + FI XYZEval& operator+=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } + FI XYZEval& operator-=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } + FI XYZEval& operator*=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } + FI XYZEval& operator/=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } + FI XYZEval& operator*=(const T &v) { LOGICAL_AXIS_CODE(e *= v, x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } + FI XYZEval& operator>>=(const int &v) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } + FI XYZEval& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYZval &rs) { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); } - FI bool operator==(const XYZval &rs) const { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); } + FI bool operator==(const XYZval &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } + FI bool operator==(const XYZval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } FI bool operator!=(const XYZval &rs) { return !operator==(rs); } FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } }; diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 4e16e2693a..d30511ae40 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -125,7 +125,7 @@ void safe_delay(millis_t ms) { #endif #if ABL_PLANAR SERIAL_ECHOPGM("ABL Adjustment"); - LOOP_LINEAR_AXES(a) { + LOOP_NUM_AXES(a) { SERIAL_CHAR(' ', AXIS_CHAR(a)); serial_offset(planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]); } diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index d248091ce5..b845cd0412 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -77,10 +77,13 @@ public: // in the range 0-100 while avoiding rounding artifacts constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; } -const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME); - -#if LINEAR_AXES <= XYZ +// Axis names for G-code parsing, reports, etc. +const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME); +#if NUM_AXES <= XYZ #define AXIS_CHAR(A) ((char)('X' + A)) + #define IAXIS_CHAR AXIS_CHAR #else + const xyze_char_t iaxis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', 'I', 'J', 'K', 'U', 'V', 'W'); #define AXIS_CHAR(A) axis_codes[A] + #define IAXIS_CHAR(A) iaxis_codes[A] #endif diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index 84382cf856..876d28a8fe 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -97,7 +97,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const const float f_corr = float(correction) / all_on; - LOOP_LINEAR_AXES(axis) { + LOOP_NUM_AXES(axis) { if (distance_mm[axis]) { const bool reverse = TEST(dm, axis); @@ -145,7 +145,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const } int32_t Backlash::get_applied_steps(const AxisEnum axis) { - if (axis >= LINEAR_AXES) return 0; + if (axis >= NUM_AXES) return 0; const bool reverse = TEST(last_direction_bits, axis); @@ -165,11 +165,11 @@ class Backlash::StepAdjuster { xyz_long_t applied_steps; public: StepAdjuster() { - LOOP_LINEAR_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis); + LOOP_NUM_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis); } ~StepAdjuster() { // after backlash compensation parameter changes, ensure applied step count does not change - LOOP_LINEAR_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis]; + LOOP_NUM_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis]; } }; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 0d00296b5b..9d2aaf8247 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -317,6 +317,42 @@ void unified_bed_leveling::G29() { // Send 'N' to force homing before G29 (internal only) if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes(); TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true)); + + // Position bed horizontally and Z probe vertically. + #if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ + || defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \ + || defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W) + xyze_pos_t safe_position = current_position; + #ifdef SAFE_BED_LEVELING_START_X + safe_position.x = SAFE_BED_LEVELING_START_X; + #endif + #ifdef SAFE_BED_LEVELING_START_Y + safe_position.y = SAFE_BED_LEVELING_START_Y; + #endif + #ifdef SAFE_BED_LEVELING_START_Z + safe_position.z = SAFE_BED_LEVELING_START_Z; + #endif + #ifdef SAFE_BED_LEVELING_START_I + safe_position.i = SAFE_BED_LEVELING_START_I; + #endif + #ifdef SAFE_BED_LEVELING_START_J + safe_position.j = SAFE_BED_LEVELING_START_J; + #endif + #ifdef SAFE_BED_LEVELING_START_K + safe_position.k = SAFE_BED_LEVELING_START_K; + #endif + #ifdef SAFE_BED_LEVELING_START_U + safe_position.u = SAFE_BED_LEVELING_START_U; + #endif + #ifdef SAFE_BED_LEVELING_START_V + safe_position.v = SAFE_BED_LEVELING_START_V; + #endif + #ifdef SAFE_BED_LEVELING_START_W + safe_position.w = SAFE_BED_LEVELING_START_W; + #endif + + do_blocking_move_to(safe_position); + #endif } // Invalidate one or more nearby mesh points, possibly all. diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index fa14c9ac71..c1dbb906fd 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -337,7 +337,7 @@ bool I2CPositionEncoder::test_axis() { ec = false; xyze_pos_t startCoord, endCoord; - LOOP_LINEAR_AXES(a) { + LOOP_NUM_AXES(a) { startCoord[a] = planner.get_axis_position_mm((AxisEnum)a); endCoord[a] = planner.get_axis_position_mm((AxisEnum)a); } @@ -395,7 +395,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) { travelDistance = endDistance - startDistance; xyze_pos_t startCoord, endCoord; - LOOP_LINEAR_AXES(a) { + LOOP_NUM_AXES(a) { startCoord[a] = planner.get_axis_position_mm((AxisEnum)a); endCoord[a] = planner.get_axis_position_mm((AxisEnum)a); } diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index c68a2b8df9..daa642d32e 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -163,7 +163,7 @@ Joystick joystick; // norm_jog values of [-1 .. 1] maps linearly to [-feedrate .. feedrate] xyz_float_t move_dist{0}; float hypot2 = 0; - LOOP_LINEAR_AXES(i) if (norm_jog[i]) { + LOOP_NUM_AXES(i) if (norm_jog[i]) { move_dist[i] = seg_time * norm_jog[i] * TERN(EXTENSIBLE_UI, manual_feedrate_mm_s, planner.settings.max_feedrate_mm_s)[i]; hypot2 += sq(move_dist[i]); } diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 74008ed55a..0fc195e7dd 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -562,7 +562,7 @@ void PrintJobRecovery::resume() { TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset); TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift); #if HAS_HOME_OFFSET || HAS_POSITION_SHIFT - LOOP_LINEAR_AXES(i) update_workspace_offset((AxisEnum)i); + LOOP_NUM_AXES(i) update_workspace_offset((AxisEnum)i); #endif // Relative axis modes @@ -612,7 +612,7 @@ void PrintJobRecovery::resume() { #if HAS_HOME_OFFSET DEBUG_ECHOPGM("home_offset: "); - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { if (i) DEBUG_CHAR(','); DEBUG_DECIMAL(info.home_offset[i]); } @@ -621,7 +621,7 @@ void PrintJobRecovery::resume() { #if HAS_POSITION_SHIFT DEBUG_ECHOPGM("position_shift: "); - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { if (i) DEBUG_CHAR(','); DEBUG_DECIMAL(info.position_shift[i]); } diff --git a/Marlin/src/feature/stepper_driver_safety.cpp b/Marlin/src/feature/stepper_driver_safety.cpp index 11b90954b4..b8762da9b0 100644 --- a/Marlin/src/feature/stepper_driver_safety.cpp +++ b/Marlin/src/feature/stepper_driver_safety.cpp @@ -65,15 +65,18 @@ void stepper_driver_backward_check() { TEST_BACKWARD(I, 8); TEST_BACKWARD(J, 9); TEST_BACKWARD(K, 10); + TEST_BACKWARD(U, 11); + TEST_BACKWARD(V, 12); + TEST_BACKWARD(W, 13); - TEST_BACKWARD(E0, 11); - TEST_BACKWARD(E1, 12); - TEST_BACKWARD(E2, 13); - TEST_BACKWARD(E3, 14); - TEST_BACKWARD(E4, 15); - TEST_BACKWARD(E5, 16); - TEST_BACKWARD(E6, 17); - TEST_BACKWARD(E7, 18); + TEST_BACKWARD(E0, 14); + TEST_BACKWARD(E1, 15); + TEST_BACKWARD(E2, 16); + TEST_BACKWARD(E3, 17); + TEST_BACKWARD(E4, 18); + TEST_BACKWARD(E5, 19); + TEST_BACKWARD(E6, 20); + TEST_BACKWARD(E7, 21); if (!axis_plug_backward) WRITE(SAFE_POWER_PIN, HIGH); @@ -103,15 +106,18 @@ void stepper_driver_backward_report() { REPORT_BACKWARD(I, 8); REPORT_BACKWARD(J, 9); REPORT_BACKWARD(K, 10); + REPORT_BACKWARD(U, 11); + REPORT_BACKWARD(V, 12); + REPORT_BACKWARD(W, 13); - REPORT_BACKWARD(E0, 11); - REPORT_BACKWARD(E1, 12); - REPORT_BACKWARD(E2, 13); - REPORT_BACKWARD(E3, 14); - REPORT_BACKWARD(E4, 15); - REPORT_BACKWARD(E5, 16); - REPORT_BACKWARD(E6, 17); - REPORT_BACKWARD(E7, 18); + REPORT_BACKWARD(E0, 14); + REPORT_BACKWARD(E1, 15); + REPORT_BACKWARD(E2, 16); + REPORT_BACKWARD(E3, 17); + REPORT_BACKWARD(E4, 18); + REPORT_BACKWARD(E5, 19); + REPORT_BACKWARD(E6, 20); + REPORT_BACKWARD(E7, 21); } #endif // HAS_DRIVER_SAFE_POWER_PROTECT diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index c69772bebc..cb970c7ebc 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -429,6 +429,18 @@ if (monitor_tmc_driver(stepperK, need_update_error_counters, need_debug_reporting)) step_current_down(stepperK); #endif + #if AXIS_IS_TMC(U) + if (monitor_tmc_driver(stepperU, need_update_error_counters, need_debug_reporting)) + step_current_down(stepperU); + #endif + #if AXIS_IS_TMC(V) + if (monitor_tmc_driver(stepperV, need_update_error_counters, need_debug_reporting)) + step_current_down(stepperV); + #endif + #if AXIS_IS_TMC(W) + if (monitor_tmc_driver(stepperW, need_update_error_counters, need_debug_reporting)) + step_current_down(stepperW); + #endif #if AXIS_IS_TMC(E0) (void)monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting); @@ -809,6 +821,15 @@ #if AXIS_IS_TMC(K) if (k) tmc_status(stepperK, n); #endif + #if AXIS_IS_TMC(U) + if (u) tmc_status(stepperU, n); + #endif + #if AXIS_IS_TMC(V) + if (v) tmc_status(stepperV, n); + #endif + #if AXIS_IS_TMC(W) + if (w) tmc_status(stepperW, n); + #endif if (TERN0(HAS_EXTRUDERS, e)) { #if AXIS_IS_TMC(E0) @@ -883,6 +904,15 @@ #if AXIS_IS_TMC(K) if (k) tmc_parse_drv_status(stepperK, n); #endif + #if AXIS_IS_TMC(U) + if (u) tmc_parse_drv_status(stepperU, n); + #endif + #if AXIS_IS_TMC(V) + if (v) tmc_parse_drv_status(stepperV, n); + #endif + #if AXIS_IS_TMC(W) + if (w) tmc_parse_drv_status(stepperW, n); + #endif if (TERN0(HAS_EXTRUDERS, e)) { #if AXIS_IS_TMC(E0) @@ -1088,6 +1118,15 @@ #if AXIS_IS_TMC(K) if (k) tmc_get_registers(stepperK, n); #endif + #if AXIS_IS_TMC(U) + if (u) tmc_get_registers(stepperU, n); + #endif + #if AXIS_IS_TMC(V) + if (v) tmc_get_registers(stepperV, n); + #endif + #if AXIS_IS_TMC(W) + if (w) tmc_get_registers(stepperW, n); + #endif if (TERN0(HAS_EXTRUDERS, e)) { #if AXIS_IS_TMC(E0) @@ -1244,6 +1283,15 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) { #if AXIS_IS_TMC(K) if (k) axis_connection += test_connection(stepperK); #endif + #if AXIS_IS_TMC(U) + if (u) axis_connection += test_connection(stepperU); + #endif + #if AXIS_IS_TMC(V) + if (v) axis_connection += test_connection(stepperV); + #endif + #if AXIS_IS_TMC(W) + if (w) axis_connection += test_connection(stepperW); + #endif if (TERN0(HAS_EXTRUDERS, e)) { #if AXIS_IS_TMC(E0) @@ -1313,6 +1361,15 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) { #if AXIS_HAS_SPI(K) SET_CS_PIN(K); #endif + #if AXIS_HAS_SPI(U) + SET_CS_PIN(U); + #endif + #if AXIS_HAS_SPI(V) + SET_CS_PIN(V); + #endif + #if AXIS_HAS_SPI(W) + SET_CS_PIN(W); + #endif #if AXIS_HAS_SPI(E0) SET_CS_PIN(E0); #endif diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index fc333b09dd..c10bab6274 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -348,7 +348,7 @@ void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true)); #if USE_SENSORLESS // Track enabled status of stealthChop and only re-enable where applicable - struct sensorless_t { bool LINEAR_AXIS_ARGS(), x2, y2, z2, z3, z4; }; + struct sensorless_t { bool NUM_AXIS_ARGS(), x2, y2, z2, z3, z4; }; #if ENABLED(IMPROVE_HOMING_RELIABILITY) extern millis_t sg_guard_period; diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 61848c45bd..ac8eff0e95 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -437,6 +437,42 @@ G29_TYPE GcodeSuite::G29() { #endif } + // Position bed horizontally and Z probe vertically. + #if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ + || defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \ + || defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W) + xyze_pos_t safe_position = current_position; + #ifdef SAFE_BED_LEVELING_START_X + safe_position.x = SAFE_BED_LEVELING_START_X; + #endif + #ifdef SAFE_BED_LEVELING_START_Y + safe_position.y = SAFE_BED_LEVELING_START_Y; + #endif + #ifdef SAFE_BED_LEVELING_START_Z + safe_position.z = SAFE_BED_LEVELING_START_Z; + #endif + #ifdef SAFE_BED_LEVELING_START_I + safe_position.i = SAFE_BED_LEVELING_START_I; + #endif + #ifdef SAFE_BED_LEVELING_START_J + safe_position.j = SAFE_BED_LEVELING_START_J; + #endif + #ifdef SAFE_BED_LEVELING_START_K + safe_position.k = SAFE_BED_LEVELING_START_K; + #endif + #ifdef SAFE_BED_LEVELING_START_U + safe_position.u = SAFE_BED_LEVELING_START_U; + #endif + #ifdef SAFE_BED_LEVELING_START_V + safe_position.v = SAFE_BED_LEVELING_START_V; + #endif + #ifdef SAFE_BED_LEVELING_START_W + safe_position.w = SAFE_BED_LEVELING_START_W; + #endif + + do_blocking_move_to(safe_position); + #endif + // Disable auto bed leveling during G29. // Be formal so G29 can be done successively without G28. if (!no_action) set_bed_leveling_enabled(false); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 74843235f4..e04073b122 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -106,6 +106,43 @@ void GcodeSuite::G29() { queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2")); TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); + + // Position bed horizontally and Z probe vertically. + #if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ + || defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \ + || defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W) + xyze_pos_t safe_position = current_position; + #ifdef SAFE_BED_LEVELING_START_X + safe_position.x = SAFE_BED_LEVELING_START_X; + #endif + #ifdef SAFE_BED_LEVELING_START_Y + safe_position.y = SAFE_BED_LEVELING_START_Y; + #endif + #ifdef SAFE_BED_LEVELING_START_Z + safe_position.z = SAFE_BED_LEVELING_START_Z; + #endif + #ifdef SAFE_BED_LEVELING_START_I + safe_position.i = SAFE_BED_LEVELING_START_I; + #endif + #ifdef SAFE_BED_LEVELING_START_J + safe_position.j = SAFE_BED_LEVELING_START_J; + #endif + #ifdef SAFE_BED_LEVELING_START_K + safe_position.k = SAFE_BED_LEVELING_START_K; + #endif + #ifdef SAFE_BED_LEVELING_START_U + safe_position.u = SAFE_BED_LEVELING_START_U; + #endif + #ifdef SAFE_BED_LEVELING_START_V + safe_position.v = SAFE_BED_LEVELING_START_V; + #endif + #ifdef SAFE_BED_LEVELING_START_W + safe_position.w = SAFE_BED_LEVELING_START_W; + #endif + + do_blocking_move_to(safe_position); + #endif + return; } state = MeshNext; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 681df55f20..07896856a1 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -82,7 +82,7 @@ #if ENABLED(SENSORLESS_HOMING) sensorless_t stealth_states { - LINEAR_AXIS_LIST( + NUM_AXIS_LIST( TERN0(X_SENSORLESS, tmc_enable_stallguard(stepperX)), TERN0(Y_SENSORLESS, tmc_enable_stallguard(stepperY)), false, false, false, false @@ -214,7 +214,7 @@ void GcodeSuite::G28() { #if ENABLED(MARLIN_DEV_MODE) if (parser.seen_test('S')) { - LOOP_LINEAR_AXES(a) set_axis_is_at_home((AxisEnum)a); + LOOP_NUM_AXES(a) set_axis_is_at_home((AxisEnum)a); sync_plan_position(); SERIAL_ECHOLNPGM("Simulated Homing"); report_current_position(); @@ -258,7 +258,7 @@ void GcodeSuite::G28() { reset_stepper_timeout(); #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) + #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) || HAS_CURRENT_HOME(U) || HAS_CURRENT_HOME(V) || HAS_CURRENT_HOME(W) #define HAS_HOMING_CURRENT 1 #endif @@ -286,21 +286,6 @@ void GcodeSuite::G28() { stepperY2.rms_current(Y2_CURRENT_HOME); if (DEBUGGING(LEVELING)) debug_current(F(STR_Y2), tmc_save_current_Y2, Y2_CURRENT_HOME); #endif - #if HAS_CURRENT_HOME(I) - const int16_t tmc_save_current_I = stepperI.getMilliamps(); - stepperI.rms_current(I_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_I), tmc_save_current_I, I_CURRENT_HOME); - #endif - #if HAS_CURRENT_HOME(J) - const int16_t tmc_save_current_J = stepperJ.getMilliamps(); - stepperJ.rms_current(J_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_J), tmc_save_current_J, J_CURRENT_HOME); - #endif - #if HAS_CURRENT_HOME(K) - const int16_t tmc_save_current_K = stepperK.getMilliamps(); - stepperK.rms_current(K_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(STR_K), tmc_save_current_K, K_CURRENT_HOME); - #endif #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) const int16_t tmc_save_current_Z = stepperZ.getMilliamps(); stepperZ.rms_current(Z_CURRENT_HOME); @@ -321,6 +306,21 @@ void GcodeSuite::G28() { stepperK.rms_current(K_CURRENT_HOME); if (DEBUGGING(LEVELING)) debug_current(F(STR_K), tmc_save_current_K, K_CURRENT_HOME); #endif + #if HAS_CURRENT_HOME(U) + const int16_t tmc_save_current_U = stepperU.getMilliamps(); + stepperU.rms_current(U_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_U), tmc_save_current_U, U_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(V) + const int16_t tmc_save_current_V = stepperV.getMilliamps(); + stepperV.rms_current(V_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_V), tmc_save_current_V, V_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(W) + const int16_t tmc_save_current_W = stepperW.getMilliamps(); + stepperW.rms_current(W_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_W), tmc_save_current_W, W_CURRENT_HOME); + #endif #endif #if ENABLED(IMPROVE_HOMING_RELIABILITY) @@ -364,23 +364,28 @@ void GcodeSuite::G28() { #define _UNSAFE(A) (homeZ && TERN0(Z_SAFE_HOMING, axes_should_home(_BV(A##_AXIS)))) const bool homeZ = TERN0(HAS_Z_AXIS, parser.seen_test('Z')), - LINEAR_AXIS_LIST( // Other axes should be homed before Z safe-homing + NUM_AXIS_LIST( // Other axes should be homed before Z safe-homing needX = _UNSAFE(X), needY = _UNSAFE(Y), needZ = false, // UNUSED - needI = _UNSAFE(I), needJ = _UNSAFE(J), needK = _UNSAFE(K) + needI = _UNSAFE(I), needJ = _UNSAFE(J), needK = _UNSAFE(K), + needU = _UNSAFE(U), needV = _UNSAFE(V), needW = _UNSAFE(W) ), - LINEAR_AXIS_LIST( // Home each axis if needed or flagged + NUM_AXIS_LIST( // Home each axis if needed or flagged homeX = needX || parser.seen_test('X'), homeY = needY || parser.seen_test('Y'), homeZZ = homeZ, - homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), homeK = needK || parser.seen_test(AXIS6_NAME) + homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), + homeK = needK || parser.seen_test(AXIS6_NAME), homeU = needU || parser.seen_test(AXIS7_NAME), + homeV = needV || parser.seen_test(AXIS8_NAME), homeW = needW || parser.seen_test(AXIS9_NAME), ), - home_all = LINEAR_AXIS_GANG( // Home-all if all or none are flagged + home_all = NUM_AXIS_GANG( // Home-all if all or none are flagged homeX == homeX, && homeY == homeX, && homeZ == homeX, - && homeI == homeX, && homeJ == homeX, && homeK == homeX + && homeI == homeX, && homeJ == homeX, && homeK == homeX, + && homeU == homeX, && homeV == homeX, && homeW == homeX ), - LINEAR_AXIS_LIST( + NUM_AXIS_LIST( doX = home_all || homeX, doY = home_all || homeY, doZ = home_all || homeZ, - doI = home_all || homeI, doJ = home_all || homeJ, doK = home_all || homeK + doI = home_all || homeI, doJ = home_all || homeJ, doK = home_all || homeK, + doU = home_all || homeU, doV = home_all || homeV, doW = home_all || homeW ); #if HAS_Z_AXIS @@ -394,7 +399,7 @@ void GcodeSuite::G28() { const bool seenR = parser.seenval('R'); const float z_homing_height = seenR ? parser.value_linear_units() : Z_HOMING_HEIGHT; - if (z_homing_height && (seenR || LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { + if (z_homing_height && (seenR || NUM_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK, || doU, || doV, || doW))) { // Raise Z before homing any other axes and z is not already high enough (never lower z) if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Raise Z (before homing) by ", z_homing_height); do_z_clearance(z_homing_height); @@ -434,32 +439,52 @@ void GcodeSuite::G28() { #endif } + #if BOTH(FOAMCUTTER_XYUV, HAS_I_AXIS) + // Home I (after X) + if (doI) homeaxis(I_AXIS); + #endif + // Home Y (after X) if (DISABLED(HOME_Y_BEFORE_X) && doY) homeaxis(Y_AXIS); - TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state)); - - // Home Z last if homing towards the bed - #if HAS_Z_AXIS && DISABLED(HOME_Z_FIRST) - if (doZ) { - #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) - stepper.set_all_z_lock(false); - stepper.set_separate_multi_axis(false); - #endif - - #if ENABLED(Z_SAFE_HOMING) - if (TERN1(POWER_LOSS_RECOVERY, !parser.seen_test('H'))) home_z_safely(); else homeaxis(Z_AXIS); - #else - homeaxis(Z_AXIS); - #endif - probe.move_z_after_homing(); - } + #if BOTH(FOAMCUTTER_XYUV, HAS_J_AXIS) + // Home J (after Y) + if (doJ) homeaxis(J_AXIS); #endif - TERN_(HAS_I_AXIS, if (doI) homeaxis(I_AXIS)); - TERN_(HAS_J_AXIS, if (doJ) homeaxis(J_AXIS)); - TERN_(HAS_K_AXIS, if (doK) homeaxis(K_AXIS)); + TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(saved_motion_state)); + + #if ENABLED(FOAMCUTTER_XYUV) + // skip homing of unused Z axis for foamcutters + if (doZ) set_axis_is_at_home(Z_AXIS); + #else + // Home Z last if homing towards the bed + #if HAS_Z_AXIS && DISABLED(HOME_Z_FIRST) + if (doZ) { + #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) + stepper.set_all_z_lock(false); + stepper.set_separate_multi_axis(false); + #endif + + #if ENABLED(Z_SAFE_HOMING) + if (TERN1(POWER_LOSS_RECOVERY, !parser.seen_test('H'))) home_z_safely(); else homeaxis(Z_AXIS); + #else + homeaxis(Z_AXIS); + #endif + probe.move_z_after_homing(); + } + #endif + + SECONDARY_AXIS_CODE( + if (doI) homeaxis(I_AXIS), + if (doJ) homeaxis(J_AXIS), + if (doK) homeaxis(K_AXIS), + if (doU) homeaxis(U_AXIS), + if (doV) homeaxis(V_AXIS), + if (doW) homeaxis(W_AXIS) + ); + #endif sync_plan_position(); @@ -542,6 +567,15 @@ void GcodeSuite::G28() { #if HAS_CURRENT_HOME(K) stepperK.rms_current(tmc_save_current_K); #endif + #if HAS_CURRENT_HOME(U) + stepperU.rms_current(tmc_save_current_U); + #endif + #if HAS_CURRENT_HOME(V) + stepperV.rms_current(tmc_save_current_V); + #endif + #if HAS_CURRENT_HOME(W) + stepperW.rms_current(tmc_save_current_W); + #endif #endif // HAS_HOMING_CURRENT ui.refresh(); @@ -562,7 +596,7 @@ void GcodeSuite::G28() { // If not, this will need a PROGMEM directive and an accessor. #define _EN_ITEM(N) , E_AXIS static constexpr AxisEnum L64XX_axis_xref[MAX_L64XX] = { - LINEAR_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS), + NUM_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS, U_AXIS, V_AXIS, W_AXIS), X_AXIS, Y_AXIS, Z_AXIS, Z_AXIS, Z_AXIS REPEAT(E_STEPPERS, _EN_ITEM) }; diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index 506f367947..7f487abd6b 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -343,7 +343,7 @@ static float auto_tune_a(const float dcr) { abc_float_t delta_e = { 0.0f }, delta_t = { 0.0f }; delta_t.reset(); - LOOP_LINEAR_AXES(axis) { + LOOP_NUM_AXES(axis) { delta_t[axis] = diff; calc_kinematics_diff_probe_points(z_pt, dcr, delta_e, delta_r, delta_t); delta_t[axis] = 0; @@ -536,7 +536,7 @@ void GcodeSuite::G33() { case 1: test_precision = 0.0f; // forced end - LOOP_LINEAR_AXES(axis) e_delta[axis] = +Z4(CEN); + LOOP_NUM_AXES(axis) e_delta[axis] = +Z4(CEN); break; case 2: @@ -584,14 +584,14 @@ void GcodeSuite::G33() { // Normalize angles to least-squares if (_angle_results) { float a_sum = 0.0f; - LOOP_LINEAR_AXES(axis) a_sum += delta_tower_angle_trim[axis]; - LOOP_LINEAR_AXES(axis) delta_tower_angle_trim[axis] -= a_sum / 3.0f; + LOOP_NUM_AXES(axis) a_sum += delta_tower_angle_trim[axis]; + LOOP_NUM_AXES(axis) delta_tower_angle_trim[axis] -= a_sum / 3.0f; } // adjust delta_height and endstops by the max amount const float z_temp = _MAX(delta_endstop_adj.a, delta_endstop_adj.b, delta_endstop_adj.c); delta_height -= z_temp; - LOOP_LINEAR_AXES(axis) delta_endstop_adj[axis] -= z_temp; + LOOP_NUM_AXES(axis) delta_endstop_adj[axis] -= z_temp; } recalc_delta_settings(); NOMORE(zero_std_dev_min, zero_std_dev); diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index a2dec64bc3..450a715117 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -85,10 +85,19 @@ #if ALL(HAS_K_AXIS, CALIBRATION_MEASURE_KMIN, CALIBRATION_MEASURE_KMAX) #define HAS_K_CENTER 1 #endif +#if ALL(HAS_U_AXIS, CALIBRATION_MEASURE_UMIN, CALIBRATION_MEASURE_UMAX) + #define HAS_U_CENTER 1 +#endif +#if ALL(HAS_V_AXIS, CALIBRATION_MEASURE_VMIN, CALIBRATION_MEASURE_VMAX) + #define HAS_V_CENTER 1 +#endif +#if ALL(HAS_W_AXIS, CALIBRATION_MEASURE_WMIN, CALIBRATION_MEASURE_WMAX) + #define HAS_W_CENTER 1 +#endif enum side_t : uint8_t { TOP, RIGHT, FRONT, LEFT, BACK, NUM_SIDES, - LIST_N(DOUBLE(SUB3(LINEAR_AXES)), IMINIMUM, IMAXIMUM, JMINIMUM, JMAXIMUM, KMINIMUM, KMAXIMUM) + LIST_N(DOUBLE(SECONDARY_AXES), IMINIMUM, IMAXIMUM, JMINIMUM, JMAXIMUM, KMINIMUM, KMAXIMUM, UMINIMUM, UMAXIMUM, VMINIMUM, VMAXIMUM, WMINIMUM, WMAXIMUM) }; static constexpr xyz_pos_t true_center CALIBRATION_OBJECT_CENTER; @@ -282,6 +291,15 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t #if HAS_K_AXIS && AXIS_CAN_CALIBRATE(K) _PCASE(K); #endif + #if HAS_U_AXIS && AXIS_CAN_CALIBRATE(U) + _PCASE(U); + #endif + #if HAS_V_AXIS && AXIS_CAN_CALIBRATE(V) + _PCASE(V); + #endif + #if HAS_W_AXIS && AXIS_CAN_CALIBRATE(W) + _PCASE(W); + #endif default: return; } @@ -335,6 +353,12 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { TERN_(CALIBRATION_MEASURE_JMAX, probe_side(m, uncertainty, JMAXIMUM, probe_top_at_edge)); TERN_(CALIBRATION_MEASURE_KMIN, probe_side(m, uncertainty, KMINIMUM, probe_top_at_edge)); TERN_(CALIBRATION_MEASURE_KMAX, probe_side(m, uncertainty, KMAXIMUM, probe_top_at_edge)); + TERN_(CALIBRATION_MEASURE_UMIN, probe_side(m, uncertainty, UMINIMUM, probe_top_at_edge)); + TERN_(CALIBRATION_MEASURE_UMAX, probe_side(m, uncertainty, UMAXIMUM, probe_top_at_edge)); + TERN_(CALIBRATION_MEASURE_VMIN, probe_side(m, uncertainty, VMINIMUM, probe_top_at_edge)); + TERN_(CALIBRATION_MEASURE_VMAX, probe_side(m, uncertainty, VMAXIMUM, probe_top_at_edge)); + TERN_(CALIBRATION_MEASURE_WMIN, probe_side(m, uncertainty, WMINIMUM, probe_top_at_edge)); + TERN_(CALIBRATION_MEASURE_WMAX, probe_side(m, uncertainty, WMAXIMUM, probe_top_at_edge)); // Compute the measured center of the calibration object. TERN_(HAS_X_CENTER, m.obj_center.x = (m.obj_side[LEFT] + m.obj_side[RIGHT]) / 2); @@ -342,6 +366,9 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { TERN_(HAS_I_CENTER, m.obj_center.i = (m.obj_side[IMINIMUM] + m.obj_side[IMAXIMUM]) / 2); TERN_(HAS_J_CENTER, m.obj_center.j = (m.obj_side[JMINIMUM] + m.obj_side[JMAXIMUM]) / 2); TERN_(HAS_K_CENTER, m.obj_center.k = (m.obj_side[KMINIMUM] + m.obj_side[KMAXIMUM]) / 2); + TERN_(HAS_U_CENTER, m.obj_center.u = (m.obj_side[UMINIMUM] + m.obj_side[UMAXIMUM]) / 2); + TERN_(HAS_V_CENTER, m.obj_center.v = (m.obj_side[VMINIMUM] + m.obj_side[VMAXIMUM]) / 2); + TERN_(HAS_W_CENTER, m.obj_center.w = (m.obj_side[WMINIMUM] + m.obj_side[WMAXIMUM]) / 2); // Compute the outside diameter of the nozzle at the height // at which it makes contact with the calibration object @@ -352,13 +379,16 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { // The difference between the known and the measured location // of the calibration object is the positional error - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( m.pos_error.x = TERN0(HAS_X_CENTER, true_center.x - m.obj_center.x), m.pos_error.y = TERN0(HAS_Y_CENTER, true_center.y - m.obj_center.y), m.pos_error.z = true_center.z - m.obj_center.z, m.pos_error.i = TERN0(HAS_I_CENTER, true_center.i - m.obj_center.i), m.pos_error.j = TERN0(HAS_J_CENTER, true_center.j - m.obj_center.j), - m.pos_error.k = TERN0(HAS_K_CENTER, true_center.k - m.obj_center.k) + m.pos_error.k = TERN0(HAS_K_CENTER, true_center.k - m.obj_center.k), + m.pos_error.u = TERN0(HAS_U_CENTER, true_center.u - m.obj_center.u), + m.pos_error.v = TERN0(HAS_V_CENTER, true_center.v - m.obj_center.v), + m.pos_error.w = TERN0(HAS_W_CENTER, true_center.w - m.obj_center.w) ); } @@ -406,6 +436,30 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_K_MAX ": ", m.obj_side[KMAXIMUM]); #endif #endif + #if HAS_U_AXIS + #if ENABLED(CALIBRATION_MEASURE_UMIN) + SERIAL_ECHOLNPAIR(" " STR_U_MIN ": ", m.obj_side[UMINIMUM]); + #endif + #if ENABLED(CALIBRATION_MEASURE_UMAX) + SERIAL_ECHOLNPAIR(" " STR_U_MAX ": ", m.obj_side[UMAXIMUM]); + #endif + #endif + #if HAS_V_AXIS + #if ENABLED(CALIBRATION_MEASURE_VMIN) + SERIAL_ECHOLNPAIR(" " STR_V_MIN ": ", m.obj_side[VMINIMUM]); + #endif + #if ENABLED(CALIBRATION_MEASURE_VMAX) + SERIAL_ECHOLNPAIR(" " STR_V_MAX ": ", m.obj_side[VMAXIMUM]); + #endif + #endif + #if HAS_W_AXIS + #if ENABLED(CALIBRATION_MEASURE_WMIN) + SERIAL_ECHOLNPAIR(" " STR_W_MIN ": ", m.obj_side[WMINIMUM]); + #endif + #if ENABLED(CALIBRATION_MEASURE_WMAX) + SERIAL_ECHOLNPAIR(" " STR_W_MAX ": ", m.obj_side[WMAXIMUM]); + #endif + #endif SERIAL_EOL(); } @@ -427,6 +481,15 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { #if HAS_K_CENTER SERIAL_ECHOLNPGM_P(SP_K_STR, m.obj_center.k); #endif + #if HAS_U_CENTER + SERIAL_ECHOLNPGM_P(SP_U_STR, m.obj_center.u); + #endif + #if HAS_V_CENTER + SERIAL_ECHOLNPGM_P(SP_V_STR, m.obj_center.v); + #endif + #if HAS_W_CENTER + SERIAL_ECHOLNPGM_P(SP_W_STR, m.obj_center.w); + #endif SERIAL_EOL(); } @@ -475,6 +538,30 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_K_MAX ": ", m.backlash[KMAXIMUM]); #endif #endif + #if HAS_U_AXIS && AXIS_CAN_CALIBRATE(U) + #if ENABLED(CALIBRATION_MEASURE_UMIN) + SERIAL_ECHOLNPGM(" " STR_U_MIN ": ", m.backlash[UMINIMUM]); + #endif + #if ENABLED(CALIBRATION_MEASURE_UMAX) + SERIAL_ECHOLNPGM(" " STR_U_MAX ": ", m.backlash[UMAXIMUM]); + #endif + #endif + #if HAS_V_AXIS && AXIS_CAN_CALIBRATE(V) + #if ENABLED(CALIBRATION_MEASURE_VMIN) + SERIAL_ECHOLNPGM(" " STR_V_MIN ": ", m.backlash[VMINIMUM]); + #endif + #if ENABLED(CALIBRATION_MEASURE_VMAX) + SERIAL_ECHOLNPGM(" " STR_V_MAX ": ", m.backlash[VMAXIMUM]); + #endif + #endif + #if HAS_W_AXIS && AXIS_CAN_CALIBRATE(W) + #if ENABLED(CALIBRATION_MEASURE_WMIN) + SERIAL_ECHOLNPGM(" " STR_W_MIN ": ", m.backlash[WMINIMUM]); + #endif + #if ENABLED(CALIBRATION_MEASURE_WMAX) + SERIAL_ECHOLNPGM(" " STR_W_MAX ": ", m.backlash[WMAXIMUM]); + #endif + #endif SERIAL_EOL(); } @@ -498,7 +585,16 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM_P(SP_J_STR, m.pos_error.j); #endif #if HAS_K_CENTER && AXIS_CAN_CALIBRATE(K) - SERIAL_ECHOLNPGM_P(SP_Z_STR, m.pos_error.z); + SERIAL_ECHOLNPGM_P(SP_K_STR, m.pos_error.k); + #endif + #if HAS_U_CENTER && AXIS_CAN_CALIBRATE(U) + SERIAL_ECHOLNPGM_P(SP_U_STR, m.pos_error.u); + #endif + #if HAS_V_CENTER && AXIS_CAN_CALIBRATE(V) + SERIAL_ECHOLNPGM_P(SP_V_STR, m.pos_error.v); + #endif + #if HAS_W_CENTER && AXIS_CAN_CALIBRATE(W) + SERIAL_ECHOLNPGM_P(SP_W_STR, m.pos_error.w); #endif SERIAL_EOL(); } @@ -587,6 +683,30 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { backlash.set_distance_mm(K_AXIS, m.backlash[KMAXIMUM]); #endif + #if HAS_U_CENTER + backlash.distance_mm.u = (m.backlash[UMINIMUM] + m.backlash[UMAXIMUM]) / 2; + #elif ENABLED(CALIBRATION_MEASURE_UMIN) + backlash.distance_mm.u = m.backlash[UMINIMUM]; + #elif ENABLED(CALIBRATION_MEASURE_UMAX) + backlash.distance_mm.u = m.backlash[UMAXIMUM]; + #endif + + #if HAS_V_CENTER + backlash.distance_mm.v = (m.backlash[VMINIMUM] + m.backlash[VMAXIMUM]) / 2; + #elif ENABLED(CALIBRATION_MEASURE_VMIN) + backlash.distance_mm.v = m.backlash[VMINIMUM]; + #elif ENABLED(CALIBRATION_MEASURE_UMAX) + backlash.distance_mm.v = m.backlash[VMAXIMUM]; + #endif + + #if HAS_W_CENTER + backlash.distance_mm.w = (m.backlash[WMINIMUM] + m.backlash[WMAXIMUM]) / 2; + #elif ENABLED(CALIBRATION_MEASURE_WMIN) + backlash.distance_mm.w = m.backlash[WMINIMUM]; + #elif ENABLED(CALIBRATION_MEASURE_WMAX) + backlash.distance_mm.w = m.backlash[WMAXIMUM]; + #endif + #endif // BACKLASH_GCODE } @@ -597,9 +717,10 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { // New scope for TEMPORARY_BACKLASH_CORRECTION TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); - const xyz_float_t move = LINEAR_AXIS_ARRAY( + const xyz_float_t move = NUM_AXIS_ARRAY( AXIS_CAN_CALIBRATE(X) * 3, AXIS_CAN_CALIBRATE(Y) * 3, AXIS_CAN_CALIBRATE(Z) * 3, - AXIS_CAN_CALIBRATE(I) * 3, AXIS_CAN_CALIBRATE(J) * 3, AXIS_CAN_CALIBRATE(K) * 3 + AXIS_CAN_CALIBRATE(I) * 3, AXIS_CAN_CALIBRATE(J) * 3, AXIS_CAN_CALIBRATE(K) * 3, + AXIS_CAN_CALIBRATE(U) * 3, AXIS_CAN_CALIBRATE(V) * 3, AXIS_CAN_CALIBRATE(W) * 3 ); current_position += move; calibration_move(); current_position -= move; calibration_move(); @@ -650,6 +771,9 @@ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const TERN_(HAS_I_CENTER, update_measurements(m, I_AXIS)); TERN_(HAS_J_CENTER, update_measurements(m, J_AXIS)); TERN_(HAS_K_CENTER, update_measurements(m, K_AXIS)); + TERN_(HAS_U_CENTER, update_measurements(m, U_AXIS)); + TERN_(HAS_V_CENTER, update_measurements(m, V_AXIS)); + TERN_(HAS_W_CENTER, update_measurements(m, W_AXIS)); sync_plan_position(); } diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index 6b1f56fcf6..bfceefdbe2 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -49,21 +49,24 @@ void GcodeSuite::M425() { auto axis_can_calibrate = [](const uint8_t a) { switch (a) { default: return false; - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( case X_AXIS: return AXIS_CAN_CALIBRATE(X), case Y_AXIS: return AXIS_CAN_CALIBRATE(Y), case Z_AXIS: return AXIS_CAN_CALIBRATE(Z), case I_AXIS: return AXIS_CAN_CALIBRATE(I), case J_AXIS: return AXIS_CAN_CALIBRATE(J), - case K_AXIS: return AXIS_CAN_CALIBRATE(K) + case K_AXIS: return AXIS_CAN_CALIBRATE(K), + case U_AXIS: return AXIS_CAN_CALIBRATE(U), + case V_AXIS: return AXIS_CAN_CALIBRATE(V), + case W_AXIS: return AXIS_CAN_CALIBRATE(W) ); } }; - LOOP_LINEAR_AXES(a) { + LOOP_NUM_AXES(a) { if (axis_can_calibrate(a) && parser.seen(AXIS_CHAR(a))) { planner.synchronize(); - backlash.set_distance_mm(AxisEnum(a), parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a))); + backlash.set_distance_mm(AxisEnum(a), parser.has_value() ? parser.value_axis_units(AxisEnum(a)) : backlash.get_measurement(AxisEnum(a))); noArgs = false; } } @@ -88,7 +91,7 @@ void GcodeSuite::M425() { SERIAL_ECHOLNPGM("active:"); SERIAL_ECHOLNPGM(" Correction Amount/Fade-out: F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)"); SERIAL_ECHOPGM(" Backlash Distance (mm): "); - LOOP_LINEAR_AXES(a) if (axis_can_calibrate(a)) { + LOOP_NUM_AXES(a) if (axis_can_calibrate(a)) { SERIAL_CHAR(' ', AXIS_CHAR(a)); SERIAL_ECHO(backlash.get_distance_mm(AxisEnum(a))); SERIAL_EOL(); @@ -101,7 +104,7 @@ void GcodeSuite::M425() { #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) SERIAL_ECHOPGM(" Average measured backlash (mm):"); if (backlash.has_any_measurement()) { - LOOP_LINEAR_AXES(a) if (axis_can_calibrate(a) && backlash.has_measurement(AxisEnum(a))) { + LOOP_NUM_AXES(a) if (axis_can_calibrate(a) && backlash.has_measurement(AxisEnum(a))) { SERIAL_CHAR(' ', AXIS_CHAR(a)); SERIAL_ECHO(backlash.get_measurement(AxisEnum(a))); } @@ -120,13 +123,16 @@ void GcodeSuite::M425_report(const bool forReplay/*=true*/) { #ifdef BACKLASH_SMOOTHING_MM , PSTR(" S"), LINEAR_UNIT(backlash.get_smoothing_mm()) #endif - , LIST_N(DOUBLE(LINEAR_AXES), + , LIST_N(DOUBLE(NUM_AXES), SP_X_STR, LINEAR_UNIT(backlash.get_distance_mm(X_AXIS)), SP_Y_STR, LINEAR_UNIT(backlash.get_distance_mm(Y_AXIS)), SP_Z_STR, LINEAR_UNIT(backlash.get_distance_mm(Z_AXIS)), - SP_I_STR, LINEAR_UNIT(backlash.get_distance_mm(I_AXIS)), - SP_J_STR, LINEAR_UNIT(backlash.get_distance_mm(J_AXIS)), - SP_K_STR, LINEAR_UNIT(backlash.get_distance_mm(K_AXIS)) + SP_I_STR, I_AXIS_UNIT(backlash.get_distance_mm(I_AXIS)), + SP_J_STR, J_AXIS_UNIT(backlash.get_distance_mm(J_AXIS)), + SP_K_STR, K_AXIS_UNIT(backlash.get_distance_mm(K_AXIS)), + SP_U_STR, U_AXIS_UNIT(backlash.get_distance_mm(U_AXIS)), + SP_V_STR, V_AXIS_UNIT(backlash.get_distance_mm(V_AXIS)), + SP_W_STR, W_AXIS_UNIT(backlash.get_distance_mm(W_AXIS)) ) ); } diff --git a/Marlin/src/gcode/calibrate/M666.cpp b/Marlin/src/gcode/calibrate/M666.cpp index 15f8baf109..fe244b21f7 100644 --- a/Marlin/src/gcode/calibrate/M666.cpp +++ b/Marlin/src/gcode/calibrate/M666.cpp @@ -44,7 +44,7 @@ void GcodeSuite::M666() { DEBUG_SECTION(log_M666, "M666", DEBUGGING(LEVELING)); bool is_err = false, is_set = false; - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { if (parser.seen(AXIS_CHAR(i))) { is_set = true; const float v = parser.value_linear_units(); diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index fb4c9b8af3..5e15ff65e8 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -135,13 +135,16 @@ void GcodeSuite::M201() { void GcodeSuite::M201_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_MAX_ACCELERATION)); SERIAL_ECHOLNPGM_P( - LIST_N(DOUBLE(LINEAR_AXES), + LIST_N(DOUBLE(NUM_AXES), PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]), SP_Y_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Y_AXIS]), SP_Z_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[Z_AXIS]), - SP_I_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[I_AXIS]), - SP_J_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[J_AXIS]), - SP_K_STR, LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[K_AXIS]) + SP_I_STR, I_AXIS_UNIT(planner.settings.max_acceleration_mm_per_s2[I_AXIS]), + SP_J_STR, J_AXIS_UNIT(planner.settings.max_acceleration_mm_per_s2[J_AXIS]), + SP_K_STR, K_AXIS_UNIT(planner.settings.max_acceleration_mm_per_s2[K_AXIS]), + SP_U_STR, U_AXIS_UNIT(planner.settings.max_acceleration_mm_per_s2[U_AXIS]), + SP_V_STR, V_AXIS_UNIT(planner.settings.max_acceleration_mm_per_s2[V_AXIS]), + SP_W_STR, W_AXIS_UNIT(planner.settings.max_acceleration_mm_per_s2[W_AXIS]), ) #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_acceleration_mm_per_s2[E_AXIS]) @@ -180,13 +183,16 @@ void GcodeSuite::M203() { void GcodeSuite::M203_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_MAX_FEEDRATES)); SERIAL_ECHOLNPGM_P( - LIST_N(DOUBLE(LINEAR_AXES), + LIST_N(DOUBLE(NUM_AXES), PSTR(" M203 X"), LINEAR_UNIT(planner.settings.max_feedrate_mm_s[X_AXIS]), SP_Y_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Y_AXIS]), SP_Z_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[Z_AXIS]), SP_I_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[I_AXIS]), SP_J_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[J_AXIS]), - SP_K_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[K_AXIS]) + SP_K_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[K_AXIS]), + SP_U_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[U_AXIS]), + SP_V_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[V_AXIS]), + SP_W_STR, LINEAR_UNIT(planner.settings.max_feedrate_mm_s[W_AXIS]) ) #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS]) @@ -273,9 +279,12 @@ void GcodeSuite::M205() { if (parser.seenval('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units()), if (parser.seenval('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units()), if ((seenZ = parser.seenval('Z'))) planner.set_max_jerk(Z_AXIS, parser.value_linear_units()), - if (parser.seenval(AXIS4_NAME)) planner.set_max_jerk(I_AXIS, parser.value_linear_units()), - if (parser.seenval(AXIS5_NAME)) planner.set_max_jerk(J_AXIS, parser.value_linear_units()), - if (parser.seenval(AXIS6_NAME)) planner.set_max_jerk(K_AXIS, parser.value_linear_units()) + if (parser.seenval(AXIS4_NAME)) planner.set_max_jerk(I_AXIS, parser.TERN(AXIS4_ROTATES, value_float, value_linear_units)()), + if (parser.seenval(AXIS5_NAME)) planner.set_max_jerk(J_AXIS, parser.TERN(AXIS5_ROTATES, value_float, value_linear_units)()), + if (parser.seenval(AXIS6_NAME)) planner.set_max_jerk(K_AXIS, parser.TERN(AXIS6_ROTATES, value_float, value_linear_units)()), + if (parser.seenval(AXIS7_NAME)) planner.set_max_jerk(U_AXIS, parser.TERN(AXIS7_ROTATES, value_float, value_linear_units)()), + if (parser.seenval(AXIS8_NAME)) planner.set_max_jerk(V_AXIS, parser.TERN(AXIS8_ROTATES, value_float, value_linear_units)()), + if (parser.seenval(AXIS9_NAME)) planner.set_max_jerk(W_AXIS, parser.TERN(AXIS9_ROTATES, value_float, value_linear_units)()) ); #if HAS_MESH && DISABLED(LIMITED_JERK_EDITING) if (seenZ && planner.max_jerk.z <= 0.1f) @@ -289,9 +298,10 @@ void GcodeSuite::M205_report(const bool forReplay/*=true*/) { "Advanced (B S T" TERN_(HAS_JUNCTION_DEVIATION, " J") #if HAS_CLASSIC_JERK - LINEAR_AXIS_GANG( + NUM_AXIS_GANG( " X", " Y", " Z", - " " STR_I "", " " STR_J "", " " STR_K "" + " " STR_I "", " " STR_J "", " " STR_K "", + " " STR_U "", " " STR_V "", " " STR_W "" ) #endif TERN_(HAS_CLASSIC_E_JERK, " E") @@ -305,13 +315,16 @@ void GcodeSuite::M205_report(const bool forReplay/*=true*/) { , PSTR(" J"), LINEAR_UNIT(planner.junction_deviation_mm) #endif #if HAS_CLASSIC_JERK - , LIST_N(DOUBLE(LINEAR_AXES), + , LIST_N(DOUBLE(NUM_AXES), SP_X_STR, LINEAR_UNIT(planner.max_jerk.x), SP_Y_STR, LINEAR_UNIT(planner.max_jerk.y), SP_Z_STR, LINEAR_UNIT(planner.max_jerk.z), - SP_I_STR, LINEAR_UNIT(planner.max_jerk.i), - SP_J_STR, LINEAR_UNIT(planner.max_jerk.j), - SP_K_STR, LINEAR_UNIT(planner.max_jerk.k) + SP_I_STR, I_AXIS_UNIT(planner.max_jerk.i), + SP_J_STR, J_AXIS_UNIT(planner.max_jerk.j), + SP_K_STR, K_AXIS_UNIT(planner.max_jerk.k), + SP_U_STR, U_AXIS_UNIT(planner.max_jerk.u), + SP_V_STR, V_AXIS_UNIT(planner.max_jerk.v), + SP_W_STR, W_AXIS_UNIT(planner.max_jerk.w) ) #if HAS_CLASSIC_E_JERK , SP_E_STR, LINEAR_UNIT(planner.max_jerk.e) diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 344adc34e3..ad96b2b659 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -50,9 +50,12 @@ * W[linear] 0/1 Enable park & Z Raise * X[linear] Park X (Requires TOOLCHANGE_PARK) * Y[linear] Park Y (Requires TOOLCHANGE_PARK) - * I[linear] Park I (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 4) - * J[linear] Park J (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 5) - * K[linear] Park K (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 6) + * I[linear] Park I (Requires TOOLCHANGE_PARK and NUM_AXES >= 4) + * J[linear] Park J (Requires TOOLCHANGE_PARK and NUM_AXES >= 5) + * K[linear] Park K (Requires TOOLCHANGE_PARK and NUM_AXES >= 6) + * C[linear] Park U (Requires TOOLCHANGE_PARK and NUM_AXES >= 7) + * H[linear] Park V (Requires TOOLCHANGE_PARK and NUM_AXES >= 8) + * O[linear] Park W (Requires TOOLCHANGE_PARK and NUM_AXES >= 9) * Z[linear] Z Raise * F[linear] Fan Speed 0-255 * G[linear/s] Fan time @@ -95,13 +98,22 @@ void GcodeSuite::M217() { if (parser.seenval('Y')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.y = constrain(v, Y_MIN_POS, Y_MAX_POS); } #endif #if HAS_I_AXIS - if (parser.seenval('I')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.i = constrain(v, I_MIN_POS, I_MAX_POS); } + if (parser.seenval('I')) { const int16_t v = parser.TERN(AXIS4_ROTATES, value_int, value_linear_units)(); toolchange_settings.change_point.i = constrain(v, I_MIN_POS, I_MAX_POS); } #endif #if HAS_J_AXIS - if (parser.seenval('J')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.j = constrain(v, J_MIN_POS, J_MAX_POS); } + if (parser.seenval('J')) { const int16_t v = parser.TERN(AXIS5_ROTATES, value_int, value_linear_units)(); toolchange_settings.change_point.j = constrain(v, J_MIN_POS, J_MAX_POS); } #endif #if HAS_K_AXIS - if (parser.seenval('K')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.k = constrain(v, K_MIN_POS, K_MAX_POS); } + if (parser.seenval('K')) { const int16_t v = parser.TERN(AXIS6_ROTATES, value_int, value_linear_units)(); toolchange_settings.change_point.k = constrain(v, K_MIN_POS, K_MAX_POS); } + #endif + #if HAS_U_AXIS + if (parser.seenval('C')) { const int16_t v = parser.TERN(AXIS7_ROTATES, value_int, value_linear_units)(); toolchange_settings.change_point.u = constrain(v, U_MIN_POS, U_MAX_POS); } + #endif + #if HAS_V_AXIS + if (parser.seenval('H')) { const int16_t v = parser.TERN(AXIS8_ROTATES, value_int, value_linear_units)(); toolchange_settings.change_point.v = constrain(v, V_MIN_POS, V_MAX_POS); } + #endif + #if HAS_W_AXIS + if (parser.seenval('O')) { const int16_t v = parser.TERN(AXIS9_ROTATES, value_int, value_linear_units)(); toolchange_settings.change_point.w = constrain(v, W_MIN_POS, W_MAX_POS); } #endif #endif @@ -167,24 +179,23 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { #endif #if ENABLED(TOOLCHANGE_PARK) - { SERIAL_ECHOPGM(" W", LINEAR_UNIT(toolchange_settings.enable_park)); SERIAL_ECHOPGM_P( SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x) #if HAS_Y_AXIS , SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y) #endif - #if HAS_I_AXIS - , SP_I_STR, LINEAR_UNIT(toolchange_settings.change_point.i) - #endif - #if HAS_J_AXIS - , SP_J_STR, LINEAR_UNIT(toolchange_settings.change_point.j) - #endif - #if HAS_K_AXIS - , SP_K_STR, LINEAR_UNIT(toolchange_settings.change_point.k) + #if SECONDARY_AXES >= 1 + , LIST_N(DOUBLE(SECONDARY_AXES), + PSTR(" I"), I_AXIS_UNIT(toolchange_settings.change_point.i), + PSTR(" J"), J_AXIS_UNIT(toolchange_settings.change_point.j), + PSTR(" K"), K_AXIS_UNIT(toolchange_settings.change_point.k), + SP_C_STR, U_AXIS_UNIT(toolchange_settings.change_point.u), + PSTR(" H"), V_AXIS_UNIT(toolchange_settings.change_point.v), + PSTR(" O"), W_AXIS_UNIT(toolchange_settings.change_point.w), + ) #endif ); - } #endif #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index 8f527919fd..cca4f7f12a 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -24,7 +24,7 @@ #include "../../module/planner.h" /** - * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, [I, [J, [K]]] and E. + * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, [I, [J, [K, [U, [V, [W,]]]]]] and E. * (Follows the same syntax as G92) * * With multiple extruders use T to specify which one. @@ -92,14 +92,17 @@ void GcodeSuite::M92() { void GcodeSuite::M92_report(const bool forReplay/*=true*/, const int8_t e/*=-1*/) { report_heading_etc(forReplay, F(STR_STEPS_PER_UNIT)); - SERIAL_ECHOPGM_P(LIST_N(DOUBLE(LINEAR_AXES), + SERIAL_ECHOPGM_P(LIST_N(DOUBLE(NUM_AXES), PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]), SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]), SP_Z_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]), - SP_I_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[I_AXIS]), - SP_J_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[J_AXIS]), - SP_K_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[K_AXIS])) - ); + SP_I_STR, I_AXIS_UNIT(planner.settings.axis_steps_per_mm[I_AXIS]), + SP_J_STR, J_AXIS_UNIT(planner.settings.axis_steps_per_mm[J_AXIS]), + SP_K_STR, K_AXIS_UNIT(planner.settings.axis_steps_per_mm[K_AXIS]), + SP_U_STR, U_AXIS_UNIT(planner.settings.axis_steps_per_mm[U_AXIS]), + SP_V_STR, V_AXIS_UNIT(planner.settings.axis_steps_per_mm[V_AXIS]), + SP_W_STR, W_AXIS_UNIT(planner.settings.axis_steps_per_mm[W_AXIS]) + )); #if HAS_EXTRUDERS && DISABLED(DISTINCT_E_FACTORS) SERIAL_ECHOPGM_P(SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS])); #endif diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 3bc5582ce7..c6473af48f 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -46,13 +46,16 @@ inline axis_flags_t selected_axis_bits() { selected.bits = selected.e_bits(); } #endif - selected.bits |= LINEAR_AXIS_GANG( + selected.bits |= NUM_AXIS_GANG( (parser.seen_test('X') << X_AXIS), | (parser.seen_test('Y') << Y_AXIS), | (parser.seen_test('Z') << Z_AXIS), | (parser.seen_test(AXIS4_NAME) << I_AXIS), | (parser.seen_test(AXIS5_NAME) << J_AXIS), - | (parser.seen_test(AXIS6_NAME) << K_AXIS) + | (parser.seen_test(AXIS6_NAME) << K_AXIS), + | (parser.seen_test(AXIS7_NAME) << U_AXIS), + | (parser.seen_test(AXIS8_NAME) << V_AXIS), + | (parser.seen_test(AXIS9_NAME) << W_AXIS) ); return selected; } @@ -69,7 +72,7 @@ void do_enable(const axis_flags_t to_enable) { ena_mask_t also_enabled = 0; // Track steppers enabled due to overlap // Enable all flagged axes - LOOP_LINEAR_AXES(a) { + LOOP_NUM_AXES(a) { if (TEST(shall_enable, a)) { stepper.enable_axis(AxisEnum(a)); // Mark and enable the requested axis DEBUG_ECHOLNPGM("Enabled ", axis_codes[a], " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... Enabled: ", hex_word(stepper.axis_enabled.bits)); @@ -89,7 +92,7 @@ void do_enable(const axis_flags_t to_enable) { if ((also_enabled &= ~(shall_enable | was_enabled))) { SERIAL_CHAR('('); - LOOP_LINEAR_AXES(a) if (TEST(also_enabled, a)) SERIAL_CHAR(axis_codes[a], ' '); + LOOP_NUM_AXES(a) if (TEST(also_enabled, a)) SERIAL_CHAR(axis_codes[a], ' '); #if HAS_EXTRUDERS #define _EN_ALSO(N) if (TEST(also_enabled, INDEX_OF_AXIS(E_AXIS, N))) SERIAL_CHAR('E', '0' + N, ' '); REPEAT(EXTRUDERS, _EN_ALSO) @@ -125,13 +128,16 @@ void GcodeSuite::M17() { stepper.enable_e_steppers(); } #endif - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( if (parser.seen_test('X')) stepper.enable_axis(X_AXIS), if (parser.seen_test('Y')) stepper.enable_axis(Y_AXIS), if (parser.seen_test('Z')) stepper.enable_axis(Z_AXIS), if (parser.seen_test(AXIS4_NAME)) stepper.enable_axis(I_AXIS), if (parser.seen_test(AXIS5_NAME)) stepper.enable_axis(J_AXIS), - if (parser.seen_test(AXIS6_NAME)) stepper.enable_axis(K_AXIS) + if (parser.seen_test(AXIS6_NAME)) stepper.enable_axis(K_AXIS), + if (parser.seen_test(AXIS7_NAME)) stepper.enable_axis(U_AXIS), + if (parser.seen_test(AXIS8_NAME)) stepper.enable_axis(V_AXIS), + if (parser.seen_test(AXIS9_NAME)) stepper.enable_axis(W_AXIS) ); } } @@ -149,7 +155,7 @@ void try_to_disable(const axis_flags_t to_disable) { if (!still_enabled) return; // Attempt to disable all flagged axes - LOOP_LINEAR_AXES(a) + LOOP_NUM_AXES(a) if (TEST(to_disable.bits, a)) { DEBUG_ECHOPGM("Try to disable ", axis_codes[a], " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... "); if (stepper.disable_axis(AxisEnum(a))) { // Mark the requested axis and request to disable @@ -178,7 +184,7 @@ void try_to_disable(const axis_flags_t to_disable) { auto overlap_warning = [](const ena_mask_t axis_bits) { SERIAL_ECHOPGM(" not disabled. Shared with"); - LOOP_LINEAR_AXES(a) if (TEST(axis_bits, a)) SERIAL_CHAR(' ', axis_codes[a]); + LOOP_NUM_AXES(a) if (TEST(axis_bits, a)) SERIAL_CHAR(' ', axis_codes[a]); #if HAS_EXTRUDERS #define _EN_STILLON(N) if (TEST(axis_bits, INDEX_OF_AXIS(E_AXIS, N))) SERIAL_CHAR(' ', 'E', '0' + N); REPEAT(EXTRUDERS, _EN_STILLON) @@ -187,7 +193,7 @@ void try_to_disable(const axis_flags_t to_disable) { }; // If any of the requested axes are still enabled, give a warning - LOOP_LINEAR_AXES(a) { + LOOP_NUM_AXES(a) { if (TEST(still_enabled, a)) { SERIAL_CHAR(axis_codes[a]); overlap_warning(stepper.axis_enabled.bits & enable_overlap[a]); @@ -229,13 +235,16 @@ void GcodeSuite::M18_M84() { stepper.disable_e_steppers(); } #endif - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( if (parser.seen_test('X')) stepper.disable_axis(X_AXIS), if (parser.seen_test('Y')) stepper.disable_axis(Y_AXIS), if (parser.seen_test('Z')) stepper.disable_axis(Z_AXIS), if (parser.seen_test(AXIS4_NAME)) stepper.disable_axis(I_AXIS), if (parser.seen_test(AXIS5_NAME)) stepper.disable_axis(J_AXIS), - if (parser.seen_test(AXIS6_NAME)) stepper.disable_axis(K_AXIS) + if (parser.seen_test(AXIS6_NAME)) stepper.disable_axis(K_AXIS), + if (parser.seen_test(AXIS7_NAME)) stepper.disable_axis(U_AXIS), + if (parser.seen_test(AXIS8_NAME)) stepper.disable_axis(V_AXIS), + if (parser.seen_test(AXIS9_NAME)) stepper.disable_axis(W_AXIS) ); } } diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 788659e7e2..a0296bba57 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -146,7 +146,7 @@ HOTEND_LOOP() { DEBUG_ECHOPGM_P(SP_T_STR, e); - LOOP_LINEAR_AXES(a) DEBUG_ECHOPGM(" hotend_offset[", e, "].", AS_CHAR(AXIS_CHAR(a) | 0x20), "=", hotend_offset[e][a]); + LOOP_NUM_AXES(a) DEBUG_ECHOPGM(" hotend_offset[", e, "].", AS_CHAR(AXIS_CHAR(a) | 0x20), "=", hotend_offset[e][a]); DEBUG_EOL(); } DEBUG_EOL(); diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index 95adde3ea5..3b66f78593 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -39,7 +39,7 @@ #endif /** - * M907: Set digital trimpot motor current using axis codes X [Y] [Z] [E] + * M907: Set digital trimpot motor current using axis codes X [Y] [Z] [I] [J] [K] [U] [V] [W] [E] * B - Special case for 4th (E) axis * S - Special case to set first 3 axes */ @@ -49,15 +49,15 @@ void GcodeSuite::M907() { if (!parser.seen("BS" LOGICAL_AXES_STRING)) return M907_report(); - LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.set_digipot_current(i, parser.value_int()); + LOOP_LOGICAL_AXES(i) if (parser.seenval(IAXIS_CHAR(i))) stepper.set_digipot_current(i, parser.value_int()); if (parser.seenval('B')) stepper.set_digipot_current(4, parser.value_int()); if (parser.seenval('S')) LOOP_LE_N(i, 4) stepper.set_digipot_current(i, parser.value_int()); #elif HAS_MOTOR_CURRENT_PWM if (!parser.seen( - #if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY) - "XY" + #if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K, MOTOR_CURRENT_PWM_U, MOTOR_CURRENT_PWM_V, MOTOR_CURRENT_PWM_W) + "XY" SECONDARY_AXIS_GANG("I", "J", "K", "U", "V", "W") #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) "Z" @@ -67,8 +67,12 @@ void GcodeSuite::M907() { #endif )) return M907_report(); - #if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY) - if (parser.seenval('X') || parser.seenval('Y')) stepper.set_digipot_current(0, parser.value_int()); + #if ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K, MOTOR_CURRENT_PWM_U, MOTOR_CURRENT_PWM_V, MOTOR_CURRENT_PWM_W) + if (NUM_AXIS_GANG( + parser.seenval('X'), || parser.seenval('Y'), || false, + || parser.seenval('I'), || parser.seenval('J'), || parser.seenval('K'), + || parser.seenval('U'), || parser.seenval('V'), || parser.seenval('W') + )) stepper.set_digipot_current(0, parser.value_int()); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) if (parser.seenval('Z')) stepper.set_digipot_current(1, parser.value_int()); @@ -81,7 +85,7 @@ void GcodeSuite::M907() { #if HAS_MOTOR_CURRENT_I2C // this one uses actual amps in floating point - LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) digipot_i2c.set_current(i, parser.value_float()); + LOOP_LOGICAL_AXES(i) if (parser.seenval(IAXIS_CHAR(i))) digipot_i2c.set_current(i, parser.value_float()); // Additional extruders use B,C,D for channels 4,5,6. // TODO: Change these parameters because 'E' is used. B? #if HAS_EXTRUDERS @@ -95,7 +99,7 @@ void GcodeSuite::M907() { const float dac_percent = parser.value_float(); LOOP_LE_N(i, 4) stepper_dac.set_current_percent(i, dac_percent); } - LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper_dac.set_current_percent(i, parser.value_float()); + LOOP_LOGICAL_AXES(i) if (parser.seenval(IAXIS_CHAR(i))) stepper_dac.set_current_percent(i, parser.value_float()); #endif } @@ -104,15 +108,15 @@ void GcodeSuite::M907() { void GcodeSuite::M907_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_STEPPER_MOTOR_CURRENTS)); #if HAS_MOTOR_CURRENT_PWM - SERIAL_ECHOLNPGM_P( // PWM-based has 3 values: - PSTR(" M907 X"), stepper.motor_current_setting[0] // X and Y + SERIAL_ECHOLNPGM_P( // PWM-based has 3 values: + PSTR(" M907 X"), stepper.motor_current_setting[0] // X, Y, (I, J, K, U, V, W) , SP_Z_STR, stepper.motor_current_setting[1] // Z , SP_E_STR, stepper.motor_current_setting[2] // E ); #elif HAS_MOTOR_CURRENT_SPI SERIAL_ECHOPGM(" M907"); // SPI-based has 5 values: - LOOP_LOGICAL_AXES(q) { // X Y Z (I J K) E (map to X Y Z (I J K) E0 by default) - SERIAL_CHAR(' ', axis_codes[q]); + LOOP_LOGICAL_AXES(q) { // X Y Z (I J K U V W) E (map to X Y Z (I J K U V W) E0 by default) + SERIAL_CHAR(' ', IAXIS_CHAR(q)); SERIAL_ECHO(stepper.motor_current_setting[q]); } SERIAL_CHAR(' ', 'B'); // B (maps to E1 by default) diff --git a/Marlin/src/gcode/feature/pause/G60.cpp b/Marlin/src/gcode/feature/pause/G60.cpp index d4770577a6..9e0962fd34 100644 --- a/Marlin/src/gcode/feature/pause/G60.cpp +++ b/Marlin/src/gcode/feature/pause/G60.cpp @@ -48,10 +48,14 @@ void GcodeSuite::G60() { #if ENABLED(SAVED_POSITIONS_DEBUG) { - DEBUG_ECHOPGM(STR_SAVED_POS " S", slot); const xyze_pos_t &pos = stored_position[slot]; + DEBUG_ECHOPGM(STR_SAVED_POS " S", slot, " :"); DEBUG_ECHOLNPAIR_F_P( - LIST_N(DOUBLE(LINEAR_AXES), PSTR(" : X"), pos.x, SP_Y_STR, pos.y, SP_Z_STR, pos.z, SP_I_STR, pos.i, SP_J_STR, pos.j, SP_K_STR, pos.k) + LIST_N(DOUBLE(NUM_AXES), + SP_Y_STR, pos.x, SP_Y_STR, pos.y, SP_Z_STR, pos.z, + SP_I_STR, pos.i, SP_J_STR, pos.j, SP_K_STR, pos.k, + SP_U_STR, pos.u, SP_V_STR, pos.v, SP_W_STR, pos.w + ) #if HAS_EXTRUDERS , SP_E_STR, pos.e #endif diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index e0e1983a25..baf96f0d0a 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -68,9 +68,9 @@ void GcodeSuite::G61() { SYNC_E(stored_position[slot].e); } else { - if (parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K))) { + if (parser.seen(NUM_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K, STR_U, STR_V, STR_W))) { DEBUG_ECHOPGM(STR_RESTORING_POS " S", slot); - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { destination[i] = parser.seen(AXIS_CHAR(i)) ? stored_position[slot][i] + parser.value_axis_units((AxisEnum)i) : current_position[i]; diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index 940e1b369b..ae450cc5e9 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -52,6 +52,9 @@ * A = Override park position A (requires AXIS*_NAME 'A') * B = Override park position B (requires AXIS*_NAME 'B') * C = Override park position C (requires AXIS*_NAME 'C') + * U = Override park position U (requires AXIS*_NAME 'U') + * V = Override park position V (requires AXIS*_NAME 'V') + * W = Override park position W (requires AXIS*_NAME 'W') * Z = Override Z raise * * With an LCD menu: @@ -64,17 +67,22 @@ void GcodeSuite::M125() { xyz_pos_t park_point = NOZZLE_PARK_POINT; // Move to filament change position or given position - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( if (parser.seenval('X')) park_point.x = RAW_X_POSITION(parser.linearval('X')), if (parser.seenval('Y')) park_point.y = RAW_Y_POSITION(parser.linearval('Y')), NOOP, - if (parser.seenval(AXIS4_NAME)) park_point.i = RAW_I_POSITION(parser.linearval(AXIS4_NAME)), - if (parser.seenval(AXIS5_NAME)) park_point.j = RAW_J_POSITION(parser.linearval(AXIS5_NAME)), - if (parser.seenval(AXIS6_NAME)) park_point.k = RAW_K_POSITION(parser.linearval(AXIS6_NAME)) + if (parser.seenval(AXIS4_NAME)) park_point.i = RAW_X_POSITION(parser.linearval(AXIS4_NAME)), + if (parser.seenval(AXIS5_NAME)) park_point.j = RAW_X_POSITION(parser.linearval(AXIS5_NAME)), + if (parser.seenval(AXIS6_NAME)) park_point.k = RAW_X_POSITION(parser.linearval(AXIS6_NAME)), + if (parser.seenval(AXIS7_NAME)) park_point.u = RAW_X_POSITION(parser.linearval(AXIS7_NAME)), + if (parser.seenval(AXIS8_NAME)) park_point.v = RAW_X_POSITION(parser.linearval(AXIS8_NAME)), + if (parser.seenval(AXIS9_NAME)) park_point.w = RAW_X_POSITION(parser.linearval(AXIS9_NAME)) ); // Lift Z axis - if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); + #if HAS_Z_AXIS + if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); + #endif #if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA) park_point += hotend_offset[active_extruder]; diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 1679c90687..4fd08489d3 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -54,8 +54,14 @@ * * E[distance] - Retract the filament this far * Z[distance] - Move the Z axis by this distance - * X[position] - Move to this X position, with Y - * Y[position] - Move to this Y position, with X + * X[position] - Move to this X position (instead of NOZZLE_PARK_POINT.x) + * Y[position] - Move to this Y position (instead of NOZZLE_PARK_POINT.y) + * I[position] - Move to this I position (instead of NOZZLE_PARK_POINT.i) + * J[position] - Move to this J position (instead of NOZZLE_PARK_POINT.j) + * K[position] - Move to this K position (instead of NOZZLE_PARK_POINT.k) + * C[position] - Move to this U position (instead of NOZZLE_PARK_POINT.u) + * H[position] - Move to this V position (instead of NOZZLE_PARK_POINT.v) + * O[position] - Move to this W position (instead of NOZZLE_PARK_POINT.w) * U[distance] - Retract distance for removal (manual reload) * L[distance] - Extrude distance for insertion (manual reload) * B[count] - Number of times to beep, -1 for indefinite (if equipped with a buzzer) @@ -117,26 +123,25 @@ void GcodeSuite::M600() { xyz_pos_t park_point NOZZLE_PARK_POINT; // Move XY axes to filament change position or given position - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( if (parser.seenval('X')) park_point.x = parser.linearval('X'), if (parser.seenval('Y')) park_point.y = parser.linearval('Y'), if (parser.seenval('Z')) park_point.z = parser.linearval('Z'), // Lift Z axis - if (parser.seenval(AXIS4_NAME)) park_point.i = parser.linearval(AXIS4_NAME), - if (parser.seenval(AXIS5_NAME)) park_point.j = parser.linearval(AXIS5_NAME), - if (parser.seenval(AXIS6_NAME)) park_point.k = parser.linearval(AXIS6_NAME) + if (parser.seenval('I')) park_point.i = parser.linearval('I'), + if (parser.seenval('J')) park_point.j = parser.linearval('J'), + if (parser.seenval('K')) park_point.k = parser.linearval('K'), + if (parser.seenval('C')) park_point.u = parser.linearval('C'), // U axis + if (parser.seenval('H')) park_point.v = parser.linearval('H'), // V axis + if (parser.seenval('O')) park_point.w = parser.linearval('O') // W axis ); #if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA) park_point += hotend_offset[active_extruder]; #endif - #if ENABLED(MMU2_MENUS) - // For MMU2, when enabled, reset retract value so it doesn't mess with MMU filament handling - const float unload_length = standardM600 ? -ABS(parser.axisunitsval('U', E_AXIS, fc_settings[active_extruder].unload_length)) : 0.5f; - #else - // Unload filament - const float unload_length = -ABS(parser.axisunitsval('U', E_AXIS, fc_settings[active_extruder].unload_length)); - #endif + // Unload filament + // For MMU2, when enabled, reset retract value so it doesn't mess with MMU filament handling + const float unload_length = standardM600 ? -ABS(parser.axisunitsval('U', E_AXIS, fc_settings[active_extruder].unload_length)) : 0.5f; const int beep_count = parser.intval('B', -1 #ifdef FILAMENT_CHANGE_ALERT_BEEPS diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 7bfedf8c72..3a325ad264 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -85,6 +85,15 @@ static void set_stealth_status(const bool enable, const int8_t eindex) { #if K_HAS_STEALTHCHOP case K_AXIS: TMC_SET_STEALTH(K); break; #endif + #if U_HAS_STEALTHCHOP + case U_AXIS: TMC_SET_STEALTH(U); break; + #endif + #if V_HAS_STEALTHCHOP + case V_AXIS: TMC_SET_STEALTH(V); break; + #endif + #if W_HAS_STEALTHCHOP + case W_AXIS: TMC_SET_STEALTH(W); break; + #endif #if E_STEPPERS case E_AXIS: { @@ -115,6 +124,9 @@ static void say_stealth_status() { OPTCODE( I_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(I)) OPTCODE( J_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(J)) OPTCODE( K_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(K)) + OPTCODE( U_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(U)) + OPTCODE( V_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(V)) + OPTCODE( W_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(W)) OPTCODE(E0_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(E0)) OPTCODE(E1_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(E1)) OPTCODE(E2_HAS_STEALTHCHOP, TMC_SAY_STEALTH_STATUS(E2)) @@ -157,17 +169,23 @@ void GcodeSuite::M569_report(const bool forReplay/*=true*/) { chop_z = TERN0(Z_HAS_STEALTHCHOP, stepperZ.get_stored_stealthChop()), chop_i = TERN0(I_HAS_STEALTHCHOP, stepperI.get_stored_stealthChop()), chop_j = TERN0(J_HAS_STEALTHCHOP, stepperJ.get_stored_stealthChop()), - chop_k = TERN0(K_HAS_STEALTHCHOP, stepperK.get_stored_stealthChop()); + chop_k = TERN0(K_HAS_STEALTHCHOP, stepperK.get_stored_stealthChop()), + chop_u = TERN0(U_HAS_STEALTHCHOP, stepperU.get_stored_stealthChop()), + chop_v = TERN0(V_HAS_STEALTHCHOP, stepperV.get_stored_stealthChop()), + chop_w = TERN0(W_HAS_STEALTHCHOP, stepperW.get_stored_stealthChop()); - if (chop_x || chop_y || chop_z || chop_i || chop_j || chop_k) { + if (chop_x || chop_y || chop_z || chop_i || chop_j || chop_k || chop_u || chop_v || chop_w) { say_M569(forReplay); - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( if (chop_x) SERIAL_ECHOPGM_P(SP_X_STR), if (chop_y) SERIAL_ECHOPGM_P(SP_Y_STR), if (chop_z) SERIAL_ECHOPGM_P(SP_Z_STR), if (chop_i) SERIAL_ECHOPGM_P(SP_I_STR), if (chop_j) SERIAL_ECHOPGM_P(SP_J_STR), - if (chop_k) SERIAL_ECHOPGM_P(SP_K_STR) + if (chop_k) SERIAL_ECHOPGM_P(SP_K_STR), + if (chop_u) SERIAL_ECHOPGM_P(SP_U_STR), + if (chop_v) SERIAL_ECHOPGM_P(SP_V_STR), + if (chop_w) SERIAL_ECHOPGM_P(SP_W_STR) ); SERIAL_EOL(); } @@ -190,6 +208,9 @@ void GcodeSuite::M569_report(const bool forReplay/*=true*/) { if (TERN0( I_HAS_STEALTHCHOP, stepperI.get_stored_stealthChop())) { say_M569(forReplay, FPSTR(SP_I_STR), true); } if (TERN0( J_HAS_STEALTHCHOP, stepperJ.get_stored_stealthChop())) { say_M569(forReplay, FPSTR(SP_J_STR), true); } if (TERN0( K_HAS_STEALTHCHOP, stepperK.get_stored_stealthChop())) { say_M569(forReplay, FPSTR(SP_K_STR), true); } + if (TERN0( U_HAS_STEALTHCHOP, stepperU.get_stored_stealthChop())) { say_M569(forReplay, FPSTR(SP_U_STR), true); } + if (TERN0( V_HAS_STEALTHCHOP, stepperV.get_stored_stealthChop())) { say_M569(forReplay, FPSTR(SP_V_STR), true); } + if (TERN0( W_HAS_STEALTHCHOP, stepperW.get_stored_stealthChop())) { say_M569(forReplay, FPSTR(SP_W_STR), true); } if (TERN0(E0_HAS_STEALTHCHOP, stepperE0.get_stored_stealthChop())) { say_M569(forReplay, F("T0 E"), true); } if (TERN0(E1_HAS_STEALTHCHOP, stepperE1.get_stored_stealthChop())) { say_M569(forReplay, F("T1 E"), true); } diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index c85d0be8a1..4822b8e268 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -44,6 +44,9 @@ static void tmc_print_current(TMC &st) { * A[current] - Set mA current for A driver(s) (Requires AXIS*_NAME 'A') * B[current] - Set mA current for B driver(s) (Requires AXIS*_NAME 'B') * C[current] - Set mA current for C driver(s) (Requires AXIS*_NAME 'C') + * U[current] - Set mA current for U driver(s) (Requires AXIS*_NAME 'U') + * V[current] - Set mA current for V driver(s) (Requires AXIS*_NAME 'V') + * W[current] - Set mA current for W driver(s) (Requires AXIS*_NAME 'W') * E[current] - Set mA current for E driver(s) * * I[index] - Axis sub-index (Omit or 0 for X, Y, Z; 1 for X2, Y2, Z2; 2 for Z3; 3 for Z4.) @@ -114,6 +117,15 @@ void GcodeSuite::M906() { #if AXIS_IS_TMC(K) case K_AXIS: TMC_SET_CURRENT(K); break; #endif + #if AXIS_IS_TMC(U) + case U_AXIS: TMC_SET_CURRENT(U); break; + #endif + #if AXIS_IS_TMC(V) + case V_AXIS: TMC_SET_CURRENT(V); break; + #endif + #if AXIS_IS_TMC(W) + case W_AXIS: TMC_SET_CURRENT(W); break; + #endif #if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7) case E_AXIS: { @@ -181,6 +193,16 @@ void GcodeSuite::M906() { #if AXIS_IS_TMC(K) TMC_SAY_CURRENT(K); #endif + #if AXIS_IS_TMC(U) + TMC_SAY_CURRENT(U); + #endif + #if AXIS_IS_TMC(V) + TMC_SAY_CURRENT(V); + #endif + #if AXIS_IS_TMC(W) + TMC_SAY_CURRENT(W); + #endif + #if AXIS_IS_TMC(E0) TMC_SAY_CURRENT(E0); #endif @@ -217,7 +239,8 @@ void GcodeSuite::M906_report(const bool forReplay/*=true*/) { }; #if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) \ - || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) + || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) \ + || AXIS_IS_TMC(U) || AXIS_IS_TMC(V) || AXIS_IS_TMC(W) say_M906(forReplay); #if AXIS_IS_TMC(X) SERIAL_ECHOPGM_P(SP_X_STR, stepperX.getMilliamps()); @@ -237,6 +260,15 @@ void GcodeSuite::M906_report(const bool forReplay/*=true*/) { #if AXIS_IS_TMC(K) SERIAL_ECHOPGM_P(SP_K_STR, stepperK.getMilliamps()); #endif + #if AXIS_IS_TMC(U) + SERIAL_ECHOPGM_P(SP_U_STR, stepperU.getMilliamps()); + #endif + #if AXIS_IS_TMC(V) + SERIAL_ECHOPGM_P(SP_V_STR, stepperV.getMilliamps()); + #endif + #if AXIS_IS_TMC(W) + SERIAL_ECHOPGM_P(SP_W_STR, stepperW.getMilliamps()); + #endif SERIAL_EOL(); #endif diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 57a77c0e5d..206e2e456c 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -53,12 +53,21 @@ #if HAS_K_AXIS && M91x_USE(K) #define M91x_USE_K 1 #endif + #if HAS_U_AXIS && M91x_USE(U) + #define M91x_USE_U 1 + #endif + #if HAS_V_AXIS && M91x_USE(V) + #define M91x_USE_V 1 + #endif + #if HAS_W_AXIS && M91x_USE(W) + #define M91x_USE_W 1 + #endif #if M91x_USE_E(0) || M91x_USE_E(1) || M91x_USE_E(2) || M91x_USE_E(3) || M91x_USE_E(4) || M91x_USE_E(5) || M91x_USE_E(6) || M91x_USE_E(7) #define M91x_SOME_E 1 #endif - #if !M91x_SOME_X && !M91x_SOME_Y && !M91x_SOME_Z && !M91x_USE_I && !M91x_USE_J && !M91x_USE_K && !M91x_SOME_E + #if !M91x_SOME_X && !M91x_SOME_Y && !M91x_SOME_Z && !M91x_USE_I && !M91x_USE_J && !M91x_USE_K && !M91x_USE_U && !M91x_USE_V && !M91x_USE_W && !M91x_SOME_E #error "MONITOR_DRIVER_STATUS requires at least one TMC2130, 2160, 2208, 2209, 2660, 5130, or 5160." #endif @@ -109,6 +118,9 @@ TERN_(M91x_USE_I, tmc_report_otpw(stepperI)); TERN_(M91x_USE_J, tmc_report_otpw(stepperJ)); TERN_(M91x_USE_K, tmc_report_otpw(stepperK)); + TERN_(M91x_USE_U, tmc_report_otpw(stepperU)); + TERN_(M91x_USE_V, tmc_report_otpw(stepperV)); + TERN_(M91x_USE_W, tmc_report_otpw(stepperW)); #if M91x_USE_E(0) tmc_report_otpw(stepperE0); #endif @@ -137,7 +149,7 @@ /** * M912: Clear TMC stepper driver overtemperature pre-warn flag held by the library - * Specify one or more axes with X, Y, Z, X1, Y1, Z1, X2, Y2, Z2, Z3, Z4 and E[index]. + * Specify one or more axes with X, Y, Z, X1, Y1, Z1, X2, Y2, Z2, Z3, Z4, A, B, C, U, V, W, and E[index]. * If no axes are given, clear all. * * Examples: @@ -154,9 +166,12 @@ hasI = TERN0(M91x_USE_I, parser.seen(axis_codes.i)), hasJ = TERN0(M91x_USE_J, parser.seen(axis_codes.j)), hasK = TERN0(M91x_USE_K, parser.seen(axis_codes.k)), + hasU = TERN0(M91x_USE_U, parser.seen(axis_codes.u)), + hasV = TERN0(M91x_USE_V, parser.seen(axis_codes.v)), + hasW = TERN0(M91x_USE_W, parser.seen(axis_codes.w)), hasE = TERN0(M91x_SOME_E, parser.seen(axis_codes.e)); - const bool hasNone = !hasE && !hasX && !hasY && !hasZ && !hasI && !hasJ && !hasK; + const bool hasNone = !hasE && !hasX && !hasY && !hasZ && !hasI && !hasJ && !hasK && !hasU && !hasV && !hasW; #if M91x_SOME_X const int8_t xval = int8_t(parser.byteval(axis_codes.x, 0xFF)); @@ -206,6 +221,18 @@ const int8_t kval = int8_t(parser.byteval(axis_codes.k, 0xFF)); if (hasNone || kval == 1 || (hasK && kval < 0)) tmc_clear_otpw(stepperK); #endif + #if M91x_USE_U + const int8_t uval = int8_t(parser.byteval(axis_codes.u, 0xFF)); + if (hasNone || uval == 1 || (hasU && uval < 0)) tmc_clear_otpw(stepperU); + #endif + #if M91x_USE_V + const int8_t vval = int8_t(parser.byteval(axis_codes.v, 0xFF)); + if (hasNone || vval == 1 || (hasV && vval < 0)) tmc_clear_otpw(stepperV); + #endif + #if M91x_USE_W + const int8_t wval = int8_t(parser.byteval(axis_codes.w, 0xFF)); + if (hasNone || wval == 1 || (hasW && wval < 0)) tmc_clear_otpw(stepperW); + #endif #if M91x_SOME_E const int8_t eval = int8_t(parser.byteval(axis_codes.e, 0xFF)); @@ -296,6 +323,15 @@ #if K_HAS_STEALTHCHOP case K_AXIS: TMC_SET_PWMTHRS(K,K); break; #endif + #if U_HAS_STEALTHCHOP + case U_AXIS: TMC_SET_PWMTHRS(U,U); break; + #endif + #if V_HAS_STEALTHCHOP + case V_AXIS: TMC_SET_PWMTHRS(V,V); break; + #endif + #if W_HAS_STEALTHCHOP + case W_AXIS: TMC_SET_PWMTHRS(W,W); break; + #endif #if E0_HAS_STEALTHCHOP || E1_HAS_STEALTHCHOP || E2_HAS_STEALTHCHOP || E3_HAS_STEALTHCHOP || E4_HAS_STEALTHCHOP || E5_HAS_STEALTHCHOP || E6_HAS_STEALTHCHOP || E7_HAS_STEALTHCHOP case E_AXIS: { @@ -326,6 +362,9 @@ TERN_( I_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS(I,I)); TERN_( J_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS(J,J)); TERN_( K_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS(K,K)); + TERN_( U_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS(U,U)); + TERN_( V_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS(V,V)); + TERN_( W_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS(W,W)); TERN_(E0_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS_E(0)); TERN_(E1_HAS_STEALTHCHOP, TMC_SAY_PWMTHRS_E(1)); @@ -397,6 +436,18 @@ say_M913(forReplay); SERIAL_ECHOLNPGM_P(SP_K_STR, stepperK.get_pwm_thrs()); #endif + #if U_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPGM_P(SP_U_STR, stepperU.get_pwm_thrs()); + #endif + #if V_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPGM_P(SP_V_STR, stepperV.get_pwm_thrs()); + #endif + #if W_HAS_STEALTHCHOP + say_M913(forReplay); + SERIAL_ECHOLNPGM_P(SP_W_STR, stepperW.get_pwm_thrs()); + #endif #if E0_HAS_STEALTHCHOP say_M913(forReplay); @@ -451,7 +502,7 @@ bool report = true; const uint8_t index = parser.byteval('I'); - LOOP_LINEAR_AXES(i) if (parser.seen(AXIS_CHAR(i))) { + LOOP_NUM_AXES(i) if (parser.seen(AXIS_CHAR(i))) { const int16_t value = parser.value_int(); report = false; switch (i) { @@ -484,6 +535,15 @@ #if K_SENSORLESS case K_AXIS: stepperK.homing_threshold(value); break; #endif + #if U_SENSORLESS && AXIS_HAS_STALLGUARD(U) + case U_AXIS: stepperU.homing_threshold(value); break; + #endif + #if V_SENSORLESS && AXIS_HAS_STALLGUARD(V) + case V_AXIS: stepperV.homing_threshold(value); break; + #endif + #if W_SENSORLESS && AXIS_HAS_STALLGUARD(W) + case W_AXIS: stepperW.homing_threshold(value); break; + #endif } } @@ -499,6 +559,9 @@ TERN_(I_SENSORLESS, tmc_print_sgt(stepperI)); TERN_(J_SENSORLESS, tmc_print_sgt(stepperJ)); TERN_(K_SENSORLESS, tmc_print_sgt(stepperK)); + TERN_(U_SENSORLESS, tmc_print_sgt(stepperU)); + TERN_(V_SENSORLESS, tmc_print_sgt(stepperV)); + TERN_(W_SENSORLESS, tmc_print_sgt(stepperW)); } } @@ -561,6 +624,18 @@ say_M914(forReplay); SERIAL_ECHOLNPGM_P(SP_K_STR, stepperK.homing_threshold()); #endif + #if U_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOLNPGM_P(SP_U_STR, stepperU.homing_threshold()); + #endif + #if V_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOLNPGM_P(SP_V_STR, stepperV.homing_threshold()); + #endif + #if W_SENSORLESS + say_M914(forReplay); + SERIAL_ECHOLNPGM_P(SP_W_STR, stepperW.homing_threshold()); + #endif } #endif // USE_SENSORLESS diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index c365f8a67b..9d225cef51 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -85,7 +85,10 @@ axis_bits_t GcodeSuite::axis_relative = 0 LOGICAL_AXIS_GANG( | (ar_init.z << REL_Z), | (ar_init.i << REL_I), | (ar_init.j << REL_J), - | (ar_init.k << REL_K) + | (ar_init.k << REL_K), + | (ar_init.u << REL_U), + | (ar_init.v << REL_V), + | (ar_init.w << REL_W) ); #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) @@ -176,7 +179,7 @@ void GcodeSuite::get_destination_from_command() { #endif // Get new XYZ position, whether absolute or relative - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { if ( (seen[i] = parser.seenval(AXIS_CHAR(i))) ) { const float v = parser.value_axis_units((AxisEnum)i); if (skip_move) diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 61fe6cb9d9..3ec27710b4 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -337,7 +337,7 @@ #endif enum AxisRelative : uint8_t { - LOGICAL_AXIS_LIST(REL_E, REL_X, REL_Y, REL_Z, REL_I, REL_J, REL_K) + LOGICAL_AXIS_LIST(REL_E, REL_X, REL_Y, REL_Z, REL_I, REL_J, REL_K, REL_U, REL_V, REL_W) #if HAS_EXTRUDERS , E_MODE_ABS, E_MODE_REL #endif @@ -363,7 +363,8 @@ public: axis_relative = rel ? (0 LOGICAL_AXIS_GANG( | _BV(REL_E), | _BV(REL_X), | _BV(REL_Y), | _BV(REL_Z), - | _BV(REL_I), | _BV(REL_J), | _BV(REL_K) + | _BV(REL_I), | _BV(REL_J), | _BV(REL_K), + | _BV(REL_U), | _BV(REL_V), | _BV(REL_W) )) : 0; } #if HAS_EXTRUDERS diff --git a/Marlin/src/gcode/geometry/G53-G59.cpp b/Marlin/src/gcode/geometry/G53-G59.cpp index db2404a28d..092c141228 100644 --- a/Marlin/src/gcode/geometry/G53-G59.cpp +++ b/Marlin/src/gcode/geometry/G53-G59.cpp @@ -39,7 +39,7 @@ bool GcodeSuite::select_coordinate_system(const int8_t _new) { xyz_float_t new_offset{0}; if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1)) new_offset = coordinate_system[_new]; - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { if (position_shift[i] != new_offset[i]) { position_shift[i] = new_offset[i]; update_workspace_offset((AxisEnum)i); diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index 3c49fe2a26..2407599239 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -29,7 +29,7 @@ #endif /** - * G92: Set the Current Position to the given X [Y [Z [A [B [C [E]]]]]] values. + * G92: Set the Current Position to the given X [Y [Z [A [B [C [U [V [W ]]]]]]]] [E] values. * * Behind the scenes the G92 command may modify the Current Position * or the Position Shift depending on settings and sub-commands. @@ -37,14 +37,14 @@ * Since E has no Workspace Offset, it is always set directly. * * Without Workspace Offsets (e.g., with NO_WORKSPACE_OFFSETS): - * G92 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [E]]]]]]. + * G92 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [U [V [W ]]]]]]]] [E]. * * Using Workspace Offsets (default Marlin behavior): - * G92 : Modify Workspace Offsets so the reported position shows the given X [Y [Z [A [B [C [E]]]]]]. + * G92 : Modify Workspace Offsets so the reported position shows the given X [Y [Z [A [B [C [U [V [W ]]]]]]]] [E]. * G92.1 : Zero XYZ Workspace Offsets (so the reported position = the native position). * * With POWER_LOSS_RECOVERY: - * G92.9 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [E]]]]]]. + * G92.9 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [U [V [W ]]]]]]]] [E]. */ void GcodeSuite::G92() { @@ -64,7 +64,7 @@ void GcodeSuite::G92() { #if ENABLED(CNC_COORDINATE_SYSTEMS) && !IS_SCARA case 1: // G92.1 - Zero the Workspace Offset - LOOP_LINEAR_AXES(i) if (position_shift[i]) { + LOOP_NUM_AXES(i) if (position_shift[i]) { position_shift[i] = 0; update_workspace_offset((AxisEnum)i); } diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index b32d729969..f23c83140e 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -39,11 +39,17 @@ */ void GcodeSuite::M206() { if (!parser.seen_any()) return M206_report(); - - LOOP_LINEAR_AXES(i) - if (parser.seen(AXIS_CHAR(i))) - set_home_offset((AxisEnum)i, parser.value_linear_units()); - + NUM_AXIS_CODE( + if (parser.seen('X')) set_home_offset(X_AXIS, parser.value_linear_units()), + if (parser.seen('Y')) set_home_offset(Y_AXIS, parser.value_linear_units()), + if (parser.seen('Z')) set_home_offset(Y_AXIS, parser.value_linear_units()), + if (parser.seen(AXIS4_NAME)) set_home_offset(I_AXIS, parser.TERN(AXIS4_ROTATES, value_float, value_linear_units)()), + if (parser.seen(AXIS5_NAME)) set_home_offset(J_AXIS, parser.TERN(AXIS5_ROTATES, value_float, value_linear_units)()), + if (parser.seen(AXIS6_NAME)) set_home_offset(K_AXIS, parser.TERN(AXIS6_ROTATES, value_float, value_linear_units)()), + if (parser.seen(AXIS7_NAME)) set_home_offset(U_AXIS, parser.TERN(AXIS7_ROTATES, value_float, value_linear_units)()), + if (parser.seen(AXIS8_NAME)) set_home_offset(V_AXIS, parser.TERN(AXIS8_ROTATES, value_float, value_linear_units)()), + if (parser.seen(AXIS9_NAME)) set_home_offset(W_AXIS, parser.TERN(AXIS9_ROTATES, value_float, value_linear_units)()) + ); #if ENABLED(MORGAN_SCARA) if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi @@ -56,13 +62,16 @@ void GcodeSuite::M206_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_HOME_OFFSET)); SERIAL_ECHOLNPGM_P( #if IS_CARTESIAN - LIST_N(DOUBLE(LINEAR_AXES), + LIST_N(DOUBLE(NUM_AXES), PSTR(" M206 X"), LINEAR_UNIT(home_offset.x), SP_Y_STR, LINEAR_UNIT(home_offset.y), SP_Z_STR, LINEAR_UNIT(home_offset.z), - SP_I_STR, LINEAR_UNIT(home_offset.i), - SP_J_STR, LINEAR_UNIT(home_offset.j), - SP_K_STR, LINEAR_UNIT(home_offset.k) + SP_I_STR, I_AXIS_UNIT(home_offset.i), + SP_J_STR, J_AXIS_UNIT(home_offset.j), + SP_K_STR, K_AXIS_UNIT(home_offset.k), + SP_U_STR, U_AXIS_UNIT(home_offset.u), + SP_V_STR, V_AXIS_UNIT(home_offset.v), + SP_W_STR, W_AXIS_UNIT(home_offset.w) ) #else PSTR(" M206 Z"), LINEAR_UNIT(home_offset.z) @@ -85,7 +94,7 @@ void GcodeSuite::M428() { if (homing_needed_error()) return; xyz_float_t diff; - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { diff[i] = base_home_pos((AxisEnum)i) - current_position[i]; if (!WITHIN(diff[i], -20, 20) && home_dir((AxisEnum)i) > 0) diff[i] = -current_position[i]; @@ -97,7 +106,7 @@ void GcodeSuite::M428() { } } - LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]); + LOOP_NUM_AXES(i) set_home_offset((AxisEnum)i, diff[i]); report_current_position(); LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED); OKAY_BUZZ(); diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index cdb9efb71b..41433b510d 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -47,7 +47,7 @@ void report_linear_axis_pos(const xyz_pos_t &pos, const uint8_t precision=3) { char str[12]; - LOOP_LINEAR_AXES(a) { + LOOP_NUM_AXES(a) { SERIAL_CHAR(' ', AXIS_CHAR(a), ':'); SERIAL_ECHO(dtostrf(pos[a], 1, precision, str)); } @@ -134,6 +134,15 @@ #if AXIS_IS_L64XX(K) REPORT_ABSOLUTE_POS(K); #endif + #if AXIS_IS_L64XX(U) + REPORT_ABSOLUTE_POS(U); + #endif + #if AXIS_IS_L64XX(V) + REPORT_ABSOLUTE_POS(V); + #endif + #if AXIS_IS_L64XX(W) + REPORT_ABSOLUTE_POS(W); + #endif #if AXIS_IS_L64XX(E0) REPORT_ABSOLUTE_POS(E0); #endif @@ -184,7 +193,10 @@ cartes.x, cartes.y, cartes.z, planner.get_axis_position_mm(I_AXIS), planner.get_axis_position_mm(J_AXIS), - planner.get_axis_position_mm(K_AXIS) + planner.get_axis_position_mm(K_AXIS), + planner.get_axis_position_mm(U_AXIS), + planner.get_axis_position_mm(V_AXIS), + planner.get_axis_position_mm(W_AXIS) ); report_all_axis_pos(from_steppers); diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 36731c23da..d38bd6612d 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -65,8 +65,8 @@ void GcodeSuite::M115() { "PROTOCOL_VERSION:" PROTOCOL_VERSION " " "MACHINE_TYPE:" MACHINE_NAME " " "EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " " - #if LINEAR_AXES != XYZ - "AXIS_COUNT:" STRINGIFY(LINEAR_AXES) " " + #if NUM_AXES != XYZ + "AXIS_COUNT:" STRINGIFY(NUM_AXES) " " #endif #ifdef MACHINE_UUID "UUID:" MACHINE_UUID diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 493fd00da1..d647894d27 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -49,13 +49,16 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { if (IsRunning() #if ENABLED(NO_MOTION_BEFORE_HOMING) && !homing_needed_error( - LINEAR_AXIS_GANG( + NUM_AXIS_GANG( (parser.seen_test('X') ? _BV(X_AXIS) : 0), | (parser.seen_test('Y') ? _BV(Y_AXIS) : 0), | (parser.seen_test('Z') ? _BV(Z_AXIS) : 0), | (parser.seen_test(AXIS4_NAME) ? _BV(I_AXIS) : 0), | (parser.seen_test(AXIS5_NAME) ? _BV(J_AXIS) : 0), - | (parser.seen_test(AXIS6_NAME) ? _BV(K_AXIS) : 0)) + | (parser.seen_test(AXIS6_NAME) ? _BV(K_AXIS) : 0), + | (parser.seen_test(AXIS7_NAME) ? _BV(U_AXIS) : 0), + | (parser.seen_test(AXIS8_NAME) ? _BV(V_AXIS) : 0), + | (parser.seen_test(AXIS9_NAME) ? _BV(W_AXIS) : 0)) ) #endif ) { @@ -89,7 +92,7 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { if (MIN_AUTORETRACT <= MAX_AUTORETRACT) { // When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves if (fwretract.autoretract_enabled && parser.seen_test('E') - && !parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K)) + && !parser.seen(NUM_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K, STR_U, STR_V, STR_W)) ) { const float echange = destination.e - current_position.e; // Is this a retract or recover move? diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index 0c7bdc7a3a..dd1c1d1470 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -48,8 +48,8 @@ #define MIN_ARC_SEGMENT_MM MAX_ARC_SEGMENT_MM #endif -#define ARC_LIJK_CODE(L,I,J,K) CODE_N(SUB2(LINEAR_AXES),L,I,J,K) -#define ARC_LIJKE_CODE(L,I,J,K,E) ARC_LIJK_CODE(L,I,J,K); CODE_ITEM_E(E) +#define ARC_LIJKUVW_CODE(L,I,J,K,U,V,W) CODE_N(SUB2(NUM_AXES),L,I,J,K,U,V,W) +#define ARC_LIJKUVWE_CODE(L,I,J,K,U,V,W,E) ARC_LIJKUVW_CODE(L,I,J,K,U,V,W); CODE_ITEM_E(E) /** * Plan an arc in 2 dimensions, with linear motion in the other axes. @@ -82,11 +82,14 @@ void plan_arc( rt_X = cart[axis_p] - center_P, rt_Y = cart[axis_q] - center_Q; - ARC_LIJK_CODE( + ARC_LIJKUVW_CODE( const float start_L = current_position[axis_l], const float start_I = current_position.i, const float start_J = current_position.j, - const float start_K = current_position.k + const float start_K = current_position.k, + const float start_U = current_position.u, + const float start_V = current_position.v, + const float start_W = current_position.w ); // Angle of rotation between position and target from the circle center. @@ -122,11 +125,14 @@ void plan_arc( min_segments = CEIL((MIN_CIRCLE_SEGMENTS) * portion_of_circle); // Minimum segments for the arc } - ARC_LIJKE_CODE( + ARC_LIJKUVWE_CODE( float travel_L = cart[axis_l] - start_L, float travel_I = cart.i - start_I, float travel_J = cart.j - start_J, float travel_K = cart.k - start_K, + float travel_U = cart.u - start_U, + float travel_V = cart.v - start_V, + float travel_W = cart.w - start_W, float travel_E = cart.e - current_position.e ); @@ -135,30 +141,39 @@ void plan_arc( const float total_angular = abs_angular_travel + circles * RADIANS(360), // Total rotation with all circles and remainder part_per_circle = RADIANS(360) / total_angular; // Each circle's part of the total - ARC_LIJKE_CODE( + ARC_LIJKUVWE_CODE( const float per_circle_L = travel_L * part_per_circle, // L movement per circle const float per_circle_I = travel_I * part_per_circle, const float per_circle_J = travel_J * part_per_circle, const float per_circle_K = travel_K * part_per_circle, + const float per_circle_U = travel_U * part_per_circle, + const float per_circle_V = travel_V * part_per_circle, + const float per_circle_W = travel_W * part_per_circle, const float per_circle_E = travel_E * part_per_circle // E movement per circle ); xyze_pos_t temp_position = current_position; for (uint16_t n = circles; n--;) { - ARC_LIJKE_CODE( // Destination Linear Axes + ARC_LIJKUVWE_CODE( // Destination Linear Axes temp_position[axis_l] += per_circle_L, temp_position.i += per_circle_I, temp_position.j += per_circle_J, temp_position.k += per_circle_K, + temp_position.u += per_circle_U, + temp_position.v += per_circle_V, + temp_position.w += per_circle_W, temp_position.e += per_circle_E // Destination E axis ); plan_arc(temp_position, offset, clockwise, 0); // Plan a single whole circle } - ARC_LIJKE_CODE( + ARC_LIJKUVWE_CODE( travel_L = cart[axis_l] - current_position[axis_l], travel_I = cart.i - current_position.i, travel_J = cart.j - current_position.j, travel_K = cart.k - current_position.k, + travel_U = cart.u - current_position.u, + travel_V = cart.v - current_position.v, + travel_W = cart.w - current_position.w, travel_E = cart.e - current_position.e ); } @@ -168,11 +183,14 @@ void plan_arc( // Return if the move is near zero if (flat_mm < 0.0001f - GANG_N(SUB2(LINEAR_AXES), + GANG_N(SUB2(NUM_AXES), && travel_L < 0.0001f, && travel_I < 0.0001f, && travel_J < 0.0001f, - && travel_K < 0.0001f + && travel_K < 0.0001f, + && travel_U < 0.0001f, + && travel_V < 0.0001f, + && travel_W < 0.0001f ) ) return; @@ -236,11 +254,14 @@ void plan_arc( cos_T = 1 - 0.5f * sq_theta_per_segment; // Small angle approximation #if DISABLED(AUTO_BED_LEVELING_UBL) - ARC_LIJK_CODE( + ARC_LIJKUVW_CODE( const float per_segment_L = proportion * travel_L / segments, const float per_segment_I = proportion * travel_I / segments, const float per_segment_J = proportion * travel_J / segments, - const float per_segment_K = proportion * travel_K / segments + const float per_segment_K = proportion * travel_K / segments, + const float per_segment_U = proportion * travel_U / segments, + const float per_segment_V = proportion * travel_V / segments, + const float per_segment_W = proportion * travel_W / segments ); #endif @@ -250,11 +271,14 @@ void plan_arc( if (tooshort) segments++; // Initialize all linear axes and E - ARC_LIJKE_CODE( + ARC_LIJKUVWE_CODE( raw[axis_l] = current_position[axis_l], raw.i = current_position.i, raw.j = current_position.j, raw.k = current_position.k, + raw.u = current_position.u, + raw.v = current_position.v, + raw.w = current_position.w, raw.e = current_position.e ); @@ -303,11 +327,15 @@ void plan_arc( // Update raw location raw[axis_p] = center_P + rvec.a; raw[axis_q] = center_Q + rvec.b; - ARC_LIJKE_CODE( + ARC_LIJKUVWE_CODE( #if ENABLED(AUTO_BED_LEVELING_UBL) - raw[axis_l] = start_L, raw.i = start_I, raw.j = start_J, raw.k = start_K + raw[axis_l] = start_L, + raw.i = start_I, raw.j = start_J, raw.k = start_K, + raw.u = start_U, raw.v = start_V, raw.w = start_V #else - raw[axis_l] += per_segment_L, raw.i += per_segment_I, raw.j += per_segment_J, raw.k += per_segment_K + raw[axis_l] += per_segment_L, + raw.i += per_segment_I, raw.j += per_segment_J, raw.k += per_segment_K, + raw.u += per_segment_U, raw.v += per_segment_V, raw.w += per_segment_W #endif , raw.e += extruder_per_segment ); @@ -325,7 +353,11 @@ void plan_arc( // Ensure last segment arrives at target location. raw = cart; #if ENABLED(AUTO_BED_LEVELING_UBL) - ARC_LIJK_CODE(raw[axis_l] = start_L, raw.i = start_I, raw.j = start_J, raw.k = start_K); + ARC_LIJKUVW_CODE( + raw[axis_l] = start_L, + raw.i = start_I, raw.j = start_J, raw.k = start_K, + raw.u = start_U, raw.v = start_V, raw.w = start_W + ); #endif apply_motion_limits(raw); @@ -337,7 +369,11 @@ void plan_arc( planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); #if ENABLED(AUTO_BED_LEVELING_UBL) - ARC_LIJK_CODE(raw[axis_l] = start_L, raw.i = start_I, raw.j = start_J, raw.k = start_K); + ARC_LIJKUVW_CODE( + raw[axis_l] = start_L, + raw.i = start_I, raw.j = start_J, raw.k = start_K, + raw.u = start_U, raw.v = start_V, raw.w = start_W + ); #endif current_position = raw; @@ -380,7 +416,7 @@ void GcodeSuite::G2_G3(const bool clockwise) { relative_mode = true; #endif - get_destination_from_command(); // Get X Y [Z[I[J[K]]]] [E] F (and set cutter power) + get_destination_from_command(); // Get X Y [Z[I[J[K...]]]] [E] F (and set cutter power) TERN_(SF_ARC_FIX, relative_mode = relative_mode_backup); diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index f3d7b7c8dc..8185bf8f78 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -69,7 +69,7 @@ */ void GcodeSuite::M290() { #if ENABLED(BABYSTEP_XY) - LOOP_LINEAR_AXES(a) + LOOP_NUM_AXES(a) if (parser.seenval(AXIS_CHAR(a)) || (a == Z_AXIS && parser.seenval('S'))) { const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2); babystep.add_mm((AxisEnum)a, offs); @@ -87,7 +87,7 @@ void GcodeSuite::M290() { } #endif - if (!parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K)) || parser.seen('R')) { + if (!parser.seen(NUM_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K, STR_U, STR_V, STR_W)) || parser.seen('R')) { SERIAL_ECHO_START(); #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 4d4fdae0d6..3fc1fc1625 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -248,7 +248,7 @@ void GCodeParser::parse(char *p) { case 'R': if (!WITHIN(motion_mode_codenum, 2, 3)) return; #endif - LOGICAL_AXIS_GANG(case 'E':, case 'X':, case 'Y':, case 'Z':, case AXIS4_NAME:, case AXIS5_NAME:, case AXIS6_NAME:) + LOGICAL_AXIS_GANG(case 'E':, case 'X':, case 'Y':, case 'Z':, case AXIS4_NAME:, case AXIS5_NAME:, case AXIS6_NAME:, case AXIS7_NAME:, case AXIS8_NAME:, case AXIS9_NAME:) case 'F': if (motion_mode_codenum < 0) return; command_letter = 'G'; diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 1487c083ec..c91a0de5f2 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -309,13 +309,18 @@ public: } static float axis_unit_factor(const AxisEnum axis) { - return ( - #if HAS_EXTRUDERS - axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor - #else - linear_unit_factor - #endif - ); + if (false + || TERN0(AXIS4_ROTATES, axis == I_AXIS) + || TERN0(AXIS5_ROTATES, axis == J_AXIS) + || TERN0(AXIS6_ROTATES, axis == K_AXIS) + || TERN0(AXIS7_ROTATES, axis == U_AXIS) + || TERN0(AXIS8_ROTATES, axis == V_AXIS) + || TERN0(AXIS9_ROTATES, axis == W_AXIS) + ) return 1.0f; + #if HAS_EXTRUDERS + if (axis >= E_AXIS && volumetric_enabled) return volumetric_unit_factor; + #endif + return linear_unit_factor; } static float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; } @@ -340,6 +345,13 @@ public: #define LINEAR_UNIT(V) parser.mm_to_linear_unit(V) #define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V) + #define I_AXIS_UNIT(V) TERN(AXIS4_ROTATES, (V), LINEAR_UNIT(V)) + #define J_AXIS_UNIT(V) TERN(AXIS5_ROTATES, (V), LINEAR_UNIT(V)) + #define K_AXIS_UNIT(V) TERN(AXIS6_ROTATES, (V), LINEAR_UNIT(V)) + #define U_AXIS_UNIT(V) TERN(AXIS7_ROTATES, (V), LINEAR_UNIT(V)) + #define V_AXIS_UNIT(V) TERN(AXIS8_ROTATES, (V), LINEAR_UNIT(V)) + #define W_AXIS_UNIT(V) TERN(AXIS9_ROTATES, (V), LINEAR_UNIT(V)) + static float value_linear_units() { return linear_value_to_mm(value_float()); } static float value_axis_units(const AxisEnum axis) { return axis_value_to_mm(axis, value_float()); } static float value_per_axis_units(const AxisEnum axis) { return per_axis_value(axis, value_float()); } diff --git a/Marlin/src/gcode/probe/G38.cpp b/Marlin/src/gcode/probe/G38.cpp index 6906805fca..ed24ce3258 100644 --- a/Marlin/src/gcode/probe/G38.cpp +++ b/Marlin/src/gcode/probe/G38.cpp @@ -49,7 +49,7 @@ inline bool G38_run_probe() { #if MULTIPLE_PROBING > 1 // Get direction of move and retract xyz_float_t retract_mm; - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { const float dist = destination[i] - current_position[i]; retract_mm[i] = ABS(dist) < G38_MINIMUM_MOVE ? 0 : home_bump_mm((AxisEnum)i) * (dist > 0 ? -1 : 1); } @@ -119,7 +119,7 @@ void GcodeSuite::G38(const int8_t subcode) { ; // If any axis has enough movement, do the move - LOOP_LINEAR_AXES(i) + LOOP_NUM_AXES(i) if (ABS(destination[i] - current_position[i]) >= G38_MINIMUM_MOVE) { if (!parser.seenval('F')) feedrate_mm_s = homing_feedrate((AxisEnum)i); // If G38.2 fails throw an error diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e7473420cf..5adc04fe2d 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -677,22 +677,31 @@ #endif /** - * Number of Linear Axes (e.g., XYZ) + * Number of Linear Axes (e.g., XYZIJKUVW) * All the logical axes except for the tool (E) axis */ -#ifndef LINEAR_AXES - #define LINEAR_AXES XYZ +#ifndef NUM_AXES + #define NUM_AXES XYZ #endif -#if LINEAR_AXES >= XY +#if NUM_AXES >= XY #define HAS_Y_AXIS 1 - #if LINEAR_AXES >= XYZ + #if NUM_AXES >= XYZ #define HAS_Z_AXIS 1 - #if LINEAR_AXES >= 4 + #if NUM_AXES >= 4 #define HAS_I_AXIS 1 - #if LINEAR_AXES >= 5 + #if NUM_AXES >= 5 #define HAS_J_AXIS 1 - #if LINEAR_AXES >= 6 + #if NUM_AXES >= 6 #define HAS_K_AXIS 1 + #if NUM_AXES >= 7 + #define HAS_U_AXIS 1 + #if NUM_AXES >= 8 + #define HAS_V_AXIS 1 + #if NUM_AXES >= 9 + #define HAS_W_AXIS 1 + #endif + #endif + #endif #endif #endif #endif @@ -700,14 +709,58 @@ #endif /** - * Number of Logical Axes (e.g., XYZE) - * All the logical axes that can be commanded directly by G-code. + * Number of Primary Linear Axes (e.g., XYZ) + * X, XY, or XYZ axes. Excluding duplicate axes (X2, Y2. Z2. Z3, Z4) + */ +#if HAS_I_AXIS + #define PRIMARY_LINEAR_AXES 3 +#else + #define PRIMARY_LINEAR_AXES NUM_AXES +#endif + +/** + * Number of Secondary Axes (e.g., IJKUVW) + * All linear/rotational axes between XYZ and E. + */ +#define SECONDARY_AXES SUB3(NUM_AXES) + +/** + * Number of Rotational Axes (e.g., IJK) + * All axes for which AXIS*_ROTATES is defined. + * For these axes, positions are specified in angular degrees. + */ +#if ENABLED(AXIS9_ROTATES) + #define ROTATIONAL_AXES 6 +#elif ENABLED(AXIS8_ROTATES) + #define ROTATIONAL_AXES 5 +#elif ENABLED(AXIS7_ROTATES) + #define ROTATIONAL_AXES 4 +#elif ENABLED(AXIS6_ROTATES) + #define ROTATIONAL_AXES 3 +#elif ENABLED(AXIS5_ROTATES) + #define ROTATIONAL_AXES 2 +#elif ENABLED(AXIS4_ROTATES) + #define ROTATIONAL_AXES 1 +#else + #define ROTATIONAL_AXES 0 +#endif + +/** + * Number of Secondary Linear Axes (e.g., UVW) + * All secondary axes for which AXIS*_ROTATES is not defined. + * Excluding primary axes and excluding duplicate axes (X2, Y2, Z2, Z3, Z4) + */ +#define SECONDARY_LINEAR_AXES (NUM_AXES - PRIMARY_LINEAR_AXES - ROTATIONAL_AXES) + +/** + * Number of Logical Axes (e.g., XYZIJKUVWE) + * All logical axes that can be commanded directly by G-code. * Delta maps stepper-specific values to ABC steppers. */ #if HAS_EXTRUDERS - #define LOGICAL_AXES INCREMENT(LINEAR_AXES) + #define LOGICAL_AXES INCREMENT(NUM_AXES) #else - #define LOGICAL_AXES LINEAR_AXES + #define LOGICAL_AXES NUM_AXES #endif /** @@ -725,7 +778,7 @@ * distinguished. */ #if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1 - #define DISTINCT_AXES (LINEAR_AXES + E_STEPPERS) + #define DISTINCT_AXES (NUM_AXES + E_STEPPERS) #define DISTINCT_E E_STEPPERS #define E_INDEX_N(E) (E) #else @@ -955,6 +1008,21 @@ #elif K_HOME_DIR < 0 #define K_HOME_TO_MIN 1 #endif +#if U_HOME_DIR > 0 + #define U_HOME_TO_MAX 1 +#elif U_HOME_DIR < 0 + #define U_HOME_TO_MIN 1 +#endif +#if V_HOME_DIR > 0 + #define V_HOME_TO_MAX 1 +#elif V_HOME_DIR < 0 + #define V_HOME_TO_MIN 1 +#endif +#if W_HOME_DIR > 0 + #define W_HOME_TO_MAX 1 +#elif W_HOME_DIR < 0 + #define W_HOME_TO_MIN 1 +#endif /** * Conditionals based on the type of Bed Probe @@ -1228,6 +1296,15 @@ #if HAS_K_AXIS && !defined(INVERT_K_DIR) #define INVERT_K_DIR false #endif +#if HAS_U_AXIS && !defined(INVERT_U_DIR) + #define INVERT_U_DIR false +#endif +#if HAS_V_AXIS && !defined(INVERT_V_DIR) + #define INVERT_V_DIR false +#endif +#if HAS_W_AXIS && !defined(INVERT_W_DIR) + #define INVERT_W_DIR false +#endif #if HAS_EXTRUDERS && !defined(INVERT_E_DIR) #define INVERT_E_DIR false #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 8a85536aea..ace946d766 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -914,30 +914,45 @@ #endif // Remove unused STEALTHCHOP flags -#if LINEAR_AXES < 6 - #undef STEALTHCHOP_K - #undef CALIBRATION_MEASURE_KMIN - #undef CALIBRATION_MEASURE_KMAX - #if LINEAR_AXES < 5 - #undef STEALTHCHOP_J - #undef CALIBRATION_MEASURE_JMIN - #undef CALIBRATION_MEASURE_JMAX - #if LINEAR_AXES < 4 - #undef STEALTHCHOP_I - #undef CALIBRATION_MEASURE_IMIN - #undef CALIBRATION_MEASURE_IMAX - #if LINEAR_AXES < 3 - #undef Z_IDLE_HEIGHT - #undef STEALTHCHOP_Z - #undef Z_PROBE_SLED - #undef Z_SAFE_HOMING - #undef HOME_Z_FIRST - #undef HOMING_Z_WITH_PROBE - #undef ENABLE_LEVELING_FADE_HEIGHT - #undef NUM_Z_STEPPER_DRIVERS - #undef CNC_WORKSPACE_PLANES - #if LINEAR_AXES < 2 - #undef STEALTHCHOP_Y +#if NUM_AXES < 9 + #undef STEALTHCHOP_W + #undef CALIBRATION_MEASURE_WMIN + #undef CALIBRATION_MEASURE_WMAX + #if NUM_AXES < 8 + #undef STEALTHCHOP_V + #undef CALIBRATION_MEASURE_VMIN + #undef CALIBRATION_MEASURE_VMAX + #if NUM_AXES < 7 + #undef STEALTHCHOP_U + #undef CALIBRATION_MEASURE_UMIN + #undef CALIBRATION_MEASURE_UMAX + #if NUM_AXES < 6 + #undef STEALTHCHOP_K + #undef CALIBRATION_MEASURE_KMIN + #undef CALIBRATION_MEASURE_KMAX + #if NUM_AXES < 5 + #undef STEALTHCHOP_J + #undef CALIBRATION_MEASURE_JMIN + #undef CALIBRATION_MEASURE_JMAX + #if NUM_AXES < 4 + #undef STEALTHCHOP_I + #undef CALIBRATION_MEASURE_IMIN + #undef CALIBRATION_MEASURE_IMAX + #if NUM_AXES < 3 + #undef Z_IDLE_HEIGHT + #undef STEALTHCHOP_Z + #undef Z_PROBE_SLED + #undef Z_SAFE_HOMING + #undef HOME_Z_FIRST + #undef HOMING_Z_WITH_PROBE + #undef ENABLE_LEVELING_FADE_HEIGHT + #undef NUM_Z_STEPPER_DRIVERS + #undef CNC_WORKSPACE_PLANES + #if NUM_AXES < 2 + #undef STEALTHCHOP_Y + #endif + #endif + #endif #endif #endif #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 85ccb8088e..ada2a512b5 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -87,6 +87,19 @@ #if HAS_K_AXIS && !defined(AXIS6_NAME) #define AXIS6_NAME 'C' #endif +#if HAS_U_AXIS && !defined(AXIS7_NAME) + #define AXIS7_NAME 'U' +#endif +#if HAS_V_AXIS && !defined(AXIS8_NAME) + #define AXIS8_NAME 'V' +#endif +#if HAS_W_AXIS && !defined(AXIS9_NAME) + #define AXIS9_NAME 'W' +#endif + +#if ANY(AXIS4_ROTATES, AXIS5_ROTATES, AXIS6_ROTATES, AXIS7_ROTATES, AXIS8_ROTATES, AXIS9_ROTATES) + #define HAS_ROTATIONAL_AXES 1 +#endif #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS)) #if HAS_Y_AXIS @@ -106,6 +119,15 @@ #if HAS_K_AXIS #define K_MAX_LENGTH (K_MAX_POS - (K_MIN_POS)) #endif +#if HAS_U_AXIS + #define U_MAX_LENGTH (U_MAX_POS - (U_MIN_POS)) +#endif +#if HAS_V_AXIS + #define V_MAX_LENGTH (V_MAX_POS - (V_MIN_POS)) +#endif +#if HAS_W_AXIS + #define W_MAX_LENGTH (W_MAX_POS - (W_MIN_POS)) +#endif // Defined only if the sanity-check is bypassed #ifndef X_BED_SIZE @@ -123,6 +145,15 @@ #if HAS_K_AXIS && !defined(K_BED_SIZE) #define K_BED_SIZE K_MAX_LENGTH #endif +#if HAS_U_AXIS && !defined(U_BED_SIZE) + #define U_BED_SIZE U_MAX_LENGTH +#endif +#if HAS_V_AXIS && !defined(V_BED_SIZE) + #define V_BED_SIZE V_MAX_LENGTH +#endif +#if HAS_W_AXIS && !defined(W_BED_SIZE) + #define W_BED_SIZE W_MAX_LENGTH +#endif // Require 0,0 bed center for Delta and SCARA #if IS_KINEMATIC @@ -143,6 +174,15 @@ #if HAS_K_AXIS #define _K_HALF_KMAX ((K_BED_SIZE) / 2) #endif +#if HAS_U_AXIS + #define _U_HALF_UMAX ((U_BED_SIZE) / 2) +#endif +#if HAS_V_AXIS + #define _V_HALF_VMAX ((V_BED_SIZE) / 2) +#endif +#if HAS_W_AXIS + #define _W_HALF_WMAX ((W_BED_SIZE) / 2) +#endif #define X_CENTER TERN(BED_CENTER_AT_0_0, 0, _X_HALF_BED) #if HAS_Y_AXIS @@ -158,6 +198,15 @@ #if HAS_K_AXIS #define K_CENTER TERN(BED_CENTER_AT_0_0, 0, _K_HALF_BED) #endif +#if HAS_U_AXIS + #define U_CENTER TERN(BED_CENTER_AT_0_0, 0, _U_HALF_BED) +#endif +#if HAS_V_AXIS + #define V_CENTER TERN(BED_CENTER_AT_0_0, 0, _V_HALF_BED) +#endif +#if HAS_W_AXIS + #define W_CENTER TERN(BED_CENTER_AT_0_0, 0, _W_HALF_BED) +#endif // Get the linear boundaries of the bed #define X_MIN_BED (X_CENTER - _X_HALF_BED) @@ -178,6 +227,18 @@ #define K_MINIM (K_CENTER - _K_HALF_BED_SIZE) #define K_MAXIM (K_MINIM + K_BED_SIZE) #endif +#if HAS_U_AXIS + #define U_MINIM (U_CENTER - _U_HALF_BED_SIZE) + #define U_MAXIM (U_MINIM + U_BED_SIZE) +#endif +#if HAS_V_AXIS + #define V_MINIM (V_CENTER - _V_HALF_BED_SIZE) + #define V_MAXIM (V_MINIM + V_BED_SIZE) +#endif +#if HAS_W_AXIS + #define W_MINIM (W_CENTER - _W_HALF_BED_SIZE) + #define W_MAXIM (W_MINIM + W_BED_SIZE) +#endif /** * Dual X Carriage @@ -274,6 +335,27 @@ #define K_HOME_POS TERN(K_HOME_TO_MIN, K_MIN_POS, K_MAX_POS) #endif #endif +#if HAS_U_AXIS + #ifdef MANUAL_U_HOME_POS + #define U_HOME_POS MANUAL_U_HOME_POS + #else + #define U_HOME_POS (U_HOME_DIR < 0 ? U_MIN_POS : U_MAX_POS) + #endif +#endif +#if HAS_V_AXIS + #ifdef MANUAL_V_HOME_POS + #define V_HOME_POS MANUAL_V_HOME_POS + #else + #define V_HOME_POS (V_HOME_DIR < 0 ? V_MIN_POS : V_MAX_POS) + #endif +#endif +#if HAS_W_AXIS + #ifdef MANUAL_W_HOME_POS + #define W_HOME_POS MANUAL_W_HOME_POS + #else + #define W_HOME_POS (W_HOME_DIR < 0 ? W_MIN_POS : W_MAX_POS) + #endif +#endif /** * If DELTA_HEIGHT isn't defined use the old setting @@ -1440,6 +1522,15 @@ #if ENABLED(USE_KMAX_PLUG) #define ENDSTOPPULLUP_KMAX #endif + #if ENABLED(USE_UMAX_PLUG) + #define ENDSTOPPULLUP_UMAX + #endif + #if ENABLED(USE_VMAX_PLUG) + #define ENDSTOPPULLUP_VMAX + #endif + #if ENABLED(USE_WMAX_PLUG) + #define ENDSTOPPULLUP_WMAX + #endif #if ENABLED(USE_XMIN_PLUG) #define ENDSTOPPULLUP_XMIN #endif @@ -1458,6 +1549,15 @@ #if ENABLED(USE_KMIN_PLUG) #define ENDSTOPPULLUP_KMIN #endif + #if ENABLED(USE_UMIN_PLUG) + #define ENDSTOPPULLUP_UMIN + #endif + #if ENABLED(USE_VMIN_PLUG) + #define ENDSTOPPULLUP_VMIN + #endif + #if ENABLED(USE_WMIN_PLUG) + #define ENDSTOPPULLUP_WMIN + #endif #endif /** @@ -1680,6 +1780,66 @@ #undef DISABLE_INACTIVE_K #endif +#if HAS_U_AXIS + #if PIN_EXISTS(U_ENABLE) || AXIS_IS_L64XX(U) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U)) + #define HAS_U_ENABLE 1 + #endif + #if PIN_EXISTS(U_DIR) + #define HAS_U_DIR 1 + #endif + #if PIN_EXISTS(U_STEP) + #define HAS_U_STEP 1 + #endif + #if PIN_EXISTS(U_MS1) + #define HAS_U_MS_PINS 1 + #endif + #if !defined(DISABLE_INACTIVE_U) && ENABLED(DISABLE_U) + #define DISABLE_INACTIVE_U 1 + #endif +#else + #undef DISABLE_INACTIVE_U +#endif + +#if HAS_V_AXIS + #if PIN_EXISTS(V_ENABLE) || AXIS_IS_L64XX(V) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V)) + #define HAS_V_ENABLE 1 + #endif + #if PIN_EXISTS(V_DIR) + #define HAS_V_DIR 1 + #endif + #if PIN_EXISTS(V_STEP) + #define HAS_V_STEP 1 + #endif + #if PIN_EXISTS(V_MS1) + #define HAS_V_MS_PINS 1 + #endif + #if !defined(DISABLE_INACTIVE_V) && ENABLED(DISABLE_V) + #define DISABLE_INACTIVE_V 1 + #endif +#else + #undef DISABLE_INACTIVE_V +#endif + +#if HAS_W_AXIS + #if PIN_EXISTS(W_ENABLE) || AXIS_IS_L64XX(W) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W)) + #define HAS_W_ENABLE 1 + #endif + #if PIN_EXISTS(W_DIR) + #define HAS_W_DIR 1 + #endif + #if PIN_EXISTS(W_STEP) + #define HAS_W_STEP 1 + #endif + #if PIN_EXISTS(W_MS1) + #define HAS_W_MS_PINS 1 + #endif + #if !defined(DISABLE_INACTIVE_W) && ENABLED(DISABLE_W) + #define DISABLE_INACTIVE_W 1 + #endif +#else + #undef DISABLE_INACTIVE_W +#endif + // Extruder steppers and solenoids #if HAS_EXTRUDERS @@ -1848,7 +2008,7 @@ // #if HAS_TRINAMIC_CONFIG - #if ANY(STEALTHCHOP_E, STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_I, STEALTHCHOP_J, STEALTHCHOP_K) + #if ANY(STEALTHCHOP_E, STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_I, STEALTHCHOP_J, STEALTHCHOP_K, STEALTHCHOP_U, STEALTHCHOP_V, STEALTHCHOP_W) #define STEALTHCHOP_ENABLED 1 #endif #if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING) @@ -1937,6 +2097,15 @@ #define Y2_SLAVE_ADDRESS 0 #endif #endif + #if HAS_U_AXIS + #define U_SPI_SENSORLESS U_SENSORLESS + #endif + #if HAS_V_AXIS + #define V_SPI_SENSORLESS V_SENSORLESS + #endif + #if HAS_W_AXIS + #define W_SPI_SENSORLESS W_SENSORLESS + #endif #endif #if AXIS_IS_TMC(Z) @@ -2074,6 +2243,69 @@ #endif #endif + #if AXIS_IS_TMC(U) + #if defined(U_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(U) + #define U_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(U) + #define U_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) + #define U_SPI_SENSORLESS U_SENSORLESS + #endif + #ifndef U_INTERPOLATE + #define U_INTERPOLATE INTERPOLATE + #endif + #ifndef U_HOLD_MULTIPLIER + #define U_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef U_SLAVE_ADDRESS + #define U_SLAVE_ADDRESS 0 + #endif + #endif + + #if AXIS_IS_TMC(V) + #if defined(V_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(V) + #define V_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(V) + #define V_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) + #define V_SPI_SENSORLESS V_SENSORLESS + #endif + #ifndef V_INTERPOLATE + #define V_INTERPOLATE INTERPOLATE + #endif + #ifndef V_HOLD_MULTIPLIER + #define V_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef V_SLAVE_ADDRESS + #define V_SLAVE_ADDRESS 0 + #endif + #endif + + #if AXIS_IS_TMC(W) + #if defined(W_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(W) + #define W_SENSORLESS 1 + #endif + #if AXIS_HAS_STEALTHCHOP(W) + #define W_HAS_STEALTHCHOP 1 + #endif + #if ENABLED(SPI_ENDSTOPS) + #define W_SPI_SENSORLESS W_SENSORLESS + #endif + #ifndef W_INTERPOLATE + #define W_INTERPOLATE INTERPOLATE + #endif + #ifndef W_HOLD_MULTIPLIER + #define W_HOLD_MULTIPLIER HOLD_MULTIPLIER + #endif + #ifndef W_SLAVE_ADDRESS + #define W_SLAVE_ADDRESS 0 + #endif + #endif + #if AXIS_IS_TMC(E0) #if AXIS_HAS_STEALTHCHOP(E0) #define E0_HAS_STEALTHCHOP 1 @@ -2215,6 +2447,7 @@ #define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \ || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \ || TMC_UART_IS(I, N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \ + || TMC_UART_IS(U, N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \ || TMC_UART_IS(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \ || TMC_UART_IS(E0, N) || TMC_UART_IS(E1, N) || TMC_UART_IS(E2, N) || TMC_UART_IS(E3, N) || TMC_UART_IS(E4, N) ) @@ -2349,6 +2582,24 @@ #if _HAS_STOP(K,MAX) #define HAS_K_MAX 1 #endif +#if _HAS_STOP(U,MIN) + #define HAS_U_MIN 1 +#endif +#if _HAS_STOP(U,MAX) + #define HAS_U_MAX 1 +#endif +#if _HAS_STOP(V,MIN) + #define HAS_V_MIN 1 +#endif +#if _HAS_STOP(V,MAX) + #define HAS_V_MAX 1 +#endif +#if _HAS_STOP(W,MIN) + #define HAS_W_MIN 1 +#endif +#if _HAS_STOP(W,MAX) + #define HAS_W_MAX 1 +#endif #if PIN_EXISTS(X2_MIN) #define HAS_X2_MIN 1 #endif @@ -2849,7 +3100,7 @@ #if HAS_EXTRUDERS && PIN_EXISTS(MOTOR_CURRENT_PWM_E) #define HAS_MOTOR_CURRENT_PWM_E 1 #endif -#if HAS_MOTOR_CURRENT_PWM_E || ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K) +#if HAS_MOTOR_CURRENT_PWM_E || ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K, MOTOR_CURRENT_PWM_U, MOTOR_CURRENT_PWM_V, MOTOR_CURRENT_PWM_W) #define HAS_MOTOR_CURRENT_PWM 1 #endif @@ -2859,7 +3110,7 @@ #if ANY(HAS_E0_MS_PINS, HAS_E1_MS_PINS, HAS_E2_MS_PINS, HAS_E3_MS_PINS, HAS_E4_MS_PINS, HAS_E5_MS_PINS, HAS_E6_MS_PINS, HAS_E7_MS_PINS) #define HAS_SOME_E_MS_PINS 1 #endif -#if ANY(HAS_X_MS_PINS, HAS_X2_MS_PINS, HAS_Y_MS_PINS, HAS_Y2_MS_PINS, HAS_SOME_Z_MS_PINS, HAS_I_MS_PINS, HAS_J_MS_PINS, HAS_K_MS_PINS, HAS_SOME_E_MS_PINS) +#if ANY(HAS_X_MS_PINS, HAS_X2_MS_PINS, HAS_Y_MS_PINS, HAS_Y2_MS_PINS, HAS_SOME_Z_MS_PINS, HAS_I_MS_PINS, HAS_J_MS_PINS, HAS_K_MS_PINS, HAS_U_MS_PINS, HAS_V_MS_PINS, HAS_W_MS_PINS, HAS_SOME_E_MS_PINS) #define HAS_MICROSTEPS 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 665381207f..ec8b278b02 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -35,8 +35,8 @@ #endif // Strings for sanity check messages -#define _LINEAR_AXES_STR LINEAR_AXIS_GANG("X ", "Y ", "Z ", "I ", "J ", "K ") -#define _LOGICAL_AXES_STR LOGICAL_AXIS_GANG("E ", "X ", "Y ", "Z ", "I ", "J ", "K ") +#define _NUM_AXES_STR NUM_AXIS_GANG("X ", "Y ", "Z ", "I ", "J ", "K ", "U ", "V ", "W ") +#define _LOGICAL_AXES_STR LOGICAL_AXIS_GANG("E ", "X ", "Y ", "Z ", "I ", "J ", "K ", "U ", "V ", "W ") // Make sure macros aren't borked #define TEST1 @@ -617,6 +617,8 @@ #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS is now just Z_STEPPER_ALIGN_STEPPER_XY." #elif defined(DWIN_CREALITY_LCD_ENHANCED) #error "DWIN_CREALITY_LCD_ENHANCED is now DWIN_LCD_PROUI." +#elif defined(LINEAR_AXES) + #error "LINEAR_AXES is now NUM_AXES (to account for rotational axes)." #endif constexpr float arm[] = AXIS_RELATIVE_MODES; @@ -798,6 +800,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Enable only one of ENDSTOPPULLUP_J_MAX or ENDSTOPPULLDOWN_J_MAX." #elif BOTH(ENDSTOPPULLUP_KMAX, ENDSTOPPULLDOWN_KMAX) #error "Enable only one of ENDSTOPPULLUP_K_MAX or ENDSTOPPULLDOWN_K_MAX." +#elif BOTH(ENDSTOPPULLUP_UMAX, ENDSTOPPULLDOWN_UMAX) + #error "Enable only one of ENDSTOPPULLUP_U_MAX or ENDSTOPPULLDOWN_U_MAX." +#elif BOTH(ENDSTOPPULLUP_VMAX, ENDSTOPPULLDOWN_VMAX) + #error "Enable only one of ENDSTOPPULLUP_V_MAX or ENDSTOPPULLDOWN_V_MAX." +#elif BOTH(ENDSTOPPULLUP_WMAX, ENDSTOPPULLDOWN_WMAX) + #error "Enable only one of ENDSTOPPULLUP_W_MAX or ENDSTOPPULLDOWN_W_MAX." #elif BOTH(ENDSTOPPULLUP_XMIN, ENDSTOPPULLDOWN_XMIN) #error "Enable only one of ENDSTOPPULLUP_X_MIN or ENDSTOPPULLDOWN_X_MIN." #elif BOTH(ENDSTOPPULLUP_YMIN, ENDSTOPPULLDOWN_YMIN) @@ -810,6 +818,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Enable only one of ENDSTOPPULLUP_J_MIN or ENDSTOPPULLDOWN_J_MIN." #elif BOTH(ENDSTOPPULLUP_KMIN, ENDSTOPPULLDOWN_KMIN) #error "Enable only one of ENDSTOPPULLUP_K_MIN or ENDSTOPPULLDOWN_K_MIN." +#elif BOTH(ENDSTOPPULLUP_UMIN, ENDSTOPPULLDOWN_UMIN) + #error "Enable only one of ENDSTOPPULLUP_U_MIN or ENDSTOPPULLDOWN_U_MIN." +#elif BOTH(ENDSTOPPULLUP_VMIN, ENDSTOPPULLDOWN_VMIN) + #error "Enable only one of ENDSTOPPULLUP_V_MIN or ENDSTOPPULLDOWN_V_MIN." +#elif BOTH(ENDSTOPPULLUP_WMIN, ENDSTOPPULLDOWN_WMIN) + #error "Enable only one of ENDSTOPPULLUP_W_MIN or ENDSTOPPULLDOWN_W_MIN." #endif /** @@ -1417,16 +1431,18 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif /** - * Features that require a min/max/specific LINEAR_AXES + * Features that require a min/max/specific NUM_AXES */ #if HAS_LEVELING && !HAS_Z_AXIS #error "Leveling in Marlin requires three or more axes, with Z as the vertical axis." #elif ENABLED(CNC_WORKSPACE_PLANES) && !HAS_Z_AXIS - #error "CNC_WORKSPACE_PLANES currently requires LINEAR_AXES >= 3" -#elif ENABLED(DIRECT_STEPPING) && LINEAR_AXES > XYZ - #error "DIRECT_STEPPING currently requires LINEAR_AXES 3" -#elif ENABLED(FOAMCUTTER_XYUV) && LINEAR_AXES < 5 - #error "FOAMCUTTER_XYUV requires LINEAR_AXES >= 5." + #error "CNC_WORKSPACE_PLANES currently requires NUM_AXES >= 3" +#elif ENABLED(DIRECT_STEPPING) && NUM_AXES > XYZ + #error "DIRECT_STEPPING currently requires NUM_AXES 3" +#elif ENABLED(FOAMCUTTER_XYUV) && NUM_AXES < 5 + #error "FOAMCUTTER_XYUV requires NUM_AXES >= 5." +#elif ENABLED(LINEAR_ADVANCE) && HAS_I_AXIS + #error "LINEAR_ADVANCE currently requires NUM_AXES <= 3." #endif /** @@ -1434,33 +1450,76 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if HAS_I_AXIS #if !defined(I_MIN_POS) || !defined(I_MAX_POS) - #error "I_MIN_POS and I_MAX_POS are required with LINEAR_AXES >= 4." + #error "I_MIN_POS and I_MAX_POS are required with NUM_AXES >= 4." #elif !defined(I_HOME_DIR) - #error "I_HOME_DIR is required with LINEAR_AXES >= 4." + #error "I_HOME_DIR is required with NUM_AXES >= 4." #elif HAS_I_ENABLE && !defined(I_ENABLE_ON) - #error "I_ENABLE_ON is required for your I driver with LINEAR_AXES >= 4." + #error "I_ENABLE_ON is required for your I driver with NUM_AXES >= 4." #endif #endif #if HAS_J_AXIS #if AXIS5_NAME == AXIS4_NAME #error "AXIS5_NAME must be unique." + #elif ENABLED(AXIS5_ROTATES) && DISABLED(AXIS4_ROTATES) + #error "AXIS5_ROTATES requires AXIS4_ROTATES." #elif !defined(J_MIN_POS) || !defined(J_MAX_POS) - #error "J_MIN_POS and J_MAX_POS are required with LINEAR_AXES >= 5." + #error "J_MIN_POS and J_MAX_POS are required with NUM_AXES >= 5." #elif !defined(J_HOME_DIR) - #error "J_HOME_DIR is required with LINEAR_AXES >= 5." + #error "J_HOME_DIR is required with NUM_AXES >= 5." #elif HAS_J_ENABLE && !defined(J_ENABLE_ON) - #error "J_ENABLE_ON is required for your J driver with LINEAR_AXES >= 5." + #error "J_ENABLE_ON is required for your J driver with NUM_AXES >= 5." #endif #endif #if HAS_K_AXIS #if AXIS6_NAME == AXIS5_NAME || AXIS6_NAME == AXIS4_NAME #error "AXIS6_NAME must be unique." + #elif ENABLED(AXIS6_ROTATES) && DISABLED(AXIS5_ROTATES) + #error "AXIS6_ROTATES requires AXIS5_ROTATES." #elif !defined(K_MIN_POS) || !defined(K_MAX_POS) - #error "K_MIN_POS and K_MAX_POS are required with LINEAR_AXES >= 6." + #error "K_MIN_POS and K_MAX_POS are required with NUM_AXES >= 6." #elif !defined(K_HOME_DIR) - #error "K_HOME_DIR is required with LINEAR_AXES >= 6." + #error "K_HOME_DIR is required with NUM_AXES >= 6." #elif HAS_K_ENABLE && !defined(K_ENABLE_ON) - #error "K_ENABLE_ON is required for your K driver with LINEAR_AXES >= 6." + #error "K_ENABLE_ON is required for your K driver with NUM_AXES >= 6." + #endif +#endif +#if HAS_U_AXIS + #if AXIS7_NAME == AXIS6_NAME || AXIS7_NAME == AXIS5_NAME || AXIS7_NAME == AXIS4_NAME + #error "AXIS7_NAME must be unique." + #elif ENABLED(AXIS7_ROTATES) && DISABLED(AXIS6_ROTATES) + #error "AXIS7_ROTATES requires AXIS6_ROTATES." + #elif !defined(U_MIN_POS) || !defined(U_MAX_POS) + #error "U_MIN_POS and U_MAX_POS are required with NUM_AXES >= 7." + #elif !defined(U_HOME_DIR) + #error "U_HOME_DIR is required with NUM_AXES >= 7." + #elif HAS_U_ENABLE && !defined(U_ENABLE_ON) + #error "U_ENABLE_ON is required for your U driver with NUM_AXES >= 7." + #endif +#endif +#if HAS_V_AXIS + #if AXIS8_NAME == AXIS7_NAME || AXIS8_NAME == AXIS6_NAME || AXIS8_NAME == AXIS5_NAME || AXIS8_NAME == AXIS4_NAME + #error "AXIS8_NAME must be unique." + #elif ENABLED(AXIS8_ROTATES) && DISABLED(AXIS7_ROTATES) + #error "AXIS8_ROTATES requires AXIS7_ROTATES." + #elif !defined(V_MIN_POS) || !defined(V_MAX_POS) + #error "V_MIN_POS and V_MAX_POS are required with NUM_AXES >= 8." + #elif !defined(V_HOME_DIR) + #error "V_HOME_DIR is required with NUM_AXES >= 8." + #elif HAS_V_ENABLE && !defined(V_ENABLE_ON) + #error "V_ENABLE_ON is required for your V driver with NUM_AXES >= 8." + #endif +#endif +#if HAS_W_AXIS + #if AXIS9_NAME == AXIS8_NAME || AXIS9_NAME == AXIS7_NAME || AXIS9_NAME == AXIS6_NAME || AXIS9_NAME == AXIS5_NAME || AXIS9_NAME == AXIS4_NAME + #error "AXIS9_NAME must be unique." + #elif ENABLED(AXIS9_ROTATES) && DISABLED(AXIS8_ROTATES) + #error "AXIS9_ROTATES requires AXIS8_ROTATES." + #elif !defined(W_MIN_POS) || !defined(W_MAX_POS) + #error "W_MIN_POS and W_MAX_POS are required with NUM_AXES >= 9." + #elif !defined(W_HOME_DIR) + #error "W_HOME_DIR is required with NUM_AXES >= 9." + #elif HAS_W_ENABLE && !defined(W_ENABLE_ON) + #error "W_ENABLE_ON is required for your W driver with NUM_AXES >= 9." #endif #endif @@ -1850,49 +1909,61 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Required setting HOMING_BUMP_DIVISOR is missing!" #else constexpr float hbm[] = HOMING_BUMP_MM, hbd[] = HOMING_BUMP_DIVISOR; - static_assert(COUNT(hbm) == LINEAR_AXES, "HOMING_BUMP_MM must have " _LINEAR_AXES_STR "elements (and no others)."); - LINEAR_AXIS_CODE( + static_assert(COUNT(hbm) == NUM_AXES, "HOMING_BUMP_MM must have " _NUM_AXES_STR "elements (and no others)."); + NUM_AXIS_CODE( static_assert(hbm[X_AXIS] >= 0, "HOMING_BUMP_MM.X must be greater than or equal to 0."), static_assert(hbm[Y_AXIS] >= 0, "HOMING_BUMP_MM.Y must be greater than or equal to 0."), static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal to 0."), static_assert(hbm[I_AXIS] >= 0, "HOMING_BUMP_MM.I must be greater than or equal to 0."), static_assert(hbm[J_AXIS] >= 0, "HOMING_BUMP_MM.J must be greater than or equal to 0."), - static_assert(hbm[K_AXIS] >= 0, "HOMING_BUMP_MM.K must be greater than or equal to 0.") + static_assert(hbm[K_AXIS] >= 0, "HOMING_BUMP_MM.K must be greater than or equal to 0."), + static_assert(hbm[U_AXIS] >= 0, "HOMING_BUMP_MM.U must be greater than or equal to 0."), + static_assert(hbm[V_AXIS] >= 0, "HOMING_BUMP_MM.V must be greater than or equal to 0."), + static_assert(hbm[W_AXIS] >= 0, "HOMING_BUMP_MM.W must be greater than or equal to 0.") ); - static_assert(COUNT(hbd) == LINEAR_AXES, "HOMING_BUMP_DIVISOR must have " _LINEAR_AXES_STR "elements (and no others)."); - LINEAR_AXIS_CODE( + static_assert(COUNT(hbd) == NUM_AXES, "HOMING_BUMP_DIVISOR must have " _NUM_AXES_STR "elements (and no others)."); + NUM_AXIS_CODE( static_assert(hbd[X_AXIS] >= 1, "HOMING_BUMP_DIVISOR.X must be greater than or equal to 1."), static_assert(hbd[Y_AXIS] >= 1, "HOMING_BUMP_DIVISOR.Y must be greater than or equal to 1."), static_assert(hbd[Z_AXIS] >= 1, "HOMING_BUMP_DIVISOR.Z must be greater than or equal to 1."), static_assert(hbd[I_AXIS] >= 1, "HOMING_BUMP_DIVISOR.I must be greater than or equal to 1."), static_assert(hbd[J_AXIS] >= 1, "HOMING_BUMP_DIVISOR.J must be greater than or equal to 1."), - static_assert(hbd[K_AXIS] >= 1, "HOMING_BUMP_DIVISOR.K must be greater than or equal to 1.") + static_assert(hbd[K_AXIS] >= 1, "HOMING_BUMP_DIVISOR.K must be greater than or equal to 1."), + static_assert(hbd[U_AXIS] >= 1, "HOMING_BUMP_DIVISOR.U must be greater than or equal to 1."), + static_assert(hbd[V_AXIS] >= 1, "HOMING_BUMP_DIVISOR.V must be greater than or equal to 1."), + static_assert(hbd[W_AXIS] >= 1, "HOMING_BUMP_DIVISOR.W must be greater than or equal to 1.") ); #endif #ifdef HOMING_BACKOFF_POST_MM constexpr float hbp[] = HOMING_BACKOFF_POST_MM; - static_assert(COUNT(hbp) == LINEAR_AXES, "HOMING_BACKOFF_POST_MM must have " _LINEAR_AXES_STR "elements (and no others)."); - LINEAR_AXIS_CODE( + static_assert(COUNT(hbp) == NUM_AXES, "HOMING_BACKOFF_POST_MM must have " _NUM_AXES_STR "elements (and no others)."); + NUM_AXIS_CODE( static_assert(hbp[X_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.X must be greater than or equal to 0."), static_assert(hbp[Y_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.Y must be greater than or equal to 0."), static_assert(hbp[Z_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.Z must be greater than or equal to 0."), static_assert(hbp[I_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.I must be greater than or equal to 0."), static_assert(hbp[J_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.J must be greater than or equal to 0."), - static_assert(hbp[K_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.K must be greater than or equal to 0.") + static_assert(hbp[K_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.K must be greater than or equal to 0."), + static_assert(hbp[U_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.U must be greater than or equal to 0."), + static_assert(hbp[V_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.V must be greater than or equal to 0."), + static_assert(hbp[W_AXIS] >= 0, "HOMING_BACKOFF_POST_MM.W must be greater than or equal to 0.") ); #endif #ifdef SENSORLESS_BACKOFF_MM constexpr float sbm[] = SENSORLESS_BACKOFF_MM; - static_assert(COUNT(sbm) == LINEAR_AXES, "SENSORLESS_BACKOFF_MM must have " _LINEAR_AXES_STR "elements (and no others)."); - LINEAR_AXIS_CODE( + static_assert(COUNT(sbm) == NUM_AXES, "SENSORLESS_BACKOFF_MM must have " _NUM_AXES_STR "elements (and no others)."); + NUM_AXIS_CODE( static_assert(sbm[X_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.X must be greater than or equal to 0."), static_assert(sbm[Y_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.Y must be greater than or equal to 0."), static_assert(sbm[Z_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.Z must be greater than or equal to 0."), static_assert(sbm[I_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.I must be greater than or equal to 0."), static_assert(sbm[J_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.J must be greater than or equal to 0."), - static_assert(sbm[K_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.K must be greater than or equal to 0.") + static_assert(sbm[K_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.K must be greater than or equal to 0."), + static_assert(sbm[U_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.U must be greater than or equal to 0."), + static_assert(sbm[V_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.V must be greater than or equal to 0."), + static_assert(sbm[W_AXIS] >= 0, "SENSORLESS_BACKOFF_MM.W must be greater than or equal to 0.") ); #endif @@ -1915,9 +1986,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Make sure DISABLE_[XYZ] compatible with selected homing options */ -#if ANY(DISABLE_X, DISABLE_Y, DISABLE_Z, DISABLE_I, DISABLE_J, DISABLE_K) +#if ANY(DISABLE_X, DISABLE_Y, DISABLE_Z, DISABLE_I, DISABLE_J, DISABLE_K, DISABLE_U, DISABLE_V, DISABLE_W) #if EITHER(HOME_AFTER_DEACTIVATE, Z_SAFE_HOMING) - #error "DISABLE_[XYZIJK] is not compatible with HOME_AFTER_DEACTIVATE or Z_SAFE_HOMING." + #error "DISABLE_[XYZIJKUVW] is not compatible with HOME_AFTER_DEACTIVATE or Z_SAFE_HOMING." #endif #endif @@ -2431,7 +2502,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #define _PLUG_UNUSED_TEST(A,P) (DISABLED(USE_##P##MIN_PLUG, USE_##P##MAX_PLUG) \ && !(ENABLED(A##_DUAL_ENDSTOPS) && WITHIN(A##2_USE_ENDSTOP, _##P##MAX_, _##P##MIN_)) \ && !(ENABLED(A##_MULTI_ENDSTOPS) && WITHIN(A##2_USE_ENDSTOP, _##P##MAX_, _##P##MIN_)) ) -#define _AXIS_PLUG_UNUSED_TEST(A) (1 LINEAR_AXIS_GANG(&& _PLUG_UNUSED_TEST(A,X), && _PLUG_UNUSED_TEST(A,Y), && _PLUG_UNUSED_TEST(A,Z), && _PLUG_UNUSED_TEST(A,I), && _PLUG_UNUSED_TEST(A,J), && _PLUG_UNUSED_TEST(A,K) ) ) +#define _AXIS_PLUG_UNUSED_TEST(A) (1 NUM_AXIS_GANG(&& _PLUG_UNUSED_TEST(A,X), && _PLUG_UNUSED_TEST(A,Y), && _PLUG_UNUSED_TEST(A,Z), \ + && _PLUG_UNUSED_TEST(A,I), && _PLUG_UNUSED_TEST(A,J), && _PLUG_UNUSED_TEST(A,K), \ + && _PLUG_UNUSED_TEST(A,U), && _PLUG_UNUSED_TEST(A,V), && _PLUG_UNUSED_TEST(A,W) ) ) // A machine with endstops must have a minimum of 3 #if HAS_ENDSTOPS @@ -2453,6 +2526,15 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if HAS_K_AXIS && _AXIS_PLUG_UNUSED_TEST(K) #error "You must enable USE_KMIN_PLUG or USE_KMAX_PLUG." #endif + #if HAS_U_AXIS && _AXIS_PLUG_UNUSED_TEST(U) + #error "You must enable USE_UMIN_PLUG or USE_UMAX_PLUG." + #endif + #if HAS_V_AXIS && _AXIS_PLUG_UNUSED_TEST(V) + #error "You must enable USE_VMIN_PLUG or USE_VMAX_PLUG." + #endif + #if HAS_W_AXIS && _AXIS_PLUG_UNUSED_TEST(W) + #error "You must enable USE_WMIN_PLUG or USE_WMAX_PLUG." + #endif // Delta and Cartesian use 3 homing endstops #if NONE(IS_SCARA, SPI_ENDSTOPS) @@ -2476,6 +2558,18 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Enable USE_KMIN_PLUG when homing K to MIN." #elif HAS_K_AXIS && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) #error "Enable USE_KMAX_PLUG when homing K to MAX." + #elif HAS_U_AXIS && U_HOME_TO_MIN && DISABLED(USE_UMIN_PLUG) + #error "Enable USE_UMIN_PLUG when homing U to MIN." + #elif HAS_U_AXIS && U_HOME_TO_MAX && DISABLED(USE_UMAX_PLUG) + #error "Enable USE_UMAX_PLUG when homing U to MAX." + #elif HAS_V_AXIS && V_HOME_TO_MIN && DISABLED(USE_VMIN_PLUG) + #error "Enable USE_VMIN_PLUG when homing V to MIN." + #elif HAS_V_AXIS && V_HOME_TO_MAX && DISABLED(USE_VMAX_PLUG) + #error "Enable USE_VMAX_PLUG when homing V to MAX." + #elif HAS_W_AXIS && W_HOME_TO_MIN && DISABLED(USE_WMIN_PLUG) + #error "Enable USE_WMIN_PLUG when homing W to MIN." + #elif HAS_W_AXIS && W_HOME_TO_MAX && DISABLED(USE_WMAX_PLUG) + #error "Enable USE_WMAX_PLUG when homing W to MAX." #endif #endif @@ -2959,6 +3053,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "An SPI driven TMC on J requires J_CS_PIN." #elif INVALID_TMC_SPI(K) #error "An SPI driven TMC on K requires K_CS_PIN." +#elif INVALID_TMC_SPI(U) + #error "An SPI driven TMC on U requires U_CS_PIN." +#elif INVALID_TMC_SPI(V) + #error "An SPI driven TMC on V requires V_CS_PIN." +#elif INVALID_TMC_SPI(W) + #error "An SPI driven TMC on W requires W_CS_PIN." #endif #undef INVALID_TMC_SPI @@ -3004,6 +3104,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TMC2208 or TMC2209 on J requires J_HARDWARE_SERIAL or J_SERIAL_(RX|TX)_PIN." #elif HAS_K_AXIS && INVALID_TMC_UART(K) #error "TMC2208 or TMC2209 on K requires K_HARDWARE_SERIAL or K_SERIAL_(RX|TX)_PIN." +#elif HAS_U_AXIS && INVALID_TMC_UART(U) + #error "TMC2208 or TMC2209 on U requires U_HARDWARE_SERIAL or U_SERIAL_(RX|TX)_PIN." +#elif HAS_V_AXIS && INVALID_TMC_UART(V) + #error "TMC2208 or TMC2209 on V requires V_HARDWARE_SERIAL or V_SERIAL_(RX|TX)_PIN." +#elif HAS_W_AXIS && INVALID_TMC_UART(W) + #error "TMC2208 or TMC2209 on W requires W_HARDWARE_SERIAL or W_SERIAL_(RX|TX)_PIN." + #endif #undef INVALID_TMC_UART @@ -3033,6 +3140,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS INVALID_TMC_ADDRESS(J); #elif AXIS_DRIVER_TYPE_K(TMC2209) INVALID_TMC_ADDRESS(K); +#elif AXIS_DRIVER_TYPE_U(TMC2209) + INVALID_TMC_ADDRESS(U); +#elif AXIS_DRIVER_TYPE_V(TMC2209) + INVALID_TMC_ADDRESS(V); +#elif AXIS_DRIVER_TYPE_W(TMC2209) + INVALID_TMC_ADDRESS(W); #elif AXIS_DRIVER_TYPE_E0(TMC2209) INVALID_TMC_ADDRESS(E0); #elif AXIS_DRIVER_TYPE_E1(TMC2209) @@ -3094,6 +3207,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS INVALID_TMC_MS(J) #elif HAS_K_AXIS && !TMC_MICROSTEP_IS_VALID(K) INVALID_TMC_MS(K) +#elif HAS_U_AXIS && !TMC_MICROSTEP_IS_VALID(U) + INVALID_TMC_MS(U) +#elif HAS_V_AXIS && !TMC_MICROSTEP_IS_VALID(V) + INVALID_TMC_MS(V) +#elif HAS_W_AXIS && !TMC_MICROSTEP_IS_VALID(W) + INVALID_TMC_MS(W) #endif #undef INVALID_TMC_MS #undef TMC_MICROSTEP_IS_VALID @@ -3123,6 +3242,15 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if HAS_K_AXIS #define K_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(K,TMC2209) #endif + #if HAS_U_AXIS + #define U_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(U,TMC2209) + #endif + #if HAS_V_AXIS + #define V_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(V,TMC2209) + #endif + #if HAS_W_AXIS + #define W_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(W,TMC2209) + #endif #if NONE(SPI_ENDSTOPS, ONBOARD_ENDSTOPPULLUPS, ENDSTOPPULLUPS) #if X_SENSORLESS && X_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_XMIN) @@ -3149,6 +3277,19 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMIN (or ENDSTOPPULLUPS) when homing to K_MIN." #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_KMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMAX (or ENDSTOPPULLUPS) when homing to K_MAX." + #elif HAS_U_AXIS && U_SENSORLESS && U_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_UMIN) + #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_UMIN (or ENDSTOPPULLUPS) when homing to U_MIN." + #elif HAS_U_AXIS && U_SENSORLESS && U_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_UMAX) + #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_UMAX (or ENDSTOPPULLUPS) when homing to U_MAX." + #elif HAS_V_AXIS && V_SENSORLESS && V_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_VMIN) + #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_VMIN (or ENDSTOPPULLUPS) when homing to V_MIN." + #elif HAS_V_AXIS && V_SENSORLESS && V_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_VMAX) + #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_VMAX (or ENDSTOPPULLUPS) when homing to V_MAX." + #elif HAS_W_AXIS && W_SENSORLESS && W_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_WMIN) + #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_WMIN (or ENDSTOPPULLUPS) when homing to W_MIN." + #elif HAS_W_AXIS && W_SENSORLESS && W_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_WMAX) + #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_WMAX (or ENDSTOPPULLUPS) when homing to W_MAX." + #endif #endif @@ -3229,6 +3370,42 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #else #error "SENSORLESS_HOMING requires K_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to K_MAX." #endif + #elif ALL(HAS_U_AXIS, U_SENSORLESS, U_HOME_TO_MIN) && U_MIN_ENDSTOP_INVERTING != U_ENDSTOP_INVERTING + #if U_ENDSTOP_INVERTING + #error "SENSORLESS_HOMING requires U_MIN_ENDSTOP_INVERTING = true when homing to U_MIN." + #else + #error "SENSORLESS_HOMING requires U_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to U_MIN." + #endif + #elif ALL(HAS_U_AXIS, U_SENSORLESS, U_HOME_TO_MAX) && U_MAX_ENDSTOP_INVERTING != U_ENDSTOP_INVERTING + #if U_ENDSTOP_INVERTING + #error "SENSORLESS_HOMING requires U_MAX_ENDSTOP_INVERTING = true when homing to U_MAX." + #else + #error "SENSORLESS_HOMING requires U_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to U_MAX." + #endif + #elif ALL(HAS_V_AXIS, V_SENSORLESS, V_HOME_TO_MIN) && V_MIN_ENDSTOP_INVERTING != V_ENDSTOP_INVERTING + #if V_ENDSTOP_INVERTING + #error "SENSORLESS_HOMING requires V_MIN_ENDSTOP_INVERTING = true when homing to V_MIN." + #else + #error "SENSORLESS_HOMING requires V_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to V_MIN." + #endif + #elif ALL(HAS_V_AXIS, V_SENSORLESS, V_HOME_TO_MAX) && V_MAX_ENDSTOP_INVERTING != V_ENDSTOP_INVERTING + #if V_ENDSTOP_INVERTING + #error "SENSORLESS_HOMING requires V_MAX_ENDSTOP_INVERTING = true when homing to V_MAX." + #else + #error "SENSORLESS_HOMING requires V_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to V_MAX." + #endif + #elif ALL(HAS_W_AXIS, W_SENSORLESS, W_HOME_TO_MIN) && W_MIN_ENDSTOP_INVERTING != W_ENDSTOP_INVERTING + #if W_ENDSTOP_INVERTING + #error "SENSORLESS_HOMING requires W_MIN_ENDSTOP_INVERTING = true when homing to W_MIN." + #else + #error "SENSORLESS_HOMING requires W_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to W_MIN." + #endif + #elif ALL(HAS_W_AXIS, W_SENSORLESS, W_HOME_TO_MAX0) && W_MAX_ENDSTOP_INVERTING != W_ENDSTOP_INVERTING + #if W_ENDSTOP_INVERTING + #error "SENSORLESS_HOMING requires W_MAX_ENDSTOP_INVERTING = true when homing to W_MAX." + #else + #error "SENSORLESS_HOMING requires W_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to W_MAX." + #endif #endif #endif @@ -3246,6 +3423,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #undef I_ENDSTOP_INVERTING #undef J_ENDSTOP_INVERTING #undef K_ENDSTOP_INVERTING + #undef U_ENDSTOP_INVERTING + #undef V_ENDSTOP_INVERTING + #undef W_ENDSTOP_INVERTING #endif // Sensorless probing requirements @@ -3314,6 +3494,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #define CS_COMPARE J_CS_PIN #elif IN_CHAIN(K) #define CS_COMPARE K_CS_PIN + #elif IN_CHAIN(U) + #define CS_COMPARE U_CS_PIN + #elif IN_CHAIN(V) + #define CS_COMPARE V_CS_PIN + #elif IN_CHAIN(W) + #define CS_COMPARE W_CS_PIN #elif IN_CHAIN(E0) #define CS_COMPARE E0_CS_PIN #elif IN_CHAIN(E1) @@ -3334,6 +3520,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #define BAD_CS_PIN(A) (IN_CHAIN(A) && A##_CS_PIN != CS_COMPARE) #if BAD_CS_PIN(X ) || BAD_CS_PIN(Y ) || BAD_CS_PIN(Z ) || BAD_CS_PIN(X2) || BAD_CS_PIN(Y2) || BAD_CS_PIN(Z2) || BAD_CS_PIN(Z3) || BAD_CS_PIN(Z4) \ || BAD_CS_PIN(I) || BAD_CS_PIN(J) || BAD_CS_PIN(K) \ + || BAD_CS_PIN(U) || BAD_CS_PIN(V) || BAD_CS_PIN(W) \ || BAD_CS_PIN(E0) || BAD_CS_PIN(E1) || BAD_CS_PIN(E2) || BAD_CS_PIN(E3) || BAD_CS_PIN(E4) || BAD_CS_PIN(E5) || BAD_CS_PIN(E6) || BAD_CS_PIN(E7) #error "All chained TMC drivers must use the same CS pin." #endif @@ -3347,8 +3534,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * L64XX requirement */ -#if HAS_L64XX && HAS_I_AXIS - #error "L64XX requires LINEAR_AXES <= 3. Homing with L64XX is not yet implemented for LINEAR_AXES > 3." +#if HAS_L64XX && NUM_AXES > 3 + #error "L64XX requires NUM_AXES <= 3. Homing with L64XX is not yet implemented for NUM_AXES > 3." #endif /** @@ -3372,7 +3559,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if HAS_MULTI_EXTRUDER #define _EXTRA_NOTE " (Did you forget to enable DISTINCT_E_FACTORS?)" #else - #define _EXTRA_NOTE " (Should be " STRINGIFY(LINEAR_AXES) "+" STRINGIFY(E_STEPPERS) ")" + #define _EXTRA_NOTE " (Should be " STRINGIFY(NUM_AXES) "+" STRINGIFY(E_STEPPERS) ")" #endif constexpr float sanity_arr_1[] = DEFAULT_AXIS_STEPS_PER_UNIT; @@ -3391,7 +3578,7 @@ static_assert(COUNT(sanity_arr_3) <= DISTINCT_AXES, "DEFAULT_MAX_ACCELERATION ha static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive."); constexpr float sanity_arr_4[] = HOMING_FEEDRATE_MM_M; -static_assert(COUNT(sanity_arr_4) == LINEAR_AXES, "HOMING_FEEDRATE_MM_M requires " _LINEAR_AXES_STR "elements (and no others)."); +static_assert(COUNT(sanity_arr_4) == NUM_AXES, "HOMING_FEEDRATE_MM_M requires " _NUM_AXES_STR "elements (and no others)."); static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #ifdef MAX_ACCEL_EDIT_VALUES @@ -3831,6 +4018,15 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #if _BAD_DRIVER(K) #error "K_DRIVER_TYPE is not recognized." #endif +#if _BAD_DRIVER(U) + #error "U_DRIVER_TYPE is not recognized." +#endif +#if _BAD_DRIVER(V) + #error "V_DRIVER_TYPE is not recognized." +#endif +#if _BAD_DRIVER(W) + #error "W_DRIVER_TYPE is not recognized." +#endif #if _BAD_DRIVER(X2) #error "X2_DRIVER_TYPE is not recognized." #endif @@ -3903,7 +4099,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); // Misc. Cleanup #undef _TEST_PWM -#undef _LINEAR_AXES_STR +#undef _NUM_AXES_STR #undef _LOGICAL_AXES_STR // JTAG support in the HAL diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 140d9ba5c2..aadb91dadf 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02000903 +#define MARLIN_HEX_VERSION 02010000 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 97e8e76b38..96f8dc7d54 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -532,6 +532,163 @@ #endif #endif + #if AUTO_ASSIGNED_U_STEPPER + #warning "Note: Auto-assigned U STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_U_CS + #warning "Note: Auto-assigned U_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_U_MS1 + #warning "Note: Auto-assigned U_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_U_MS2 + #warning "Note: Auto-assigned U_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_U_MS3 + #warning "Note: Auto-assigned U_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_U_DIAG + #if U_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned U_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned U_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned U_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned U_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned U_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned U_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif U_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned U_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_V_STEPPER + #warning "Note: Auto-assigned V STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_V_CS + #warning "Note: Auto-assigned V_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_V_MS1 + #warning "Note: Auto-assigned V_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_V_MS2 + #warning "Note: Auto-assigned V_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_V_MS3 + #warning "Note: Auto-assigned V_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_V_DIAG + #if V_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned V_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned V_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned V_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned V_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned V_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned V_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif V_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned V_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_W_STEPPER + #warning "Note: Auto-assigned W STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_W_CS + #warning "Note: Auto-assigned W_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_W_MS1 + #warning "Note: Auto-assigned W_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_W_MS2 + #warning "Note: Auto-assigned W_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_W_MS3 + #warning "Note: Auto-assigned W_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_W_DIAG + #if W_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned W_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned W_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned W_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned W_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned W_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned W_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif W_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned W_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if ENABLED(CHAMBER_FAN) && !defined(CHAMBER_FAN_INDEX) #warning "Note: Auto-assigned CHAMBER_FAN_INDEX to the first free FAN pin. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp index 8d57038765..961b29ca22 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp @@ -286,7 +286,7 @@ void DGUSTxHandler::TempMax(DGUS_VP &vp) { } void DGUSTxHandler::StepperStatus(DGUS_VP &vp) { - const bool motor_on = stepper.axis_enabled.bits & (_BV(LINEAR_AXES) - 1); + const bool motor_on = stepper.axis_enabled.bits & (_BV(NUM_AXES) - 1); dgus_display.Write((uint16_t)vp.addr, Swap16(uint16_t(motor_on ? DGUS_Data::Status::ENABLED : DGUS_Data::Status::DISABLED))); } diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 0dad675cb7..1da46d7e47 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -420,6 +420,15 @@ namespace ExtUI { #if AXIS_IS_TMC(K) case K: return stepperK.getMilliamps(); #endif + #if AXIS_IS_TMC(U) + case U: return stepperU.getMilliamps(); + #endif + #if AXIS_IS_TMC(V) + case V: return stepperV.getMilliamps(); + #endif + #if AXIS_IS_TMC(W) + case W: return stepperW.getMilliamps(); + #endif #if AXIS_IS_TMC(X2) case X2: return stepperX2.getMilliamps(); #endif @@ -489,6 +498,15 @@ namespace ExtUI { #if AXIS_IS_TMC(K) case K: stepperK.rms_current(constrain(mA, 400, 1500)); break; #endif + #if AXIS_IS_TMC(U) + case U: stepperU.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(V) + case V: stepperV.rms_current(constrain(mA, 400, 1500)); break; + #endif + #if AXIS_IS_TMC(W) + case W: stepperW.rms_current(constrain(mA, 400, 1500)); break; + #endif #if AXIS_IS_TMC(X2) case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break; #endif @@ -546,6 +564,9 @@ namespace ExtUI { OPTCODE(I_SENSORLESS, case I: return stepperI.homing_threshold()) OPTCODE(J_SENSORLESS, case J: return stepperJ.homing_threshold()) OPTCODE(K_SENSORLESS, case K: return stepperK.homing_threshold()) + OPTCODE(U_SENSORLESS, case U: return stepperU.homing_threshold()) + OPTCODE(V_SENSORLESS, case V: return stepperV.homing_threshold()) + OPTCODE(W_SENSORLESS, case W: return stepperW.homing_threshold()) OPTCODE(X2_SENSORLESS, case X2: return stepperX2.homing_threshold()) OPTCODE(Y2_SENSORLESS, case Y2: return stepperY2.homing_threshold()) OPTCODE(Z2_SENSORLESS, case Z2: return stepperZ2.homing_threshold()) @@ -575,6 +596,15 @@ namespace ExtUI { #if K_SENSORLESS case K: stepperK.homing_threshold(value); break; #endif + #if U_SENSORLESS + case U: stepperU.homing_threshold(value); break; + #endif + #if V_SENSORLESS + case V: stepperV.homing_threshold(value); break; + #endif + #if W_SENSORLESS + case W: stepperW.homing_threshold(value); break; + #endif #if X2_SENSORLESS case X2: stepperX2.homing_threshold(value); break; #endif diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 84b2ed8c6d..8455518767 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -57,7 +57,7 @@ namespace ExtUI { static constexpr size_t eeprom_data_size = 48; - enum axis_t : uint8_t { X, Y, Z, I, J, K, X2, Y2, Z2, Z3, Z4 }; + enum axis_t : uint8_t { X, Y, Z, I, J, K, U, V, W, X2, Y2, Z2, Z3, Z4 }; enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 }; enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER, COOLER }; enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 }; diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 43bbd90210..313098a9f6 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -103,6 +103,9 @@ namespace Language_en { LSTR MSG_HOME_OFFSET_I = _UxGT("Home Offset ") STR_I; LSTR MSG_HOME_OFFSET_J = _UxGT("Home Offset ") STR_J; LSTR MSG_HOME_OFFSET_K = _UxGT("Home Offset ") STR_K; + LSTR MSG_HOME_OFFSET_U = _UxGT("Home Offset ") STR_U; + LSTR MSG_HOME_OFFSET_V = _UxGT("Home Offset ") STR_V; + LSTR MSG_HOME_OFFSET_W = _UxGT("Home Offset ") STR_W; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsets Applied"); LSTR MSG_SET_ORIGIN = _UxGT("Set Origin"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Tramming Wizard"); @@ -288,6 +291,9 @@ namespace Language_en { LSTR MSG_MOVE_I = _UxGT("Move ") STR_I; LSTR MSG_MOVE_J = _UxGT("Move ") STR_J; LSTR MSG_MOVE_K = _UxGT("Move ") STR_K; + LSTR MSG_MOVE_U = _UxGT("Move ") STR_U; + LSTR MSG_MOVE_V = _UxGT("Move ") STR_V; + LSTR MSG_MOVE_W = _UxGT("Move ") STR_W; LSTR MSG_MOVE_E = _UxGT("Move Extruder"); LSTR MSG_MOVE_EN = _UxGT("Move E*"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend too cold"); @@ -354,6 +360,9 @@ namespace Language_en { LSTR MSG_VI_JERK = _UxGT("Max ") STR_I _UxGT(" Jerk"); LSTR MSG_VJ_JERK = _UxGT("Max ") STR_J _UxGT(" Jerk"); LSTR MSG_VK_JERK = _UxGT("Max ") STR_K _UxGT(" Jerk"); + LSTR MSG_VU_JERK = _UxGT("Max ") STR_U _UxGT(" Jerk"); + LSTR MSG_VV_JERK = _UxGT("Max ") STR_V _UxGT(" Jerk"); + LSTR MSG_VW_JERK = _UxGT("Max ") STR_W _UxGT(" Jerk"); LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); LSTR MSG_VELOCITY = _UxGT("Velocity"); @@ -363,6 +372,9 @@ namespace Language_en { LSTR MSG_VMAX_I = _UxGT("Max ") STR_I _UxGT(" Vel"); LSTR MSG_VMAX_J = _UxGT("Max ") STR_J _UxGT(" Vel"); LSTR MSG_VMAX_K = _UxGT("Max ") STR_K _UxGT(" Vel"); + LSTR MSG_VMAX_U = _UxGT("Max ") STR_U _UxGT(" Vel"); + LSTR MSG_VMAX_V = _UxGT("Max ") STR_V _UxGT(" Vel"); + LSTR MSG_VMAX_W = _UxGT("Max ") STR_W _UxGT(" Vel"); LSTR MSG_VMAX_E = _UxGT("Max ") STR_E _UxGT(" Vel"); LSTR MSG_VMAX_EN = _UxGT("Max * Vel"); LSTR MSG_VMIN = _UxGT("Min Velocity"); @@ -374,6 +386,9 @@ namespace Language_en { LSTR MSG_AMAX_I = _UxGT("Max ") STR_I _UxGT(" Accel"); LSTR MSG_AMAX_J = _UxGT("Max ") STR_J _UxGT(" Accel"); LSTR MSG_AMAX_K = _UxGT("Max ") STR_K _UxGT(" Accel"); + LSTR MSG_AMAX_U = _UxGT("Max ") STR_U _UxGT(" Accel"); + LSTR MSG_AMAX_V = _UxGT("Max ") STR_V _UxGT(" Accel"); + LSTR MSG_AMAX_W = _UxGT("Max ") STR_W _UxGT(" Accel"); LSTR MSG_AMAX_E = _UxGT("Max ") STR_E _UxGT(" Accel"); LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); LSTR MSG_A_RETRACT = _UxGT("Retract Accel"); @@ -387,6 +402,9 @@ namespace Language_en { LSTR MSG_I_STEPS = STR_I _UxGT(" Steps/mm"); LSTR MSG_J_STEPS = STR_J _UxGT(" Steps/mm"); LSTR MSG_K_STEPS = STR_K _UxGT(" Steps/mm"); + LSTR MSG_U_STEPS = STR_U _UxGT(" Steps/mm"); + LSTR MSG_V_STEPS = STR_V _UxGT(" Steps/mm"); + LSTR MSG_W_STEPS = STR_W _UxGT(" Steps/mm"); LSTR MSG_E_STEPS = _UxGT("E steps/mm"); LSTR MSG_EN_STEPS = _UxGT("* Steps/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperature"); @@ -540,6 +558,9 @@ namespace Language_en { LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") STR_I; LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") STR_J; LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") STR_K; + LSTR MSG_BABYSTEP_U = _UxGT("Babystep ") STR_U; + LSTR MSG_BABYSTEP_V = _UxGT("Babystep ") STR_V; + LSTR MSG_BABYSTEP_W = _UxGT("Babystep ") STR_W; LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop Abort"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Heating Failed"); @@ -639,6 +660,9 @@ namespace Language_en { LSTR MSG_DAC_PERCENT_I = STR_I _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_J = STR_J _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_K = STR_K _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_U = STR_U _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_V = STR_V _UxGT(" Driver %"); + LSTR MSG_DAC_PERCENT_W = STR_W _UxGT(" Driver %"); LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); LSTR MSG_ERROR_TMC = _UxGT("TMC CONNECTION ERROR"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Write"); @@ -814,6 +838,9 @@ namespace Language_en { LSTR MSG_BACKLASH_I = STR_I; LSTR MSG_BACKLASH_J = STR_J; LSTR MSG_BACKLASH_K = STR_K; + LSTR MSG_BACKLASH_U = STR_U; + LSTR MSG_BACKLASH_V = STR_V; + LSTR MSG_BACKLASH_W = STR_W; } #if FAN_COUNT == 1 diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index eb979a4319..80b8f5b1d2 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -68,7 +68,7 @@ void menu_backlash(); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ stepper_dac.set_current_percents(driverPercent); }) - LOGICAL_AXIS_CODE(EDIT_DAC_PERCENT(E), EDIT_DAC_PERCENT(A), EDIT_DAC_PERCENT(B), EDIT_DAC_PERCENT(C), EDIT_DAC_PERCENT(I), EDIT_DAC_PERCENT(J), EDIT_DAC_PERCENT(K)); + LOGICAL_AXIS_CODE(EDIT_DAC_PERCENT(E), EDIT_DAC_PERCENT(A), EDIT_DAC_PERCENT(B), EDIT_DAC_PERCENT(C), EDIT_DAC_PERCENT(I), EDIT_DAC_PERCENT(J), EDIT_DAC_PERCENT(K), EDIT_DAC_PERCENT(U), EDIT_DAC_PERCENT(V), EDIT_DAC_PERCENT(W)); ACTION_ITEM(MSG_DAC_EEPROM_WRITE, stepper_dac.commit_eeprom); END_MENU(); } @@ -356,7 +356,7 @@ void menu_backlash(); #elif ENABLED(LIMITED_MAX_FR_EDITING) DEFAULT_MAX_FEEDRATE #else - LOGICAL_AXIS_ARRAY(9999, 9999, 9999, 9999, 9999, 9999, 9999) + LOGICAL_AXIS_ARRAY(9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999) #endif ; #if ENABLED(LIMITED_MAX_FR_EDITING) && !defined(MAX_FEEDRATE_EDIT_VALUES) @@ -369,7 +369,7 @@ void menu_backlash(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_VMAX(N) EDIT_ITEM_FAST(float5, MSG_VMAX_##N, &planner.settings.max_feedrate_mm_s[_AXIS(N)], 1, max_fr_edit_scaled[_AXIS(N)]) - LINEAR_AXIS_CODE(EDIT_VMAX(A), EDIT_VMAX(B), EDIT_VMAX(C), EDIT_VMAX(I), EDIT_VMAX(J), EDIT_VMAX(K)); + NUM_AXIS_CODE(EDIT_VMAX(A), EDIT_VMAX(B), EDIT_VMAX(C), EDIT_VMAX(I), EDIT_VMAX(J), EDIT_VMAX(K), EDIT_VMAX(U), EDIT_VMAX(V), EDIT_VMAX(W)); #if E_STEPPERS EDIT_ITEM_FAST(float5, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e); @@ -399,7 +399,7 @@ void menu_backlash(); #elif ENABLED(LIMITED_MAX_ACCEL_EDITING) DEFAULT_MAX_ACCELERATION #else - LOGICAL_AXIS_ARRAY(99000, 99000, 99000, 99000, 99000, 99000, 99000) + LOGICAL_AXIS_ARRAY(99000, 99000, 99000, 99000, 99000, 99000, 99000, 99000, 99000, 99000) #endif ; #if ENABLED(LIMITED_MAX_ACCEL_EDITING) && !defined(MAX_ACCEL_EDIT_VALUES) @@ -423,9 +423,10 @@ void menu_backlash(); EDIT_ITEM_FAST(float5_25, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 25, max_accel); #define EDIT_AMAX(Q,L) EDIT_ITEM_FAST(long5_25, MSG_AMAX_##Q, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.reset_acceleration_rates(); }) - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( EDIT_AMAX(A, 100), EDIT_AMAX(B, 100), EDIT_AMAX(C, 10), - EDIT_AMAX(I, 10), EDIT_AMAX(J, 10), EDIT_AMAX(K, 10) + EDIT_AMAX(I, 10), EDIT_AMAX(J, 10), EDIT_AMAX(K, 10), + EDIT_AMAX(U, 10), EDIT_AMAX(V, 10), EDIT_AMAX(W, 10) ); #if ENABLED(DISTINCT_E_FACTORS) @@ -468,9 +469,10 @@ void menu_backlash(); #elif ENABLED(LIMITED_JERK_EDITING) { LOGICAL_AXIS_LIST((DEFAULT_EJERK) * 2, (DEFAULT_XJERK) * 2, (DEFAULT_YJERK) * 2, (DEFAULT_ZJERK) * 2, - (DEFAULT_IJERK) * 2, (DEFAULT_JJERK) * 2, (DEFAULT_KJERK) * 2) } + (DEFAULT_IJERK) * 2, (DEFAULT_JJERK) * 2, (DEFAULT_KJERK) * 2, + (DEFAULT_UJERK) * 2, (DEFAULT_VJERK) * 2, (DEFAULT_WJERK) * 2) } #else - { LOGICAL_AXIS_LIST(990, 990, 990, 990, 990, 990, 990) } + { LOGICAL_AXIS_LIST(990, 990, 990, 990, 990, 990, 990, 990, 990, 990) } #endif ; #define EDIT_JERK(N) EDIT_ITEM_FAST(float3, MSG_V##N##_JERK, &planner.max_jerk[_AXIS(N)], 1, max_jerk_edit[_AXIS(N)]) @@ -479,9 +481,10 @@ void menu_backlash(); #else #define EDIT_JERK_C() EDIT_ITEM_FAST(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, max_jerk_edit.c) #endif - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( EDIT_JERK(A), EDIT_JERK(B), EDIT_JERK_C(), - EDIT_JERK(I), EDIT_JERK(J), EDIT_JERK(K) + EDIT_JERK(I), EDIT_JERK(J), EDIT_JERK(K), + EDIT_JERK(U), EDIT_JERK(V), EDIT_JERK(W) ); #if HAS_EXTRUDERS @@ -524,9 +527,10 @@ void menu_advanced_steps_per_mm() { BACK_ITEM(MSG_ADVANCED_SETTINGS); #define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float61, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); }) - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( EDIT_QSTEPS(A), EDIT_QSTEPS(B), EDIT_QSTEPS(C), - EDIT_QSTEPS(I), EDIT_QSTEPS(J), EDIT_QSTEPS(K) + EDIT_QSTEPS(I), EDIT_QSTEPS(J), EDIT_QSTEPS(K), + EDIT_QSTEPS(U), EDIT_QSTEPS(V), EDIT_QSTEPS(W) ); #if ENABLED(DISTINCT_E_FACTORS) diff --git a/Marlin/src/lcd/menu/menu_backlash.cpp b/Marlin/src/lcd/menu/menu_backlash.cpp index faed8cf777..07f3c9d704 100644 --- a/Marlin/src/lcd/menu/menu_backlash.cpp +++ b/Marlin/src/lcd/menu/menu_backlash.cpp @@ -66,6 +66,15 @@ void menu_backlash() { #if HAS_K_AXIS && _CAN_CALI(K) EDIT_BACKLASH_DISTANCE(K); #endif + #if HAS_U_AXIS && _CAN_CALI(U) + EDIT_BACKLASH_DISTANCE(U); + #endif + #if HAS_V_AXIS && _CAN_CALI(V) + EDIT_BACKLASH_DISTANCE(V); + #endif + #if HAS_W_AXIS && _CAN_CALI(W) + EDIT_BACKLASH_DISTANCE(W); + #endif #ifdef BACKLASH_SMOOTHING_MM editable.decimal = backlash.get_smoothing_mm(); diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 0a446b1349..baed081036 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -106,6 +106,15 @@ void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); } #if HAS_K_AXIS void lcd_move_k() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_K), K_AXIS); } #endif +#if HAS_U_AXIS + void lcd_move_u() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_U), U_AXIS); } +#endif +#if HAS_V_AXIS + void lcd_move_v() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_V), V_AXIS); } +#endif +#if HAS_W_AXIS + void lcd_move_w() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_W), W_AXIS); } +#endif #if E_MANUAL @@ -263,6 +272,15 @@ void menu_move() { #if HAS_K_AXIS SUBMENU(MSG_MOVE_K, []{ _menu_move_distance(K_AXIS, lcd_move_k); }); #endif + #if HAS_U_AXIS + SUBMENU(MSG_MOVE_U, []{ _menu_move_distance(U_AXIS, lcd_move_u); }); + #endif + #if HAS_V_AXIS + SUBMENU(MSG_MOVE_V, []{ _menu_move_distance(V_AXIS, lcd_move_v); }); + #endif + #if HAS_W_AXIS + SUBMENU(MSG_MOVE_W, []{ _menu_move_distance(W_AXIS, lcd_move_w); }); + #endif } else GCODES_ITEM(MSG_AUTO_HOME, G28_STR); @@ -354,6 +372,15 @@ void menu_move() { #if HAS_K_AXIS GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_K)); #endif + #if HAS_U_AXIS + GCODES_ITEM_N(U_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_U)); + #endif + #if HAS_V_AXIS + GCODES_ITEM_N(V_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_V)); + #endif + #if HAS_W_AXIS + GCODES_ITEM_N(W_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_W)); + #endif END_MENU(); } @@ -407,6 +434,15 @@ void menu_motion() { #if HAS_K_AXIS GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_K)); #endif + #if HAS_U_AXIS + GCODES_ITEM_N(U_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_U)); + #endif + #if HAS_V_AXIS + GCODES_ITEM_N(V_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_V)); + #endif + #if HAS_W_AXIS + GCODES_ITEM_N(W_AXIS, MSG_AUTO_HOME_A, PSTR("G28" STR_W)); + #endif #endif #endif diff --git a/Marlin/src/lcd/menu/menu_tmc.cpp b/Marlin/src/lcd/menu/menu_tmc.cpp index 7e206e8d79..995bc3b195 100644 --- a/Marlin/src/lcd/menu/menu_tmc.cpp +++ b/Marlin/src/lcd/menu/menu_tmc.cpp @@ -134,6 +134,9 @@ void menu_tmc_current() { TERN_( I_SENSORLESS, TMC_EDIT_STORED_SGT(I)); TERN_( J_SENSORLESS, TMC_EDIT_STORED_SGT(J)); TERN_( K_SENSORLESS, TMC_EDIT_STORED_SGT(K)); + TERN_( U_SENSORLESS, TMC_EDIT_STORED_SGT(U)); + TERN_( V_SENSORLESS, TMC_EDIT_STORED_SGT(V)); + TERN_( W_SENSORLESS, TMC_EDIT_STORED_SGT(W)); END_MENU(); } diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index a8c2695630..0aa2a85439 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -37,7 +37,7 @@ L64XX_Marlin L64xxManager; #include "../../module/planner.h" #include "../../HAL/shared/Delay.h" -static const char LINEAR_AXIS_LIST( +static const char NUM_AXIS_LIST( str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ", str_I[] PROGMEM = STR_I " ", str_J[] PROGMEM = STR_J " ", str_K[] PROGMEM = STR_K " " ), @@ -53,7 +53,7 @@ static const char LINEAR_AXIS_LIST( #define _EN_ITEM(N) , str_E##N PGM_P const L64XX_Marlin::index_to_axis[] PROGMEM = { - LINEAR_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K), + NUM_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K), str_X2, str_Y2, str_Z2, str_Z3, str_Z4 REPEAT(E_STEPPERS, _EN_ITEM) }; @@ -68,7 +68,7 @@ uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction comma #define _EN_ITEM(N) , INVERT_E##N##_DIR const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { - LINEAR_AXIS_LIST(INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR, INVERT_I_DIR, INVERT_J_DIR, INVERT_K_DIR) + NUM_AXIS_LIST(INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR, INVERT_I_DIR, INVERT_J_DIR, INVERT_K_DIR) , (INVERT_X_DIR) ^ BOTH(X_DUAL_STEPPER_DRIVERS, INVERT_X2_VS_X_DIR) // X2 , (INVERT_Y_DIR) ^ BOTH(Y_DUAL_STEPPER_DRIVERS, INVERT_Y2_VS_Y_DIR) // Y2 , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2 diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.h b/Marlin/src/libs/L64XX/L64XX_Marlin.h index de7c0d6057..d00b5c16cd 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.h +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.h @@ -36,7 +36,7 @@ #define HAS_L64XX_EXTRUDER (AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7)) #define _EN_ITEM(N) , E##N -enum L64XX_axis_t : uint8_t { LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX }; +enum L64XX_axis_t : uint8_t { NUM_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX }; #undef _EN_ITEM class L64XX_Marlin : public L64XXHelper { diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index cd40175da4..39eb15f896 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -233,6 +233,9 @@ void home_delta() { TERN_(I_SENSORLESS, sensorless_t stealth_states_i = start_sensorless_homing_per_axis(I_AXIS)); TERN_(J_SENSORLESS, sensorless_t stealth_states_j = start_sensorless_homing_per_axis(J_AXIS)); TERN_(K_SENSORLESS, sensorless_t stealth_states_k = start_sensorless_homing_per_axis(K_AXIS)); + TERN_(U_SENSORLESS, sensorless_t stealth_states_u = start_sensorless_homing_per_axis(U_AXIS)); + TERN_(V_SENSORLESS, sensorless_t stealth_states_v = start_sensorless_homing_per_axis(V_AXIS)); + TERN_(W_SENSORLESS, sensorless_t stealth_states_w = start_sensorless_homing_per_axis(W_AXIS)); #endif // Move all carriages together linearly until an endstop is hit. @@ -249,6 +252,9 @@ void home_delta() { TERN_(I_SENSORLESS, end_sensorless_homing_per_axis(I_AXIS, stealth_states_i)); TERN_(J_SENSORLESS, end_sensorless_homing_per_axis(J_AXIS, stealth_states_j)); TERN_(K_SENSORLESS, end_sensorless_homing_per_axis(K_AXIS, stealth_states_k)); + TERN_(U_SENSORLESS, end_sensorless_homing_per_axis(U_AXIS, stealth_states_u)); + TERN_(V_SENSORLESS, end_sensorless_homing_per_axis(V_AXIS, stealth_states_v)); + TERN_(W_SENSORLESS, end_sensorless_homing_per_axis(W_AXIS, stealth_states_w)); #endif endstops.validate_homing_move(); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 3dd6d8aeb6..7381e98b01 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -319,6 +319,66 @@ void Endstops::init() { #endif #endif + #if HAS_U_MIN + #if ENABLED(ENDSTOPPULLUP_UMIN) + SET_INPUT_PULLUP(U_MIN_PIN); + #elif ENABLED(ENDSTOPPULLDOWN_UMIN) + SET_INPUT_PULLDOWN(U_MIN_PIN); + #else + SET_INPUT(U_MIN_PIN); + #endif + #endif + + #if HAS_U_MAX + #if ENABLED(ENDSTOPPULLUP_UMAX) + SET_INPUT_PULLUP(U_MAX_PIN); + #elif ENABLED(ENDSTOPPULLDOWN_UMIN) + SET_INPUT_PULLDOWN(U_MAX_PIN); + #else + SET_INPUT(U_MAX_PIN); + #endif + #endif + + #if HAS_V_MIN + #if ENABLED(ENDSTOPPULLUP_VMIN) + SET_INPUT_PULLUP(V_MIN_PIN); + #elif ENABLED(ENDSTOPPULLDOWN_VMIN) + SET_INPUT_PULLDOWN(V_MIN_PIN); + #else + SET_INPUT(V_MIN_PIN); + #endif + #endif + + #if HAS_V_MAX + #if ENABLED(ENDSTOPPULLUP_VMAX) + SET_INPUT_PULLUP(V_MAX_PIN); + #elif ENABLED(ENDSTOPPULLDOWN_VMIN) + SET_INPUT_PULLDOWN(V_MAX_PIN); + #else + SET_INPUT(V_MAX_PIN); + #endif + #endif + + #if HAS_W_MIN + #if ENABLED(ENDSTOPPULLUP_WMIN) + SET_INPUT_PULLUP(W_MIN_PIN); + #elif ENABLED(ENDSTOPPULLDOWN_WMIN) + SET_INPUT_PULLDOWN(W_MIN_PIN); + #else + SET_INPUT(W_MIN_PIN); + #endif + #endif + + #if HAS_W_MAX + #if ENABLED(ENDSTOPPULLUP_WMAX) + SET_INPUT_PULLUP(W_MAX_PIN); + #elif ENABLED(ENDSTOPPULLDOWN_WMIN) + SET_INPUT_PULLDOWN(W_MAX_PIN); + #else + SET_INPUT(W_MAX_PIN); + #endif + #endif + #if PIN_EXISTS(CALIBRATION) #if ENABLED(CALIBRATION_PIN_PULLUP) SET_INPUT_PULLUP(CALIBRATION_PIN); @@ -424,7 +484,7 @@ void Endstops::event_handler() { prev_hit_state = hit_state; if (hit_state) { #if HAS_STATUS_MESSAGE - char LINEAR_AXIS_LIST(chrX = ' ', chrY = ' ', chrZ = ' ', chrI = ' ', chrJ = ' ', chrK = ' '), + char NUM_AXIS_LIST(chrX = ' ', chrY = ' ', chrZ = ' ', chrI = ' ', chrJ = ' ', chrK = ' ', chrU = ' ', chrV = ' ', chrW = ' '), chrP = ' '; #define _SET_STOP_CHAR(A,C) (chr## A = C) #else @@ -444,16 +504,22 @@ void Endstops::event_handler() { #define ENDSTOP_HIT_TEST_I() _ENDSTOP_HIT_TEST(I,'I') #define ENDSTOP_HIT_TEST_J() _ENDSTOP_HIT_TEST(J,'J') #define ENDSTOP_HIT_TEST_K() _ENDSTOP_HIT_TEST(K,'K') + #define ENDSTOP_HIT_TEST_U() _ENDSTOP_HIT_TEST(U,'U') + #define ENDSTOP_HIT_TEST_V() _ENDSTOP_HIT_TEST(V,'V') + #define ENDSTOP_HIT_TEST_W() _ENDSTOP_HIT_TEST(W,'W') SERIAL_ECHO_START(); SERIAL_ECHOPGM(STR_ENDSTOPS_HIT); - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( ENDSTOP_HIT_TEST_X(), ENDSTOP_HIT_TEST_Y(), ENDSTOP_HIT_TEST_Z(), _ENDSTOP_HIT_TEST(I,'I'), _ENDSTOP_HIT_TEST(J,'J'), - _ENDSTOP_HIT_TEST(K,'K') + _ENDSTOP_HIT_TEST(K,'K'), + _ENDSTOP_HIT_TEST(U,'U'), + _ENDSTOP_HIT_TEST(V,'V'), + _ENDSTOP_HIT_TEST(W,'W') ); #if USES_Z_MIN_PROBE_PIN @@ -464,9 +530,9 @@ void Endstops::event_handler() { TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, - F(S_FMT GANG_N_1(LINEAR_AXES, " %c") " %c"), + F(S_FMT GANG_N_1(NUM_AXES, " %c") " %c"), GET_TEXT(MSG_LCD_ENDSTOPS), - LINEAR_AXIS_LIST(chrX, chrY, chrZ, chrI, chrJ, chrK), chrP + NUM_AXIS_LIST(chrX, chrY, chrZ, chrI, chrJ, chrK, chrU, chrV, chrW), chrP ) ); @@ -564,6 +630,24 @@ void _O2 Endstops::report_states() { #if HAS_K_MAX ES_REPORT(K_MAX); #endif + #if HAS_U_MIN + ES_REPORT(U_MIN); + #endif + #if HAS_U_MAX + ES_REPORT(U_MAX); + #endif + #if HAS_V_MIN + ES_REPORT(V_MIN); + #endif + #if HAS_V_MAX + ES_REPORT(V_MAX); + #endif + #if HAS_W_MIN + ES_REPORT(W_MIN); + #endif + #if HAS_W_MAX + ES_REPORT(W_MAX); + #endif #if ENABLED(PROBE_ACTIVATION_SWITCH) print_es_state(probe_switch_activated(), F(STR_PROBE_EN)); #endif @@ -649,6 +733,9 @@ void Endstops::update() { #define I_AXIS_HEAD I_AXIS #define J_AXIS_HEAD J_AXIS #define K_AXIS_HEAD K_AXIS + #define U_AXIS_HEAD U_AXIS + #define V_AXIS_HEAD V_AXIS + #define W_AXIS_HEAD W_AXIS /** * Check and update endstops @@ -835,6 +922,82 @@ void Endstops::update() { #endif #endif + #if HAS_U_MIN && !U_SPI_SENSORLESS + #if ENABLED(U_DUAL_ENDSTOPS) + UPDATE_ENDSTOP_BIT(U, MIN); + #if HAS_U2_MIN + UPDATE_ENDSTOP_BIT(U2, MIN); + #else + COPY_LIVE_STATE(U_MIN, U2_MIN); + #endif + #else + UPDATE_ENDSTOP_BIT(U, MIN); + #endif + #endif + + #if HAS_U_MAX && !U_SPI_SENSORLESS + #if ENABLED(U_DUAL_ENDSTOPS) + UPDATE_ENDSTOP_BIT(U, MAX); + #if HAS_U2_MAX + UPDATE_ENDSTOP_BIT(U2, MAX); + #else + COPY_LIVE_STATE(U_MAX, U2_MAX); + #endif + #else + UPDATE_ENDSTOP_BIT(U, MAX); + #endif + #endif + + #if HAS_V_MIN && !V_SPI_SENSORLESS + #if ENABLED(V_DUAL_ENDSTOPS) + UPDATE_ENDSTOP_BIT(V, MIN); + #if HAS_V2_MIN + UPDATE_ENDSTOP_BIT(V2, MIN); + #else + COPY_LIVE_STATE(V_MIN, V2_MIN); + #endif + #else + UPDATE_ENDSTOP_BIT(V, MIN); + #endif + #endif + #if HAS_V_MAX && !V_SPI_SENSORLESS + #if ENABLED(O_DUAL_ENDSTOPS) + UPDATE_ENDSTOP_BIT(V, MAX); + #if HAS_V2_MAX + UPDATE_ENDSTOP_BIT(V2, MAX); + #else + COPY_LIVE_STATE(V_MAX, V2_MAX); + #endif + #else + UPDATE_ENDSTOP_BIT(V, MAX); + #endif + #endif + + #if HAS_W_MIN && !W_SPI_SENSORLESS + #if ENABLED(W_DUAL_ENDSTOPS) + UPDATE_ENDSTOP_BIT(W, MIN); + #if HAS_W2_MIN + UPDATE_ENDSTOP_BIT(W2, MIN); + #else + COPY_LIVE_STATE(W_MIN, W2_MIN); + #endif + #else + UPDATE_ENDSTOP_BIT(W, MIN); + #endif + #endif + #if HAS_W_MAX && !W_SPI_SENSORLESS + #if ENABLED(W_DUAL_ENDSTOPS) + UPDATE_ENDSTOP_BIT(W, MAX); + #if HAS_W2_MAX + UPDATE_ENDSTOP_BIT(W2, MAX); + #else + COPY_LIVE_STATE(W_MAX, W2_MAX); + #endif + #else + UPDATE_ENDSTOP_BIT(W, MAX); + #endif + #endif + #if ENDSTOP_NOISE_THRESHOLD /** @@ -935,7 +1098,7 @@ void Endstops::update() { #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX) #endif - #if HAS_G38_PROBE + #if HAS_G38_PROBE // TODO (DerAndere): Add support for HAS_I_AXIS #define _G38_OPEN_STATE TERN(G38_PROBE_AWAY, (G38_move >= 4), LOW) // For G38 moves check the probe's pin for ALL movement if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) != _G38_OPEN_STATE) { @@ -1105,6 +1268,51 @@ void Endstops::update() { } } #endif + + #if HAS_U_AXIS + if (stepper.axis_is_moving(U_AXIS)) { + if (stepper.motor_direction(U_AXIS_HEAD)) { // -direction + #if HAS_U_MIN || (U_SPI_SENSORLESS && U_HOME_TO_MIN) + PROCESS_ENDSTOP(U, MIN); + #endif + } + else { // +direction + #if HAS_U_MAX || (U_SPI_SENSORLESS && U_HOME_TO_MAX) + PROCESS_ENDSTOP(U, MAX); + #endif + } + } + #endif + + #if HAS_V_AXIS + if (stepper.axis_is_moving(V_AXIS)) { + if (stepper.motor_direction(V_AXIS_HEAD)) { // -direction + #if HAS_V_MIN || (V_SPI_SENSORLESS && V_HOME_TO_MIN) + PROCESS_ENDSTOP(V, MIN); + #endif + } + else { // +direction + #if HAS_V_MAX || (V_SPI_SENSORLESS && V_HOME_TO_MAX) + PROCESS_ENDSTOP(V, MAX); + #endif + } + } + #endif + + #if HAS_W_AXIS + if (stepper.axis_is_moving(W_AXIS)) { + if (stepper.motor_direction(W_AXIS_HEAD)) { // -direction + #if HAS_W_MIN || (W_SPI_SENSORLESS && W_HOME_TO_MIN) + PROCESS_ENDSTOP(W, MIN); + #endif + } + else { // +direction + #if HAS_W_MAX || (W_SPI_SENSORLESS && W_HOME_TO_MAX) + PROCESS_ENDSTOP(W, MAX); + #endif + } + } + #endif } // Endstops::update() #if ENABLED(SPI_ENDSTOPS) @@ -1166,6 +1374,24 @@ void Endstops::update() { hit = true; } #endif + #if U_SPI_SENSORLESS + if (tmc_spi_homing.u && stepperU.test_stall_status()) { + SBI(live_state, U_ENDSTOP); + hit = true; + } + #endif + #if V_SPI_SENSORLESS + if (tmc_spi_homing.v && stepperV.test_stall_status()) { + SBI(live_state, V_ENDSTOP); + hit = true; + } + #endif + #if W_SPI_SENSORLESS + if (tmc_spi_homing.w && stepperW.test_stall_status()) { + SBI(live_state, W_ENDSTOP); + hit = true; + } + #endif if (TERN0(ENDSTOP_INTERRUPTS_FEATURE, hit)) update(); @@ -1179,6 +1405,9 @@ void Endstops::update() { TERN_(I_SPI_SENSORLESS, CBI(live_state, I_ENDSTOP)); TERN_(J_SPI_SENSORLESS, CBI(live_state, J_ENDSTOP)); TERN_(K_SPI_SENSORLESS, CBI(live_state, K_ENDSTOP)); + TERN_(U_SPI_SENSORLESS, CBI(live_state, U_ENDSTOP)); + TERN_(V_SPI_SENSORLESS, CBI(live_state, V_ENDSTOP)); + TERN_(W_SPI_SENSORLESS, CBI(live_state, W_ENDSTOP)); } #endif // SPI_ENDSTOPS @@ -1273,6 +1502,24 @@ void Endstops::update() { #if HAS_K_MIN ES_GET_STATE(K_MIN); #endif + #if HAS_U_MAX + ES_GET_STATE(U_MAX); + #endif + #if HAS_U_MIN + ES_GET_STATE(U_MIN); + #endif + #if HAS_V_MAX + ES_GET_STATE(V_MAX); + #endif + #if HAS_V_MIN + ES_GET_STATE(V_MIN); + #endif + #if HAS_W_MAX + ES_GET_STATE(W_MAX); + #endif + #if HAS_W_MIN + ES_GET_STATE(W_MIN); + #endif uint16_t endstop_change = live_state_local ^ old_live_state_local; #define ES_REPORT_CHANGE(S) if (TEST(endstop_change, S)) SERIAL_ECHOPGM(" " STRINGIFY(S) ":", TEST(live_state_local, S)) @@ -1347,6 +1594,25 @@ void Endstops::update() { #if HAS_K_MAX ES_REPORT_CHANGE(K_MAX); #endif + #if HAS_U_MIN + ES_REPORT_CHANGE(U_MIN); + #endif + #if HAS_U_MAX + ES_REPORT_CHANGE(U_MAX); + #endif + #if HAS_V_MIN + ES_REPORT_CHANGE(V_MIN); + #endif + #if HAS_V_MAX + ES_REPORT_CHANGE(V_MAX); + #endif + #if HAS_W_MIN + ES_REPORT_CHANGE(W_MIN); + #endif + #if HAS_W_MAX + ES_REPORT_CHANGE(W_MAX); + #endif + SERIAL_ECHOLNPGM("\n"); hal.set_pwm_duty(pin_t(LED_PIN), local_LED_status); local_LED_status ^= 255; diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 82a44cf95b..1848e6cdcf 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -45,6 +45,12 @@ enum EndstopEnum : char { _ES_ITEM(HAS_J_MAX, J_MAX) _ES_ITEM(HAS_K_MIN, K_MIN) _ES_ITEM(HAS_K_MAX, K_MAX) + _ES_ITEM(HAS_U_MIN, U_MIN) + _ES_ITEM(HAS_U_MAX, U_MAX) + _ES_ITEM(HAS_V_MIN, V_MIN) + _ES_ITEM(HAS_V_MAX, V_MAX) + _ES_ITEM(HAS_W_MIN, W_MIN) + _ES_ITEM(HAS_W_MAX, W_MAX) // Extra Endstops for XYZ #if ENABLED(X_DUAL_ENDSTOPS) @@ -234,7 +240,7 @@ class Endstops { typedef struct { union { bool any; - struct { bool LINEAR_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1); }; + struct { bool NUM_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1); }; }; } tmc_spi_homing_t; static tmc_spi_homing_t tmc_spi_homing; diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index d8df8e12e1..3037c38bb0 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -84,7 +84,7 @@ bool relative_mode; // = false; #define Z_INIT_POS Z_HOME_POS #endif -xyze_pos_t current_position = LOGICAL_AXIS_ARRAY(0, X_HOME_POS, Y_HOME_POS, Z_INIT_POS, I_HOME_POS, J_HOME_POS, K_HOME_POS); +xyze_pos_t current_position = LOGICAL_AXIS_ARRAY(0, X_HOME_POS, Y_HOME_POS, Z_INIT_POS, I_HOME_POS, J_HOME_POS, K_HOME_POS, U_HOME_POS, V_HOME_POS, W_HOME_POS); /** * Cartesian Destination @@ -189,13 +189,16 @@ inline void report_more_positions() { inline void report_logical_position(const xyze_pos_t &rpos) { const xyze_pos_t lpos = rpos.asLogical(); SERIAL_ECHOPGM_P( - LIST_N(DOUBLE(LINEAR_AXES), + LIST_N(DOUBLE(NUM_AXES), X_LBL, lpos.x, SP_Y_LBL, lpos.y, SP_Z_LBL, lpos.z, SP_I_LBL, lpos.i, SP_J_LBL, lpos.j, - SP_K_LBL, lpos.k + SP_K_LBL, lpos.k, + SP_U_LBL, lpos.u, + SP_V_LBL, lpos.v, + SP_W_LBL, lpos.w ) #if HAS_EXTRUDERS , SP_E_LBL, lpos.e @@ -210,7 +213,8 @@ void report_real_position() { xyze_pos_t npos = LOGICAL_AXIS_ARRAY( planner.get_axis_position_mm(E_AXIS), cartes.x, cartes.y, cartes.z, - cartes.i, cartes.j, cartes.k + cartes.i, cartes.j, cartes.k, + cartes.u, cartes.v, cartes.w ); TERN_(HAS_POSITION_MODIFIERS, planner.unapply_modifiers(npos, true)); @@ -258,13 +262,16 @@ void report_current_position_projected() { const xyz_pos_t lpos = cartes.asLogical(); SERIAL_ECHOPGM_P( - LIST_N(DOUBLE(LINEAR_AXES), + LIST_N(DOUBLE(NUM_AXES), X_LBL, lpos.x, SP_Y_LBL, lpos.y, SP_Z_LBL, lpos.z, SP_I_LBL, lpos.i, SP_J_LBL, lpos.j, - SP_K_LBL, lpos.k + SP_K_LBL, lpos.k, + SP_U_LBL, lpos.u, + SP_V_LBL, lpos.v, + SP_W_LBL, lpos.w ) #if HAS_EXTRUDERS , SP_E_LBL, current_position.e @@ -355,13 +362,16 @@ void get_cartesian_from_steppers() { ); cartes.z = planner.get_axis_position_mm(Z_AXIS); #else - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( cartes.x = planner.get_axis_position_mm(X_AXIS), cartes.y = planner.get_axis_position_mm(Y_AXIS), cartes.z = planner.get_axis_position_mm(Z_AXIS), cartes.i = planner.get_axis_position_mm(I_AXIS), cartes.j = planner.get_axis_position_mm(J_AXIS), - cartes.k = planner.get_axis_position_mm(K_AXIS) + cartes.k = planner.get_axis_position_mm(K_AXIS), + cartes.u = planner.get_axis_position_mm(U_AXIS), + cartes.v = planner.get_axis_position_mm(V_AXIS), + cartes.w = planner.get_axis_position_mm(W_AXIS) ); #endif } @@ -468,24 +478,23 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ * - Delta may lower Z first to get into the free motion zone. * - Before returning, wait for the planner buffer to empty. */ -void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s/*=0.0f*/) { +void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s/*=0.0f*/) { DEBUG_SECTION(log_move, "do_blocking_move_to", DEBUGGING(LEVELING)); - if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", LINEAR_AXIS_ARGS()); + if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", NUM_AXIS_ARGS()); const feedRate_t xy_feedrate = fr_mm_s ?: feedRate_t(XY_PROBE_FEEDRATE_MM_S); #if HAS_Z_AXIS const feedRate_t z_feedrate = fr_mm_s ?: homing_feedrate(Z_AXIS); #endif - #if HAS_I_AXIS - const feedRate_t i_feedrate = fr_mm_s ?: homing_feedrate(I_AXIS); - #endif - #if HAS_J_AXIS - const feedRate_t j_feedrate = fr_mm_s ?: homing_feedrate(J_AXIS); - #endif - #if HAS_K_AXIS - const feedRate_t k_feedrate = fr_mm_s ?: homing_feedrate(K_AXIS); - #endif + SECONDARY_AXIS_CODE( + const feedRate_t i_feedrate = fr_mm_s ?: homing_feedrate(I_AXIS), + const feedRate_t j_feedrate = fr_mm_s ?: homing_feedrate(J_AXIS), + const feedRate_t k_feedrate = fr_mm_s ?: homing_feedrate(K_AXIS), + const feedRate_t u_feedrate = fr_mm_s ?: homing_feedrate(U_AXIS), + const feedRate_t v_feedrate = fr_mm_s ?: homing_feedrate(V_AXIS), + const feedRate_t w_feedrate = fr_mm_s ?: homing_feedrate(W_AXIS) + ); #if IS_KINEMATIC if (!position_is_reachable(x, y)) return; @@ -554,7 +563,18 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s #if HAS_K_AXIS current_position.k = k; line_to_current_position(k_feedrate); #endif - #if HAS_Z_AXIS // If Z needs to lower, do it after moving XY... + #if HAS_U_AXIS + current_position.u = u; line_to_current_position(u_feedrate); + #endif + #if HAS_V_AXIS + current_position.v = v; line_to_current_position(v_feedrate); + #endif + #if HAS_W_AXIS + current_position.w = w; line_to_current_position(w_feedrate); + #endif + + #if HAS_Z_AXIS + // If Z needs to lower, do it after moving XY if (current_position.z > z) { current_position.z = z; line_to_current_position(z_feedrate); } #endif @@ -564,17 +584,19 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s } void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(LINEAR_AXIS_LIST(raw.x, raw.y, current_position.z, current_position.i, current_position.j, current_position.k), fr_mm_s); + do_blocking_move_to(NUM_AXIS_LIST(raw.x, raw.y, current_position.z, current_position.i, current_position.j, current_position.k, + current_position.u, current_position.v, current_position.w), fr_mm_s); } void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(LINEAR_AXIS_ELEM(raw), fr_mm_s); + do_blocking_move_to(NUM_AXIS_ELEM(raw), fr_mm_s); } void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*/) { - do_blocking_move_to(LINEAR_AXIS_ELEM(raw), fr_mm_s); + do_blocking_move_to(NUM_AXIS_ELEM(raw), fr_mm_s); } void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to( - LINEAR_AXIS_LIST(rx, current_position.y, current_position.z, current_position.i, current_position.j, current_position.k), + NUM_AXIS_LIST(rx, current_position.y, current_position.z, current_position.i, current_position.j, current_position.k, + current_position.u, current_position.v, current_position.w), fr_mm_s ); } @@ -582,7 +604,8 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { #if HAS_Y_AXIS void do_blocking_move_to_y(const_float_t ry, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to( - LINEAR_AXIS_LIST(current_position.x, ry, current_position.z, current_position.i, current_position.j, current_position.k), + NUM_AXIS_LIST(current_position.x, ry, current_position.z, current_position.i, current_position.j, current_position.k, + current_position.u, current_position.v, current_position.w), fr_mm_s ); } @@ -600,7 +623,7 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } void do_blocking_move_to_xyz_i(const xyze_pos_t &raw, const_float_t i, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to( - LINEAR_AXIS_LIST(raw.x, raw.y, raw.z, i, raw.j, raw.k), + NUM_AXIS_LIST(raw.x, raw.y, raw.z, i, raw.j, raw.k, raw.u, raw.v, raw.w), fr_mm_s ); } @@ -612,7 +635,7 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } void do_blocking_move_to_xyzi_j(const xyze_pos_t &raw, const_float_t j, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to( - LINEAR_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, j, raw.k), + NUM_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, j, raw.k, raw.u, raw.v, raw.w), fr_mm_s ); } @@ -624,7 +647,43 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } void do_blocking_move_to_xyzij_k(const xyze_pos_t &raw, const_float_t k, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to( - LINEAR_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, raw.j, k), + NUM_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, raw.j, k, raw.u, raw.v, raw.w), + fr_mm_s + ); + } +#endif + +#if HAS_U_AXIS + void do_blocking_move_to_u(const_float_t ru, const_feedRate_t fr_mm_s/*=0.0*/) { + do_blocking_move_to_xyzijk_u(current_position, ru, fr_mm_s); + } + void do_blocking_move_to_xyzijk_u(const xyze_pos_t &raw, const_float_t u, const_feedRate_t fr_mm_s/*=0.0f*/) { + do_blocking_move_to( + NUM_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, raw.j, raw.k, u, raw.v, raw.w), + fr_mm_s + ); + } +#endif + +#if HAS_V_AXIS + void do_blocking_move_to_v(const_float_t rv, const_feedRate_t fr_mm_s/*=0.0*/) { + do_blocking_move_to_xyzijku_v(current_position, rv, fr_mm_s); + } + void do_blocking_move_to_xyzijku_v(const xyze_pos_t &raw, const_float_t v, const_feedRate_t fr_mm_s/*=0.0f*/) { + do_blocking_move_to( + NUM_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, raw.j, raw.k, raw.u, v, raw.w), + fr_mm_s + ); + } +#endif + +#if HAS_W_AXIS + void do_blocking_move_to_w(const_float_t rw, const_feedRate_t fr_mm_s/*=0.0*/) { + do_blocking_move_to_xyzijkuv_w(current_position, rw, fr_mm_s); + } + void do_blocking_move_to_xyzijkuv_w(const xyze_pos_t &raw, const_float_t w, const_feedRate_t fr_mm_s/*=0.0f*/) { + do_blocking_move_to( + NUM_AXIS_LIST(raw.x, raw.y, raw.z, raw.i, raw.j, raw.k, raw.u, raw.v, w), fr_mm_s ); } @@ -633,7 +692,8 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { #if HAS_Y_AXIS void do_blocking_move_to_xy(const_float_t rx, const_float_t ry, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to( - LINEAR_AXIS_LIST(rx, ry, current_position.z, current_position.i, current_position.j, current_position.k), + NUM_AXIS_LIST(rx, ry, current_position.z, current_position.i, current_position.j, current_position.k, + current_position.u, current_position.v, current_position.w), fr_mm_s ); } @@ -645,7 +705,8 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { #if HAS_Z_AXIS void do_blocking_move_to_xy_z(const xy_pos_t &raw, const_float_t z, const_feedRate_t fr_mm_s/*=0.0f*/) { do_blocking_move_to( - LINEAR_AXIS_LIST(raw.x, raw.y, z, current_position.i, current_position.j, current_position.k), + NUM_AXIS_LIST(raw.x, raw.y, z, current_position.i, current_position.j, current_position.k, + current_position.u, current_position.v, current_position.w), fr_mm_s ); } @@ -680,8 +741,8 @@ void restore_feedrate_and_scaling() { // Software Endstops are based on the configured limits. soft_endstops_t soft_endstop = { true, false, - LINEAR_AXIS_ARRAY(X_MIN_POS, Y_MIN_POS, Z_MIN_POS, I_MIN_POS, J_MIN_POS, K_MIN_POS), - LINEAR_AXIS_ARRAY(X_MAX_BED, Y_MAX_BED, Z_MAX_POS, I_MAX_POS, J_MAX_POS, K_MAX_POS) + NUM_AXIS_ARRAY(X_MIN_POS, Y_MIN_POS, Z_MIN_POS, I_MIN_POS, J_MIN_POS, K_MIN_POS, U_MIN_POS, V_MIN_POS, W_MIN_POS), + NUM_AXIS_ARRAY(X_MAX_BED, Y_MAX_BED, Z_MAX_POS, I_MAX_POS, J_MAX_POS, K_MAX_POS, U_MAX_POS, V_MAX_POS, W_MAX_POS) }; /** @@ -860,6 +921,36 @@ void restore_feedrate_and_scaling() { #endif } #endif + #if HAS_U_AXIS + if (axis_was_homed(U_AXIS)) { + #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_U) + NOLESS(target.u, soft_endstop.min.u); + #endif + #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_U) + NOMORE(target.u, soft_endstop.max.u); + #endif + } + #endif + #if HAS_V_AXIS + if (axis_was_homed(V_AXIS)) { + #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_V) + NOLESS(target.v, soft_endstop.min.v); + #endif + #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_V) + NOMORE(target.v, soft_endstop.max.v); + #endif + } + #endif + #if HAS_W_AXIS + if (axis_was_homed(W_AXIS)) { + #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_W) + NOLESS(target.w, soft_endstop.min.w); + #endif + #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MAX_SOFTWARE_ENDSTOP_W) + NOMORE(target.w, soft_endstop.max.w); + #endif + } + #endif } #else // !HAS_SOFTWARE_ENDSTOPS @@ -1297,9 +1388,10 @@ void prepare_line_to_destination() { CBI(b, a); }; // Clear test bits that are trusted - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( set_should(axis_bits, X_AXIS), set_should(axis_bits, Y_AXIS), set_should(axis_bits, Z_AXIS), - set_should(axis_bits, I_AXIS), set_should(axis_bits, J_AXIS), set_should(axis_bits, K_AXIS) + set_should(axis_bits, I_AXIS), set_should(axis_bits, J_AXIS), set_should(axis_bits, K_AXIS), + set_should(axis_bits, U_AXIS), set_should(axis_bits, V_AXIS), set_should(axis_bits, W_AXIS) ); return axis_bits; } @@ -1309,13 +1401,16 @@ void prepare_line_to_destination() { PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); char msg[strlen_P(home_first)+1]; sprintf_P(msg, home_first, - LINEAR_AXIS_LIST( - TEST(axis_bits, X_AXIS) ? "X" : "", - TEST(axis_bits, Y_AXIS) ? "Y" : "", - TEST(axis_bits, Z_AXIS) ? "Z" : "", + NUM_AXIS_LIST( + TEST(axis_bits, X_AXIS) ? STR_A : "", + TEST(axis_bits, Y_AXIS) ? STR_B : "", + TEST(axis_bits, Z_AXIS) ? STR_C : "", TEST(axis_bits, I_AXIS) ? STR_I : "", TEST(axis_bits, J_AXIS) ? STR_J : "", - TEST(axis_bits, K_AXIS) ? STR_K : "" + TEST(axis_bits, K_AXIS) ? STR_K : "", + TEST(axis_bits, U_AXIS) ? STR_U : "", + TEST(axis_bits, V_AXIS) ? STR_V : "", + TEST(axis_bits, W_AXIS) ? STR_W : "" ) ); SERIAL_ECHO_START(); @@ -1395,6 +1490,15 @@ void prepare_line_to_destination() { #if K_SENSORLESS case K_AXIS: stealth_states.k = tmc_enable_stallguard(stepperK); break; #endif + #if U_SENSORLESS + case U_AXIS: stealth_states.u = tmc_enable_stallguard(stepperU); break; + #endif + #if V_SENSORLESS + case V_AXIS: stealth_states.v = tmc_enable_stallguard(stepperV); break; + #endif + #if W_SENSORLESS + case W_AXIS: stealth_states.w = tmc_enable_stallguard(stepperW); break; + #endif } #if ENABLED(SPI_ENDSTOPS) @@ -1415,6 +1519,15 @@ void prepare_line_to_destination() { #if HAS_K_AXIS case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = true; break; #endif + #if HAS_U_AXIS + case U_AXIS: if (ENABLED(U_SPI_SENSORLESS)) endstops.tmc_spi_homing.u = true; break; + #endif + #if HAS_V_AXIS + case V_AXIS: if (ENABLED(V_SPI_SENSORLESS)) endstops.tmc_spi_homing.v = true; break; + #endif + #if HAS_W_AXIS + case W_AXIS: if (ENABLED(W_SPI_SENSORLESS)) endstops.tmc_spi_homing.w = true; break; + #endif default: break; } #endif @@ -1471,6 +1584,15 @@ void prepare_line_to_destination() { #if K_SENSORLESS case K_AXIS: tmc_disable_stallguard(stepperK, enable_stealth.k); break; #endif + #if U_SENSORLESS + case U_AXIS: tmc_disable_stallguard(stepperU, enable_stealth.u); break; + #endif + #if V_SENSORLESS + case V_AXIS: tmc_disable_stallguard(stepperV, enable_stealth.v); break; + #endif + #if W_SENSORLESS + case W_AXIS: tmc_disable_stallguard(stepperW, enable_stealth.w); break; + #endif } #if ENABLED(SPI_ENDSTOPS) @@ -1491,6 +1613,15 @@ void prepare_line_to_destination() { #if HAS_K_AXIS case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = false; break; #endif + #if HAS_U_AXIS + case U_AXIS: if (ENABLED(U_SPI_SENSORLESS)) endstops.tmc_spi_homing.u = false; break; + #endif + #if HAS_V_AXIS + case V_AXIS: if (ENABLED(V_SPI_SENSORLESS)) endstops.tmc_spi_homing.v = false; break; + #endif + #if HAS_W_AXIS + case W_AXIS: if (ENABLED(W_SPI_SENSORLESS)) endstops.tmc_spi_homing.w = false; break; + #endif default: break; } #endif @@ -1667,6 +1798,30 @@ void prepare_line_to_destination() { stepperBackoutDir = INVERT_K_DIR ? effectorBackoutDir : -effectorBackoutDir; break; #endif + #ifdef U_MICROSTEPS + case U_AXIS: + phasePerUStep = PHASE_PER_MICROSTEP(U); + phaseCurrent = stepperU.get_microstep_counter(); + effectorBackoutDir = -U_HOME_DIR; + stepperBackoutDir = INVERT_U_DIR ? effectorBackoutDir : -effectorBackoutDir; + break; + #endif + #ifdef V_MICROSTEPS + case V_AXIS: + phasePerUStep = PHASE_PER_MICROSTEP(V); + phaseCurrent = stepperV.get_microstep_counter(); + effectorBackoutDir = -V_HOME_DIR; + stepperBackoutDir = INVERT_V_DIR ? effectorBackoutDir : -effectorBackoutDir; + break; + #endif + #ifdef W_MICROSTEPS + case W_AXIS: + phasePerUStep = PHASE_PER_MICROSTEP(W); + phaseCurrent = stepperW.get_microstep_counter(); + effectorBackoutDir = -W_HOME_DIR; + stepperBackoutDir = INVERT_W_DIR ? effectorBackoutDir : -effectorBackoutDir; + break; + #endif default: return; } @@ -1723,13 +1878,16 @@ void prepare_line_to_destination() { || TERN0(A##_HOME_TO_MIN, A##_MIN_PIN > -1) \ || TERN0(A##_HOME_TO_MAX, A##_MAX_PIN > -1) \ )) - if (LINEAR_AXIS_GANG( + if (NUM_AXIS_GANG( !_CAN_HOME(X), && !_CAN_HOME(Y), && !_CAN_HOME(Z), && !_CAN_HOME(I), && !_CAN_HOME(J), - && !_CAN_HOME(K)) + && !_CAN_HOME(K), + && !_CAN_HOME(U), + && !_CAN_HOME(V), + && !_CAN_HOME(W)) ) return; #endif @@ -1822,6 +1980,15 @@ void prepare_line_to_destination() { #if HAS_K_AXIS case K_AXIS: es = K_ENDSTOP; break; #endif + #if HAS_U_AXIS + case U_AXIS: es = U_ENDSTOP; break; + #endif + #if HAS_V_AXIS + case V_AXIS: es = V_ENDSTOP; break; + #endif + #if HAS_W_AXIS + case W_AXIS: es = W_ENDSTOP; break; + #endif } if (TEST(endstops.state(), es)) { SERIAL_ECHO_MSG("Bad ", AS_CHAR(AXIS_CHAR(axis)), " Endstop?"); diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 1dd6d8c4ed..45dae5d609 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -44,7 +44,7 @@ extern xyze_pos_t current_position, // High-level current tool position // G60/G61 Position Save and Return #if SAVED_POSITIONS - extern uint8_t saved_slots[(SAVED_POSITIONS + 7) >> 3]; // TODO: Add support for LINEAR_AXES >= 4 + extern uint8_t saved_slots[(SAVED_POSITIONS + 7) >> 3]; // TODO: Add support for HAS_I_AXIS extern xyze_pos_t stored_position[SAVED_POSITIONS]; #endif @@ -77,13 +77,16 @@ constexpr xyz_feedrate_t homing_feedrate_mm_m = HOMING_FEEDRATE_MM_M; FORCE_INLINE feedRate_t homing_feedrate(const AxisEnum a) { float v = TERN0(HAS_Z_AXIS, homing_feedrate_mm_m.z); #if DISABLED(DELTA) - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( if (a == X_AXIS) v = homing_feedrate_mm_m.x, else if (a == Y_AXIS) v = homing_feedrate_mm_m.y, else if (a == Z_AXIS) v = homing_feedrate_mm_m.z, else if (a == I_AXIS) v = homing_feedrate_mm_m.i, else if (a == J_AXIS) v = homing_feedrate_mm_m.j, - else if (a == K_AXIS) v = homing_feedrate_mm_m.k + else if (a == K_AXIS) v = homing_feedrate_mm_m.k, + else if (a == U_AXIS) v = homing_feedrate_mm_m.u, + else if (a == V_AXIS) v = homing_feedrate_mm_m.v, + else if (a == W_AXIS) v = homing_feedrate_mm_m.w ); #endif return MMM_TO_MMS(v); @@ -124,7 +127,7 @@ inline int8_t pgm_read_any(const int8_t *p) { return TERN(__IMXRT1062__, *p, pgm #define XYZ_DEFS(T, NAME, OPT) \ inline T NAME(const AxisEnum axis) { \ - static const XYZval NAME##_P DEFS_PROGMEM = LINEAR_AXIS_ARRAY(X_##OPT, Y_##OPT, Z_##OPT, I_##OPT, J_##OPT, K_##OPT); \ + static const XYZval NAME##_P DEFS_PROGMEM = NUM_AXIS_ARRAY(X_##OPT, Y_##OPT, Z_##OPT, I_##OPT, J_##OPT, K_##OPT, U_##OPT, V_##OPT, W_##OPT); \ return pgm_read_any(&NAME##_P[axis]); \ } XYZ_DEFS(float, base_min_pos, MIN_POS); @@ -198,6 +201,24 @@ inline float home_bump_mm(const AxisEnum axis) { TERN_(MIN_SOFTWARE_ENDSTOP_K, amax = max.k); break; #endif + #if HAS_U_AXIS + case U_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_U, amin = min.u); + TERN_(MIN_SOFTWARE_ENDSTOP_U, amax = max.u); + break; + #endif + #if HAS_V_AXIS + case V_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_V, amin = min.v); + TERN_(MIN_SOFTWARE_ENDSTOP_V, amax = max.v); + break; + #endif + #if HAS_W_AXIS + case W_AXIS: + TERN_(MIN_SOFTWARE_ENDSTOP_W, amin = min.w); + TERN_(MIN_SOFTWARE_ENDSTOP_W, amax = max.w); + break; + #endif default: break; } #endif @@ -323,7 +344,7 @@ inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) /** * Blocking movement and shorthand functions */ -void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); @@ -347,6 +368,18 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to_k(const_float_t rk, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to_xyzij_k(const xyze_pos_t &raw, const_float_t k, const_feedRate_t fr_mm_s=0.0f); #endif +#if HAS_U_AXIS + void do_blocking_move_to_u(const_float_t ru, const_feedRate_t fr_mm_s=0.0f); + void do_blocking_move_to_xyzijk_u(const xyze_pos_t &raw, const_float_t u, const_feedRate_t fr_mm_s=0.0f); +#endif +#if HAS_V_AXIS + void do_blocking_move_to_v(const_float_t rv, const_feedRate_t fr_mm_s=0.0f); + void do_blocking_move_to_xyzijku_v(const xyze_pos_t &raw, const_float_t v, const_feedRate_t fr_mm_s=0.0f); +#endif +#if HAS_W_AXIS + void do_blocking_move_to_w(const float rw, const feedRate_t &fr_mm_s=0.0f); + void do_blocking_move_to_xyzijkuv_w(const xyze_pos_t &raw, const float w, const feedRate_t &fr_mm_s=0.0f); +#endif #if HAS_Y_AXIS void do_blocking_move_to_xy(const_float_t rx, const_float_t ry, const_feedRate_t fr_mm_s=0.0f); @@ -374,8 +407,8 @@ void restore_feedrate_and_scaling(); /** * Homing and Trusted Axes */ -typedef IF<(LINEAR_AXES > 8), uint16_t, uint8_t>::type linear_axis_bits_t; -constexpr linear_axis_bits_t linear_bits = _BV(LINEAR_AXES) - 1; +typedef IF<(NUM_AXES > 8), uint16_t, uint8_t>::type linear_axis_bits_t; +constexpr linear_axis_bits_t linear_bits = _BV(NUM_AXES) - 1; void set_axis_is_at_home(const AxisEnum axis); @@ -490,6 +523,18 @@ void home_if_needed(const bool keeplev=false); #define LOGICAL_K_POSITION(POS) NATIVE_TO_LOGICAL(POS, K_AXIS) #define RAW_K_POSITION(POS) LOGICAL_TO_NATIVE(POS, K_AXIS) #endif +#if HAS_U_AXIS + #define LOGICAL_U_POSITION(POS) NATIVE_TO_LOGICAL(POS, U_AXIS) + #define RAW_U_POSITION(POS) LOGICAL_TO_NATIVE(POS, U_AXIS) +#endif +#if HAS_V_AXIS + #define LOGICAL_V_POSITION(POS) NATIVE_TO_LOGICAL(POS, V_AXIS) + #define RAW_V_POSITION(POS) LOGICAL_TO_NATIVE(POS, V_AXIS) +#endif +#if HAS_W_AXIS + #define LOGICAL_W_POSITION(POS) NATIVE_TO_LOGICAL(POS, W_AXIS) + #define RAW_W_POSITION(POS) LOGICAL_TO_NATIVE(POS, W_AXIS) +#endif /** * position_is_reachable family of functions diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 8c723aa06e..ae67073b4f 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1300,7 +1300,7 @@ void Planner::recalculate() { */ void Planner::check_axes_activity() { - #if ANY(DISABLE_X, DISABLE_Y, DISABLE_Z, DISABLE_I, DISABLE_J, DISABLE_K, DISABLE_E) + #if ANY(DISABLE_X, DISABLE_Y, DISABLE_Z, DISABLE_I, DISABLE_J, DISABLE_K, DISABLE_U, DISABLE_V, DISABLE_W, DISABLE_E) xyze_bool_t axis_active = { false }; #endif @@ -1350,7 +1350,10 @@ void Planner::check_axes_activity() { if (TERN0(DISABLE_Z, block->steps.z)) axis_active.z = true, if (TERN0(DISABLE_I, block->steps.i)) axis_active.i = true, if (TERN0(DISABLE_J, block->steps.j)) axis_active.j = true, - if (TERN0(DISABLE_K, block->steps.k)) axis_active.k = true + if (TERN0(DISABLE_K, block->steps.k)) axis_active.k = true, + if (TERN0(DISABLE_U, block->steps.u)) axis_active.u = true, + if (TERN0(DISABLE_V, block->steps.v)) axis_active.v = true, + if (TERN0(DISABLE_W, block->steps.w)) axis_active.w = true ); } #endif @@ -1385,7 +1388,10 @@ void Planner::check_axes_activity() { if (TERN0(DISABLE_Z, !axis_active.z)) stepper.disable_axis(Z_AXIS), if (TERN0(DISABLE_I, !axis_active.i)) stepper.disable_axis(I_AXIS), if (TERN0(DISABLE_J, !axis_active.j)) stepper.disable_axis(J_AXIS), - if (TERN0(DISABLE_K, !axis_active.k)) stepper.disable_axis(K_AXIS) + if (TERN0(DISABLE_K, !axis_active.k)) stepper.disable_axis(K_AXIS), + if (TERN0(DISABLE_U, !axis_active.u)) stepper.disable_axis(U_AXIS), + if (TERN0(DISABLE_V, !axis_active.v)) stepper.disable_axis(V_AXIS), + if (TERN0(DISABLE_W, !axis_active.w)) stepper.disable_axis(W_AXIS) ); // @@ -1453,7 +1459,7 @@ void Planner::check_axes_activity() { float high = 0.0; for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { block_t *block = &block_buffer[b]; - if (LINEAR_AXIS_GANG(block->steps.x, || block->steps.y, || block->steps.z, || block->steps.i, || block->steps.j, || block->steps.k)) { + if (NUM_AXIS_GANG(block->steps.x, || block->steps.y, || block->steps.z, || block->steps.i, || block->steps.j, || block->steps.k, || block->steps.u, || block->steps.v, || block->steps.w)) { const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; NOLESS(high, se); } @@ -1856,15 +1862,22 @@ bool Planner::_populate_block(block_t * const block, bool split_move, dc = target.c - position.c, di = target.i - position.i, dj = target.j - position.j, - dk = target.k - position.k + dk = target.k - position.k, + du = target.u - position.u, + dv = target.v - position.v, + dw = target.w - position.w ); /* <-- add a slash to enable SERIAL_ECHOLNPGM( " _populate_block FR:", fr_mm_s, " A:", target.a, " (", da, " steps)" - " B:", target.b, " (", db, " steps)" - " C:", target.c, " (", dc, " steps)" + #if HAS_Y_AXIS + " B:", target.b, " (", db, " steps)" + #endif + #if HAS_Z_AXIS + " C:", target.c, " (", dc, " steps)" + #endif #if HAS_I_AXIS " " STR_I ":", target.i, " (", di, " steps)" #endif @@ -1874,6 +1887,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if HAS_K_AXIS " " STR_K ":", target.k, " (", dk, " steps)" #endif + #if HAS_U_AXIS + " " STR_U ":", target.u, " (", du, " steps)" + #endif + #if HAS_V_AXIS + " " STR_V ":", target.v, " (", dv, " steps)" + #endif + #if HAS_W_AXIS + " " STR_W ":", target.w, " (", dw, " steps)" #if HAS_EXTRUDERS " E:", target.e, " (", de, " steps)" #endif @@ -1938,15 +1959,6 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction if (CORESIGN(db - dc) < 0) SBI(dm, C_AXIS); // Motor C direction #endif - #if HAS_I_AXIS - if (di < 0) SBI(dm, I_AXIS); - #endif - #if HAS_J_AXIS - if (dj < 0) SBI(dm, J_AXIS); - #endif - #if HAS_K_AXIS - if (dk < 0) SBI(dm, K_AXIS); - #endif #elif ENABLED(MARKFORGED_XY) if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction if (db < 0) SBI(dm, B_AXIS); // Motor B direction @@ -1954,16 +1966,22 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (da < 0) SBI(dm, A_AXIS); // Motor A direction if (db + da < 0) SBI(dm, B_AXIS); // Motor B direction #else - LINEAR_AXIS_CODE( + XYZ_CODE( if (da < 0) SBI(dm, X_AXIS), if (db < 0) SBI(dm, Y_AXIS), - if (dc < 0) SBI(dm, Z_AXIS), - if (di < 0) SBI(dm, I_AXIS), - if (dj < 0) SBI(dm, J_AXIS), - if (dk < 0) SBI(dm, K_AXIS) + if (dc < 0) SBI(dm, Z_AXIS) ); #endif + SECONDARY_AXIS_CODE( + if (di < 0) SBI(dm, I_AXIS), + if (dj < 0) SBI(dm, J_AXIS), + if (dk < 0) SBI(dm, K_AXIS), + if (du < 0) SBI(dm, U_AXIS), + if (dv < 0) SBI(dm, V_AXIS), + if (dw < 0) SBI(dm, W_AXIS) + ); + #if HAS_EXTRUDERS if (de < 0) SBI(dm, E_AXIS); const float esteps_float = de * e_factor[extruder]; @@ -1988,20 +2006,20 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Number of steps for each axis // See https://www.corexy.com/theory.html #if CORE_IS_XY - block->steps.set(LINEAR_AXIS_LIST(ABS(da + db), ABS(da - db), ABS(dc), ABS(di), ABS(dj), ABS(dk))); + block->steps.set(NUM_AXIS_LIST(ABS(da + db), ABS(da - db), ABS(dc), ABS(di), ABS(dj), ABS(dk), ABS(du), ABS(dv), ABS(dw))); #elif CORE_IS_XZ - block->steps.set(LINEAR_AXIS_LIST(ABS(da + dc), ABS(db), ABS(da - dc), ABS(di), ABS(dj), ABS(dk))); + block->steps.set(NUM_AXIS_LIST(ABS(da + dc), ABS(db), ABS(da - dc), ABS(di), ABS(dj), ABS(dk), ABS(du), ABS(dv), ABS(dw))); #elif CORE_IS_YZ - block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db + dc), ABS(db - dc), ABS(di), ABS(dj), ABS(dk))); + block->steps.set(NUM_AXIS_LIST(ABS(da), ABS(db + dc), ABS(db - dc), ABS(di), ABS(dj), ABS(dk), ABS(du), ABS(dv), ABS(dw))); #elif ENABLED(MARKFORGED_XY) - block->steps.set(LINEAR_AXIS_LIST(ABS(da + db), ABS(db), ABS(dc), ABS(di), ABS(dj), ABS(dk))); + block->steps.set(NUM_AXIS_LIST(ABS(da + db), ABS(db), ABS(dc), ABS(di), ABS(dj), ABS(dk), ABS(du), ABS(dv), ABS(dw))); #elif ENABLED(MARKFORGED_YX) - block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db + da), ABS(dc), ABS(di), ABS(dj), ABS(dk))); + block->steps.set(NUM_AXIS_LIST(ABS(da), ABS(db + da), ABS(dc), ABS(di), ABS(dj), ABS(dk), ABS(du), ABS(dv), ABS(dw))); #elif IS_SCARA - block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db), ABS(dc), ABS(di), ABS(dj), ABS(dk))); + block->steps.set(NUM_AXIS_LIST(ABS(da), ABS(db), ABS(dc), ABS(di), ABS(dj), ABS(dk), ABS(du), ABS(dv), ABS(dw))); #else // default non-h-bot planning - block->steps.set(LINEAR_AXIS_LIST(ABS(da), ABS(db), ABS(dc), ABS(di), ABS(dj), ABS(dk))); + block->steps.set(NUM_AXIS_LIST(ABS(da), ABS(db), ABS(dc), ABS(di), ABS(dj), ABS(dk), ABS(du), ABS(dv), ABS(dw))); #endif /** @@ -2040,9 +2058,6 @@ bool Planner::_populate_block(block_t * const block, bool split_move, steps_dist_mm.b = (db + dc) * mm_per_step[B_AXIS]; steps_dist_mm.c = CORESIGN(db - dc) * mm_per_step[C_AXIS]; #endif - TERN_(HAS_I_AXIS, steps_dist_mm.i = di * mm_per_step[I_AXIS]); - TERN_(HAS_J_AXIS, steps_dist_mm.j = dj * mm_per_step[J_AXIS]); - TERN_(HAS_K_AXIS, steps_dist_mm.k = dk * mm_per_step[K_AXIS]); #elif ENABLED(MARKFORGED_XY) steps_dist_mm.a = (da - db) * mm_per_step[A_AXIS]; steps_dist_mm.b = db * mm_per_step[B_AXIS]; @@ -2050,27 +2065,40 @@ bool Planner::_populate_block(block_t * const block, bool split_move, steps_dist_mm.a = da * mm_per_step[A_AXIS]; steps_dist_mm.b = (db - da) * mm_per_step[B_AXIS]; #else - LINEAR_AXIS_CODE( + XYZ_CODE( steps_dist_mm.a = da * mm_per_step[A_AXIS], steps_dist_mm.b = db * mm_per_step[B_AXIS], - steps_dist_mm.c = dc * mm_per_step[C_AXIS], - steps_dist_mm.i = di * mm_per_step[I_AXIS], - steps_dist_mm.j = dj * mm_per_step[J_AXIS], - steps_dist_mm.k = dk * mm_per_step[K_AXIS] + steps_dist_mm.c = dc * mm_per_step[C_AXIS] ); #endif + SECONDARY_AXIS_CODE( + steps_dist_mm.i = di * mm_per_step[I_AXIS], + steps_dist_mm.j = dj * mm_per_step[J_AXIS], + steps_dist_mm.k = dk * mm_per_step[K_AXIS], + steps_dist_mm.u = du * mm_per_step[U_AXIS], + steps_dist_mm.v = dv * mm_per_step[V_AXIS], + steps_dist_mm.w = dw * mm_per_step[W_AXIS] + ); + TERN_(HAS_EXTRUDERS, steps_dist_mm.e = esteps_float * mm_per_step[E_AXIS_N(extruder)]); TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator += steps_dist_mm.e); - if (true LINEAR_AXIS_GANG( + #if BOTH(HAS_ROTATIONAL_AXES, INCH_MODE_SUPPORT) + bool cartesian_move = true; + #endif + + if (true NUM_AXIS_GANG( && block->steps.a < MIN_STEPS_PER_SEGMENT, && block->steps.b < MIN_STEPS_PER_SEGMENT, && block->steps.c < MIN_STEPS_PER_SEGMENT, && block->steps.i < MIN_STEPS_PER_SEGMENT, && block->steps.j < MIN_STEPS_PER_SEGMENT, - && block->steps.k < MIN_STEPS_PER_SEGMENT + && block->steps.k < MIN_STEPS_PER_SEGMENT, + && block->steps.u < MIN_STEPS_PER_SEGMENT, + && block->steps.v < MIN_STEPS_PER_SEGMENT, + && block->steps.w < MIN_STEPS_PER_SEGMENT ) ) { block->millimeters = TERN0(HAS_EXTRUDERS, ABS(steps_dist_mm.e)); @@ -2079,36 +2107,71 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (millimeters) block->millimeters = millimeters; else { - block->millimeters = SQRT( - #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) - LINEAR_AXIS_GANG( - sq(steps_dist_mm.head.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.z), - + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k) - ) - #elif CORE_IS_XZ - LINEAR_AXIS_GANG( - sq(steps_dist_mm.head.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.head.z), - + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k) - ) - #elif CORE_IS_YZ - LINEAR_AXIS_GANG( - sq(steps_dist_mm.x) + sq(steps_dist_mm.head.y) + sq(steps_dist_mm.head.z) - + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k) - ) - #elif ENABLED(FOAMCUTTER_XYUV) - // Return the largest distance move from either X/Y or I/J plane + /** + * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of NIST + * RS274NGC interpreter - version 3) and its default CANON_XYZ feed reference mode. + * Assume that X, Y, Z are the primary linear axes and U, V, W are secondary linear axes and A, B, C are + * rotational axes. Then dX, dY, dZ are the displacements of the primary linear axes and dU, dV, dW are the displacements of linear axes and + * dA, dB, dC are the displacements of rotational axes. + * The time it takes to execute move command with feedrate F is t = D/F, where D is the total distance, calculated as follows: + * D^2 = dX^2 + dY^2 + dZ^2 + * if D^2 == 0 (none of XYZ move but any secondary linear axes move, whether other axes are moved or not): + * D^2 = dU^2 + dV^2 + dW^2 + * if D^2 == 0 (only rotational axes are moved): + * D^2 = dA^2 + dB^2 + dC^2 + */ + float distance_sqr = ( + #if ENABLED(ARTICULATED_ROBOT_ARM) + // For articulated robots, interpreting feedrate like LinuxCNC would require inverse kinematics. As a workaround, pretend that motors sit on n mutually orthogonal + // axes and assume that we could think of distance as magnitude of an n-vector in an n-dimensional Euclidian space. + NUM_AXIS_GANG( + sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z), + + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k), + + sq(steps_dist_mm.u), + sq(steps_dist_mm.v), + sq(steps_dist_mm.w) + ); + #elif ENABLED(FOAMCUTTER_XYUV) #if HAS_J_AXIS - _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j)) - #else + // Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane + _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j)) + #else // Foamcutter with only two axes (XY) sq(steps_dist_mm.x) + sq(steps_dist_mm.y) #endif + #elif ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + XYZ_GANG(sq(steps_dist_mm.head.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.z)) + #elif CORE_IS_XZ + XYZ_GANG(sq(steps_dist_mm.head.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.head.z)) + #elif CORE_IS_YZ + XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.head.y), + sq(steps_dist_mm.head.z)) #else - LINEAR_AXIS_GANG( - sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z), - + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k) - ) + XYZ_GANG(sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z)) #endif ); + + #if SECONDARY_LINEAR_AXES >= 1 && NONE(FOAMCUTTER_XYUV, ARTICULATED_ROBOT_ARM) + if (NEAR_ZERO(distance_sqr)) { + // Move does not involve any primary linear axes (xyz) but might involve secondary linear axes + distance_sqr = (0.0 + SECONDARY_AXIS_GANG( + IF_DISABLED(AXIS4_ROTATES, + sq(steps_dist_mm.i)), + IF_DISABLED(AXIS5_ROTATES, + sq(steps_dist_mm.j)), + IF_DISABLED(AXIS6_ROTATES, + sq(steps_dist_mm.k)), + IF_DISABLED(AXIS7_ROTATES, + sq(steps_dist_mm.u)), + IF_DISABLED(AXIS8_ROTATES, + sq(steps_dist_mm.v)), + IF_DISABLED(AXIS9_ROTATES, + sq(steps_dist_mm.w)) + ) + ); + } + #endif + + #if HAS_ROTATIONAL_AXES && NONE(FOAMCUTTER_XYUV, ARTICULATED_ROBOT_ARM) + if (NEAR_ZERO(distance_sqr)) { + // Move involves only rotational axes. Calculate angular distance in accordance with LinuxCNC + TERN_(INCH_MODE_SUPPORT, cartesian_move = false); + distance_sqr = ROTATIONAL_AXIS_GANG(sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k), + sq(steps_dist_mm.u), + sq(steps_dist_mm.v), + sq(steps_dist_mm.w)); + } + #endif + + block->millimeters = SQRT(distance_sqr); } /** @@ -2125,8 +2188,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, TERN_(HAS_EXTRUDERS, block->steps.e = esteps); - block->step_event_count = _MAX(LOGICAL_AXIS_LIST( - esteps, block->steps.a, block->steps.b, block->steps.c, block->steps.i, block->steps.j, block->steps.k + block->step_event_count = _MAX(LOGICAL_AXIS_LIST(esteps, + block->steps.a, block->steps.b, block->steps.c, + block->steps.i, block->steps.j, block->steps.k, + block->steps.u, block->steps.v, block->steps.w )); // Bail if this is a zero-length block @@ -2148,13 +2213,16 @@ bool Planner::_populate_block(block_t * const block, bool split_move, E_TERN_(block->extruder = extruder); #if ENABLED(AUTO_POWER_CONTROL) - if (LINEAR_AXIS_GANG( + if (NUM_AXIS_GANG( block->steps.x, || block->steps.y, || block->steps.z, || block->steps.i, || block->steps.j, - || block->steps.k + || block->steps.k, + || block->steps.u, + || block->steps.v, + || block->steps.w )) powerManager.power_on(); #endif @@ -2180,19 +2248,27 @@ bool Planner::_populate_block(block_t * const block, bool split_move, } if (block->steps.x) stepper.enable_axis(X_AXIS); #else - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( if (block->steps.x) stepper.enable_axis(X_AXIS), if (block->steps.y) stepper.enable_axis(Y_AXIS), if (TERN(Z_LATE_ENABLE, 0, block->steps.z)) stepper.enable_axis(Z_AXIS), if (block->steps.i) stepper.enable_axis(I_AXIS), if (block->steps.j) stepper.enable_axis(J_AXIS), - if (block->steps.k) stepper.enable_axis(K_AXIS) + if (block->steps.k) stepper.enable_axis(K_AXIS), + if (block->steps.u) stepper.enable_axis(U_AXIS), + if (block->steps.v) stepper.enable_axis(V_AXIS), + if (block->steps.w) stepper.enable_axis(W_AXIS) ); #endif #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) - TERN_(HAS_I_AXIS, if (block->steps.i) stepper.enable_axis(I_AXIS)); - TERN_(HAS_J_AXIS, if (block->steps.j) stepper.enable_axis(J_AXIS)); - TERN_(HAS_K_AXIS, if (block->steps.k) stepper.enable_axis(K_AXIS)); + SECONDARY_AXIS_CODE( + if (block->steps.i) stepper.enable_axis(I_AXIS), + if (block->steps.j) stepper.enable_axis(J_AXIS), + if (block->steps.k) stepper.enable_axis(K_AXIS), + if (block->steps.u) stepper.enable_axis(U_AXIS), + if (block->steps.v) stepper.enable_axis(V_AXIS), + if (block->steps.w) stepper.enable_axis(W_AXIS) + ); #endif // Enable extruder(s) @@ -2239,8 +2315,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move, const float inverse_millimeters = 1.0f / block->millimeters; // Inverse millimeters to remove multiple divides // Calculate inverse time for this move. No divide by zero due to previous checks. - // Example: At 120mm/s a 60mm move takes 0.5s. So this will give 2.0. - float inverse_secs = fr_mm_s * inverse_millimeters; + // Example: At 120mm/s a 60mm move involving XYZ axes takes 0.5s. So this will give 2.0. + // Example 2: At 120°/s a 60° move involving only rotational axes takes 0.5s. So this will give 2.0. + float inverse_secs; + #if BOTH(HAS_ROTATIONAL_AXES, INCH_MODE_SUPPORT) + inverse_secs = inverse_millimeters * (cartesian_move ? fr_mm_s : LINEAR_UNIT(fr_mm_s)); + #else + inverse_secs = fr_mm_s * inverse_millimeters; + #endif // Get the number of non busy movements in queue (non busy means that they can be altered) const uint8_t moves_queued = nonbusy_movesplanned(); @@ -2286,13 +2368,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move, filwidth.advance_e(steps_dist_mm.e); #endif - // Calculate and limit speed in mm/sec + // Calculate and limit speed in mm/sec (linear) or degrees/sec (rotational) xyze_float_t current_speed; float speed_factor = 1.0f; // factor <1 decreases speed // Linear axes first with less logic - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { current_speed[i] = steps_dist_mm[i] * inverse_secs; const feedRate_t cs = ABS(current_speed[i]), max_fr = settings.max_feedrate_mm_s[i]; @@ -2380,9 +2462,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Compute and limit the acceleration rate for the trapezoid generator. const float steps_per_mm = block->step_event_count * inverse_millimeters; uint32_t accel; - if (LINEAR_AXIS_GANG( + if (NUM_AXIS_GANG( !block->steps.a, && !block->steps.b, && !block->steps.c, - && !block->steps.i, && !block->steps.j, && !block->steps.k) + && !block->steps.i, && !block->steps.j, && !block->steps.k, + && !block->steps.u, && !block->steps.v, && !block->steps.w) ) { // Is this a retract / recover move? accel = CEIL(settings.retract_acceleration * steps_per_mm); // Convert to: acceleration steps/sec^2 TERN_(LIN_ADVANCE, block->use_advance_lead = false); // No linear advance for simple retract/recover @@ -2455,7 +2538,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, LIMIT_ACCEL_LONG(C_AXIS, 0), LIMIT_ACCEL_LONG(I_AXIS, 0), LIMIT_ACCEL_LONG(J_AXIS, 0), - LIMIT_ACCEL_LONG(K_AXIS, 0) + LIMIT_ACCEL_LONG(K_AXIS, 0), + LIMIT_ACCEL_LONG(U_AXIS, 0), + LIMIT_ACCEL_LONG(V_AXIS, 0), + LIMIT_ACCEL_LONG(W_AXIS, 0) ); } else { @@ -2466,7 +2552,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, LIMIT_ACCEL_FLOAT(C_AXIS, 0), LIMIT_ACCEL_FLOAT(I_AXIS, 0), LIMIT_ACCEL_FLOAT(J_AXIS, 0), - LIMIT_ACCEL_FLOAT(K_AXIS, 0) + LIMIT_ACCEL_FLOAT(K_AXIS, 0), + LIMIT_ACCEL_FLOAT(U_AXIS, 0), + LIMIT_ACCEL_FLOAT(V_AXIS, 0), + LIMIT_ACCEL_FLOAT(W_AXIS, 0) ); } } @@ -2531,7 +2620,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if HAS_DIST_MM_ARG cart_dist_mm #else - LOGICAL_AXIS_ARRAY(steps_dist_mm.e, steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.i, steps_dist_mm.j, steps_dist_mm.k) + LOGICAL_AXIS_ARRAY(steps_dist_mm.e, steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.i, steps_dist_mm.j, steps_dist_mm.k, steps_dist_mm.u, steps_dist_mm.v, steps_dist_mm.w) #endif ; @@ -2557,7 +2646,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, + (-prev_unit_vec.z * unit_vec.z), + (-prev_unit_vec.i * unit_vec.i), + (-prev_unit_vec.j * unit_vec.j), - + (-prev_unit_vec.k * unit_vec.k) + + (-prev_unit_vec.k * unit_vec.k), + + (-prev_unit_vec.u * unit_vec.u), + + (-prev_unit_vec.v * unit_vec.v), + + (-prev_unit_vec.w * unit_vec.w) ); // NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta). @@ -2704,7 +2796,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, const float extra_xyjerk = TERN0(HAS_EXTRUDERS, de <= 0) ? TRAVEL_EXTRA_XYJERK : 0; uint8_t limited = 0; - TERN(HAS_LINEAR_E_JERK, LOOP_LINEAR_AXES, LOOP_LOGICAL_AXES)(i) { + TERN(HAS_LINEAR_E_JERK, LOOP_NUM_AXES, LOOP_LOGICAL_AXES)(i) { const float jerk = ABS(current_speed[i]), // cs : Starting from zero, change in speed for this axis maxj = (max_jerk[i] + (i == X_AXIS || i == Y_AXIS ? extra_xyjerk : 0.0f)); // mj : The max jerk setting for this axis if (jerk > maxj) { // cs > mj : New current speed too fast? @@ -2742,7 +2834,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, vmax_junction = previous_nominal_speed; // Now limit the jerk in all axes. - TERN(HAS_LINEAR_E_JERK, LOOP_LINEAR_AXES, LOOP_LOGICAL_AXES)(axis) { + TERN(HAS_LINEAR_E_JERK, LOOP_NUM_AXES, LOOP_LOGICAL_AXES)(axis) { // Limit an axis. We have to differentiate: coasting, reversal of an axis, full stop. float v_exit = previous_speed[axis] * smaller_speed_factor, v_entry = current_speed[axis]; @@ -2844,7 +2936,7 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ block->position = position; #if ENABLED(BACKLASH_COMPENSATION) - LOOP_LINEAR_AXES(axis) block->position[axis] += backlash.get_applied_steps((AxisEnum)axis); + LOOP_NUM_AXES(axis) block->position[axis] += backlash.get_applied_steps((AxisEnum)axis); #endif #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107) @@ -2906,7 +2998,10 @@ bool Planner::buffer_segment(const abce_pos_t &abce int32_t(LROUND(abce.c * settings.axis_steps_per_mm[C_AXIS])), int32_t(LROUND(abce.i * settings.axis_steps_per_mm[I_AXIS])), int32_t(LROUND(abce.j * settings.axis_steps_per_mm[J_AXIS])), - int32_t(LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS])) + int32_t(LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS])), + int32_t(LROUND(abce.u * settings.axis_steps_per_mm[U_AXIS])), + int32_t(LROUND(abce.v * settings.axis_steps_per_mm[V_AXIS])), + int32_t(LROUND(abce.w * settings.axis_steps_per_mm[W_AXIS])) ) }; @@ -2958,6 +3053,21 @@ bool Planner::buffer_segment(const abce_pos_t &abce SERIAL_ECHOPGM(" (", position.k, "->", target.k); SERIAL_CHAR(')'); #endif + #if HAS_U_AXIS + SERIAL_ECHOPGM_P(SP_U_LBL, abce.u); + SERIAL_ECHOPGM(" (", position.u, "->", target.u); + SERIAL_CHAR(')'); + #endif + #if HAS_V_AXIS + SERIAL_ECHOPGM_P(SP_V_LBL, abce.v); + SERIAL_ECHOPGM(" (", position.v, "->", target.v); + SERIAL_CHAR(')'); + #endif + #if HAS_W_AXIS + SERIAL_ECHOPGM_P(SP_W_LBL, abce.w); + SERIAL_ECHOPGM(" (", position.w, "->", target.w); + SERIAL_CHAR(')'); + #endif #if HAS_EXTRUDERS SERIAL_ECHOPGM_P(SP_E_LBL, abce.e); SERIAL_ECHOLNPGM(" (", position.e, "->", target.e, ")"); @@ -3000,12 +3110,14 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons const xyze_pos_t cart_dist_mm = LOGICAL_AXIS_ARRAY( cart.e - position_cart.e, cart.x - position_cart.x, cart.y - position_cart.y, cart.z - position_cart.z, - cart.i - position_cart.i, cart.j - position_cart.j, cart.j - position_cart.k + cart.i - position_cart.i, cart.j - position_cart.j, cart.k - position_cart.k, + cart.u - position_cart.u, cart.v - position_cart.v, cart.w - position_cart.w ); #else - const xyz_pos_t cart_dist_mm = LINEAR_AXIS_ARRAY( + const xyz_pos_t cart_dist_mm = NUM_AXIS_ARRAY( cart.x - position_cart.x, cart.y - position_cart.y, cart.z - position_cart.z, - cart.i - position_cart.i, cart.j - position_cart.j, cart.j - position_cart.k + cart.i - position_cart.i, cart.j - position_cart.j, cart.k - position_cart.k, + cart.u - position_cart.u, cart.v - position_cart.v, cart.w - position_cart.w ); #endif @@ -3110,7 +3222,10 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { LROUND(abce.c * settings.axis_steps_per_mm[C_AXIS]), LROUND(abce.i * settings.axis_steps_per_mm[I_AXIS]), LROUND(abce.j * settings.axis_steps_per_mm[J_AXIS]), - LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS]) + LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS]), + LROUND(abce.u * settings.axis_steps_per_mm[U_AXIS]), + LROUND(abce.v * settings.axis_steps_per_mm[V_AXIS]), + LROUND(abce.w * settings.axis_steps_per_mm[W_AXIS]) ) ); @@ -3122,7 +3237,7 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { else { #if ENABLED(BACKLASH_COMPENSATION) abce_long_t stepper_pos = position; - LOOP_LINEAR_AXES(axis) stepper_pos[axis] += backlash.get_applied_steps((AxisEnum)axis); + LOOP_NUM_AXES(axis) stepper_pos[axis] += backlash.get_applied_steps((AxisEnum)axis); stepper.set_position(stepper_pos); #else stepper.set_position(position); diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 5b79e406f5..eb4a34cec9 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -84,7 +84,8 @@ constexpr xyze_feedrate_t _mf = MANUAL_FEEDRATE, manual_feedrate_mm_s = LOGICAL_AXIS_ARRAY(_mf.e / 60.0f, _mf.x / 60.0f, _mf.y / 60.0f, _mf.z / 60.0f, - _mf.i / 60.0f, _mf.j / 60.0f, _mf.k / 60.0f); + _mf.i / 60.0f, _mf.j / 60.0f, _mf.k / 60.0f, + _mf.u / 60.0f, _mf.v / 60.0f, _mf.w / 60.0f); #endif #if IS_KINEMATIC && HAS_JUNCTION_DEVIATION @@ -843,7 +844,8 @@ class Planner { const abce_pos_t out = LOGICAL_AXIS_ARRAY( get_axis_position_mm(E_AXIS), get_axis_position_mm(A_AXIS), get_axis_position_mm(B_AXIS), get_axis_position_mm(C_AXIS), - get_axis_position_mm(I_AXIS), get_axis_position_mm(J_AXIS), get_axis_position_mm(K_AXIS) + get_axis_position_mm(I_AXIS), get_axis_position_mm(J_AXIS), get_axis_position_mm(K_AXIS), + get_axis_position_mm(U_AXIS), get_axis_position_mm(V_AXIS), get_axis_position_mm(W_AXIS) ); return out; } diff --git a/Marlin/src/module/planner_bezier.cpp b/Marlin/src/module/planner_bezier.cpp index 848906705f..fa7e16a387 100644 --- a/Marlin/src/module/planner_bezier.cpp +++ b/Marlin/src/module/planner_bezier.cpp @@ -188,7 +188,10 @@ void cubic_b_spline( interp(position.z, target.z, t), // FIXME. Wrong, since t is not linear in the distance. interp(position.i, target.i, t), // FIXME. Wrong, since t is not linear in the distance. interp(position.j, target.j, t), // FIXME. Wrong, since t is not linear in the distance. - interp(position.k, target.k, t) // FIXME. Wrong, since t is not linear in the distance. + interp(position.k, target.k, t), // FIXME. Wrong, since t is not linear in the distance. + interp(position.u, target.u, t), // FIXME. Wrong, since t is not linear in the distance. + interp(position.v, target.v, t), // FIXME. Wrong, since t is not linear in the distance. + interp(position.w, target.w, t) // FIXME. Wrong, since t is not linear in the distance. ); apply_motion_limits(new_bez); bez_target = new_bez; diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 5b0bd77d0d..f9a64a02d3 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -794,9 +794,10 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai #endif // On delta keep Z below clip height or do_blocking_move_to will abort - xyz_pos_t npos = LINEAR_AXIS_ARRAY( + xyz_pos_t npos = NUM_AXIS_ARRAY( rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, current_position.z), current_position.z), - current_position.i, current_position.j, current_position.k + current_position.i, current_position.j, current_position.k, + current_position.u, current_position.v, current_position.w ); if (!can_reach(npos, probe_relative)) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable"); @@ -888,7 +889,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai */ void Probe::set_homing_current(const bool onoff) { #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Z) + #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Z) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) || HAS_CURRENT_HOME(U) || HAS_CURRENT_HOME(V) || HAS_CURRENT_HOME(W) #if ENABLED(DELTA) static int16_t saved_current_X, saved_current_Y; #endif diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index f2fca10a80..c802411be3 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -138,7 +138,7 @@ public: #else - static constexpr xyz_pos_t offset = xyz_pos_t(LINEAR_AXIS_ARRAY(0, 0, 0, 0, 0, 0)); // See #16767 + static constexpr xyz_pos_t offset = xyz_pos_t(NUM_AXIS_ARRAY(0, 0, 0, 0, 0, 0)); // See #16767 static bool set_deployed(const bool) { return false; } diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index 2527292e16..bc42b85fbe 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -254,7 +254,7 @@ float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SE // Do this here all at once for Delta, because // XYZ isn't ABC. Applying this per-tower would // give the impression that they are the same. - LOOP_LINEAR_AXES(i) set_axis_is_at_home((AxisEnum)i); + LOOP_NUM_AXES(i) set_axis_is_at_home((AxisEnum)i); sync_plan_position(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 5d91a90c65..2b2aae2633 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -179,10 +179,10 @@ #define _EN_ITEM(N) , E##N -typedef struct { uint16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stepper_current_t; -typedef struct { uint32_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_hybrid_threshold_t; -typedef struct { int16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4; } tmc_sgt_t; -typedef struct { bool LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stealth_enabled_t; +typedef struct { uint16_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stepper_current_t; +typedef struct { uint32_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_hybrid_threshold_t; +typedef struct { int16_t NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4; } tmc_sgt_t; +typedef struct { bool NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stealth_enabled_t; #undef _EN_ITEM @@ -210,7 +210,7 @@ typedef struct SettingsDataStruct { // // DISTINCT_E_FACTORS // - uint8_t e_factors; // DISTINCT_AXES - LINEAR_AXES + uint8_t e_factors; // DISTINCT_AXES - NUM_AXES // // Planner settings @@ -444,7 +444,7 @@ typedef struct SettingsDataStruct { // HAS_MOTOR_CURRENT_PWM // #ifndef MOTOR_CURRENT_COUNT - #define MOTOR_CURRENT_COUNT LINEAR_AXES + #define MOTOR_CURRENT_COUNT NUM_AXES #endif uint32_t motor_current_setting[MOTOR_CURRENT_COUNT]; // M907 X Z E ... @@ -590,7 +590,7 @@ void MarlinSettings::postprocess() { #endif // Software endstops depend on home_offset - LOOP_LINEAR_AXES(i) { + LOOP_NUM_AXES(i) { update_workspace_offset((AxisEnum)i); update_software_endstops((AxisEnum)i); } @@ -738,7 +738,7 @@ void MarlinSettings::postprocess() { working_crc = 0; // clear before first "real data" - const uint8_t e_factors = DISTINCT_AXES - (LINEAR_AXES); + const uint8_t e_factors = DISTINCT_AXES - (NUM_AXES); _FIELD_TEST(e_factors); EEPROM_WRITE(e_factors); @@ -755,7 +755,7 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(dummyf); #endif #else - const xyze_pos_t planner_max_jerk = LOGICAL_AXIS_ARRAY(float(DEFAULT_EJERK), 10, 10, 0.4, 0.4, 0.4, 0.4); + const xyze_pos_t planner_max_jerk = LOGICAL_AXIS_ARRAY(float(DEFAULT_EJERK), 10, 10, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4); EEPROM_WRITE(planner_max_jerk); #endif @@ -1234,6 +1234,15 @@ void MarlinSettings::postprocess() { #if AXIS_IS_TMC(K) tmc_stepper_current.K = stepperK.getMilliamps(); #endif + #if AXIS_IS_TMC(U) + tmc_stepper_current.U = stepperU.getMilliamps(); + #endif + #if AXIS_IS_TMC(V) + tmc_stepper_current.V = stepperV.getMilliamps(); + #endif + #if AXIS_IS_TMC(W) + tmc_stepper_current.W = stepperW.getMilliamps(); + #endif #if AXIS_IS_TMC(X2) tmc_stepper_current.X2 = stepperX2.getMilliamps(); #endif @@ -1291,6 +1300,9 @@ void MarlinSettings::postprocess() { TERN_(I_HAS_STEALTHCHOP, tmc_hybrid_threshold.I = stepperI.get_pwm_thrs()); TERN_(J_HAS_STEALTHCHOP, tmc_hybrid_threshold.J = stepperJ.get_pwm_thrs()); TERN_(K_HAS_STEALTHCHOP, tmc_hybrid_threshold.K = stepperK.get_pwm_thrs()); + TERN_(U_HAS_STEALTHCHOP, tmc_hybrid_threshold.U = stepperU.get_pwm_thrs()); + TERN_(V_HAS_STEALTHCHOP, tmc_hybrid_threshold.V = stepperV.get_pwm_thrs()); + TERN_(W_HAS_STEALTHCHOP, tmc_hybrid_threshold.W = stepperW.get_pwm_thrs()); TERN_(X2_HAS_STEALTHCHOP, tmc_hybrid_threshold.X2 = stepperX2.get_pwm_thrs()); TERN_(Y2_HAS_STEALTHCHOP, tmc_hybrid_threshold.Y2 = stepperY2.get_pwm_thrs()); TERN_(Z2_HAS_STEALTHCHOP, tmc_hybrid_threshold.Z2 = stepperZ2.get_pwm_thrs()); @@ -1307,7 +1319,7 @@ void MarlinSettings::postprocess() { #else #define _EN_ITEM(N) , .E##N = 30 const tmc_hybrid_threshold_t tmc_hybrid_threshold = { - LINEAR_AXIS_LIST(.X = 100, .Y = 100, .Z = 3, .I = 3, .J = 3, .K = 3), + NUM_AXIS_LIST(.X = 100, .Y = 100, .Z = 3, .I = 3, .J = 3, .K = 3, .U = 3, .V = 3, .W = 3), .X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3 REPEAT(E_STEPPERS, _EN_ITEM) }; @@ -1322,13 +1334,16 @@ void MarlinSettings::postprocess() { { tmc_sgt_t tmc_sgt{0}; #if USE_SENSORLESS - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( TERN_(X_SENSORLESS, tmc_sgt.X = stepperX.homing_threshold()), TERN_(Y_SENSORLESS, tmc_sgt.Y = stepperY.homing_threshold()), TERN_(Z_SENSORLESS, tmc_sgt.Z = stepperZ.homing_threshold()), TERN_(I_SENSORLESS, tmc_sgt.I = stepperI.homing_threshold()), TERN_(J_SENSORLESS, tmc_sgt.J = stepperJ.homing_threshold()), - TERN_(K_SENSORLESS, tmc_sgt.K = stepperK.homing_threshold()) + TERN_(K_SENSORLESS, tmc_sgt.K = stepperK.homing_threshold()), + TERN_(U_SENSORLESS, tmc_sgt.U = stepperU.homing_threshold()), + TERN_(V_SENSORLESS, tmc_sgt.V = stepperV.homing_threshold()), + TERN_(W_SENSORLESS, tmc_sgt.W = stepperW.homing_threshold()) ); TERN_(X2_SENSORLESS, tmc_sgt.X2 = stepperX2.homing_threshold()); TERN_(Y2_SENSORLESS, tmc_sgt.Y2 = stepperY2.homing_threshold()); @@ -1352,6 +1367,9 @@ void MarlinSettings::postprocess() { TERN_(I_HAS_STEALTHCHOP, tmc_stealth_enabled.I = stepperI.get_stored_stealthChop()); TERN_(J_HAS_STEALTHCHOP, tmc_stealth_enabled.J = stepperJ.get_stored_stealthChop()); TERN_(K_HAS_STEALTHCHOP, tmc_stealth_enabled.K = stepperK.get_stored_stealthChop()); + TERN_(U_HAS_STEALTHCHOP, tmc_stealth_enabled.U = stepperU.get_stored_stealthChop()); + TERN_(V_HAS_STEALTHCHOP, tmc_stealth_enabled.V = stepperV.get_stored_stealthChop()); + TERN_(W_HAS_STEALTHCHOP, tmc_stealth_enabled.W = stepperW.get_stored_stealthChop()); TERN_(X2_HAS_STEALTHCHOP, tmc_stealth_enabled.X2 = stepperX2.get_stored_stealthChop()); TERN_(Y2_HAS_STEALTHCHOP, tmc_stealth_enabled.Y2 = stepperY2.get_stored_stealthChop()); TERN_(Z2_HAS_STEALTHCHOP, tmc_stealth_enabled.Z2 = stepperZ2.get_stored_stealthChop()); @@ -1441,7 +1459,7 @@ void MarlinSettings::postprocess() { { #if ENABLED(BACKLASH_GCODE) xyz_float_t backlash_distance_mm; - LOOP_LINEAR_AXES(axis) backlash_distance_mm[axis] = backlash.get_distance_mm((AxisEnum)axis); + LOOP_NUM_AXES(axis) backlash_distance_mm[axis] = backlash.get_distance_mm((AxisEnum)axis); const uint8_t backlash_correction = backlash.get_correction_uint8(); #else const xyz_float_t backlash_distance_mm{0}; @@ -1653,16 +1671,16 @@ void MarlinSettings::postprocess() { { // Get only the number of E stepper parameters previously stored // Any steppers added later are set to their defaults - uint32_t tmp1[LINEAR_AXES + e_factors]; - float tmp2[LINEAR_AXES + e_factors]; - feedRate_t tmp3[LINEAR_AXES + e_factors]; + uint32_t tmp1[NUM_AXES + e_factors]; + float tmp2[NUM_AXES + e_factors]; + feedRate_t tmp3[NUM_AXES + e_factors]; EEPROM_READ((uint8_t *)tmp1, sizeof(tmp1)); // max_acceleration_mm_per_s2 EEPROM_READ(planner.settings.min_segment_time_us); EEPROM_READ((uint8_t *)tmp2, sizeof(tmp2)); // axis_steps_per_mm EEPROM_READ((uint8_t *)tmp3, sizeof(tmp3)); // max_feedrate_mm_s if (!validating) LOOP_DISTINCT_AXES(i) { - const bool in = (i < e_factors + LINEAR_AXES); + const bool in = (i < e_factors + NUM_AXES); planner.settings.max_acceleration_mm_per_s2[i] = in ? tmp1[i] : pgm_read_dword(&_DMA[ALIM(i, _DMA)]); planner.settings.axis_steps_per_mm[i] = in ? tmp2[i] : pgm_read_float(&_DASU[ALIM(i, _DASU)]); planner.settings.max_feedrate_mm_s[i] = in ? tmp3[i] : pgm_read_float(&_DMF[ALIM(i, _DMF)]); @@ -2175,6 +2193,15 @@ void MarlinSettings::postprocess() { #if AXIS_IS_TMC(K) SET_CURR(K); #endif + #if AXIS_IS_TMC(U) + SET_CURR(U); + #endif + #if AXIS_IS_TMC(V) + SET_CURR(V); + #endif + #if AXIS_IS_TMC(W) + SET_CURR(W); + #endif #if AXIS_IS_TMC(E0) SET_CURR(E0); #endif @@ -2222,6 +2249,9 @@ void MarlinSettings::postprocess() { TERN_(I_HAS_STEALTHCHOP, stepperI.set_pwm_thrs(tmc_hybrid_threshold.I)); TERN_(J_HAS_STEALTHCHOP, stepperJ.set_pwm_thrs(tmc_hybrid_threshold.J)); TERN_(K_HAS_STEALTHCHOP, stepperK.set_pwm_thrs(tmc_hybrid_threshold.K)); + TERN_(U_HAS_STEALTHCHOP, stepperU.set_pwm_thrs(tmc_hybrid_threshold.U)); + TERN_(V_HAS_STEALTHCHOP, stepperV.set_pwm_thrs(tmc_hybrid_threshold.V)); + TERN_(W_HAS_STEALTHCHOP, stepperW.set_pwm_thrs(tmc_hybrid_threshold.W)); TERN_(E0_HAS_STEALTHCHOP, stepperE0.set_pwm_thrs(tmc_hybrid_threshold.E0)); TERN_(E1_HAS_STEALTHCHOP, stepperE1.set_pwm_thrs(tmc_hybrid_threshold.E1)); TERN_(E2_HAS_STEALTHCHOP, stepperE2.set_pwm_thrs(tmc_hybrid_threshold.E2)); @@ -2243,13 +2273,16 @@ void MarlinSettings::postprocess() { EEPROM_READ(tmc_sgt); #if USE_SENSORLESS if (!validating) { - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( TERN_(X_SENSORLESS, stepperX.homing_threshold(tmc_sgt.X)), TERN_(Y_SENSORLESS, stepperY.homing_threshold(tmc_sgt.Y)), TERN_(Z_SENSORLESS, stepperZ.homing_threshold(tmc_sgt.Z)), TERN_(I_SENSORLESS, stepperI.homing_threshold(tmc_sgt.I)), TERN_(J_SENSORLESS, stepperJ.homing_threshold(tmc_sgt.J)), - TERN_(K_SENSORLESS, stepperK.homing_threshold(tmc_sgt.K)) + TERN_(K_SENSORLESS, stepperK.homing_threshold(tmc_sgt.K)), + TERN_(U_SENSORLESS, stepperU.homing_threshold(tmc_sgt.U)), + TERN_(V_SENSORLESS, stepperV.homing_threshold(tmc_sgt.V)), + TERN_(W_SENSORLESS, stepperW.homing_threshold(tmc_sgt.W)) ); TERN_(X2_SENSORLESS, stepperX2.homing_threshold(tmc_sgt.X2)); TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(tmc_sgt.Y2)); @@ -2277,6 +2310,9 @@ void MarlinSettings::postprocess() { TERN_(I_HAS_STEALTHCHOP, SET_STEPPING_MODE(I)); TERN_(J_HAS_STEALTHCHOP, SET_STEPPING_MODE(J)); TERN_(K_HAS_STEALTHCHOP, SET_STEPPING_MODE(K)); + TERN_(U_HAS_STEALTHCHOP, SET_STEPPING_MODE(U)); + TERN_(V_HAS_STEALTHCHOP, SET_STEPPING_MODE(V)); + TERN_(W_HAS_STEALTHCHOP, SET_STEPPING_MODE(W)); TERN_(X2_HAS_STEALTHCHOP, SET_STEPPING_MODE(X2)); TERN_(Y2_HAS_STEALTHCHOP, SET_STEPPING_MODE(Y2)); TERN_(Z2_HAS_STEALTHCHOP, SET_STEPPING_MODE(Z2)); @@ -2397,7 +2433,7 @@ void MarlinSettings::postprocess() { EEPROM_READ(backlash_smoothing_mm); #if ENABLED(BACKLASH_GCODE) - LOOP_LINEAR_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, backlash_distance_mm[axis]); + LOOP_NUM_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, backlash_distance_mm[axis]); backlash.set_correction_uint8(backlash_correction); #ifdef BACKLASH_SMOOTHING_MM backlash.set_smoothing_mm(backlash_smoothing_mm); @@ -2773,8 +2809,17 @@ void MarlinSettings::reset() { #if HAS_K_AXIS && !defined(DEFAULT_KJERK) #define DEFAULT_KJERK 0 #endif + #if HAS_U_AXIS && !defined(DEFAULT_UJERK) + #define DEFAULT_UJERK 0 + #endif + #if HAS_V_AXIS && !defined(DEFAULT_VJERK) + #define DEFAULT_VJERK 0 + #endif + #if HAS_W_AXIS && !defined(DEFAULT_WJERK) + #define DEFAULT_WJERK 0 + #endif planner.max_jerk.set( - LINEAR_AXIS_LIST(DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_IJERK, DEFAULT_JJERK, DEFAULT_KJERK) + NUM_AXIS_LIST(DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_IJERK, DEFAULT_JJERK, DEFAULT_KJERK, DEFAULT_UJERK, DEFAULT_VJERK, DEFAULT_WJERK) ); TERN_(HAS_CLASSIC_E_JERK, planner.max_jerk.e = DEFAULT_EJERK); #endif @@ -2836,7 +2881,7 @@ void MarlinSettings::reset() { #if ENABLED(BACKLASH_GCODE) backlash.set_correction(BACKLASH_CORRECTION); constexpr xyz_float_t tmp = BACKLASH_DISTANCE_MM; - LOOP_LINEAR_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, tmp[axis]); + LOOP_NUM_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, tmp[axis]); #ifdef BACKLASH_SMOOTHING_MM backlash.set_smoothing_mm(BACKLASH_SMOOTHING_MM); #endif @@ -2881,11 +2926,11 @@ void MarlinSettings::reset() { // #if HAS_BED_PROBE constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET; - static_assert(COUNT(dpo) == LINEAR_AXES, "NOZZLE_TO_PROBE_OFFSET must contain offsets for each linear axis X, Y, Z...."); + static_assert(COUNT(dpo) == NUM_AXES, "NOZZLE_TO_PROBE_OFFSET must contain offsets for each linear axis X, Y, Z...."); #if HAS_PROBE_XY_OFFSET - LOOP_LINEAR_AXES(a) probe.offset[a] = dpo[a]; + LOOP_NUM_AXES(a) probe.offset[a] = dpo[a]; #else - probe.offset.set(LINEAR_AXIS_LIST(0, 0, dpo[Z_AXIS], 0, 0, 0)); + probe.offset.set(NUM_AXIS_LIST(0, 0, dpo[Z_AXIS], 0, 0, 0, 0, 0, 0)); #endif #endif diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index af64d9f8bf..5aa7822e20 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -447,6 +447,18 @@ xyze_int8_t Stepper::count_direction{0}; #define K_APPLY_DIR(v,Q) K_DIR_WRITE(v) #define K_APPLY_STEP(v,Q) K_STEP_WRITE(v) #endif +#if HAS_U_AXIS + #define U_APPLY_DIR(v,Q) U_DIR_WRITE(v) + #define U_APPLY_STEP(v,Q) U_STEP_WRITE(v) +#endif +#if HAS_V_AXIS + #define V_APPLY_DIR(v,Q) V_DIR_WRITE(v) + #define V_APPLY_STEP(v,Q) V_STEP_WRITE(v) +#endif +#if HAS_W_AXIS + #define W_APPLY_DIR(v,Q) W_DIR_WRITE(v) + #define W_APPLY_STEP(v,Q) W_STEP_WRITE(v) +#endif #if DISABLED(MIXING_EXTRUDER) #define E_APPLY_STEP(v,Q) E_STEP_WRITE(stepper_extruder, v) @@ -486,9 +498,10 @@ xyze_int8_t Stepper::count_direction{0}; void Stepper::enable_axis(const AxisEnum axis) { #define _CASE_ENABLE(N) case N##_AXIS: ENABLE_AXIS_##N(); break; switch (axis) { - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( _CASE_ENABLE(X), _CASE_ENABLE(Y), _CASE_ENABLE(Z), - _CASE_ENABLE(I), _CASE_ENABLE(J), _CASE_ENABLE(K) + _CASE_ENABLE(I), _CASE_ENABLE(J), _CASE_ENABLE(K), + _CASE_ENABLE(U), _CASE_ENABLE(V), _CASE_ENABLE(W) ); default: break; } @@ -505,9 +518,10 @@ bool Stepper::disable_axis(const AxisEnum axis) { if (can_disable) { #define _CASE_DISABLE(N) case N##_AXIS: DISABLE_AXIS_##N(); break; switch (axis) { - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( _CASE_DISABLE(X), _CASE_DISABLE(Y), _CASE_DISABLE(Z), - _CASE_DISABLE(I), _CASE_DISABLE(J), _CASE_DISABLE(K) + _CASE_DISABLE(I), _CASE_DISABLE(J), _CASE_DISABLE(K), + _CASE_DISABLE(U), _CASE_DISABLE(V), _CASE_DISABLE(W) ); default: break; } @@ -550,9 +564,10 @@ bool Stepper::disable_axis(const AxisEnum axis) { void Stepper::enable_all_steppers() { TERN_(AUTO_POWER_CONTROL, powerManager.power_on()); - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( enable_axis(X_AXIS), enable_axis(Y_AXIS), enable_axis(Z_AXIS), - enable_axis(I_AXIS), enable_axis(J_AXIS), enable_axis(K_AXIS) + enable_axis(I_AXIS), enable_axis(J_AXIS), enable_axis(K_AXIS), + enable_axis(U_AXIS), enable_axis(V_AXIS), enable_axis(W_AXIS) ); enable_e_steppers(); @@ -560,9 +575,10 @@ void Stepper::enable_all_steppers() { } void Stepper::disable_all_steppers() { - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( disable_axis(X_AXIS), disable_axis(Y_AXIS), disable_axis(Z_AXIS), - disable_axis(I_AXIS), disable_axis(J_AXIS), disable_axis(K_AXIS) + disable_axis(I_AXIS), disable_axis(J_AXIS), disable_axis(K_AXIS), + disable_axis(U_AXIS), disable_axis(V_AXIS), disable_axis(W_AXIS) ); disable_e_steppers(); @@ -596,6 +612,9 @@ void Stepper::set_directions() { TERN_(HAS_I_DIR, SET_STEP_DIR(I)); TERN_(HAS_J_DIR, SET_STEP_DIR(J)); TERN_(HAS_K_DIR, SET_STEP_DIR(K)); + TERN_(HAS_U_DIR, SET_STEP_DIR(U)); + TERN_(HAS_V_DIR, SET_STEP_DIR(V)); + TERN_(HAS_W_DIR, SET_STEP_DIR(W)); #if DISABLED(LIN_ADVANCE) #if ENABLED(MIXING_EXTRUDER) @@ -1816,6 +1835,15 @@ void Stepper::pulse_phase_isr() { #if HAS_K_STEP PULSE_PREP(K); #endif + #if HAS_U_STEP + PULSE_PREP(U); + #endif + #if HAS_V_STEP + PULSE_PREP(V); + #endif + #if HAS_W_STEP + PULSE_PREP(W); + #endif #if EITHER(LIN_ADVANCE, MIXING_EXTRUDER) delta_error.e += advance_dividend.e; @@ -1860,6 +1888,15 @@ void Stepper::pulse_phase_isr() { #if HAS_K_STEP PULSE_START(K); #endif + #if HAS_U_STEP + PULSE_START(U); + #endif + #if HAS_V_STEP + PULSE_START(V); + #endif + #if HAS_W_STEP + PULSE_START(W); + #endif #if DISABLED(LIN_ADVANCE) #if ENABLED(MIXING_EXTRUDER) @@ -1898,6 +1935,15 @@ void Stepper::pulse_phase_isr() { #if HAS_K_STEP PULSE_STOP(K); #endif + #if HAS_U_STEP + PULSE_STOP(U); + #endif + #if HAS_V_STEP + PULSE_STOP(V); + #endif + #if HAS_W_STEP + PULSE_STOP(W); + #endif #if DISABLED(LIN_ADVANCE) #if ENABLED(MIXING_EXTRUDER) @@ -2243,13 +2289,16 @@ uint32_t Stepper::block_phase_isr() { #endif axis_bits_t axis_bits = 0; - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( if (X_MOVE_TEST) SBI(axis_bits, A_AXIS), if (Y_MOVE_TEST) SBI(axis_bits, B_AXIS), if (Z_MOVE_TEST) SBI(axis_bits, C_AXIS), if (current_block->steps.i) SBI(axis_bits, I_AXIS), if (current_block->steps.j) SBI(axis_bits, J_AXIS), - if (current_block->steps.k) SBI(axis_bits, K_AXIS) + if (current_block->steps.k) SBI(axis_bits, K_AXIS), + if (current_block->steps.u) SBI(axis_bits, U_AXIS), + if (current_block->steps.v) SBI(axis_bits, V_AXIS), + if (current_block->steps.w) SBI(axis_bits, W_AXIS) ); //if (current_block->steps.e) SBI(axis_bits, E_AXIS); //if (current_block->steps.a) SBI(axis_bits, X_HEAD); @@ -2589,6 +2638,15 @@ void Stepper::init() { #if HAS_K_DIR K_DIR_INIT(); #endif + #if HAS_U_DIR + U_DIR_INIT(); + #endif + #if HAS_V_DIR + V_DIR_INIT(); + #endif + #if HAS_W_DIR + W_DIR_INIT(); + #endif #if HAS_E0_DIR E0_DIR_INIT(); #endif @@ -2659,6 +2717,18 @@ void Stepper::init() { K_ENABLE_INIT(); if (!K_ENABLE_ON) K_ENABLE_WRITE(HIGH); #endif + #if HAS_U_ENABLE + U_ENABLE_INIT(); + if (!U_ENABLE_ON) U_ENABLE_WRITE(HIGH); + #endif + #if HAS_V_ENABLE + V_ENABLE_INIT(); + if (!V_ENABLE_ON) V_ENABLE_WRITE(HIGH); + #endif + #if HAS_W_ENABLE + W_ENABLE_INIT(); + if (!W_ENABLE_ON) W_ENABLE_WRITE(HIGH); + #endif #if HAS_E0_ENABLE E0_ENABLE_INIT(); if (!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH); @@ -2744,6 +2814,15 @@ void Stepper::init() { #if HAS_K_STEP AXIS_INIT(K, K); #endif + #if HAS_U_STEP + AXIS_INIT(U, U); + #endif + #if HAS_V_STEP + AXIS_INIT(V, V); + #endif + #if HAS_W_STEP + AXIS_INIT(W, W); + #endif #if E_STEPPERS && HAS_E0_STEP E_AXIS_INIT(0); @@ -2778,13 +2857,16 @@ void Stepper::init() { // Init direction bits for first moves set_directions(0 - LINEAR_AXIS_GANG( + NUM_AXIS_GANG( | TERN0(INVERT_X_DIR, _BV(X_AXIS)), | TERN0(INVERT_Y_DIR, _BV(Y_AXIS)), | TERN0(INVERT_Z_DIR, _BV(Z_AXIS)), | TERN0(INVERT_I_DIR, _BV(I_AXIS)), | TERN0(INVERT_J_DIR, _BV(J_AXIS)), - | TERN0(INVERT_K_DIR, _BV(K_AXIS)) + | TERN0(INVERT_K_DIR, _BV(K_AXIS)), + | TERN0(INVERT_U_DIR, _BV(U_AXIS)), + | TERN0(INVERT_V_DIR, _BV(V_AXIS)), + | TERN0(INVERT_W_DIR, _BV(W_AXIS)) ) ); @@ -2820,6 +2902,14 @@ void Stepper::_set_position(const abce_long_t &spos) { #elif ENABLED(MARKFORGED_YX) count_position.set(spos.a, spos.b - spos.a, spos.c); #endif + SECONDARY_AXIS_CODE( + count_position.i = spos.i, + count_position.j = spos.j, + count_position.k = spos.k, + count_position.u = spos.u, + count_position.v = spos.v, + count_position.w = spos.w + ); TERN_(HAS_EXTRUDERS, count_position.e = spos.e); #else // default non-h-bot planning @@ -2934,13 +3024,16 @@ int32_t Stepper::triggered_position(const AxisEnum axis) { void Stepper::report_a_position(const xyz_long_t &pos) { SERIAL_ECHOLNPGM_P( - LIST_N(DOUBLE(LINEAR_AXES), + LIST_N(DOUBLE(NUM_AXES), TERN(SAYS_A, PSTR(STR_COUNT_A), PSTR(STR_COUNT_X)), pos.x, TERN(SAYS_B, PSTR("B:"), SP_Y_LBL), pos.y, TERN(SAYS_C, PSTR("C:"), SP_Z_LBL), pos.z, SP_I_LBL, pos.i, SP_J_LBL, pos.j, - SP_K_LBL, pos.k + SP_K_LBL, pos.k, + SP_U_LBL, pos.u, + SP_V_LBL, pos.v, + SP_W_LBL, pos.w ) ); } @@ -3091,16 +3184,18 @@ void Stepper::report_positions() { const bool z_direction = direction ^ BABYSTEP_INVERT_Z; - LINEAR_AXIS_CODE( + NUM_AXIS_CODE( enable_axis(X_AXIS), enable_axis(Y_AXIS), enable_axis(Z_AXIS), - enable_axis(I_AXIS), enable_axis(J_AXIS), enable_axis(K_AXIS) + enable_axis(I_AXIS), enable_axis(J_AXIS), enable_axis(K_AXIS), + enable_axis(U_AXIS), enable_axis(V_AXIS), enable_axis(W_AXIS) ); DIR_WAIT_BEFORE(); - const xyz_byte_t old_dir = LINEAR_AXIS_ARRAY( + const xyz_byte_t old_dir = NUM_AXIS_ARRAY( X_DIR_READ(), Y_DIR_READ(), Z_DIR_READ(), - I_DIR_READ(), J_DIR_READ(), K_DIR_READ() + I_DIR_READ(), J_DIR_READ(), K_DIR_READ(), + U_DIR_READ(), V_DIR_READ(), W_DIR_READ() ); X_DIR_WRITE(INVERT_X_DIR ^ z_direction); @@ -3119,6 +3214,15 @@ void Stepper::report_positions() { #ifdef K_DIR_WRITE K_DIR_WRITE(INVERT_K_DIR ^ z_direction); #endif + #ifdef U_DIR_WRITE + U_DIR_WRITE(INVERT_U_DIR ^ z_direction); + #endif + #ifdef V_DIR_WRITE + V_DIR_WRITE(INVERT_V_DIR ^ z_direction); + #endif + #ifdef W_DIR_WRITE + W_DIR_WRITE(INVERT_W_DIR ^ z_direction); + #endif DIR_WAIT_AFTER(); @@ -3140,6 +3244,15 @@ void Stepper::report_positions() { #ifdef K_STEP_WRITE K_STEP_WRITE(!INVERT_K_STEP_PIN); #endif + #ifdef U_STEP_WRITE + U_STEP_WRITE(!INVERT_U_STEP_PIN); + #endif + #ifdef V_STEP_WRITE + V_STEP_WRITE(!INVERT_V_STEP_PIN); + #endif + #ifdef W_STEP_WRITE + W_STEP_WRITE(!INVERT_W_STEP_PIN); + #endif _PULSE_WAIT(); @@ -3159,6 +3272,15 @@ void Stepper::report_positions() { #ifdef K_STEP_WRITE K_STEP_WRITE(INVERT_K_STEP_PIN); #endif + #ifdef U_STEP_WRITE + U_STEP_WRITE(INVERT_U_STEP_PIN); + #endif + #ifdef V_STEP_WRITE + V_STEP_WRITE(INVERT_V_STEP_PIN); + #endif + #ifdef W_STEP_WRITE + W_STEP_WRITE(INVERT_W_STEP_PIN); + #endif // Restore direction bits EXTRA_DIR_WAIT_BEFORE(); @@ -3179,6 +3301,15 @@ void Stepper::report_positions() { #ifdef K_DIR_WRITE K_DIR_WRITE(old_dir.k); #endif + #ifdef U_DIR_WRITE + U_DIR_WRITE(old_dir.u); + #endif + #ifdef V_DIR_WRITE + V_DIR_WRITE(old_dir.v); + #endif + #ifdef W_DIR_WRITE + W_DIR_WRITE(old_dir.w); + #endif EXTRA_DIR_WAIT_AFTER(); @@ -3195,6 +3326,15 @@ void Stepper::report_positions() { #if HAS_K_AXIS case K_AXIS: BABYSTEP_AXIS(K, 0, direction); break; #endif + #if HAS_U_AXIS + case U_AXIS: BABYSTEP_AXIS(U, 0, direction); break; + #endif + #if HAS_V_AXIS + case V_AXIS: BABYSTEP_AXIS(V, 0, direction); break; + #endif + #if HAS_W_AXIS + case W_AXIS: BABYSTEP_AXIS(W, 0, direction); break; + #endif default: break; } @@ -3423,6 +3563,24 @@ void Stepper::report_positions() { SET_OUTPUT(K_MS3_PIN); #endif #endif + #if HAS_U_MS_PINS + SET_OUTPUT(U_MS1_PIN); SET_OUTPUT(U_MS2_PIN); + #if PIN_EXISTS(U_MS3) + SET_OUTPUT(U_MS3_PIN); + #endif + #endif + #if HAS_V_MS_PINS + SET_OUTPUT(V_MS1_PIN); SET_OUTPUT(V_MS2_PIN); + #if PIN_EXISTS(V_MS3) + SET_OUTPUT(V_MS3_PIN); + #endif + #endif + #if HAS_W_MS_PINS + SET_OUTPUT(W_MS1_PIN); SET_OUTPUT(W_MS2_PIN); + #if PIN_EXISTS(W_MS3) + SET_OUTPUT(W_MS3_PIN); + #endif + #endif #if HAS_E0_MS_PINS SET_OUTPUT(E0_MS1_PIN); SET_OUTPUT(E0_MS2_PIN); #if PIN_EXISTS(E0_MS3) @@ -3548,6 +3706,15 @@ void Stepper::report_positions() { #if HAS_K_MS_PINS case 13: WRITE(K_MS1_PIN, ms1); break #endif + #if HAS_U_MS_PINS + case 14: WRITE(U_MS1_PIN, ms1); break + #endif + #if HAS_V_MS_PINS + case 15: WRITE(V_MS1_PIN, ms1); break + #endif + #if HAS_W_MS_PINS + case 16: WRITE(W_MS1_PIN, ms1); break + #endif } if (ms2 >= 0) switch (driver) { #if HAS_X_MS_PINS || HAS_X2_MS_PINS @@ -3619,6 +3786,15 @@ void Stepper::report_positions() { #if HAS_K_MS_PINS case 13: WRITE(K_MS2_PIN, ms2); break #endif + #if HAS_U_MS_PINS + case 14: WRITE(U_MS2_PIN, ms2); break + #endif + #if HAS_V_MS_PINS + case 15: WRITE(V_MS2_PIN, ms2); break + #endif + #if HAS_W_MS_PINS + case 16: WRITE(W_MS2_PIN, ms2); break + #endif } if (ms3 >= 0) switch (driver) { #if HAS_X_MS_PINS || HAS_X2_MS_PINS @@ -3755,6 +3931,24 @@ void Stepper::report_positions() { PIN_CHAR(K_MS3); #endif #endif + #if HAS_U_MS_PINS + MS_LINE(U); + #if PIN_EXISTS(U_MS3) + PIN_CHAR(U_MS3); + #endif + #endif + #if HAS_V_MS_PINS + MS_LINE(V); + #if PIN_EXISTS(V_MS3) + PIN_CHAR(V_MS3); + #endif + #endif + #if HAS_W_MS_PINS + MS_LINE(W); + #if PIN_EXISTS(W_MS3) + PIN_CHAR(W_MS3); + #endif + #endif #if HAS_E0_MS_PINS MS_LINE(E0); #if PIN_EXISTS(E0_MS3) diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 4c9fbb9556..8cc8610fd4 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -159,12 +159,21 @@ #if HAS_K_STEP #define ISR_K_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif +#if HAS_U_STEP + #define ISR_U_STEPPER_CYCLES ISR_STEPPER_CYCLES +#endif +#if HAS_V_STEP + #define ISR_V_STEPPER_CYCLES ISR_STEPPER_CYCLES +#endif +#if HAS_W_STEP + #define ISR_W_STEPPER_CYCLES ISR_STEPPER_CYCLES +#endif #if HAS_EXTRUDERS #define ISR_E_STEPPER_CYCLES ISR_STEPPER_CYCLES // E is always interpolated, even for mixing extruders #endif // And the total minimum loop time, not including the base -#define MIN_ISR_LOOP_CYCLES (ISR_MIXING_STEPPER_CYCLES LOGICAL_AXIS_GANG(+ ISR_E_STEPPER_CYCLES, + ISR_X_STEPPER_CYCLES, + ISR_Y_STEPPER_CYCLES, + ISR_Z_STEPPER_CYCLES, + ISR_I_STEPPER_CYCLES, + ISR_J_STEPPER_CYCLES, + ISR_K_STEPPER_CYCLES)) +#define MIN_ISR_LOOP_CYCLES (ISR_MIXING_STEPPER_CYCLES LOGICAL_AXIS_GANG(+ ISR_E_STEPPER_CYCLES, + ISR_X_STEPPER_CYCLES, + ISR_Y_STEPPER_CYCLES, + ISR_Z_STEPPER_CYCLES, + ISR_I_STEPPER_CYCLES, + ISR_J_STEPPER_CYCLES, + ISR_K_STEPPER_CYCLES, + ISR_U_STEPPER_CYCLES, + ISR_V_STEPPER_CYCLES, + ISR_W_STEPPER_CYCLES)) // Calculate the minimum MPU cycles needed per pulse to enforce, limited to the max stepper rate #define _MIN_STEPPER_PULSE_CYCLES(N) _MAX(uint32_t((F_CPU) / (MAXIMUM_STEPPER_RATE)), ((F_CPU) / 500000UL) * (N)) @@ -236,7 +245,7 @@ // Perhaps DISABLE_MULTI_STEPPING should be required with ADAPTIVE_STEP_SMOOTHING. #define MIN_STEP_ISR_FREQUENCY (MAX_STEP_ISR_FREQUENCY_1X / 2) -#define ENABLE_COUNT (LINEAR_AXES + E_STEPPERS) +#define ENABLE_COUNT (NUM_AXES + E_STEPPERS) typedef IF<(ENABLE_COUNT > 8), uint16_t, uint8_t>::type ena_mask_t; // Axis flags type, for enabled state or other simple state @@ -244,25 +253,25 @@ typedef struct { union { ena_mask_t bits; struct { - bool LINEAR_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1); + bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1); #if HAS_EXTRUDERS bool LIST_N(EXTRUDERS, E0:1, E1:1, E2:1, E3:1, E4:1, E5:1, E6:1, E7:1); #endif }; }; - constexpr ena_mask_t linear_bits() { return _BV(LINEAR_AXES) - 1; } - constexpr ena_mask_t e_bits() { return (_BV(EXTRUDERS) - 1) << LINEAR_AXES; } + constexpr ena_mask_t linear_bits() { return _BV(NUM_AXES) - 1; } + constexpr ena_mask_t e_bits() { return (_BV(EXTRUDERS) - 1) << NUM_AXES; } } axis_flags_t; // All the stepper enable pins constexpr pin_t ena_pins[] = { - LINEAR_AXIS_LIST(X_ENABLE_PIN, Y_ENABLE_PIN, Z_ENABLE_PIN, I_ENABLE_PIN, J_ENABLE_PIN, K_ENABLE_PIN), + NUM_AXIS_LIST(X_ENABLE_PIN, Y_ENABLE_PIN, Z_ENABLE_PIN, I_ENABLE_PIN, J_ENABLE_PIN, K_ENABLE_PIN, U_ENABLE_PIN, V_ENABLE_PIN, W_ENABLE_PIN), LIST_N(E_STEPPERS, E0_ENABLE_PIN, E1_ENABLE_PIN, E2_ENABLE_PIN, E3_ENABLE_PIN, E4_ENABLE_PIN, E5_ENABLE_PIN, E6_ENABLE_PIN, E7_ENABLE_PIN) }; // Index of the axis or extruder element in a combined array constexpr uint8_t index_of_axis(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { - return uint8_t(axis) + (E_TERN0(axis < LINEAR_AXES ? 0 : eindex)); + return uint8_t(axis) + (E_TERN0(axis < NUM_AXES ? 0 : eindex)); } //#define __IAX_N(N,V...) _IAX_##N(V) //#define _IAX_N(N,V...) __IAX_N(N,V) @@ -292,7 +301,7 @@ constexpr bool any_enable_overlap(const uint8_t a=0) { // (e.g., CoreXY, Dual XYZ, or E with multiple steppers, etc.). constexpr ena_mask_t enable_overlap[] = { #define _OVERLAP(N) ena_overlap(INDEX_OF_AXIS(AxisEnum(N))), - REPEAT(LINEAR_AXES, _OVERLAP) + REPEAT(NUM_AXES, _OVERLAP) #if HAS_EXTRUDERS #define _E_OVERLAP(N) ena_overlap(INDEX_OF_AXIS(E_AXIS, N)), REPEAT(E_STEPPERS, _E_OVERLAP) @@ -320,7 +329,7 @@ class Stepper { #ifndef MOTOR_CURRENT_PWM_FREQUENCY #define MOTOR_CURRENT_PWM_FREQUENCY 31400 #endif - #define MOTOR_CURRENT_COUNT LINEAR_AXES + #define MOTOR_CURRENT_COUNT NUM_AXES #elif HAS_MOTOR_CURRENT_SPI static constexpr uint32_t digipot_count[] = DIGIPOT_MOTOR_CURRENT; #define MOTOR_CURRENT_COUNT COUNT(Stepper::digipot_count) diff --git a/Marlin/src/module/stepper/L64xx.cpp b/Marlin/src/module/stepper/L64xx.cpp index 27816fb4f7..5b60746396 100644 --- a/Marlin/src/module/stepper/L64xx.cpp +++ b/Marlin/src/module/stepper/L64xx.cpp @@ -64,6 +64,15 @@ #if AXIS_IS_L64XX(K) L64XX_CLASS(K) stepperK(L6470_CHAIN_SS_PIN); #endif +#if AXIS_IS_L64XX(U) + L64XX_CLASS(u) stepperU(L6470_CHAIN_SS_PIN); +#endif +#if AXIS_IS_L64XX(V) + L64XX_CLASS(v) stepperV(L6470_CHAIN_SS_PIN); +#endif +#if AXIS_IS_L64XX(W) + L64XX_CLASS(w) stepperW(L6470_CHAIN_SS_PIN); +#endif #if AXIS_IS_L64XX(E0) L64XX_CLASS(E0) stepperE0(L6470_CHAIN_SS_PIN); #endif @@ -217,6 +226,15 @@ void L64XX_Marlin::init_to_defaults() { #if AXIS_IS_L64XX(K) L6470_INIT_CHIP(K); #endif + #if AXIS_IS_L64XX(U) + L6470_INIT_CHIP(U); + #endif + #if AXIS_IS_L64XX(V) + L6470_INIT_CHIP(V); + #endif + #if AXIS_IS_L64XX(W) + L6470_INIT_CHIP(W); + #endif #if AXIS_IS_L64XX(E0) L6470_INIT_CHIP(E0); #endif diff --git a/Marlin/src/module/stepper/L64xx.h b/Marlin/src/module/stepper/L64xx.h index 9f7e6623b1..870b0414f8 100644 --- a/Marlin/src/module/stepper/L64xx.h +++ b/Marlin/src/module/stepper/L64xx.h @@ -266,6 +266,72 @@ #endif #endif +// U Stepper +#if HAS_U_AXIS + #if AXIS_IS_L64XX(U) + extern L64XX_CLASS(U) stepperU; + #define U_ENABLE_INIT() NOOP + #define U_ENABLE_WRITE(STATE) (STATE ? stepperU.hardStop() : stepperU.free()) + #define U_ENABLE_READ() (stepperU.getStatus() & STATUS_HIZ) + #if AXIS_DRIVER_TYPE_U(L6474) + #define U_DIR_INIT() SET_OUTPUT(U_DIR_PIN) + #define U_DIR_WRITE(STATE) L6474_DIR_WRITE(U, STATE) + #define U_DIR_READ() READ(U_DIR_PIN) + #else + #define U_DIR_INIT() NOOP + #define U_DIR_WRITE(STATE) L64XX_DIR_WRITE(U, STATE) + #define U_DIR_READ() (stepper##U.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_U(L6470) + #define DISABLE_STEPPER_U() stepperU.free() + #endif + #endif + #endif +#endif + +// V Stepper +#if HAS_V_AXIS + #if AXIS_IS_L64XX(V) + extern L64XX_CLASS(V) stepperV; + #define V_ENABLE_INIT() NOOP + #define V_ENABLE_WRITE(STATE) (STATE ? stepperV.hardStop() : stepperV.free()) + #define V_ENABLE_READ() (stepperV.getStatus() & STATUS_HIZ) + #if AXIS_DRIVER_TYPE_V(L6474) + #define V_DIR_INIT() SET_OUTPUT(V_DIR_PIN) + #define V_DIR_WRITE(STATE) L6474_DIR_WRITE(V, STATE) + #define V_DIR_READ() READ(V_DIR_PIN) + #else + #define V_DIR_INIT() NOOP + #define V_DIR_WRITE(STATE) L64XX_DIR_WRITE(V, STATE) + #define V_DIR_READ() (stepper##V.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_V(L6470) + #define DISABLE_STEPPER_V() stepperV.free() + #endif + #endif + #endif +#endif + +// W Stepper +#if HAS_W_AXIS + #if AXIS_IS_L64XX(W) + extern L64XX_CLASS(w) stepperW; + #define W_ENABLE_INIT() NOOP + #define W_ENABLE_WRITE(STATE) (STATE ? stepperW.hardStop() : stepperW.free()) + #define W_ENABLE_READ() (stepperW.getStatus() & STATUS_HIZ) + #if AXIS_DRIVER_TYPE_W(L6474) + #define W_DIR_INIT() SET_OUTPUT(W_DIR_PIN) + #define W_DIR_WRITE(STATE) L6474_DIR_WRITE(W, STATE) + #define W_DIR_READ() READ(W_DIR_PIN) + #else + #define W_DIR_INIT() NOOP + #define W_DIR_WRITE(STATE) L64XX_DIR_WRITE(W, STATE) + #define W_DIR_READ() (stepper##W.getStatus() & STATUS_DIR); + #if AXIS_DRIVER_TYPE_W(L6470) + #define DISABLE_STEPPER_W() stepperW.free() + #endif + #endif + #endif +#endif + // E0 Stepper #if AXIS_IS_L64XX(E0) extern L64XX_CLASS(E0) stepperE0; diff --git a/Marlin/src/module/stepper/TMC26X.cpp b/Marlin/src/module/stepper/TMC26X.cpp index 26f91bfeb9..52d84f8410 100644 --- a/Marlin/src/module/stepper/TMC26X.cpp +++ b/Marlin/src/module/stepper/TMC26X.cpp @@ -69,6 +69,15 @@ #if AXIS_DRIVER_TYPE_K(TMC26X) _TMC26X_DEFINE(K); #endif +#if AXIS_DRIVER_TYPE_U(TMC26X) + _TMC26X_DEFINE(U); +#endif +#if AXIS_DRIVER_TYPE_V(TMC26X) + _TMC26X_DEFINE(V); +#endif +#if AXIS_DRIVER_TYPE_W(TMC26X) + _TMC26X_DEFINE(W); +#endif #if AXIS_DRIVER_TYPE_E0(TMC26X) _TMC26X_DEFINE(E0); #endif @@ -133,6 +142,15 @@ void tmc26x_init_to_defaults() { #if AXIS_DRIVER_TYPE_K(TMC26X) _TMC26X_INIT(K); #endif + #if AXIS_DRIVER_TYPE_U(TMC26X) + _TMC26X_INIT(U); + #endif + #if AXIS_DRIVER_TYPE_V(TMC26X) + _TMC26X_INIT(V); + #endif + #if AXIS_DRIVER_TYPE_W(TMC26X) + _TMC26X_INIT(W); + #endif #if AXIS_DRIVER_TYPE_E0(TMC26X) _TMC26X_INIT(E0); #endif diff --git a/Marlin/src/module/stepper/TMC26X.h b/Marlin/src/module/stepper/TMC26X.h index 988bebe0f2..1fd94b26a8 100644 --- a/Marlin/src/module/stepper/TMC26X.h +++ b/Marlin/src/module/stepper/TMC26X.h @@ -123,6 +123,30 @@ void tmc26x_init_to_defaults(); #define K_ENABLE_READ() stepperK.isEnabled() #endif +// U Stepper +#if HAS_U_ENABLE && AXIS_DRIVER_TYPE_U(TMC26X) + extern TMC26XStepper stepperU; + #define U_ENABLE_INIT() NOOP + #define U_ENABLE_WRITE(STATE) stepperU.setEnabled(STATE) + #define U_ENABLE_READ() stepperU.isEnabled() +#endif + +// V Stepper +#if HAS_V_ENABLE && AXIS_DRIVER_TYPE_V(TMC26X) + extern TMC26XStepper stepperV; + #define V_ENABLE_INIT() NOOP + #define V_ENABLE_WRITE(STATE) stepperV.setEnabled(STATE) + #define V_ENABLE_READ() stepperV.isEnabled() +#endif + +// W Stepper +#if HAS_W_ENABLE && AXIS_DRIVER_TYPE_W(TMC26X) + extern TMC26XStepper stepperW; + #define W_ENABLE_INIT() NOOP + #define W_ENABLE_WRITE(STATE) stepperW.setEnabled(STATE) + #define W_ENABLE_READ() stepperW.isEnabled() +#endif + // E0 Stepper #if AXIS_DRIVER_TYPE_E0(TMC26X) extern TMC26XStepper stepperE0; diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 7aea677534..879185ca14 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -262,6 +262,63 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define K_STEP_READ() bool(READ(K_STEP_PIN)) #endif +// U Stepper +#if HAS_U_AXIS + #ifndef U_ENABLE_INIT + #define U_ENABLE_INIT() SET_OUTPUT(U_ENABLE_PIN) + #define U_ENABLE_WRITE(STATE) WRITE(U_ENABLE_PIN,STATE) + #define U_ENABLE_READ() bool(READ(U_ENABLE_PIN)) + #endif + #ifndef U_DIR_INIT + #define U_DIR_INIT() SET_OUTPUT(U_DIR_PIN) + #define U_DIR_WRITE(STATE) WRITE(U_DIR_PIN,STATE) + #define U_DIR_READ() bool(READ(U_DIR_PIN)) + #endif + #define U_STEP_INIT() SET_OUTPUT(U_STEP_PIN) + #ifndef U_STEP_WRITE + #define U_STEP_WRITE(STATE) WRITE(U_STEP_PIN,STATE) + #endif + #define U_STEP_READ() bool(READ(U_STEP_PIN)) +#endif + +// V Stepper +#if HAS_V_AXIS + #ifndef V_ENABLE_INIT + #define V_ENABLE_INIT() SET_OUTPUT(V_ENABLE_PIN) + #define V_ENABLE_WRITE(STATE) WRITE(V_ENABLE_PIN,STATE) + #define V_ENABLE_READ() bool(READ(V_ENABLE_PIN)) + #endif + #ifndef V_DIR_INIT + #define V_DIR_INIT() SET_OUTPUT(V_DIR_PIN) + #define V_DIR_WRITE(STATE) WRITE(V_DIR_PIN,STATE) + #define V_DIR_READ() bool(READ(V_DIR_PIN)) + #endif + #define V_STEP_INIT() SET_OUTPUT(V_STEP_PIN) + #ifndef V_STEP_WRITE + #define V_STEP_WRITE(STATE) WRITE(V_STEP_PIN,STATE) + #endif + #define V_STEP_READ() bool(READ(V_STEP_PIN)) +#endif + +// W Stepper +#if HAS_W_AXIS + #ifndef W_ENABLE_INIT + #define W_ENABLE_INIT() SET_OUTPUT(W_ENABLE_PIN) + #define W_ENABLE_WRITE(STATE) WRITE(W_ENABLE_PIN,STATE) + #define W_ENABLE_READ() bool(READ(W_ENABLE_PIN)) + #endif + #ifndef W_DIR_INIT + #define W_DIR_INIT() SET_OUTPUT(W_DIR_PIN) + #define W_DIR_WRITE(STATE) WRITE(W_DIR_PIN,STATE) + #define W_DIR_READ() bool(READ(W_DIR_PIN)) + #endif + #define W_STEP_INIT() SET_OUTPUT(W_STEP_PIN) + #ifndef W_STEP_WRITE + #define W_STEP_WRITE(STATE) WRITE(W_STEP_PIN,STATE) + #endif + #define W_STEP_READ() bool(READ(W_STEP_PIN)) +#endif + // E0 Stepper #ifndef E0_ENABLE_INIT #define E0_ENABLE_INIT() SET_OUTPUT(E0_ENABLE_PIN) @@ -743,6 +800,51 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define DISABLE_STEPPER_K() TERN(HAS_K_ENABLE, K_ENABLE_WRITE(!K_ENABLE_ON), NOOP) #endif +#ifndef ENABLE_STEPPER_U + #if HAS_U_ENABLE + #define ENABLE_STEPPER_U() U_ENABLE_WRITE( U_ENABLE_ON) + #else + #define ENABLE_STEPPER_U() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_U + #if HAS_U_ENABLE + #define DISABLE_STEPPER_U() U_ENABLE_WRITE(!U_ENABLE_ON) + #else + #define DISABLE_STEPPER_U() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_V + #if HAS_V_ENABLE + #define ENABLE_STEPPER_V() V_ENABLE_WRITE( V_ENABLE_ON) + #else + #define ENABLE_STEPPER_V() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_V + #if HAS_V_ENABLE + #define DISABLE_STEPPER_V() V_ENABLE_WRITE(!V_ENABLE_ON) + #else + #define DISABLE_STEPPER_V() NOOP + #endif +#endif + +#ifndef ENABLE_STEPPER_W + #if HAS_W_ENABLE + #define ENABLE_STEPPER_W() W_ENABLE_WRITE( W_ENABLE_ON) + #else + #define ENABLE_STEPPER_W() NOOP + #endif +#endif +#ifndef DISABLE_STEPPER_W + #if HAS_W_ENABLE + #define DISABLE_STEPPER_W() W_ENABLE_WRITE(!W_ENABLE_ON) + #else + #define DISABLE_STEPPER_W() NOOP + #endif +#endif + #ifndef ENABLE_STEPPER_E0 #define ENABLE_STEPPER_E0() TERN(HAS_E0_ENABLE, E0_ENABLE_WRITE( E_ENABLE_ON), NOOP) #endif @@ -917,6 +1019,28 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define DISABLE_AXIS_K() NOOP #endif +#if HAS_U_AXIS + #define ENABLE_AXIS_U() if (SHOULD_ENABLE(u)) { ENABLE_STEPPER_U(); AFTER_CHANGE(u, true); } + #define DISABLE_AXIS_U() if (SHOULD_DISABLE(u)) { DISABLE_STEPPER_U(); AFTER_CHANGE(u, false); set_axis_untrusted(U_AXIS); } +#else + #define ENABLE_AXIS_U() NOOP + #define DISABLE_AXIS_U() NOOP +#endif +#if HAS_V_AXIS + #define ENABLE_AXIS_V() if (SHOULD_ENABLE(v)) { ENABLE_STEPPER_V(); AFTER_CHANGE(v, true); } + #define DISABLE_AXIS_V() if (SHOULD_DISABLE(v)) { DISABLE_STEPPER_V(); AFTER_CHANGE(v, false); set_axis_untrusted(V_AXIS); } +#else + #define ENABLE_AXIS_V() NOOP + #define DISABLE_AXIS_V() NOOP +#endif +#if HAS_W_AXIS + #define ENABLE_AXIS_W() if (SHOULD_ENABLE(w)) { ENABLE_STEPPER_W(); AFTER_CHANGE(w, true); } + #define DISABLE_AXIS_W() if (SHOULD_DISABLE(w)) { DISABLE_STEPPER_W(); AFTER_CHANGE(w, false); set_axis_untrusted(W_AXIS); } +#else + #define ENABLE_AXIS_W() NOOP + #define DISABLE_AXIS_W() NOOP +#endif + // // Extruder steppers enable / disable macros // diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index af09623dc1..ee156a1986 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -36,7 +36,7 @@ #include enum StealthIndex : uint8_t { - LOGICAL_AXIS_LIST(STEALTH_AXIS_E, STEALTH_AXIS_X, STEALTH_AXIS_Y, STEALTH_AXIS_Z, STEALTH_AXIS_I, STEALTH_AXIS_J, STEALTH_AXIS_K) + LOGICAL_AXIS_LIST(STEALTH_AXIS_E, STEALTH_AXIS_X, STEALTH_AXIS_Y, STEALTH_AXIS_Z, STEALTH_AXIS_I, STEALTH_AXIS_J, STEALTH_AXIS_K, STEALTH_AXIS_U, STEALTH_AXIS_V, STEALTH_AXIS_W) }; #define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE, ST##_HOLD_MULTIPLIER) @@ -106,6 +106,15 @@ enum StealthIndex : uint8_t { #if AXIS_HAS_SPI(K) TMC_SPI_DEFINE(K, K); #endif +#if AXIS_HAS_SPI(U) + TMC_SPI_DEFINE(U, U); +#endif +#if AXIS_HAS_SPI(V) + TMC_SPI_DEFINE(V, V); +#endif +#if AXIS_HAS_SPI(W) + TMC_SPI_DEFINE(W, W); +#endif #if AXIS_HAS_SPI(E0) TMC_SPI_DEFINE_E(0); #endif @@ -173,6 +182,15 @@ enum StealthIndex : uint8_t { #ifndef TMC_K_BAUD_RATE #define TMC_K_BAUD_RATE TMC_BAUD_RATE #endif +#ifndef TMC_U_BAUD_RATE + #define TMC_U_BAUD_RATE TMC_BAUD_RATE +#endif +#ifndef TMC_V_BAUD_RATE + #define TMC_V_BAUD_RATE TMC_BAUD_RATE +#endif +#ifndef TMC_W_BAUD_RATE + #define TMC_W_BAUD_RATE TMC_BAUD_RATE +#endif #ifndef TMC_E0_BAUD_RATE #define TMC_E0_BAUD_RATE TMC_BAUD_RATE #endif @@ -374,6 +392,32 @@ enum StealthIndex : uint8_t { #define K_HAS_SW_SERIAL 1 #endif #endif + #if AXIS_HAS_UART(U) + #ifdef U_HARDWARE_SERIAL + TMC_UART_DEFINE(HW, U, U); + #define U_HAS_HW_SERIAL 1 + #else + TMC_UART_DEFINE(SW, U, U); + #define U_HAS_SW_SERIAL 1 + #endif + #endif + #if AXIS_HAS_UART(V) + #ifdef V_HARDWARE_SERIAL + TMC_UART_DEFINE(HW, V, V); + #else + TMC_UART_DEFINE(SW, V, V); + #define V_HAS_SW_SERIAL 1 + #endif + #endif + #if AXIS_HAS_UART(W) + #ifdef W_HARDWARE_SERIAL + TMC_UART_DEFINE(HW, W, W); + #define W_HAS_HW_SERIAL 1 + #else + TMC_UART_DEFINE(SW, W, W); + #define W_HAS_SW_SERIAL 1 + #endif + #endif #if AXIS_HAS_UART(E0) #ifdef E0_HARDWARE_SERIAL @@ -449,7 +493,7 @@ enum StealthIndex : uint8_t { #endif #define _EN_ITEM(N) , E##N - enum TMCAxis : uint8_t { LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(EXTRUDERS, _EN_ITEM), TOTAL }; + enum TMCAxis : uint8_t { NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W), X2, Y2, Z2, Z3, Z4 REPEAT(EXTRUDERS, _EN_ITEM), TOTAL }; #undef _EN_ITEM void tmc_serial_begin() { @@ -543,6 +587,27 @@ enum StealthIndex : uint8_t { stepperK.beginSerial(TMC_BAUD_RATE); #endif #endif + #if AXIS_HAS_UART(U) + #ifdef U_HARDWARE_SERIAL + HW_SERIAL_BEGIN(U); + #else + stepperU.beginSerial(TMC_BAUD_RATE); + #endif + #endif + #if AXIS_HAS_UART(V) + #ifdef V_HARDWARE_SERIAL + HW_SERIAL_BEGIN(V); + #else + stepperV.beginSerial(TMC_BAUD_RATE); + #endif + #endif + #if AXIS_HAS_UART(W) + #ifdef W_HARDWARE_SERIAL + HW_SERIAL_BEGIN(W); + #else + stepperW.beginSerial(TMC_BAUD_RATE); + #endif + #endif #if AXIS_HAS_UART(E0) #ifdef E0_HARDWARE_SERIAL HW_SERIAL_BEGIN(E0); @@ -814,6 +879,15 @@ void restore_trinamic_drivers() { #if AXIS_IS_TMC(K) stepperK.push(); #endif + #if AXIS_IS_TMC(U) + stepperU.push(); + #endif + #if AXIS_IS_TMC(V) + stepperV.push(); + #endif + #if AXIS_IS_TMC(W) + stepperW.push(); + #endif #if AXIS_IS_TMC(E0) stepperE0.push(); #endif @@ -844,7 +918,8 @@ void reset_trinamic_drivers() { static constexpr bool stealthchop_by_axis[] = LOGICAL_AXIS_ARRAY( ENABLED(STEALTHCHOP_E), ENABLED(STEALTHCHOP_XY), ENABLED(STEALTHCHOP_XY), ENABLED(STEALTHCHOP_Z), - ENABLED(STEALTHCHOP_I), ENABLED(STEALTHCHOP_J), ENABLED(STEALTHCHOP_K) + ENABLED(STEALTHCHOP_I), ENABLED(STEALTHCHOP_J), ENABLED(STEALTHCHOP_K), + ENABLED(STEALTHCHOP_U), ENABLED(STEALTHCHOP_V), ENABLED(STEALTHCHOP_W) ); #if AXIS_IS_TMC(X) @@ -880,6 +955,15 @@ void reset_trinamic_drivers() { #if AXIS_IS_TMC(K) TMC_INIT(K, STEALTH_AXIS_K); #endif + #if AXIS_IS_TMC(U) + TMC_INIT(U, STEALTH_AXIS_U); + #endif + #if AXIS_IS_TMC(V) + TMC_INIT(V, STEALTH_AXIS_V); + #endif + #if AXIS_IS_TMC(W) + TMC_INIT(W, STEALTH_AXIS_W); + #endif #if AXIS_IS_TMC(E0) TMC_INIT(E0, STEALTH_AXIS_E); #endif @@ -917,6 +1001,9 @@ void reset_trinamic_drivers() { TERN_(I_SENSORLESS, stepperI.homing_threshold(I_STALL_SENSITIVITY)); TERN_(J_SENSORLESS, stepperJ.homing_threshold(J_STALL_SENSITIVITY)); TERN_(K_SENSORLESS, stepperK.homing_threshold(K_STALL_SENSITIVITY)); + TERN_(U_SENSORLESS, stepperU.homing_threshold(U_STALL_SENSITIVITY)); + TERN_(V_SENSORLESS, stepperV.homing_threshold(V_STALL_SENSITIVITY)); + TERN_(W_SENSORLESS, stepperW.homing_threshold(W_STALL_SENSITIVITY)); #endif #ifdef TMC_ADV @@ -946,7 +1033,7 @@ void reset_trinamic_drivers() { TMC_HW_DETAIL(X), TMC_HW_DETAIL(X2), TMC_HW_DETAIL(Y), TMC_HW_DETAIL(Y2), TMC_HW_DETAIL(Z), TMC_HW_DETAIL(Z2), TMC_HW_DETAIL(Z3), TMC_HW_DETAIL(Z4), - TMC_HW_DETAIL(I), TMC_HW_DETAIL(J), TMC_HW_DETAIL(K), + TMC_HW_DETAIL(I), TMC_HW_DETAIL(J), TMC_HW_DETAIL(K), TMC_HW_DETAIL(U), TMC_HW_DETAIL(V), TMC_HW_DETAIL(W), TMC_HW_DETAIL(E0), TMC_HW_DETAIL(E1), TMC_HW_DETAIL(E2), TMC_HW_DETAIL(E3), TMC_HW_DETAIL(E4), TMC_HW_DETAIL(E5), TMC_HW_DETAIL(E6), TMC_HW_DETAIL(E7) }; @@ -969,7 +1056,7 @@ void reset_trinamic_drivers() { SA_NO_TMC_HW_C(X); SA_NO_TMC_HW_C(X2); SA_NO_TMC_HW_C(Y); SA_NO_TMC_HW_C(Y2); SA_NO_TMC_HW_C(Z); SA_NO_TMC_HW_C(Z2); SA_NO_TMC_HW_C(Z3); SA_NO_TMC_HW_C(Z4); - SA_NO_TMC_HW_C(I); SA_NO_TMC_HW_C(J); SA_NO_TMC_HW_C(K); + SA_NO_TMC_HW_C(I); SA_NO_TMC_HW_C(J); SA_NO_TMC_HW_C(K); SA_NO_TMC_HW_C(U); SA_NO_TMC_HW_C(V); SA_NO_TMC_HW_C(W); SA_NO_TMC_HW_C(E0); SA_NO_TMC_HW_C(E1); SA_NO_TMC_HW_C(E2); SA_NO_TMC_HW_C(E3); SA_NO_TMC_HW_C(E4); SA_NO_TMC_HW_C(E5); SA_NO_TMC_HW_C(E6); SA_NO_TMC_HW_C(E7); #endif @@ -981,7 +1068,7 @@ void reset_trinamic_drivers() { TMC_SW_DETAIL(X), TMC_SW_DETAIL(X2), TMC_SW_DETAIL(Y), TMC_SW_DETAIL(Y2), TMC_SW_DETAIL(Z), TMC_SW_DETAIL(Z2), TMC_SW_DETAIL(Z3), TMC_SW_DETAIL(Z4), - TMC_SW_DETAIL(I), TMC_SW_DETAIL(J), TMC_SW_DETAIL(K), + TMC_SW_DETAIL(I), TMC_SW_DETAIL(J), TMC_SW_DETAIL(K), TMC_SW_DETAIL(U), TMC_SW_DETAIL(V), TMC_SW_DETAIL(W), TMC_SW_DETAIL(E0), TMC_SW_DETAIL(E1), TMC_SW_DETAIL(E2), TMC_SW_DETAIL(E3), TMC_SW_DETAIL(E4), TMC_SW_DETAIL(E5), TMC_SW_DETAIL(E6), TMC_SW_DETAIL(E7) }; @@ -999,7 +1086,7 @@ void reset_trinamic_drivers() { SA_NO_TMC_SW_C(X); SA_NO_TMC_SW_C(X2); SA_NO_TMC_SW_C(Y); SA_NO_TMC_SW_C(Y2); SA_NO_TMC_SW_C(Z); SA_NO_TMC_SW_C(Z2); SA_NO_TMC_SW_C(Z3); SA_NO_TMC_SW_C(Z4); - SA_NO_TMC_SW_C(I); SA_NO_TMC_SW_C(J); SA_NO_TMC_SW_C(K); + SA_NO_TMC_SW_C(I); SA_NO_TMC_SW_C(J); SA_NO_TMC_SW_C(K); SA_NO_TMC_SW_C(U); SA_NO_TMC_SW_C(V); SA_NO_TMC_SW_C(W); SA_NO_TMC_SW_C(E0); SA_NO_TMC_SW_C(E1); SA_NO_TMC_SW_C(E2); SA_NO_TMC_SW_C(E3); SA_NO_TMC_SW_C(E4); SA_NO_TMC_SW_C(E5); SA_NO_TMC_SW_C(E6); SA_NO_TMC_SW_C(E7); #endif diff --git a/Marlin/src/module/stepper/trinamic.h b/Marlin/src/module/stepper/trinamic.h index dd3a64240f..95bab7652c 100644 --- a/Marlin/src/module/stepper/trinamic.h +++ b/Marlin/src/module/stepper/trinamic.h @@ -49,6 +49,9 @@ #define TMC_I_LABEL 'I', '0' #define TMC_J_LABEL 'J', '0' #define TMC_K_LABEL 'K', '0' +#define TMC_U_LABEL 'U', '0' +#define TMC_V_LABEL 'V', '0' +#define TMC_W_LABEL 'W', '0' #define TMC_X2_LABEL 'X', '2' #define TMC_Y2_LABEL 'Y', '2' @@ -92,6 +95,15 @@ #if HAS_K_AXIS && !defined(CHOPPER_TIMING_K) #define CHOPPER_TIMING_K CHOPPER_TIMING #endif +#if HAS_U_AXIS && !defined(CHOPPER_TIMING_U) + #define CHOPPER_TIMING_U CHOPPER_TIMING +#endif +#if HAS_V_AXIS && !defined(CHOPPER_TIMING_V) + #define CHOPPER_TIMING_V CHOPPER_TIMING +#endif +#if HAS_W_AXIS && !defined(CHOPPER_TIMING_W) + #define CHOPPER_TIMING_W CHOPPER_TIMING +#endif #if HAS_EXTRUDERS && !defined(CHOPPER_TIMING_E) #define CHOPPER_TIMING_E CHOPPER_TIMING #endif @@ -274,6 +286,48 @@ void reset_trinamic_drivers(); #endif #endif +// U Stepper +#if AXIS_IS_TMC(U) + extern TMC_CLASS(U, U) stepperU; + static constexpr chopper_timing_t chopper_timing_U = CHOPPER_TIMING_U; + #if ENABLED(SOFTWARE_DRIVER_ENABLE) + #define U_ENABLE_INIT() NOOP + #define U_ENABLE_WRITE(STATE) stepperU.toff((STATE)==U_ENABLE_ON ? chopper_timing_U.toff : 0) + #define U_ENABLE_READ() stepperU.isEnabled() + #endif + #if AXIS_HAS_SQUARE_WAVE(U) + #define U_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(U_STEP_PIN); }while(0) + #endif +#endif + +// V Stepper +#if AXIS_IS_TMC(V) + extern TMC_CLASS(V, V) stepperV; + static constexpr chopper_timing_t chopper_timing_V = CHOPPER_TIMING_V; + #if ENABLED(SOFTWARE_DRIVER_ENABLE) + #define V_ENABLE_INIT() NOOP + #define V_ENABLE_WRITE(STATE) stepperV.toff((STATE)==V_ENABLE_ON ? chopper_timing_V.toff : 0) + #define V_ENABLE_READ() stepperV.isEnabled() + #endif + #if AXIS_HAS_SQUARE_WAVE(V) + #define V_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(V_STEP_PIN); }while(0) + #endif +#endif + +// W Stepper +#if AXIS_IS_TMC(W) + extern TMC_CLASS(W, W) stepperW; + static constexpr chopper_timing_t chopper_timing_W = CHOPPER_TIMING_W; + #if ENABLED(SOFTWARE_DRIVER_ENABLE) + #define W_ENABLE_INIT() NOOP + #define W_ENABLE_WRITE(STATE) stepperW.toff((STATE)==W_ENABLE_ON ? chopper_timing_W.toff : 0) + #define W_ENABLE_READ() stepperW.isEnabled() + #endif + #if AXIS_HAS_SQUARE_WAVE(W) + #define W_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(W_STEP_PIN); }while(0) + #endif +#endif + // E0 Stepper #if AXIS_IS_TMC(E0) extern TMC_CLASS_E(0) stepperE0; diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 26815642db..8a62d00782 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -926,6 +926,16 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. if (ok) { IF_DISABLED(TOOLCHANGE_PARK_Y_ONLY, current_position.x = toolchange_settings.change_point.x); IF_DISABLED(TOOLCHANGE_PARK_X_ONLY, current_position.y = toolchange_settings.change_point.y); + #if NONE(TOOLCHANGE_PARK_X_ONLY, TOOLCHANGE_PARK_Y_ONLY) + SECONDARY_AXIS_CODE( + current_position.i = toolchange_settings.change_point.i, + current_position.j = toolchange_settings.change_point.j, + current_position.k = toolchange_settings.change_point.k, + current_position.u = toolchange_settings.change_point.u, + current_position.v = toolchange_settings.change_point.v, + current_position.w = toolchange_settings.change_point.w, + ); + #endif planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), active_extruder); planner.synchronize(); } @@ -1121,6 +1131,16 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (can_move_away && toolchange_settings.enable_park) { IF_DISABLED(TOOLCHANGE_PARK_Y_ONLY, current_position.x = toolchange_settings.change_point.x); IF_DISABLED(TOOLCHANGE_PARK_X_ONLY, current_position.y = toolchange_settings.change_point.y); + #if NONE(TOOLCHANGE_PARK_X_ONLY, TOOLCHANGE_PARK_Y_ONLY) + SECONDARY_AXIS_CODE( + current_position.i = toolchange_settings.change_point.i, + current_position.j = toolchange_settings.change_point.j, + current_position.k = toolchange_settings.change_point.k, + current_position.u = toolchange_settings.change_point.u, + current_position.v = toolchange_settings.change_point.v, + current_position.w = toolchange_settings.change_point.w, + ); + #endif planner.buffer_line(current_position, MMM_TO_MMS(TOOLCHANGE_PARK_XY_FEEDRATE), old_tool); planner.synchronize(); } @@ -1175,7 +1195,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { sync_plan_position(); #if ENABLED(DELTA) - //LOOP_LINEAR_AXES(i) update_software_endstops(i); // or modify the constrain function + //LOOP_NUM_AXES(i) update_software_endstops(i); // or modify the constrain function const bool safe_to_move = current_position.z < delta_clip_start_height - 1; #else constexpr bool safe_to_move = true; diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index bbdc0b6862..82ed0d6105 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -34,7 +34,7 @@ #endif #if ENABLED(TOOLCHANGE_PARK) bool enable_park; - xy_pos_t change_point; + xyz_pos_t change_point; #endif float z_raise; } toolchange_settings_t; diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index d7e84b9966..8969997e9a 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -1547,6 +1547,105 @@ #if PIN_EXISTS(K_STOP) REPORT_NAME_DIGITAL(__LINE__, K_STOP_PIN) #endif +#if PIN_EXISTS(U_ATT) + REPORT_NAME_DIGITAL(__LINE__, U_ATT_PIN) +#endif +#if PIN_EXISTS(U_CS) + REPORT_NAME_DIGITAL(__LINE__, U_CS_PIN) +#endif +#if PIN_EXISTS(U_DIR) + REPORT_NAME_DIGITAL(__LINE__, U_DIR_PIN) +#endif +#if PIN_EXISTS(U_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, U_ENABLE_PIN) +#endif +#if PIN_EXISTS(U_MAX) + REPORT_NAME_DIGITAL(__LINE__, U_MAX_PIN) +#endif +#if PIN_EXISTS(U_MIN) + REPORT_NAME_DIGITAL(__LINE__, U_MIN_PIN) +#endif +#if PIN_EXISTS(U_MS1) + REPORT_NAME_DIGITAL(__LINE__, U_MS1_PIN) +#endif +#if PIN_EXISTS(U_MS2) + REPORT_NAME_DIGITAL(__LINE__, U_MS2_PIN) +#endif +#if PIN_EXISTS(U_MS3) + REPORT_NAME_DIGITAL(__LINE__, U_MS3_PIN) +#endif +#if PIN_EXISTS(U_STEP) + REPORT_NAME_DIGITAL(__LINE__, U_STEP_PIN) +#endif +#if PIN_EXISTS(U_STOP) + REPORT_NAME_DIGITAL(__LINE__, U_STOP_PIN) +#endif +#if PIN_EXISTS(V_ATT) + REPORT_NAME_DIGITAL(__LINE__, V_ATT_PIN) +#endif +#if PIN_EXISTS(V_CS) + REPORT_NAME_DIGITAL(__LINE__, V_CS_PIN) +#endif +#if PIN_EXISTS(V_DIR) + REPORT_NAME_DIGITAL(__LINE__, V_DIR_PIN) +#endif +#if PIN_EXISTS(V_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, V_ENABLE_PIN) +#endif +#if PIN_EXISTS(V_MAX) + REPORT_NAME_DIGITAL(__LINE__, V_MAX_PIN) +#endif +#if PIN_EXISTS(V_MIN) + REPORT_NAME_DIGITAL(__LINE__, V_MIN_PIN) +#endif +#if PIN_EXISTS(V_MS1) + REPORT_NAME_DIGITAL(__LINE__, V_MS1_PIN) +#endif +#if PIN_EXISTS(V_MS2) + REPORT_NAME_DIGITAL(__LINE__, V_MS2_PIN) +#endif +#if PIN_EXISTS(V_MS3) + REPORT_NAME_DIGITAL(__LINE__, V_MS3_PIN) +#endif +#if PIN_EXISTS(V_STEP) + REPORT_NAME_DIGITAL(__LINE__, V_STEP_PIN) +#endif +#if PIN_EXISTS(V_STOP) + REPORT_NAME_DIGITAL(__LINE__, V_STOP_PIN) +#endif +#if PIN_EXISTS(W_ATT) + REPORT_NAME_DIGITAL(__LINE__, W_ATT_PIN) +#endif +#if PIN_EXISTS(W_CS) + REPORT_NAME_DIGITAL(__LINE__, W_CS_PIN) +#endif +#if PIN_EXISTS(W_DIR) + REPORT_NAME_DIGITAL(__LINE__, W_DIR_PIN) +#endif +#if PIN_EXISTS(W_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, W_ENABLE_PIN) +#endif +#if PIN_EXISTS(W_MAX) + REPORT_NAME_DIGITAL(__LINE__, W_MAX_PIN) +#endif +#if PIN_EXISTS(W_MIN) + REPORT_NAME_DIGITAL(__LINE__, W_MIN_PIN) +#endif +#if PIN_EXISTS(W_MS1) + REPORT_NAME_DIGITAL(__LINE__, W_MS1_PIN) +#endif +#if PIN_EXISTS(W_MS2) + REPORT_NAME_DIGITAL(__LINE__, W_MS2_PIN) +#endif +#if PIN_EXISTS(W_MS3) + REPORT_NAME_DIGITAL(__LINE__, W_MS3_PIN) +#endif +#if PIN_EXISTS(W_STEP) + REPORT_NAME_DIGITAL(__LINE__, W_STEP_PIN) +#endif +#if PIN_EXISTS(W_STOP) + REPORT_NAME_DIGITAL(__LINE__, W_STOP_PIN) +#endif #if PIN_EXISTS(ZRIB_V20_D6) REPORT_NAME_DIGITAL(__LINE__, ZRIB_V20_D6_PIN) #endif @@ -1619,6 +1718,24 @@ #if PIN_EXISTS(K_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(U_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, U_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(U_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, U_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(V_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, V_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(V_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, V_SERIAL_RX_PIN) +#endif +#if PIN_EXISTS(W_SERIAL_TX) + REPORT_NAME_DIGITAL(__LINE__, W_SERIAL_TX_PIN) +#endif +#if PIN_EXISTS(W_SERIAL_RX) + REPORT_NAME_DIGITAL(__LINE__, W_SERIAL_RX_PIN) +#endif #if PIN_EXISTS(E0_DIAG) REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) #endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index aabe0da858..8da2b969bc 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -221,6 +221,15 @@ #if !AXIS_HAS_SPI(K) #undef K_CS_PIN #endif +#if !AXIS_HAS_SPI(U) + #undef U_CS_PIN +#endif +#if !AXIS_HAS_SPI(V) + #undef V_CS_PIN +#endif +#if !AXIS_HAS_SPI(W) + #undef W_CS_PIN +#endif #if E_STEPPERS && !AXIS_HAS_SPI(E0) #undef E0_CS_PIN #endif @@ -264,6 +273,15 @@ #ifndef K_CS_PIN #define K_CS_PIN -1 #endif +#ifndef U_CS_PIN + #define U_CS_PIN -1 +#endif +#ifndef V_CS_PIN + #define V_CS_PIN -1 +#endif +#ifndef W_CS_PIN + #define W_CS_PIN -1 +#endif #ifndef E0_CS_PIN #define E0_CS_PIN -1 #endif @@ -546,6 +564,75 @@ #undef K_MAX_PIN #endif +#if HAS_U_AXIS + #ifdef U_STOP_PIN + #if U_HOME_TO_MIN + #define U_MIN_PIN U_STOP_PIN + #ifndef U_MAX_PIN + #define U_MAX_PIN -1 + #endif + #else + #define U_MAX_PIN U_STOP_PIN + #ifndef U_MIN_PIN + #define U_MIN_PIN -1 + #endif + #endif + #elif U_HOME_TO_MIN + #define U_STOP_PIN U_MIN_PIN + #else + #define U_STOP_PIN U_MAX_PIN + #endif +#else + #undef U_MIN_PIN + #undef U_MAX_PIN +#endif + +#if HAS_V_AXIS + #ifdef V_STOP_PIN + #if V_HOME_TO_MIN + #define V_MIN_PIN V_STOP_PIN + #ifndef V_MAX_PIN + #define V_MAX_PIN -1 + #endif + #else + #define V_MAX_PIN V_STOP_PIN + #ifndef V_MIN_PIN + #define V_MIN_PIN -1 + #endif + #endif + #elif V_HOME_TO_MIN + #define V_STOP_PIN V_MIN_PIN + #else + #define V_STOP_PIN V_MAX_PIN + #endif +#else + #undef V_MIN_PIN + #undef V_MAX_PIN +#endif + +#if HAS_W_AXIS + #ifdef W_STOP_PIN + #if W_HOME_TO_MIN + #define W_MIN_PIN W_STOP_PIN + #ifndef W_MAX_PIN + #define W_MAX_PIN -1 + #endif + #else + #define W_MAX_PIN W_STOP_PIN + #ifndef W_MIN_PIN + #define W_MIN_PIN -1 + #endif + #endif + #elif W_HOME_TO_MIN + #define W_STOP_PIN W_MIN_PIN + #else + #define W_STOP_PIN W_MAX_PIN + #endif +#else + #undef W_MIN_PIN + #undef W_MAX_PIN +#endif + // Filament Sensor first pin alias #if HAS_FILAMENT_SENSOR #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN // Filament Sensor first pin alias @@ -1204,6 +1291,12 @@ #define J_MS3_PIN -1 #endif +#if HAS_K_AXIS && !defined(K_DIAG_PIN) && !defined(K_STEP_PIN) && !PIN_EXISTS(K_CS_PIN) + #define U_E_INDEX INCREMENT(K_E_INDEX) +#else + #define U_E_INDEX K_E_INDEX +#endif + // The K axis, if any, should be the next open extruder port #if HAS_K_AXIS #ifndef K_STEP_PIN @@ -1284,6 +1377,258 @@ #define K_MS3_PIN -1 #endif +#if HAS_U_AXIS && !defined(U_DIAG_PIN) && !defined(U_STEP_PIN) && !PIN_EXISTS(U_CS_PIN) + #define V_E_INDEX INCREMENT(U_E_INDEX) +#else + #define V_E_INDEX U_E_INDEX +#endif + +// The U axis, if any, should be the next open extruder port +#if HAS_U_AXIS + #ifndef U_STEP_PIN + #define U_STEP_PIN _EPIN(U_E_INDEX, STEP) + #define U_DIR_PIN _EPIN(U_E_INDEX, DIR) + #define U_ENABLE_PIN _EPIN(U_E_INDEX, ENABLE) + #if M_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(U_STEP) + #error "No E stepper plug left for U!" + #else + #define AUTO_ASSIGNED_U_STEPPER 1 + #endif + #endif + #if AXIS_HAS_SPI(U) && !defined(U_CS_PIN) + #define U_CS_PIN _EPIN(U_E_INDEX, CS) + #if PIN_EXISTS(U_CS) + #define AUTO_ASSIGNED_U_CS 1 + #endif + #endif + #ifndef U_MS1_PIN + #define U_MS1_PIN _EPIN(U_E_INDEX, MS1) + #if PIN_EXISTS(U_MS1) + #define AUTO_ASSIGNED_U_MS1 1 + #endif + #endif + #ifndef U_MS2_PIN + #define U_MS2_PIN _EPIN(U_E_INDEX, MS2) + #if PIN_EXISTS(U_MS2) + #define AUTO_ASSIGNED_U_MS2 1 + #endif + #endif + #ifndef U_MS3_PIN + #define U_MS3_PIN _EPIN(U_E_INDEX, MS3) + #if PIN_EXISTS(U_MS3) + #define AUTO_ASSIGNED_U_MS3 1 + #endif + #endif + #if AXIS_HAS_UART(U) + #ifndef U_SERIAL_TX_PIN + #define U_SERIAL_TX_PIN _EPIN(U_E_INDEX, SERIAL_TX) + #endif + #ifndef U_SERIAL_RX_PIN + #define U_SERIAL_RX_PIN _EPIN(U_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(U_DIAG_PIN) && !defined(U_USE_ENDSTOP) && defined(U_STALL_SENSITIVITY) && _PEXI(U_E_INDEX, DIAG) + #define U_DIAG_PIN _EPIN(U_E_INDEX, DIAG) + #if DIAG_REMAPPED(U, X_MIN) + #define U_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(U, Y_MIN) + #define U_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(U, Z_MIN) + #define U_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(U, X_MAX) + #define U_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(U, Y_MAX) + #define U_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(U, Z_MAX) + #define U_USE_ENDSTOP _ZMAX_ + #else + #define U_USE_ENDSTOP _En_DIAG_(U_E_INDEX) + #endif + #define AUTO_ASSIGNED_U_DIAG 1 + #undef U_DIAG_PIN // Defined in Conditionals_post.h based on U_USE_ENDSTOP + #endif +#endif + +#ifndef U_CS_PIN + #define U_CS_PIN -1 +#endif +#ifndef U_MS1_PIN + #define U_MS1_PIN -1 +#endif +#ifndef U_MS2_PIN + #define U_MS2_PIN -1 +#endif +#ifndef U_MS3_PIN + #define U_MS3_PIN -1 +#endif + +#if HAS_V_AXIS && !defined(V_DIAG_PIN) && !defined(V_STEP_PIN) && !PIN_EXISTS(V_CS_PIN) + #define W_E_INDEX INCREMENT(V_E_INDEX) +#else + #define W_E_INDEX V_E_INDEX +#endif + +// The V axis, if any, should be the next open extruder port +#if HAS_V_AXIS + #ifndef V_STEP_PIN + #define V_STEP_PIN _EPIN(V_E_INDEX, STEP) + #define V_DIR_PIN _EPIN(V_E_INDEX, DIR) + #define V_ENABLE_PIN _EPIN(V_E_INDEX, ENABLE) + #if V_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(V_STEP) + #error "No E stepper plug left for V!" + #else + #define AUTO_ASSIGNED_V_STEPPER 1 + #endif + #endif + #if AXIS_HAS_SPI(V) && !defined(V_CS_PIN) + #define V_CS_PIN _EPIN(V_E_INDEX, CS) + #if PIN_EXISTS(V_CS) + #define AUTO_ASSIGNED_V_CS 1 + #endif + #endif + #ifndef V_MS1_PIN + #define V_MS1_PIN _EPIN(V_E_INDEX, MS1) + #if PIN_EXISTS(V_MS1) + #define AUTO_ASSIGNED_V_MS1 1 + #endif + #endif + #ifndef V_MS2_PIN + #define V_MS2_PIN _EPIN(V_E_INDEX, MS2) + #if PIN_EXISTS(V_MS2) + #define AUTO_ASSIGNED_V_MS2 1 + #endif + #endif + #ifndef V_MS3_PIN + #define V_MS3_PIN _EPIN(V_E_INDEX, MS3) + #if PIN_EXISTS(V_MS3) + #define AUTO_ASSIGNED_V_MS3 1 + #endif + #endif + #if AXIS_HAS_UART(V) + #ifndef V_SERIAL_TX_PIN + #define V_SERIAL_TX_PIN _EPIN(V_E_INDEX, SERIAL_TX) + #endif + #ifndef V_SERIAL_RX_PIN + #define V_SERIAL_RX_PIN _EPIN(V_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(V_DIAG_PIN) && !defined(V_USE_ENDSTOP) && defined(V_STALL_SENSITIVITY) && _PEXI(V_E_INDEX, DIAG) + #define V_DIAG_PIN _EPIN(V_E_INDEX, DIAG) + #if DIAG_REMAPPED(V, X_MIN) + #define V_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(V, Y_MIN) + #define V_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(V, Z_MIN) + #define V_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(V, X_MAX) + #define V_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(V, Y_MAX) + #define V_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(V, Z_MAX) + #define V_USE_ENDSTOP _ZMAX_ + #else + #define V_USE_ENDSTOP _En_DIAG_(V_E_INDEX) + #endif + #define AUTO_ASSIGNED_V_DIAG 1 + #undef V_DIAG_PIN // Defined in Conditionals_post.h based on O_USE_ENDSTOP + #endif +#endif + +#ifndef V_CS_PIN + #define V_CS_PIN -1 +#endif +#ifndef V_MS1_PIN + #define V_MS1_PIN -1 +#endif +#ifndef V_MS2_PIN + #define V_MS2_PIN -1 +#endif +#ifndef V_MS3_PIN + #define V_MS3_PIN -1 +#endif + +// The W axis, if any, should be the next open extruder port +#if HAS_W_AXIS + #ifndef W_STEP_PIN + #define W_STEP_PIN _EPIN(W_E_INDEX, STEP) + #define W_DIR_PIN _EPIN(W_E_INDEX, DIR) + #define W_ENABLE_PIN _EPIN(W_E_INDEX, ENABLE) + #if W_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(W_STEP) + #error "No E stepper plug left for W!" + #else + #define AUTO_ASSIGNED_W_STEPPER 1 + #endif + #endif + #if AXIS_HAS_SPI(W) && !defined(W_CS_PIN) + #define W_CS_PIN _EPIN(W_E_INDEX, CS) + #if PIN_EXISTS(W_CS) + #define AUTO_ASSIGNED_W_CS 1 + #endif + #endif + #ifndef W_MS1_PIN + #define W_MS1_PIN _EPIN(W_E_INDEX, MS1) + #if PIN_EXISTS(W_MS1) + #define AUTO_ASSIGNED_W_MS1 1 + #endif + #endif + #ifndef W_MS2_PIN + #define W_MS2_PIN _EPIN(W_E_INDEX, MS2) + #if PIN_EXISTS(W_MS2) + #define AUTO_ASSIGNED_W_MS2 1 + #endif + #endif + #ifndef W_MS3_PIN + #define W_MS3_PIN _EPIN(W_E_INDEX, MS3) + #if PIN_EXISTS(W_MS3) + #define AUTO_ASSIGNED_W_MS3 1 + #endif + #endif + #if AXIS_HAS_UART(W) + #ifndef W_SERIAL_TX_PIN + #define W_SERIAL_TX_PIN _EPIN(W_E_INDEX, SERIAL_TX) + #endif + #ifndef W_SERIAL_RX_PIN + #define W_SERIAL_RX_PIN _EPIN(W_E_INDEX, SERIAL_RX) + #endif + #endif + // Auto-assign pins for stallGuard sensorless homing + #if !defined(W_DIAG_PIN) && !defined(W_USE_ENDSTOP) && defined(W_STALL_SENSITIVITY) && _PEXI(W_E_INDEX, DIAG) + #define W_DIAG_PIN _EPIN(W_E_INDEX, DIAG) + #if DIAG_REMAPPED(W, X_MIN) + #define W_USE_ENDSTOP _XMIN_ + #elif DIAG_REMAPPED(W, Y_MIN) + #define W_USE_ENDSTOP _YMIN_ + #elif DIAG_REMAPPED(W, Z_MIN) + #define W_USE_ENDSTOP _ZMIN_ + #elif DIAG_REMAPPED(W, X_MAX) + #define W_USE_ENDSTOP _XMAX_ + #elif DIAG_REMAPPED(W, Y_MAX) + #define W_USE_ENDSTOP _YMAX_ + #elif DIAG_REMAPPED(W, Z_MAX) + #define W_USE_ENDSTOP _ZMAX_ + #else + #define W_USE_ENDSTOP _En_DIAG_(W_E_INDEX) + #endif + #define AUTO_ASSIGNED_W_DIAG 1 + #undef W_DIAG_PIN // Defined in Conditionals_post.h based on Q_USE_ENDSTOP + #endif +#endif + +#ifndef W_CS_PIN + #define W_CS_PIN -1 +#endif +#ifndef W_MS1_PIN + #define W_MS1_PIN -1 +#endif +#ifndef W_MS2_PIN + #define W_MS2_PIN -1 +#endif +#ifndef W_MS3_PIN + #define W_MS3_PIN -1 +#endif + // // Disable unused endstop / probe pins // @@ -1359,6 +1704,30 @@ #undef K_MAX_PIN #define K_MAX_PIN -1 #endif +#if DISABLED(USE_UMIN_PLUG) + #undef U_MIN_PIN + #define U_MIN_PIN -1 +#endif +#if DISABLED(USE_UMAX_PLUG) + #undef U_MAX_PIN + #define U_MAX_PIN -1 +#endif +#if DISABLED(USE_VMIN_PLUG) + #undef V_MIN_PIN + #define V_MIN_PIN -1 +#endif +#if DISABLED(USE_VMAX_PLUG) + #undef V_MAX_PIN + #define V_MAX_PIN -1 +#endif +#if DISABLED(USE_WMIN_PLUG) + #undef W_MIN_PIN + #define W_MIN_PIN -1 +#endif +#if DISABLED(USE_WMAX_PLUG) + #undef W_MAX_PIN + #define W_MAX_PIN -1 +#endif #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MAX #undef X2_MIN_PIN diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index f9911cc863..db6cb2353b 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -293,6 +293,126 @@ #endif +#if HAS_U_AXIS + #if PIN_EXISTS(U_MIN) + #define _U_MIN U_MIN_PIN, + #else + #define _U_MIN + #endif + #if PIN_EXISTS(U_MAX) + #define _U_MAX U_MAX_PIN, + #else + #define _U_MAX + #endif + #if PIN_EXISTS(U_CS) && AXIS_HAS_SPI(U) + #define _U_CS U_CS_PIN, + #else + #define _U_CS + #endif + #if PIN_EXISTS(U_MS1) + #define _U_MS1 U_MS1_PIN, + #else + #define _U_MS1 + #endif + #if PIN_EXISTS(U_MS2) + #define _U_MS2 U_MS2_PIN, + #else + #define _U_MS2 + #endif + #if PIN_EXISTS(U_MS3) + #define _U_MS3 U_MS3_PIN, + #else + #define _U_MS3 + #endif + + #define _U_PINS U_STEP_PIN, U_DIR_PIN, U_ENABLE_PIN, _U_MIN _U_MAX _U_MS1 _U_MS2 _U_MS3 _U_CS + +#else + + #define _U_PINS + +#endif + +#if HAS_V_AXIS + #if PIN_EXISTS(V_MIN) + #define _V_MIN V_MIN_PIN, + #else + #define _V_MIN + #endif + #if PIN_EXISTS(V_MAX) + #define _V_MAX V_MAX_PIN, + #else + #define _V_MAX + #endif + #if PIN_EXISTS(V_CS) && AXIS_HAS_SPI(V) + #define _V_CS V_CS_PIN, + #else + #define _V_CS + #endif + #if PIN_EXISTS(V_MS1) + #define _V_MS1 V_MS1_PIN, + #else + #define _V_MS1 + #endif + #if PIN_EXISTS(V_MS2) + #define _V_MS2 V_MS2_PIN, + #else + #define _V_MS2 + #endif + #if PIN_EXISTS(V_MS3) + #define _V_MS3 V_MS3_PIN, + #else + #define _V_MS3 + #endif + + #define _V_PINS V_STEP_PIN, V_DIR_PIN, V_ENABLE_PIN, _V_MIN _V_MAX _V_MS1 _V_MS2 _V_MS3 _V_CS + +#else + + #define _V_PINS + +#endif + +#if HAS_W_AXIS + #if PIN_EXISTS(W_MIN) + #define _W_MIN W_MIN_PIN, + #else + #define _W_MIN + #endif + #if PIN_EXISTS(W_MAX) + #define _W_MAX W_MAX_PIN, + #else + #define _W_MAX + #endif + #if PIN_EXISTS(W_CS) && AXIS_HAS_SPI(W) + #define _W_CS W_CS_PIN, + #else + #define _W_CS + #endif + #if PIN_EXISTS(W_MS1) + #define _W_MS1 W_MS1_PIN, + #else + #define _W_MS1 + #endif + #if PIN_EXISTS(W_MS2) + #define _W_MS2 W_MS2_PIN, + #else + #define _W_MS2 + #endif + #if PIN_EXISTS(W_MS3) + #define _W_MS3 W_MS3_PIN, + #else + #define _W_MS3 + #endif + + #define _W_PINS W_STEP_PIN, W_DIR_PIN, W_ENABLE_PIN, _W_MIN _W_MAX _W_MS1 _W_MS2 _W_MS3 _W_CS + +#else + + #define _W_PINS + +#endif + // // Extruder Chip Select, Digital Micro-steps // @@ -886,7 +1006,7 @@ #endif #define SENSITIVE_PINS \ - _X_PINS _Y_PINS _Z_PINS _I_PINS _J_PINS _K_PINS \ + _X_PINS _Y_PINS _Z_PINS _I_PINS _J_PINS _K_PINS _U_PINS _V_PINS _W_PINS \ _X2_PINS _Y2_PINS _Z2_PINS _Z3_PINS _Z4_PINS _Z_PROBE \ _E0_PINS _E1_PINS _E2_PINS _E3_PINS _E4_PINS _E5_PINS _E6_PINS _E7_PINS \ _H0_PINS _H1_PINS _H2_PINS _H3_PINS _H4_PINS _H5_PINS _H6_PINS _H7_PINS \ From 8fb65211fc3bd55db9aac2145d327aad3d5d547d Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 1 Apr 2022 06:01:01 +0000 Subject: [PATCH 197/203] [cron] Bump distribution date (2022-04-01) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 0e3ee06055..8f3a9a4f57 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-03-30" +//#define STRING_DISTRIBUTION_DATE "2022-04-01" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index aadb91dadf..b3072b560b 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-03-30" + #define STRING_DISTRIBUTION_DATE "2022-04-01" #endif /** From 72b2e2b2c7230245dea9fcb46b9b8a92bcb11bcc Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Fri, 1 Apr 2022 08:14:14 +0100 Subject: [PATCH 198/203] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20Temperature=20Mode?= =?UTF-8?q?l=20Predictive=20Control=20(#23751)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 48 ++- Marlin/src/HAL/ESP32/HAL.cpp | 26 +- Marlin/src/gcode/gcode.cpp | 4 + Marlin/src/gcode/gcode.h | 6 + Marlin/src/gcode/temp/M306.cpp | 86 +++++ Marlin/src/inc/SanityCheck.h | 20 ++ .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 2 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 2 +- Marlin/src/module/settings.cpp | 61 ++++ Marlin/src/module/temperature.cpp | 300 +++++++++++++++++- Marlin/src/module/temperature.h | 41 ++- ini/features.ini | 1 + platformio.ini | 1 + 13 files changed, 566 insertions(+), 32 deletions(-) create mode 100644 Marlin/src/gcode/temp/M306.cpp diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9237818c25..9d05901457 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -608,10 +608,12 @@ //=========================================================================== //============================= PID Settings ================================ //=========================================================================== -// PID Tuning Guide here: https://reprap.org/wiki/PID_Tuning -// Comment the following line to disable PID and enable bang-bang. -#define PIDTEMP +// Enable PIDTEMP for PID control or MPCTEMP for Predictive Model. +// temperature control. Disable both for bang-bang heating. +#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning +//#define MPCTEMP // ** EXPERIMENTAL ** + #define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current #define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current #define PID_K1 0.95 // Smoothing factor within any PID loop @@ -633,7 +635,45 @@ #define DEFAULT_Ki 1.08 #define DEFAULT_Kd 114.00 #endif -#endif // PIDTEMP +#endif + +/** + * Model Predictive Control for hotend + * + * Use a physical model of the hotend to control temperature. When configured correctly + * this gives better responsiveness and stability than PID and it also removes the need + * for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model. + */ +#if ENABLED(MPCTEMP) + #define MPC_MAX BANG_MAX // (0..255) Current to nozzle while MPC is active. + #define MPC_HEATER_POWER { 40.0f } // (W) Heat cartridge powers. + + #define MPC_INCLUDE_FAN // Model the fan speed? + + // Measured physical constants from M306 + #define MPC_BLOCK_HEAT_CAPACITY { 16.7f } // (J/K) Heat block heat capacities. + #define MPC_SENSOR_RESPONSIVENESS { 0.22f } // (K/s per ∆K) Rate of change of sensor temperature from heat block. + #define MPC_AMBIENT_XFER_COEFF { 0.068f } // (W/K) Heat transfer coefficients from heat block to room air with fan off. + #if ENABLED(MPC_INCLUDE_FAN) + #define MPC_AMBIENT_XFER_COEFF_FAN255 { 0.097f } // (W/K) Heat transfer coefficients from heat block to room air with fan on full. + #endif + + // For one fan and multiple hotends MPC needs to know how to apply the fan cooling effect. + #if ENABLED(MPC_INCLUDE_FAN) + //#define MPC_FAN_0_ALL_HOTENDS + //#define MPC_FAN_0_ACTIVE_HOTEND + #endif + + #define FILAMENT_HEAT_CAPACITY_PERMM 5.6e-3f // 0.0056 J/K/mm for 1.75mm PLA (0.0149 J/K/mm for 2.85mm PLA). + //#define FILAMENT_HEAT_CAPACITY_PERMM 3.6e-3f // 0.0036 J/K/mm for 1.75mm PETG (0.0094 J/K/mm for 2.85mm PETG). + + // Advanced options + #define MPC_SMOOTHING_FACTOR 0.5f // (0.0...1.0) Noisy temperature sensors may need a lower value for stabilization. + #define MPC_MIN_AMBIENT_CHANGE 1.0f // (K/s) Modeled ambient temperature rate of change, when correcting model inaccuracies. + #define MPC_STEADYSTATE 0.5f // (K/s) Temperature change rate for steady state logic to be enforced. + + #define MPC_TUNING_POS { X_CENTER, Y_CENTER, 1.0f } // (mm) M306 Autotuning position, ideally bed center just above the surface. +#endif //=========================================================================== //====================== PID > Bed Temperature Control ====================== diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 44be0b540a..e204e0b6fe 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -209,19 +209,19 @@ void MarlinHAL::adc_init() { adc1_config_width(ADC_WIDTH_12Bit); // Configure channels only if used as (re-)configuring a pin for ADC that is used elsewhere might have adverse effects - TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db)); - TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_PROBE, adc1_set_attenuation(get_channel(TEMP_PROBE_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_BOARD, adc1_set_attenuation(get_channel(TEMP_BOARD_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db)); + TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_PROBE, adc1_set_attenuation(get_channel(TEMP_PROBE_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_BOARD, adc1_set_attenuation(get_channel(TEMP_BOARD_PIN), ADC_ATTEN_11db)); TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db)); // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail. diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 9d225cef51..5c02cbb507 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -790,6 +790,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 305: M305(); break; // M305: Set user thermistor parameters #endif + #if ENABLED(MPCTEMP) + case 306: M306(); break; // M306: MPC autotune + #endif + #if ENABLED(REPETIER_GCODE_M360) case 360: M360(); break; // M360: Firmware settings #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 3ec27710b4..a4ce273e51 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -215,6 +215,7 @@ * M303 - PID relay autotune S sets the target temperature. Default 150C. (Requires PIDTEMP) * M304 - Set bed PID parameters P I and D. (Requires PIDTEMPBED) * M305 - Set user thermistor parameters R T and P. (Requires TEMP_SENSOR_x 1000) + * M306 - MPC autotune. (Requires MPCTEMP) * M309 - Set chamber PID parameters P I and D. (Requires PIDTEMPCHAMBER) * M350 - Set microstepping mode. (Requires digital microstepping pins.) * M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.) @@ -929,6 +930,11 @@ private: static void M305(); #endif + #if ENABLED(MPCTEMP) + static void M306(); + static void M306_report(const bool forReplay=true); + #endif + #if ENABLED(PIDTEMPCHAMBER) static void M309(); static void M309_report(const bool forReplay=true); diff --git a/Marlin/src/gcode/temp/M306.cpp b/Marlin/src/gcode/temp/M306.cpp new file mode 100644 index 0000000000..9e1a8dd8ef --- /dev/null +++ b/Marlin/src/gcode/temp/M306.cpp @@ -0,0 +1,86 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(MPCTEMP) + +#include "../gcode.h" +#include "../../module/temperature.h" + +/** + * M306: MPC settings and autotune + * + * T Autotune the active extruder. + * + * A Ambient heat transfer coefficient (no fan). + * C Block heat capacity. + * E Extruder number to set. (Default: E0) + * F Ambient heat transfer coefficient (fan on full). + * P Heater power. + * R Sensor responsiveness (= transfer coefficient / heat capcity). + */ + +void GcodeSuite::M306() { + if (parser.seen_test('T')) { thermalManager.MPC_autotune(); return; } + + if (parser.seen("ACFPR")) { + const heater_id_t hid = (heater_id_t)parser.intval('E', 0); + MPC_t &constants = thermalManager.temp_hotend[hid].constants; + if (parser.seenval('P')) constants.heater_power = parser.value_float(); + if (parser.seenval('C')) constants.block_heat_capacity = parser.value_float(); + if (parser.seenval('R')) constants.sensor_responsiveness = parser.value_float(); + if (parser.seenval('A')) constants.ambient_xfer_coeff_fan0 = parser.value_float(); + #if ENABLED(MPC_INCLUDE_FAN) + if (parser.seenval('F')) constants.fan255_adjustment = parser.value_float() - constants.ambient_xfer_coeff_fan0; + #endif + return; + } + + HOTEND_LOOP() { + SERIAL_ECHOLNPGM("MPC constants for hotend ", e); + MPC_t& constants = thermalManager.temp_hotend[e].constants; + SERIAL_ECHOLNPGM("Heater power: ", constants.heater_power); + SERIAL_ECHOLNPGM("Heatblock heat capacity: ", constants.block_heat_capacity); + SERIAL_ECHOLNPAIR_F("Sensor responsivness: ", constants.sensor_responsiveness, 4); + SERIAL_ECHOLNPAIR_F("Ambient heat transfer coeff. (no fan): ", constants.ambient_xfer_coeff_fan0, 4); + #if ENABLED(MPC_INCLUDE_FAN) + SERIAL_ECHOLNPAIR_F("Ambient heat transfer coeff. (full fan): ", constants.ambient_xfer_coeff_fan0 + constants.fan255_adjustment, 4); + #endif + } +} + +void GcodeSuite::M306_report(const bool forReplay/*=true*/) { + report_heading(forReplay, F("Model predictive control")); + HOTEND_LOOP() { + report_echo_start(forReplay); + MPC_t& constants = thermalManager.temp_hotend[e].constants; + SERIAL_ECHOPGM(" M306 E", e); + SERIAL_ECHOPAIR_F(" P", constants.heater_power, 2); + SERIAL_ECHOPAIR_F(" C", constants.block_heat_capacity, 2); + SERIAL_ECHOPAIR_F(" R", constants.sensor_responsiveness, 4); + SERIAL_ECHOPAIR_F(" A", constants.ambient_xfer_coeff_fan0, 4); + SERIAL_ECHOLNPAIR_F(" F", constants.ambient_xfer_coeff_fan0 + constants.fan255_adjustment, 4); + } +} + +#endif // MPCTEMP diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ec8b278b02..b4c97187e6 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1405,6 +1405,26 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You must set DISPLAY_CHARSET_HD44780 to JAPANESE, WESTERN or CYRILLIC for your LCD controller." #endif +/** + * Extruder temperature control algorithm - There can be only one! + */ +#if BOTH(PIDTEMP, MPCTEMP) + #error "Only enable PIDTEMP or MPCTEMP, but not both." +#endif + +#if ENABLED(MPC_INCLUDE_FAN) + #if FAN_COUNT < 1 + #error "MPC_INCLUDE_FAN requires at least one fan." + #endif + #if FAN_COUNT < HOTENDS + #if COUNT_ENABLED(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) > 1 + #error "Enable either MPC_FAN_0_ALL_HOTENDS or MPC_FAN_0_ACTIVE_HOTEND, not both." + #elif NONE(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) + #error "MPC_INCLUDE_FAN requires MPC_FAN_0_ALL_HOTENDS or MPC_FAN_0_ACTIVE_HOTEND for one fan with multiple hotends." + #endif + #endif +#endif + /** * Bed Heating Options - PID vs Limit Switching */ diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index fa85de2a8e..7561c89d79 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -85,7 +85,7 @@ void ChironTFT::Startup() { // opt_enable FIL_RUNOUT_PULLUP TFTSer.begin(115200); - // wait for the TFT panel to initialise and finish the animation + // Wait for the TFT panel to initialize and finish the animation safe_delay(1000); // There are different panels for the Chiron with slightly different commands diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 729d4547a8..c382af3fe2 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -85,7 +85,7 @@ void AnycubicTFTClass::OnSetup() { SENDLINE_DBG_PGM("J17", "TFT Serial Debug: Main board reset... J17"); // J17 Main board reset delay_ms(10); - // initialise the state of the key pins running on the tft + // Init the state of the key pins running on the TFT #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) SET_INPUT_PULLUP(SD_DETECT_PIN); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 2b2aae2633..fa0222119d 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -554,6 +554,13 @@ typedef struct SettingsDataStruct { uint8_t ui_language; // M414 S #endif + // + // Model predictive control + // + #if ENABLED(MPCTEMP) + MPC_t mpc_constants[HOTENDS]; // M306 + #endif + } SettingsData; //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); @@ -1581,6 +1588,14 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(ui.language); #endif + // + // Model predictive control + // + #if ENABLED(MPCTEMP) + HOTEND_LOOP() + EEPROM_WRITE(thermalManager.temp_hotend[e].constants); + #endif + // // Report final CRC and Data Size // @@ -2549,6 +2564,16 @@ void MarlinSettings::postprocess() { } #endif + // + // Model predictive control + // + #if ENABLED(MPCTEMP) + { + HOTEND_LOOP() + EEPROM_READ(thermalManager.temp_hotend[e].constants); + } + #endif + // // Validate Final Size and CRC // @@ -3267,6 +3292,37 @@ void MarlinSettings::reset() { #endif TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); + + // + // Model predictive control + // + #if ENABLED(MPCTEMP) + constexpr float _mpc_heater_power[] = MPC_HEATER_POWER; + constexpr float _mpc_block_heat_capacity[] = MPC_BLOCK_HEAT_CAPACITY; + constexpr float _mpc_sensor_responsiveness[] = MPC_SENSOR_RESPONSIVENESS; + constexpr float _mpc_ambient_xfer_coeff[] = MPC_AMBIENT_XFER_COEFF; + #if ENABLED(MPC_INCLUDE_FAN) + constexpr float _mpc_ambient_xfer_coeff_fan255[] = MPC_AMBIENT_XFER_COEFF_FAN255; + #endif + + static_assert(COUNT(_mpc_heater_power) == HOTENDS, "MPC_HEATER_POWER must have HOTENDS items."); + static_assert(COUNT(_mpc_block_heat_capacity) == HOTENDS, "MPC_BLOCK_HEAT_CAPACITY must have HOTENDS items."); + static_assert(COUNT(_mpc_sensor_responsiveness) == HOTENDS, "MPC_SENSOR_RESPONSIVENESS must have HOTENDS items."); + static_assert(COUNT(_mpc_ambient_xfer_coeff) == HOTENDS, "MPC_AMBIENT_XFER_COEFF must have HOTENDS items."); + #if ENABLED(MPC_INCLUDE_FAN) + static_assert(COUNT(_mpc_ambient_xfer_coeff_fan255) == HOTENDS, "MPC_AMBIENT_XFER_COEFF_FAN255 must have HOTENDS items."); + #endif + + HOTEND_LOOP() { + thermalManager.temp_hotend[e].constants.heater_power = _mpc_heater_power[e]; + thermalManager.temp_hotend[e].constants.block_heat_capacity = _mpc_block_heat_capacity[e]; + thermalManager.temp_hotend[e].constants.sensor_responsiveness = _mpc_sensor_responsiveness[e]; + thermalManager.temp_hotend[e].constants.ambient_xfer_coeff_fan0 = _mpc_ambient_xfer_coeff[e]; + #if ENABLED(MPC_INCLUDE_FAN) + thermalManager.temp_hotend[e].constants.fan255_adjustment = _mpc_ambient_xfer_coeff_fan255[e] - _mpc_ambient_xfer_coeff[e]; + #endif + } + #endif } #if DISABLED(DISABLE_M503) @@ -3543,6 +3599,11 @@ void MarlinSettings::reset() { #endif TERN_(HAS_MULTI_LANGUAGE, gcode.M414_report(forReplay)); + + // + // Model predictive control + // + TERN_(MPCTEMP, gcode.M306_report(forReplay)); } #endif // !DISABLE_M503 diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 6660d9a8f8..4bd43705ad 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -141,7 +141,8 @@ #endif #endif -#if ENABLED(PID_EXTRUSION_SCALING) +#if EITHER(MPCTEMP, PID_EXTRUSION_SCALING) + #include #include "stepper.h" #endif @@ -503,10 +504,14 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); volatile bool Temperature::raw_temps_ready = false; #if ENABLED(PID_EXTRUSION_SCALING) - int32_t Temperature::last_e_position, Temperature::lpq[LPQ_MAX_LEN]; + int32_t Temperature::pes_e_position, Temperature::lpq[LPQ_MAX_LEN]; lpq_ptr_t Temperature::lpq_ptr = 0; #endif +#if ENABLED(MPCTEMP) + int32_t Temperature::mpc_e_position; // = 0 +#endif + #define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1) #define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) @@ -581,8 +586,8 @@ volatile bool Temperature::raw_temps_ready = false; PID_t tune_pid = { 0, 0, 0 }; celsius_float_t maxT = 0, minT = 10000; - const bool isbed = (heater_id == H_BED); - const bool ischamber = (heater_id == H_CHAMBER); + const bool isbed = (heater_id == H_BED), + ischamber = (heater_id == H_CHAMBER); #if ENABLED(PIDTEMPCHAMBER) #define C_TERN(T,A,B) ((T) ? (A) : (B)) @@ -840,6 +845,198 @@ volatile bool Temperature::raw_temps_ready = false; #endif // HAS_PID_HEATING +#if ENABLED(MPCTEMP) + + void Temperature::MPC_autotune() { + auto housekeeping = [] (millis_t& ms, celsius_float_t& current_temp, millis_t& next_report_ms) { + ms = millis(); + + if (updateTemperaturesIfReady()) { // temp sample ready + current_temp = degHotend(active_extruder); + TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); + } + + if (ELAPSED(ms, next_report_ms)) { + next_report_ms += 1000UL; + SERIAL_ECHOLNPGM("Temperature ", current_temp); + } + + hal.idletask(); + }; + + SERIAL_ECHOLNPGM("Measuring MPC constants for E", active_extruder); + MPCHeaterInfo& hotend = temp_hotend[active_extruder]; + MPC_t& constants = hotend.constants; + + // move to center of bed, just above bed height and cool with max fan + SERIAL_ECHOLNPGM("Moving to tuning position"); + TERN_(HAS_FAN, zero_fan_speeds()); + disable_all_heaters(); + TERN_(HAS_FAN, set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255)); + TERN_(HAS_FAN, planner.sync_fan_speeds(fan_speed)); + gcode.home_all_axes(true); + const xyz_pos_t tuningpos = MPC_TUNING_POS; + do_blocking_move_to(tuningpos); + + SERIAL_ECHOLNPGM("Cooling to ambient"); + millis_t ms = millis(), next_report_ms = ms, next_test_ms = ms + 10000UL; + celsius_float_t current_temp = degHotend(active_extruder), + ambient_temp = current_temp; + + wait_for_heatup = true; // Can be interrupted with M108 + while (wait_for_heatup) { + housekeeping(ms, current_temp, next_report_ms); + + if (ELAPSED(ms, next_test_ms)) { + if (current_temp >= ambient_temp) { + ambient_temp = (ambient_temp + current_temp) / 2.0f; + break; + } + ambient_temp = current_temp; + next_test_ms += 10000UL; + } + } + TERN_(HAS_FAN, set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0)); + TERN_(HAS_FAN, planner.sync_fan_speeds(fan_speed)); + + hotend.modeled_ambient_temp = ambient_temp; + + SERIAL_ECHOLNPGM("Heating to 200C"); + hotend.soft_pwm_amount = MPC_MAX >> 1; + const millis_t heat_start_time = ms; + next_test_ms = ms; + celsius_float_t temp_samples[16]; + uint8_t sample_count = 0; + uint16_t sample_distance = 1; + float t1_time = 0; + + while (wait_for_heatup) { + housekeeping(ms, current_temp, next_report_ms); + + if (ELAPSED(ms, next_test_ms)) { + // record samples between 100C and 200C + if (current_temp >= 100.0f) { + // if there are too many samples, space them more widely + if (sample_count == COUNT(temp_samples)) { + for (uint8_t i = 0; i < COUNT(temp_samples) / 2; i++) + temp_samples[i] = temp_samples[i*2]; + sample_count /= 2; + sample_distance *= 2; + } + + if (sample_count == 0) t1_time = float(ms - heat_start_time) / 1000.0f; + temp_samples[sample_count++] = current_temp; + } + + if (current_temp >= 200.0f) break; + + next_test_ms += 1000UL * sample_distance; + } + } + hotend.soft_pwm_amount = 0; + + // calculate physical constants from three equally spaced samples + sample_count = (sample_count + 1) / 2 * 2 - 1; + const float t1 = temp_samples[0], + t2 = temp_samples[(sample_count - 1) >> 1], + t3 = temp_samples[sample_count - 1], + asymp_temp = (t2 * t2 - t1 * t3) / (2 * t2 - t1 - t3), + block_responsiveness = -log((t2 - asymp_temp) / (t1 - asymp_temp)) / (sample_distance * (sample_count >> 1)); + + constants.ambient_xfer_coeff_fan0 = constants.heater_power * MPC_MAX / 255 / (asymp_temp - ambient_temp); + constants.fan255_adjustment = 0.0f; + constants.block_heat_capacity = constants.ambient_xfer_coeff_fan0 / block_responsiveness; + constants.sensor_responsiveness = block_responsiveness / (1.0f - (ambient_temp - asymp_temp) * exp(-block_responsiveness * t1_time) / (t1 - asymp_temp)); + + hotend.modeled_block_temp = asymp_temp + (ambient_temp - asymp_temp) * exp(-block_responsiveness * (ms - heat_start_time) / 1000.0f); + hotend.modeled_sensor_temp = current_temp; + + // let the system stabilise under MPC control then get a better measure of ambient loss without and with fan + SERIAL_ECHOLNPGM("Measuring ambient heatloss at target ", hotend.modeled_block_temp); + hotend.target = hotend.modeled_block_temp; + next_test_ms = ms + MPC_dT * 1000; + constexpr millis_t settle_time = 20000UL, + test_length = 20000UL; + millis_t settle_end_ms = ms + settle_time, + test_end_ms = settle_end_ms + test_length; + float total_energy_fan0 = 0.0f; + #if HAS_FAN + bool fan0_done = false; + float total_energy_fan255 = 0.0f; + #endif + float last_temp = current_temp; + + while (wait_for_heatup) { + housekeeping(ms, current_temp, next_report_ms); + + if (ELAPSED(ms, next_test_ms)) { + // use MPC to control the temperature, let it settle for 30s and then track power output for 10s + hotend.soft_pwm_amount = (int)get_pid_output_hotend(active_extruder) >> 1; + + if (ELAPSED(ms, settle_end_ms) && !ELAPSED(ms, test_end_ms) && TERN1(HAS_FAN, !fan0_done)) + total_energy_fan0 += constants.heater_power * hotend.soft_pwm_amount / 127 * MPC_dT + (last_temp - current_temp) * constants.block_heat_capacity; + #if HAS_FAN + else if (ELAPSED(ms, test_end_ms) && !fan0_done) { + SERIAL_ECHOLNPGM("Measuring ambient heatloss with full fan"); + set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); + planner.sync_fan_speeds(fan_speed); + settle_end_ms = ms + settle_time; + test_end_ms = settle_end_ms + test_length; + fan0_done = true; + } + else if (ELAPSED(ms, settle_end_ms) && !ELAPSED(ms, test_end_ms)) + total_energy_fan255 += constants.heater_power * hotend.soft_pwm_amount / 127 * MPC_dT + (last_temp - current_temp) * constants.block_heat_capacity; + #endif + else if (ELAPSED(ms, test_end_ms)) break; + + last_temp = current_temp; + next_test_ms += MPC_dT * 1000; + } + + if (!WITHIN(current_temp, hotend.target - 15.0f, hotend.target + 15.0f)) { + SERIAL_ECHOLNPGM("Temperature error while measuring ambient loss"); + break; + } + } + + const float power_fan0 = total_energy_fan0 * 1000 / test_length; + constants.ambient_xfer_coeff_fan0 = power_fan0 / (hotend.target - ambient_temp); + + #if HAS_FAN + const float power_fan255 = total_energy_fan255 * 1000 / test_length, + ambient_xfer_coeff_fan255 = power_fan255 / (hotend.target - ambient_temp); + constants.fan255_adjustment = ambient_xfer_coeff_fan255 - constants.ambient_xfer_coeff_fan0; + #endif + + hotend.target = 0.0f; + hotend.soft_pwm_amount = 0; + TERN_(HAS_FAN, set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0)); + TERN_(HAS_FAN, planner.sync_fan_speeds(fan_speed)); + + if (!wait_for_heatup) SERIAL_ECHOLNPGM("Test was interrupted"); + + wait_for_heatup = false; + + SERIAL_ECHOLNPGM("Done"); + + /* <-- add a slash to enable + SERIAL_ECHOLNPGM("t1_time ", t1_time); + SERIAL_ECHOLNPGM("sample_count ", sample_count); + SERIAL_ECHOLNPGM("sample_distance ", sample_distance); + for (uint8_t i = 0; i < sample_count; i++) + SERIAL_ECHOLNPGM("sample ", i, " : ", temp_samples[i]); + SERIAL_ECHOLNPGM("t1 ", t1, " t2 ", t2, " t3 ", t3); + SERIAL_ECHOLNPGM("asymp_temp ", asymp_temp); + SERIAL_ECHOLNPAIR_F("block_responsiveness ", block_responsiveness, 4); + //*/ + SERIAL_ECHOLNPGM("MPC_BLOCK_HEAT_CAPACITY ", constants.block_heat_capacity); + SERIAL_ECHOLNPAIR_F("MPC_SENSOR_RESPONSIVENESS ", constants.sensor_responsiveness, 4); + SERIAL_ECHOLNPAIR_F("MPC_AMBIENT_XFER_COEFF ", constants.ambient_xfer_coeff_fan0, 4); + TERN_(HAS_FAN, SERIAL_ECHOLNPAIR_F("MPC_AMBIENT_XFER_COEFF_FAN255 ", ambient_xfer_coeff_fan255, 4)); + } + +#endif // MPCTEMP + int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { switch (heater_id) { #if HAS_HEATED_BED @@ -1099,7 +1296,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { pid_reset[ee] = true; } else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = BANG_MAX; + pid_output = PID_MAX; pid_reset[ee] = true; } else { @@ -1126,9 +1323,9 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { work_pid[ee].Kc = 0; if (this_hotend) { const long e_position = stepper.position(E_AXIS); - if (e_position > last_e_position) { - lpq[lpq_ptr] = e_position - last_e_position; - last_e_position = e_position; + if (e_position > pes_e_position) { + lpq[lpq_ptr] = e_position - pes_e_position; + pes_e_position = e_position; } else lpq[lpq_ptr] = 0; @@ -1171,7 +1368,86 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { } #endif - #else // No PID enabled + #elif ENABLED(MPCTEMP) + MPCHeaterInfo& hotend = temp_hotend[ee]; + MPC_t& constants = hotend.constants; + + // At startup, initialize modeled temperatures + if (isnan(hotend.modeled_block_temp)) { + hotend.modeled_ambient_temp = min(30.0f, hotend.celsius); // cap initial value at reasonable max room temperature of 30C + hotend.modeled_block_temp = hotend.modeled_sensor_temp = hotend.celsius; + } + + #if HOTENDS == 1 + constexpr bool this_hotend = true; + #else + const bool this_hotend = (ee == active_extruder); + #endif + + float ambient_xfer_coeff = constants.ambient_xfer_coeff_fan0; + #if ENABLED(MPC_INCLUDE_FAN) + const uint8_t fan_index = ANY(MPC_FAN_0_ACTIVE_HOTEND, MPC_FAN_0_ALL_HOTENDS) ? 0 : ee; + const float fan_fraction = TERN_(MPC_FAN_0_ACTIVE_HOTEND, !this_hotend ? 0.0f : ) fan_speed[fan_index] * RECIPROCAL(255); + ambient_xfer_coeff += fan_fraction * constants.fan255_adjustment; + #endif + + if (this_hotend) { + const int32_t e_position = stepper.position(E_AXIS); + const float e_speed = (e_position - mpc_e_position) * planner.mm_per_step[E_AXIS] / MPC_dT; + + // the position can appear to make big jumps when, e.g. homing + if (fabs(e_speed) > planner.settings.max_feedrate_mm_s[E_AXIS]) + mpc_e_position = e_position; + else if (e_speed > 0.0f) { // ignore retract/recover moves + ambient_xfer_coeff += e_speed * FILAMENT_HEAT_CAPACITY_PERMM; + mpc_e_position = e_position; + } + } + + // update the modeled temperatures + float blocktempdelta = hotend.soft_pwm_amount * constants.heater_power * (MPC_dT / 127) / constants.block_heat_capacity; + blocktempdelta += (hotend.modeled_ambient_temp - hotend.modeled_block_temp) * ambient_xfer_coeff * MPC_dT / constants.block_heat_capacity; + hotend.modeled_block_temp += blocktempdelta; + + const float sensortempdelta = (hotend.modeled_block_temp - hotend.modeled_sensor_temp) * (constants.sensor_responsiveness * MPC_dT); + hotend.modeled_sensor_temp += sensortempdelta; + + // Any delta between hotend.modeled_sensor_temp and hotend.celsius is either model + // error diverging slowly or (fast) noise. Slowly correct towards this temperature and noise will average out. + const float delta_to_apply = (hotend.celsius - hotend.modeled_sensor_temp) * (MPC_SMOOTHING_FACTOR); + hotend.modeled_block_temp += delta_to_apply; + hotend.modeled_sensor_temp += delta_to_apply; + + // only correct ambient when close to steady state (output power is not clipped or asymptotic temperature is reached) + if (WITHIN(hotend.soft_pwm_amount, 1, 126) || fabs(blocktempdelta + delta_to_apply) < (MPC_STEADYSTATE * MPC_dT)) + hotend.modeled_ambient_temp += delta_to_apply > 0.f ? max(delta_to_apply, MPC_MIN_AMBIENT_CHANGE * MPC_dT) : min(delta_to_apply, -MPC_MIN_AMBIENT_CHANGE * MPC_dT); + + float power = 0.0; + if (hotend.target != 0 && TERN1(HEATER_IDLE_HANDLER, !heater_idle[ee].timed_out)) { + // plan power level to get to target temperature in 2 seconds + power = (hotend.target - hotend.modeled_block_temp) * constants.block_heat_capacity / 2.0f; + power -= (hotend.modeled_ambient_temp - hotend.modeled_block_temp) * ambient_xfer_coeff; + } + + float pid_output = power * 254.0f / constants.heater_power + 1.0f; // ensure correct quantization into a range of 0 to 127 + pid_output = constrain(pid_output, 0, MPC_MAX); + + /* <-- add a slash to enable + static uint32_t nexttime = millis() + 1000; + if (ELAPSED(millis(), nexttime)) { + nexttime += 1000; + SERIAL_ECHOLNPGM("block temp ", hotend.modeled_block_temp, + ", celsius ", hotend.celsius, + ", blocktempdelta ", blocktempdelta, + ", delta_to_apply ", delta_to_apply, + ", ambient ", hotend.modeled_ambient_temp, + ", power ", power, + ", pid_output ", pid_output, + ", pwm ", (int)pid_output >> 1); + } + //*/ + + #else // No PID or MPC enabled const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); const float pid_output = (!is_idling && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0; @@ -2176,7 +2452,7 @@ void Temperature::init() { TERN_(PROBING_HEATERS_OFF, paused_for_probing = false); #if BOTH(PIDTEMP, PID_EXTRUSION_SCALING) - last_e_position = 0; + pes_e_position = 0; #endif // Init (and disable) SPI thermocouples @@ -2246,6 +2522,10 @@ void Temperature::init() { )); #endif + #if ENABLED(MPCTEMP) + HOTEND_LOOP() temp_hotend[e].modeled_block_temp = NAN; + #endif + #if HAS_HEATER_0 #ifdef BOARD_OPENDRAIN_MOSFETS OUT_WRITE_OD(HEATER_0_PIN, HEATER_0_INVERTING); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index a4681ba02b..aa80bd0a23 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -94,6 +94,18 @@ hotend_pid_t; #define _PID_Kf(H) 0 #endif +#if ENABLED(MPCTEMP) + typedef struct { + float heater_power; // M306 P + float block_heat_capacity; // M306 C + float sensor_responsiveness; // M306 R + float ambient_xfer_coeff_fan0; // M306 A + #if ENABLED(MPC_INCLUDE_FAN) + float fan255_adjustment; // M306 F + #endif + } MPC_t; +#endif + /** * States for ADC reading in the ISR */ @@ -177,7 +189,7 @@ enum ADCSensorState : char { #if HAS_PID_HEATING #define PID_K2 (1-float(PID_K1)) - #define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / TEMP_TIMER_FREQUENCY) + #define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (TEMP_TIMER_FREQUENCY)) // Apply the scale factors to the PID values #define scalePID_i(i) ( float(i) * PID_dT ) @@ -186,6 +198,10 @@ enum ADCSensorState : char { #define unscalePID_d(d) ( float(d) * PID_dT ) #endif +#if ENABLED(MPCTEMP) + #define MPC_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (TEMP_TIMER_FREQUENCY)) +#endif + #if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) #define G26_CLICK_CAN_CANCEL 1 #endif @@ -223,8 +239,19 @@ struct PIDHeaterInfo : public HeaterInfo { T pid; // Initialized by settings.load() }; +#if ENABLED(MPCTEMP) + struct MPCHeaterInfo : public HeaterInfo { + MPC_t constants; + float modeled_ambient_temp, + modeled_block_temp, + modeled_sensor_temp; + }; +#endif + #if ENABLED(PIDTEMP) typedef struct PIDHeaterInfo hotend_info_t; +#elif ENABLED(MPCTEMP) + typedef struct MPCHeaterInfo hotend_info_t; #else typedef heater_info_t hotend_info_t; #endif @@ -481,10 +508,14 @@ class Temperature { #endif #if ENABLED(PID_EXTRUSION_SCALING) - static int32_t last_e_position, lpq[LPQ_MAX_LEN]; + static int32_t pes_e_position, lpq[LPQ_MAX_LEN]; static lpq_ptr_t lpq_ptr; #endif + #if ENABLED(MPCTEMP) + static int32_t mpc_e_position; + #endif + #if HAS_HOTEND static temp_range_t temp_range[HOTENDS]; #endif @@ -924,12 +955,16 @@ class Temperature { */ #if ENABLED(PIDTEMP) static void updatePID() { - TERN_(PID_EXTRUSION_SCALING, last_e_position = 0); + TERN_(PID_EXTRUSION_SCALING, pes_e_position = 0); } #endif #endif + #if ENABLED(MPCTEMP) + void MPC_autotune(); + #endif + #if ENABLED(PROBING_HEATERS_OFF) static void pause_heaters(const bool p); #endif diff --git a/ini/features.ini b/ini/features.ini index a153b18530..fac9cf9b57 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -218,6 +218,7 @@ HAS_EXTRUDERS = src_filter=+ HAS_COOLER = src_filter=+ AUTO_REPORT_TEMPERATURES = src_filter=+ +MPCTEMP = src_filter=+ INCH_MODE_SUPPORT = src_filter=+ TEMPERATURE_UNITS_SUPPORT = src_filter=+ NEED_HEX_PRINT = src_filter=+ diff --git a/platformio.ini b/platformio.ini index 952912b21d..79ef54bd47 100644 --- a/platformio.ini +++ b/platformio.ini @@ -239,6 +239,7 @@ default_src_filter = + - - + - - - + - - - - From 0c366d35742b9a64e551f608c56bebaa4e4998a5 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 1 Apr 2022 21:01:34 +1300 Subject: [PATCH 199/203] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20E3V2=20Marli?= =?UTF-8?q?nUI=20draw=20flags=20(#23979)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lcd/e3v2/marlinui/ui_status_480x272.cpp | 113 ++++++++++-------- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index c2948048c1..822b73a44c 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -193,11 +193,11 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #define HOTEND_STATS 3 #elif HOTENDS > 1 #define HOTEND_STATS 2 - #elif HAS_HOTEND + #else #define HOTEND_STATS 1 #endif static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500), - old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500); + old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500); static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false); #endif @@ -211,24 +211,23 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #if HAS_HOTEND && HAS_HEATED_BED const bool isBed = heater < 0; - const float tc = isBed ? thermalManager.degBed() : thermalManager.degHotend(heater), - tt = isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater); - const bool ta = isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater); - - bool c_draw = tc != (isBed ? old_bed_temp : old_temp[heater]), - t_draw = tt != (isBed ? old_bed_target : old_target[heater]), - i_draw = ta != (isBed ? old_bed_on : old_on[heater]); - + bool c_draw, t_draw, i_draw; if (isBed) { - #if HAS_LEVELING - if (!i_draw && planner.leveling_active != old_leveling_on) i_draw = true; - old_leveling_on = planner.leveling_active; - #endif + const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); + const bool ta = thermalManager.isHeatingBed(); + c_draw = tc != old_bed_temp; + t_draw = tt != old_bed_target; + i_draw = ta != old_bed_on; old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; } else { + const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); + const bool ta = thermalManager.isHeatingHotend(heater); + c_draw = tc != old_temp[heater]; + t_draw = tt != old_target[heater]; + i_draw = ta != old_on[heater]; old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; @@ -237,31 +236,41 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x constexpr bool isBed = false; const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); const uint8_t ta = thermalManager.isHeatingHotend(heater); - const bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on; + bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; #elif HAS_HEATED_BED constexpr bool isBed = true; const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); const uint8_t ta = thermalManager.isHeatingBed(); - bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; - #if HAS_LEVELING - if (!idraw && planner.leveling_active != old_leveling_on) i_draw = true; - old_leveling_on = tl; - #endif + bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on; old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; + #else + bool c_draw = false, t_draw = false, i_draw = false; + constexpr float tc = 0, tt = 0; + constexpr uint8_t ta = 0; #endif + #if HAS_HEATED_BED && HAS_LEVELING + if (isBed) { + i_draw |= (planner.leveling_active != old_leveling_on); + old_leveling_on = planner.leveling_active; + } + #endif + + // Draw target temperature, if needed if (!ui.did_first_redraw || t_draw) { dwin_string.set(i16tostr3rj(tt + 0.5)); dwin_string.add(LCD_STR_DEGREE); DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y, S(dwin_string.string())); } - if (!ui.did_first_redraw || i_draw){ + // Draw heater icon with on / off / leveled states + if (!ui.did_first_redraw || i_draw) { const uint8_t ico = isBed ? (TERN0(HAS_LEVELING, planner.leveling_active) ? ICON_BedLevelOff : ICON_BedOff) : ICON_HotendOff; DWIN_ICON_Show(ICON, ico + ta, x, y + STATUS_CHR_HEIGHT + 2); } + // Draw current temperature, if needed if (!ui.did_first_redraw || c_draw) { dwin_string.set(i16tostr3rj(tc + 0.5)); dwin_string.add(LCD_STR_DEGREE); @@ -412,43 +421,45 @@ void MarlinUI::draw_status_screen() { // // Progress Bar // - constexpr int16_t pb_margin = 5, - pb_left = pb_margin + TERN(DWIN_MARLINUI_PORTRAIT, 0, 90), - pb_height = TERN(DWIN_MARLINUI_PORTRAIT, 60, 20), - pb_right = LCD_PIXEL_WIDTH - pb_margin, - pb_bottom = TERN(DWIN_MARLINUI_PORTRAIT, 410, 220), - pb_top = pb_bottom - pb_height, - pb_width = pb_right - pb_left; + #if HAS_PRINT_PROGRESS + constexpr int16_t pb_margin = 5, + pb_left = pb_margin + TERN(DWIN_MARLINUI_PORTRAIT, 0, 90), + pb_height = TERN(DWIN_MARLINUI_PORTRAIT, 60, 20), + pb_right = LCD_PIXEL_WIDTH - pb_margin, + pb_bottom = TERN(DWIN_MARLINUI_PORTRAIT, 410, 220), + pb_top = pb_bottom - pb_height, + pb_width = pb_right - pb_left; - const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); + const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); - if (!ui.did_first_redraw) - DWIN_Draw_Rectangle(0, Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline + if (!ui.did_first_redraw) + DWIN_Draw_Rectangle(0, Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline - static uint16_t old_solid = 50; - const uint16_t pb_solid = (pb_width - 2) * (progress / (PROGRESS_SCALE)) * 0.01f; - const bool p_draw = !ui.did_first_redraw || old_solid != pb_solid; + static uint16_t old_solid = 50; + const uint16_t pb_solid = (pb_width - 2) * (progress / (PROGRESS_SCALE)) * 0.01f; + const bool p_draw = !ui.did_first_redraw || old_solid != pb_solid; - if (p_draw) { - //if (pb_solid) - DWIN_Draw_Rectangle(1, Select_Color, pb_left + 1, pb_top + 1, pb_left + pb_solid, pb_bottom - 1); // Fill the solid part + if (p_draw) { + //if (pb_solid) + DWIN_Draw_Rectangle(1, Select_Color, pb_left + 1, pb_top + 1, pb_left + pb_solid, pb_bottom - 1); // Fill the solid part - //if (pb_solid < old_solid) - DWIN_Draw_Rectangle(1, Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1, pb_right - 1, pb_bottom - 1); // Erase the rest + //if (pb_solid < old_solid) + DWIN_Draw_Rectangle(1, Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1, pb_right - 1, pb_bottom - 1); // Erase the rest - #if ENABLED(SHOW_SD_PERCENT) - dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); - dwin_string.add(PSTR("%")); - DWIN_Draw_String( - false, font16x32, Percent_Color, Color_Bg_Black, - pb_left + (pb_width - dwin_string.length() * 16) / 2, - pb_top + (pb_height - 32) / 2, - S(dwin_string.string()) - ); - #endif + #if ENABLED(SHOW_SD_PERCENT) + dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); + dwin_string.add(PSTR("%")); + DWIN_Draw_String( + false, font16x32, Percent_Color, Color_Bg_Black, + pb_left + (pb_width - dwin_string.length() * 16) / 2, + pb_top + (pb_height - 32) / 2, + S(dwin_string.string()) + ); + #endif - old_solid = pb_solid; - } + old_solid = pb_solid; + } + #endif // HAS_PRINT_PROGRESS // // Status Message From 931e24311686a0d4637985f376e9c45a17414d68 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 1 Apr 2022 04:57:41 -0500 Subject: [PATCH 200/203] Draw flags followup --- Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 822b73a44c..2a4909d921 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -210,11 +210,13 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #endif #if HAS_HOTEND && HAS_HEATED_BED + float tc, tt; + bool c_draw, t_draw, i_draw, ta; const bool isBed = heater < 0; - bool c_draw, t_draw, i_draw; if (isBed) { - const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); - const bool ta = thermalManager.isHeatingBed(); + tc = thermalManager.degBed(); + tt = thermalManager.degTargetBed(); + ta = thermalManager.isHeatingBed(); c_draw = tc != old_bed_temp; t_draw = tt != old_bed_target; i_draw = ta != old_bed_on; @@ -223,8 +225,9 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x old_bed_on = ta; } else { - const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); - const bool ta = thermalManager.isHeatingHotend(heater); + tc = thermalManager.degHotend(heater); + tt = thermalManager.degTargetHotend(heater); + ta = thermalManager.isHeatingHotend(heater); c_draw = tc != old_temp[heater]; t_draw = tt != old_target[heater]; i_draw = ta != old_on[heater]; From d98c61cafba1df39316f90af21b99d6c7183f58c Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 2 Apr 2022 00:01:39 +0000 Subject: [PATCH 201/203] [cron] Bump distribution date (2022-04-02) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 8f3a9a4f57..31ff10c13c 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-04-01" +//#define STRING_DISTRIBUTION_DATE "2022-04-02" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index b3072b560b..447dd67d24 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-04-01" + #define STRING_DISTRIBUTION_DATE "2022-04-02" #endif /** From e4c7c550fcb3a69b2d89f718b23166fcad4d0f15 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Sun, 3 Apr 2022 01:27:05 +0200 Subject: [PATCH 202/203] =?UTF-8?q?=F0=9F=90=9B=20Fix=20PID=20edit=20menu?= =?UTF-8?q?=20for=20Bed,=20Chamber=20(#23987)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_advanced.cpp | 43 ++++++++++++++++++++++----- Marlin/src/module/planner.cpp | 2 +- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 80b8f5b1d2..e82743cd6b 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -39,7 +39,7 @@ #include "../../module/probe.h" #endif -#if ENABLED(PIDTEMP) +#if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER) #include "../../module/temperature.h" #endif @@ -190,7 +190,12 @@ void menu_backlash(); #if ENABLED(PIDTEMPCHAMBER) case H_CHAMBER: tune_temp = autotune_temp_chamber; break; #endif - default: tune_temp = autotune_temp[hid]; break; + default: + #if ENABLED(PIDTEMP) + tune_temp = autotune_temp[hid]; break; + #else + return; + #endif } sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), hid, tune_temp); queue.inject(cmd); @@ -206,14 +211,36 @@ void menu_backlash(); // Helpers for editing PID Ki & Kd values // grab the PID value out of the temp variable; scale it; then update the PID driver void copy_and_scalePID_i(int16_t e) { - UNUSED(e); - PID_PARAM(Ki, e) = scalePID_i(raw_Ki); - thermalManager.updatePID(); + switch (e) { + #if ENABLED(PIDTEMPBED) + case H_BED: thermalManager.temp_bed.pid.Ki = scalePID_i(raw_Ki); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.Ki = scalePID_i(raw_Ki); break; + #endif + default: + #if ENABLED(PIDTEMP) + PID_PARAM(Ki, e) = scalePID_i(raw_Ki); + thermalManager.updatePID(); + #endif + break; + } } void copy_and_scalePID_d(int16_t e) { - UNUSED(e); - PID_PARAM(Kd, e) = scalePID_d(raw_Kd); - thermalManager.updatePID(); + switch (e) { + #if ENABLED(PIDTEMPBED) + case H_BED: thermalManager.temp_bed.pid.Kd = scalePID_d(raw_Kd); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.Kd = scalePID_d(raw_Kd); break; + #endif + default: + #if ENABLED(PIDTEMP) + PID_PARAM(Kd, e) = scalePID_d(raw_Kd); + thermalManager.updatePID(); + #endif + break; + } } #define _DEFINE_PIDTEMP_BASE_FUNCS(N) \ diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index ae67073b4f..42a16603d4 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2129,7 +2129,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k), + sq(steps_dist_mm.u), + sq(steps_dist_mm.v), + sq(steps_dist_mm.w) ); - #elif ENABLED(FOAMCUTTER_XYUV) + #elif ENABLED(FOAMCUTTER_XYUV) #if HAS_J_AXIS // Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j)) From 4f1967a0a536bcc0bfb18e8a35df31c8fc4e21ef Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 3 Apr 2022 00:46:28 +0000 Subject: [PATCH 203/203] [cron] Bump distribution date (2022-04-03) --- Marlin/Version.h | 2 +- Marlin/src/inc/Version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Version.h b/Marlin/Version.h index 31ff10c13c..5f601adb9e 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-04-02" +//#define STRING_DISTRIBUTION_DATE "2022-04-03" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 447dd67d24..250133c435 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-04-02" + #define STRING_DISTRIBUTION_DATE "2022-04-03" #endif /**