From 402aab968ced932eb6fd3574dac899a88c90317a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 19 Nov 2025 00:33:07 +0000 Subject: [PATCH 01/39] [cron] Bump distribution date (2025-11-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 74efd4011b..56a03d5885 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 "2025-11-18" +//#define STRING_DISTRIBUTION_DATE "2025-11-19" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index e8f66b735d..293dee7ad6 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 "2025-11-18" + #define STRING_DISTRIBUTION_DATE "2025-11-19" #endif /** From 06c6c479dd048d18445097b04557a7d90ad1f4fa Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 19 Nov 2025 21:42:43 -0600 Subject: [PATCH 02/39] =?UTF-8?q?=F0=9F=9A=B8=20Immediate=20Buttons=20and?= =?UTF-8?q?=20Menu=20Items=20(#28180)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 13 +++ Marlin/src/HAL/HC32/inc/SanityCheck.h | 2 +- Marlin/src/HAL/HC32/sysclock.cpp | 2 +- Marlin/src/MarlinCore.cpp | 8 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 75 +++++++++-------- .../generic/custom_user_menus.cpp | 81 ++++++++++--------- .../generic/endstop_state_screen.cpp | 10 ++- Marlin/src/lcd/extui/mks_ui/draw_more.cpp | 13 +-- Marlin/src/lcd/extui/ui_api.h | 2 + Marlin/src/lcd/menu/menu.h | 4 + Marlin/src/lcd/menu/menu_configuration.cpp | 8 +- Marlin/src/lcd/menu/menu_item.h | 16 ++++ Marlin/src/lcd/menu/menu_main.cpp | 19 ++++- buildroot/tests/STM32F103RE_btt_USB | 6 +- 14 files changed, 157 insertions(+), 102 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2e0f7f14fb..c5ed503b4c 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -4123,22 +4123,27 @@ #define MAIN_MENU_ITEM_1_DESC "Home & UBL Info" #define MAIN_MENU_ITEM_1_GCODE "G28\nG29 W" //#define MAIN_MENU_ITEM_1_CONFIRM // Show a confirmation dialog before this action + //#define MAIN_MENU_ITEM_1_IMMEDIATE // Skip the queue and execute immediately. Rarely needed. #define MAIN_MENU_ITEM_2_DESC "Preheat for " PREHEAT_1_LABEL #define MAIN_MENU_ITEM_2_GCODE "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) //#define MAIN_MENU_ITEM_2_CONFIRM + //#define MAIN_MENU_ITEM_2_IMMEDIATE //#define MAIN_MENU_ITEM_3_DESC "Preheat for " PREHEAT_2_LABEL //#define MAIN_MENU_ITEM_3_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) //#define MAIN_MENU_ITEM_3_CONFIRM + //#define MAIN_MENU_ITEM_3_IMMEDIATE //#define MAIN_MENU_ITEM_4_DESC "Heat Bed/Home/Level" //#define MAIN_MENU_ITEM_4_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29" //#define MAIN_MENU_ITEM_4_CONFIRM + //#define MAIN_MENU_ITEM_4_IMMEDIATE //#define MAIN_MENU_ITEM_5_DESC "Home & Info" //#define MAIN_MENU_ITEM_5_GCODE "G28\nM503" //#define MAIN_MENU_ITEM_5_CONFIRM + //#define MAIN_MENU_ITEM_5_IMMEDIATE #endif // @section custom config menu @@ -4155,22 +4160,27 @@ #define CONFIG_MENU_ITEM_1_DESC "Wifi ON" #define CONFIG_MENU_ITEM_1_GCODE "M118 [ESP110] WIFI-STA pwd=12345678" //#define CONFIG_MENU_ITEM_1_CONFIRM // Show a confirmation dialog before this action + //#define CONFIG_MENU_ITEM_1_IMMEDIATE // Skip the queue and execute immediately. Rarely needed. #define CONFIG_MENU_ITEM_2_DESC "Bluetooth ON" #define CONFIG_MENU_ITEM_2_GCODE "M118 [ESP110] BT pwd=12345678" //#define CONFIG_MENU_ITEM_2_CONFIRM + //#define CONFIG_MENU_ITEM_2_IMMEDIATE //#define CONFIG_MENU_ITEM_3_DESC "Radio OFF" //#define CONFIG_MENU_ITEM_3_GCODE "M118 [ESP110] OFF pwd=12345678" //#define CONFIG_MENU_ITEM_3_CONFIRM + //#define CONFIG_MENU_ITEM_3_IMMEDIATE //#define CONFIG_MENU_ITEM_4_DESC "Wifi ????" //#define CONFIG_MENU_ITEM_4_GCODE "M118 ????" //#define CONFIG_MENU_ITEM_4_CONFIRM + //#define CONFIG_MENU_ITEM_4_IMMEDIATE //#define CONFIG_MENU_ITEM_5_DESC "Wifi ????" //#define CONFIG_MENU_ITEM_5_GCODE "M118 ????" //#define CONFIG_MENU_ITEM_5_CONFIRM + //#define CONFIG_MENU_ITEM_5_IMMEDIATE #endif // @section custom buttons @@ -4187,6 +4197,7 @@ #define BUTTON1_WHEN_PRINTING false // Button allowed to trigger during printing? #define BUTTON1_GCODE "G28" #define BUTTON1_DESC "Homing" // Optional string to set the LCD status + //#define BUTTON1_IMMEDIATE // Skip the queue and run the G-code immediately. Rarely needed. #endif //#define BUTTON2_PIN -1 @@ -4195,6 +4206,7 @@ #define BUTTON2_WHEN_PRINTING false #define BUTTON2_GCODE "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) #define BUTTON2_DESC "Preheat for " PREHEAT_1_LABEL + //#define BUTTON2_IMMEDIATE #endif //#define BUTTON3_PIN -1 @@ -4203,6 +4215,7 @@ #define BUTTON3_WHEN_PRINTING false #define BUTTON3_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) #define BUTTON3_DESC "Preheat for " PREHEAT_2_LABEL + //#define BUTTON3_IMMEDIATE #endif #endif diff --git a/Marlin/src/HAL/HC32/inc/SanityCheck.h b/Marlin/src/HAL/HC32/inc/SanityCheck.h index e38bce91e5..c6b3b221df 100644 --- a/Marlin/src/HAL/HC32/inc/SanityCheck.h +++ b/Marlin/src/HAL/HC32/inc/SanityCheck.h @@ -83,7 +83,7 @@ #error "POSTMORTEM_DEBUGGING requires CORE_DISABLE_FAULT_HANDLER to be set." #endif -#if defined(PANIC_ENABLE) +#ifdef PANIC_ENABLE #if defined(PANIC_USART1_TX_PIN) || defined(PANIC_USART2_TX_PIN) || defined(PANIC_USART3_TX_PIN) || defined(PANIC_USART3_TX_PIN) #error "HC32 HAL uses a custom panic handler. Do not define PANIC_USARTx_TX_PIN." #endif diff --git a/Marlin/src/HAL/HC32/sysclock.cpp b/Marlin/src/HAL/HC32/sysclock.cpp index 493515b0e8..e98395c42e 100644 --- a/Marlin/src/HAL/HC32/sysclock.cpp +++ b/Marlin/src/HAL/HC32/sysclock.cpp @@ -171,7 +171,7 @@ void core_hook_sysclock_init() { panic("HRC is not 16 MHz"); } - #if defined(BOARD_XTAL_FREQUENCY) + #ifdef BOARD_XTAL_FREQUENCY #warning "No valid XTAL frequency defined, falling back to HRC." #endif diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 175fd0c315..cb81efc4bb 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -531,11 +531,15 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { constexpr millis_t CUB_DEBOUNCE_DELAY_##N = 250UL; \ static millis_t next_cub_ms_##N; \ if (BUTTON##N##_HIT_STATE == READ(BUTTON##N##_PIN) \ - && (ENABLED(BUTTON##N##_WHEN_PRINTING) || printer_not_busy)) { \ + && (ENABLED(BUTTON##N##_WHEN_PRINTING) || printer_not_busy) \ + ) { \ if (ELAPSED(ms, next_cub_ms_##N)) { \ next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \ CODE; \ - queue.inject(F(BUTTON##N##_GCODE)); \ + if (ENABLED(BUTTON##N##_IMMEDIATE)) \ + gcode.process_subcommands_now(F(BUTTON##N##_GCODE)); \ + else \ + queue.inject(F(BUTTON##N##_GCODE)); \ TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \ } \ } \ diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 2870524dea..dbda3cd225 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -266,7 +266,7 @@ private: uint8_t tilt_grid = 1; void manualValueUpdate(bool undefined=false) { - gcode.process_subcommands_now( + queue.inject( TS(F("M421I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3), undefined ? "N" : "") ); planner.synchronize(); @@ -313,7 +313,7 @@ private: #else void manualValueUpdate() { - gcode.process_subcommands_now( + queue.inject( TS(F("G29I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3)) ); planner.synchronize(); @@ -1176,7 +1176,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra thermalManager.wait_for_hotend(0); } popupHandler(Popup_FilChange); - gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0))); + queue.inject(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0))); } #endif } @@ -1225,7 +1225,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_MoveX, GET_TEXT_F(MSG_AUTO_HOME_X)); else { popupHandler(Popup_Home); - gcode.process_subcommands_now(F("G28X")); + queue.inject(F("G28X")); planner.synchronize(); redrawMenu(); } @@ -1235,7 +1235,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_MoveY, GET_TEXT_F(MSG_AUTO_HOME_X)); else { popupHandler(Popup_Home); - gcode.process_subcommands_now(F("G28Y")); + queue.inject(F("G28Y")); planner.synchronize(); redrawMenu(); } @@ -1245,7 +1245,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_MoveZ, GET_TEXT_F(MSG_AUTO_HOME_X)); else { popupHandler(Popup_Home); - gcode.process_subcommands_now(F("G28Z")); + queue.inject(F("G28Z")); planner.synchronize(); redrawMenu(); } @@ -1254,7 +1254,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra if (draw) drawMenuItem(row, ICON_SetHome, F("Set Home Here")); else { - gcode.process_subcommands_now(F("G92X0Y0Z0")); + queue.inject(F("G92X0Y0Z0")); audioFeedback(); } break; @@ -1577,7 +1577,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME_Z)); else { popupHandler(Popup_Home); - gcode.process_subcommands_now(F("G28Z")); + queue.inject(F("G28Z")); popupHandler(Popup_MoveWait); #if ENABLED(Z_SAFE_HOMING) planner.synchronize(); @@ -1809,8 +1809,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Info, F(CONFIG_MENU_ITEM_1_DESC)); else { popupHandler(Popup_Custom); - //queue.inject(F(CONFIG_MENU_ITEM_1_GCODE)); // Old code - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_1_GCODE)); + TERN(CONFIG_MENU_ITEM_1_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(CONFIG_MENU_ITEM_1_GCODE)); planner.synchronize(); redrawMenu(); #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) @@ -1829,7 +1828,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Info, F(CONFIG_MENU_ITEM_2_DESC)); else { popupHandler(Popup_Custom); - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_2_GCODE)); + TERN(CONFIG_MENU_ITEM_1_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(CONFIG_MENU_ITEM_2_GCODE)); planner.synchronize(); redrawMenu(); #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) @@ -1848,7 +1847,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Info, F(CONFIG_MENU_ITEM_3_DESC)); else { popupHandler(Popup_Custom); - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_3_GCODE)); + TERN(CONFIG_MENU_ITEM_1_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(CONFIG_MENU_ITEM_3_GCODE)); planner.synchronize(); redrawMenu(); #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) @@ -1867,7 +1866,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Info, F(CONFIG_MENU_ITEM_4_DESC)); else { popupHandler(Popup_Custom); - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_4_GCODE)); + TERN(CONFIG_MENU_ITEM_1_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(CONFIG_MENU_ITEM_4_GCODE)); planner.synchronize(); redrawMenu(); #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) @@ -1886,7 +1885,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Info, F(CONFIG_MENU_ITEM_5_DESC)); else { popupHandler(Popup_Custom); - gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_5_GCODE)); + TERN(CONFIG_MENU_ITEM_1_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(CONFIG_MENU_ITEM_5_GCODE)); planner.synchronize(); redrawMenu(); #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) @@ -2127,7 +2126,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_HotendTemp, GET_TEXT_F(MSG_PID_AUTOTUNE)); else { popupHandler(Popup_PIDWait); - gcode.process_subcommands_now(TS(F("M303E0C"), PID_cycles, 'S', PID_e_temp, 'U')); + queue.inject(TS(F("M303E0C"), PID_cycles, 'S', PID_e_temp, 'U')); planner.synchronize(); redrawMenu(); } @@ -2193,7 +2192,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_HotendTemp, GET_TEXT_F(MSG_PID_AUTOTUNE)); else { popupHandler(Popup_PIDWait); - gcode.process_subcommands_now(TS(F("M303E-1C"), PID_cycles, 'S', PID_bed_temp, 'U')); + queue.inject(TS(F("M303E-1C"), PID_cycles, 'S', PID_bed_temp, 'U')); planner.synchronize(); redrawMenu(); } @@ -3037,7 +3036,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra if (draw) drawMenuItem(row, ICON_StepY, F("M48 Probe Test")); else { - gcode.process_subcommands_now( + queue.inject( TS(F("G28O\nM48X"), p_float_t((X_BED_SIZE + X_MIN_POS) / 2.0f, 3), 'Y', p_float_t((Y_BED_SIZE + Y_MIN_POS) / 2.0f, 3), 'P', testcount) ); } @@ -3231,9 +3230,9 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra gcode.home_all_axes(true); popupHandler(Popup_Level); if (mesh_conf.tilt_grid > 1) - gcode.process_subcommands_now(TS(F("G29J"), mesh_conf.tilt_grid)); + queue.inject(TS(F("G29J"), mesh_conf.tilt_grid)); else - gcode.process_subcommands_now(F("G29J")); + queue.inject(F("G29J")); planner.synchronize(); redrawMenu(); } @@ -3268,7 +3267,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra #endif #elif HAS_BED_PROBE popupHandler(Popup_Level); - gcode.process_subcommands_now(F("G29")); + queue.inject(F("G29")); planner.synchronize(); popupHandler(Popup_SaveLevel); #else @@ -3276,7 +3275,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra set_bed_leveling_enabled(false); gridpoint = 1; popupHandler(Popup_MoveWait); - gcode.process_subcommands_now(F("G29")); + queue.inject(F("G29")); planner.synchronize(); drawMenu(ID_ManualMesh); #endif @@ -3359,7 +3358,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra popupHandler(Popup_MeshSlot); break; } - gcode.process_subcommands_now(F("G29 L")); + queue.inject(F("G29 L")); planner.synchronize(); audioFeedback(true); } @@ -3372,7 +3371,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra popupHandler(Popup_MeshSlot); break; } - gcode.process_subcommands_now(F("G29 S")); + queue.inject(F("G29 S")); planner.synchronize(); audioFeedback(true); } @@ -3576,7 +3575,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Axis, F("+0.01mm Up")); else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; - gcode.process_subcommands_now(F("M290 Z0.01")); + queue.inject(F("M290 Z0.01")); planner.synchronize(); current_position.z += 0.01f; sync_plan_position(); @@ -3588,7 +3587,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_AxisD, F("-0.01mm Down")); else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; - gcode.process_subcommands_now(F("M290 Z-0.01")); + queue.inject(F("M290 Z-0.01")); planner.synchronize(); current_position.z -= 0.01f; sync_plan_position(); @@ -3659,7 +3658,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra mesh_conf.manual_mesh_move(); } else { - gcode.process_subcommands_now(F("G29 S")); + queue.inject(F("G29 S")); planner.synchronize(); audioFeedback(true); drawMenu(ID_Leveling, LEVELING_GET_MESH); @@ -3697,7 +3696,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Axis, F("+0.01mm Up")); else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; - gcode.process_subcommands_now(F("M290 Z0.01")); + queue.inject(F("M290 Z0.01")); planner.synchronize(); current_position.z += 0.01f; sync_plan_position(); @@ -3709,7 +3708,7 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawMenuItem(row, ICON_Axis, F("-0.01mm Down")); else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; - gcode.process_subcommands_now(F("M290 Z-0.01")); + queue.inject(F("M290 Z-0.01")); planner.synchronize(); current_position.z -= 0.01f; sync_plan_position(); @@ -3751,13 +3750,13 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra } else if (gridpoint < GRID_MAX_POINTS) { popupHandler(Popup_MoveWait); - gcode.process_subcommands_now(F("G29")); + queue.inject(F("G29")); planner.synchronize(); gridpoint++; redrawMenu(); } else { - gcode.process_subcommands_now(F("G29")); + queue.inject(F("G29")); planner.synchronize(); audioFeedback(settings.save()); drawMenu(ID_Leveling, LEVELING_GET_MESH); @@ -4020,26 +4019,26 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra switch (last_menu) { case ID_Prepare: popupHandler(Popup_FilChange); - gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0))); + queue.inject(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0))); break; #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case ID_ChangeFilament: switch (last_selection) { case CHANGEFIL_LOAD: popupHandler(Popup_FilLoad); - gcode.process_subcommands_now(F("M701")); + queue.inject(F("M701")); planner.synchronize(); redrawMenu(true, true, true); break; case CHANGEFIL_UNLOAD: popupHandler(Popup_FilLoad, true); - gcode.process_subcommands_now(F("M702")); + queue.inject(F("M702")); planner.synchronize(); redrawMenu(true, true, true); break; case CHANGEFIL_CHANGE: popupHandler(Popup_FilChange); - gcode.process_subcommands_now(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0))); + queue.inject(TS(F("M600 B1 R"), thermalManager.degTargetHotend(0))); break; } break; @@ -4614,10 +4613,10 @@ void JyersDWIN::printScreenControl() { TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); #else #if HAS_HEATED_BED - gcode.process_subcommands_now(TS(F("M140 S"), pausebed)); + queue.inject(TS(F("M140 S"), pausebed)); #endif #if HAS_EXTRUDERS - gcode.process_subcommands_now(TS(F("M109 S"), pausetemp)); + queue.inject(TS(F("M109 S"), pausetemp)); #endif TERN_(HAS_FAN, thermalManager.fan_speed[0] = pausefan); planner.synchronize(); @@ -4737,7 +4736,7 @@ void JyersDWIN::popupControl() { thermalManager.wait_for_hotend(0); } popupHandler(Popup_FilChange); - gcode.process_subcommands_now(TS(F("M600B1R"), thermalManager.degTargetHotend(0))); + queue.inject(TS(F("M600B1R"), thermalManager.degTargetHotend(0))); } } else @@ -4760,7 +4759,7 @@ void JyersDWIN::popupControl() { case Popup_SaveLevel: if (selection == 0) { #if ENABLED(AUTO_BED_LEVELING_UBL) - gcode.process_subcommands_now(F("G29 S")); + queue.inject(F("G29 S")); planner.synchronize(); audioFeedback(true); #else diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp index 896de3fe56..d86946ca4f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp @@ -42,7 +42,7 @@ void CustomUserMenus::onRedraw(draw_mode_t what) { } #if ENABLED(TOUCH_UI_PORTRAIT) - #if defined(TOOLHEAD_Legacy_Universal) + #ifdef TOOLHEAD_Legacy_Universal #define GRID_ROWS 10 #else #define GRID_ROWS 7 @@ -61,10 +61,9 @@ void CustomUserMenus::onRedraw(draw_mode_t what) { #define BACK_POS BTN_POS(1,GRID_ROWS), BTN_SIZE(GRID_COLS,1) #endif -btn_colors thcolor[8] = {normal_btn}; + btn_colors thcolor[8] = {normal_btn}; + //.color(TH_color[1]) - -//.color(TH_color[1]) if (what & FOREGROUND) { CommandProcessor cmd; cmd.colors(normal_btn) @@ -72,42 +71,42 @@ btn_colors thcolor[8] = {normal_btn}; .tag(0).text(TOOLHEAD_LABL_POS, GET_TEXT_F(MSG_CUSTOM_MENU_MAIN_TITLE)); cmd.colors(accent_btn) .font(Theme::font_medium) - #if defined(MAIN_MENU_ITEM_1_DESC) + #ifdef MAIN_MENU_ITEM_1_DESC //_USER_ITEM(1) .tag(_ITEM_TAG(11)).button(USER_ITEM_POS(1), MAIN_MENU_ITEM_1_DESC) #endif .colors(thcolor[1]) - #if defined(MAIN_MENU_ITEM_2_DESC) + #ifdef MAIN_MENU_ITEM_2_DESC //_USER_ITEM(2) .tag(_ITEM_TAG(12)).button(USER_ITEM_POS(2), MAIN_MENU_ITEM_2_DESC) #endif .colors(thcolor[2]) - #if defined(MAIN_MENU_ITEM_3_DESC) + #ifdef MAIN_MENU_ITEM_3_DESC //_USER_ITEM(3) .tag(_ITEM_TAG(13)).button(USER_ITEM_POS(3), MAIN_MENU_ITEM_3_DESC) #endif .colors(thcolor[3]) - #if defined(MAIN_MENU_ITEM_4_DESC) + #ifdef MAIN_MENU_ITEM_4_DESC //_USER_ITEM(4) .tag(_ITEM_TAG(14)).button(USER_ITEM_POS(4), MAIN_MENU_ITEM_4_DESC) #endif .colors(thcolor[4]) - #if defined(MAIN_MENU_ITEM_5_DESC) + #ifdef MAIN_MENU_ITEM_5_DESC //_USER_ITEM(5) .tag(_ITEM_TAG(15)).button(USER_ITEM_POS(5), MAIN_MENU_ITEM_5_DESC) #endif .colors(thcolor[5]) - #if defined(MAIN_MENU_ITEM_6_DESC) + #ifdef MAIN_MENU_ITEM_6_DESC //_USER_ITEM(6) .tag(_ITEM_TAG(16)).button(USER_ITEM_POS(6), MAIN_MENU_ITEM_6_DESC) #endif .colors(thcolor[6]) - #if defined(MAIN_MENU_ITEM_7_DESC) + #ifdef MAIN_MENU_ITEM_7_DESC //_USER_ITEM(7) .tag(_ITEM_TAG(17)).button(USER_ITEM_POS(7), MAIN_MENU_ITEM_7_DESC) #endif .colors(thcolor[7]) - #if defined(MAIN_MENU_ITEM_8_DESC) + #ifdef MAIN_MENU_ITEM_8_DESC //_USER_ITEM(8) .tag(_ITEM_TAG(18)).button(USER_ITEM_POS(8), MAIN_MENU_ITEM_8_DESC) #endif @@ -123,41 +122,49 @@ btn_colors thcolor[8] = {normal_btn}; } } +#include "../../../../gcode/queue.h" + +template void _lcd_custom_menu_gcode(FSTR_P const fstr); + +FORCE_INLINE void _lcd_custom_menu_gcode_done() { + TERN_(CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); + TERN_(CUSTOM_MENU_MAIN_SCRIPT_RETURN, ui.return_to_status()); +} +template<> void _lcd_custom_menu_gcode(FSTR_P const fstr) { + gcode.process_subcommands_now(fstr); + _lcd_custom_menu_gcode_done(); +} +template<> void _lcd_custom_menu_gcode(FSTR_P const fstr) { + queue.inject(fstr); + _lcd_custom_menu_gcode_done(); +} + bool CustomUserMenus::onTouchEnd(uint8_t tag) { switch (tag) { - #if defined(MAIN_MENU_ITEM_1_DESC) - //_USER_ACTION(1) - case _ITEM_TAG(11): injectCommands_P(PSTR(MAIN_MENU_ITEM_1_GCODE));sound.play(chimes, PLAY_ASYNCHRONOUS); GOTO_SCREEN(StatusScreen); break; + #ifdef MAIN_MENU_ITEM_1_DESC + case _ITEM_TAG(11): _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_1_GCODE)); break; #endif - #if defined(MAIN_MENU_ITEM_2_DESC) - //_USER_ACTION(2) - case _ITEM_TAG(12): injectCommands_P(PSTR(MAIN_MENU_ITEM_2_GCODE));sound.play(chimes, PLAY_ASYNCHRONOUS); GOTO_SCREEN(StatusScreen); break; + #ifdef MAIN_MENU_ITEM_2_DESC + case _ITEM_TAG(12): _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_2_GCODE)); break; #endif - #if defined(MAIN_MENU_ITEM_3_DESC) - //_USER_ACTION(3) - case _ITEM_TAG(13): injectCommands_P(PSTR(MAIN_MENU_ITEM_3_GCODE));sound.play(chimes, PLAY_ASYNCHRONOUS); GOTO_SCREEN(StatusScreen); break; + #ifdef MAIN_MENU_ITEM_3_DESC + case _ITEM_TAG(13): _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_3_GCODE)); break; #endif - #if defined(MAIN_MENU_ITEM_4_DESC) - //_USER_ACTION(4) - case _ITEM_TAG(14): injectCommands_P(PSTR(MAIN_MENU_ITEM_4_GCODE));sound.play(chimes, PLAY_ASYNCHRONOUS); GOTO_SCREEN(StatusScreen); break; + #ifdef MAIN_MENU_ITEM_4_DESC + case _ITEM_TAG(14): _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_4_GCODE)); break; #endif - #if defined(MAIN_MENU_ITEM_5_DESC) - //_USER_ACTION(5) - case _ITEM_TAG(15): injectCommands_P(PSTR(MAIN_MENU_ITEM_5_GCODE));sound.play(chimes, PLAY_ASYNCHRONOUS); GOTO_SCREEN(StatusScreen); break; + #ifdef MAIN_MENU_ITEM_5_DESC + case _ITEM_TAG(15): _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_5_GCODE)); break; #endif - #if defined(MAIN_MENU_ITEM_6_DESC) - //_USER_ACTION(6) - case _ITEM_TAG(16): injectCommands_P(PSTR(MAIN_MENU_ITEM_6_GCODE));sound.play(chimes, PLAY_ASYNCHRONOUS); GOTO_SCREEN(StatusScreen); break; + #ifdef MAIN_MENU_ITEM_6_DESC + case _ITEM_TAG(16): _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_6_GCODE)); break; #endif - #if defined(MAIN_MENU_ITEM_7_DESC) - //_USER_ACTION(7) - case _ITEM_TAG(17): injectCommands_P(PSTR(MAIN_MENU_ITEM_7_GCODE));sound.play(chimes, PLAY_ASYNCHRONOUS); GOTO_SCREEN(StatusScreen);break; + #ifdef MAIN_MENU_ITEM_7_DESC + case _ITEM_TAG(17): _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_7_GCODE)); break; #endif - #if defined(MAIN_MENU_ITEM_8_DESC) - //_USER_ACTION(8) - case _ITEM_TAG(18): injectCommands_P(PSTR(MAIN_MENU_ITEM_8_GCODE));sound.play(chimes, PLAY_ASYNCHRONOUS); GOTO_SCREEN(StatusScreen);break; + #ifdef MAIN_MENU_ITEM_8_DESC + case _ITEM_TAG(18): _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_8_GCODE)); break; #endif - case 1: GOTO_PREVIOUS(); break; #ifdef PARKING_COMMAND_GCODE case 20: injectCommands(F(PARKING_COMMAND_GCODE)); break; 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 8a935313a1..1552b6a496 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 @@ -94,10 +94,12 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { #else PIN_DISABLED(3, 4, GET_TEXT_F(MSG_RUNOUT_2), FIL_RUNOUT2) #endif - #if PIN_EXISTS(Z_MIN_PROBE) - PIN_ENABLED (5, 4, PSTR(STR_Z_PROBE), Z_MIN_PROBE, Z_MIN_PROBE_ENDSTOP_HIT_STATE) - #else - PIN_DISABLED(5, 4, PSTR(STR_Z_PROBE), Z_MIN_PROBE) + #if HAS_BED_PROBE + #if PIN_EXISTS(Z_MIN_PROBE) + PIN_ENABLED (5, 4, PSTR(STR_Z_PROBE), Z_MIN_PROBE, Z_MIN_PROBE_ENDSTOP_HIT_STATE) + #else + PIN_DISABLED(5, 4, PSTR(STR_Z_PROBE), Z_MIN_PROBE) + #endif #endif #if HAS_SOFTWARE_ENDSTOPS diff --git a/Marlin/src/lcd/extui/mks_ui/draw_more.cpp b/Marlin/src/lcd/extui/mks_ui/draw_more.cpp index 864a3e1d96..dd53374583 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_more.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_more.cpp @@ -29,6 +29,7 @@ #include "draw_set.h" #include "lv_conf.h" #include "draw_ui.h" +#include "../../../gcode/gcode.h" #include "../../../gcode/queue.h" extern lv_group_t * g; @@ -62,22 +63,22 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) { switch (obj->mks_obj_id) { case ID_GCODE: lv_clear_more(); lv_draw_gcode(true); break; #if HAS_USER_ITEM(1) - case ID_CUSTOM_1: queue.inject(F(MAIN_MENU_ITEM_1_GCODE)); break; + case ID_CUSTOM_1: TERN(CONFIG_MENU_ITEM_1_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(MAIN_MENU_ITEM_1_GCODE)); break; #endif #if HAS_USER_ITEM(2) - case ID_CUSTOM_2: queue.inject(F(MAIN_MENU_ITEM_2_GCODE)); break; + case ID_CUSTOM_2: TERN(CONFIG_MENU_ITEM_2_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(MAIN_MENU_ITEM_2_GCODE)); break; #endif #if HAS_USER_ITEM(3) - case ID_CUSTOM_3: queue.inject(F(MAIN_MENU_ITEM_3_GCODE)); break; + case ID_CUSTOM_3: TERN(CONFIG_MENU_ITEM_3_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(MAIN_MENU_ITEM_3_GCODE)); break; #endif #if HAS_USER_ITEM(4) - case ID_CUSTOM_4: queue.inject(F(MAIN_MENU_ITEM_4_GCODE)); break; + case ID_CUSTOM_4: TERN(CONFIG_MENU_ITEM_4_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(MAIN_MENU_ITEM_4_GCODE)); break; #endif #if HAS_USER_ITEM(5) - case ID_CUSTOM_5: queue.inject(F(MAIN_MENU_ITEM_5_GCODE)); break; + case ID_CUSTOM_5: TERN(CONFIG_MENU_ITEM_5_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(MAIN_MENU_ITEM_5_GCODE)); break; #endif #if HAS_USER_ITEM(6) - case ID_CUSTOM_6: queue.inject(F(MAIN_MENU_ITEM_6_GCODE)); break; + case ID_CUSTOM_6: TERN(CONFIG_MENU_ITEM_6_IMMEDIATE, gcode.process_subcommands_now, queue.inject)(F(MAIN_MENU_ITEM_6_GCODE)); break; #endif case ID_M_RETURN: lv_clear_more(); diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 88145621e5..f864f3d1cd 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -132,6 +132,8 @@ namespace ExtUI { inline void injectCommands(FSTR_P const fstr) { injectCommands_P(FTOP(fstr)); } void injectCommands(char * const); bool commandsInQueue(); + inline void executeCommands(FSTR_P const fstr) { gcode.process_subcommands_now(fstr); } + inline void executeCommands(char * const cstr) { gcode.process_subcommands_now(cstr); } #if ENABLED(HOST_KEEPALIVE_FEATURE) GcodeSuite::MarlinBusyState getHostKeepaliveState(); diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 73f7a9dcc9..869b06828c 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -269,3 +269,7 @@ inline void clear_menu_history() { screen_history_depth = 0; } #if ANY(PROBE_MANUALLY, MESH_BED_LEVELING, X_AXIS_TWIST_COMPENSATION) extern uint8_t manual_probe_index; #endif + +#if ANY(CUSTOM_MENU_MAIN, CUSTOM_MENU_CONFIG) + template void _lcd_custom_menu_gcode(FSTR_P const fstr); +#endif diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 259a81fb0e..d2849ccd1b 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -464,12 +464,6 @@ void menu_advanced_settings(); #if ENABLED(CUSTOM_MENU_CONFIG) - void _lcd_custom_menus_configuration_gcode(FSTR_P const fstr) { - queue.inject(fstr); - TERN_(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); - TERN_(CUSTOM_MENU_CONFIG_SCRIPT_RETURN, ui.return_to_status()); - } - void custom_menus_configuration() { START_MENU(); BACK_ITEM(MSG_MAIN_MENU); @@ -481,7 +475,7 @@ void menu_advanced_settings(); #else #define _DONE_SCRIPT "" #endif - #define GCODE_LAMBDA_CONF(N) []{ _lcd_custom_menus_configuration_gcode(F(CONFIG_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } + #define GCODE_LAMBDA_CONF(N) []{ _lcd_custom_menu_gcode(F(CONFIG_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } #define _CUSTOM_ITEM_CONF(N) ACTION_ITEM_F(F(CONFIG_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_CONF(N)); #define _CUSTOM_ITEM_CONF_CONFIRM(N) \ SUBMENU_F(F(CONFIG_MENU_ITEM_##N##_DESC), []{ \ diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index d79956aea7..c3544f3c67 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -23,6 +23,7 @@ #include "menu.h" #include "../marlinui.h" +#include "../../gcode/gcode.h" // for process_subcommands_now #include "../../gcode/queue.h" // for inject #include "../../inc/MarlinConfigPre.h" @@ -70,6 +71,12 @@ class MenuItem_gcode : public MenuItem_button { static void action(FSTR_P const fstr, const uint8_t, FSTR_P const fgcode) { action(fstr, fgcode); } }; +class MenuItem_command : public MenuItem_gcode { + public: + static void action(FSTR_P const, FSTR_P const fgcode) { gcode.process_subcommands_now(fgcode); } + static void action(FSTR_P const fstr, const uint8_t, FSTR_P const fgcode) { action(fstr, fgcode); } +}; + //////////////////////////////////////////// ///////////// Edit Menu Items ////////////// //////////////////////////////////////////// @@ -479,6 +486,15 @@ class MenuItem_bool : public MenuEditItemBase { #define GCODES_ITEM_F(FLABEL, GCODES) MENU_ITEM_F(gcode, FLABEL, GCODES) #define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_F(GET_TEXT_F(LABEL), GCODES) +#define COMMAND_ITEM_N_S_F(N, S, FLABEL, GCODES) MENU_ITEM_N_S_F(command, N, S, FLABEL, GCODES) +#define COMMAND_ITEM_N_S(N, S, LABEL, GCODES) COMMAND_ITEM_N_S_F(N, S, GET_TEXT_F(LABEL), GCODES) +#define COMMAND_ITEM_S_F(S, FLABEL, GCODES) MENU_ITEM_S_F(command, S, FLABEL, GCODES) +#define COMMAND_ITEM_S(S, LABEL, GCODES) COMMAND_ITEM_S_F(S, GET_TEXT_F(LABEL), GCODES) +#define COMMAND_ITEM_N_F(N, FLABEL, GCODES) MENU_ITEM_N_F(command, N, FLABEL, GCODES) +#define COMMAND_ITEM_N(N, LABEL, GCODES) COMMAND_ITEM_N_F(N, GET_TEXT_F(LABEL), GCODES) +#define COMMAND_ITEM_F(FLABEL, GCODES) MENU_ITEM_F(command, FLABEL, GCODES) +#define COMMAND_ITEM(LABEL, GCODES) COMMAND_ITEM_F(GET_TEXT_F(LABEL), GCODES) + #define SUBMENU_N_S_F(N, S, FLABEL, DEST) MENU_ITEM_N_S_F(submenu, N, S, FLABEL, DEST) #define SUBMENU_N_S(N, S, LABEL, DEST) SUBMENU_N_S_F(N, S, GET_TEXT_F(LABEL), DEST) #define SUBMENU_S_F(S, FLABEL, DEST) MENU_ITEM_S_F(submenu, S, FLABEL, DEST) diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 401c59f5c0..13fe4e89e2 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -116,13 +116,24 @@ void menu_configuration(); void menu_language(); #endif -#if ENABLED(CUSTOM_MENU_MAIN) +#if ANY(CUSTOM_MENU_MAIN, CUSTOM_MENU_CONFIG) - void _lcd_custom_menu_main_gcode(FSTR_P const fstr) { - queue.inject(fstr); + FORCE_INLINE void _lcd_custom_menu_gcode_done() { TERN_(CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); TERN_(CUSTOM_MENU_MAIN_SCRIPT_RETURN, ui.return_to_status()); } + template<> void _lcd_custom_menu_gcode(FSTR_P const fstr) { + gcode.process_subcommands_now(fstr); + _lcd_custom_menu_gcode_done(); + } + template<> void _lcd_custom_menu_gcode(FSTR_P const fstr) { + queue.inject(fstr); + _lcd_custom_menu_gcode_done(); + } + +#endif + +#if ENABLED(CUSTOM_MENU_MAIN) void custom_menus_main() { START_MENU(); @@ -135,7 +146,7 @@ void menu_configuration(); #else #define _DONE_SCRIPT "" #endif - #define GCODE_LAMBDA_MAIN(N) []{ _lcd_custom_menu_main_gcode(F(MAIN_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } + #define GCODE_LAMBDA_MAIN(N) []{ _lcd_custom_menu_gcode(F(MAIN_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } #define _CUSTOM_ITEM_MAIN(N) ACTION_ITEM_F(F(MAIN_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_MAIN(N)); #define _CUSTOM_ITEM_MAIN_CONFIRM(N) \ SUBMENU_F(F(MAIN_MENU_ITEM_##N##_DESC), []{ \ diff --git a/buildroot/tests/STM32F103RE_btt_USB b/buildroot/tests/STM32F103RE_btt_USB index ddf1903c9b..b74b8dd3a3 100755 --- a/buildroot/tests/STM32F103RE_btt_USB +++ b/buildroot/tests/STM32F103RE_btt_USB @@ -15,10 +15,12 @@ opt_enable SDSUPPORT EMERGENCY_PARSER exec_test $1 $2 "BigTreeTech SKR E3 DIP v1.0 - Basic Configuration" "$3" restore_configs -opt_set MOTHERBOARD BOARD_BTT_SKR_CR6 SERIAL_PORT -1 SERIAL_PORT_2 2 TEMP_SENSOR_BED 1 +opt_set MOTHERBOARD BOARD_BTT_SKR_CR6 SERIAL_PORT -1 SERIAL_PORT_2 2 TEMP_SENSOR_BED 1 BUTTON1_PIN PA12 opt_enable CR10_STOCKDISPLAY SDSUPPORT EMERGENCY_PARSER FAN_SOFT_PWM \ NOZZLE_AS_PROBE Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN Z_SAFE_HOMING \ PROBE_ACTIVATION_SWITCH PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE \ - PROBING_HEATERS_OFF PREHEAT_BEFORE_PROBING + PROBING_HEATERS_OFF PREHEAT_BEFORE_PROBING CUSTOM_USER_BUTTONS BUTTON1_IMMEDIATE \ + CUSTOM_MENU_MAIN MAIN_MENU_ITEM_1_CONFIRM MAIN_MENU_ITEM_2_IMMEDIATE MAIN_MENU_ITEM_3_DESC MAIN_MENU_ITEM_3_GCODE \ + CUSTOM_MENU_CONFIG CONFIG_MENU_ITEM_1_CONFIRM CONFIG_MENU_ITEM_2_IMMEDIATE CONFIG_MENU_ITEM_3_DESC CONFIG_MENU_ITEM_3_GCODE opt_disable NOZZLE_TO_PROBE_OFFSET exec_test $1 $2 "BigTreeTech SKR CR6 PROBE_ACTIVATION_SWITCH, Probe Tare" "$3" From 8dee0c128101c8da0da04b69d675971445cf8be2 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 20 Nov 2025 06:10:58 +0000 Subject: [PATCH 03/39] [cron] Bump distribution date (2025-11-20) --- 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 56a03d5885..117e6d9f1d 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 "2025-11-19" +//#define STRING_DISTRIBUTION_DATE "2025-11-20" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 293dee7ad6..e3d358c5ef 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 "2025-11-19" + #define STRING_DISTRIBUTION_DATE "2025-11-20" #endif /** From ccc69582efb99cc4a8e7a8b77aade7906395d4ce Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Nov 2025 13:27:17 -0600 Subject: [PATCH 04/39] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Warn?= =?UTF-8?q?=20about=20language=20features?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Warnings.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 6da36d832f..e15d053b4e 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -31,6 +31,10 @@ // Warnings! Located here so they will appear just once in the build output. // +#if __cplusplus < 201703L + #warning "This build does not have access to >= c++17 features." +#endif + // static_warning works like a static_assert but only emits a (messy) warning. #ifdef __GNUC__ namespace mfwarn { From 9da6b580d92cecac7e506480ff5b67cda5dd48f5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 23 Nov 2025 13:32:56 -0600 Subject: [PATCH 05/39] =?UTF-8?q?=F0=9F=9A=B8=20Immediate=20Buttons=20and?= =?UTF-8?q?=20Menu=20Items=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #28180 --- .../ftdi_eve_touch_ui/generic/custom_user_menus.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp index d86946ca4f..167dda1b0a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp @@ -122,20 +122,18 @@ void CustomUserMenus::onRedraw(draw_mode_t what) { } } -#include "../../../../gcode/queue.h" - template void _lcd_custom_menu_gcode(FSTR_P const fstr); FORCE_INLINE void _lcd_custom_menu_gcode_done() { - TERN_(CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback()); - TERN_(CUSTOM_MENU_MAIN_SCRIPT_RETURN, ui.return_to_status()); + sound.play(chimes, PLAY_ASYNCHRONOUS); + GOTO_SCREEN(StatusScreen); } template<> void _lcd_custom_menu_gcode(FSTR_P const fstr) { - gcode.process_subcommands_now(fstr); + ExtUI::executeCommands(fstr); _lcd_custom_menu_gcode_done(); } template<> void _lcd_custom_menu_gcode(FSTR_P const fstr) { - queue.inject(fstr); + ExtUI::injectCommands(fstr); _lcd_custom_menu_gcode_done(); } From 46ee5b0a0883cb7285b08d197229a99738f3e3b1 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 24 Nov 2025 00:35:08 +0000 Subject: [PATCH 06/39] [cron] Bump distribution date (2025-11-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 117e6d9f1d..9ff5e45d02 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 "2025-11-20" +//#define STRING_DISTRIBUTION_DATE "2025-11-24" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index e3d358c5ef..eb8cab633b 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 "2025-11-20" + #define STRING_DISTRIBUTION_DATE "2025-11-24" #endif /** From fe1d6f93e26ef5199ae54c32bb90baa7cdc10d63 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 24 Nov 2025 19:55:30 -0600 Subject: [PATCH 07/39] =?UTF-8?q?=F0=9F=94=A8=20STM32=20build=20with=20-st?= =?UTF-8?q?d=3Dgnu++17=20(#28188)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/stm32-common.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini index 2ba6baed1b..c5fedfa4e1 100644 --- a/ini/stm32-common.ini +++ b/ini/stm32-common.ini @@ -13,10 +13,10 @@ platform = ststm32@~12.1 #platform_packages = toolchain-gccarmnoneeabi@1.100301.220327 # Otherwise it's GCC 9.2.1 board_build.core = stm32 -build_flags = ${common.build_flags} -std=gnu++14 +build_flags = ${common.build_flags} -std=gnu++17 -DHAL_STM32 -DPLATFORM_M997_SUPPORT -DUSBCON -DUSBD_USE_CDC -DTIM_IRQ_PRIO=13 -DADC_RESOLUTION=12 -build_unflags = -std=gnu++11 +build_unflags = -std=gnu++11 -std=gnu++14 build_src_filter = ${common.default_src_filter} + - + extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py From 50297c65d47273d0c50a0d3649dbbb012838c996 Mon Sep 17 00:00:00 2001 From: Andrew <18502096+classicrocker883@users.noreply.github.com> Date: Mon, 24 Nov 2025 20:56:11 -0500 Subject: [PATCH 08/39] =?UTF-8?q?=F0=9F=9A=B8=20Update/fix=20JyersUI/ProUI?= =?UTF-8?q?=20park,=20leveling=20(#28183)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 6 +-- Marlin/src/feature/bltouch.cpp | 8 ++-- Marlin/src/gcode/bedlevel/mbl/G29.cpp | 2 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 44 +++++++------------- Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp | 23 +++------- Marlin/src/lcd/e3v2/proui/bedlevel_tools.h | 4 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 2 + Marlin/src/lcd/language/language_en.h | 1 + 8 files changed, 33 insertions(+), 57 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index 24a1638731..e14d7b2a38 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -1161,16 +1161,16 @@ bool unified_bed_leveling::G29_parse_parameters() { } if (parser.seen('P')) { - const uint8_t pv = parser.value_byte(); + const uint8_t pval = parser.value_byte(); #if !HAS_BED_PROBE - if (pv == 1) { + if (pval == 1) { SERIAL_ECHOLNPGM("G29 P1 requires a probe.\n"); err_flag = true; } else #endif { - param.P_phase = pv; + param.P_phase = pval; if (!WITHIN(param.P_phase, 0, 6)) { SERIAL_ECHOLNPGM("?(P)hase value invalid (0-6).\n"); err_flag = true; diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 5b498cd474..85b69d66c4 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -71,11 +71,9 @@ void BLTouch::init(const bool set_voltage/*=false*/) { #else - #ifdef DEBUG_OUT - if (DEBUGGING(LEVELING)) - DEBUG_ECHOLN( F("BLTouch Mode: "), bltouch.od_5v_mode ? F("5V") : F("OD"), - F(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")")); - #endif + if (DEBUGGING(LEVELING)) + DEBUG_ECHOLN( F("BLTouch Mode: "), bltouch.od_5v_mode ? F("5V") : F("OD"), + F(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")")); const bool should_set = od_5v_mode != ENABLED(BLTOUCH_SET_5V_MODE); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index 1cdeba103e..a08ecc327d 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -225,7 +225,7 @@ void GcodeSuite::G29() { } } else - return echo_not_entered('J'); + return echo_not_entered('I'); if (parser.seenval('J')) { iy = parser.value_int(); diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index dbda3cd225..557a8f0c7c 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -265,13 +265,6 @@ private: #if ENABLED(AUTO_BED_LEVELING_UBL) uint8_t tilt_grid = 1; - void manualValueUpdate(bool undefined=false) { - queue.inject( - TS(F("M421I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3), undefined ? "N" : "") - ); - planner.synchronize(); - } - bool createPlaneFromMesh() { struct linear_fit_data lsf_results; incremental_LSF_reset(&lsf_results); @@ -310,17 +303,14 @@ private: return false; } - #else - - void manualValueUpdate() { - queue.inject( - TS(F("G29I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3)) - ); - planner.synchronize(); - } - #endif + void manualValueUpdate(const bool reset=false) { + const float zval = reset ? 0.0f : current_position.z; + queue.inject(TS(F("M421I"), mesh_x, F("J"), mesh_y, F("Z"), p_float_t(zval, 3))); + planner.synchronize(); + } + void manual_mesh_move(const bool zmove=false) { if (zmove) { planner.synchronize(); @@ -3515,8 +3505,8 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra #define LEVELING_M_UP (LEVELING_M_OFFSET + 1) #define LEVELING_M_DOWN (LEVELING_M_UP + 1) #define LEVELING_M_GOTO_VALUE (LEVELING_M_DOWN + 1) - #define LEVELING_M_UNDEF (LEVELING_M_GOTO_VALUE + ENABLED(AUTO_BED_LEVELING_UBL)) - #define LEVELING_M_TOTAL LEVELING_M_UNDEF + #define LEVELING_M_ZERO (LEVELING_M_GOTO_VALUE + 1) + #define LEVELING_M_TOTAL LEVELING_M_ZERO switch (item) { case LEVELING_M_BACK: @@ -3606,16 +3596,14 @@ void JyersDWIN::menuItemHandler(const uint8_t menu, const uint8_t item, bool dra drawCheckbox(row, mesh_conf.goto_mesh_value); } break; - #if ENABLED(AUTO_BED_LEVELING_UBL) - case LEVELING_M_UNDEF: - if (draw) - drawMenuItem(row, ICON_ResetEEPROM, F("Clear Point Value")); - else { - mesh_conf.manualValueUpdate(true); - redrawMenu(false); - } - break; - #endif + case LEVELING_M_ZERO: + if (draw) + drawMenuItem(row, ICON_ResetEEPROM, GET_TEXT_F(MSG_ZERO_MESH_POINT)); + else { + mesh_conf.manualValueUpdate(true); + redrawMenu(false); + } + break; } break; #endif // HAS_MESH diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index 7c6ee0491a..4621ce6653 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -75,14 +75,6 @@ bool drawing_mesh = false; #if ENABLED(AUTO_BED_LEVELING_UBL) - void BedLevelTools::manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { - MString cmd; - cmd.set(F("M421 I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3)); - if (undefined) cmd += F(" N"); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - } - bool BedLevelTools::createPlaneFromMesh() { struct linear_fit_data lsf_results; incremental_LSF_reset(&lsf_results); @@ -122,17 +114,14 @@ bool drawing_mesh = false; return false; } -#else - - void BedLevelTools::manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y) { - gcode.process_subcommands_now( - TS(F("G29 I"), mesh_x, 'J', mesh_y, 'Z', p_float_t(current_position.z, 3)) - ); - planner.synchronize(); - } - #endif +void BedLevelTools::manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y, const bool reset/*=false*/) { + const float zval = reset ? 0.0f : current_position.z; + queue.inject(TS(F("M421I"), mesh_x, F("J"), mesh_y, F("Z"), p_float_t(zval, 3))); + planner.synchronize(); +} + void BedLevelTools::manualMove(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { gcode.process_subcommands_now(F("G28O")); if (!zmove) { diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 5716316ee4..26f2ecc399 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -55,11 +55,9 @@ public: static uint8_t tilt_grid; #if ENABLED(AUTO_BED_LEVELING_UBL) - static void manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined=false); static bool createPlaneFromMesh(); - #else - static void manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y); #endif + static void manualValueUpdate(const uint8_t mesh_x, const uint8_t mesh_y, const bool reset=false); static void manualMove(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false); static void moveToXYZ(); static void moveToXY(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 47e2acb27d..a82e055acf 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -4316,6 +4316,7 @@ void drawMaxAccelMenu() { void applyEditMeshX() { bedLevelTools.mesh_x = menuData.value; } void applyEditMeshY() { bedLevelTools.mesh_y = menuData.value; } void resetMesh() { bedLevelTools.meshReset(); LCD_MESSAGE(MSG_MESH_RESET); } + void zeroPoint() { bedLevelTools.manualValueUpdate(bedLevelTools.mesh_x, bedLevelTools.mesh_y, true); editZValueItem->redraw(); LCD_MESSAGE(MSG_ZERO_MESH_POINT); } void setEditMeshX() { hmiValue.select = 0; setIntOnClick(0, GRID_MAX_POINTS_X - 1, bedLevelTools.mesh_x, applyEditMeshX, liveEditMesh); } void setEditMeshY() { hmiValue.select = 1; setIntOnClick(0, GRID_MAX_POINTS_Y - 1, bedLevelTools.mesh_y, applyEditMeshY, liveEditMesh); } void setEditZValue() { setPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } @@ -4417,6 +4418,7 @@ void drawMaxAccelMenu() { EDIT_ITEM(ICON_MeshEditX, MSG_MESH_X, onDrawPInt8Menu, setEditMeshX, &bedLevelTools.mesh_x); EDIT_ITEM(ICON_MeshEditY, MSG_MESH_Y, onDrawPInt8Menu, setEditMeshY, &bedLevelTools.mesh_y); editZValueItem = EDIT_ITEM(ICON_MeshEditZ, MSG_MESH_EDIT_Z, onDrawPFloat2Menu, setEditZValue, &bedlevel.z_values[bedLevelTools.mesh_x][bedLevelTools.mesh_y]); + MENU_ITEM(ICON_SetZOffset, MSG_ZERO_MESH_POINT, onDrawMenuItem, zeroPoint); } updateMenu(editMeshMenu); } diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index bc1f22aa84..5e34a47723 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -140,6 +140,7 @@ namespace LanguageNarrow_en { LSTR MSG_LEVEL_BED_WAITING = _UxGT("Click to Begin"); LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Next Point"); LSTR MSG_LEVEL_BED_DONE = _UxGT("Leveling Done!"); + LSTR MSG_ZERO_MESH_POINT = _UxGT("Zero Current Point"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Fade Height"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Set Home Offsets"); LSTR MSG_HOME_OFFSET_X = _UxGT("Home Offset X"); // DWIN From e35bedab48c5453474bbd466390b5412f8494c4d Mon Sep 17 00:00:00 2001 From: Andrew <18502096+classicrocker883@users.noreply.github.com> Date: Mon, 24 Nov 2025 20:57:47 -0500 Subject: [PATCH 09/39] =?UTF-8?q?=F0=9F=94=A8=20Importable=20configuration?= =?UTF-8?q?.py=20for=20mc-apply.py=20(#28182)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformIO/scripts/collect-code-tests.py | 2 +- .../share/PlatformIO/scripts/configuration.py | 69 ++++++---- .../share/PlatformIO/scripts/mc-apply.py | 127 ++++-------------- 3 files changed, 72 insertions(+), 126 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/collect-code-tests.py b/buildroot/share/PlatformIO/scripts/collect-code-tests.py index a5758e97d3..fc82e9072d 100644 --- a/buildroot/share/PlatformIO/scripts/collect-code-tests.py +++ b/buildroot/share/PlatformIO/scripts/collect-code-tests.py @@ -28,7 +28,7 @@ if pioutil.is_pio_build(): name = f"marlin_{name}", dependencies = None, actions = [ - f"echo ====== Configuring for marlin_{name} ======", + f"@echo ====== Configuring for marlin_{name} ======", "restore_configs", f"cp -f {path} ./Marlin/config.ini", "python ./buildroot/share/PlatformIO/scripts/configuration.py", diff --git a/buildroot/share/PlatformIO/scripts/configuration.py b/buildroot/share/PlatformIO/scripts/configuration.py index 7d811b47ed..71d4e3777c 100755 --- a/buildroot/share/PlatformIO/scripts/configuration.py +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -7,27 +7,29 @@ import re, os, shutil, configparser, datetime from pathlib import Path verbose = 0 -def blab(str,level=1): - if verbose >= level: print(f"[config] {str}") +def blab(msg, level=1): + if verbose >= level: print(f"[config] {msg}") def config_path(cpath): return Path("Marlin", cpath) # Apply a single name = on/off ; name = value ; etc. # TODO: Limit to the given (optional) configuration -def apply_opt(name, val, conf=None): +def apply_opt(name, val): if name == "lcd": name, val = val, "on" - # Create a regex to match the option and capture parts of the line - # 1: Indentation - # 2: Comment - # 3: #define and whitespace - # 4: Option name - # 5: First space after name - # 6: Remaining spaces between name and value - # 7: Option value - # 8: Whitespace after value - # 9: End comment + """ + Create a regex to match the option and capture parts of the line + 1: Indentation + 2: Comment + 3: #define and whitespace + 4: Option name + 5: First space after name + 6: Remaining spaces between name and value + 7: Option value + 8: Whitespace after value + 9: End comment + """ regex = re.compile( rf"^(\s*)(//\s*)?(#define\s+)({name}\b)(\s?)(\s*)(.*?)(\s*)(//.*)?$", re.IGNORECASE @@ -101,11 +103,16 @@ def apply_opt(name, val, conf=None): # Everything in the named sections. Section hint for exceptions may be added. def disable_all_options(): # Create a regex to match the option and capture parts of the line + blab("Disabling all configuration options...") regex = re.compile(r'^(\s*)(#define\s+)([A-Z0-9_]+\b)(\s?)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) # Disable all enabled options in both Config files for file in ("Configuration.h", "Configuration_adv.h"): fullpath = config_path(file) + if not fullpath.exists(): + blab(f"File not found: {fullpath}", 0) + continue + lines = fullpath.read_text(encoding='utf-8').split('\n') found = False for i in range(len(lines)): @@ -120,14 +127,18 @@ def disable_all_options(): # TODO: Comment more lines in a multi-line define with \ continuation lines[i] = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line) blab(f"Disable {name}") + #blab(f"Disable {name}", 2) + # TODO: Taken from mc-apply, not sure which # If the option was found, write the modified lines if found: fullpath.write_text('\n'.join(lines), encoding='utf-8') + blab(f"Updated {file}") # Fetch configuration files from GitHub given the path. # Return True if any files were fetched. def fetch_example(url): + blab(f"Fetching example configuration from: {url}") if url.endswith("/"): url = url[:-1] if not url.startswith('http'): brch = "bugfix-2.1.x" @@ -143,9 +154,12 @@ def fetch_example(url): fetch = "wget -q -O" else: blab("Couldn't find curl or wget", -1) + #blab("Couldn't find curl or wget", 0) + # TODO: Taken from mc-apply, not sure which return False # Reset configurations to default + blab("Resetting configurations to default...") os.system("git checkout HEAD Marlin/*.h") # Try to fetch the remote files @@ -154,9 +168,15 @@ def fetch_example(url): if os.system(f"{fetch} wgot {url}/{fn} >/dev/null 2>&1") == 0: shutil.move('wgot', config_path(fn)) gotfile = True + blab(f"Fetched {fn}", 2) if Path('wgot').exists(): shutil.rmtree('wgot') + if gotfile: + blab("Example configuration fetched successfully") + else: + blab("Failed to fetch example configuration", 0) + return gotfile def section_items(cp, sectkey): @@ -217,8 +237,6 @@ def apply_config_ini(cp): # For each ini_use_config item perform an action for ckey in config_keys: - addbase = False - # For a key ending in .ini load and parse another .ini file if ckey.endswith('.ini'): sect = 'base' @@ -278,12 +296,17 @@ else: # # From within PlatformIO use the loaded INI file # - import pioutil - if pioutil.is_pio_build(): - try: - verbose = int(pioutil.env.GetProjectOption('custom_verbose')) - except: - pass + try: + import pioutil + if pioutil.is_pio_build(): + try: + verbose = int(pioutil.env.GetProjectOption('custom_verbose')) + except: + pass - from platformio.project.config import ProjectConfig - apply_config_ini(ProjectConfig()) + from platformio.project.config import ProjectConfig + apply_config_ini(ProjectConfig()) + except AttributeError: + # Handle the 'IsIntegrationDump' error here, or just continue if + # the build is not a PlatformIO build where pioutil would be unavailable. + pass diff --git a/buildroot/share/PlatformIO/scripts/mc-apply.py b/buildroot/share/PlatformIO/scripts/mc-apply.py index 6ec7122688..7d04ad5585 100755 --- a/buildroot/share/PlatformIO/scripts/mc-apply.py +++ b/buildroot/share/PlatformIO/scripts/mc-apply.py @@ -1,32 +1,29 @@ #!/usr/bin/env python3 -# -# mc-apply.py -# -# Apply firmware configuration from a JSON file (marlin_config.json). -# -# usage: mc-apply.py [-h] [--opt] [--verbose] [config_file] -# -# Process Marlin firmware configuration. -# -# positional arguments: -# config_file Path to the configuration file. -# -# optional arguments: -# -h, --help show this help message and exit -# --opt Output as an option setting script. -# --verbose Enable verbose logging (0-2) -# -import json, sys, os, re, shutil, datetime +""" +mc-apply.py + + Apply firmware configuration from a JSON file (marlin_config.json). + + usage: mc-apply.py [-h] [--opt] [--verbose] [config_file] + + Process Marlin firmware configuration. + + positional arguments: + config_file Path to the configuration file. + + optional arguments: + -h, --help Show this help message and exit + --opt Output as an option setting script. + --verbose Enable verbose logging (0-2) +""" + +import json, sys, os, configuration import config import argparse -from pathlib import Path verbose = 0 -def blab(str, level=1): - if verbose >= level: print(f"[mc-apply] {str}") - -def config_path(cpath): - return Path("Marlin", cpath) +def blab(msg, level=1): + if verbose >= level: print(f"[mc-apply] {msg}") def normalize_value(v): """ @@ -55,80 +52,6 @@ def normalize_value(v): else: return ('set', v if not isinstance(v, bool) else v_str) -# Disable all (most) defined options in the configuration files. -def disable_all_options(): - blab("Disabling all configuration options...") - # Create a regex to match the option and capture parts of the line - regex = re.compile(r'^(\s*)(#define\s+)([A-Z0-9_]+\b)(\s?)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) - - # Disable all enabled options in both Config files - for file in ("Configuration.h", "Configuration_adv.h"): - fullpath = config_path(file) - if not fullpath.exists(): - blab(f"File not found: {fullpath}", 0) - continue - - lines = fullpath.read_text(encoding='utf-8').split('\n') - found = False - for i in range(len(lines)): - line = lines[i] - match = regex.match(line) - if match: - name = match[3].upper() - if name in ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXAMPLES_DIR'): continue - if name.startswith('_'): continue - found = True - # Comment out the define - lines[i] = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line) - blab(f"Disable {name}", 2) - - # If the option was found, write the modified lines - if found: - fullpath.write_text('\n'.join(lines), encoding='utf-8') - blab(f"Updated {file}") - -# Fetch configuration files from GitHub given the path. -# Return True if any files were fetched. -def fetch_example(url): - blab(f"Fetching example configuration from: {url}") - if url.endswith("/"): url = url[:-1] - if not url.startswith('http'): - brch = "bugfix-2.1.x" - if '@' in url: url, brch = map(str.strip, url.split('@')) - if url == 'examples/default': url = 'default' - url = f"https://raw.githubusercontent.com/MarlinFirmware/Configurations/{brch}/config/{url}" - url = url.replace("%", "%25").replace(" ", "%20") - - # Find a suitable fetch command - if shutil.which("curl") is not None: - fetch = "curl -L -s -S -f -o" - elif shutil.which("wget") is not None: - fetch = "wget -q -O" - else: - blab("Couldn't find curl or wget", 0) - return False - - # Reset configurations to default - blab("Resetting configurations to default...") - os.system("git checkout HEAD Marlin/*.h") - - # Try to fetch the remote files - gotfile = False - for fn in ("Configuration.h", "Configuration_adv.h", "_Bootscreen.h", "_Statusscreen.h"): - if os.system(f"{fetch} wgot {url}/{fn} >/dev/null 2>&1") == 0: - shutil.move('wgot', config_path(fn)) - gotfile = True - blab(f"Fetched {fn}", 2) - - if Path('wgot').exists(): shutil.rmtree('wgot') - - if gotfile: - blab("Example configuration fetched successfully") - else: - blab("Failed to fetch example configuration", 0) - - return gotfile - def report_version(conf): if 'VERSION' in conf: blab("Configuration version information:") @@ -142,7 +65,7 @@ def write_opt_file(conf, outpath='Marlin/apply_config.sh'): if key in ('__INITIAL_HASH', '__directives__', 'VERSION'): continue # Other keys are assumed to be configs - if not type(val) is dict: + if not isinstance(val, dict): continue # Write config commands to the script file @@ -198,17 +121,17 @@ def process_directives(directives): # Handle [disable] directive if directive == "[disable]": - disable_all_options() + configuration.disable_all_options() # Handle example fetching (examples/path or example/path) elif directive.startswith('examples/') or directive.startswith('example/'): if directive.startswith('example/'): directive = 'examples' + directive[7:] - fetch_example(directive) + configuration.fetch_example(directive) # Handle direct URLs elif directive.startswith('http://') or directive.startswith('https://'): - fetch_example(directive) + configuration.fetch_example(directive) else: blab(f"Unknown directive: {directive}", 0) From ba34902610c41d7cc5ffda6a30924a3f8fa73d8e Mon Sep 17 00:00:00 2001 From: David Buezas Date: Tue, 25 Nov 2025 05:40:27 +0100 Subject: [PATCH 10/39] =?UTF-8?q?=F0=9F=94=A7=20Recommend=20FTM=5FSMOOTHIN?= =?UTF-8?q?G=20+=20FTM=5FSHAPER=5FE=20(#28190)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Warnings.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index e15d053b4e..7f0bc58ea5 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -946,6 +946,12 @@ #endif #if ENABLED(LIN_ADVANCE) #warning "Be aware that FT_MOTION K factor is now set with M900 K (same as LIN_ADVANCE)." + #if DISABLED(FTM_SMOOTHING) + #warning "For higher print quality enable FTM_SMOOTHING with FTM_SMOOTHING_TIME_E to tame Linear Advance accelerations." + #endif + #endif + #if DISABLED(FTM_SHAPER_E) + #warning "For higher print quality enable FTM_SHAPER_E (even if shaper is NONE) to allow axis synchronization." #endif #endif #if ENABLED(FTM_HOME_AND_PROBE) From c1908c865ee42552675c7f745e0ddd6fa8746678 Mon Sep 17 00:00:00 2001 From: Giuliano <3684609+GMagician@users.noreply.github.com> Date: Tue, 25 Nov 2025 05:43:18 +0100 Subject: [PATCH 11/39] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20case=20light=20menu?= =?UTF-8?q?=20build=20(2)=20(#28185)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #28143 --- Marlin/src/lcd/menu/menu_led.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index d4807439df..0d46f4d3ff 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -105,9 +105,11 @@ void menu_led_custom() { #if ENABLED(NEOPIXEL2_SEPARATE) STATIC_ITEM_N(1, MSG_LED_CHANNEL_N, SS_DEFAULT|SS_INVERT); #endif - EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); - EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); - EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true); + #if ENABLED(LED_CONTROL_MENU) + EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); + EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true); + #endif #if HAS_WHITE_LED EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true); #endif From 38d9b97bbdd61ada4bb547fb31e5439baffb73f1 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 25 Nov 2025 06:29:28 +0000 Subject: [PATCH 12/39] [cron] Bump distribution date (2025-11-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 9ff5e45d02..47480dbe70 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 "2025-11-24" +//#define STRING_DISTRIBUTION_DATE "2025-11-25" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index eb8cab633b..3c983a9f10 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 "2025-11-24" + #define STRING_DISTRIBUTION_DATE "2025-11-25" #endif /** From 1f38b509e121212e0500fcf42edc78bb52f80e5f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 25 Nov 2025 14:35:15 -0600 Subject: [PATCH 13/39] =?UTF-8?q?=F0=9F=94=A7=20Update=20FAN=20pins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_3.h | 2 +- Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_X_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_3.h b/Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_3.h index 8df334d740..c5189dd6dc 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_3.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_3.h @@ -111,7 +111,7 @@ #define HEATER_0_PIN PA6 // HEATER1 #define HEATER_BED_PIN PA5 // HOT BED -#define FAN_PIN PB0 // FAN +#define FAN0_PIN PB0 // FAN //#define FAN1_PIN PA7 // FAN1 #if NEED_TOUCH_PINS diff --git a/Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_X_common.h b/Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_X_common.h index 39d1de237e..d5883ade59 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_X_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_NEPTUNE_X_common.h @@ -133,7 +133,7 @@ #define HEATER_1_PIN PB0 // HEATER2 #define HEATER_BED_PIN PA0 // HOT BED -#define FAN_PIN PC14 // FAN +#define FAN0_PIN PC14 // FAN #define FAN1_PIN PB1 // FAN1 // From 5bbf9537114e2eaae0f90eda8181b100b05b7ae4 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Wed, 26 Nov 2025 00:32:42 +0000 Subject: [PATCH 14/39] [cron] Bump distribution date (2025-11-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 47480dbe70..3a3b6a57b7 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 "2025-11-25" +//#define STRING_DISTRIBUTION_DATE "2025-11-26" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 3c983a9f10..b1cb664d41 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 "2025-11-25" + #define STRING_DISTRIBUTION_DATE "2025-11-26" #endif /** From 1832500eca4a8ee1f63b7bdac75a7473a3b4eee3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Nov 2025 21:34:09 -0600 Subject: [PATCH 15/39] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Singl?= =?UTF-8?q?e=20endstop=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/endstops.h | 5 +++++ Marlin/src/module/motion.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index ab124c3536..4d7a444bc4 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -221,6 +221,11 @@ class Endstops { ; } + /** + * Get a particular endstop state + */ + FORCE_INLINE static bool state(const EndstopEnum es) { return TEST(state(), es); } + static bool probe_switch_activated() { return (true #if ENABLED(PROBE_ACTIVATION_SWITCH) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 42d673db93..0a3a5a5f5e 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -2574,7 +2574,7 @@ void prepare_line_to_destination() { } #endif - if (TEST(endstops.state(), es)) { + if (endstops.state(es)) { SERIAL_ECHO_MSG("Bad ", C(AXIS_CHAR(axis)), " Endstop?"); kill(GET_TEXT_F(MSG_KILL_HOMING_FAILED)); } From c420a0b96a092809f2170f65159eca3172658691 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Nov 2025 21:33:50 -0600 Subject: [PATCH 16/39] =?UTF-8?q?=F0=9F=8E=A8=20Comments,=20refinements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/LPC1768/timers.h | 12 ++-- Marlin/src/HAL/STM32/timers.h | 2 +- Marlin/src/core/types.h | 8 ++- Marlin/src/inc/Conditionals-4-adv.h | 2 +- Marlin/src/inc/SanityCheck.h | 25 -------- Marlin/src/module/ft_motion.h | 2 +- Marlin/src/module/ft_motion/stepping.h | 3 +- Marlin/src/module/stepper.cpp | 83 ++++++++++++++++++++++---- Marlin/src/module/stepper.h | 3 +- buildroot/tests/I3DBEEZ9_V1 | 2 +- 10 files changed, 92 insertions(+), 50 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/timers.h b/Marlin/src/HAL/LPC1768/timers.h index b34f5e7907..eae2cd587e 100644 --- a/Marlin/src/HAL/LPC1768/timers.h +++ b/Marlin/src/HAL/LPC1768/timers.h @@ -59,7 +59,7 @@ typedef uint32_t hal_timer_t; #define HAL_TIMER_TYPE_MAX 0xFFFFFFFFUL -#define HAL_TIMER_RATE ((F_CPU) / 4) // frequency of timers peripherals +#define HAL_TIMER_RATE ((F_CPU) / 4) // (Hz) Frequency of timers peripherals #ifndef MF_TIMER_STEP #define MF_TIMER_STEP 0 // Timer Index for Stepper @@ -74,11 +74,13 @@ typedef uint32_t hal_timer_t; #define MF_TIMER_PWM 3 // Timer Index for PWM #endif -#define TEMP_TIMER_RATE 1000000 -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TEMP_TIMER_RATE 1000000 // 1MHz +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency -#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs +#ifndef STEPPER_TIMER_RATE + #define STEPPER_TIMER_RATE HAL_TIMER_RATE // (Hz) Frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#endif +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // Stepper Timer ticks per µs #define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) #define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer diff --git a/Marlin/src/HAL/STM32/timers.h b/Marlin/src/HAL/STM32/timers.h index 9861c45200..70e0bcd4a5 100644 --- a/Marlin/src/HAL/STM32/timers.h +++ b/Marlin/src/HAL/STM32/timers.h @@ -38,7 +38,7 @@ // of adding a run-time check and HAL_TIMER_TYPE_MAX is refactored to allow unique // values for each timer. #define hal_timer_t uint32_t -#define HAL_TIMER_TYPE_MAX UINT16_MAX +#define HAL_TIMER_TYPE_MAX hal_timer_t(UINT16_MAX) // Marlin timer_instance[] content (unrelated to timer selection) #define MF_TIMER_STEP 0 // Timer Index for Stepper diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index c48e0ffe68..173ab7fbd6 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -50,6 +50,7 @@ template struct IF { typedef L type; }; #define NUM_AXIS_DECL_LC(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 MAIN_AXIS_NAMES NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W) #define MAIN_AXIS_NAMES_LC NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w) +#define NUM_AXIS_CALL(G) do { NUM_AXIS_CODE(G(X_AXIS), G(Y_AXIS), G(Z_AXIS), G(I_AXIS), G(J_AXIS), G(K_AXIS), G(U_AXIS), G(V_AXIS), G(W_AXIS)); } while(0) #define STR_AXES_MAIN NUM_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K, STR_U, STR_V, STR_W) #define LOGICAL_AXIS_GANG(N,V...) NUM_AXIS_GANG(V) GANG_ITEM_E(N) @@ -68,6 +69,7 @@ template struct IF { typedef L type; }; #define LOGICAL_AXIS_NAMES_LC LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w) #define LOGICAL_AXIS_MAP(F) MAP(F, LOGICAL_AXIS_NAMES) #define LOGICAL_AXIS_MAP_LC(F) MAP(F, LOGICAL_AXIS_NAMES_LC) +#define LOGICAL_AXIS_CALL(G) do { LOGICAL_AXIS_CODE(G(E_AXIS), G(X_AXIS), G(Y_AXIS), G(Z_AXIS), G(I_AXIS), G(J_AXIS), G(K_AXIS), G(U_AXIS), G(V_AXIS), G(W_AXIS)); } while(0) #define STR_AXES_LOGICAL LOGICAL_AXIS_GANG("E", "X", "Y", "Z", STR_I, STR_J, STR_K, STR_U, STR_V, STR_W) #define NUM_AXIS_PAIRED_LIST(V...) LIST_N(DOUBLE(NUM_AXES), V) @@ -814,8 +816,9 @@ struct XYZval { 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 &p) { NUM_AXIS_CODE(x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZval& operator*=(const float p) { NUM_AXIS_CODE(x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } FI XYZval& operator*=(const int &p) { NUM_AXIS_CODE(x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZval& operator/=(const float p) { NUM_AXIS_CODE(x /= p, y /= p, z /= p, i /= p, j /= p, k /= p, u /= p, v /= p, w /= p); return *this; } FI XYZval& operator>>=(const int &p) { NUM_AXIS_CODE(_RSE(x), _RSE(y), _RSE(z), _RSE(i), _RSE(j), _RSE(k), _RSE(u), _RSE(v), _RSE(w)); return *this; } FI XYZval& operator<<=(const int &p) { NUM_AXIS_CODE(_LSE(x), _LSE(y), _LSE(z), _LSE(i), _LSE(j), _LSE(k), _LSE(u), _LSE(v), _LSE(w)); return *this; } @@ -986,7 +989,10 @@ struct XYZEval { 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 &p) { LOGICAL_AXIS_CODE(e += p, x += p, y += p, z += p, i += p, j += p, k += p, u += p, v += p, w += p); return *this; } + FI XYZEval& operator-=(const T &p) { LOGICAL_AXIS_CODE(e -= p, x -= p, y -= p, z -= p, i -= p, j -= p, k -= p, u -= p, v -= p, w -= p); return *this; } FI XYZEval& operator*=(const T &p) { LOGICAL_AXIS_CODE(e *= p, x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZEval& operator/=(const T &p) { LOGICAL_AXIS_CODE(e /= p, x /= p, y /= p, z /= p, i /= p, j /= p, k /= p, u /= p, v /= p, w /= p); return *this; } FI XYZEval& operator>>=(const int &p) { LOGICAL_AXIS_CODE(_RSE(e), _RSE(x), _RSE(y), _RSE(z), _RSE(i), _RSE(j), _RSE(k), _RSE(u), _RSE(v), _RSE(w)); return *this; } FI XYZEval& operator<<=(const int &p) { LOGICAL_AXIS_CODE(_LSE(e), _LSE(x), _LSE(y), _LSE(z), _LSE(i), _LSE(j), _LSE(k), _LSE(u), _LSE(v), _LSE(w)); return *this; } diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index 8770f6bf9b..6bac442308 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -1526,7 +1526,7 @@ #define HAS_ZV_SHAPING 1 #endif -// FT Motion unified window and batch size +// FT Motion: Shapers #if ENABLED(FT_MOTION) #if HAS_X_AXIS #define HAS_FTM_SHAPING 1 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 474e51a7ec..868b0e9fb8 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -47,31 +47,6 @@ #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 -#define TEST2 1 -#define TEST3 0 -#define TEST4 true -#if ENABLED(TEST0) || !ENABLED(TEST2) || ENABLED(TEST3) || !ENABLED(TEST1, TEST2, TEST4) - #error "ENABLED is borked!" -#endif -#if ALL(TEST0, TEST1) - #error "ALL is borked!" -#endif -#if DISABLED(TEST1) || !DISABLED(TEST3) || DISABLED(TEST4) || DISABLED(TEST0, TEST1, TEST2, TEST4) || !DISABLED(TEST0, TEST3) - #error "DISABLED is borked!" -#endif -#if !ANY(TEST1, TEST2, TEST3, TEST4) || ANY(TEST0, TEST3) - #error "ANY is borked!" -#endif -#if NONE(TEST0, TEST1, TEST2, TEST4) || !NONE(TEST0, TEST3) - #error "NONE is borked!" -#endif -#undef TEST1 -#undef TEST2 -#undef TEST3 -#undef TEST4 - /** * This is to alert you about non-matching versions of config files. * diff --git a/Marlin/src/module/ft_motion.h b/Marlin/src/module/ft_motion.h index 6e5b36cbe4..d839869058 100644 --- a/Marlin/src/module/ft_motion.h +++ b/Marlin/src/module/ft_motion.h @@ -185,7 +185,6 @@ class FTMotion { return cfg.active ? axis_move_dir[axis] : stepper.last_direction_bits[axis]; } - static stepping_t stepping; FORCE_INLINE static bool stepper_plan_is_empty() { return stepper_plan_head == stepper_plan_tail; @@ -261,6 +260,7 @@ class FTMotion { static stepper_plan_t stepper_plan_buff[FTM_BUFFER_SIZE]; static uint32_t stepper_plan_tail, stepper_plan_head; static XYZEval curr_steps_q32_32; + }; // class FTMotion extern FTMotion ftMotion; // Use ftMotion.thing, not FTMotion::thing. diff --git a/Marlin/src/module/ft_motion/stepping.h b/Marlin/src/module/ft_motion/stepping.h index 2b9ad3a21a..fc3a5858fd 100644 --- a/Marlin/src/module/ft_motion/stepping.h +++ b/Marlin/src/module/ft_motion/stepping.h @@ -29,7 +29,7 @@ typedef struct stepper_plan { void reset() { advance_dividend_q0_32.reset(); } } stepper_plan_t; -// Stepping plan handles steps for a while frame (trajectory point delta) +// Stepping plan handles steps for a whole frame (trajectory point delta) typedef struct Stepping { stepper_plan_t stepper_plan; xyze_ulong_t advance_dividend_reciprocal{0}; // Note this 32 bit reciprocal underestimates quotients by at most one. @@ -49,4 +49,5 @@ typedef struct Stepping { #define INTERVAL_PER_ITERATION (STEPPER_TIMER_RATE / FTM_STEPPER_FS) #define INTERVAL_PER_TRAJ_POINT (STEPPER_TIMER_RATE / FTM_FS) #define ITERATIONS_PER_TRAJ (FTM_STEPPER_FS * FTM_TS) + } stepping_t; diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index b6d79dfac7..3d51ce5e4b 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -169,14 +169,23 @@ bool Stepper::abort_current_block; // In timer_ticks uint32_t Stepper::acceleration_time, Stepper::deceleration_time; +/** + * Standard Motion Multi-Stepping Limit (or 1) + */ #if MULTISTEPPING_LIMIT > 1 uint8_t Stepper::steps_per_isr = 1; // Count of steps to perform per Stepper ISR call #endif +/** + * Standard Motion Legacy Adaptive Multi-stepping - Automatically adjust steps-per-ISR to avoid ISR overhead + */ #if DISABLED(OLD_ADAPTIVE_MULTISTEPPING) hal_timer_t Stepper::time_spent_in_isr = 0, Stepper::time_spent_out_isr = 0; #endif +/** + * Standard Motion Adaptive Step Smoothing - Ensure that moves use a higher time resolution + */ #if ENABLED(ADAPTIVE_STEP_SMOOTHING) #if ENABLED(ADAPTIVE_STEP_SMOOTHING_TOGGLE) bool Stepper::adaptive_step_smoothing_enabled; // Initialized by settings.load @@ -193,8 +202,8 @@ uint32_t Stepper::acceleration_time, Stepper::deceleration_time; bool Stepper::frozen; // = false #endif +// Delta error variables for the Bresenham line tracer xyze_long_t Stepper::delta_error{0}; - xyze_long_t Stepper::advance_dividend{0}; uint32_t Stepper::advance_divisor = 0, Stepper::step_events_completed = 0, // The number of step events executed in the current block @@ -202,12 +211,18 @@ uint32_t Stepper::advance_divisor = 0, Stepper::decelerate_start, // The count at which to start decelerating Stepper::step_event_count; // The total event count for the current block +/** + * The pertinent extruder for Stepper operations, as copied from the current block. + */ #if ANY(HAS_MULTI_EXTRUDER, MIXING_EXTRUDER) uint8_t Stepper::stepper_extruder; #else constexpr uint8_t Stepper::stepper_extruder; #endif +/** + * Standard Motion S-Curve / Bezier Curve Acceleration + */ #if ENABLED(S_CURVE_ACCELERATION) int32_t __attribute__((used)) Stepper::bezier_A __asm__("bezier_A"); // A coefficient in Bézier speed curve with alias for assembler int32_t __attribute__((used)) Stepper::bezier_B __asm__("bezier_B"); // B coefficient in Bézier speed curve with alias for assembler @@ -220,20 +235,26 @@ uint32_t Stepper::advance_divisor = 0, bool Stepper::bezier_2nd_half; // =false If Bézier curve has been initialized or not #endif +/** + * Standard Motion Linear Advance state + */ #if ENABLED(LIN_ADVANCE) hal_timer_t Stepper::nextAdvanceISR = LA_ADV_NEVER, Stepper::la_interval = LA_ADV_NEVER; - #if HAS_ROUGH_LIN_ADVANCE + #if ENABLED(SMOOTH_LIN_ADVANCE) + uint32_t Stepper::curr_step_rate, + Stepper::curr_timer_tick = 0; + #else int32_t Stepper::la_delta_error = 0, Stepper::la_dividend = 0, Stepper::la_advance_steps = 0; bool Stepper::la_active = false; - #else - uint32_t Stepper::curr_step_rate, - Stepper::curr_timer_tick = 0; #endif #endif +/** + * Standard Motion Non-linear Exttrusion state + */ #if ENABLED(NONLINEAR_EXTRUSION) nonlinear_t Stepper::ne; // Initialized by settings.load #endif @@ -279,12 +300,31 @@ xyz_long_t Stepper::endstops_trigsteps; xyze_long_t Stepper::count_position{0}; xyze_int8_t Stepper::count_direction{0}; +// Axis moving towards MIN/MAX #define MINDIR(A) (count_direction[_AXIS(A)] < 0) #define MAXDIR(A) (count_direction[_AXIS(A)] > 0) -#define STEPTEST(A,M,I) TERN0(USE_##A##I##_##M, !(TEST(endstops.state(), A##I##_##M) && M## DIR(A)) && !locked_ ##A##I##_motor) +// +// STEPTEST macro +// +// Test Axis, Min/Max, [Index] endstop state for unlocked motors +// Test used to decide whether to step a motor if it... +// - Does not have a triggered endstop +// - Are not locked (as with dual stepper alignment) +// Example: STEPTEST(X,MAX,2) => TERN0(USE_X2_MAX, !(endstops.state(X2_MAX) && (count_direction[_AXIS(X)] > 0)) && !locked_X2_motor) +// See also: LCD_ENDSTOP_TEST in lcd/menu/menu_configuration.cpp +// +#define STEPTEST(A,M,I) TERN0(USE_##A##I##_##M, !(endstops.state(A##I##_##M) && M## DIR(A)) && !locked_ ##A##I##_motor) + +// Direct Stepping wrapper for use in SOME_*_APPLY_STEP below: #define _STEP_WRITE(A,I,V) A##I##_STEP_WRITE(V) +// +// ENDSTOP / SEPARATE _APPLY_STEP(AXIS,STEPVAL) +// - ENDSTOP pertains to multi-endstop +// Using endstop states defined by STEP_STATE_[AXIS] in config +// - SEPARATE pertains to locking alignment +// #define DUAL_ENDSTOP_APPLY_STEP(A,V) \ if (separate_multi_axis) { \ if (ENABLED(A##_HOME_TO_MIN)) { \ @@ -382,6 +422,8 @@ xyze_int8_t Stepper::count_direction{0}; #define X_APPLY_DIR(FWD,Q) do{ X_DIR_WRITE(FWD); X2_DIR_WRITE(INVERT_DIR(X2_VS_X, FWD)); }while(0) #if ENABLED(X_DUAL_ENDSTOPS) #define X_APPLY_STEP(STATE,Q) DUAL_ENDSTOP_APPLY_STEP(X,STATE) + #elif ENABLED(X_STEPPER_AUTO_ALIGN) + #define X_APPLY_STEP(STATE,Q) DUAL_SEPARATE_APPLY_STEP(X,STATE) #else #define X_APPLY_STEP(STATE,Q) do{ X_STEP_WRITE(STATE); X2_STEP_WRITE(STATE); }while(0) #endif @@ -403,6 +445,8 @@ xyze_int8_t Stepper::count_direction{0}; #define Y_APPLY_DIR(FWD,Q) do{ Y_DIR_WRITE(FWD); Y2_DIR_WRITE(INVERT_DIR(Y2_VS_Y, FWD)); }while(0) #if ENABLED(Y_DUAL_ENDSTOPS) #define Y_APPLY_STEP(STATE,Q) DUAL_ENDSTOP_APPLY_STEP(Y,STATE) + #elif ENABLED(Y_STEPPER_AUTO_ALIGN) + #define Y_APPLY_STEP(STATE,Q) DUAL_SEPARATE_APPLY_STEP(Y,STATE) #else #define Y_APPLY_STEP(STATE,Q) do{ Y_STEP_WRITE(STATE); Y2_STEP_WRITE(STATE); }while(0) #endif @@ -1554,21 +1598,34 @@ void Stepper::isr() { #if ENABLED(FT_MOTION) if (using_ftMotion) { + // Time to run stepping and apply STEP/DIR pulses? if (!ftMotion_nextStepperISR) ftMotion_stepper(); - TERN_(BABYSTEPPING, if (!nextBabystepISR) nextBabystepISR = babystepping_isr()); - // ^== Time critical. NOTHING besides pulse generation should be above here!!! + // Piggyback babystepping to existing ISR + #if ENABLED(BABYSTEPPING) + // Time to run babystepping and apply STEP/DIR pulses? + // babystepping_isr -> babystep.task -> [ babystep.step_axis(*) -> stepper.do_babystep ] + if (nextBabystepISR < (BABYSTEP_TICKS / 10)) nextBabystepISR = babystepping_isr(); + #endif + + // ^ + // ^ Time critical! NOTHING besides pulse generation should be above here!!! + // ^ // Enable ISRs to reduce latency for higher priority ISRs hal.isr_on(); - if (!ftMotion_nextStepperISR) ftMotion_nextStepperISR = ftMotion.stepping.plan(); + // Get time until next FTM stepping event + if (!ftMotion_nextStepperISR) ftMotion_nextStepperISR = ftMotion.stepping.advance_until_step(); interval = HAL_TIMER_TYPE_MAX; // Time until the next step NOMORE(interval, ftMotion_nextStepperISR); - TERN_(BABYSTEPPING, NOMORE(interval, nextBabystepISR)); - TERN_(BABYSTEPPING, nextBabystepISR -= interval); + #if ENABLED(BABYSTEPPING) + NOMORE(interval, nextBabystepISR); // Babystepping may want to return earlier + nextBabystepISR -= interval; + #endif + ftMotion_nextStepperISR -= interval; } @@ -1590,6 +1647,8 @@ void Stepper::isr() { #endif #if ENABLED(BABYSTEPPING) + // Time to run babystepping and apply STEP/DIR pulses? + // babystepping_isr -> babystep.task -> [ babystep.step_axis(*) -> stepper.do_babystep ] const bool is_babystep = (nextBabystepISR == 0); // 0 = Do Babystepping (XY)Z pulses if (is_babystep) nextBabystepISR = babystepping_isr(); #endif @@ -3657,8 +3716,6 @@ void Stepper::report_positions() { // Replace last_direction_bits with current dir bits for all stepped axes last_direction_bits = (last_direction_bits & ~step_bits) | (dir_bits & step_bits); - //#define _FTM_SET_DIR(A) if (step_bits.A) last_direction_bits.A = dir_bits.A; - //LOGICAL_AXIS_MAP(_FTM_SET_DIR); if (last_set_direction != last_direction_bits) { // Apply directions (generally applying to the entire linear move) diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index d1132face6..b04980cb1e 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -405,6 +405,7 @@ class Stepper { static bool abort_current_block; // Signals to the stepper that current block should be aborted + // Motor locking for independent movement of multi-stepper axes #if ENABLED(X_DUAL_ENDSTOPS) static bool locked_X_motor, locked_X2_motor; #endif @@ -422,7 +423,7 @@ class Stepper { ; #endif - static uint32_t acceleration_time, deceleration_time; // time measured in Stepper Timer ticks + static uint32_t acceleration_time, deceleration_time; // Time measured in Stepper Timer ticks #if MULTISTEPPING_LIMIT == 1 static constexpr uint8_t steps_per_isr = 1; // Count of steps to perform per Stepper ISR call diff --git a/buildroot/tests/I3DBEEZ9_V1 b/buildroot/tests/I3DBEEZ9_V1 index 8cc91901c1..4cf64ec044 100755 --- a/buildroot/tests/I3DBEEZ9_V1 +++ b/buildroot/tests/I3DBEEZ9_V1 @@ -20,7 +20,7 @@ opt_set MOTHERBOARD BOARD_I3DBEEZ9_V1 SERIAL_PORT -1 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 opt_enable FT_MOTION FTM_SMOOTHING FTM_HOME_AND_PROBE FT_MOTION_MENU FTM_RESONANCE_TEST EMERGENCY_PARSER \ BLTOUCH EEPROM_SETTINGS AUTO_BED_LEVELING_3POINT Z_SAFE_HOMING PINS_DEBUGGING -exec_test $1 $2 "I3DBEE Z9 Board | 3 Extruders | Auto-Fan | BLTOUCH | Mixed TMC" "$3" +exec_test $1 $2 "I3DBEE Z9 Board | 3 Extruders | Auto-Fan | Mixed TMC | FT Motion | BLTOUCH" "$3" restore_configs opt_set MOTHERBOARD BOARD_I3DBEEZ9_V1 SERIAL_PORT -1 \ From 2700af52c8791f6af2e1a3cbbfe30bfbb388ba1e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Nov 2025 21:35:05 -0600 Subject: [PATCH 17/39] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20TERF?= =?UTF-8?q?=20-=20Single=20line=20shorthand?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/macros.h | 5 +- Marlin/src/module/stepper.cpp | 108 +++++------------ Marlin/src/module/temperature.cpp | 187 ++++++++---------------------- 3 files changed, 77 insertions(+), 223 deletions(-) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 29a625dbc3..4f6b1df98b 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -209,7 +209,10 @@ // "Ternary" that emits or omits the given content #define EMIT(V...) V #define OMIT(...) -#define TERN_(O,A) _TERN(_ENA_1(O),OMIT,EMIT)(A) // OPTION ? 'A' : '' +#define TERN_(O,A) TERF(O,EMIT)(A) // OPTION ? 'A' : '' ; Usage: TERN_(OPTION, EMITTHIS) + +// Call G(...) or swallow with OMIT(...) +#define TERF(O,G) _TERN(_ENA_1(O),OMIT,G) // OPTION ? 'G' : 'OMIT' ; Usage: TERF(OPTION, CALLTHIS)(ARGS...) // Macros to conditionally emit array items and function arguments #define _OPTITEM(A...) A, diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 3d51ce5e4b..ca6f027ade 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2041,33 +2041,15 @@ void Stepper::pulse_phase_isr() { const uint32_t advance_divisor_cached = advance_divisor; // Determine if pulses are needed - #if HAS_X_STEP - PULSE_PREP(X); - #endif - #if HAS_Y_STEP - PULSE_PREP(Y); - #endif - #if HAS_Z_STEP - PULSE_PREP(Z); - #endif - #if HAS_I_STEP - PULSE_PREP(I); - #endif - #if HAS_J_STEP - PULSE_PREP(J); - #endif - #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 + TERF(HAS_X_STEP, PULSE_PREP)(X); + TERF(HAS_Y_STEP, PULSE_PREP)(Y); + TERF(HAS_Z_STEP, PULSE_PREP)(Z); + TERF(HAS_I_STEP, PULSE_PREP)(I); + TERF(HAS_J_STEP, PULSE_PREP)(J); + TERF(HAS_K_STEP, PULSE_PREP)(K); + TERF(HAS_U_STEP, PULSE_PREP)(U); + TERF(HAS_V_STEP, PULSE_PREP)(V); + TERF(HAS_W_STEP, PULSE_PREP)(W); #if ANY(HAS_E0_STEP, MIXING_EXTRUDER) PULSE_PREP(E); @@ -2117,33 +2099,15 @@ void Stepper::pulse_phase_isr() { #endif // Pulse start - #if HAS_X_STEP - PULSE_START(X); - #endif - #if HAS_Y_STEP - PULSE_START(Y); - #endif - #if HAS_Z_STEP - PULSE_START(Z); - #endif - #if HAS_I_STEP - PULSE_START(I); - #endif - #if HAS_J_STEP - PULSE_START(J); - #endif - #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 + TERF(HAS_X_STEP, PULSE_START)(X); + TERF(HAS_Y_STEP, PULSE_START)(Y); + TERF(HAS_Z_STEP, PULSE_START)(Z); + TERF(HAS_I_STEP, PULSE_START)(I); + TERF(HAS_J_STEP, PULSE_START)(J); + TERF(HAS_K_STEP, PULSE_START)(K); + TERF(HAS_U_STEP, PULSE_START)(U); + TERF(HAS_V_STEP, PULSE_START)(V); + TERF(HAS_W_STEP, PULSE_START)(W); #if ENABLED(MIXING_EXTRUDER) if (step_needed.e) { @@ -2163,33 +2127,15 @@ void Stepper::pulse_phase_isr() { #endif // Pulse stop - #if HAS_X_STEP - PULSE_STOP(X); - #endif - #if HAS_Y_STEP - PULSE_STOP(Y); - #endif - #if HAS_Z_STEP - PULSE_STOP(Z); - #endif - #if HAS_I_STEP - PULSE_STOP(I); - #endif - #if HAS_J_STEP - PULSE_STOP(J); - #endif - #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 + TERF(HAS_X_STEP, PULSE_STOP)(X); + TERF(HAS_Y_STEP, PULSE_STOP)(Y); + TERF(HAS_Z_STEP, PULSE_STOP)(Z); + TERF(HAS_I_STEP, PULSE_STOP)(I); + TERF(HAS_J_STEP, PULSE_STOP)(J); + TERF(HAS_K_STEP, PULSE_STOP)(K); + TERF(HAS_U_STEP, PULSE_STOP)(U); + TERF(HAS_V_STEP, PULSE_STOP)(V); + TERF(HAS_W_STEP, PULSE_STOP)(W); #if ENABLED(MIXING_EXTRUDER) if (step_needed.e) E_STEP_WRITE(mixer.get_stepper(), !STEP_STATE_E); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 5d5ccd3e4d..418f8c498a 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3131,27 +3131,14 @@ void Temperature::init() { OUT_WRITE(HEATER_0_PIN, ENABLED(HEATER_0_INVERTING)); #endif #endif - #if HAS_HEATER_1 - OUT_WRITE(HEATER_1_PIN, ENABLED(HEATER_1_INVERTING)); - #endif - #if HAS_HEATER_2 - OUT_WRITE(HEATER_2_PIN, ENABLED(HEATER_2_INVERTING)); - #endif - #if HAS_HEATER_3 - OUT_WRITE(HEATER_3_PIN, ENABLED(HEATER_3_INVERTING)); - #endif - #if HAS_HEATER_4 - OUT_WRITE(HEATER_4_PIN, ENABLED(HEATER_4_INVERTING)); - #endif - #if HAS_HEATER_5 - OUT_WRITE(HEATER_5_PIN, ENABLED(HEATER_5_INVERTING)); - #endif - #if HAS_HEATER_6 - OUT_WRITE(HEATER_6_PIN, ENABLED(HEATER_6_INVERTING)); - #endif - #if HAS_HEATER_7 - OUT_WRITE(HEATER_7_PIN, ENABLED(HEATER_7_INVERTING)); - #endif + + TERF(HAS_HEATER_1, OUT_WRITE)(HEATER_1_PIN, ENABLED(HEATER_1_INVERTING)); + TERF(HAS_HEATER_2, OUT_WRITE)(HEATER_2_PIN, ENABLED(HEATER_2_INVERTING)); + TERF(HAS_HEATER_3, OUT_WRITE)(HEATER_3_PIN, ENABLED(HEATER_3_INVERTING)); + TERF(HAS_HEATER_4, OUT_WRITE)(HEATER_4_PIN, ENABLED(HEATER_4_INVERTING)); + TERF(HAS_HEATER_5, OUT_WRITE)(HEATER_5_PIN, ENABLED(HEATER_5_INVERTING)); + TERF(HAS_HEATER_6, OUT_WRITE)(HEATER_6_PIN, ENABLED(HEATER_6_INVERTING)); + TERF(HAS_HEATER_7, OUT_WRITE)(HEATER_7_PIN, ENABLED(HEATER_7_INVERTING)); #if HAS_HEATED_BED #if ENABLED(PELTIER_BED) @@ -3173,33 +3160,15 @@ void Temperature::init() { OUT_WRITE(COOLER_PIN, ENABLED(COOLER_INVERTING)); #endif - #if HAS_FAN0 - INIT_FAN_PIN(FAN0_PIN); - #endif - #if HAS_FAN1 - INIT_FAN_PIN(FAN1_PIN); - #endif - #if HAS_FAN2 - INIT_FAN_PIN(FAN2_PIN); - #endif - #if HAS_FAN3 - INIT_FAN_PIN(FAN3_PIN); - #endif - #if HAS_FAN4 - INIT_FAN_PIN(FAN4_PIN); - #endif - #if HAS_FAN5 - INIT_FAN_PIN(FAN5_PIN); - #endif - #if HAS_FAN6 - INIT_FAN_PIN(FAN6_PIN); - #endif - #if HAS_FAN7 - INIT_FAN_PIN(FAN7_PIN); - #endif - #if ENABLED(USE_CONTROLLER_FAN) - INIT_FAN_PIN(CONTROLLER_FAN_PIN); - #endif + TERF(HAS_FAN0, INIT_FAN_PIN)(FAN0_PIN); + TERF(HAS_FAN1, INIT_FAN_PIN)(FAN1_PIN); + TERF(HAS_FAN2, INIT_FAN_PIN)(FAN2_PIN); + TERF(HAS_FAN3, INIT_FAN_PIN)(FAN3_PIN); + TERF(HAS_FAN4, INIT_FAN_PIN)(FAN4_PIN); + TERF(HAS_FAN5, INIT_FAN_PIN)(FAN5_PIN); + TERF(HAS_FAN6, INIT_FAN_PIN)(FAN6_PIN); + TERF(HAS_FAN7, INIT_FAN_PIN)(FAN7_PIN); + TERF(USE_CONTROLLER_FAN, INIT_FAN_PIN)(CONTROLLER_FAN_PIN); TERN_(HAS_MAXTC_SW_SPI, max_tc_spi.init()); @@ -3229,9 +3198,7 @@ void Temperature::init() { TERN_(POWER_MONITOR_CURRENT, hal.adc_enable(POWER_MONITOR_CURRENT_PIN)); TERN_(POWER_MONITOR_VOLTAGE, hal.adc_enable(POWER_MONITOR_VOLTAGE_PIN)); - #if HAS_JOY_ADC_EN - SET_INPUT_PULLUP(JOY_EN_PIN); - #endif + TERF(HAS_JOY_ADC_EN, SET_INPUT_PULLUP)(JOY_EN_PIN); HAL_timer_start(MF_TIMER_TEMP, TEMP_TIMER_FREQUENCY); ENABLE_TEMPERATURE_INTERRUPT(); @@ -4140,18 +4107,12 @@ void Temperature::isr() { #if HAS_HEATED_BED _PWM_MOD(BED, soft_pwm_bed, temp_bed); - #if ENABLED(PELTIER_BED) - WRITE_PELTIER_DIR(temp_bed.peltier_dir_heating); - #endif + TERF(PELTIER_BED, WRITE_PELTIER_DIR)(temp_bed.peltier_dir_heating); #endif - #if HAS_HEATED_CHAMBER - _PWM_MOD(CHAMBER, soft_pwm_chamber, temp_chamber); - #endif + TERF(HAS_HEATED_CHAMBER, _PWM_MOD)(CHAMBER, soft_pwm_chamber, temp_chamber); - #if HAS_COOLER - _PWM_MOD(COOLER, soft_pwm_cooler, temp_cooler); - #endif + TERF(HAS_COOLER, _PWM_MOD)(COOLER, soft_pwm_cooler, temp_cooler); #if ENABLED(FAN_SOFT_PWM) @@ -4165,30 +4126,14 @@ void Temperature::isr() { WRITE_FAN(N, spcf > pwm_mask ? HIGH : LOW); \ }while(0) - #if HAS_FAN0 - _FAN_PWM(0); - #endif - #if HAS_FAN1 - _FAN_PWM(1); - #endif - #if HAS_FAN2 - _FAN_PWM(2); - #endif - #if HAS_FAN3 - _FAN_PWM(3); - #endif - #if HAS_FAN4 - _FAN_PWM(4); - #endif - #if HAS_FAN5 - _FAN_PWM(5); - #endif - #if HAS_FAN6 - _FAN_PWM(6); - #endif - #if HAS_FAN7 - _FAN_PWM(7); - #endif + TERF(HAS_FAN0, _FAN_PWM)(0); + TERF(HAS_FAN1, _FAN_PWM)(1); + TERF(HAS_FAN2, _FAN_PWM)(2); + TERF(HAS_FAN3, _FAN_PWM)(3); + TERF(HAS_FAN4, _FAN_PWM)(4); + TERF(HAS_FAN5, _FAN_PWM)(5); + TERF(HAS_FAN6, _FAN_PWM)(6); + TERF(HAS_FAN7, _FAN_PWM)(7); #endif } else { @@ -4198,17 +4143,9 @@ void Temperature::isr() { REPEAT(HOTENDS, _PWM_LOW_E); #endif - #if HAS_HEATED_BED - _PWM_LOW(BED, soft_pwm_bed); - #endif - - #if HAS_HEATED_CHAMBER - _PWM_LOW(CHAMBER, soft_pwm_chamber); - #endif - - #if HAS_COOLER - _PWM_LOW(COOLER, soft_pwm_cooler); - #endif + TERF(HAS_HEATED_BED, _PWM_LOW)(BED, soft_pwm_bed); + TERF(HAS_HEATED_CHAMBER, _PWM_LOW)(CHAMBER, soft_pwm_chamber); + TERF(HAS_COOLER, _PWM_LOW)(COOLER, soft_pwm_cooler); #if ENABLED(FAN_SOFT_PWM) #if HAS_FAN0 @@ -4271,17 +4208,9 @@ void Temperature::isr() { REPEAT(HOTENDS, _SLOW_PWM_E); #endif - #if HAS_HEATED_BED - _SLOW_PWM(BED, soft_pwm_bed, temp_bed); - #endif - - #if HAS_HEATED_CHAMBER - _SLOW_PWM(CHAMBER, soft_pwm_chamber, temp_chamber); - #endif - - #if HAS_COOLER - _SLOW_PWM(COOLER, soft_pwm_cooler, temp_cooler); - #endif + TERF(HAS_HEATED_BED, _SLOW_PWM)(BED, soft_pwm_bed, temp_bed); + TERF(HAS_HEATED_CHAMBER, _SLOW_PWM)(CHAMBER, soft_pwm_chamber, temp_chamber); + TERF(HAS_COOLER, _SLOW_PWM)(COOLER, soft_pwm_cooler, temp_cooler); } // slow_pwm_count == 0 @@ -4290,17 +4219,9 @@ void Temperature::isr() { REPEAT(HOTENDS, _PWM_OFF_E); #endif - #if HAS_HEATED_BED - _PWM_OFF(BED, soft_pwm_bed); - #endif - - #if HAS_HEATED_CHAMBER - _PWM_OFF(CHAMBER, soft_pwm_chamber); - #endif - - #if HAS_COOLER - _PWM_OFF(COOLER, soft_pwm_cooler, temp_cooler); - #endif + TERF(HAS_HEATED_BED, _PWM_OFF)(BED, soft_pwm_bed); + TERF(HAS_HEATED_CHAMBER, _PWM_OFF)(CHAMBER, soft_pwm_chamber); + TERF(HAS_COOLER, _PWM_OFF)(COOLER, soft_pwm_cooler, temp_cooler); #if ENABLED(FAN_SOFT_PWM) if (pwm_count_tmp >= 127) { @@ -4309,30 +4230,14 @@ void Temperature::isr() { soft_pwm_count_fan[N] = soft_pwm_amount_fan[N] >> 1; \ WRITE_FAN(N, soft_pwm_count_fan[N] > 0 ? HIGH : LOW); \ }while(0) - #if HAS_FAN0 - _PWM_FAN(0); - #endif - #if HAS_FAN1 - _PWM_FAN(1); - #endif - #if HAS_FAN2 - _PWM_FAN(2); - #endif - #if HAS_FAN3 - _FAN_PWM(3); - #endif - #if HAS_FAN4 - _FAN_PWM(4); - #endif - #if HAS_FAN5 - _FAN_PWM(5); - #endif - #if HAS_FAN6 - _FAN_PWM(6); - #endif - #if HAS_FAN7 - _FAN_PWM(7); - #endif + TERF(HAS_FAN0, _PWM_FAN)(0); + TERF(HAS_FAN1, _PWM_FAN)(1); + TERF(HAS_FAN2, _PWM_FAN)(2); + TERF(HAS_FAN3, _FAN_PWM)(3); + TERF(HAS_FAN4, _FAN_PWM)(4); + TERF(HAS_FAN5, _FAN_PWM)(5); + TERF(HAS_FAN6, _FAN_PWM)(6); + TERF(HAS_FAN7, _FAN_PWM)(7); } #if HAS_FAN0 if (soft_pwm_count_fan[0] <= pwm_count_tmp) WRITE_FAN(0, LOW); From efb58a9a0d16f0907cfbf31899f423c08c50ef5b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 26 Nov 2025 23:04:31 -0600 Subject: [PATCH 18/39] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Conso?= =?UTF-8?q?lidate=20repetitious=20items?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/fancheck.cpp | 64 +-- Marlin/src/feature/joystick.cpp | 16 +- Marlin/src/gcode/calibrate/G425.cpp | 104 +--- Marlin/src/gcode/config/M210.cpp | 38 +- .../lcd/extui/dgus_reloaded/DGUSRxHandler.cpp | 40 +- .../lcd/extui/dgus_reloaded/DGUSTxHandler.cpp | 148 ++--- Marlin/src/module/endstops.cpp | 529 +++++------------- Marlin/src/module/stepper/control.cpp | 72 +-- Marlin/src/module/temperature.cpp | 12 +- 9 files changed, 263 insertions(+), 760 deletions(-) diff --git a/Marlin/src/feature/fancheck.cpp b/Marlin/src/feature/fancheck.cpp index 844191e7e4..4978b8c999 100644 --- a/Marlin/src/feature/fancheck.cpp +++ b/Marlin/src/feature/fancheck.cpp @@ -42,30 +42,14 @@ bool FanCheck::enabled; void FanCheck::init() { #define _TACHINIT(N) TERN(E##N##_FAN_TACHO_PULLUP, SET_INPUT_PULLUP, TERN(E##N##_FAN_TACHO_PULLDOWN, SET_INPUT_PULLDOWN, SET_INPUT))(E##N##_FAN_TACHO_PIN) - #if HAS_E0_FAN_TACHO - _TACHINIT(0); - #endif - #if HAS_E1_FAN_TACHO - _TACHINIT(1); - #endif - #if HAS_E2_FAN_TACHO - _TACHINIT(2); - #endif - #if HAS_E3_FAN_TACHO - _TACHINIT(3); - #endif - #if HAS_E4_FAN_TACHO - _TACHINIT(4); - #endif - #if HAS_E5_FAN_TACHO - _TACHINIT(5); - #endif - #if HAS_E6_FAN_TACHO - _TACHINIT(6); - #endif - #if HAS_E7_FAN_TACHO - _TACHINIT(7); - #endif + TERF(HAS_E0_FAN_TACHO, _TACHINIT)(0); + TERF(HAS_E1_FAN_TACHO, _TACHINIT)(1); + TERF(HAS_E2_FAN_TACHO, _TACHINIT)(2); + TERF(HAS_E3_FAN_TACHO, _TACHINIT)(3); + TERF(HAS_E4_FAN_TACHO, _TACHINIT)(4); + TERF(HAS_E5_FAN_TACHO, _TACHINIT)(5); + TERF(HAS_E6_FAN_TACHO, _TACHINIT)(6); + TERF(HAS_E7_FAN_TACHO, _TACHINIT)(7); } void FanCheck::update_tachometers() { @@ -74,30 +58,14 @@ void FanCheck::update_tachometers() { #define _TACHO_CASE(N) case N: status = READ(E##N##_FAN_TACHO_PIN); break; for (uint8_t f = 0; f < TACHO_COUNT; ++f) { switch (f) { - #if HAS_E0_FAN_TACHO - _TACHO_CASE(0) - #endif - #if HAS_E1_FAN_TACHO - _TACHO_CASE(1) - #endif - #if HAS_E2_FAN_TACHO - _TACHO_CASE(2) - #endif - #if HAS_E3_FAN_TACHO - _TACHO_CASE(3) - #endif - #if HAS_E4_FAN_TACHO - _TACHO_CASE(4) - #endif - #if HAS_E5_FAN_TACHO - _TACHO_CASE(5) - #endif - #if HAS_E6_FAN_TACHO - _TACHO_CASE(6) - #endif - #if HAS_E7_FAN_TACHO - _TACHO_CASE(7) - #endif + TERF(HAS_E0_FAN_TACHO, _TACHO_CASE)(0) + TERF(HAS_E1_FAN_TACHO, _TACHO_CASE)(1) + TERF(HAS_E2_FAN_TACHO, _TACHO_CASE)(2) + TERF(HAS_E3_FAN_TACHO, _TACHO_CASE)(3) + TERF(HAS_E4_FAN_TACHO, _TACHO_CASE)(4) + TERF(HAS_E5_FAN_TACHO, _TACHO_CASE)(5) + TERF(HAS_E6_FAN_TACHO, _TACHO_CASE)(6) + TERF(HAS_E7_FAN_TACHO, _TACHO_CASE)(7) default: continue; } diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index 29addfcf1e..cbfab1fed8 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -67,18 +67,10 @@ Joystick joystick; #if ENABLED(JOYSTICK_DEBUG) void Joystick::report() { SERIAL_ECHOPGM("Joystick"); - #if HAS_JOY_ADC_X - 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.getraw())); - #endif - #if HAS_JOY_ADC_Z - 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)"); - #endif + TERF(HAS_JOY_ADC_X, SERIAL_ECHOPGM_P)(SP_X_STR, JOY_X(x.getraw())); + TERF(HAS_JOY_ADC_Y, SERIAL_ECHOPGM_P)(SP_Y_STR, JOY_Y(y.getraw())); + TERF(HAS_JOY_ADC_Z, SERIAL_ECHOPGM_P)(SP_Z_STR, JOY_Z(z.getraw())); + TERF(HAS_JOY_ADC_EN, SERIAL_ECHO_TERNARY)(READ(JOY_EN_PIN), " EN=", "HIGH (dis", "LOW (en", "abled)"); SERIAL_EOL(); } #endif diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 338c776885..883d7b4b6f 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -468,102 +468,54 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { inline void report_measured_center(const measurements_t &m) { SERIAL_ECHOLNPGM("Center:"); - #if HAS_X_CENTER - SERIAL_ECHOLNPGM_P(SP_X_STR, m.obj_center.x); - #endif - #if HAS_Y_CENTER - SERIAL_ECHOLNPGM_P(SP_Y_STR, m.obj_center.y); - #endif + TERF(HAS_X_CENTER, SERIAL_ECHOLNPGM_P)(SP_X_STR, m.obj_center.x); + TERF(HAS_Y_CENTER, SERIAL_ECHOLNPGM_P)(SP_Y_STR, m.obj_center.y); SERIAL_ECHOLNPGM_P(SP_Z_STR, m.obj_center.z); - #if HAS_I_CENTER - SERIAL_ECHOLNPGM_P(SP_I_STR, m.obj_center.i); - #endif - #if HAS_J_CENTER - SERIAL_ECHOLNPGM_P(SP_J_STR, m.obj_center.j); - #endif - #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 + TERF(HAS_I_CENTER, SERIAL_ECHOLNPGM_P)(SP_I_STR, m.obj_center.i); + TERF(HAS_J_CENTER, SERIAL_ECHOLNPGM_P)(SP_J_STR, m.obj_center.j); + TERF(HAS_K_CENTER, SERIAL_ECHOLNPGM_P)(SP_K_STR, m.obj_center.k); + TERF(HAS_U_CENTER, SERIAL_ECHOLNPGM_P)(SP_U_STR, m.obj_center.u); + TERF(HAS_V_CENTER, SERIAL_ECHOLNPGM_P)(SP_V_STR, m.obj_center.v); + TERF(HAS_W_CENTER, SERIAL_ECHOLNPGM_P)(SP_W_STR, m.obj_center.w); SERIAL_EOL(); } inline void report_measured_backlash(const measurements_t &m) { SERIAL_ECHOLNPGM("Backlash:"); #if AXIS_CAN_CALIBRATE(X) - #if ENABLED(CALIBRATION_MEASURE_LEFT) - SERIAL_ECHOLNPGM(" Left: ", m.backlash[LEFT]); - #endif - #if ENABLED(CALIBRATION_MEASURE_RIGHT) - SERIAL_ECHOLNPGM(" Right: ", m.backlash[RIGHT]); - #endif + TERF(CALIBRATION_MEASURE_LEFT, SERIAL_ECHOLNPGM)(" Left: ", m.backlash[LEFT]); + TERF(CALIBRATION_MEASURE_RIGHT, SERIAL_ECHOLNPGM)(" Right: ", m.backlash[RIGHT]); #endif #if AXIS_CAN_CALIBRATE(Y) - #if ENABLED(CALIBRATION_MEASURE_FRONT) - SERIAL_ECHOLNPGM(" Front: ", m.backlash[FRONT]); - #endif - #if ENABLED(CALIBRATION_MEASURE_BACK) - SERIAL_ECHOLNPGM(" Back: ", m.backlash[BACK]); - #endif + TERF(CALIBRATION_MEASURE_FRONT, SERIAL_ECHOLNPGM)(" Front: ", m.backlash[FRONT]); + TERF(CALIBRATION_MEASURE_BACK, SERIAL_ECHOLNPGM)(" Back: ", m.backlash[BACK]); #endif #if AXIS_CAN_CALIBRATE(Z) SERIAL_ECHOLNPGM(" Top: ", m.backlash[TOP]); #endif #if AXIS_CAN_CALIBRATE(I) - #if ENABLED(CALIBRATION_MEASURE_IMIN) - SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.backlash[IMINIMUM]); - #endif - #if ENABLED(CALIBRATION_MEASURE_IMAX) - SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.backlash[IMAXIMUM]); - #endif + TERF(CALIBRATION_MEASURE_IMIN, SERIAL_ECHOLNPGM)(" " STR_I_MIN ": ", m.backlash[IMINIMUM]); + TERF(CALIBRATION_MEASURE_IMAX, SERIAL_ECHOLNPGM)(" " STR_I_MAX ": ", m.backlash[IMAXIMUM]); #endif #if AXIS_CAN_CALIBRATE(J) - #if ENABLED(CALIBRATION_MEASURE_JMIN) - SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.backlash[JMINIMUM]); - #endif - #if ENABLED(CALIBRATION_MEASURE_JMAX) - SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.backlash[JMAXIMUM]); - #endif + TERF(CALIBRATION_MEASURE_JMIN, SERIAL_ECHOLNPGM)(" " STR_J_MIN ": ", m.backlash[JMINIMUM]); + TERF(CALIBRATION_MEASURE_JMAX, SERIAL_ECHOLNPGM)(" " STR_J_MAX ": ", m.backlash[JMAXIMUM]); #endif #if AXIS_CAN_CALIBRATE(K) - #if ENABLED(CALIBRATION_MEASURE_KMIN) - SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.backlash[KMINIMUM]); - #endif - #if ENABLED(CALIBRATION_MEASURE_KMAX) - SERIAL_ECHOLNPGM(" " STR_K_MAX ": ", m.backlash[KMAXIMUM]); - #endif + TERF(CALIBRATION_MEASURE_KMIN, SERIAL_ECHOLNPGM)(" " STR_K_MIN ": ", m.backlash[KMINIMUM]); + TERF(CALIBRATION_MEASURE_KMAX, SERIAL_ECHOLNPGM)(" " STR_K_MAX ": ", m.backlash[KMAXIMUM]); #endif #if 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 + TERF(CALIBRATION_MEASURE_UMIN, SERIAL_ECHOLNPGM)(" " STR_U_MIN ": ", m.backlash[UMINIMUM]); + TERF(CALIBRATION_MEASURE_UMAX, SERIAL_ECHOLNPGM)(" " STR_U_MAX ": ", m.backlash[UMAXIMUM]); #endif #if 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 + TERF(CALIBRATION_MEASURE_VMIN, SERIAL_ECHOLNPGM)(" " STR_V_MIN ": ", m.backlash[VMINIMUM]); + TERF(CALIBRATION_MEASURE_VMAX, SERIAL_ECHOLNPGM)(" " STR_V_MAX ": ", m.backlash[VMAXIMUM]); #endif #if 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 + TERF(CALIBRATION_MEASURE_WMIN, SERIAL_ECHOLNPGM)(" " STR_W_MIN ": ", m.backlash[WMINIMUM]); + TERF(CALIBRATION_MEASURE_WMAX, SERIAL_ECHOLNPGM)(" " STR_W_MAX ": ", m.backlash[WMAXIMUM]); #endif SERIAL_EOL(); } @@ -604,12 +556,8 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { inline void report_measured_nozzle_dimensions(const measurements_t &m) { SERIAL_ECHOLNPGM("Nozzle Tip Outer Dimensions:"); - #if HAS_X_CENTER - SERIAL_ECHOLNPGM_P(SP_X_STR, m.nozzle_outer_dimension.x); - #endif - #if HAS_Y_CENTER - SERIAL_ECHOLNPGM_P(SP_Y_STR, m.nozzle_outer_dimension.y); - #endif + TERF(HAS_X_CENTER, SERIAL_ECHOLNPGM_P)(SP_X_STR, m.nozzle_outer_dimension.x); + TERF(HAS_Y_CENTER, SERIAL_ECHOLNPGM_P)(SP_Y_STR, m.nozzle_outer_dimension.y); SERIAL_EOL(); UNUSED(m); } diff --git a/Marlin/src/gcode/config/M210.cpp b/Marlin/src/gcode/config/M210.cpp index f07e009b4a..41dbd73db4 100644 --- a/Marlin/src/gcode/config/M210.cpp +++ b/Marlin/src/gcode/config/M210.cpp @@ -47,33 +47,17 @@ void GcodeSuite::M210() { if (!parser.seen_any()) return M210_report(); - #if HAS_X_AXIS - if (parser.floatval(AXIS1_PARAM) > 0) homing_feedrate_mm_m.x = parser.value_axis_units(X_AXIS); - #endif - #if HAS_Y_AXIS - if (parser.floatval(AXIS2_PARAM) > 0) homing_feedrate_mm_m.y = parser.value_axis_units(Y_AXIS); - #endif - #if HAS_Z_AXIS - if (parser.floatval(AXIS3_PARAM) > 0) homing_feedrate_mm_m.z = parser.value_axis_units(Z_AXIS); - #endif - #if HAS_I_AXIS - if (parser.floatval(AXIS4_PARAM) > 0) homing_feedrate_mm_m.i = parser.value_axis_units(I_AXIS); - #endif - #if HAS_J_AXIS - if (parser.floatval(AXIS5_PARAM) > 0) homing_feedrate_mm_m.j = parser.value_axis_units(J_AXIS); - #endif - #if HAS_K_AXIS - if (parser.floatval(AXIS6_PARAM) > 0) homing_feedrate_mm_m.k = parser.value_axis_units(K_AXIS); - #endif - #if HAS_U_AXIS - if (parser.floatval(AXIS7_PARAM) > 0) homing_feedrate_mm_m.u = parser.value_axis_units(U_AXIS); - #endif - #if HAS_V_AXIS - if (parser.floatval(AXIS8_PARAM) > 0) homing_feedrate_mm_m.v = parser.value_axis_units(V_AXIS); - #endif - #if HAS_W_AXIS - if (parser.floatval(AXIS9_PARAM) > 0) homing_feedrate_mm_m.w = parser.value_axis_units(W_AXIS); - #endif + NUM_AXIS_CODE( + if (parser.floatval(AXIS1_PARAM) > 0) homing_feedrate_mm_m.x = parser.value_axis_units(X_AXIS), + if (parser.floatval(AXIS2_PARAM) > 0) homing_feedrate_mm_m.y = parser.value_axis_units(Y_AXIS), + if (parser.floatval(AXIS3_PARAM) > 0) homing_feedrate_mm_m.z = parser.value_axis_units(Z_AXIS), + if (parser.floatval(AXIS4_PARAM) > 0) homing_feedrate_mm_m.i = parser.value_axis_units(I_AXIS), + if (parser.floatval(AXIS5_PARAM) > 0) homing_feedrate_mm_m.j = parser.value_axis_units(J_AXIS), + if (parser.floatval(AXIS6_PARAM) > 0) homing_feedrate_mm_m.k = parser.value_axis_units(K_AXIS), + if (parser.floatval(AXIS7_PARAM) > 0) homing_feedrate_mm_m.u = parser.value_axis_units(U_AXIS), + if (parser.floatval(AXIS8_PARAM) > 0) homing_feedrate_mm_m.v = parser.value_axis_units(V_AXIS), + if (parser.floatval(AXIS9_PARAM) > 0) homing_feedrate_mm_m.w = parser.value_axis_units(W_AXIS) + ); } void GcodeSuite::M210_report(const bool forReplay/*=true*/) { diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index c25163b7e6..68e1f95b79 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -231,12 +231,8 @@ void DGUSRxHandler::flowrate(DGUS_VP &vp, void *data_ptr) { ExtUI::setFlow_percent(flowrate, TERN(HAS_MULTI_EXTRUDER, ExtUI::getActiveTool(), ExtUI::E0)); break; #if HAS_MULTI_EXTRUDER - case DGUS_Addr::ADJUST_SetFlowrate_E0: - ExtUI::setFlow_percent(flowrate, ExtUI::E0); - break; - case DGUS_Addr::ADJUST_SetFlowrate_E1: - ExtUI::setFlow_percent(flowrate, ExtUI::E1); - break; + case DGUS_Addr::ADJUST_SetFlowrate_E0: ExtUI::setFlow_percent(flowrate, ExtUI::E0); break; + case DGUS_Addr::ADJUST_SetFlowrate_E1: ExtUI::setFlow_percent(flowrate, ExtUI::E1); break; #endif } @@ -265,12 +261,8 @@ void DGUSRxHandler::babystep(DGUS_VP &vp, void *data_ptr) { switch (adjust) { default: return; - case DGUS_Data::Adjust::INCREMENT: - steps = ExtUI::mmToWholeSteps(DGUS_PRINT_BABYSTEP, ExtUI::Z); - break; - case DGUS_Data::Adjust::DECREMENT: - steps = ExtUI::mmToWholeSteps(-DGUS_PRINT_BABYSTEP, ExtUI::Z); - break; + case DGUS_Data::Adjust::INCREMENT: steps = ExtUI::mmToWholeSteps(DGUS_PRINT_BABYSTEP, ExtUI::Z); break; + case DGUS_Data::Adjust::DECREMENT: steps = ExtUI::mmToWholeSteps(-DGUS_PRINT_BABYSTEP, ExtUI::Z); break; } ExtUI::smartAdjustAxis_steps(steps, ExtUI::Z, true); @@ -319,16 +311,10 @@ void DGUSRxHandler::tempTarget(DGUS_VP &vp, void *data_ptr) { switch (vp.addr) { default: return; - case DGUS_Addr::TEMP_SetTarget_Bed: - ExtUI::setTargetTemp_celsius(temp, ExtUI::BED); - break; - case DGUS_Addr::TEMP_SetTarget_H0: - ExtUI::setTargetTemp_celsius(temp, ExtUI::H0); - break; + case DGUS_Addr::TEMP_SetTarget_Bed: ExtUI::setTargetTemp_celsius(temp, ExtUI::BED); break; + case DGUS_Addr::TEMP_SetTarget_H0: ExtUI::setTargetTemp_celsius(temp, ExtUI::H0); break; #if HAS_MULTI_HOTEND - case DGUS_Addr::TEMP_SetTarget_H1: - ExtUI::setTargetTemp_celsius(temp, ExtUI::H1); - break; + case DGUS_Addr::TEMP_SetTarget_H1: ExtUI::setTargetTemp_celsius(temp, ExtUI::H1); break; #endif } @@ -349,16 +335,10 @@ void DGUSRxHandler::tempCool(DGUS_VP &vp, void *data_ptr) { ExtUI::setTargetTemp_celsius(0, ExtUI::H1); #endif break; - case DGUS_Data::Heater::BED: - ExtUI::setTargetTemp_celsius(0, ExtUI::BED); - break; - case DGUS_Data::Heater::H0: - ExtUI::setTargetTemp_celsius(0, ExtUI::H0); - break; + case DGUS_Data::Heater::BED: ExtUI::setTargetTemp_celsius(0, ExtUI::BED); break; + case DGUS_Data::Heater::H0: ExtUI::setTargetTemp_celsius(0, ExtUI::H0); break; #if HAS_MULTI_HOTEND - case DGUS_Data::Heater::H1: - ExtUI::setTargetTemp_celsius(0, ExtUI::H1); - break; + case DGUS_Data::Heater::H1: ExtUI::setTargetTemp_celsius(0, ExtUI::H1); break; #endif } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp index a2327d025f..d0059f056a 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp @@ -44,21 +44,11 @@ switch (file) { default: return; - case 0: - control = DGUS_Control::FILE0; - break; - case 1: - control = DGUS_Control::FILE1; - break; - case 2: - control = DGUS_Control::FILE2; - break; - case 3: - control = DGUS_Control::FILE3; - break; - case 4: - control = DGUS_Control::FILE4; - break; + case 0: control = DGUS_Control::FILE0; break; + case 1: control = DGUS_Control::FILE1; break; + case 2: control = DGUS_Control::FILE2; break; + case 3: control = DGUS_Control::FILE3; break; + case 4: control = DGUS_Control::FILE4; break; } if (state) { @@ -100,21 +90,11 @@ switch (vp.addr) { default: return; - case DGUS_Addr::SD_FileName0: - offset = 0; - break; - case DGUS_Addr::SD_FileName1: - offset = 1; - break; - case DGUS_Addr::SD_FileName2: - offset = 2; - break; - case DGUS_Addr::SD_FileName3: - offset = 3; - break; - case DGUS_Addr::SD_FileName4: - offset = 4; - break; + case DGUS_Addr::SD_FileName0: offset = 0; break; + case DGUS_Addr::SD_FileName1: offset = 1; break; + case DGUS_Addr::SD_FileName2: offset = 2; break; + case DGUS_Addr::SD_FileName3: offset = 3; break; + case DGUS_Addr::SD_FileName4: offset = 4; break; } if (screen.filelist.seek(screen.filelist_offset + offset)) { @@ -199,12 +179,8 @@ void DGUSTxHandler::percent(DGUS_VP &vp) { switch (vp.addr) { default: return; - case DGUS_Addr::STATUS_Percent: - progress = constrain(ExtUI::getProgress_percent(), 0, 100); - break; - case DGUS_Addr::STATUS_Percent_Complete: - progress = 100; - break; + case DGUS_Addr::STATUS_Percent: progress = constrain(ExtUI::getProgress_percent(), 0, 100); break; + case DGUS_Addr::STATUS_Percent_Complete: progress = 100; break; } dgus.write((uint16_t)DGUS_Addr::STATUS_Percent, Swap16(progress)); @@ -251,12 +227,8 @@ void DGUSTxHandler::flowrate(DGUS_VP &vp) { flowrate = ExtUI::getFlow_percent(TERN(HAS_MULTI_EXTRUDER, ExtUI::getActiveTool(), ExtUI::E0)); break; #if HAS_MULTI_EXTRUDER - case DGUS_Addr::ADJUST_Flowrate_E0: - flowrate = ExtUI::getFlow_percent(ExtUI::E0); - break; - case DGUS_Addr::ADJUST_Flowrate_E1: - flowrate = ExtUI::getFlow_percent(ExtUI::E1); - break; + case DGUS_Addr::ADJUST_Flowrate_E0: flowrate = ExtUI::getFlow_percent(ExtUI::E0); break; + case DGUS_Addr::ADJUST_Flowrate_E1: flowrate = ExtUI::getFlow_percent(ExtUI::E1); break; #endif } @@ -269,19 +241,13 @@ void DGUSTxHandler::tempMax(DGUS_VP &vp) { switch (vp.addr) { default: return; #if HAS_HEATED_BED - case DGUS_Addr::TEMP_Max_Bed: - temp = BED_MAX_TARGET; - break; + case DGUS_Addr::TEMP_Max_Bed: temp = BED_MAX_TARGET; break; #endif #if HAS_HOTEND - case DGUS_Addr::TEMP_Max_H0: - temp = thermalManager.hotend_max_target(0); - break; + case DGUS_Addr::TEMP_Max_H0: temp = thermalManager.hotend_max_target(0); break; #endif #if HAS_MULTI_HOTEND - case DGUS_Addr::TEMP_Max_H1: - temp = thermalManager.hotend_max_target(1); - break; + case DGUS_Addr::TEMP_Max_H1: temp = thermalManager.hotend_max_target(1); break; #endif } @@ -299,18 +265,10 @@ void DGUSTxHandler::stepIcons(DGUS_VP &vp) { DGUS_Data::StepSize size = *(DGUS_Data::StepSize*)vp.extra; switch (size) { - case DGUS_Data::StepSize::MM10: - icons |= (uint16_t)DGUS_Data::StepIcon::MM10; - break; - case DGUS_Data::StepSize::MM1: - icons |= (uint16_t)DGUS_Data::StepIcon::MM1; - break; - case DGUS_Data::StepSize::MMP1: - icons |= (uint16_t)DGUS_Data::StepIcon::MMP1; - break; - case DGUS_Data::StepSize::MMP01: - icons |= (uint16_t)DGUS_Data::StepIcon::MMP01; - break; + case DGUS_Data::StepSize::MM10: icons |= (uint16_t)DGUS_Data::StepIcon::MM10; break; + case DGUS_Data::StepSize::MM1: icons |= (uint16_t)DGUS_Data::StepIcon::MM1; break; + case DGUS_Data::StepSize::MMP1: icons |= (uint16_t)DGUS_Data::StepIcon::MMP1; break; + case DGUS_Data::StepSize::MMP01: icons |= (uint16_t)DGUS_Data::StepIcon::MMP01; break; } dgus.write((uint16_t)vp.addr, Swap16(icons)); @@ -362,21 +320,13 @@ void DGUSTxHandler::filamentIcons(DGUS_VP &vp) { #if HAS_MULTI_EXTRUDER switch (ExtUI::getActiveTool()) { default: break; - case ExtUI::E0: - icons |= (uint16_t)DGUS_Data::ExtruderIcon::E0; - break; - case ExtUI::E1: - icons |= (uint16_t)DGUS_Data::ExtruderIcon::E1; - break; + case ExtUI::E0: icons |= (uint16_t)DGUS_Data::ExtruderIcon::E0; break; + case ExtUI::E1: icons |= (uint16_t)DGUS_Data::ExtruderIcon::E1; break; } break; #endif - case DGUS_Data::Extruder::E0: - icons |= (uint16_t)DGUS_Data::ExtruderIcon::E0; - break; - case DGUS_Data::Extruder::E1: - icons |= (uint16_t)DGUS_Data::ExtruderIcon::E1; - break; + case DGUS_Data::Extruder::E0: icons |= (uint16_t)DGUS_Data::ExtruderIcon::E0; break; + case DGUS_Data::Extruder::E1: icons |= (uint16_t)DGUS_Data::ExtruderIcon::E1; break; } dgus.write((uint16_t)vp.addr, Swap16(icons)); @@ -403,15 +353,9 @@ void DGUSTxHandler::pidIcons(DGUS_VP &vp) { switch (screen.pid_heater) { default: return; - case DGUS_Data::Heater::BED: - icons |= (uint16_t)DGUS_Data::HeaterIcon::BED; - break; - case DGUS_Data::Heater::H0: - icons |= (uint16_t)DGUS_Data::HeaterIcon::H0; - break; - case DGUS_Data::Heater::H1: - icons |= (uint16_t)DGUS_Data::HeaterIcon::H1; - break; + case DGUS_Data::Heater::BED: icons |= (uint16_t)DGUS_Data::HeaterIcon::BED; break; + case DGUS_Data::Heater::H0: icons |= (uint16_t)DGUS_Data::HeaterIcon::H0; break; + case DGUS_Data::Heater::H1: icons |= (uint16_t)DGUS_Data::HeaterIcon::H1; break; } dgus.write((uint16_t)vp.addr, Swap16(icons)); @@ -423,18 +367,12 @@ void DGUSTxHandler::pidKp(DGUS_VP &vp) { switch (screen.pid_heater) { default: return; #if ENABLED(PIDTEMPBED) - case DGUS_Data::Heater::BED: - value = ExtUI::getBedPID_Kp(); - break; + case DGUS_Data::Heater::BED: value = ExtUI::getBedPID_Kp(); break; #endif #if ENABLED(PIDTEMP) - case DGUS_Data::Heater::H0: - value = ExtUI::getPID_Kp(ExtUI::E0); - break; + case DGUS_Data::Heater::H0: value = ExtUI::getPID_Kp(ExtUI::E0); break; #if HAS_MULTI_HOTEND - case DGUS_Data::Heater::H1: - value = ExtUI::getPID_Kp(ExtUI::E1); - break; + case DGUS_Data::Heater::H1: value = ExtUI::getPID_Kp(ExtUI::E1); break; #endif #endif } @@ -449,18 +387,12 @@ void DGUSTxHandler::pidKi(DGUS_VP &vp) { switch (screen.pid_heater) { default: return; #if ENABLED(PIDTEMPBED) - case DGUS_Data::Heater::BED: - value = ExtUI::getBedPID_Ki(); - break; + case DGUS_Data::Heater::BED: value = ExtUI::getBedPID_Ki(); break; #endif #if ENABLED(PIDTEMP) - case DGUS_Data::Heater::H0: - value = ExtUI::getPID_Ki(ExtUI::E0); - break; + case DGUS_Data::Heater::H0: value = ExtUI::getPID_Ki(ExtUI::E0); break; #if HAS_MULTI_HOTEND - case DGUS_Data::Heater::H1: - value = ExtUI::getPID_Ki(ExtUI::E1); - break; + case DGUS_Data::Heater::H1: value = ExtUI::getPID_Ki(ExtUI::E1); break; #endif #endif } @@ -475,18 +407,12 @@ void DGUSTxHandler::pidKd(DGUS_VP &vp) { switch (screen.pid_heater) { default: return; #if ENABLED(PIDTEMPBED) - case DGUS_Data::Heater::BED: - value = ExtUI::getBedPID_Kd(); - break; + case DGUS_Data::Heater::BED: value = ExtUI::getBedPID_Kd(); break; #endif #if ENABLED(PIDTEMP) - case DGUS_Data::Heater::H0: - value = ExtUI::getPID_Kd(ExtUI::E0); - break; + case DGUS_Data::Heater::H0: value = ExtUI::getPID_Kd(ExtUI::E0); break; #if HAS_MULTI_HOTEND - case DGUS_Data::Heater::H1: - value = ExtUI::getPID_Kd(ExtUI::E1); - break; + case DGUS_Data::Heater::H1: value = ExtUI::getPID_Kd(ExtUI::E1); break; #endif #endif } diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 91d2fcd858..20b3b8b1d2 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -133,90 +133,34 @@ Endstops::endstop_mask_t Endstops::live_state = 0; void Endstops::init() { #define _INIT_ENDSTOP(T,A,N) TERN(ENDSTOPPULLUP_##A##T, SET_INPUT_PULLUP, TERN(ENDSTOPPULLDOWN_##A##T, SET_INPUT_PULLDOWN, SET_INPUT))(A##N##_##T##_PIN) - #if USE_X_MIN - _INIT_ENDSTOP(MIN,X,); - #endif - #if USE_X_MAX - _INIT_ENDSTOP(MAX,X,); - #endif - #if USE_X2_MIN - _INIT_ENDSTOP(MIN,X,2); - #endif - #if USE_X2_MAX - _INIT_ENDSTOP(MAX,X,2); - #endif - #if USE_Y_MIN - _INIT_ENDSTOP(MIN,Y,); - #endif - #if USE_Y_MAX - _INIT_ENDSTOP(MAX,Y,); - #endif - #if USE_Y2_MIN - _INIT_ENDSTOP(MIN,Y,2); - #endif - #if USE_Y2_MAX - _INIT_ENDSTOP(MAX,Y,2); - #endif - #if USE_Z_MIN - _INIT_ENDSTOP(MIN,Z,); - #endif - #if USE_Z_MAX - _INIT_ENDSTOP(MAX,Z,); - #endif - #if USE_Z2_MIN - _INIT_ENDSTOP(MIN,Z,2); - #endif - #if USE_Z2_MAX - _INIT_ENDSTOP(MAX,Z,2); - #endif - #if USE_Z3_MIN - _INIT_ENDSTOP(MIN,Z,3); - #endif - #if USE_Z3_MAX - _INIT_ENDSTOP(MAX,Z,3); - #endif - #if USE_Z4_MIN - _INIT_ENDSTOP(MIN,Z,4); - #endif - #if USE_Z4_MAX - _INIT_ENDSTOP(MAX,Z,4); - #endif - #if USE_I_MIN - _INIT_ENDSTOP(MIN,I,); - #endif - #if USE_I_MAX - _INIT_ENDSTOP(MAX,I,); - #endif - #if USE_J_MIN - _INIT_ENDSTOP(MIN,J,); - #endif - #if USE_J_MAX - _INIT_ENDSTOP(MAX,J,); - #endif - #if USE_K_MIN - _INIT_ENDSTOP(MIN,K,); - #endif - #if USE_K_MAX - _INIT_ENDSTOP(MAX,K,); - #endif - #if USE_U_MIN - _INIT_ENDSTOP(MIN,U,); - #endif - #if USE_U_MAX - _INIT_ENDSTOP(MAX,U,); - #endif - #if USE_V_MIN - _INIT_ENDSTOP(MIN,V,); - #endif - #if USE_V_MAX - _INIT_ENDSTOP(MAX,V,); - #endif - #if USE_W_MIN - _INIT_ENDSTOP(MIN,W,); - #endif - #if USE_W_MAX - _INIT_ENDSTOP(MAX,W,); - #endif + TERF(USE_X_MIN, _INIT_ENDSTOP)(MIN,X,); + TERF(USE_X_MAX, _INIT_ENDSTOP)(MAX,X,); + TERF(USE_X2_MIN, _INIT_ENDSTOP)(MIN,X,2); + TERF(USE_X2_MAX, _INIT_ENDSTOP)(MAX,X,2); + TERF(USE_Y_MIN, _INIT_ENDSTOP)(MIN,Y,); + TERF(USE_Y_MAX, _INIT_ENDSTOP)(MAX,Y,); + TERF(USE_Y2_MIN, _INIT_ENDSTOP)(MIN,Y,2); + TERF(USE_Y2_MAX, _INIT_ENDSTOP)(MAX,Y,2); + TERF(USE_Z_MIN, _INIT_ENDSTOP)(MIN,Z,); + TERF(USE_Z_MAX, _INIT_ENDSTOP)(MAX,Z,); + TERF(USE_Z2_MIN, _INIT_ENDSTOP)(MIN,Z,2); + TERF(USE_Z2_MAX, _INIT_ENDSTOP)(MAX,Z,2); + TERF(USE_Z3_MIN, _INIT_ENDSTOP)(MIN,Z,3); + TERF(USE_Z3_MAX, _INIT_ENDSTOP)(MAX,Z,3); + TERF(USE_Z4_MIN, _INIT_ENDSTOP)(MIN,Z,4); + TERF(USE_Z4_MAX, _INIT_ENDSTOP)(MAX,Z,4); + TERF(USE_I_MIN, _INIT_ENDSTOP)(MIN,I,); + TERF(USE_I_MAX, _INIT_ENDSTOP)(MAX,I,); + TERF(USE_J_MIN, _INIT_ENDSTOP)(MIN,J,); + TERF(USE_J_MAX, _INIT_ENDSTOP)(MAX,J,); + TERF(USE_K_MIN, _INIT_ENDSTOP)(MIN,K,); + TERF(USE_K_MAX, _INIT_ENDSTOP)(MAX,K,); + TERF(USE_U_MIN, _INIT_ENDSTOP)(MIN,U,); + TERF(USE_U_MAX, _INIT_ENDSTOP)(MAX,U,); + TERF(USE_V_MIN, _INIT_ENDSTOP)(MIN,V,); + TERF(USE_V_MAX, _INIT_ENDSTOP)(MAX,V,); + TERF(USE_W_MIN, _INIT_ENDSTOP)(MIN,W,); + TERF(USE_W_MAX, _INIT_ENDSTOP)(MAX,W,); #if USE_CALIBRATION #if ENABLED(CALIBRATION_PIN_PULLUP) @@ -458,99 +402,41 @@ void __O2 Endstops::report_states() { TERN_(BLTOUCH, bltouch._set_SW_mode()); SERIAL_ECHOLNPGM(STR_M119_REPORT); #define ES_REPORT(S) print_es_state(READ_ENDSTOP(S##_PIN) == S##_ENDSTOP_HIT_STATE, F(STR_##S)) - #if USE_X_MIN - ES_REPORT(X_MIN); - #endif - #if USE_X2_MIN - ES_REPORT(X2_MIN); - #endif - #if USE_X_MAX - ES_REPORT(X_MAX); - #endif - #if USE_X2_MAX - ES_REPORT(X2_MAX); - #endif - #if USE_Y_MIN - ES_REPORT(Y_MIN); - #endif - #if USE_Y2_MIN - ES_REPORT(Y2_MIN); - #endif - #if USE_Y_MAX - ES_REPORT(Y_MAX); - #endif - #if USE_Y2_MAX - ES_REPORT(Y2_MAX); - #endif - #if USE_Z_MIN - ES_REPORT(Z_MIN); - #endif - #if USE_Z2_MIN - ES_REPORT(Z2_MIN); - #endif - #if USE_Z3_MIN - ES_REPORT(Z3_MIN); - #endif - #if USE_Z4_MIN - ES_REPORT(Z4_MIN); - #endif - #if USE_Z_MAX - ES_REPORT(Z_MAX); - #endif - #if USE_Z2_MAX - ES_REPORT(Z2_MAX); - #endif - #if USE_Z3_MAX - ES_REPORT(Z3_MAX); - #endif - #if USE_Z4_MAX - ES_REPORT(Z4_MAX); - #endif - #if USE_I_MIN - ES_REPORT(I_MIN); - #endif - #if USE_I_MAX - ES_REPORT(I_MAX); - #endif - #if USE_J_MIN - ES_REPORT(J_MIN); - #endif - #if USE_J_MAX - ES_REPORT(J_MAX); - #endif - #if USE_K_MIN - ES_REPORT(K_MIN); - #endif - #if USE_K_MAX - ES_REPORT(K_MAX); - #endif - #if USE_U_MIN - ES_REPORT(U_MIN); - #endif - #if USE_U_MAX - ES_REPORT(U_MAX); - #endif - #if USE_V_MIN - ES_REPORT(V_MIN); - #endif - #if USE_V_MAX - ES_REPORT(V_MAX); - #endif - #if USE_W_MIN - ES_REPORT(W_MIN); - #endif - #if USE_W_MAX - ES_REPORT(W_MAX); - #endif - #if ENABLED(PROBE_ACTIVATION_SWITCH) - print_es_state(probe_switch_activated(), F(STR_PROBE_EN)); - #endif - #if USE_Z_MIN_PROBE - print_es_state(PROBE_TRIGGERED(), F(STR_Z_PROBE)); - #endif - #if USE_CALIBRATION - print_es_state(READ(CALIBRATION_PIN) != CALIBRATION_PIN_INVERTING, F(STR_CALIBRATION)); - #endif + TERF(USE_X_MIN, ES_REPORT)(X_MIN); + TERF(USE_X2_MIN, ES_REPORT)(X2_MIN); + TERF(USE_X_MAX, ES_REPORT)(X_MAX); + TERF(USE_X2_MAX, ES_REPORT)(X2_MAX); + TERF(USE_Y_MIN, ES_REPORT)(Y_MIN); + TERF(USE_Y2_MIN, ES_REPORT)(Y2_MIN); + TERF(USE_Y_MAX, ES_REPORT)(Y_MAX); + TERF(USE_Y2_MAX, ES_REPORT)(Y2_MAX); + TERF(USE_Z_MIN, ES_REPORT)(Z_MIN); + TERF(USE_Z2_MIN, ES_REPORT)(Z2_MIN); + TERF(USE_Z3_MIN, ES_REPORT)(Z3_MIN); + TERF(USE_Z4_MIN, ES_REPORT)(Z4_MIN); + TERF(USE_Z_MAX, ES_REPORT)(Z_MAX); + TERF(USE_Z2_MAX, ES_REPORT)(Z2_MAX); + TERF(USE_Z3_MAX, ES_REPORT)(Z3_MAX); + TERF(USE_Z4_MAX, ES_REPORT)(Z4_MAX); + TERF(USE_I_MIN, ES_REPORT)(I_MIN); + TERF(USE_I_MAX, ES_REPORT)(I_MAX); + TERF(USE_J_MIN, ES_REPORT)(J_MIN); + TERF(USE_J_MAX, ES_REPORT)(J_MAX); + TERF(USE_K_MIN, ES_REPORT)(K_MIN); + TERF(USE_K_MAX, ES_REPORT)(K_MAX); + TERF(USE_U_MIN, ES_REPORT)(U_MIN); + TERF(USE_U_MAX, ES_REPORT)(U_MAX); + TERF(USE_V_MIN, ES_REPORT)(V_MIN); + TERF(USE_V_MAX, ES_REPORT)(V_MAX); + TERF(USE_W_MIN, ES_REPORT)(W_MIN); + TERF(USE_W_MAX, ES_REPORT)(W_MAX); + + TERF(PROBE_ACTIVATION_SWITCH, print_es_state)(probe_switch_activated(), F(STR_PROBE_EN)); + + TERF(USE_Z_MIN_PROBE, print_es_state)(PROBE_TRIGGERED(), F(STR_Z_PROBE)); + + TERF(USE_CALIBRATION, print_es_state)(READ(CALIBRATION_PIN) != CALIBRATION_PIN_INVERTING, F(STR_CALIBRATION)); + #if MULTI_FILAMENT_SENSOR #define _CASE_RUNOUT(N) do{ \ SERIAL_ECHO(F(STR_FILAMENT)); \ @@ -719,42 +605,18 @@ void Endstops::update() { COPY_LIVE_STATE(Z_MAX, Z4_MAX); #endif - #if USE_I_MIN - UPDATE_LIVE_STATE(I, MIN); - #endif - #if USE_I_MAX - UPDATE_LIVE_STATE(I, MAX); - #endif - #if USE_J_MIN - UPDATE_LIVE_STATE(J, MIN); - #endif - #if USE_J_MAX - UPDATE_LIVE_STATE(J, MAX); - #endif - #if USE_K_MIN - UPDATE_LIVE_STATE(K, MIN); - #endif - #if USE_K_MAX - UPDATE_LIVE_STATE(K, MAX); - #endif - #if USE_U_MIN - UPDATE_LIVE_STATE(U, MIN); - #endif - #if USE_U_MAX - UPDATE_LIVE_STATE(U, MAX); - #endif - #if USE_V_MIN - UPDATE_LIVE_STATE(V, MIN); - #endif - #if USE_V_MAX - UPDATE_LIVE_STATE(V, MAX); - #endif - #if USE_W_MIN - UPDATE_LIVE_STATE(W, MIN); - #endif - #if USE_W_MAX - UPDATE_LIVE_STATE(W, MAX); - #endif + TERF(USE_I_MIN, UPDATE_LIVE_STATE)(I, MIN); + TERF(USE_I_MAX, UPDATE_LIVE_STATE)(I, MAX); + TERF(USE_J_MIN, UPDATE_LIVE_STATE)(J, MIN); + TERF(USE_J_MAX, UPDATE_LIVE_STATE)(J, MAX); + TERF(USE_K_MIN, UPDATE_LIVE_STATE)(K, MIN); + TERF(USE_K_MAX, UPDATE_LIVE_STATE)(K, MAX); + TERF(USE_U_MIN, UPDATE_LIVE_STATE)(U, MIN); + TERF(USE_U_MAX, UPDATE_LIVE_STATE)(U, MAX); + TERF(USE_V_MIN, UPDATE_LIVE_STATE)(V, MIN); + TERF(USE_V_MAX, UPDATE_LIVE_STATE)(V, MAX); + TERF(USE_W_MIN, UPDATE_LIVE_STATE)(W, MIN); + TERF(USE_W_MAX, UPDATE_LIVE_STATE)(W, MAX); #if ENDSTOP_NOISE_THRESHOLD @@ -1225,192 +1087,71 @@ void Endstops::update() { uint16_t live_state_local = 0; #define ES_GET_STATE(S) if (READ_ENDSTOP(S##_PIN)) SBI(live_state_local, S) - - #if USE_X_MIN - ES_GET_STATE(X_MIN); - #endif - #if USE_X_MAX - ES_GET_STATE(X_MAX); - #endif - #if USE_Y_MIN - ES_GET_STATE(Y_MIN); - #endif - #if USE_Y_MAX - ES_GET_STATE(Y_MAX); - #endif - #if USE_Z_MIN - ES_GET_STATE(Z_MIN); - #endif - #if USE_Z_MAX - ES_GET_STATE(Z_MAX); - #endif - #if USE_Z_MIN_PROBE - ES_GET_STATE(Z_MIN_PROBE); - #endif - #if USE_CALIBRATION - ES_GET_STATE(CALIBRATION); - #endif - #if USE_X2_MIN - ES_GET_STATE(X2_MIN); - #endif - #if USE_X2_MAX - ES_GET_STATE(X2_MAX); - #endif - #if USE_Y2_MIN - ES_GET_STATE(Y2_MIN); - #endif - #if USE_Y2_MAX - ES_GET_STATE(Y2_MAX); - #endif - #if USE_Z2_MIN - ES_GET_STATE(Z2_MIN); - #endif - #if USE_Z2_MAX - ES_GET_STATE(Z2_MAX); - #endif - #if USE_Z3_MIN - ES_GET_STATE(Z3_MIN); - #endif - #if USE_Z3_MAX - ES_GET_STATE(Z3_MAX); - #endif - #if USE_Z4_MIN - ES_GET_STATE(Z4_MIN); - #endif - #if USE_Z4_MAX - ES_GET_STATE(Z4_MAX); - #endif - #if USE_I_MAX - ES_GET_STATE(I_MAX); - #endif - #if USE_I_MIN - ES_GET_STATE(I_MIN); - #endif - #if USE_J_MAX - ES_GET_STATE(J_MAX); - #endif - #if USE_J_MIN - ES_GET_STATE(J_MIN); - #endif - #if USE_K_MAX - ES_GET_STATE(K_MAX); - #endif - #if USE_K_MIN - ES_GET_STATE(K_MIN); - #endif - #if USE_U_MAX - ES_GET_STATE(U_MAX); - #endif - #if USE_U_MIN - ES_GET_STATE(U_MIN); - #endif - #if USE_V_MAX - ES_GET_STATE(V_MAX); - #endif - #if USE_V_MIN - ES_GET_STATE(V_MIN); - #endif - #if USE_W_MAX - ES_GET_STATE(W_MAX); - #endif - #if USE_W_MIN - ES_GET_STATE(W_MIN); - #endif + TERF(USE_X_MIN, ES_GET_STATE)(X_MIN); + TERF(USE_X_MAX, ES_GET_STATE)(X_MAX); + TERF(USE_Y_MIN, ES_GET_STATE)(Y_MIN); + TERF(USE_Y_MAX, ES_GET_STATE)(Y_MAX); + TERF(USE_Z_MIN, ES_GET_STATE)(Z_MIN); + TERF(USE_Z_MAX, ES_GET_STATE)(Z_MAX); + TERF(USE_Z_MIN_PROBE, ES_GET_STATE)(Z_MIN_PROBE); + TERF(USE_CALIBRATION, ES_GET_STATE)(CALIBRATION); + TERF(USE_X2_MIN, ES_GET_STATE)(X2_MIN); + TERF(USE_X2_MAX, ES_GET_STATE)(X2_MAX); + TERF(USE_Y2_MIN, ES_GET_STATE)(Y2_MIN); + TERF(USE_Y2_MAX, ES_GET_STATE)(Y2_MAX); + TERF(USE_Z2_MIN, ES_GET_STATE)(Z2_MIN); + TERF(USE_Z2_MAX, ES_GET_STATE)(Z2_MAX); + TERF(USE_Z3_MIN, ES_GET_STATE)(Z3_MIN); + TERF(USE_Z3_MAX, ES_GET_STATE)(Z3_MAX); + TERF(USE_Z4_MIN, ES_GET_STATE)(Z4_MIN); + TERF(USE_Z4_MAX, ES_GET_STATE)(Z4_MAX); + TERF(USE_I_MAX, ES_GET_STATE)(I_MAX); + TERF(USE_I_MIN, ES_GET_STATE)(I_MIN); + TERF(USE_J_MAX, ES_GET_STATE)(J_MAX); + TERF(USE_J_MIN, ES_GET_STATE)(J_MIN); + TERF(USE_K_MAX, ES_GET_STATE)(K_MAX); + TERF(USE_K_MIN, ES_GET_STATE)(K_MIN); + TERF(USE_U_MAX, ES_GET_STATE)(U_MAX); + TERF(USE_U_MIN, ES_GET_STATE)(U_MIN); + TERF(USE_V_MAX, ES_GET_STATE)(V_MAX); + TERF(USE_V_MIN, ES_GET_STATE)(V_MIN); + TERF(USE_W_MAX, ES_GET_STATE)(W_MAX); + TERF(USE_W_MIN, ES_GET_STATE)(W_MIN); const 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)) if (endstop_change) { - #if USE_X_MIN - ES_REPORT_CHANGE(X_MIN); - #endif - #if USE_X_MAX - ES_REPORT_CHANGE(X_MAX); - #endif - #if USE_Y_MIN - ES_REPORT_CHANGE(Y_MIN); - #endif - #if USE_Y_MAX - ES_REPORT_CHANGE(Y_MAX); - #endif - #if USE_Z_MIN - ES_REPORT_CHANGE(Z_MIN); - #endif - #if USE_Z_MAX - ES_REPORT_CHANGE(Z_MAX); - #endif - #if USE_Z_MIN_PROBE - ES_REPORT_CHANGE(Z_MIN_PROBE); - #endif - #if USE_CALIBRATION - ES_REPORT_CHANGE(CALIBRATION); - #endif - #if USE_X2_MIN - ES_REPORT_CHANGE(X2_MIN); - #endif - #if USE_X2_MAX - ES_REPORT_CHANGE(X2_MAX); - #endif - #if USE_Y2_MIN - ES_REPORT_CHANGE(Y2_MIN); - #endif - #if USE_Y2_MAX - ES_REPORT_CHANGE(Y2_MAX); - #endif - #if USE_Z2_MIN - ES_REPORT_CHANGE(Z2_MIN); - #endif - #if USE_Z2_MAX - ES_REPORT_CHANGE(Z2_MAX); - #endif - #if USE_Z3_MIN - ES_REPORT_CHANGE(Z3_MIN); - #endif - #if USE_Z3_MAX - ES_REPORT_CHANGE(Z3_MAX); - #endif - #if USE_Z4_MIN - ES_REPORT_CHANGE(Z4_MIN); - #endif - #if USE_Z4_MAX - ES_REPORT_CHANGE(Z4_MAX); - #endif - #if USE_I_MIN - ES_REPORT_CHANGE(I_MIN); - #endif - #if USE_I_MAX - ES_REPORT_CHANGE(I_MAX); - #endif - #if USE_J_MIN - ES_REPORT_CHANGE(J_MIN); - #endif - #if USE_J_MAX - ES_REPORT_CHANGE(J_MAX); - #endif - #if USE_K_MIN - ES_REPORT_CHANGE(K_MIN); - #endif - #if USE_K_MAX - ES_REPORT_CHANGE(K_MAX); - #endif - #if USE_U_MIN - ES_REPORT_CHANGE(U_MIN); - #endif - #if USE_U_MAX - ES_REPORT_CHANGE(U_MAX); - #endif - #if USE_V_MIN - ES_REPORT_CHANGE(V_MIN); - #endif - #if USE_V_MAX - ES_REPORT_CHANGE(V_MAX); - #endif - #if USE_W_MIN - ES_REPORT_CHANGE(W_MIN); - #endif - #if USE_W_MAX - ES_REPORT_CHANGE(W_MAX); - #endif + TERF(USE_X_MIN, ES_REPORT_CHANGE)(X_MIN); + TERF(USE_X_MAX, ES_REPORT_CHANGE)(X_MAX); + TERF(USE_Y_MIN, ES_REPORT_CHANGE)(Y_MIN); + TERF(USE_Y_MAX, ES_REPORT_CHANGE)(Y_MAX); + TERF(USE_Z_MIN, ES_REPORT_CHANGE)(Z_MIN); + TERF(USE_Z_MAX, ES_REPORT_CHANGE)(Z_MAX); + TERF(USE_Z_MIN_PROBE, ES_REPORT_CHANGE)(Z_MIN_PROBE); + TERF(USE_CALIBRATION, ES_REPORT_CHANGE)(CALIBRATION); + TERF(USE_X2_MIN, ES_REPORT_CHANGE)(X2_MIN); + TERF(USE_X2_MAX, ES_REPORT_CHANGE)(X2_MAX); + TERF(USE_Y2_MIN, ES_REPORT_CHANGE)(Y2_MIN); + TERF(USE_Y2_MAX, ES_REPORT_CHANGE)(Y2_MAX); + TERF(USE_Z2_MIN, ES_REPORT_CHANGE)(Z2_MIN); + TERF(USE_Z2_MAX, ES_REPORT_CHANGE)(Z2_MAX); + TERF(USE_Z3_MIN, ES_REPORT_CHANGE)(Z3_MIN); + TERF(USE_Z3_MAX, ES_REPORT_CHANGE)(Z3_MAX); + TERF(USE_Z4_MIN, ES_REPORT_CHANGE)(Z4_MIN); + TERF(USE_Z4_MAX, ES_REPORT_CHANGE)(Z4_MAX); + TERF(USE_I_MIN, ES_REPORT_CHANGE)(I_MIN); + TERF(USE_I_MAX, ES_REPORT_CHANGE)(I_MAX); + TERF(USE_J_MIN, ES_REPORT_CHANGE)(J_MIN); + TERF(USE_J_MAX, ES_REPORT_CHANGE)(J_MAX); + TERF(USE_K_MIN, ES_REPORT_CHANGE)(K_MIN); + TERF(USE_K_MAX, ES_REPORT_CHANGE)(K_MAX); + TERF(USE_U_MIN, ES_REPORT_CHANGE)(U_MIN); + TERF(USE_U_MAX, ES_REPORT_CHANGE)(U_MAX); + TERF(USE_V_MIN, ES_REPORT_CHANGE)(V_MIN); + TERF(USE_V_MAX, ES_REPORT_CHANGE)(V_MAX); + TERF(USE_W_MIN, ES_REPORT_CHANGE)(W_MIN); + TERF(USE_W_MAX, ES_REPORT_CHANGE)(W_MAX); SERIAL_ECHOLNPGM("\n"); hal.set_pwm_duty(pin_t(LED_PIN), local_LED_status); diff --git a/Marlin/src/module/stepper/control.cpp b/Marlin/src/module/stepper/control.cpp index ec7ec878c4..6aaec687c8 100644 --- a/Marlin/src/module/stepper/control.cpp +++ b/Marlin/src/module/stepper/control.cpp @@ -96,12 +96,8 @@ #if ANY_PIN(MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K, MOTOR_CURRENT_PWM_U, MOTOR_CURRENT_PWM_V, MOTOR_CURRENT_PWM_W) case 0: #endif - #if HAS_MOTOR_CURRENT_PWM_Z - case 1: - #endif - #if HAS_MOTOR_CURRENT_PWM_E - case 2: - #endif + TERN_(HAS_MOTOR_CURRENT_PWM_Z, case 1:) + TERN_(HAS_MOTOR_CURRENT_PWM_E, case 2:) set_digipot_current(i, motor_current_setting[i]); default: break; } @@ -385,38 +381,22 @@ if (ms1 >= 0) switch (driver) { #if HAS_X_MS_PINS || HAS_X2_MS_PINS case X_AXIS: - #if HAS_X_MS_PINS - WRITE(X_MS1_PIN, ms1); - #endif - #if HAS_X2_MS_PINS - WRITE(X2_MS1_PIN, ms1); - #endif + TERF(HAS_X_MS_PINS, WRITE)(X_MS1_PIN, ms1); + TERF(HAS_X2_MS_PINS, WRITE)(X2_MS1_PIN, ms1); break; #endif #if HAS_Y_MS_PINS || HAS_Y2_MS_PINS case Y_AXIS: - #if HAS_Y_MS_PINS - WRITE(Y_MS1_PIN, ms1); - #endif - #if HAS_Y2_MS_PINS - WRITE(Y2_MS1_PIN, ms1); - #endif + TERF(HAS_Y_MS_PINS, WRITE)(Y_MS1_PIN, ms1); + TERF(HAS_Y2_MS_PINS, WRITE)(Y2_MS1_PIN, ms1); break; #endif #if HAS_SOME_Z_MS_PINS case Z_AXIS: - #if HAS_Z_MS_PINS - WRITE(Z_MS1_PIN, ms1); - #endif - #if HAS_Z2_MS_PINS - WRITE(Z2_MS1_PIN, ms1); - #endif - #if HAS_Z3_MS_PINS - WRITE(Z3_MS1_PIN, ms1); - #endif - #if HAS_Z4_MS_PINS - WRITE(Z4_MS1_PIN, ms1); - #endif + TERF(HAS_Z_MS_PINS, WRITE)(Z_MS1_PIN, ms1); + TERF(HAS_Z2_MS_PINS, WRITE)(Z2_MS1_PIN, ms1); + TERF(HAS_Z3_MS_PINS, WRITE)(Z3_MS1_PIN, ms1); + TERF(HAS_Z4_MS_PINS, WRITE)(Z4_MS1_PIN, ms1); break; #endif #if HAS_I_MS_PINS @@ -465,38 +445,22 @@ if (ms2 >= 0) switch (driver) { #if HAS_X_MS_PINS || HAS_X2_MS_PINS case X_AXIS: - #if HAS_X_MS_PINS - WRITE(X_MS2_PIN, ms2); - #endif - #if HAS_X2_MS_PINS - WRITE(X2_MS2_PIN, ms2); - #endif + TERF(HAS_X_MS_PINS, WRITE)(X_MS2_PIN, ms2); + TERF(HAS_X2_MS_PINS, WRITE)(X2_MS2_PIN, ms2); break; #endif #if HAS_Y_MS_PINS || HAS_Y2_MS_PINS case Y_AXIS: - #if HAS_Y_MS_PINS - WRITE(Y_MS2_PIN, ms2); - #endif - #if HAS_Y2_MS_PINS - WRITE(Y2_MS2_PIN, ms2); - #endif + TERF(HAS_Y_MS_PINS, WRITE)(Y_MS2_PIN, ms2); + TERF(HAS_Y2_MS_PINS, WRITE)(Y2_MS2_PIN, ms2); break; #endif #if HAS_SOME_Z_MS_PINS case Z_AXIS: - #if HAS_Z_MS_PINS - WRITE(Z_MS2_PIN, ms2); - #endif - #if HAS_Z2_MS_PINS - WRITE(Z2_MS2_PIN, ms2); - #endif - #if HAS_Z3_MS_PINS - WRITE(Z3_MS2_PIN, ms2); - #endif - #if HAS_Z4_MS_PINS - WRITE(Z4_MS2_PIN, ms2); - #endif + TERF(HAS_Z_MS_PINS, WRITE)(Z_MS2_PIN, ms2); + TERF(HAS_Z2_MS_PINS, WRITE)(Z2_MS2_PIN, ms2); + TERF(HAS_Z3_MS_PINS, WRITE)(Z3_MS2_PIN, ms2); + TERF(HAS_Z4_MS_PINS, WRITE)(Z4_MS2_PIN, ms2); break; #endif #if HAS_I_MS_PINS diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 418f8c498a..96ea110963 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -4143,9 +4143,9 @@ void Temperature::isr() { REPEAT(HOTENDS, _PWM_LOW_E); #endif - TERF(HAS_HEATED_BED, _PWM_LOW)(BED, soft_pwm_bed); + TERF(HAS_HEATED_BED, _PWM_LOW)(BED, soft_pwm_bed); TERF(HAS_HEATED_CHAMBER, _PWM_LOW)(CHAMBER, soft_pwm_chamber); - TERF(HAS_COOLER, _PWM_LOW)(COOLER, soft_pwm_cooler); + TERF(HAS_COOLER, _PWM_LOW)(COOLER, soft_pwm_cooler); #if ENABLED(FAN_SOFT_PWM) #if HAS_FAN0 @@ -4208,9 +4208,9 @@ void Temperature::isr() { REPEAT(HOTENDS, _SLOW_PWM_E); #endif - TERF(HAS_HEATED_BED, _SLOW_PWM)(BED, soft_pwm_bed, temp_bed); + TERF(HAS_HEATED_BED, _SLOW_PWM)(BED, soft_pwm_bed, temp_bed); TERF(HAS_HEATED_CHAMBER, _SLOW_PWM)(CHAMBER, soft_pwm_chamber, temp_chamber); - TERF(HAS_COOLER, _SLOW_PWM)(COOLER, soft_pwm_cooler, temp_cooler); + TERF(HAS_COOLER, _SLOW_PWM)(COOLER, soft_pwm_cooler, temp_cooler); } // slow_pwm_count == 0 @@ -4219,9 +4219,9 @@ void Temperature::isr() { REPEAT(HOTENDS, _PWM_OFF_E); #endif - TERF(HAS_HEATED_BED, _PWM_OFF)(BED, soft_pwm_bed); + TERF(HAS_HEATED_BED, _PWM_OFF)(BED, soft_pwm_bed); TERF(HAS_HEATED_CHAMBER, _PWM_OFF)(CHAMBER, soft_pwm_chamber); - TERF(HAS_COOLER, _PWM_OFF)(COOLER, soft_pwm_cooler, temp_cooler); + TERF(HAS_COOLER, _PWM_OFF)(COOLER, soft_pwm_cooler, temp_cooler); #if ENABLED(FAN_SOFT_PWM) if (pwm_count_tmp >= 127) { From 3e4344ad7a066cea164938b907cbe849ff6c17b2 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Thu, 27 Nov 2025 06:11:36 +0000 Subject: [PATCH 19/39] [cron] Bump distribution date (2025-11-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 3a3b6a57b7..1cf1b23558 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 "2025-11-26" +//#define STRING_DISTRIBUTION_DATE "2025-11-27" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index b1cb664d41..e768d28ce1 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 "2025-11-26" + #define STRING_DISTRIBUTION_DATE "2025-11-27" #endif /** From 64182d60aa1578d0078efd1d0ab46aea2092eb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20Sep=C3=BAlveda?= Date: Thu, 27 Nov 2025 17:38:04 -0300 Subject: [PATCH 20/39] =?UTF-8?q?=F0=9F=8E=A8=20Patches=20for=20README=20(?= =?UTF-8?q?#28194)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 45e91d62c0..7de24fb08b 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ Marlin is compatible with a plethora of 32-bit ARM boards, which offer ample com ## 8-Bit AVR Boards -Marlin originates from the era of Arduino based 8-bit boards, and we aim to support 8-bit AVR boards in perpetuity. Both 32-bit and 8-bit boards are covered by a single code base that can apply to all machines. Our goal is to support casual hobbyists, tinkerers, and owners of older machines and boards, striving to allow them to benefit from the community's innovations just as much as those with fancier machines and newer baords. In addition, these venerable AVR-based machines are often the best for testing and feedback! +Marlin originates from the era of Arduino based 8-bit boards, and we aim to support 8-bit AVR boards in perpetuity. Both 32-bit and 8-bit boards are covered by a single code base that can apply to all machines. Our goal is to support casual hobbyists, tinkerers, and owners of older machines and boards, striving to allow them to benefit from the community's innovations just as much as those with fancier machines and newer boards. In addition, these venerable AVR-based machines are often the best for testing and feedback! ## Hardware Abstraction Layer (HAL) @@ -110,17 +110,17 @@ Did you know that Marlin includes a Simulator that can run on Windows, macOS, an ### Supported Platforms -| Platform | MCU | Example Boards | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | ---------------------------------------------------------- | -| [Arduino AVR](//www.arduino.cc/) | ATmega | RAMPS, Melzi, RAMBo | -| [Teensy++ 2.0](//www.microchip.com/en-us/product/AT90USB1286) | AT90USB1286 | Printrboard | -| [Arduino Due](//www.arduino.cc/en/Guide/ArduinoDue) | SAM3X8E | RAMPS-FD, RADDS, RAMPS4DUE | -| [ESP32](//github.com/espressif/arduino-esp32) | ESP32 | FYSETC E4, E4d@BOX, MRR | -| [GD32](//www.gigadevice.com/) | GD32 ARM Cortex-M4 | Creality MFL GD32 V4.2.2 | -| [HC32](//www.huazhoucn.com/) | HC32 | Ender-2 Pro, Voxelab Aquila | +| Platform | MCU | Example Boards | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------- | ---------------------------------------------------------- | +| [Arduino AVR](//www.arduino.cc/) | ATmega | RAMPS, Melzi, RAMBo | +| [Teensy++ 2.0](//www.microchip.com/en-us/product/AT90USB1286) | AT90USB1286 | Printrboard | +| [Arduino Due](//www.arduino.cc/en/Guide/ArduinoDue) | SAM3X8E | RAMPS-FD, RADDS, RAMPS4DUE | +| [ESP32](//github.com/espressif/arduino-esp32) | ESP32 | FYSETC E4, E4d@BOX, MRR | +| [GD32](//www.gigadevice.com/) | GD32 ARM Cortex-M4 | Creality MFL GD32 V4.2.2 | +| [HC32](//www.huazhoucn.com/) | HC32 | Ender-2 Pro, Voxelab Aquila | | [LPC1768](//www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc1700-cortex-m3/512-kb-flash-64-kb-sram-ethernet-usb-lqfp100-package:LPC1768FBD100) | ARM® Cortex-M3 | MKS SBASE, Re-ARM, Selena Compact | | [LPC1769](//www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc1700-cortex-m3/512-kb-flash-64-kb-sram-ethernet-usb-lqfp100-package:LPC1769FBD100) | ARM® Cortex-M3 | Smoothieboard, Azteeg X5 mini, TH3D EZBoard | -| [Pico RP2040](//www.raspberrypi.com/documentation/microcontrollers/pico-series.html) | Dual Cortex M0+ | BigTreeTech SKR Pico | +| [Pico RP2040](//www.raspberrypi.com/documentation/microcontrollers/pico-series.html) | Dual Cortex M0+ | BigTreeTech SKR Pico | | [STM32F103](//www.st.com/en/microcontrollers-microprocessors/stm32f103.html) | ARM® Cortex-M3 | Malyan M200, GTM32 Pro, MKS Robin, BTT SKR Mini | | [STM32F401](//www.st.com/en/microcontrollers-microprocessors/stm32f401.html) | ARM® Cortex-M4 | ARMED, Rumba32, SKR Pro, Lerdge, FYSETC S6, Artillery Ruby | | [STM32F7x6](//www.st.com/en/microcontrollers-microprocessors/stm32f7x6.html) | ARM® Cortex-M7 | The Borg, RemRam V1 | @@ -133,9 +133,9 @@ Did you know that Marlin includes a Simulator that can run on Windows, macOS, an | [Teensy 3.6](//www.pjrc.com/store/teensy36.html) | MK66FX1MB-VMD18 ARM® Cortex-M4 | | [Teensy 4.0](//www.pjrc.com/store/teensy40.html) | MIMXRT1062-DVL6B ARM® Cortex-M7 | | [Teensy 4.1](//www.pjrc.com/store/teensy41.html) | MIMXRT1062-DVJ6B ARM® Cortex-M7 | -| Linux Native | x86 / ARM / RISC-V | Raspberry Pi GPIO | -| Simulator | Windows, macOS, Linux | Desktop OS | -| [All supported boards](//marlinfw.org/docs/hardware/boards.html#boards-list) | All platforms | All boards | +| Linux Native | x86 / ARM / RISC-V | Raspberry Pi GPIO | +| Simulator | Windows, macOS, Linux | Desktop OS | +| [All supported boards](//marlinfw.org/docs/hardware/boards.html#boards-list) | All platforms | All boards | ## Marlin Support From b9f0c68e3c686a7eb0a7e01284ff395a994d3960 Mon Sep 17 00:00:00 2001 From: Vovodroid Date: Fri, 28 Nov 2025 00:41:20 +0200 Subject: [PATCH 21/39] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Minimize=20M190=20an?= =?UTF-8?q?nealing=20code=20(#26888)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/temp/M140_M190.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 1a179873cc..7d2de2084a 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -93,7 +93,7 @@ void GcodeSuite::M140_M190(const bool isM190) { #if ENABLED(BED_ANNEALING_GCODE) const bool anneal = isM190 && !no_wait_for_cooling && parser.seenval('T'); - const millis_t anneal_ms = anneal ? millis() + parser.value_millis_from_seconds() : 0UL; + const millis_t anneal_ms = anneal ? parser.value_millis_from_seconds() : 0UL; #else constexpr bool anneal = false; #endif @@ -110,15 +110,11 @@ void GcodeSuite::M140_M190(const bool isM190) { #if ENABLED(BED_ANNEALING_GCODE) if (anneal) { LCD_MESSAGE(MSG_BED_ANNEALING); + const millis_t wait_ms = anneal_ms / (thermalManager.degBed() - temp); // Loop from current temp down to the target - for (celsius_t cool_temp = thermalManager.degBed(); --cool_temp >= temp; ) { - thermalManager.setTargetBed(cool_temp); // Cool by one degree - thermalManager.wait_for_bed(false); // Could this wait forever? - const millis_t ms = millis(); - if (PENDING(ms, anneal_ms) && cool_temp > temp) { // Still warmer and waiting? - const millis_t remain = anneal_ms - ms; - dwell(remain / (cool_temp - temp)); // Wait for a fraction of remaining time - } + for (celsius_t cool_temp = thermalManager.degBed() - 1; cool_temp >= temp; --cool_temp) { + thermalManager.setTargetBed(cool_temp); // Cool by one degree + dwell(wait_ms); // Wait while going to the next degree } return; } From e3ef8d2089b008b8ba8ad3fa2b519e9820db8a03 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 28 Nov 2025 12:28:32 +1300 Subject: [PATCH 22/39] =?UTF-8?q?=E2=9C=A8=20BOARD=5FRASPBERRY=5FPI=5FPICO?= =?UTF-8?q?=20(and=20other=20RP2040=20updates)=20(#28181)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/RP2040/HAL.cpp | 173 +++++++++++++++--- Marlin/src/HAL/RP2040/HAL.h | 10 +- Marlin/src/HAL/RP2040/eeprom/eeprom_flash.cpp | 42 +++-- Marlin/src/HAL/RP2040/pinsDebug.h | 117 +++++++----- Marlin/src/HAL/RP2040/temp_soc.h | 30 +++ Marlin/src/HAL/RP2040/u8g/LCD_defines.h | 28 +++ .../HAL/RP2040/u8g/u8g_com_rp2040_ssd_i2c.cpp | 108 +++++++++++ Marlin/src/HAL/STM32/pinsDebug.h | 9 +- Marlin/src/core/boards.h | 3 +- Marlin/src/lcd/marlinui.cpp | 6 +- Marlin/src/pins/mega/pins_GT2560_V3.h | 3 +- Marlin/src/pins/mega/pins_INTAMSYS40.h | 2 +- Marlin/src/pins/pins.h | 2 + .../src/pins/rp2040/pins_RASPBERRY_PI_PICO.h | 171 +++++++++++++++++ Marlin/src/pins/rp2040/pins_RP2040.h | 28 ++- Marlin/src/sd/SdBaseFile.h | 13 ++ Marlin/src/sd/SdFatStructs.h | 4 +- ini/raspberrypi.ini | 5 +- 18 files changed, 646 insertions(+), 108 deletions(-) create mode 100644 Marlin/src/HAL/RP2040/temp_soc.h create mode 100644 Marlin/src/HAL/RP2040/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/RP2040/u8g/u8g_com_rp2040_ssd_i2c.cpp create mode 100644 Marlin/src/pins/rp2040/pins_RASPBERRY_PI_PICO.h diff --git a/Marlin/src/HAL/RP2040/HAL.cpp b/Marlin/src/HAL/RP2040/HAL.cpp index e8d0eea7cd..9341480078 100644 --- a/Marlin/src/HAL/RP2040/HAL.cpp +++ b/Marlin/src/HAL/RP2040/HAL.cpp @@ -32,17 +32,123 @@ extern "C" { #include "pico/bootrom.h" #include "hardware/watchdog.h" + #include "pico/multicore.h" + #include "hardware/adc.h" + #include "pico/time.h" } #if HAS_SD_HOST_DRIVE #include "msc_sd.h" - #include "usbd_cdc_if.h" #endif +// Core 1 watchdog configuration +#define CORE1_MAX_RESETS 5 // Maximum number of Core 1 resets before halting system + // ------------------------ // Public Variables // ------------------------ +volatile uint32_t adc_accumulators[5] = {0}; // Accumulators for oversampling (sum of readings) +volatile uint8_t adc_counts[5] = {0}; // Count of readings accumulated per channel +volatile uint16_t adc_values[5] = {512, 512, 512, 512, 512}; // Final oversampled ADC values (averages) - initialized to mid-range + +// Core 1 watchdog monitoring +volatile uint32_t core1_last_heartbeat = 0; // Timestamp of Core 1's last activity +volatile bool core1_watchdog_triggered = false; // Flag to indicate Core 1 reset +volatile uint8_t core1_reset_count = 0; // Count of Core 1 resets - halt system if >= CORE1_MAX_RESETS +volatile uint8_t current_pin; +volatile bool MarlinHAL::adc_has_result; +volatile uint8_t adc_channels_enabled[5] = {false}; // Track which ADC channels are enabled + +// Helper function for LED blinking patterns +void blink_led_pattern(uint8_t blink_count, uint32_t blink_duration_us = 100000) { + #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) + for (uint8_t i = 0; i < blink_count; i++) { + WRITE(LED_PIN, HIGH); + busy_wait_us(blink_duration_us); + WRITE(LED_PIN, LOW); + if (i < blink_count - 1) { // Don't delay after the last blink + busy_wait_us(blink_duration_us); + } + } + #endif +} + +// Core 1 ADC reading task - dynamically reads all enabled channels with oversampling +void core1_adc_task() { + static uint32_t last_led_toggle = 0; + const uint8_t OVERSAMPLENR = 16; // Standard Marlin oversampling count + + // Signal successful Core 1 startup/restart + SERIAL_ECHO_MSG("Core 1 ADC task started"); + + while (true) { + // Update heartbeat timestamp at start of each scan cycle + core1_last_heartbeat = time_us_32(); + + // Scan all enabled ADC channels + for (uint8_t channel = 0; channel < 5; channel++) { + if (!adc_channels_enabled[channel]) continue; + + // Enable temperature sensor if reading channel 4 + if (channel == 4) { + adc_set_temp_sensor_enabled(true); + } + + // Select and read the channel + adc_select_input(channel); + busy_wait_us(100); // Settling delay + adc_fifo_drain(); + adc_run(true); + + // Wait for conversion with timeout + uint32_t timeout = 10000; + while (adc_fifo_is_empty() && timeout--) { + busy_wait_us(1); + } + + adc_run(false); + uint16_t reading = adc_fifo_is_empty() ? 0 : adc_fifo_get(); + + // Accumulate readings for oversampling + adc_accumulators[channel] += reading; + adc_counts[channel]++; + + // Update the averaged value with current accumulation (provides immediate valid data) + adc_values[channel] = adc_accumulators[channel] / adc_counts[channel]; + + // When we reach the full oversampling count, reset accumulator for next cycle + if (adc_counts[channel] >= OVERSAMPLENR) { + adc_accumulators[channel] = 0; + adc_counts[channel] = 0; + } + + // Disable temp sensor after reading to save power + if (channel == 4) { + adc_set_temp_sensor_enabled(false); + } + } + + // Core 1 LED indicator: Double blink every 2 seconds to show Core 1 is active + uint32_t now = time_us_32(); + if (now - last_led_toggle >= 2000000) { // 2 seconds + last_led_toggle = now; + #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) + // Triple blink pattern if watchdog was triggered (shows Core 1 was reset) + if (core1_watchdog_triggered) { + core1_watchdog_triggered = false; // Clear flag + blink_led_pattern(3); // Triple blink for watchdog reset + } else { + blink_led_pattern(2); // Normal double blink + } + #endif + } + + // Delay between full scan cycles + busy_wait_us(10000); // 10ms between scans + } +} + volatile uint16_t adc_result; // ------------------------ @@ -118,9 +224,28 @@ void MarlinHAL::reboot() { watchdog_reboot(0, 0, 1); } } void MarlinHAL::watchdog_refresh() { + // If Core 1 has reset CORE1_MAX_RESETS+ times, stop updating watchdog to halt system + if (core1_reset_count >= CORE1_MAX_RESETS) { + SERIAL_ECHO_MSG("Core 1 reset limit exceeded (", core1_reset_count, " resets) - halting system for safety"); + return; // Don't update watchdog - system will halt + } + watchdog_update(); + + // Check Core 1 watchdog (15 second timeout) + uint32_t now = time_us_32(); + if (now - core1_last_heartbeat > 15000000) { // 15 seconds + // Core 1 appears stuck - reset it + multicore_reset_core1(); + multicore_launch_core1(core1_adc_task); + core1_watchdog_triggered = true; // Signal for LED indicator + core1_reset_count++; // Increment reset counter + SERIAL_ECHO_MSG("Core 1 ADC watchdog triggered - resetting Core 1 (attempt ", core1_reset_count, ")"); + } + #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) - TOGGLE(LED_PIN); // heartbeat indicator + // Core 0 LED indicator: Single toggle every watchdog refresh (shows Core 0 activity) + TOGGLE(LED_PIN); #endif } @@ -130,43 +255,35 @@ void MarlinHAL::reboot() { watchdog_reboot(0, 0, 1); } // ADC // ------------------------ -volatile bool MarlinHAL::adc_has_result = false; - void MarlinHAL::adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); ::adc_init(); adc_fifo_setup(true, false, 1, false, false); - irq_set_exclusive_handler(ADC_IRQ_FIFO, adc_exclusive_handler); - irq_set_enabled(ADC_IRQ_FIFO, true); - adc_irq_set_enabled(true); + // Launch Core 1 for continuous ADC reading + multicore_launch_core1(core1_adc_task); + adc_has_result = true; // Results are always available with continuous sampling } void MarlinHAL::adc_enable(const pin_t pin) { - if (pin >= A0 && pin <= A3) + if (pin >= A0 && pin <= A3) { adc_gpio_init(pin); - else if (pin == HAL_ADC_MCU_TEMP_DUMMY_PIN) - adc_set_temp_sensor_enabled(true); -} - -void MarlinHAL::adc_start(const pin_t pin) { - adc_has_result = false; - // Select an ADC input. 0...3 are GPIOs 26...29 respectively. - adc_select_input(pin == HAL_ADC_MCU_TEMP_DUMMY_PIN ? 4 : pin - A0); - adc_run(true); -} - -void MarlinHAL::adc_exclusive_handler() { - adc_run(false); // Disable since we only want one result - irq_clear(ADC_IRQ_FIFO); // Clear the IRQ - - if (adc_fifo_get_level() >= 1) { - adc_result = adc_fifo_get(); // Pop the result - adc_fifo_drain(); - adc_has_result = true; // Signal the end of the conversion + adc_channels_enabled[pin - A0] = true; // Mark this channel as enabled + } + else if (pin == HAL_ADC_MCU_TEMP_DUMMY_PIN) { + adc_channels_enabled[4] = true; // Mark MCU temp channel as enabled } } -uint16_t MarlinHAL::adc_value() { return adc_result; } +void MarlinHAL::adc_start(const pin_t pin) { + // Just store which pin we need to read - values are continuously updated by Core 1 + current_pin = pin; +} + +uint16_t MarlinHAL::adc_value() { + // Return the latest ADC value from Core 1's continuous readings + const uint8_t channel = (current_pin == HAL_ADC_MCU_TEMP_DUMMY_PIN) ? 4 : (current_pin - A0); + return adc_values[channel]; +} // Reset the system to initiate a firmware flash void flashFirmware(const int16_t) { hal.reboot(); } diff --git a/Marlin/src/HAL/RP2040/HAL.h b/Marlin/src/HAL/RP2040/HAL.h index 11472f72f5..206847053b 100644 --- a/Marlin/src/HAL/RP2040/HAL.h +++ b/Marlin/src/HAL/RP2040/HAL.h @@ -40,6 +40,11 @@ #include "msc_sd.h" #endif +// ADC index 4 is the MCU temperature +#define HAL_ADC_MCU_TEMP_DUMMY_PIN 127 +#define TEMP_SOC_PIN HAL_ADC_MCU_TEMP_DUMMY_PIN // ADC4 is internal temp sensor +#include "temp_soc.h" + // // Serial Ports // @@ -85,8 +90,6 @@ typedef libServo hal_servo_t; #else #define HAL_ADC_RESOLUTION 12 #endif -// ADC index 4 is the MCU temperature -#define HAL_ADC_MCU_TEMP_DUMMY_PIN 127 // // Pin Mapping for M42, M43, M226 @@ -164,9 +167,6 @@ public: // Begin ADC sampling on the given pin. Called from Temperature::isr! static void adc_start(const pin_t pin); - // This ADC runs a periodic task - static void adc_exclusive_handler(); - // Is the ADC ready for reading? static volatile bool adc_has_result; static bool adc_ready() { return adc_has_result; } diff --git a/Marlin/src/HAL/RP2040/eeprom/eeprom_flash.cpp b/Marlin/src/HAL/RP2040/eeprom/eeprom_flash.cpp index 89e882d77b..bf52109173 100644 --- a/Marlin/src/HAL/RP2040/eeprom/eeprom_flash.cpp +++ b/Marlin/src/HAL/RP2040/eeprom/eeprom_flash.cpp @@ -31,28 +31,48 @@ // NOTE: The Bigtreetech SKR Pico has an onboard W25Q16 flash module -// Use EEPROM.h for compatibility, for now. -#include +// RP2040 Flash-based EEPROM emulation using internal flash memory +#include +#include -static bool eeprom_data_written = false; +// Flash sector size is already defined in hardware/flash.h as FLASH_SECTOR_SIZE +// Place EEPROM emulation at the end of flash, before the filesystem +// This assumes 2MB flash, adjust if using different flash size +#define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES - FLASH_SECTOR_SIZE) #ifndef MARLIN_EEPROM_SIZE #define MARLIN_EEPROM_SIZE size_t(E2END + 1) #endif + +static uint8_t eeprom_buffer[MARLIN_EEPROM_SIZE]; +static bool eeprom_data_written = false; +static bool eeprom_initialized = false; size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } bool PersistentStore::access_start() { - EEPROM.begin(); // Avoid EEPROM.h warning (do nothing) - eeprom_buffer_fill(); + if (!eeprom_initialized) { + // Read from flash into buffer + const uint8_t *flash_data = (const uint8_t *)(XIP_BASE + FLASH_TARGET_OFFSET); + memcpy(eeprom_buffer, flash_data, MARLIN_EEPROM_SIZE); + eeprom_initialized = true; + } return true; } bool PersistentStore::access_finish() { if (eeprom_data_written) { TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); - hal.isr_off(); - eeprom_buffer_flush(); - hal.isr_on(); + + // Disable interrupts during flash write + const uint32_t intstate = save_and_disable_interrupts(); + + // Erase and program the sector + flash_range_erase(FLASH_TARGET_OFFSET, FLASH_SECTOR_SIZE); + flash_range_program(FLASH_TARGET_OFFSET, eeprom_buffer, MARLIN_EEPROM_SIZE); + + // Restore interrupts + restore_interrupts(intstate); + TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); eeprom_data_written = false; } @@ -62,8 +82,8 @@ bool PersistentStore::access_finish() { bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { while (size--) { uint8_t v = *value; - if (v != eeprom_buffered_read_byte(pos)) { - eeprom_buffered_write_byte(pos, v); + if (pos < (int)MARLIN_EEPROM_SIZE && v != eeprom_buffer[pos]) { + eeprom_buffer[pos] = v; eeprom_data_written = true; } crc16(crc, &v, 1); @@ -75,7 +95,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { do { - const uint8_t c = eeprom_buffered_read_byte(pos); + const uint8_t c = (pos < (int)MARLIN_EEPROM_SIZE) ? eeprom_buffer[pos] : 0xFF; if (writing) *value = c; crc16(crc, &c, 1); pos++; diff --git a/Marlin/src/HAL/RP2040/pinsDebug.h b/Marlin/src/HAL/RP2040/pinsDebug.h index f3842c4aff..8f58089fb1 100644 --- a/Marlin/src/HAL/RP2040/pinsDebug.h +++ b/Marlin/src/HAL/RP2040/pinsDebug.h @@ -25,7 +25,7 @@ #include "HAL.h" #ifndef NUM_DIGITAL_PINS - #error "Expected NUM_DIGITAL_PINS not found" + #error "Expected NUM_DIGITAL_PINS not found." #endif /** @@ -74,6 +74,27 @@ * signal. The Arduino pin number is listed by the M43 I command. */ +/** + * Pins Debugging for RP2040 + * + * - NUMBER_PINS_TOTAL + * - MULTI_NAME_PAD + * - getPinByIndex(index) + * - printPinNameByIndex(index) + * - getPinIsDigitalByIndex(index) + * - digitalPinToAnalogIndex(pin) + * - getValidPinMode(pin) + * - isValidPin(pin) + * - isAnalogPin(pin) + * - digitalRead_mod(pin) + * - pwm_status(pin) + * - printPinPWM(pin) + * - printPinPort(pin) + * - printPinNumber(pin) + * - printPinAnalog(pin) + */ + +#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS #define NUM_ANALOG_FIRST A0 #define MODE_PIN_INPUT 0 // Input mode (reset state) @@ -81,66 +102,66 @@ #define MODE_PIN_ALT 2 // Alternate function mode #define MODE_PIN_ANALOG 3 // Analog mode -#define PIN_NUM(P) (P & 0x000F) -#define PIN_NUM_ALPHA_LEFT(P) (((P & 0x000F) < 10) ? ('0' + (P & 0x000F)) : '1') -#define PIN_NUM_ALPHA_RIGHT(P) (((P & 0x000F) > 9) ? ('0' + (P & 0x000F) - 10) : 0 ) -#define PORT_NUM(P) ((P >> 4) & 0x0007) -#define PORT_ALPHA(P) ('A' + (P >> 4)) +#define getPinByIndex(x) pin_array[x].pin +#define printPinNameByIndex(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) +#define getPinIsDigitalByIndex(x) pin_array[x].is_digital +#define digitalPinToAnalogIndex(P) digital_pin_to_analog_pin(P) -/** - * Translation of routines & variables used by pinsDebug.h - */ -#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS -#define VALID_PIN(ANUM) (pin_t(ANUM) >= 0 && pin_t(ANUM) < NUMBER_PINS_TOTAL) -#define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads -#define PRINT_PIN(Q) -#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) -#define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine +uint8_t get_pin_mode(const pin_t pin) { + // Check if pin is in alternate function mode (I2C, SPI, etc.) + const uint32_t gpio_func = gpio_get_function(pin); -// x is a variable used to search pin_array -#define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital) -#define GET_ARRAY_PIN(x) ((pin_t) pin_array[x].pin) -#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 - -uint8_t get_pin_mode(const pin_t Ard_num) { - - uint dir = gpio_get_dir( Ard_num); - - if (dir) return MODE_PIN_OUTPUT; - else return MODE_PIN_INPUT; + // GPIO_FUNC_I2C is typically function 3 on RP2040 + if ( gpio_func == GPIO_FUNC_I2C + || gpio_func == GPIO_FUNC_SPI + || gpio_func == GPIO_FUNC_UART + || gpio_func == GPIO_FUNC_PWM + ) { + return MODE_PIN_ALT; + } + // For GPIO mode, check direction + return gpio_get_dir(pin) ? MODE_PIN_OUTPUT : MODE_PIN_INPUT; } -bool getValidPinMode(const pin_t Ard_num) { - const uint8_t pin_mode = get_pin_mode(Ard_num); +bool getValidPinMode(const pin_t pin) { + const uint8_t pin_mode = get_pin_mode(pin); return pin_mode == MODE_PIN_OUTPUT || pin_mode == MODE_PIN_ALT; // assume all alt definitions are PWM } -int8_t digital_pin_to_analog_pin(pin_t Ard_num) { - Ard_num -= NUM_ANALOG_FIRST; - return (Ard_num >= 0 && Ard_num < NUM_ANALOG_INPUTS) ? Ard_num : -1; +#define isValidPin(P) WITHIN(P, 0, pin_t(NUMBER_PINS_TOTAL - 1)) + +int8_t digital_pin_to_analog_pin(pin_t pin) { + pin -= NUM_ANALOG_FIRST; + return (WITHIN(pin, 0, NUM_ANALOG_INPUTS - 1)) ? pin : -1; } -bool isAnalogPin(const pin_t Ard_num) { - return digital_pin_to_analog_pin(Ard_num) != -1; +bool isAnalogPin(const pin_t pin) { + return digital_pin_to_analog_pin(pin) != -1; } -bool is_digital(const pin_t x) { - const uint8_t pin_mode = get_pin_mode(x); - return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT; +#define digitalRead_mod(A) extDigitalRead(A) // must use Arduino pin numbers when doing reads +#define printPinNumber(P) do{ sprintf_P(buffer, PSTR("%3d "), P); SERIAL_ECHO(buffer); }while(0) +#define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0) +#define MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin + +//bool is_digital(const pin_t pin) { +// const uint8_t pin_mode = get_pin_mode(pin); +// return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT; +//} + +bool pwm_status(const pin_t pin) { + // Check if this pin is configured for PWM + return PWM_PIN(pin) && get_pin_mode(pin) == MODE_PIN_ALT; } -void printPinPort(const pin_t Ard_num) { - SERIAL_ECHOPGM("Pin: "); - SERIAL_ECHO(Ard_num); -} - -bool pwm_status(const pin_t Ard_num) { - return get_pin_mode(Ard_num) == MODE_PIN_ALT; -} - -void printPinPWM(const pin_t Ard_num) { - if (PWM_PIN(Ard_num)) { +void printPinPWM(const pin_t pin) { + if (pwm_status(pin)) { + // RP2040 has hardware PWM on specific pins + char buffer[22]; + sprintf_P(buffer, PSTR("PWM: pin %d "), pin); + SERIAL_ECHO(buffer); } } + +void printPinPort(const pin_t pin) {} diff --git a/Marlin/src/HAL/RP2040/temp_soc.h b/Marlin/src/HAL/RP2040/temp_soc.h new file mode 100644 index 0000000000..e182fb88dc --- /dev/null +++ b/Marlin/src/HAL/RP2040/temp_soc.h @@ -0,0 +1,30 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 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 + +// RP2040 internal temperature sensor +// Formula: T = 27 - (ADC_voltage - 0.706) / 0.001721 +// ADC_voltage = (RAW / OVERSAMPLENR) * 3.3 / 4096 (RAW is accumulated over OVERSAMPLENR samples) +// T = 27 - ((RAW / OVERSAMPLENR) * 3.3 / 4096 - 0.706) / 0.001721 +// Simplified: T = 437.423 - (RAW / OVERSAMPLENR) * 0.46875 + +#define TEMP_SOC_SENSOR(RAW) (437.423f - ((RAW) / OVERSAMPLENR) * 0.46875f) diff --git a/Marlin/src/HAL/RP2040/u8g/LCD_defines.h b/Marlin/src/HAL/RP2040/u8g/LCD_defines.h new file mode 100644 index 0000000000..acdd94b477 --- /dev/null +++ b/Marlin/src/HAL/RP2040/u8g/LCD_defines.h @@ -0,0 +1,28 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 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 + +/** + * RP2040 LCD-specific defines + */ +uint8_t u8g_com_rp2040_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // u8g_com_rp2040_ssd_i2c.cpp +#define U8G_COM_SSD_I2C_HAL u8g_com_rp2040_ssd_i2c_fn diff --git a/Marlin/src/HAL/RP2040/u8g/u8g_com_rp2040_ssd_i2c.cpp b/Marlin/src/HAL/RP2040/u8g/u8g_com_rp2040_ssd_i2c.cpp new file mode 100644 index 0000000000..ea42bf190d --- /dev/null +++ b/Marlin/src/HAL/RP2040/u8g/u8g_com_rp2040_ssd_i2c.cpp @@ -0,0 +1,108 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 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 . + * + */ + +/** + * 2-Wire I2C COM Driver + * + * Handles Hardware I2C on valid pin combinations. + * Wire library is used for Hardware I2C. + * + * Hardware I2C uses pins defined in pins_arduino.h. + */ + +#ifdef __PLAT_RP2040__ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_U8GLIB_I2C_OLED + +#include + +#include +#ifndef MASTER_ADDRESS + #define MASTER_ADDRESS 0x01 +#endif + +/** + * BUFFER_LENGTH is defined in libraries\Wire\utility\WireBase.h + * Default value is 32 + * Increase this value to 144 to send U8G_COM_MSG_WRITE_SEQ in single block + */ +#ifndef BUFFER_LENGTH + #define BUFFER_LENGTH 32 +#endif +#if BUFFER_LENGTH > 144 + #error "BUFFER_LENGTH should not be greater than 144." +#endif +#define I2C_MAX_LENGTH (BUFFER_LENGTH - 1) + +uint8_t u8g_com_rp2040_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + + // Hardware I2C flag + //static bool i2c_initialized = false; // Flag to only run init/linking code once + //if (!i2c_initialized) { // Init runtime linkages + // i2c_initialized = true; // Only do this once + //} + + static uint8_t control; + // Use the global Wire instance (already initialized with correct pins for RP2040) + switch (msg) { + case U8G_COM_MSG_INIT: + Wire.setClock(400000); + // Wire already initialized in MarlinUI::init(), no need to call begin() again + break; + + case U8G_COM_MSG_ADDRESS: // Define cmd (arg_val = 0) or data mode (arg_val = 1) + control = arg_val ? 0x40 : 0x00; + break; + + case U8G_COM_MSG_WRITE_BYTE: + ::Wire.beginTransmission(0x3C); + ::Wire.write(control); + ::Wire.write(arg_val); + ::Wire.endTransmission(); + break; + + case U8G_COM_MSG_WRITE_SEQ: { + uint8_t* dataptr = (uint8_t*)arg_ptr; + while (arg_val > 0) { + ::Wire.beginTransmission(0x3C); + ::Wire.write(control); + if (arg_val <= I2C_MAX_LENGTH) { + ::Wire.write(dataptr, arg_val); + arg_val = 0; + } + else { + ::Wire.write(dataptr, I2C_MAX_LENGTH); + arg_val -= I2C_MAX_LENGTH; + dataptr += I2C_MAX_LENGTH; + } + ::Wire.endTransmission(); + } + break; + } + } + return 1; +} + +#endif // HAS_U8GLIB_I2C_OLED +#endif // __PLAT_RP2040__ diff --git a/Marlin/src/HAL/STM32/pinsDebug.h b/Marlin/src/HAL/STM32/pinsDebug.h index b14c9c721c..89e2514af0 100644 --- a/Marlin/src/HAL/STM32/pinsDebug.h +++ b/Marlin/src/HAL/STM32/pinsDebug.h @@ -136,10 +136,8 @@ const XrefInfo pin_xref[] PROGMEM = { #define printPinNumber(Q) #define printPinAnalog(P) do{ sprintf_P(buffer, PSTR(" (A%2d) "), digitalPinToAnalogIndex(P)); SERIAL_ECHO(buffer); }while(0) #define digitalPinToAnalogIndex(P) -1 // will report analog pin number in the print port routine - -// x is a variable used to search pin_array -#define getPinIsDigitalByIndex(x) ((bool) pin_array[x].is_digital) -#define getPinByIndex(x) ((pin_t) pin_array[x].pin) +#define getPinIsDigitalByIndex(x) bool(pin_array[x].is_digital) +#define getPinByIndex(x) pin_t(pin_array[x].pin) #define printPinNameByIndex(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 @@ -229,8 +227,7 @@ void printPinPort(const pin_t pin) { calc_p -= NUM_ANALOG_FIRST; if (calc_p > 7) calc_p += 8; } - SERIAL_ECHOPGM(" M42 P", calc_p); - SERIAL_CHAR(' '); + SERIAL_ECHO(F(" M42 P"), calc_p, C(' ')); if (calc_p < 100) { SERIAL_CHAR(' '); if (calc_p < 10) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index f22c9fd1f1..6c51cb01a4 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -578,7 +578,8 @@ // #define BOARD_RP2040 6200 // Generic RP2040 Test board -#define BOARD_BTT_SKR_PICO 6201 // BigTreeTech SKR Pico 1.x +#define BOARD_RASPBERRY_PI_PICO 6201 // Raspberry Pi Pico +#define BOARD_BTT_SKR_PICO 6202 // BigTreeTech SKR Pico 1.x // // Custom board diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index f4d4c28fa7..8a6d18dc2d 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -260,7 +260,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::init() { #if HAS_U8GLIB_I2C_OLED && PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) - Wire.begin(uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN)); + #ifdef TARGET_RP2040 + Wire.begin(); // RP2040 MbedI2C uses pins configured in pins_arduino.h + #else + Wire.begin(uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN)); + #endif #endif init_lcd(); diff --git a/Marlin/src/pins/mega/pins_GT2560_V3.h b/Marlin/src/pins/mega/pins_GT2560_V3.h index ae4614eedd..81774006df 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3.h @@ -162,8 +162,9 @@ #endif // -// LCD Controller +// LCD / Controller // + #define BEEPER_PIN 18 #if ENABLED(YHCB2004) diff --git a/Marlin/src/pins/mega/pins_INTAMSYS40.h b/Marlin/src/pins/mega/pins_INTAMSYS40.h index 83a77ec98c..cfb4d0186e 100644 --- a/Marlin/src/pins/mega/pins_INTAMSYS40.h +++ b/Marlin/src/pins/mega/pins_INTAMSYS40.h @@ -116,7 +116,7 @@ #endif // -// LCD Controller +// LCD / Controller // #define BEEPER_PIN 18 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index e73a00ae81..56c4b78dff 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -949,6 +949,8 @@ #elif MB(RP2040) #include "rp2040/pins_RP2040.h" // RP2040 env:RP2040 +#elif MB(RASPBERRY_PI_PICO) + #include "rp2040/pins_RASPBERRY_PI_PICO.h" // RP2040 env:RP2040 #elif MB(BTT_SKR_PICO) #include "rp2040/pins_BTT_SKR_Pico.h" // RP2040 env:SKR_Pico env:SKR_Pico_UART diff --git a/Marlin/src/pins/rp2040/pins_RASPBERRY_PI_PICO.h b/Marlin/src/pins/rp2040/pins_RASPBERRY_PI_PICO.h new file mode 100644 index 0000000000..daede9f560 --- /dev/null +++ b/Marlin/src/pins/rp2040/pins_RASPBERRY_PI_PICO.h @@ -0,0 +1,171 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2025 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 "Pi Pico" +#define DEFAULT_MACHINE_NAME "Pi Pico" + +#ifndef MARLIN_EEPROM_SIZE + #define MARLIN_EEPROM_SIZE 0x1000U // 4K + #define FLASH_EEPROM_EMULATION +#endif + +// +// Limit Switches +// +#define X_STOP_PIN 0 // GP0 +#define Y_STOP_PIN 1 // GP1 +#define Z_STOP_PIN 2 // GP2 + +// +// Steppers +// +#define X_STEP_PIN 3 // GP3 +#define X_DIR_PIN 6 // GP6 +#define X_ENABLE_PIN 7 // GP7 + +#define Y_STEP_PIN 8 // GP8 +#define Y_DIR_PIN 9 // GP9 +#define Y_ENABLE_PIN X_ENABLE_PIN + +#define Z_STEP_PIN 10 // GP10 +#define Z_DIR_PIN 11 // GP11 +#define Z_ENABLE_PIN X_ENABLE_PIN + +#define E0_STEP_PIN 12 // GP12 +#define E0_DIR_PIN 13 // GP13 +#define E0_ENABLE_PIN X_ENABLE_PIN + +// +// Heaters / Fans +// +#define HEATER_0_PIN 14 // GP14 +#define HEATER_BED_PIN 15 // GP15 +#define FAN0_PIN 28 // GP28 + +// +// Temperature Sensors +// +#define TEMP_0_PIN A0 // GP26 - Analog Input +#define TEMP_BED_PIN A1 // GP27 - Analog Input + +// +// Misc. Functions +// +#define LED_PIN 25 // GP25 + +// +// SD Card +// +#define SD_DETECT_PIN -1 // No pins left +#define SDCARD_CONNECTION ONBOARD +#define SD_SS_PIN 17 // GP17 - SPI0_CS for SD card chip select + +// +// LCD / Controller +// + +#if ENABLED(U8GLIB_SSD1306) + #if !IS_ULTIPANEL + #error "Add '#define IS_ULTIPANEL 1' to Configuration.h to enable Marlin UI menus and encoder support." + #endif + #if IS_NEWPANEL + #define BTN_EN1 20 // GP20 - Encoder A phase + #define BTN_EN2 21 // GP21 - Encoder B phase + #define BTN_ENC 22 // GP22 - Encoder push button + #endif + + #define ALTERNATIVE_LCD // Use default hardware I2C port +#endif // U8GLIB_SSD1306 + +/* +┌───────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ RASPBERRY PI PICO - PHYSICAL PIN MAPPING │ +├──────────────┬───────────┬───────────┬───────────┬───────────┬────────────────────────────────────────────┤ +│ Physical Pin │ GPIO │ ALT0 │ ALT1 │ ALT2 │ Marlin Usage │ +├──────────────┼───────────┼───────────┼───────────┼───────────┼────────────────────────────────────────────┤ +│ 1 │ GP0 │ I2C0_SDA │ SPI0_MISO │ UART0_TX │ X_STOP_PIN │ +│ 2 │ GP1 │ I2C0_SCL │ SPI0_CS │ UART0_RX │ Y_STOP_PIN │ +│ 3 │ GND │ │ │ │ │ +│ 4 │ GP2 │ I2C1_SDA │ SPI0_SCK │ │ Z_STOP_PIN │ +│ 5 │ GP3 │ I2C1_SCL │ SPI0_MOSI │ │ X_STEP_PIN │ +│ 6 │ GP4 │ I2C0_SDA │ SPI0_MISO │ UART1_TX │ SDA_PIN │ +│ 7 │ GP5 │ I2C0_SCL │ SPI0_CS │ UART1_RX │ SCL_PIN │ +│ 8 │ GND │ │ │ │ │ +│ 9 │ GP6 │ I2C1_SDA │ SPI0_SCK │ │ X_DIR_PIN │ +│ 10 │ GP7 │ I2C1_SCL │ SPI0_MOSI │ │ X_ENABLE_PIN │ +│ 11 │ GP8 │ I2C0_SDA │ SPI1_MISO │ UART1_TX │ Y_STEP_PIN │ +│ 12 │ GP9 │ I2C0_SCL │ SPI1_CS │ UART1_RX │ Y_DIR_PIN │ +│ 13 │ GND │ │ │ │ │ +│ 14 │ GP10 │ I2C1_SDA │ SPI1_SCK │ │ Z_STEP_PIN │ +│ 15 │ GP11 │ I2C1_SCL │ SPI1_MOSI │ │ Z_DIR_PIN │ +│ 16 │ GP12 │ I2C0_SDA │ SPI1_MISO │ UART0_TX │ E0_STEP_PIN │ +│ 17 │ GP13 │ I2C0_SCL │ SPI1_CS │ UART0_RX │ E0_DIR_PIN │ +│ 18 │ GND │ │ │ │ │ +│ 19 │ GP14 │ I2C1_SDA │ SPI1_SCK │ │ HEATER_0_PIN │ +│ 20 │ GP15 │ I2C1_SCL │ SPI1_MOSI │ │ HEATER_BED_PIN │ +│ 21 │ GP16 │ I2C0_SDA │ SPI0_MISO │ UART0_TX │ SD_MISO_PIN │ +│ 22 │ GP17 │ I2C0_SCL │ SPI0_CS │ UART0_RX │ SD_SS_PIN │ +│ 23 │ GND │ │ │ │ │ +│ 24 │ GP18 │ I2C1_SDA │ SPI0_SCK │ │ SD_SCK_PIN │ +│ 25 │ GP19 │ I2C1_SCL │ SPI0_MOSI │ │ SD_MOSI_PIN │ +│ 26 │ GP20 │ I2C0_SDA │ │ │ BTN_EN1 (Encoder A) │ +│ 27 │ GP21 │ I2C0_SCL │ │ │ BTN_EN2 (Encoder B) │ +│ 28 │ GND │ │ │ │ │ +│ 29 │ GP22 │ │ │ │ BTN_ENC (Encoder Button) │ +│ 30 │ RUN │ │ │ │ Reset (Active Low) │ +│ 31 │ GP26 │ ADC0 │ I2C1_SDA │ │ TEMP_0_PIN (A0) │ +│ 32 │ GP27 │ ADC1 │ I2C1_SCL │ │ TEMP_BED_PIN (A1) │ +│ 33 │ GND │ │ │ │ │ +│ 34 │ GP28 │ ADC2 │ │ │ FAN0_PIN │ +│ 35 │ ADC_VREF│ │ │ │ ADC Reference Voltage │ +│ 36 │ 3V3 │ │ │ │ 3.3V Power Output │ +│ 37 │ 3V3_EN │ │ │ │ 3.3V Enable (Active High) │ +│ 38 │ GND │ │ │ │ │ +│ 39 │ VSYS │ │ │ │ System Voltage Input (1.8-5.5V) │ +│ 40 │ VBUS │ │ │ │ USB Bus Voltage (5V when USB connected) │ +├──────────────┴───────────┴───────────┴───────────┴───────────┴────────────────────────────────────────────┤ +│ Special pin notes for Raspberry Pi Pico │ +├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│ • GP23 OP Controls the on-board SMPS Power Save pin. Should not be used for other purposes. │ +│ • GP24 IP VBUS sense - high if VBUS is present, else low. Should not be used for other purposes. │ +│ • GP25 OP Connected to user LED. Can be used with board modifications, is not broken out. │ +│ • GP29 IP Used in ADC mode (ADC3) to measure VSYS/3. Should not be used for other purposes. │ +│ • ADC4 (Internal) is connected to the chip's internal temperature sensor. │ +├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│ Marlin pin notes │ +├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│ Shared enable pins: │ +│ • GP7: X_ENABLE_PIN. All stepper drivers use a shared single enable pin X_ENABLE_PIN for pin conservation │ +│ │ +│ Hardware I2C and SPI configuration: │ +│ These are hardcoded in: │ +│ .platformio/packages/framework-arduino-mbed/variants/RASPBERRY_RASPBERRY_PI_PICO/pins_arduino.h │ +│ • GP4: SDA default: "#define PIN_WIRE_SDA (4u)" │ +│ • GP5: SCL default: "#define PIN_WIRE_SCL (5u)" │ +│ • GP16: MISO default: "#define PIN_SPI_MISO (16u)" │ +│ • GP18: SCK default: "#define PIN_SPI_SCK (18u)" │ +│ • GP19: MOSI default: "#define PIN_SPI_MOSI (19u)" │ +└───────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +*/ diff --git a/Marlin/src/pins/rp2040/pins_RP2040.h b/Marlin/src/pins/rp2040/pins_RP2040.h index 6a4e54f0bd..95de85b4bf 100644 --- a/Marlin/src/pins/rp2040/pins_RP2040.h +++ b/Marlin/src/pins/rp2040/pins_RP2040.h @@ -89,10 +89,7 @@ #define TEMP_2_PIN A2 // Analog Input #define TEMP_BED_PIN A1 // Analog Input -#define TEMP_MCU HAL_ADC_MCU_TEMP_DUMMY_PIN // this is a flag value, don´t change - #define TEMP_CHAMBER_PIN TEMP_1_PIN -#define TEMP_BOARD_PIN TEMP_MCU // SPI for MAX Thermocouple #if !HAS_MEDIA @@ -560,3 +557,28 @@ #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD + +/* +┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ +│ PIN CONFLICTS and ERRORS │ +├───────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│ │ +│ VIRTUAL PINS - NOT REAL GPIO: │ +│ • GP40+: E_MUX pins, TMC_SW pins are virtual/extended pins, not physical RP2040 GPIO │ +│ • GP64, GP66: TMC Software SPI pins - these don't exist on RP2040 hardware │ +│ │ +│ MULTIPLE ASSIGNMENTS - REVIEW NEEDED: │ +│ • GP4: Z_DIR_PIN + Z_CS_PIN + SPINDLE_LASER_ENA_PIN (conditional conflicts) │ +│ • GP5: Z_STEP_PIN + FILWIDTH_PIN + SPINDLE_DIR_PIN (conditional conflicts) │ +│ • GP6: CASE_LIGHT_PIN + SPINDLE_LASER_PWM_PIN (conditional - both PWM) │ +│ • GP21: FAN1_PIN + FIL_RUNOUT_PIN (may conflict if both features enabled) │ +│ • GP29: ALL assigned to same pin: │ +│ - X_STEP_PIN, X_DIR_PIN, X_ENABLE_PIN, X_CS_PIN (4 pins) │ +│ - Y_STEP_PIN, Y_DIR_PIN, Y_ENABLE_PIN, Y_CS_PIN (4 pins) │ +│ - E0_STEP_PIN, E0_DIR_PIN, E0_ENABLE_PIN, E0_CS_PIN (4 pins) │ +│ - LCD_PINS_EN (CR10_STOCKDISPLAY), LCD_PINS_D7, DOGLCD_CS (ELB_FULL_GRAPHIC_CONTROLLER) │ +│ → 12+ critical functions sharing ONE GPIO - PRINTER CANNOT FUNCTION! │ +└───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ +*/ + +#error "Pin assignments for this board are not for practical use. See comments in pins_RP2040.h" diff --git a/Marlin/src/sd/SdBaseFile.h b/Marlin/src/sd/SdBaseFile.h index dc31e8492d..e2dbf489f1 100644 --- a/Marlin/src/sd/SdBaseFile.h +++ b/Marlin/src/sd/SdBaseFile.h @@ -46,6 +46,19 @@ struct filepos_t { filepos_t() : position(0), cluster(0) {} }; +// Avoid conflict with RP2040 / newlib fcntl.h +#ifdef __PLAT_RP2040__ + #undef O_RDONLY + #undef O_WRONLY + #undef O_RDWR + #undef O_ACCMODE + #undef O_APPEND + #undef O_SYNC + #undef O_TRUNC + #undef O_CREAT + #undef O_EXCL +#endif + // use the gnu style oflag in open() uint8_t const O_READ = 0x01, // open() oflag for reading O_RDONLY = O_READ, // open() oflag - same as O_IN diff --git a/Marlin/src/sd/SdFatStructs.h b/Marlin/src/sd/SdFatStructs.h index b3f94b57a0..bacff4e1c0 100644 --- a/Marlin/src/sd/SdFatStructs.h +++ b/Marlin/src/sd/SdFatStructs.h @@ -32,7 +32,9 @@ #include -#define PACKED __attribute__((__packed__)) +#ifndef PACKED + #define PACKED __attribute__((__packed__)) +#endif /** * mostly from Microsoft document fatgen103.doc diff --git a/ini/raspberrypi.ini b/ini/raspberrypi.ini index 059f4d1821..2ee74631f9 100644 --- a/ini/raspberrypi.ini +++ b/ini/raspberrypi.ini @@ -16,12 +16,13 @@ build_src_filter = ${common.default_src_filter} + lib_deps = ${common.lib_deps} arduino-libraries/Servo https://github.com/pkElectronics/SoftwareSerialM#master + #adafruit/Adafruit TinyUSB Library #lvgl/lvgl@^8.1.0 lib_ignore = WiFi -build_flags = ${common.build_flags} -D__PLAT_RP2040__ -DPLATFORM_M997_SUPPORT -Wno-expansion-to-defined -Wno-vla -Wno-ignored-qualifiers +build_flags = ${common.build_flags} -D__PLAT_RP2040__ -DPLATFORM_M997_SUPPORT -DNO_SD_HOST_DRIVE -Wno-expansion-to-defined -Wno-vla -Wno-ignored-qualifiers #debug_tool = jlink #upload_protocol = jlink -custom_marlin.HAS_SD_HOST_DRIVE = tinyusb +#custom_marlin.HAS_SD_HOST_DRIVE = tinyusb [env:RP2040-alt] extends = env:RP2040 From ac0fc603aed0fcd3d77a15d8d4cc8e6e3037ce56 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Fri, 28 Nov 2025 00:53:52 +0000 Subject: [PATCH 23/39] [cron] Bump distribution date (2025-11-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 1cf1b23558..d9a83e4abe 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 "2025-11-27" +//#define STRING_DISTRIBUTION_DATE "2025-11-28" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index e768d28ce1..a0b4e56863 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 "2025-11-27" + #define STRING_DISTRIBUTION_DATE "2025-11-28" #endif /** From 12ac09499258c299feb14d986e9c728569b69140 Mon Sep 17 00:00:00 2001 From: Vovodroid Date: Fri, 28 Nov 2025 03:27:48 +0200 Subject: [PATCH 24/39] =?UTF-8?q?=E2=9C=A8=20PLR=5FHEAT=5FBED=5FON=5FREBOO?= =?UTF-8?q?T=20(#26691)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 ++ Marlin/src/feature/powerloss.cpp | 15 +++++++++++++++ Marlin/src/feature/powerloss.h | 5 ++++- Marlin/src/gcode/feature/powerloss/M1000.cpp | 3 +++ buildroot/tests/rambo | 2 ++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c5ed503b4c..57c8305e04 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1795,6 +1795,8 @@ //#define POWER_LOSS_RECOVERY #if ENABLED(POWER_LOSS_RECOVERY) #define PLR_ENABLED_DEFAULT false // Power-Loss Recovery enabled by default. (Set with 'M413 Sn' & M500) + //#define PLR_HEAT_BED_ON_REBOOT // Heat up bed immediately on reboot to mitigate object detaching/warping. + //#define PLR_HEAT_BED_EXTRA 0 // (°C) Relative increase of bed temperature for better adhesion (limited by max temp). //#define PLR_BED_THRESHOLD BED_MAXTEMP // (°C) Skip user confirmation at or above this bed temperature (0 to disable) //#define POWER_LOSS_PIN 44 // Pin to detect power-loss. Set to -1 to disable default pin on boards without module, or comment to use board default. diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index bb4ca0dbde..6925ed7a34 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -141,6 +141,14 @@ bool PrintJobRecovery::check() { return success; } +/** + * Cancel recovery + */ +void PrintJobRecovery::cancel() { + TERN_(PLR_HEAT_BED_ON_REBOOT, set_bed_temp(false)); + purge(); +} + /** * Delete the recovery file and clear the recovery data */ @@ -366,6 +374,13 @@ void PrintJobRecovery::write() { if (!file.close()) DEBUG_ECHOLNPGM("Power-loss file close failed."); } +#if ENABLED(PLR_HEAT_BED_ON_REBOOT) + // Set bed temperature and wait. Called from M1000 to resume bed heating. + void PrintJobRecovery::set_bed_temp(const bool on) { + PROCESS_SUBCOMMANDS_NOW(TS(F("M190S"), on ? info.target_temperature_bed + PLR_HEAT_BED_EXTRA : 0)); + } +#endif + /** * Resume the saved print job */ diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index eceb862779..0fcd167d78 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -201,10 +201,13 @@ class PrintJobRecovery { static void close() { file.close(); } static bool check(); + #if ENABLED(PLR_HEAT_BED_ON_REBOOT) + static void set_bed_temp(const bool turn_on); + #endif static void resume(); static void purge(); - static void cancel() { purge(); } + static void cancel(); static void load(); static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false); diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index c70bf7667f..c85817cd3e 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -72,6 +72,9 @@ void GcodeSuite::M1000() { const bool force_resume = TERN0(HAS_PLR_BED_THRESHOLD, recovery.bed_temp_threshold && (thermalManager.degBed() >= recovery.bed_temp_threshold)); if (!force_resume && parser.seen_test('S')) { + + TERN_(PLR_HEAT_BED_ON_REBOOT, recovery.set_bed_temp(true)); + #if HAS_MARLINUI_MENU ui.goto_screen(menu_job_recovery); #elif ENABLED(EXTENSIBLE_UI) diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index 06037a838f..6ebb26a177 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -14,6 +14,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ EXTRUDERS 2 TEMP_SENSOR_0 -2 TEMP_SENSOR_1 1 TEMP_SENSOR_BED 2 \ TEMP_SENSOR_PROBE 1 TEMP_PROBE_PIN 12 \ TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 3 HEATER_CHAMBER_PIN 45 \ + PLR_HEAT_BED_EXTRA 5 PLR_BED_THRESHOLD 60 \ GRID_MAX_POINTS_X 16 BACKLASH_MEASUREMENT_FEEDRATE 600 \ AUTO_POWER_E_TEMP 80 FANMUX0_PIN 53 FIL_MOTION1_PIN 45 opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN USE_WATCHDOG @@ -34,6 +35,7 @@ opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TE FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ PSU_CONTROL LED_POWEROFF_TIMEOUT PS_OFF_CONFIRM PS_OFF_SOUND POWER_OFF_WAIT_FOR_COOLDOWN \ POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \ + PLR_HEAT_BED_ON_REBOOT \ SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE ADVANCE_K_EXTRA \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT HOST_STATUS_NOTIFICATIONS PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL opt_add DEBUG_POWER_LOSS_RECOVERY From d061e6dbd65e6f601b5c90b5c4a3e432604bcb71 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 28 Nov 2025 13:27:33 -0600 Subject: [PATCH 25/39] =?UTF-8?q?=F0=9F=93=9D=20Motion=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit w/r/t https://github.com/MarlinFirmware/Marlin/issues/27918#issuecomment-3145339116 --- Marlin/src/module/planner.cpp | 2 ++ Marlin/src/module/planner.h | 6 ++++-- Marlin/src/module/stepper.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 7bb078be16..acd576c9b3 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2542,6 +2542,8 @@ bool Planner::_populate_block( xyze_float_t junction_unit_vec = unit_vec - prev_unit_vec; normalize_junction_vector(junction_unit_vec); + // TODO: Don't limit acceleration on axes with very small distance relative to others + // See https://github.com/MarlinFirmware/Marlin/issues/27918#issuecomment-3145339116 const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec); if (TERN0(HINTS_CURVE_RADIUS, hints.curve_radius)) { diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index d8d0e053e7..891357dbe3 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -1157,12 +1157,14 @@ class Planner { vector *= RSQRT(magnitude_sq); } + // max_value is block->acceleration FORCE_INLINE static float limit_value_by_axis_maximum(const float max_value, xyze_float_t &unit_vec) { float limit_value = max_value; LOOP_LOGICAL_AXES(idx) { if (unit_vec[idx]) { - if (limit_value * ABS(unit_vec[idx]) > settings.max_acceleration_mm_per_s2[idx]) - limit_value = ABS(settings.max_acceleration_mm_per_s2[idx] / unit_vec[idx]); + const uint32_t abs_vec = ABS(unit_vec[idx]); + if (limit_value * abs_vec > settings.max_acceleration_mm_per_s2[idx]) + limit_value = settings.max_acceleration_mm_per_s2[idx] / abs_vec; } } return limit_value; diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index ca6f027ade..8b3a60e048 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -253,7 +253,7 @@ uint32_t Stepper::advance_divisor = 0, #endif /** - * Standard Motion Non-linear Exttrusion state + * Standard Motion Non-linear Extrusion state */ #if ENABLED(NONLINEAR_EXTRUSION) nonlinear_t Stepper::ne; // Initialized by settings.load From 578ee04243631e4978400648aa66a392c8c2b525 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sat, 29 Nov 2025 00:31:12 +0000 Subject: [PATCH 26/39] [cron] Bump distribution date (2025-11-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 d9a83e4abe..b42ab23151 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 "2025-11-28" +//#define STRING_DISTRIBUTION_DATE "2025-11-29" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index a0b4e56863..9e1a60feeb 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 "2025-11-28" + #define STRING_DISTRIBUTION_DATE "2025-11-29" #endif /** From 58bce3781eb7d9884550a6b595d203adb0b783ef Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 28 Nov 2025 18:53:07 -0600 Subject: [PATCH 27/39] =?UTF-8?q?=F0=9F=93=9D=20Usage=20for=20run=5Ftests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/bin/run_tests | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/buildroot/bin/run_tests b/buildroot/bin/run_tests index 9a03be3cc7..206325417c 100755 --- a/buildroot/bin/run_tests +++ b/buildroot/bin/run_tests @@ -1,6 +1,13 @@ #!/usr/bin/env bash # -# run_tests +# buildroot/bin/run_tests +# Used by Makefile tests-single-local, tests-single-ci, tests-all-local +# +# Usage: +# run_tests path target "[only this title]" +# +# With make: +# make tests-single-local TEST_TARGET=mega2560 ONLY_TEST=2 # HERE="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" TESTS="$HERE/../tests" From 7b70e39ff6ea753190def28b3986268878de11e0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 28 Nov 2025 19:57:52 -0600 Subject: [PATCH 28/39] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Clari?= =?UTF-8?q?fy=20PID=20tuning=20macros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/planner.cpp | 14 +---- Marlin/src/module/temperature.cpp | 101 +++++++++++++----------------- 2 files changed, 47 insertions(+), 68 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index acd576c9b3..59c7c3638b 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2519,18 +2519,8 @@ bool Planner::_populate_block( if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) { // Compute cosine of angle between previous and current path. (prev_unit_vec is negative) // NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity. - float junction_cos_theta = LOGICAL_AXIS_GANG( - + (-prev_unit_vec.e * unit_vec.e), - + (-prev_unit_vec.x * unit_vec.x), - + (-prev_unit_vec.y * unit_vec.y), - + (-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.u * unit_vec.u), - + (-prev_unit_vec.v * unit_vec.v), - + (-prev_unit_vec.w * unit_vec.w) - ); + #define _UNIT_VEC(A) + (-prev_unit_vec.A * unit_vec.A) + float junction_cos_theta = LOGICAL_AXIS_MAP(_UNIT_VEC); // NOTE: Computed without any expensive trig, sin() or acos(), by trig half angle identity of cos(theta). if (junction_cos_theta > 0.999999f) { diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 96ea110963..964e473361 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -824,41 +824,34 @@ void Temperature::factory_reset() { raw_pid_t tune_pid = { 0, 0, 0 }; celsius_float_t maxT = 0, minT = 10000; - const bool isbed = (heater_id == H_BED), - ischamber = (heater_id == H_CHAMBER); + const bool isbed = TERN0(PIDTEMPBED, heater_id == H_BED), + ischamber = TERN0(PIDTEMPCHAMBER, heater_id == H_CHAMBER); - #if ENABLED(PIDTEMPCHAMBER) - #define C_TERN(T,A,B) ((T) ? (A) : (B)) - #else - #define C_TERN(T,A,B) (B) - #endif - #if ENABLED(PIDTEMPBED) - #define B_TERN(T,A,B) ((T) ? (A) : (B)) - #else - #define B_TERN(T,A,B) (B) - #endif - #define GHV(C,B,H) C_TERN(ischamber, C, B_TERN(isbed, B, H)) - #define SHV(V) C_TERN(ischamber, temp_chamber.soft_pwm_amount = V, B_TERN(isbed, temp_bed.soft_pwm_amount = V, temp_hotend[heater_id].soft_pwm_amount = V)) - #define ONHEATINGSTART() C_TERN(ischamber, printerEventLEDs.onChamberHeatingStart(), B_TERN(isbed, printerEventLEDs.onBedHeatingStart(), printerEventLEDs.onHotendHeatingStart())) - #define ONHEATING(S,C,T) C_TERN(ischamber, printerEventLEDs.onChamberHeating(S,C,T), B_TERN(isbed, printerEventLEDs.onBedHeating(S,C,T), printerEventLEDs.onHotendHeating(S,C,T))) + // BED TEST ; BED VALUE ; HOTEND VALUE + #define T_BH(T,B,H) TERN(PIDTEMPBED, ((T) ? (B) : (H)), (H)) + // CHAMBER TEST ; CHAMBER VALUE ; T_BH(...) + #define T_CBH(T,C,BH) TERN(PIDTEMPCHAMBER, ((T) ? (C) : (BH)), (BH)) + // CHAMBER VALUE ; BED VALUE ; HOTEND VALUE + #define PER_CBH(C,B,H) T_CBH(ischamber, C, T_BH(isbed, B, H)) + + // Set a field value in the pertinent Temp Monitor + #define SET_CBH(F,V) PER_CBH(temp_chamber.F = V, temp_bed.F = V, temp_hotend[heater_id].F = V) + #define ONHEATINGSTART() PER_CBH(printerEventLEDs.onChamberHeatingStart(), printerEventLEDs.onBedHeatingStart(), printerEventLEDs.onHotendHeatingStart()) + #define ONHEATING(S,C,T) PER_CBH(printerEventLEDs.onChamberHeating(S,C,T), printerEventLEDs.onBedHeating(S,C,T), printerEventLEDs.onHotendHeating(S,C,T)) #define WATCH_PID DISABLED(NO_WATCH_PID_TUNING) && (ALL(WATCH_CHAMBER, PIDTEMPCHAMBER) || ALL(WATCH_BED, PIDTEMPBED) || ALL(WATCH_HOTENDS, PIDTEMP)) - #if WATCH_PID - #if ALL(THERMAL_PROTECTION_CHAMBER, PIDTEMPCHAMBER) - #define C_GTV(T,A,B) ((T) ? (A) : (B)) - #else - #define C_GTV(T,A,B) (B) - #endif - #if ALL(THERMAL_PROTECTION_BED, PIDTEMPBED) - #define B_GTV(T,A,B) ((T) ? (A) : (B)) - #else - #define B_GTV(T,A,B) (B) - #endif - #define GTV(C,B,H) C_GTV(ischamber, C, B_GTV(isbed, B, H)) - const uint16_t watch_temp_period = GTV(WATCH_CHAMBER_TEMP_PERIOD, WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD); - const uint8_t watch_temp_increase = GTV(WATCH_CHAMBER_TEMP_INCREASE, WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE); - const celsius_float_t watch_temp_target = celsius_float_t(target - (watch_temp_increase + GTV(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS) + 1)); + // BED TEST ; BED VALUE ; HOTEND VALUE + #define W_BH(T,B,H) TERN(THERMAL_PROTECTION_BED, T_BH(T,B,H), (H)) + // CHAMBER TEST ; CHAMBER VALUE ; W_BH(...) + #define W_CBH(T,C,BH) TERN(THERMAL_PROTECTION_CHAMBER, T_CBH(T,C,BH), (BH)) + // CHAMBER VALUE ; BED VALUE ; HOTEND VALUE + #define PER_WATCH_CBH(C,B,H) W_CBH(ischamber, C, W_BH(isbed, B, H)) + + const uint16_t watch_temp_period = PER_WATCH_CBH(WATCH_CHAMBER_TEMP_PERIOD, WATCH_BED_TEMP_PERIOD, WATCH_TEMP_PERIOD); + const uint8_t watch_temp_increase = PER_WATCH_CBH(WATCH_CHAMBER_TEMP_INCREASE, WATCH_BED_TEMP_INCREASE, WATCH_TEMP_INCREASE); + const celsius_float_t watch_hysteresis = PER_WATCH_CBH(TEMP_CHAMBER_HYSTERESIS, TEMP_BED_HYSTERESIS, TEMP_HYSTERESIS), + watch_temp_target = celsius_float_t(target - (watch_temp_increase + watch_hysteresis + 1)); millis_t temp_change_ms = next_temp_ms + SEC_TO_MS(watch_temp_period); celsius_float_t next_watch_temp = 0.0; bool heated = false; @@ -866,9 +859,9 @@ void Temperature::factory_reset() { TERN_(HAS_FAN_LOGIC, fan_update_ms = next_temp_ms + fan_update_interval_ms); - TERN_(EXTENSIBLE_UI, ExtUI::onPIDTuning(ischamber ? ExtUI::pidresult_t::PID_CHAMBER_STARTED : isbed ? ExtUI::pidresult_t::PID_BED_STARTED : ExtUI::pidresult_t::PID_STARTED)); + TERN_(EXTENSIBLE_UI, ExtUI::onPIDTuning(PER_CBH(ExtUI::pidresult_t::PID_CHAMBER_STARTED, ExtUI::pidresult_t::PID_BED_STARTED, ExtUI::pidresult_t::PID_STARTED))); - if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, hotend_max_target(heater_id))) { + if (target > PER_CBH(CHAMBER_MAX_TARGET, BED_MAX_TARGET, hotend_max_target(heater_id))) { SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPIDTuning(ExtUI::pidresult_t::PID_TEMP_TOO_HIGH)); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); @@ -880,11 +873,11 @@ void Temperature::factory_reset() { disable_all_heaters(); TERN_(AUTO_POWER_CONTROL, powerManager.power_on()); - long bias = GHV(MAX_CHAMBER_POWER, MAX_BED_POWER, PID_MAX) >> 1, d = bias; - SHV(bias); + long bias = PER_CBH(MAX_CHAMBER_POWER, MAX_BED_POWER, PID_MAX) >> 1, d = bias; + SET_CBH(soft_pwm_amount, bias); #if ENABLED(PRINTER_EVENT_LEDS) - const celsius_float_t start_temp = GHV(degChamber(), degBed(), degHotend(heater_id)); + const celsius_float_t start_temp = PER_CBH(degChamber(), degBed(), degHotend(heater_id)); const LED1Color_t oldcolor = ONHEATINGSTART(); #endif @@ -905,7 +898,7 @@ void Temperature::factory_reset() { if (temp_ready) { // Get the current temperature and constrain it - current_temp = GHV(degChamber(), degBed(), degHotend(heater_id)); + current_temp = PER_CBH(degChamber(), degBed(), degHotend(heater_id)); NOLESS(maxT, current_temp); NOMORE(minT, current_temp); @@ -915,7 +908,7 @@ void Temperature::factory_reset() { if (heating && current_temp > target && ELAPSED(ms, t2, 5000UL)) { heating = false; - SHV((bias - d) >> 1); + SET_CBH(soft_pwm_amount, (bias - d) >> 1); t1 = ms; t_high = t1 - t2; maxT = target; @@ -926,7 +919,7 @@ void Temperature::factory_reset() { t2 = ms; t_low = t2 - t1; if (cycles > 0) { - const long max_pow = GHV(MAX_CHAMBER_POWER, MAX_BED_POWER, PID_MAX); + const long max_pow = PER_CBH(MAX_CHAMBER_POWER, MAX_BED_POWER, PID_MAX); bias += (d * (t_high - t_low)) / (t_low + t_high); LIMIT(bias, 20, max_pow - 20); d = (bias > max_pow >> 1) ? max_pow - 1 - bias : bias; @@ -950,7 +943,7 @@ void Temperature::factory_reset() { SERIAL_ECHOLNPGM(STR_KP, tune_pid.p, STR_KI, tune_pid.i, STR_KD, tune_pid.d); } } - SHV((bias + d) >> 1); + SET_CBH(soft_pwm_amount, (bias + d) >> 1); TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PID_CYCLE), cycles, ncycles)); cycles++; minT = target; @@ -1016,7 +1009,7 @@ void Temperature::factory_reset() { TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE))); #if ANY(PIDTEMPBED, PIDTEMPCHAMBER) - FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR)); + FSTR_P const estring = PER_CBH(F("chamber"), F("bed"), FPSTR(NUL_STR)); say_default_(); SERIAL_ECHOLN(estring, F("Kp "), tune_pid.p); say_default_(); SERIAL_ECHOLN(estring, F("Ki "), tune_pid.i); say_default_(); SERIAL_ECHOLN(estring, F("Kd "), tune_pid.d); @@ -1052,7 +1045,7 @@ void Temperature::factory_reset() { // Use the result? (As with "M303 U1") if (set_result) - GHV(_set_chamber_pid(tune_pid), _set_bed_pid(tune_pid), _set_hotend_pid(heater_id, tune_pid)); + PER_CBH(_set_chamber_pid(tune_pid), _set_bed_pid(tune_pid), _set_hotend_pid(heater_id, tune_pid)); goto EXIT_M303; } @@ -1136,9 +1129,8 @@ void Temperature::factory_reset() { wait_for_heatup = false; #if ENABLED(MPC_AUTOTUNE_DEBUG) - SERIAL_ECHOLNPGM("MPC_autotuner::measure_ambient_temp() Completed"); - SERIAL_ECHOLNPGM("====="); - SERIAL_ECHOLNPGM("ambient_temp ", get_ambient_temp()); + SERIAL_ECHOLNPGM("MPC_autotuner::measure_ambient_temp() Completed\n=====\n" + "ambient_temp ", get_ambient_temp()); #endif return SUCCESS; @@ -1223,11 +1215,8 @@ void Temperature::factory_reset() { #if ENABLED(MPC_AUTOTUNE_DEBUG) SERIAL_ECHOLNPGM("MPC_autotuner::measure_heatup() Completed"); SERIAL_ECHOLNPGM("====="); - 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_time ", t1_time, " sample_count ", sample_count, " sample_distance ", sample_distance); + for (uint8_t i = 0; i < sample_count; i++) SERIAL_ECHOLNPGM("sample ", i, " : ", temp_samples[i]); SERIAL_ECHOLNPGM("t1 ", get_sample_1_temp(), " t2 ", get_sample_2_temp(), " t3 ", get_sample_3_temp()); #endif @@ -1390,9 +1379,9 @@ void Temperature::factory_reset() { if (tuning_type == FORCE_DIFFERENTIAL) { #if ENABLED(MPC_AUTOTUNE_DEBUG) - SERIAL_ECHOLNPGM("rate_fastest ", tuner.get_rate_fastest()); - SERIAL_ECHOLNPGM("time_fastest ", tuner.get_time_fastest()); - SERIAL_ECHOLNPGM("temp_fastest ", tuner.get_temp_fastest()); + SERIAL_ECHOLNPGM("Fastest rate=", tuner.get_rate_fastest(), + " time=", tuner.get_time_fastest(), + "temp=", tuner.get_temp_fastest()); #endif // Differential tuning mpc.block_heat_capacity = mpc.heater_power / tuner.get_rate_fastest(); @@ -1435,9 +1424,9 @@ void Temperature::factory_reset() { // Check again: If analytic tuning fails, fall back to differential tuning if (tuning_type == AUTO && (mpc.sensor_responsiveness <= 0 || mpc.block_heat_capacity <= 0)) { #if ENABLED(MPC_AUTOTUNE_DEBUG) - SERIAL_ECHOLNPGM("rate_fastest ", tuner.get_rate_fastest()); - SERIAL_ECHOLNPGM("time_fastest ", tuner.get_time_fastest()); - SERIAL_ECHOLNPGM("temp_fastest ", tuner.get_temp_fastest()); + SERIAL_ECHOLNPGM("Fastest rate=", tuner.get_rate_fastest(), + " time=", tuner.get_time_fastest(), + "temp=", tuner.get_temp_fastest()); #endif tuning_type = FORCE_DIFFERENTIAL; mpc.block_heat_capacity = mpc.heater_power / tuner.get_rate_fastest(); From 3d7f84dbb618314defa615f668c5cd605ad43f9a Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Sun, 30 Nov 2025 00:38:07 +0000 Subject: [PATCH 29/39] [cron] Bump distribution date (2025-11-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 b42ab23151..e04bcf0334 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 "2025-11-29" +//#define STRING_DISTRIBUTION_DATE "2025-11-30" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 9e1a60feeb..d97a80ad36 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 "2025-11-29" + #define STRING_DISTRIBUTION_DATE "2025-11-30" #endif /** From ec8a6fc7e2ea02a330953198dc7a639c0430d115 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Nov 2025 08:43:23 -0600 Subject: [PATCH 30/39] =?UTF-8?q?=F0=9F=94=A7=20Uppercase=20PID=20options?= =?UTF-8?q?=20(#27891)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 24 +++++----- Marlin/Configuration_adv.h | 36 +++++++++------ Marlin/src/inc/Changes.h | 12 +++++ Marlin/src/module/stepper.cpp | 4 +- Marlin/src/module/temperature.cpp | 74 +++++++++---------------------- buildroot/tests/BTT_GTR_V1_0 | 2 +- 6 files changed, 72 insertions(+), 80 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2d816d9e46..ea307f126d 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -718,13 +718,13 @@ #if ENABLED(PID_PARAMS_PER_HOTEND) // Specify up to one value per hotend here, according to your setup. // If there are fewer values, the last one applies to the remaining hotends. - #define DEFAULT_Kp_LIST { 22.20, 22.20 } - #define DEFAULT_Ki_LIST { 1.08, 1.08 } - #define DEFAULT_Kd_LIST { 114.00, 114.00 } + #define DEFAULT_KP_LIST { 22.20, 22.20 } + #define DEFAULT_KI_LIST { 1.08, 1.08 } + #define DEFAULT_KD_LIST { 114.00, 114.00 } #else - #define DEFAULT_Kp 22.20 - #define DEFAULT_Ki 1.08 - #define DEFAULT_Kd 114.00 + #define DEFAULT_KP 22.20 + #define DEFAULT_KI 1.08 + #define DEFAULT_KD 114.00 #endif #else #define BANG_MAX 255 // Limit hotend current while in bang-bang mode; 255=full current @@ -822,9 +822,9 @@ // 120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) // from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) - #define DEFAULT_bedKp 10.00 - #define DEFAULT_bedKi 0.023 - #define DEFAULT_bedKd 305.4 + #define DEFAULT_BED_KP 10.00 + #define DEFAULT_BED_KI 0.023 + #define DEFAULT_BED_KD 305.4 // FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. #else @@ -905,9 +905,9 @@ // Lasko "MyHeat Personal Heater" (200w) modified with a Fotek SSR-10DA to control only the heating element // and placed inside the small Creality printer enclosure tent. - #define DEFAULT_chamberKp 37.04 - #define DEFAULT_chamberKi 1.40 - #define DEFAULT_chamberKd 655.17 + #define DEFAULT_CHAMBER_KP 37.04 + #define DEFAULT_CHAMBER_KI 1.40 + #define DEFAULT_CHAMBER_KD 655.17 // M309 P37.04 I1.04 D655.17 // FIND YOUR OWN: "M303 E-2 C8 S50" to run autotune on the chamber at 50 degreesC for 8 cycles. diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 57c8305e04..f0b685ba19 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -415,14 +415,19 @@ // A well-chosen Kc value should add just enough power to melt the increased material volume. //#define PID_EXTRUSION_SCALING #if ENABLED(PID_EXTRUSION_SCALING) - #define DEFAULT_Kc (100) // heating power = Kc * e_speed #define LPQ_MAX_LEN 50 + #define DEFAULT_KC 100 // heating power = Kc * e_speed + #if ENABLED(PID_PARAMS_PER_HOTEND) + // Specify up to one value per hotend here, according to your setup. + // If there are fewer values, the last one applies to the remaining hotends. + #define DEFAULT_KC_LIST { DEFAULT_KC, DEFAULT_KC } // heating power = Kc * e_speed + #endif #endif /** * Add an additional term to the heater power, proportional to the fan speed. * A well-chosen Kf value should add just enough power to compensate for power-loss from the cooling fan. - * You can either just add a constant compensation with the DEFAULT_Kf value + * You can either just add a constant compensation with the DEFAULT_KF value * or follow the instruction below to get speed-dependent compensation. * * Constant compensation (use only with fan speeds of 0% and 100%) @@ -453,21 +458,26 @@ #if ENABLED(PID_FAN_SCALING_ALTERNATIVE_DEFINITION) // The alternative definition is used for an easier configuration. // Just figure out Kf at full speed (255) and PID_FAN_SCALING_MIN_SPEED. - // DEFAULT_Kf and PID_FAN_SCALING_LIN_FACTOR are calculated accordingly. + // DEFAULT_KF and PID_FAN_SCALING_LIN_FACTOR are calculated accordingly. - #define PID_FAN_SCALING_AT_FULL_SPEED 13.0 //=PID_FAN_SCALING_LIN_FACTOR*255+DEFAULT_Kf - #define PID_FAN_SCALING_AT_MIN_SPEED 6.0 //=PID_FAN_SCALING_LIN_FACTOR*PID_FAN_SCALING_MIN_SPEED+DEFAULT_Kf + #define PID_FAN_SCALING_AT_FULL_SPEED 13.0 //=PID_FAN_SCALING_LIN_FACTOR*255+DEFAULT_KF + #define PID_FAN_SCALING_AT_MIN_SPEED 6.0 //=PID_FAN_SCALING_LIN_FACTOR*PID_FAN_SCALING_MIN_SPEED+DEFAULT_KF #define PID_FAN_SCALING_MIN_SPEED 10.0 // Minimum fan speed at which to enable PID_FAN_SCALING - #define DEFAULT_Kf (255.0*PID_FAN_SCALING_AT_MIN_SPEED-PID_FAN_SCALING_AT_FULL_SPEED*PID_FAN_SCALING_MIN_SPEED)/(255.0-PID_FAN_SCALING_MIN_SPEED) - #define PID_FAN_SCALING_LIN_FACTOR (PID_FAN_SCALING_AT_FULL_SPEED-DEFAULT_Kf)/255.0 + #define DEFAULT_KF (255.0*PID_FAN_SCALING_AT_MIN_SPEED-PID_FAN_SCALING_AT_FULL_SPEED*PID_FAN_SCALING_MIN_SPEED)/(255.0-PID_FAN_SCALING_MIN_SPEED) + #define PID_FAN_SCALING_LIN_FACTOR (PID_FAN_SCALING_AT_FULL_SPEED-DEFAULT_KF)/255.0 #else #define PID_FAN_SCALING_LIN_FACTOR (0) // Power-loss due to cooling = Kf * (fan_speed) - #define DEFAULT_Kf 10 // A constant value added to the PID-tuner + #define DEFAULT_KF 10 // A constant value added to the PID-tuner #define PID_FAN_SCALING_MIN_SPEED 10 // Minimum fan speed at which to enable PID_FAN_SCALING #endif #endif + #if ENABLED(PID_PARAMS_PER_HOTEND) + // Specify up to one value per hotend here, according to your setup. + // If there are fewer values, the last one applies to the remaining hotends. + #define DEFAULT_KF_LIST { DEFAULT_KF, DEFAULT_KF } + #endif #endif /** @@ -486,15 +496,15 @@ #define AUTOTEMP #if ENABLED(AUTOTEMP) #define AUTOTEMP_OLDWEIGHT 0.98 // Factor used to weight previous readings (0.0 < value < 1.0) - #define AUTOTEMP_MIN 210 - #define AUTOTEMP_MAX 250 + #define AUTOTEMP_MIN 210 + #define AUTOTEMP_MAX 250 #define AUTOTEMP_FACTOR 0.1f // Turn on AUTOTEMP on M104/M109 by default using proportions set here //#define AUTOTEMP_PROPORTIONAL #if ENABLED(AUTOTEMP_PROPORTIONAL) - #define AUTOTEMP_MIN_P 0 // (°C) Added to the target temperature - #define AUTOTEMP_MAX_P 5 // (°C) Added to the target temperature - #define AUTOTEMP_FACTOR_P 1 // Apply this F parameter by default (overridden by M104/M109 F) + #define AUTOTEMP_MIN_P 0 // (°C) Added to the target temperature + #define AUTOTEMP_MAX_P 5 // (°C) Added to the target temperature + #define AUTOTEMP_FACTOR_P 1 // Apply this F parameter by default (overridden by M104/M109 F) #endif #endif diff --git a/Marlin/src/inc/Changes.h b/Marlin/src/inc/Changes.h index 2d8fe87863..7b904218bf 100644 --- a/Marlin/src/inc/Changes.h +++ b/Marlin/src/inc/Changes.h @@ -749,6 +749,18 @@ #error "FTM_LINEAR_ADV_DEFAULT_ENA is obsolete and should be removed." #elif defined(FTM_LINEAR_ADV_DEFAULT_K) #error "FTM_LINEAR_ADV_DEFAULT_K is now set with ADVANCE_K and should be removed." +#elif defined(DEFAULT_Kp_LIST) || defined(DEFAULT_Ki_LIST) || defined(DEFAULT_Kd_LIST) + #error "DEFAULT_Kp_LIST, DEFAULT_Ki_LIST, DEFAULT_Kd_LIST are now (uppercase) DEFAULT_KP_LIST, DEFAULT_KI_LIST, DEFAULT_KD_LIST." +#elif defined(DEFAULT_Kp) || defined(DEFAULT_Ki) || defined(DEFAULT_Kd) + #error "DEFAULT_Kp, DEFAULT_Ki, DEFAULT_Kd are now (uppercase) DEFAULT_KP, DEFAULT_KI, DEFAULT_KD." +#elif defined(DEFAULT_bedKp) || defined(DEFAULT_bedKi) || defined(DEFAULT_bedKd) + #error "DEFAULT_bedKp, DEFAULT_bedKi, DEFAULT_bedKd are now DEFAULT_BED_KP, DEFAULT_BED_KI, DEFAULT_BED_KD." +#elif defined(DEFAULT_chamberKp) || defined(DEFAULT_chamberKi) || defined(DEFAULT_chamberKd) + #error "DEFAULT_chamberKp, DEFAULT_chamberKi, DEFAULT_chamberKd are now DEFAULT_CHAMBER_KP, DEFAULT_CHAMBER_KI, DEFAULT_CHAMBER_KD." +#elif defined(DEFAULT_Kc) + #error "DEFAULT_Kc is now (uppercase) DEFAULT_KC." +#elif defined(DEFAULT_Kf) + #error "DEFAULT_Kf is now (uppercase) DEFAULT_KF." #endif // SDSS renamed to SD_SS_PIN diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 8b3a60e048..00ba63c966 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2873,10 +2873,10 @@ hal_timer_t Stepper::block_phase_isr() { planner.laser_inline.status.isSyncPower = false; // Clear the flag to process subsequent trap calc's. else if (current_block->laser.status.isEnabled) { #if ENABLED(LASER_POWER_TRAP) - TERN_(DEBUG_LASER_TRAP, SERIAL_ECHO_MSG("InitTrapPwr:",current_block->laser.trap_ramp_active_pwr)); + TERN_(DEBUG_LASER_TRAP, SERIAL_ECHO_MSG("InitTrapPwr:", current_block->laser.trap_ramp_active_pwr)); cutter.apply_power(current_block->laser.status.isPowered ? current_block->laser.trap_ramp_active_pwr : 0); #else - TERN_(DEBUG_CUTTER_POWER, SERIAL_ECHO_MSG("InlinePwr:",current_block->laser.power)); + TERN_(DEBUG_CUTTER_POWER, SERIAL_ECHO_MSG("InlinePwr:", current_block->laser.power)); cutter.apply_power(current_block->laser.status.isPowered ? current_block->laser.power : 0); #endif } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 964e473361..8d63e226b9 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -720,47 +720,17 @@ void Temperature::factory_reset() { // #if ENABLED(PIDTEMP) #if ENABLED(PID_PARAMS_PER_HOTEND) - constexpr float defKp[] = - #ifdef DEFAULT_Kp_LIST - DEFAULT_Kp_LIST - #else - ARRAY_BY_HOTENDS1(DEFAULT_Kp) - #endif - , defKi[] = - #ifdef DEFAULT_Ki_LIST - DEFAULT_Ki_LIST - #else - ARRAY_BY_HOTENDS1(DEFAULT_Ki) - #endif - , defKd[] = - #ifdef DEFAULT_Kd_LIST - DEFAULT_Kd_LIST - #else - ARRAY_BY_HOTENDS1(DEFAULT_Kd) - #endif - ; - static_assert(WITHIN(COUNT(defKp), 1, HOTENDS), "DEFAULT_Kp_LIST must have between 1 and HOTENDS items."); - static_assert(WITHIN(COUNT(defKi), 1, HOTENDS), "DEFAULT_Ki_LIST must have between 1 and HOTENDS items."); - static_assert(WITHIN(COUNT(defKd), 1, HOTENDS), "DEFAULT_Kd_LIST must have between 1 and HOTENDS items."); + constexpr float defKP[] = DEFAULT_KP_LIST, defKI[] = DEFAULT_KI_LIST, defKD[] = DEFAULT_KD_LIST; + static_assert(WITHIN(COUNT(defKP), 1, HOTENDS), "DEFAULT_KP_LIST must have between 1 and HOTENDS items."); + static_assert(WITHIN(COUNT(defKI), 1, HOTENDS), "DEFAULT_KI_LIST must have between 1 and HOTENDS items."); + static_assert(WITHIN(COUNT(defKD), 1, HOTENDS), "DEFAULT_KD_LIST must have between 1 and HOTENDS items."); #if ENABLED(PID_EXTRUSION_SCALING) - constexpr float defKc[] = - #ifdef DEFAULT_Kc_LIST - DEFAULT_Kc_LIST - #else - ARRAY_BY_HOTENDS1(DEFAULT_Kc) - #endif - ; - static_assert(WITHIN(COUNT(defKc), 1, HOTENDS), "DEFAULT_Kc_LIST must have between 1 and HOTENDS items."); + constexpr float defKC[] = DEFAULT_KC_LIST; + static_assert(WITHIN(COUNT(defKC), 1, HOTENDS), "DEFAULT_KC_LIST must have between 1 and HOTENDS items."); #endif #if ENABLED(PID_FAN_SCALING) - constexpr float defKf[] = - #ifdef DEFAULT_Kf_LIST - DEFAULT_Kf_LIST - #else - ARRAY_BY_HOTENDS1(DEFAULT_Kf) - #endif - ; - static_assert(WITHIN(COUNT(defKf), 1, HOTENDS), "DEFAULT_Kf_LIST must have between 1 and HOTENDS items."); + constexpr float defKF[] = DEFAULT_KF_LIST; + static_assert(WITHIN(COUNT(defKF), 1, HOTENDS), "DEFAULT_KF_LIST must have between 1 and HOTENDS items."); #endif #define PID_DEFAULT(N,E) def##N[E] #else @@ -768,11 +738,11 @@ void Temperature::factory_reset() { #endif HOTEND_LOOP() { temp_hotend[e].pid.set( - PID_DEFAULT(Kp, ALIM(e, defKp)), - PID_DEFAULT(Ki, ALIM(e, defKi)), - PID_DEFAULT(Kd, ALIM(e, defKd)) - OPTARG(PID_EXTRUSION_SCALING, PID_DEFAULT(Kc, ALIM(e, defKc))) - OPTARG(PID_FAN_SCALING, PID_DEFAULT(Kf, ALIM(e, defKf))) + PID_DEFAULT(KP, ALIM(e, defKP)), + PID_DEFAULT(KI, ALIM(e, defKI)), + PID_DEFAULT(KD, ALIM(e, defKD)) + OPTARG(PID_EXTRUSION_SCALING, PID_DEFAULT(KC, ALIM(e, defKC))) + OPTARG(PID_FAN_SCALING, PID_DEFAULT(KF, ALIM(e, defKF))) ); } #endif // PIDTEMP @@ -786,14 +756,14 @@ void Temperature::factory_reset() { // Heated Bed PID // #if ENABLED(PIDTEMPBED) - temp_bed.pid.set(DEFAULT_bedKp, DEFAULT_bedKi, DEFAULT_bedKd); + temp_bed.pid.set(DEFAULT_BED_KP, DEFAULT_BED_KI, DEFAULT_BED_KD); #endif // // Heated Chamber PID // #if ENABLED(PIDTEMPCHAMBER) - temp_chamber.pid.set(DEFAULT_chamberKp, DEFAULT_chamberKi, DEFAULT_chamberKd); + temp_chamber.pid.set(DEFAULT_CHAMBER_KP, DEFAULT_CHAMBER_KI, DEFAULT_CHAMBER_KD); #endif // User-Defined Thermistors @@ -1009,14 +979,14 @@ void Temperature::factory_reset() { TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE))); #if ANY(PIDTEMPBED, PIDTEMPCHAMBER) - FSTR_P const estring = PER_CBH(F("chamber"), F("bed"), FPSTR(NUL_STR)); - say_default_(); SERIAL_ECHOLN(estring, F("Kp "), tune_pid.p); - say_default_(); SERIAL_ECHOLN(estring, F("Ki "), tune_pid.i); - say_default_(); SERIAL_ECHOLN(estring, F("Kd "), tune_pid.d); + FSTR_P const estring = PER_CBH(F("CHAMBER_"), F("BED_"), FPSTR(NUL_STR)); + say_default_(); SERIAL_ECHOLN(estring, F("KP "), tune_pid.p); + say_default_(); SERIAL_ECHOLN(estring, F("KI "), tune_pid.i); + say_default_(); SERIAL_ECHOLN(estring, F("KD "), tune_pid.d); #else - say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.p); - say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.i); - say_default_(); SERIAL_ECHOLNPGM("Kd ", tune_pid.d); + say_default_(); SERIAL_ECHOLNPGM("KP ", tune_pid.p); + say_default_(); SERIAL_ECHOLNPGM("KI ", tune_pid.i); + say_default_(); SERIAL_ECHOLNPGM("KD ", tune_pid.d); #endif auto _set_hotend_pid = [](const uint8_t tool, const raw_pid_t &in_pid) { diff --git a/buildroot/tests/BTT_GTR_V1_0 b/buildroot/tests/BTT_GTR_V1_0 index 81d079b4f1..1ed65dcc90 100755 --- a/buildroot/tests/BTT_GTR_V1_0 +++ b/buildroot/tests/BTT_GTR_V1_0 @@ -25,7 +25,7 @@ restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \ Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z3_DRIVER_TYPE A4988 Z4_DRIVER_TYPE A4988 \ - DEFAULT_Kp_LIST '{ 22.2, 20.0, 21.0, 19.0, 18.0 }' DEFAULT_Ki_LIST '{ 1.08 }' DEFAULT_Kd_LIST '{ 114.0, 112.0, 110.0, 108.0 }' \ + DEFAULT_KP_LIST '{ 22.2, 20.0, 21.0, 19.0, 18.0 }' DEFAULT_KI_LIST '{ 1.08 }' DEFAULT_KD_LIST '{ 114.0, 112.0, 110.0, 108.0 }' \ Z3_STOP_PIN PI7 Z4_STOP_PIN PF6 opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_SLOW_FIRST_PRIME TOOLCHANGE_FS_PRIME_FIRST_USED \ REPRAP_DISCOUNT_SMART_CONTROLLER PID_PARAMS_PER_HOTEND Z_MULTI_ENDSTOPS TC_GCODE_USE_GLOBAL_X TC_GCODE_USE_GLOBAL_Y From 084b065f46976757432fba17fed46a6e015956e1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Nov 2025 17:23:55 -0600 Subject: [PATCH 31/39] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20MMU2=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_mmu2.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index fccc1a464c..332f96ffe2 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -154,10 +154,7 @@ void menu_mmu3_fail_stats_last_print() { sprintf_P(buffer2, PSTR("%hu"), load_fail_num); START_SCREEN(); - STATIC_ITEM( - TERN(printJobOngoing(), MSG_MMU_CURRENT_PRINT_FAILURES, MSG_MMU_LAST_PRINT_FAILURES), - SS_INVERT - ); + STATIC_ITEM_F(printJobOngoing() ? GET_TEXT_F(MSG_MMU_CURRENT_PRINT_FAILURES) : GET_TEXT_F(MSG_MMU_LAST_PRINT_FAILURES), SS_INVERT); #ifndef __AVR__ // TODO: I couldn't make this work on AVR PSTRING_ITEM(MSG_MMU_FAILS, buffer1, SS_FULL); @@ -236,10 +233,7 @@ void menu_mmu3_statistics() { ACTION_ITEM(MSG_MMU_DEV_INCREMENT_LOAD_FAILS, menu_mmu3_dev_increment_load_fail_stat); #endif - SUBMENU( - TERN(printJobOngoing(), MSG_MMU_CURRENT_PRINT_FAILURES, MSG_MMU_LAST_PRINT_FAILURES), - menu_mmu3_fail_stats_last_print - ); + SUBMENU_F(printJobOngoing() ? GET_TEXT_F(MSG_MMU_CURRENT_PRINT_FAILURES) : GET_TEXT_F(MSG_MMU_LAST_PRINT_FAILURES), menu_mmu3_fail_stats_last_print); SUBMENU(MSG_MMU_TOTAL_FAILURES, menu_mmu3_fail_stas_total); SUBMENU(MSG_MMU_MATERIAL_CHANGES, menu_mmu3_toolchange_stat_total); CONFIRM_ITEM(MSG_MMU_RESET_FAIL_STATS, From 544cde20fba4486d210f2a28f0da684b4865b026 Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Mon, 1 Dec 2025 00:40:21 +0000 Subject: [PATCH 32/39] [cron] Bump distribution date (2025-12-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 e04bcf0334..c884bcea7a 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 "2025-11-30" +//#define STRING_DISTRIBUTION_DATE "2025-12-01" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index d97a80ad36..3aa89f99b0 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 "2025-11-30" + #define STRING_DISTRIBUTION_DATE "2025-12-01" #endif /** From 35319049fe1140e4e14245b1f328535760fd8b06 Mon Sep 17 00:00:00 2001 From: Harald Wagener Date: Mon, 1 Dec 2025 03:05:45 +0100 Subject: [PATCH 33/39] =?UTF-8?q?=E2=9C=A8=20FT=5FMOTION=20>=20FTM=5FPOLYS?= =?UTF-8?q?=20(#28197)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 17 ++--- Marlin/src/gcode/feature/ft_motion/M494.cpp | 62 +++++++++++-------- Marlin/src/gcode/gcode.cpp | 4 +- Marlin/src/inc/Conditionals-4-adv.h | 3 + Marlin/src/lcd/menu/menu_motion.cpp | 58 +++++++++-------- Marlin/src/module/ft_motion.cpp | 18 ++++-- Marlin/src/module/ft_motion.h | 20 ++++-- .../src/module/ft_motion/trajectory_poly6.cpp | 4 +- ini/features.ini | 3 +- 9 files changed, 114 insertions(+), 75 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index f0b685ba19..410b08ab2f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1201,14 +1201,17 @@ // smoothing acceleration peaks, which may also smooth curved surfaces. #endif - #define FTM_TRAJECTORY_TYPE TRAPEZOIDAL // Block acceleration profile (TRAPEZOIDAL, POLY5, POLY6) - // TRAPEZOIDAL: Continuous Velocity. Max acceleration is respected. - // POLY5: Like POLY6 with 1.5x but uses less CPU. - // POLY6: Continuous Acceleration (aka S_CURVE). - // POLY trajectories not only reduce resonances without rounding corners, but also - // reduce extruder strain due to linear advance. + #define FTM_POLYS // Disable POLY5/6 to save ~3k of Flash. Preserves TRAPEZOIDAL. + #if ENABLED(FTM_POLYS) + #define FTM_TRAJECTORY_TYPE TRAPEZOIDAL // Block acceleration profile (TRAPEZOIDAL, POLY5, POLY6) + // TRAPEZOIDAL: Continuous Velocity. Max acceleration is respected. + // POLY5: Like POLY6 with 1.5x but uses less CPU. + // POLY6: Continuous Acceleration (aka S_CURVE). + // POLY trajectories not only reduce resonances without rounding corners, but also + // reduce extruder strain due to linear advance. - #define FTM_POLY6_ACCELERATION_OVERSHOOT 1.875f // Max acceleration overshoot factor for POLY6 (1.25 to 1.875) + #define FTM_POLY6_ACCELERATION_OVERSHOOT 1.875f // Max acceleration overshoot factor for POLY6 (1.25 to 1.875) + #endif /** * Advanced configuration diff --git a/Marlin/src/gcode/feature/ft_motion/M494.cpp b/Marlin/src/gcode/feature/ft_motion/M494.cpp index f3a4e61123..a359ab5269 100644 --- a/Marlin/src/gcode/feature/ft_motion/M494.cpp +++ b/Marlin/src/gcode/feature/ft_motion/M494.cpp @@ -38,12 +38,16 @@ static FSTR_P get_trajectory_type_name() { } void say_ftm_settings() { - SERIAL_ECHOLN(F(" Trajectory: "), get_trajectory_type_name(), C('('), (uint8_t)ftMotion.getTrajectoryType(), C(')')); + #if ENABLED(FTM_POLYS) + SERIAL_ECHOLN(F(" Trajectory: "), get_trajectory_type_name(), C('('), (uint8_t)ftMotion.getTrajectoryType(), C(')')); + #endif const ft_config_t &c = ftMotion.cfg; - if (ftMotion.getTrajectoryType() == TrajectoryType::POLY6) - SERIAL_ECHOLNPGM(" Poly6 Overshoot: ", p_float_t(c.poly6_acceleration_overshoot, 3)); + #if ENABLED(FTM_POLYS) + if (ftMotion.getTrajectoryType() == TrajectoryType::POLY6) + SERIAL_ECHOLNPGM(" Poly6 Overshoot: ", p_float_t(c.poly6_acceleration_overshoot, 3)); + #endif #if ENABLED(FTM_SMOOTHING) #define _SMOO_REPORT(A) SERIAL_ECHOLN(F(" "), C(IAXIS_CHAR(_AXIS(A))), F(" smoothing time: "), p_float_t(c.smoothingTime.A, 3), C('s')); @@ -66,10 +70,13 @@ void GcodeSuite::M494_report(const bool forReplay/*=true*/) { " Z", c.smoothingTime.Z, " E", c.smoothingTime.E ) ); - #endif + #endif // FTM_SMOOTHING - if (ftMotion.getTrajectoryType() == TrajectoryType::POLY6) - SERIAL_ECHOPGM(" O", c.poly6_acceleration_overshoot); + #if ENABLED(FTM_POLYS) + + if (ftMotion.getTrajectoryType() == TrajectoryType::POLY6) + SERIAL_ECHOPGM(" O", c.poly6_acceleration_overshoot); + #endif // FTM_POLYS SERIAL_EOL(); } @@ -88,28 +95,31 @@ void GcodeSuite::M494_report(const bool forReplay/*=true*/) { void GcodeSuite::M494() { bool report = !parser.seen_any(); - // Parse trajectory type parameter. - if (parser.seenval('T')) { - const int val = parser.value_int(); - if (WITHIN(val, 0, 2)) { - planner.synchronize(); - ftMotion.setTrajectoryType((TrajectoryType)val); - report = true; - } - else - SERIAL_ECHOLN(F("?Invalid "), F("trajectory type [T] value. Use 0=TRAPEZOIDAL, 1=POLY5, 2=POLY6")); - } + #if ENABLED(FTM_POLYS) - // Parse overshoot parameter. - if (parser.seenval('O')) { - const float val = parser.value_float(); - if (WITHIN(val, 1.25f, 1.875f)) { - ftMotion.cfg.poly6_acceleration_overshoot = val; - report = true; + // Parse trajectory type parameter. + if (parser.seenval('T')) { + const int val = parser.value_int(); + if (WITHIN(val, 0, 2)) { + planner.synchronize(); + ftMotion.setTrajectoryType((TrajectoryType)val); + report = true; + } + else + SERIAL_ECHOLN(F("?Invalid "), F("trajectory type [T] value. Use 0=TRAPEZOIDAL, 1=POLY5, 2=POLY6")); } - else - SERIAL_ECHOLN(F("?Invalid "), F("overshoot [O] value. Range 1.25-1.875")); - } + // Parse overshoot parameter. + if (parser.seenval('O')) { + const float val = parser.value_float(); + if (WITHIN(val, 1.25f, 1.875f)) { + ftMotion.cfg.poly6_acceleration_overshoot = val; + report = true; + } + else + SERIAL_ECHOLN(F("?Invalid "), F("overshoot [O] value. Range 1.25-1.875")); + } + + #endif // FTM_POLYS #if ENABLED(FTM_SMOOTHING) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index aa629f4a71..6dab1eb3bb 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -926,8 +926,8 @@ void GcodeSuite::process_parsed_command(bool no_ok/*=false*/) { #endif #if ENABLED(FT_MOTION) - case 493: M493(); break; // M493: Fixed-Time Motion control - #if ENABLED(FTM_SMOOTHING) + case 493: M493(); break; // M493: Fixed-Time Motion control + #if ANY(FTM_SMOOTHING, FTM_POLYS) case 494: M494(); break; // M494: Fixed-Time Motion extras #endif #if ENABLED(FTM_RESONANCE_TEST) diff --git a/Marlin/src/inc/Conditionals-4-adv.h b/Marlin/src/inc/Conditionals-4-adv.h index 6bac442308..32cd506760 100644 --- a/Marlin/src/inc/Conditionals-4-adv.h +++ b/Marlin/src/inc/Conditionals-4-adv.h @@ -1541,6 +1541,9 @@ #if !HAS_EXTRUDERS #undef FTM_SHAPER_E #endif + #if DISABLED(FTM_POLYS) + #define FTM_TRAJECTORY_TYPE TRAPEZOIDAL + #endif #endif // Multi-Stepping Limit diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index ef082fe89f..8bc29739ac 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -327,14 +327,17 @@ void menu_move() { } } - FSTR_P get_trajectory_name() { - switch (ftMotion.getTrajectoryType()) { - default: - case TrajectoryType::TRAPEZOIDAL: return GET_TEXT_F(MSG_FTM_TRAPEZOIDAL); - case TrajectoryType::POLY5: return GET_TEXT_F(MSG_FTM_POLY5); - case TrajectoryType::POLY6: return GET_TEXT_F(MSG_FTM_POLY6); + #if ENABLED(FTM_POLYS) + FSTR_P get_trajectory_name() { + switch (ftMotion.getTrajectoryType()) { + default: + case TrajectoryType::TRAPEZOIDAL: return GET_TEXT_F(MSG_FTM_TRAPEZOIDAL); + case TrajectoryType::POLY5: return GET_TEXT_F(MSG_FTM_POLY5); + case TrajectoryType::POLY6: return GET_TEXT_F(MSG_FTM_POLY6); + + } } - } + #endif // FTM_POLYS #if HAS_DYNAMIC_FREQ FSTR_P get_dyn_freq_mode_name() { @@ -371,16 +374,17 @@ void menu_move() { } SHAPED_MAP(MENU_FTM_SHAPER); - - void menu_ftm_trajectory_generator() { - const TrajectoryType current_type = ftMotion.getTrajectoryType(); - START_MENU(); - BACK_ITEM(MSG_FIXED_TIME_MOTION); - if (current_type != TrajectoryType::TRAPEZOIDAL) ACTION_ITEM(MSG_FTM_TRAPEZOIDAL, []{ planner.synchronize(); ftMotion.setTrajectoryType(TrajectoryType::TRAPEZOIDAL); ui.go_back(); }); - if (current_type != TrajectoryType::POLY5) ACTION_ITEM(MSG_FTM_POLY5, []{ planner.synchronize(); ftMotion.setTrajectoryType(TrajectoryType::POLY5); ui.go_back(); }); - if (current_type != TrajectoryType::POLY6) ACTION_ITEM(MSG_FTM_POLY6, []{ planner.synchronize(); ftMotion.setTrajectoryType(TrajectoryType::POLY6); ui.go_back(); }); + #if ENABLED(FTM_POLYS) + void menu_ftm_trajectory_generator() { + const TrajectoryType current_type = ftMotion.getTrajectoryType(); + START_MENU(); + BACK_ITEM(MSG_FIXED_TIME_MOTION); + if (current_type != TrajectoryType::TRAPEZOIDAL) ACTION_ITEM(MSG_FTM_TRAPEZOIDAL, []{ planner.synchronize(); ftMotion.setTrajectoryType(TrajectoryType::TRAPEZOIDAL); ui.go_back(); }); + if (current_type != TrajectoryType::POLY5) ACTION_ITEM(MSG_FTM_POLY5, []{ planner.synchronize(); ftMotion.setTrajectoryType(TrajectoryType::POLY5); ui.go_back(); }); + if (current_type != TrajectoryType::POLY6) ACTION_ITEM(MSG_FTM_POLY6, []{ planner.synchronize(); ftMotion.setTrajectoryType(TrajectoryType::POLY6); ui.go_back(); }); END_MENU(); } + #endif // FTM_POLYS #if ENABLED(FTM_RESONANCE_TEST) @@ -497,7 +501,9 @@ void menu_move() { #else auto _shaper_name = [](const AxisEnum a) { return get_shaper_name(a); }; auto _dmode = []{ return get_dyn_freq_mode_name(); }; - auto _traj_name = []{ return get_trajectory_name(); }; + #if ENABLED(FTM_POLYS) + auto _traj_name = []{ return get_trajectory_name(); }; + #endif #endif START_MENU(); @@ -508,6 +514,12 @@ void menu_move() { // Show only when FT Motion is active (or optionally always show) if (c.active || ENABLED(FT_MOTION_NO_MENU_TOGGLE)) { + #if ENABLED(FTM_POLYS) + SUBMENU_S(_traj_name(), MSG_FTM_TRAJECTORY, menu_ftm_trajectory_generator); + if (ftMotion.getTrajectoryType() == TrajectoryType::POLY6) + EDIT_ITEM(float42_52, MSG_FTM_POLY6_OVERSHOOT, &c.poly6_acceleration_overshoot, 1.25f, 1.875f); + #endif + #define SHAPER_MENU_ITEM(A) \ SUBMENU_N_S(_AXIS(A), _shaper_name(_AXIS(A)), MSG_FTM_CMPN_MODE, menu_ftm_shaper_##A); \ if (AXIS_IS_SHAPING(A)) { \ @@ -516,11 +528,6 @@ void menu_move() { if (AXIS_IS_EISHAPING(A)) \ EDIT_ITEM_FAST_N(float42_52, _AXIS(A), MSG_FTM_VTOL_N, &c.vtol.A, 0.0f, 1.0f, ftMotion.update_shaping_params); \ } - SUBMENU_S(_traj_name(), MSG_FTM_TRAJECTORY, menu_ftm_trajectory_generator); - - if (ftMotion.getTrajectoryType() == TrajectoryType::POLY6) - EDIT_ITEM(float42_52, MSG_FTM_POLY6_OVERSHOOT, &c.poly6_acceleration_overshoot, 1.25f, 1.875f); - SHAPED_MAP(SHAPER_MENU_ITEM); #if HAS_DYNAMIC_FREQ @@ -596,10 +603,11 @@ void menu_move() { START_MENU(); BACK_ITEM(MSG_TUNE); - SUBMENU_S(_traj_name(), MSG_FTM_TRAJECTORY, menu_ftm_trajectory_generator); - - if (ftMotion.getTrajectoryType() == TrajectoryType::POLY6) - EDIT_ITEM(float42_52, MSG_FTM_POLY6_OVERSHOOT, &c.poly6_acceleration_overshoot, 1.25f, 1.875f); + #if ENABLED(FTM_POLYS) + SUBMENU_S(_traj_name(), MSG_FTM_TRAJECTORY, menu_ftm_trajectory_generator); + if (ftMotion.getTrajectoryType() == TrajectoryType::POLY6) + EDIT_ITEM(float42_52, MSG_FTM_POLY6_OVERSHOOT, &c.poly6_acceleration_overshoot, 1.25f, 1.875f); + #endif #define _CMPM_MENU_ITEM(A) SUBMENU_N_S(_AXIS(A), _shaper_name(_AXIS(A)), MSG_FTM_CMPN_MODE, menu_ftm_shaper_##A); SHAPED_MAP(_CMPM_MENU_ITEM); diff --git a/Marlin/src/module/ft_motion.cpp b/Marlin/src/module/ft_motion.cpp index 74ef6e79ef..8c596f1fa3 100644 --- a/Marlin/src/module/ft_motion.cpp +++ b/Marlin/src/module/ft_motion.cpp @@ -33,8 +33,10 @@ #include "ft_motion.h" #include "ft_motion/trajectory_trapezoidal.h" -#include "ft_motion/trajectory_poly5.h" -#include "ft_motion/trajectory_poly6.h" +#if ENABLED(FTM_POLYS) + #include "ft_motion/trajectory_poly5.h" + #include "ft_motion/trajectory_poly6.h" +#endif #if ENABLED(FTM_RESONANCE_TEST) #include "ft_motion/resonance_generator.h" #include "../gcode/gcode.h" // for home_all_axes @@ -71,8 +73,10 @@ float FTMotion::tau = 0.0f; // (s) Time since start of b // Trajectory generators TrapezoidalTrajectoryGenerator FTMotion::trapezoidalGenerator; -Poly5TrajectoryGenerator FTMotion::poly5Generator; -Poly6TrajectoryGenerator FTMotion::poly6Generator; +#if ENABLED(FTM_POLYS) + Poly5TrajectoryGenerator FTMotion::poly5Generator; + Poly6TrajectoryGenerator FTMotion::poly6Generator; +#endif TrajectoryGenerator* FTMotion::currentGenerator = &FTMotion::trapezoidalGenerator; TrajectoryType FTMotion::trajectoryType = TrajectoryType::FTM_TRAJECTORY_TYPE; @@ -307,8 +311,10 @@ void FTMotion::setTrajectoryType(const TrajectoryType type) { switch (type) { default: cfg.trajectory_type = trajectoryType = TrajectoryType::FTM_TRAJECTORY_TYPE; case TrajectoryType::TRAPEZOIDAL: currentGenerator = &trapezoidalGenerator; break; - case TrajectoryType::POLY5: currentGenerator = &poly5Generator; break; - case TrajectoryType::POLY6: currentGenerator = &poly6Generator; break; + #if ENABLED(FTM_POLYS) + case TrajectoryType::POLY5: currentGenerator = &poly5Generator; break; + case TrajectoryType::POLY6: currentGenerator = &poly6Generator; break; + #endif } } diff --git a/Marlin/src/module/ft_motion.h b/Marlin/src/module/ft_motion.h index d839869058..d26fa8b882 100644 --- a/Marlin/src/module/ft_motion.h +++ b/Marlin/src/module/ft_motion.h @@ -26,8 +26,10 @@ #include "stepper.h" // For stepper motion and direction #include "ft_motion/trajectory_trapezoidal.h" -#include "ft_motion/trajectory_poly5.h" -#include "ft_motion/trajectory_poly6.h" +#if ENABLED(FTM_POLYS) + #include "ft_motion/trajectory_poly5.h" + #include "ft_motion/trajectory_poly6.h" +#endif #if ENABLED(FTM_RESONANCE_TEST) #include "ft_motion/resonance_generator.h" #endif @@ -83,7 +85,9 @@ typedef struct FTConfig { #endif TrajectoryType trajectory_type = TrajectoryType::FTM_TRAJECTORY_TYPE; // Trajectory generator type - float poly6_acceleration_overshoot; // Overshoot factor for Poly6 (1.25 to 2.0) + #if ENABLED(FTM_POLYS) + float poly6_acceleration_overshoot; // Overshoot factor for Poly6 (1.25 to 2.0) + #endif } ft_config_t; /** @@ -134,7 +138,9 @@ class FTMotion { #undef _SET_SMOOTH #endif - cfg.poly6_acceleration_overshoot = FTM_POLY6_ACCELERATION_OVERSHOOT; + #if ENABLED(FTM_POLYS) + cfg.poly6_acceleration_overshoot = FTM_POLY6_ACCELERATION_OVERSHOOT; + #endif setTrajectoryType(TrajectoryType::FTM_TRAJECTORY_TYPE); @@ -219,8 +225,10 @@ class FTMotion { // Trajectory generators static TrapezoidalTrajectoryGenerator trapezoidalGenerator; - static Poly5TrajectoryGenerator poly5Generator; - static Poly6TrajectoryGenerator poly6Generator; + #if ENABLED(FTM_POLYS) + static Poly5TrajectoryGenerator poly5Generator; + static Poly6TrajectoryGenerator poly6Generator; + #endif static TrajectoryGenerator* currentGenerator; static TrajectoryType trajectoryType; diff --git a/Marlin/src/module/ft_motion/trajectory_poly6.cpp b/Marlin/src/module/ft_motion/trajectory_poly6.cpp index 45dff71084..4693828fe3 100644 --- a/Marlin/src/module/ft_motion/trajectory_poly6.cpp +++ b/Marlin/src/module/ft_motion/trajectory_poly6.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(FT_MOTION) +#if ENABLED(FTM_POLYS) #include "trajectory_poly6.h" #include "../ft_motion.h" @@ -140,4 +140,4 @@ void Poly6TrajectoryGenerator::reset() { acc_c6 = dec_c6 = 0.0f; } -#endif // FT_MOTION +#endif // FTM_POLYS diff --git a/ini/features.ini b/ini/features.ini index 1c10302fb0..4afdc3dc4c 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -311,9 +311,10 @@ HAS_DUPLICATION_MODE = build_src_filter=+ PLATFORM_M997_SUPPORT = build_src_filter=+ HAS_TOOLCHANGE = build_src_filter=+ -FT_MOTION = build_src_filter=+ + - + - +FT_MOTION = build_src_filter=+ + - + - - FTM_SMOOTHING = build_src_filter=+ FTM_RESONANCE_TEST = build_src_filter=+ +FTM_POLYS = build_src_filter=+ HAS_LIN_ADVANCE_K = build_src_filter=+ PHOTO_GCODE = build_src_filter=+ CONTROLLER_FAN_EDITABLE = build_src_filter=+ From 7fcc605595f777e00c377372f9a4e7c09d232a2a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 24 Nov 2025 17:06:42 -0600 Subject: [PATCH 34/39] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Reloc?= =?UTF-8?q?ate=20G38=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 5 ----- Marlin/src/MarlinCore.h | 5 ----- Marlin/src/gcode/probe/G38.cpp | 10 ++++++---- Marlin/src/module/endstops.cpp | 6 +++--- Marlin/src/module/endstops.h | 8 ++++++++ 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index cb81efc4bb..b6a47ec744 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -164,11 +164,6 @@ CardReader card; #endif -#if ENABLED(G38_PROBE_TARGET) - uint8_t G38_move; // = 0 - bool G38_did_trigger; // = false -#endif - #if ENABLED(DELTA) #include "module/delta.h" #elif ENABLED(POLARGRAPH) diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index ecab0e3630..6f27b9998e 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -33,11 +33,6 @@ void stop(); void idle(const bool no_stepper_sleep=false); inline void idle_no_sleep() { idle(true); } -#if ENABLED(G38_PROBE_TARGET) - extern uint8_t G38_move; // Flag to tell the ISR that G38 is in progress, and the type - extern bool G38_did_trigger; // Flag from the ISR to indicate the endstop changed -#endif - void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false); void minkill(const bool steppers_off=false); diff --git a/Marlin/src/gcode/probe/G38.cpp b/Marlin/src/gcode/probe/G38.cpp index d57eb9b59e..34cab07ed6 100644 --- a/Marlin/src/gcode/probe/G38.cpp +++ b/Marlin/src/gcode/probe/G38.cpp @@ -31,12 +31,14 @@ #include "../../module/planner.h" #include "../../module/probe.h" +probe_target_t G38_move{0}; + inline void G38_single_probe(const uint8_t move_value) { endstops.enable(true); - G38_move = move_value; + G38_move.type = move_value; prepare_line_to_destination(); planner.synchronize(); - G38_move = 0; + G38_move.type = 0; endstops.hit_on_purpose(); set_current_from_steppers_for_axis(ALL_AXES_ENUM); sync_plan_position(); @@ -64,12 +66,12 @@ inline bool G38_run_probe() { constexpr uint8_t move_value = 1; #endif - G38_did_trigger = false; + G38_move.triggered = false; // Move until destination reached or target hit G38_single_probe(move_value); - if (G38_did_trigger) { + if (G38_move.triggered) { G38_pass_fail = true; diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 20b3b8b1d2..31b877b642 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -473,7 +473,7 @@ void Endstops::update() { #if ENABLED(G38_PROBE_TARGET) // For G38 moves check the probe's pin for ALL movement - if (G38_move) UPDATE_LIVE_STATE(Z, TERN(USE_Z_MIN_PROBE, MIN_PROBE, MIN)); + if (G38_move.type) UPDATE_LIVE_STATE(Z, TERN(USE_Z_MIN_PROBE, MIN_PROBE, MIN)); #endif #if ENABLED(CALIBRATION_GCODE) @@ -723,8 +723,8 @@ void Endstops::update() { #if ENABLED(G38_PROBE_TARGET) // For G38 moves check the probe's pin for ALL movement - if (G38_move && TEST_ENDSTOP(Z_MIN_PROBE) == TERN1(G38_PROBE_AWAY, (G38_move < 4))) { - G38_did_trigger = true; + if (G38_move.type && TEST_ENDSTOP(Z_MIN_PROBE) == TERN1(G38_PROBE_AWAY, (G38_move.type < 4))) { + G38_move.triggered = true; #define _G38_SET(Q) | (AXIS_IS_MOVING(Q) << _AXIS(Q)) #define _G38_RESP(Q) if (moving[_AXIS(Q)]) { _ENDSTOP_HIT(Q, ENDSTOP); planner.endstop_triggered(_AXIS(Q)); } const Flags moving = { uvalue_t(NUM_AXES)(0 MAIN_AXIS_MAP(_G38_SET)) }; diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 4d7a444bc4..17715de1da 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -313,3 +313,11 @@ class TemporaryGlobalEndstopsState { } ~TemporaryGlobalEndstopsState() { endstops.enable_globally(saved); } }; + +#if ENABLED(G38_PROBE_TARGET) + typedef struct ProbeTarget { + uint8_t type; // Flag to tell the ISR the type of G38 in progress; 0 for NONE. + bool triggered; // Flag from the ISR to indicate the endstop changed + } probe_target_t; + extern probe_target_t G38_move; +#endif From 73fa80f12870525ca9ae7ca7f341f4bf57b804e8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Nov 2025 12:28:34 -0600 Subject: [PATCH 35/39] =?UTF-8?q?=F0=9F=8E=A8=20Pretty=20up=20timers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/timers.h | 14 ++++++------ Marlin/src/HAL/DUE/timers.h | 14 ++++++------ Marlin/src/HAL/ESP32/timers.h | 33 +++++++++++++++-------------- Marlin/src/HAL/GD32_MFL/timers.h | 17 ++++++++------- Marlin/src/HAL/HC32/timers.h | 12 +++++------ Marlin/src/HAL/LINUX/timers.h | 22 +++++++++---------- Marlin/src/HAL/LPC1768/timers.h | 22 +++++++++---------- Marlin/src/HAL/NATIVE_SIM/timers.h | 22 +++++++++---------- Marlin/src/HAL/RP2040/timers.h | 16 +++++++------- Marlin/src/HAL/SAMD21/timers.h | 12 +++++------ Marlin/src/HAL/SAMD51/timers.h | 12 +++++------ Marlin/src/HAL/STM32/timers.h | 16 +++++++------- Marlin/src/HAL/STM32F1/timers.h | 22 +++++++++---------- Marlin/src/HAL/TEENSY31_32/timers.h | 20 ++++++++--------- Marlin/src/HAL/TEENSY35_36/timers.h | 20 ++++++++--------- Marlin/src/HAL/TEENSY40_41/timers.h | 16 +++++++------- 16 files changed, 145 insertions(+), 145 deletions(-) diff --git a/Marlin/src/HAL/AVR/timers.h b/Marlin/src/HAL/AVR/timers.h index f316b7c551..892e0e493b 100644 --- a/Marlin/src/HAL/AVR/timers.h +++ b/Marlin/src/HAL/AVR/timers.h @@ -46,15 +46,15 @@ typedef uint16_t hal_timer_t; #define MF_TIMER_TEMP 0 #endif -#define TEMP_TIMER_FREQUENCY (((F_CPU) + 0x2000) / 0x4000) +#define TEMP_TIMER_FREQUENCY (((F_CPU) + 0x2000) / 0x4000) -#define STEPPER_TIMER_RATE HAL_TIMER_RATE -#define STEPPER_TIMER_PRESCALE 8 -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) +#define STEPPER_TIMER_RATE HAL_TIMER_RATE +#define STEPPER_TIMER_PRESCALE 8 +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define ENABLE_STEPPER_DRIVER_INTERRUPT() SBI(TIMSK1, OCIE1A) #define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A) diff --git a/Marlin/src/HAL/DUE/timers.h b/Marlin/src/HAL/DUE/timers.h index 8572958732..c63e051ef3 100644 --- a/Marlin/src/HAL/DUE/timers.h +++ b/Marlin/src/HAL/DUE/timers.h @@ -52,19 +52,19 @@ typedef uint32_t hal_timer_t; #define MF_TIMER_TONE 6 // index of timer to use for beeper tones #endif -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency -#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // (Hz) Frequency of Stepper Timer ISR (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) // (MHz) Stepper Timer ticks per µs #define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) #define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) #define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) diff --git a/Marlin/src/HAL/ESP32/timers.h b/Marlin/src/HAL/ESP32/timers.h index 868b5fa850..4e5f92d671 100644 --- a/Marlin/src/HAL/ESP32/timers.h +++ b/Marlin/src/HAL/ESP32/timers.h @@ -36,35 +36,40 @@ typedef uint64_t hal_timer_t; #define MF_TIMER_STEP 0 // Timer Index for Stepper #endif #ifndef MF_TIMER_PULSE - #define MF_TIMER_PULSE MF_TIMER_STEP + #define MF_TIMER_PULSE MF_TIMER_STEP // Timer Index for Pulse interval #endif #ifndef MF_TIMER_TEMP #define MF_TIMER_TEMP 1 // Timer Index for Temperature #endif #ifndef MF_TIMER_PWM - #define MF_TIMER_PWM 2 // index of timer to use for PWM outputs + #define MF_TIMER_PWM 2 // Timer Index for PWM outputs #endif #ifndef MF_TIMER_TONE - #define MF_TIMER_TONE 3 // index of timer for beeper tones + #define MF_TIMER_TONE 3 // Timer Index for beeper tones #endif -#define HAL_TIMER_RATE APB_CLK_FREQ // frequency of timer peripherals +#define HAL_TIMER_RATE APB_CLK_FREQ // Frequency of timer peripherals + +#define TEMP_TIMER_PRESCALE 1000 // Prescaler for setting Temp Timer, 72Khz +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency #if ENABLED(I2S_STEPPER_STREAM) #define STEPPER_TIMER_PRESCALE 1 - #define STEPPER_TIMER_RATE 250'000 // 250khz, 4µs pulses of i2s word clock + #define STEPPER_TIMER_RATE 250'000 // 250khz, 4µs pulses of i2s word clock + #define STEPPER_TIMER_TICKS_PER_US 0.25 // (MHz) Stepper Timer ticks per µs #else #define STEPPER_TIMER_PRESCALE 40 - #define STEPPER_TIMER_RATE ((HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE)) // frequency of stepper timer, 2MHz + #define STEPPER_TIMER_RATE ((HAL_TIMER_RATE) / (STEPPER_TIMER_PRESCALE)) // (Hz) Frequency of Stepper Timer ISR, 2MHz + #define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1'000'000UL) // (MHz) Stepper Timer ticks per µs #endif -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1'000'000) // stepper timer ticks per µs #define STEP_TIMER_MIN_INTERVAL 8 // minimum time in µs between stepper interrupts -#define TONE_TIMER_PRESCALE 1000 // Arbitrary value, no idea what i'm doing here +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TONE_TIMER_PRESCALE 1000 // Arbitrary value, no idea what i'm doing here #define PWM_TIMER_PRESCALE 10 #if ENABLED(FAST_PWM_FAN) @@ -74,13 +79,9 @@ typedef uint64_t hal_timer_t; #endif #define MAX_PWM_PINS 32 // Number of PWM pin-slots -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US - -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) #define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) #define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) diff --git a/Marlin/src/HAL/GD32_MFL/timers.h b/Marlin/src/HAL/GD32_MFL/timers.h index 9ecb1dcf79..d45e3d1767 100644 --- a/Marlin/src/HAL/GD32_MFL/timers.h +++ b/Marlin/src/HAL/GD32_MFL/timers.h @@ -29,10 +29,6 @@ // Defines // ------------------------ -// Timer configuration constants -#define STEPPER_TIMER_RATE 2000000 -#define TEMP_TIMER_FREQUENCY 1000 - // Timer instance definitions #define MF_TIMER_STEP 3 #define MF_TIMER_TEMP 1 @@ -43,12 +39,17 @@ extern uint32_t GetStepperTimerClkFreq(); +// Timer configuration constants +#define STEPPER_TIMER_RATE 2000000 +#define TEMP_TIMER_FREQUENCY 1000 + // Timer prescaler calculations -#define STEPPER_TIMER_PRESCALE (GetStepperTimerClkFreq() / STEPPER_TIMER_RATE) // Prescaler = 30 -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // Stepper timer ticks per µs -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE +#define STEPPER_TIMER_PRESCALE (GetStepperTimerClkFreq() / STEPPER_TIMER_RATE) // Prescaler = 30 +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) // (MHz) Stepper Timer ticks per µs + +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE // Timer interrupt priorities #define STEP_TIMER_IRQ_PRIORITY 2 diff --git a/Marlin/src/HAL/HC32/timers.h b/Marlin/src/HAL/HC32/timers.h index e5bb29e834..9b898101dc 100644 --- a/Marlin/src/HAL/HC32/timers.h +++ b/Marlin/src/HAL/HC32/timers.h @@ -65,8 +65,8 @@ extern Timer0 step_timer; #define STEP_TIMER_PRIORITY DDL_IRQ_PRIORITY_00 // Top priority, nothing else uses it #define STEPPER_TIMER_PRESCALE 16UL // 12.5MHz -#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // 50MHz / 16 = 3.125MHz -#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000UL) // Integer 3 +#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // 50MHz / 16 = 3.125MHz +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) // Integer 3 // Pulse timer (== stepper timer) #define MF_TIMER_PULSE MF_TIMER_STEP @@ -110,11 +110,11 @@ inline void HAL_timer_isr_epilogue(const timer_channel_t) {} // // HAL function aliases // -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP); // diff --git a/Marlin/src/HAL/LINUX/timers.h b/Marlin/src/HAL/LINUX/timers.h index b09fc6156a..cbca970bb2 100644 --- a/Marlin/src/HAL/LINUX/timers.h +++ b/Marlin/src/HAL/LINUX/timers.h @@ -49,21 +49,21 @@ typedef uint32_t hal_timer_t; #endif #define TEMP_TIMER_RATE 1000000 -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency -#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs -#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // (Hz) Frequency of Stepper Timer ISR (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) // (MHz) Stepper Timer ticks per µs +#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR diff --git a/Marlin/src/HAL/LPC1768/timers.h b/Marlin/src/HAL/LPC1768/timers.h index eae2cd587e..e29aa273a1 100644 --- a/Marlin/src/HAL/LPC1768/timers.h +++ b/Marlin/src/HAL/LPC1768/timers.h @@ -77,21 +77,19 @@ typedef uint32_t hal_timer_t; #define TEMP_TIMER_RATE 1000000 // 1MHz #define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency -#ifndef STEPPER_TIMER_RATE - #define STEPPER_TIMER_RATE HAL_TIMER_RATE // (Hz) Frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) -#endif -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // Stepper Timer ticks per µs -#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // (Hz) Frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) // (MHz) Stepper Timer ticks per µs +#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR diff --git a/Marlin/src/HAL/NATIVE_SIM/timers.h b/Marlin/src/HAL/NATIVE_SIM/timers.h index 3868f8f1e3..6609774d12 100644 --- a/Marlin/src/HAL/NATIVE_SIM/timers.h +++ b/Marlin/src/HAL/NATIVE_SIM/timers.h @@ -52,22 +52,22 @@ typedef uint64_t hal_timer_t; #endif #define SYSTICK_TIMER_FREQUENCY 1000 -#define TEMP_TIMER_RATE 1'000'000 -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TEMP_TIMER_RATE 1'000'000 // (Hz) Temperature Timer count rate +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR call frequency -#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1'000'000) // stepper timer ticks per µs +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // (Hz) Frequency of Stepper Timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1'000'000) // (MHz) Stepper Timer ticks per µs #define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR diff --git a/Marlin/src/HAL/RP2040/timers.h b/Marlin/src/HAL/RP2040/timers.h index 5e0234c10c..06deb152f7 100644 --- a/Marlin/src/HAL/RP2040/timers.h +++ b/Marlin/src/HAL/RP2040/timers.h @@ -58,21 +58,21 @@ typedef uint64_t hal_timer_t; #endif #define TEMP_TIMER_RATE HAL_TIMER_RATE -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency #define STEPPER_TIMER_RATE HAL_TIMER_RATE / 10 // 100khz roughly #define STEPPER_TIMER_TICKS_PER_US (0.1) // fixed value as we use a microsecond timesource #define STEPPER_TIMER_PRESCALE (10) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR diff --git a/Marlin/src/HAL/SAMD21/timers.h b/Marlin/src/HAL/SAMD21/timers.h index ee193e8137..c558b89791 100644 --- a/Marlin/src/HAL/SAMD21/timers.h +++ b/Marlin/src/HAL/SAMD21/timers.h @@ -49,15 +49,15 @@ typedef uint32_t hal_timer_t; #define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature #endif -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency -#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) -#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // (Hz) Frequency of Stepper Timer ISR (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000) // (MHz) Stepper Timer ticks per µs #define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) #define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) diff --git a/Marlin/src/HAL/SAMD51/timers.h b/Marlin/src/HAL/SAMD51/timers.h index 2b02ad8775..d39ac0254a 100644 --- a/Marlin/src/HAL/SAMD51/timers.h +++ b/Marlin/src/HAL/SAMD51/timers.h @@ -48,15 +48,15 @@ typedef uint32_t hal_timer_t; #define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature #endif -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency -#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) -#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // (Hz) Frequency of Stepper Timer ISR (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000) // (MHz) Stepper Timer ticks per µs #define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) #define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) diff --git a/Marlin/src/HAL/STM32/timers.h b/Marlin/src/HAL/STM32/timers.h index 70e0bcd4a5..c8c4845d98 100644 --- a/Marlin/src/HAL/STM32/timers.h +++ b/Marlin/src/HAL/STM32/timers.h @@ -54,17 +54,17 @@ #define STEPPER_TIMER_RATE 2000000 // 2 Mhz extern uint32_t GetStepperTimerClkFreq(); #define STEPPER_TIMER_PRESCALE (GetStepperTimerClkFreq() / (STEPPER_TIMER_RATE)) -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) // (MHz) Stepper Timer ticks per µs -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) extern void Step_Handler(); diff --git a/Marlin/src/HAL/STM32F1/timers.h b/Marlin/src/HAL/STM32F1/timers.h index b87d355922..10ee2e4f9e 100644 --- a/Marlin/src/HAL/STM32F1/timers.h +++ b/Marlin/src/HAL/STM32F1/timers.h @@ -95,27 +95,27 @@ typedef uint16_t hal_timer_t; #define TEMP_TIMER_IRQ_PRIO 3 #define SERVO0_TIMER_IRQ_PRIO 1 -#define TEMP_TIMER_PRESCALE 1000 // prescaler for setting Temp timer, 72Khz -#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency +#define TEMP_TIMER_PRESCALE 1000 // Prescaler for setting Temp Timer, 72Khz +#define TEMP_TIMER_FREQUENCY 1000 // (Hz) Temperature ISR frequency -#define STEPPER_TIMER_PRESCALE 18 // prescaler for setting stepper timer, 4Mhz -#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // frequency of stepper timer -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_PRESCALE 18 // Prescaler for setting stepper timer, 4Mhz +#define STEPPER_TIMER_RATE (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) // (Hz) Frequency of Stepper Timer ISR +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) // (MHz) Stepper Timer ticks per µs -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE timer_dev* HAL_get_timer_dev(int number); #define TIMER_DEV(num) HAL_get_timer_dev(num) #define STEP_TIMER_DEV TIMER_DEV(MF_TIMER_STEP) #define TEMP_TIMER_DEV TIMER_DEV(MF_TIMER_TEMP) -#define ENABLE_STEPPER_DRIVER_INTERRUPT() timer_enable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() timer_disable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() timer_enable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() timer_disable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() timer_enable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN) +#define ENABLE_TEMPERATURE_INTERRUPT() timer_enable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN) #define DISABLE_TEMPERATURE_INTERRUPT() timer_disable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN) #define HAL_timer_get_count(timer_num) timer_get_count(TIMER_DEV(timer_num)) diff --git a/Marlin/src/HAL/TEENSY31_32/timers.h b/Marlin/src/HAL/TEENSY31_32/timers.h index 84281a228f..7de8cccde4 100644 --- a/Marlin/src/HAL/TEENSY31_32/timers.h +++ b/Marlin/src/HAL/TEENSY31_32/timers.h @@ -58,19 +58,19 @@ typedef uint32_t hal_timer_t; #define TEMP_TIMER_FREQUENCY 1000 -#define STEPPER_TIMER_RATE HAL_TIMER_RATE -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) -#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) +#define STEPPER_TIMER_RATE HAL_TIMER_RATE +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) +#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR diff --git a/Marlin/src/HAL/TEENSY35_36/timers.h b/Marlin/src/HAL/TEENSY35_36/timers.h index c7292f3619..60b35faa38 100644 --- a/Marlin/src/HAL/TEENSY35_36/timers.h +++ b/Marlin/src/HAL/TEENSY35_36/timers.h @@ -58,19 +58,19 @@ typedef uint32_t hal_timer_t; #define TEMP_TIMER_FREQUENCY 1000 -#define STEPPER_TIMER_RATE HAL_TIMER_RATE -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) -#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) +#define STEPPER_TIMER_RATE HAL_TIMER_RATE +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) +#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR diff --git a/Marlin/src/HAL/TEENSY40_41/timers.h b/Marlin/src/HAL/TEENSY40_41/timers.h index 98a852ee57..49b5c32836 100644 --- a/Marlin/src/HAL/TEENSY40_41/timers.h +++ b/Marlin/src/HAL/TEENSY40_41/timers.h @@ -59,18 +59,18 @@ typedef uint32_t hal_timer_t; #define HAL_TIMER_RATE GPT1_TIMER_RATE #define STEPPER_TIMER_RATE HAL_TIMER_RATE -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000UL) #define STEPPER_TIMER_PRESCALE (GPT_TIMER_RATE / STEPPER_TIMER_RATE) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // (Hz) Frequency of Pulse Timer +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE -#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) -#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) -#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) -#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) #define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) #ifndef HAL_STEP_TIMER_ISR From 584abc5835e6b5db2483379ccaba10bc4a136d22 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Nov 2025 12:48:54 -0600 Subject: [PATCH 36/39] =?UTF-8?q?=F0=9F=8E=A8=20"controllerfan"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/temperature.cpp | 8 ++++---- Marlin/src/module/temperature.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8d63e226b9..d56937d513 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -410,7 +410,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #endif #if ALL(FAN_SOFT_PWM, USE_CONTROLLER_FAN) - uint8_t Temperature::soft_pwm_controller_speed = FAN_OFF_PWM; + uint8_t Temperature::soft_pwm_controllerfan_speed = FAN_OFF_PWM; #endif // Init fans according to whether they're native PWM or Software PWM @@ -4038,7 +4038,7 @@ void Temperature::isr() { #endif #if ALL(FAN_SOFT_PWM, USE_CONTROLLER_FAN) - static SoftPWM soft_pwm_controller; + static SoftPWM soft_pwm_controllerfan; #endif #define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ ENABLED(FAN_INVERTING)) @@ -4076,7 +4076,7 @@ void Temperature::isr() { #if ENABLED(FAN_SOFT_PWM) #if ENABLED(USE_CONTROLLER_FAN) - WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, controllerFan.soft_pwm_speed)); + WRITE(CONTROLLER_FAN_PIN, soft_pwm_controllerfan.add(pwm_mask, controllerFan.soft_pwm_speed)); #endif #define _FAN_PWM(N) do{ \ @@ -4132,7 +4132,7 @@ void Temperature::isr() { if (soft_pwm_count_fan[7] <= pwm_count_tmp) WRITE_FAN(7, LOW); #endif #if ENABLED(USE_CONTROLLER_FAN) - if (soft_pwm_controller.count <= pwm_count_tmp) WRITE(CONTROLLER_FAN_PIN, LOW); + if (soft_pwm_controllerfan.count <= pwm_count_tmp) WRITE(CONTROLLER_FAN_PIN, LOW); #endif #endif } diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 884a72646e..f2ef4d0f6c 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -686,7 +686,7 @@ class Temperature { #endif #if ALL(FAN_SOFT_PWM, USE_CONTROLLER_FAN) - static uint8_t soft_pwm_controller_speed; + static uint8_t soft_pwm_controllerfan_speed; #endif #if ALL(HAS_MARLINUI_MENU, PREVENT_COLD_EXTRUSION) && E_MANUAL > 0 From 0ac1435a8ca015e0edf2f28999bd6d7535b1cb0a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 27 Nov 2025 12:48:28 -0600 Subject: [PATCH 37/39] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Reduc?= =?UTF-8?q?tion=20via=20TERF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/fancheck.cpp | 42 ++------ Marlin/src/module/endstops.cpp | 173 ++++++------------------------ Marlin/src/module/stepper.cpp | 110 +++++-------------- Marlin/src/module/temperature.cpp | 100 +++-------------- 4 files changed, 82 insertions(+), 343 deletions(-) diff --git a/Marlin/src/feature/fancheck.cpp b/Marlin/src/feature/fancheck.cpp index 4978b8c999..339eb16aa9 100644 --- a/Marlin/src/feature/fancheck.cpp +++ b/Marlin/src/feature/fancheck.cpp @@ -42,30 +42,18 @@ bool FanCheck::enabled; void FanCheck::init() { #define _TACHINIT(N) TERN(E##N##_FAN_TACHO_PULLUP, SET_INPUT_PULLUP, TERN(E##N##_FAN_TACHO_PULLDOWN, SET_INPUT_PULLDOWN, SET_INPUT))(E##N##_FAN_TACHO_PIN) - TERF(HAS_E0_FAN_TACHO, _TACHINIT)(0); - TERF(HAS_E1_FAN_TACHO, _TACHINIT)(1); - TERF(HAS_E2_FAN_TACHO, _TACHINIT)(2); - TERF(HAS_E3_FAN_TACHO, _TACHINIT)(3); - TERF(HAS_E4_FAN_TACHO, _TACHINIT)(4); - TERF(HAS_E5_FAN_TACHO, _TACHINIT)(5); - TERF(HAS_E6_FAN_TACHO, _TACHINIT)(6); - TERF(HAS_E7_FAN_TACHO, _TACHINIT)(7); + #define _EN_TACHINIT(N) TERF(HAS_E##N##_FAN_TACHO, _TACHINIT)(N); + REPEAT(8, _EN_TACHINIT); } void FanCheck::update_tachometers() { bool status; - #define _TACHO_CASE(N) case N: status = READ(E##N##_FAN_TACHO_PIN); break; + #define __TACHO_GET_STATUS(N) case N: status = READ(E##N##_FAN_TACHO_PIN); break; + #define _TACHO_GET_STATUS(N) TERF(HAS_E##N##_FAN_TACHO, __TACHO_GET_STATUS)(N) for (uint8_t f = 0; f < TACHO_COUNT; ++f) { switch (f) { - TERF(HAS_E0_FAN_TACHO, _TACHO_CASE)(0) - TERF(HAS_E1_FAN_TACHO, _TACHO_CASE)(1) - TERF(HAS_E2_FAN_TACHO, _TACHO_CASE)(2) - TERF(HAS_E3_FAN_TACHO, _TACHO_CASE)(3) - TERF(HAS_E4_FAN_TACHO, _TACHO_CASE)(4) - TERF(HAS_E5_FAN_TACHO, _TACHO_CASE)(5) - TERF(HAS_E6_FAN_TACHO, _TACHO_CASE)(6) - TERF(HAS_E7_FAN_TACHO, _TACHO_CASE)(7) + REPEAT(8, _TACHO_GET_STATUS) default: continue; } @@ -83,14 +71,8 @@ void FanCheck::compute_speed(uint16_t elapsedTime) { uint8_t fan_error_msk = 0; for (uint8_t f = 0; f < TACHO_COUNT; ++f) { switch (f) { - TERN_(HAS_E0_FAN_TACHO, case 0:) - TERN_(HAS_E1_FAN_TACHO, case 1:) - TERN_(HAS_E2_FAN_TACHO, case 2:) - TERN_(HAS_E3_FAN_TACHO, case 3:) - TERN_(HAS_E4_FAN_TACHO, case 4:) - TERN_(HAS_E5_FAN_TACHO, case 5:) - TERN_(HAS_E6_FAN_TACHO, case 6:) - TERN_(HAS_E7_FAN_TACHO, case 7:) + #define _EN_COMPUTE_FAN_CASE(N) TERN_(HAS_E##N##_FAN_TACHO, case N:) + REPEAT(8, _EN_COMPUTE_FAN_CASE) // Compute fan speed rps[f] = edge_counter[f] * float(250) / elapsedTime; edge_counter[f] = 0; @@ -147,14 +129,8 @@ void FanCheck::print_fan_states() { for (uint8_t s = 0; s < 2; ++s) { for (uint8_t f = 0; f < TACHO_COUNT; ++f) { switch (f) { - TERN_(HAS_E0_FAN_TACHO, case 0:) - TERN_(HAS_E1_FAN_TACHO, case 1:) - TERN_(HAS_E2_FAN_TACHO, case 2:) - TERN_(HAS_E3_FAN_TACHO, case 3:) - TERN_(HAS_E4_FAN_TACHO, case 4:) - TERN_(HAS_E5_FAN_TACHO, case 5:) - TERN_(HAS_E6_FAN_TACHO, case 6:) - TERN_(HAS_E7_FAN_TACHO, case 7:) + #define _EN_PRINT_FAN_CASE(N) TERN_(HAS_E##N##_FAN_TACHO, case N:) + REPEAT(8, _EN_PRINT_FAN_CASE) SERIAL_ECHOPGM("E", f); if (s == 0) SERIAL_ECHOPGM(":", 60 * rps[f], " RPM "); diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 31b877b642..821bb2df48 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -133,34 +133,9 @@ Endstops::endstop_mask_t Endstops::live_state = 0; void Endstops::init() { #define _INIT_ENDSTOP(T,A,N) TERN(ENDSTOPPULLUP_##A##T, SET_INPUT_PULLUP, TERN(ENDSTOPPULLDOWN_##A##T, SET_INPUT_PULLDOWN, SET_INPUT))(A##N##_##T##_PIN) - TERF(USE_X_MIN, _INIT_ENDSTOP)(MIN,X,); - TERF(USE_X_MAX, _INIT_ENDSTOP)(MAX,X,); - TERF(USE_X2_MIN, _INIT_ENDSTOP)(MIN,X,2); - TERF(USE_X2_MAX, _INIT_ENDSTOP)(MAX,X,2); - TERF(USE_Y_MIN, _INIT_ENDSTOP)(MIN,Y,); - TERF(USE_Y_MAX, _INIT_ENDSTOP)(MAX,Y,); - TERF(USE_Y2_MIN, _INIT_ENDSTOP)(MIN,Y,2); - TERF(USE_Y2_MAX, _INIT_ENDSTOP)(MAX,Y,2); - TERF(USE_Z_MIN, _INIT_ENDSTOP)(MIN,Z,); - TERF(USE_Z_MAX, _INIT_ENDSTOP)(MAX,Z,); - TERF(USE_Z2_MIN, _INIT_ENDSTOP)(MIN,Z,2); - TERF(USE_Z2_MAX, _INIT_ENDSTOP)(MAX,Z,2); - TERF(USE_Z3_MIN, _INIT_ENDSTOP)(MIN,Z,3); - TERF(USE_Z3_MAX, _INIT_ENDSTOP)(MAX,Z,3); - TERF(USE_Z4_MIN, _INIT_ENDSTOP)(MIN,Z,4); - TERF(USE_Z4_MAX, _INIT_ENDSTOP)(MAX,Z,4); - TERF(USE_I_MIN, _INIT_ENDSTOP)(MIN,I,); - TERF(USE_I_MAX, _INIT_ENDSTOP)(MAX,I,); - TERF(USE_J_MIN, _INIT_ENDSTOP)(MIN,J,); - TERF(USE_J_MAX, _INIT_ENDSTOP)(MAX,J,); - TERF(USE_K_MIN, _INIT_ENDSTOP)(MIN,K,); - TERF(USE_K_MAX, _INIT_ENDSTOP)(MAX,K,); - TERF(USE_U_MIN, _INIT_ENDSTOP)(MIN,U,); - TERF(USE_U_MAX, _INIT_ENDSTOP)(MAX,U,); - TERF(USE_V_MIN, _INIT_ENDSTOP)(MIN,V,); - TERF(USE_V_MAX, _INIT_ENDSTOP)(MAX,V,); - TERF(USE_W_MIN, _INIT_ENDSTOP)(MIN,W,); - TERF(USE_W_MAX, _INIT_ENDSTOP)(MAX,W,); + #define _INIT_ES_MINMAX(A,N) do{ TERF(USE_##A##N##_MIN, _INIT_ENDSTOP)(MIN,A,N); TERF(USE_##A##N##_MAX, _INIT_ENDSTOP)(MAX,A,N); }while(0); + #define INIT_AXIS_ENDSTOPS(S) do{ _INIT_ES_MINMAX(S, ); _INIT_ES_MINMAX(S,2); _INIT_ES_MINMAX(S,3); _INIT_ES_MINMAX(S,4); }while(0); + MAIN_AXIS_MAP(INIT_AXIS_ENDSTOPS); #if USE_CALIBRATION #if ENABLED(CALIBRATION_PIN_PULLUP) @@ -399,37 +374,15 @@ void Endstops::event_handler() { #endif void __O2 Endstops::report_states() { + TERN_(BLTOUCH, bltouch._set_SW_mode()); + SERIAL_ECHOLNPGM(STR_M119_REPORT); - #define ES_REPORT(S) print_es_state(READ_ENDSTOP(S##_PIN) == S##_ENDSTOP_HIT_STATE, F(STR_##S)) - TERF(USE_X_MIN, ES_REPORT)(X_MIN); - TERF(USE_X2_MIN, ES_REPORT)(X2_MIN); - TERF(USE_X_MAX, ES_REPORT)(X_MAX); - TERF(USE_X2_MAX, ES_REPORT)(X2_MAX); - TERF(USE_Y_MIN, ES_REPORT)(Y_MIN); - TERF(USE_Y2_MIN, ES_REPORT)(Y2_MIN); - TERF(USE_Y_MAX, ES_REPORT)(Y_MAX); - TERF(USE_Y2_MAX, ES_REPORT)(Y2_MAX); - TERF(USE_Z_MIN, ES_REPORT)(Z_MIN); - TERF(USE_Z2_MIN, ES_REPORT)(Z2_MIN); - TERF(USE_Z3_MIN, ES_REPORT)(Z3_MIN); - TERF(USE_Z4_MIN, ES_REPORT)(Z4_MIN); - TERF(USE_Z_MAX, ES_REPORT)(Z_MAX); - TERF(USE_Z2_MAX, ES_REPORT)(Z2_MAX); - TERF(USE_Z3_MAX, ES_REPORT)(Z3_MAX); - TERF(USE_Z4_MAX, ES_REPORT)(Z4_MAX); - TERF(USE_I_MIN, ES_REPORT)(I_MIN); - TERF(USE_I_MAX, ES_REPORT)(I_MAX); - TERF(USE_J_MIN, ES_REPORT)(J_MIN); - TERF(USE_J_MAX, ES_REPORT)(J_MAX); - TERF(USE_K_MIN, ES_REPORT)(K_MIN); - TERF(USE_K_MAX, ES_REPORT)(K_MAX); - TERF(USE_U_MIN, ES_REPORT)(U_MIN); - TERF(USE_U_MAX, ES_REPORT)(U_MAX); - TERF(USE_V_MIN, ES_REPORT)(V_MIN); - TERF(USE_V_MAX, ES_REPORT)(V_MAX); - TERF(USE_W_MIN, ES_REPORT)(W_MIN); - TERF(USE_W_MAX, ES_REPORT)(W_MAX); + + #define _ES_REPORT(S) print_es_state(READ_ENDSTOP(S##_PIN) == S##_ENDSTOP_HIT_STATE, F(STR_##S)) + #define ES_REPORT(S) TERF(USE_##S, _ES_REPORT)(S); + MAP(ES_REPORT, X_MIN, X2_MIN, X_MAX, X2_MAX, Y_MIN, Y2_MIN, Y_MAX, Y2_MAX, Z_MIN, Z2_MIN, Z3_MIN, Z4_MIN, Z_MAX, Z2_MAX, Z3_MAX, Z4_MAX); + MAP(ES_REPORT, I_MIN, I_MAX, J_MIN, J_MAX, K_MIN, K_MAX, U_MIN, U_MAX, V_MIN, V_MAX, W_MIN, W_MAX) TERF(PROBE_ACTIVATION_SWITCH, print_es_state)(probe_switch_activated(), F(STR_PROBE_EN)); @@ -605,18 +558,8 @@ void Endstops::update() { COPY_LIVE_STATE(Z_MAX, Z4_MAX); #endif - TERF(USE_I_MIN, UPDATE_LIVE_STATE)(I, MIN); - TERF(USE_I_MAX, UPDATE_LIVE_STATE)(I, MAX); - TERF(USE_J_MIN, UPDATE_LIVE_STATE)(J, MIN); - TERF(USE_J_MAX, UPDATE_LIVE_STATE)(J, MAX); - TERF(USE_K_MIN, UPDATE_LIVE_STATE)(K, MIN); - TERF(USE_K_MAX, UPDATE_LIVE_STATE)(K, MAX); - TERF(USE_U_MIN, UPDATE_LIVE_STATE)(U, MIN); - TERF(USE_U_MAX, UPDATE_LIVE_STATE)(U, MAX); - TERF(USE_V_MIN, UPDATE_LIVE_STATE)(V, MIN); - TERF(USE_V_MAX, UPDATE_LIVE_STATE)(V, MAX); - TERF(USE_W_MIN, UPDATE_LIVE_STATE)(W, MIN); - TERF(USE_W_MAX, UPDATE_LIVE_STATE)(W, MAX); + #define _LIVE_UPDATE(A) TERF(USE_##A##_MIN, UPDATE_LIVE_STATE)(A, MIN); TERF(USE_##A##_MAX, UPDATE_LIVE_STATE)(A, MAX); + SECONDARY_AXIS_MAP(_LIVE_UPDATE); #if ENDSTOP_NOISE_THRESHOLD @@ -1039,15 +982,19 @@ void Endstops::update() { } void Endstops::clear_endstop_state() { - TERN_(X_SPI_SENSORLESS, CBI(live_state, X_ENDSTOP)); + + #define _ES_CLEAR(S) CBI(live_state, S##_ENDSTOP); + #define ES_CLEAR(S) TERN_(S##_SPI_SENSORLESS, CBI(live_state, S##_ENDSTOP)); + + ES_CLEAR(X); #if ALL(X_SPI_SENSORLESS, X_DUAL_ENDSTOPS) CBI(live_state, X2_ENDSTOP); #endif - TERN_(Y_SPI_SENSORLESS, CBI(live_state, Y_ENDSTOP)); + ES_CLEAR(Y); #if ALL(Y_SPI_SENSORLESS, Y_DUAL_ENDSTOPS) CBI(live_state, Y2_ENDSTOP); #endif - TERN_(Z_SPI_SENSORLESS, CBI(live_state, Z_ENDSTOP)); + ES_CLEAR(Z); #if ALL(Z_SPI_SENSORLESS, Z_MULTI_ENDSTOPS) CBI(live_state, Z2_ENDSTOP); #if NUM_Z_STEPPERS >= 3 @@ -1057,12 +1004,7 @@ void Endstops::update() { #endif #endif #endif - 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)); + SECONDARY_AXIS_MAP(ES_CLEAR); } #endif // SPI_ENDSTOPS @@ -1086,73 +1028,22 @@ void Endstops::update() { static uint8_t local_LED_status = 0; uint16_t live_state_local = 0; - #define ES_GET_STATE(S) if (READ_ENDSTOP(S##_PIN)) SBI(live_state_local, S) - TERF(USE_X_MIN, ES_GET_STATE)(X_MIN); - TERF(USE_X_MAX, ES_GET_STATE)(X_MAX); - TERF(USE_Y_MIN, ES_GET_STATE)(Y_MIN); - TERF(USE_Y_MAX, ES_GET_STATE)(Y_MAX); - TERF(USE_Z_MIN, ES_GET_STATE)(Z_MIN); - TERF(USE_Z_MAX, ES_GET_STATE)(Z_MAX); - TERF(USE_Z_MIN_PROBE, ES_GET_STATE)(Z_MIN_PROBE); - TERF(USE_CALIBRATION, ES_GET_STATE)(CALIBRATION); - TERF(USE_X2_MIN, ES_GET_STATE)(X2_MIN); - TERF(USE_X2_MAX, ES_GET_STATE)(X2_MAX); - TERF(USE_Y2_MIN, ES_GET_STATE)(Y2_MIN); - TERF(USE_Y2_MAX, ES_GET_STATE)(Y2_MAX); - TERF(USE_Z2_MIN, ES_GET_STATE)(Z2_MIN); - TERF(USE_Z2_MAX, ES_GET_STATE)(Z2_MAX); - TERF(USE_Z3_MIN, ES_GET_STATE)(Z3_MIN); - TERF(USE_Z3_MAX, ES_GET_STATE)(Z3_MAX); - TERF(USE_Z4_MIN, ES_GET_STATE)(Z4_MIN); - TERF(USE_Z4_MAX, ES_GET_STATE)(Z4_MAX); - TERF(USE_I_MAX, ES_GET_STATE)(I_MAX); - TERF(USE_I_MIN, ES_GET_STATE)(I_MIN); - TERF(USE_J_MAX, ES_GET_STATE)(J_MAX); - TERF(USE_J_MIN, ES_GET_STATE)(J_MIN); - TERF(USE_K_MAX, ES_GET_STATE)(K_MAX); - TERF(USE_K_MIN, ES_GET_STATE)(K_MIN); - TERF(USE_U_MAX, ES_GET_STATE)(U_MAX); - TERF(USE_U_MIN, ES_GET_STATE)(U_MIN); - TERF(USE_V_MAX, ES_GET_STATE)(V_MAX); - TERF(USE_V_MIN, ES_GET_STATE)(V_MIN); - TERF(USE_W_MAX, ES_GET_STATE)(W_MAX); - TERF(USE_W_MIN, ES_GET_STATE)(W_MIN); + #define _ES_GET_STATE(S) if (READ_ENDSTOP(S##_PIN)) SBI(live_state_local, S); + #define ES_GET_STATE(S) TERF(USE_##S, _ES_GET_STATE)(S) + MAP(ES_GET_STATE, X_MIN, X_MAX, Y_MIN, Y_MAX, Z_MIN, Z_MAX); + MAP(ES_GET_STATE, Z_MIN_PROBE, CALIBRATION); + MAP(ES_GET_STATE, X2_MIN, X2_MAX, Y2_MIN, Y2_MAX, Z2_MIN, Z2_MAX, Z3_MIN, Z3_MAX, Z4_MIN, Z4_MAX) + MAP(ES_GET_STATE, I_MIN, I_MAX, J_MIN, J_MAX, K_MIN, K_MAX, U_MIN, U_MAX, V_MIN, V_MAX, W_MIN, W_MAX); const 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)) + #define _ES_REPORT_CHANGE(S) SERIAL_ECHO(F(" " STRINGIFY(S) ":"), TEST(live_state_local, S)); + #define ES_REPORT_CHANGE(S) TERF(USE_##S, _ES_REPORT_CHANGE)(S) if (endstop_change) { - TERF(USE_X_MIN, ES_REPORT_CHANGE)(X_MIN); - TERF(USE_X_MAX, ES_REPORT_CHANGE)(X_MAX); - TERF(USE_Y_MIN, ES_REPORT_CHANGE)(Y_MIN); - TERF(USE_Y_MAX, ES_REPORT_CHANGE)(Y_MAX); - TERF(USE_Z_MIN, ES_REPORT_CHANGE)(Z_MIN); - TERF(USE_Z_MAX, ES_REPORT_CHANGE)(Z_MAX); - TERF(USE_Z_MIN_PROBE, ES_REPORT_CHANGE)(Z_MIN_PROBE); - TERF(USE_CALIBRATION, ES_REPORT_CHANGE)(CALIBRATION); - TERF(USE_X2_MIN, ES_REPORT_CHANGE)(X2_MIN); - TERF(USE_X2_MAX, ES_REPORT_CHANGE)(X2_MAX); - TERF(USE_Y2_MIN, ES_REPORT_CHANGE)(Y2_MIN); - TERF(USE_Y2_MAX, ES_REPORT_CHANGE)(Y2_MAX); - TERF(USE_Z2_MIN, ES_REPORT_CHANGE)(Z2_MIN); - TERF(USE_Z2_MAX, ES_REPORT_CHANGE)(Z2_MAX); - TERF(USE_Z3_MIN, ES_REPORT_CHANGE)(Z3_MIN); - TERF(USE_Z3_MAX, ES_REPORT_CHANGE)(Z3_MAX); - TERF(USE_Z4_MIN, ES_REPORT_CHANGE)(Z4_MIN); - TERF(USE_Z4_MAX, ES_REPORT_CHANGE)(Z4_MAX); - TERF(USE_I_MIN, ES_REPORT_CHANGE)(I_MIN); - TERF(USE_I_MAX, ES_REPORT_CHANGE)(I_MAX); - TERF(USE_J_MIN, ES_REPORT_CHANGE)(J_MIN); - TERF(USE_J_MAX, ES_REPORT_CHANGE)(J_MAX); - TERF(USE_K_MIN, ES_REPORT_CHANGE)(K_MIN); - TERF(USE_K_MAX, ES_REPORT_CHANGE)(K_MAX); - TERF(USE_U_MIN, ES_REPORT_CHANGE)(U_MIN); - TERF(USE_U_MAX, ES_REPORT_CHANGE)(U_MAX); - TERF(USE_V_MIN, ES_REPORT_CHANGE)(V_MIN); - TERF(USE_V_MAX, ES_REPORT_CHANGE)(V_MAX); - TERF(USE_W_MIN, ES_REPORT_CHANGE)(W_MIN); - TERF(USE_W_MAX, ES_REPORT_CHANGE)(W_MAX); - + MAP(ES_REPORT_CHANGE, X_MIN, X_MAX, Y_MIN, Y_MAX, Z_MIN, Z_MAX, + , Z_MIN_PROBE, CALIBRATION, + , X2_MIN, X2_MAX, Y2_MIN, Y2_MAX, Z2_MIN, Z2_MAX, Z3_MIN, Z3_MAX, Z4_MIN, Z4_MAX, + , I_MIN, I_MAX, J_MIN, J_MAX, K_MIN, K_MAX, U_MIN, U_MAX, V_MIN, V_MAX, W_MIN, W_MAX); SERIAL_ECHOLNPGM("\n"); hal.set_pwm_duty(pin_t(LED_PIN), local_LED_status); local_LED_status ^= 255; diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 00ba63c966..cb1926c318 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2041,15 +2041,8 @@ void Stepper::pulse_phase_isr() { const uint32_t advance_divisor_cached = advance_divisor; // Determine if pulses are needed - TERF(HAS_X_STEP, PULSE_PREP)(X); - TERF(HAS_Y_STEP, PULSE_PREP)(Y); - TERF(HAS_Z_STEP, PULSE_PREP)(Z); - TERF(HAS_I_STEP, PULSE_PREP)(I); - TERF(HAS_J_STEP, PULSE_PREP)(J); - TERF(HAS_K_STEP, PULSE_PREP)(K); - TERF(HAS_U_STEP, PULSE_PREP)(U); - TERF(HAS_V_STEP, PULSE_PREP)(V); - TERF(HAS_W_STEP, PULSE_PREP)(W); + #define _PULSE_PREP(A) TERF(HAS_##A##_STEP, PULSE_PREP)(A); + MAIN_AXIS_MAP(_PULSE_PREP); #if ANY(HAS_E0_STEP, MIXING_EXTRUDER) PULSE_PREP(E); @@ -2099,15 +2092,8 @@ void Stepper::pulse_phase_isr() { #endif // Pulse start - TERF(HAS_X_STEP, PULSE_START)(X); - TERF(HAS_Y_STEP, PULSE_START)(Y); - TERF(HAS_Z_STEP, PULSE_START)(Z); - TERF(HAS_I_STEP, PULSE_START)(I); - TERF(HAS_J_STEP, PULSE_START)(J); - TERF(HAS_K_STEP, PULSE_START)(K); - TERF(HAS_U_STEP, PULSE_START)(U); - TERF(HAS_V_STEP, PULSE_START)(V); - TERF(HAS_W_STEP, PULSE_START)(W); + #define _PULSE_START(A) TERF(HAS_##A##_STEP, PULSE_START)(A); + MAIN_AXIS_MAP(_PULSE_START); #if ENABLED(MIXING_EXTRUDER) if (step_needed.e) { @@ -2127,15 +2113,8 @@ void Stepper::pulse_phase_isr() { #endif // Pulse stop - TERF(HAS_X_STEP, PULSE_STOP)(X); - TERF(HAS_Y_STEP, PULSE_STOP)(Y); - TERF(HAS_Z_STEP, PULSE_STOP)(Z); - TERF(HAS_I_STEP, PULSE_STOP)(I); - TERF(HAS_J_STEP, PULSE_STOP)(J); - TERF(HAS_K_STEP, PULSE_STOP)(K); - TERF(HAS_U_STEP, PULSE_STOP)(U); - TERF(HAS_V_STEP, PULSE_STOP)(V); - TERF(HAS_W_STEP, PULSE_STOP)(W); + #define _PULSE_STOP(A) TERF(HAS_##A##_STEP, PULSE_STOP)(A); + MAIN_AXIS_MAP(_PULSE_STOP); #if ENABLED(MIXING_EXTRUDER) if (step_needed.e) E_STEP_WRITE(mixer.get_stepper(), !STEP_STATE_E); @@ -3231,53 +3210,21 @@ void Stepper::init() { TERN_(HAS_MICROSTEPS, microstep_init()); // Init Dir Pins - TERN_(HAS_X_DIR, X_DIR_INIT()); - TERN_(HAS_X2_DIR, X2_DIR_INIT()); - TERN_(HAS_Y_DIR, Y_DIR_INIT()); - TERN_(HAS_Y2_DIR, Y2_DIR_INIT()); - TERN_(HAS_Z_DIR, Z_DIR_INIT()); - TERN_(HAS_Z2_DIR, Z2_DIR_INIT()); - TERN_(HAS_Z3_DIR, Z3_DIR_INIT()); - TERN_(HAS_Z4_DIR, Z4_DIR_INIT()); - TERN_(HAS_I_DIR, I_DIR_INIT()); - TERN_(HAS_J_DIR, J_DIR_INIT()); - TERN_(HAS_K_DIR, K_DIR_INIT()); - TERN_(HAS_U_DIR, U_DIR_INIT()); - TERN_(HAS_V_DIR, V_DIR_INIT()); - TERN_(HAS_W_DIR, W_DIR_INIT()); - TERN_(HAS_E0_DIR, E0_DIR_INIT()); - TERN_(HAS_E1_DIR, E1_DIR_INIT()); - TERN_(HAS_E2_DIR, E2_DIR_INIT()); - TERN_(HAS_E3_DIR, E3_DIR_INIT()); - TERN_(HAS_E4_DIR, E4_DIR_INIT()); - TERN_(HAS_E5_DIR, E5_DIR_INIT()); - TERN_(HAS_E6_DIR, E6_DIR_INIT()); - TERN_(HAS_E7_DIR, E7_DIR_INIT()); + #define _INIT_DIR(A) TERN_(HAS_##A##_DIR, A##_DIR_INIT()); + #define _EN_INIT_DIR(N) _INIT_DIR(E##N) + MAIN_AXIS_MAP(_INIT_DIR); + MAP(_INIT_DIR, X2, Y2, Z2, Z3, Z4); + REPEAT(8, _EN_INIT_DIR); // Init Enable Pins - Steppers default to disabled. - #define _INIT_CONFIG_ENABLE(A) do{ A##_ENABLE_INIT(); if (A##_ENABLE_INIT_STATE) A##_ENABLE_WRITE(HIGH); }while(0) - TERN_(HAS_X_ENABLE, _INIT_CONFIG_ENABLE(X)); - TERN_(HAS_X2_ENABLE, _INIT_CONFIG_ENABLE(X2)); - TERN_(HAS_Y_ENABLE, _INIT_CONFIG_ENABLE(Y)); - TERN_(HAS_Y2_ENABLE, _INIT_CONFIG_ENABLE(Y2)); - TERN_(HAS_Z_ENABLE, _INIT_CONFIG_ENABLE(Z)); - TERN_(HAS_Z2_ENABLE, _INIT_CONFIG_ENABLE(Z2)); - TERN_(HAS_Z3_ENABLE, _INIT_CONFIG_ENABLE(Z3)); - TERN_(HAS_Z4_ENABLE, _INIT_CONFIG_ENABLE(Z4)); - TERN_(HAS_I_ENABLE, _INIT_CONFIG_ENABLE(I)); - TERN_(HAS_J_ENABLE, _INIT_CONFIG_ENABLE(J)); - TERN_(HAS_K_ENABLE, _INIT_CONFIG_ENABLE(K)); - TERN_(HAS_U_ENABLE, _INIT_CONFIG_ENABLE(U)); - TERN_(HAS_V_ENABLE, _INIT_CONFIG_ENABLE(V)); - TERN_(HAS_W_ENABLE, _INIT_CONFIG_ENABLE(W)); - TERN_(HAS_E0_ENABLE, _INIT_CONFIG_ENABLE(E0)); - TERN_(HAS_E1_ENABLE, _INIT_CONFIG_ENABLE(E1)); - TERN_(HAS_E2_ENABLE, _INIT_CONFIG_ENABLE(E2)); - TERN_(HAS_E3_ENABLE, _INIT_CONFIG_ENABLE(E3)); - TERN_(HAS_E4_ENABLE, _INIT_CONFIG_ENABLE(E4)); - TERN_(HAS_E5_ENABLE, _INIT_CONFIG_ENABLE(E5)); - TERN_(HAS_E6_ENABLE, _INIT_CONFIG_ENABLE(E6)); - TERN_(HAS_E7_ENABLE, _INIT_CONFIG_ENABLE(E7)); + #define __INIT_ENABLE(A) do{ A##_ENABLE_INIT(); if (A##_ENABLE_INIT_STATE) A##_ENABLE_WRITE(HIGH); }while(0) + + #define _INIT_ENABLE(A) TERF(HAS_##A##_ENABLE, __INIT_ENABLE)(A); + MAIN_AXIS_MAP(_INIT_ENABLE); + MAP(_INIT_ENABLE, X2, Y2, Z2, Z3, Z4); + + #define _EN_INIT_ENABLE(N) TERN_(HAS_E##N##_ENABLE, __INIT_ENABLE(E##N)); + REPEAT(8, _EN_INIT_ENABLE); #define _STEP_INIT(AXIS) AXIS ##_STEP_INIT() #define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW) @@ -3322,21 +3269,12 @@ void Stepper::init() { #endif AXIS_INIT(Z, Z); #endif - TERN_(HAS_I_STEP, AXIS_INIT(I, I)); - TERN_(HAS_J_STEP, AXIS_INIT(J, J)); - TERN_(HAS_K_STEP, AXIS_INIT(K, K)); - TERN_(HAS_U_STEP, AXIS_INIT(U, U)); - TERN_(HAS_V_STEP, AXIS_INIT(V, V)); - TERN_(HAS_W_STEP, AXIS_INIT(W, W)); - TERN_(HAS_E0_STEP, E_AXIS_INIT(0)); - TERN_(HAS_E1_STEP, E_AXIS_INIT(1)); - TERN_(HAS_E2_STEP, E_AXIS_INIT(2)); - TERN_(HAS_E3_STEP, E_AXIS_INIT(3)); - TERN_(HAS_E4_STEP, E_AXIS_INIT(4)); - TERN_(HAS_E5_STEP, E_AXIS_INIT(5)); - TERN_(HAS_E6_STEP, E_AXIS_INIT(6)); - TERN_(HAS_E7_STEP, E_AXIS_INIT(7)); + #define _AXIS_INIT(A) TERF(HAS_##A##_STEP, AXIS_INIT)(A, A); + SECONDARY_AXIS_MAP(_AXIS_INIT); + + #define _EN_AXIS_INIT(N) TERF(HAS_E##N##_STEP, E_AXIS_INIT)(N); + REPEAT(8, _EN_AXIS_INIT); #if DISABLED(I2S_STEPPER_STREAM) HAL_timer_start(MF_TIMER_STEP, 122); // Init Stepper ISR to 122 Hz for quick starting diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index d56937d513..6bda47b573 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3090,14 +3090,8 @@ void Temperature::init() { OUT_WRITE(HEATER_0_PIN, ENABLED(HEATER_0_INVERTING)); #endif #endif - - TERF(HAS_HEATER_1, OUT_WRITE)(HEATER_1_PIN, ENABLED(HEATER_1_INVERTING)); - TERF(HAS_HEATER_2, OUT_WRITE)(HEATER_2_PIN, ENABLED(HEATER_2_INVERTING)); - TERF(HAS_HEATER_3, OUT_WRITE)(HEATER_3_PIN, ENABLED(HEATER_3_INVERTING)); - TERF(HAS_HEATER_4, OUT_WRITE)(HEATER_4_PIN, ENABLED(HEATER_4_INVERTING)); - TERF(HAS_HEATER_5, OUT_WRITE)(HEATER_5_PIN, ENABLED(HEATER_5_INVERTING)); - TERF(HAS_HEATER_6, OUT_WRITE)(HEATER_6_PIN, ENABLED(HEATER_6_INVERTING)); - TERF(HAS_HEATER_7, OUT_WRITE)(HEATER_7_PIN, ENABLED(HEATER_7_INVERTING)); + #define _INIT_HEATER(N) TERF(HAS_HEATER_##N, OUT_WRITE)(HEATER_##N##_PIN, ENABLED(HEATER_##N##_INVERTING)); + REPEAT_1(7, _INIT_HEATER); #if HAS_HEATED_BED #if ENABLED(PELTIER_BED) @@ -3119,14 +3113,9 @@ void Temperature::init() { OUT_WRITE(COOLER_PIN, ENABLED(COOLER_INVERTING)); #endif - TERF(HAS_FAN0, INIT_FAN_PIN)(FAN0_PIN); - TERF(HAS_FAN1, INIT_FAN_PIN)(FAN1_PIN); - TERF(HAS_FAN2, INIT_FAN_PIN)(FAN2_PIN); - TERF(HAS_FAN3, INIT_FAN_PIN)(FAN3_PIN); - TERF(HAS_FAN4, INIT_FAN_PIN)(FAN4_PIN); - TERF(HAS_FAN5, INIT_FAN_PIN)(FAN5_PIN); - TERF(HAS_FAN6, INIT_FAN_PIN)(FAN6_PIN); - TERF(HAS_FAN7, INIT_FAN_PIN)(FAN7_PIN); + #define _INIT_FAN(N) TERF(HAS_FAN##N, INIT_FAN_PIN)(FAN##N##_PIN); + REPEAT(FAN_COUNT, _INIT_FAN); + TERF(USE_CONTROLLER_FAN, INIT_FAN_PIN)(CONTROLLER_FAN_PIN); TERN_(HAS_MAXTC_SW_SPI, max_tc_spi.init()); @@ -4043,6 +4032,10 @@ void Temperature::isr() { #define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ ENABLED(FAN_INVERTING)) + #if ENABLED(FAN_SOFT_PWM) + #define _FAN_LOW(N) if (TERN0(HAS_FAN##N, soft_pwm_count_fan[N] <= pwm_count_tmp)) { TERF(HAS_FAN##N, WRITE_FAN)(N, LOW); }; + #endif + #if DISABLED(SLOW_PWM_HEATERS) #if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_HEATED_CHAMBER, HAS_COOLER, FAN_SOFT_PWM) @@ -4079,20 +4072,13 @@ void Temperature::isr() { WRITE(CONTROLLER_FAN_PIN, soft_pwm_controllerfan.add(pwm_mask, controllerFan.soft_pwm_speed)); #endif - #define _FAN_PWM(N) do{ \ + #define __FAN_PWM(N) do{ \ uint8_t &spcf = soft_pwm_count_fan[N]; \ spcf = (spcf & pwm_mask) + (soft_pwm_amount_fan[N] >> 1); \ WRITE_FAN(N, spcf > pwm_mask ? HIGH : LOW); \ }while(0) - - TERF(HAS_FAN0, _FAN_PWM)(0); - TERF(HAS_FAN1, _FAN_PWM)(1); - TERF(HAS_FAN2, _FAN_PWM)(2); - TERF(HAS_FAN3, _FAN_PWM)(3); - TERF(HAS_FAN4, _FAN_PWM)(4); - TERF(HAS_FAN5, _FAN_PWM)(5); - TERF(HAS_FAN6, _FAN_PWM)(6); - TERF(HAS_FAN7, _FAN_PWM)(7); + #define _FAN_PWM(N) TERF(HAS_FAN##N, __FAN_PWM)(N); + REPEAT(FAN_COUNT, _FAN_PWM); #endif } else { @@ -4107,30 +4093,7 @@ void Temperature::isr() { TERF(HAS_COOLER, _PWM_LOW)(COOLER, soft_pwm_cooler); #if ENABLED(FAN_SOFT_PWM) - #if HAS_FAN0 - if (soft_pwm_count_fan[0] <= pwm_count_tmp) WRITE_FAN(0, LOW); - #endif - #if HAS_FAN1 - if (soft_pwm_count_fan[1] <= pwm_count_tmp) WRITE_FAN(1, LOW); - #endif - #if HAS_FAN2 - if (soft_pwm_count_fan[2] <= pwm_count_tmp) WRITE_FAN(2, LOW); - #endif - #if HAS_FAN3 - if (soft_pwm_count_fan[3] <= pwm_count_tmp) WRITE_FAN(3, LOW); - #endif - #if HAS_FAN4 - if (soft_pwm_count_fan[4] <= pwm_count_tmp) WRITE_FAN(4, LOW); - #endif - #if HAS_FAN5 - if (soft_pwm_count_fan[5] <= pwm_count_tmp) WRITE_FAN(5, LOW); - #endif - #if HAS_FAN6 - if (soft_pwm_count_fan[6] <= pwm_count_tmp) WRITE_FAN(6, LOW); - #endif - #if HAS_FAN7 - if (soft_pwm_count_fan[7] <= pwm_count_tmp) WRITE_FAN(7, LOW); - #endif + REPEAT(FAN_COUNT, _FAN_LOW); #if ENABLED(USE_CONTROLLER_FAN) if (soft_pwm_controllerfan.count <= pwm_count_tmp) WRITE(CONTROLLER_FAN_PIN, LOW); #endif @@ -4185,43 +4148,14 @@ void Temperature::isr() { #if ENABLED(FAN_SOFT_PWM) if (pwm_count_tmp >= 127) { pwm_count_tmp = 0; - #define _PWM_FAN(N) do{ \ + #define __PWM_FAN(N) do{ \ soft_pwm_count_fan[N] = soft_pwm_amount_fan[N] >> 1; \ WRITE_FAN(N, soft_pwm_count_fan[N] > 0 ? HIGH : LOW); \ }while(0) - TERF(HAS_FAN0, _PWM_FAN)(0); - TERF(HAS_FAN1, _PWM_FAN)(1); - TERF(HAS_FAN2, _PWM_FAN)(2); - TERF(HAS_FAN3, _FAN_PWM)(3); - TERF(HAS_FAN4, _FAN_PWM)(4); - TERF(HAS_FAN5, _FAN_PWM)(5); - TERF(HAS_FAN6, _FAN_PWM)(6); - TERF(HAS_FAN7, _FAN_PWM)(7); + #define _PWM_FAN(N) TERF(HAS_FAN##N, __PWM_FAN)(N); + REPEAT(FAN_COUNT, _PWM_FAN); } - #if HAS_FAN0 - if (soft_pwm_count_fan[0] <= pwm_count_tmp) WRITE_FAN(0, LOW); - #endif - #if HAS_FAN1 - if (soft_pwm_count_fan[1] <= pwm_count_tmp) WRITE_FAN(1, LOW); - #endif - #if HAS_FAN2 - if (soft_pwm_count_fan[2] <= pwm_count_tmp) WRITE_FAN(2, LOW); - #endif - #if HAS_FAN3 - if (soft_pwm_count_fan[3] <= pwm_count_tmp) WRITE_FAN(3, LOW); - #endif - #if HAS_FAN4 - if (soft_pwm_count_fan[4] <= pwm_count_tmp) WRITE_FAN(4, LOW); - #endif - #if HAS_FAN5 - if (soft_pwm_count_fan[5] <= pwm_count_tmp) WRITE_FAN(5, LOW); - #endif - #if HAS_FAN6 - if (soft_pwm_count_fan[6] <= pwm_count_tmp) WRITE_FAN(6, LOW); - #endif - #if HAS_FAN7 - if (soft_pwm_count_fan[7] <= pwm_count_tmp) WRITE_FAN(7, LOW); - #endif + REPEAT(FAN_COUNT, _FAN_LOW); #endif // FAN_SOFT_PWM // SOFT_PWM_SCALE to frequency: From e99d801e6be64f686a5af69bf3066fbcf809e8fc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 24 Nov 2025 15:16:03 -0600 Subject: [PATCH 38/39] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20a=20"Marlin"=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/HAL.cpp | 3 +- Marlin/src/HAL/AVR/HAL.h | 2 +- Marlin/src/HAL/AVR/MarlinSerial.cpp | 1 - Marlin/src/HAL/DUE/HAL.cpp | 1 - Marlin/src/HAL/DUE/HAL.h | 2 +- Marlin/src/HAL/DUE/MarlinSerial.cpp | 1 - Marlin/src/HAL/ESP32/HAL.h | 2 +- Marlin/src/HAL/HC32/MarlinHAL.h | 2 +- Marlin/src/HAL/LINUX/HAL.h | 2 +- Marlin/src/HAL/LPC1768/HAL.h | 2 +- Marlin/src/HAL/LPC1768/Servo.h | 2 + Marlin/src/HAL/NATIVE_SIM/HAL.h | 2 +- Marlin/src/HAL/RP2040/HAL.h | 2 +- Marlin/src/HAL/SAMD21/HAL.h | 2 +- Marlin/src/HAL/SAMD51/HAL.h | 2 +- Marlin/src/HAL/STM32/HAL.h | 2 +- Marlin/src/HAL/STM32F1/HAL.h | 2 +- Marlin/src/HAL/STM32F1/Servo.cpp | 2 - Marlin/src/HAL/TEENSY31_32/HAL.h | 2 +- Marlin/src/HAL/TEENSY35_36/HAL.h | 2 +- Marlin/src/HAL/TEENSY40_41/HAL.h | 2 +- Marlin/src/MarlinCore.cpp | 107 ++++++++++------- Marlin/src/MarlinCore.h | 111 ++++++++++++------ Marlin/src/core/language.h | 7 ++ Marlin/src/core/utility.cpp | 12 +- Marlin/src/core/utility.h | 2 - Marlin/src/feature/babystep.cpp | 1 - Marlin/src/feature/bedlevel/bdl/bdl.cpp | 5 +- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 3 +- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 15 ++- .../src/feature/bedlevel/ubl/ubl_motion.cpp | 1 - Marlin/src/feature/dac/dac_dac084s085.cpp | 1 - Marlin/src/feature/direct_stepping.cpp | 2 +- Marlin/src/feature/e_parser.cpp | 5 +- Marlin/src/feature/easythreed_ui.cpp | 10 +- Marlin/src/feature/encoder_i2c.cpp | 2 +- Marlin/src/feature/fancheck.cpp | 8 +- Marlin/src/feature/fancheck.h | 7 +- Marlin/src/feature/host_actions.cpp | 6 +- Marlin/src/feature/hotend_idle.cpp | 2 +- Marlin/src/feature/max7219.h | 15 ++- Marlin/src/feature/mmu/mmu.cpp | 1 - Marlin/src/feature/mmu/mmu2.cpp | 9 +- Marlin/src/feature/mmu3/mmu3.cpp | 4 +- Marlin/src/feature/mmu3/mmu3_marlin1.cpp | 10 +- Marlin/src/feature/mmu3/mmu3_reporting.cpp | 2 +- Marlin/src/feature/mmu3/ultralcd.cpp | 2 +- Marlin/src/feature/pause.cpp | 38 +++--- Marlin/src/feature/power.cpp | 4 +- Marlin/src/feature/powerloss.cpp | 4 +- Marlin/src/feature/runout.h | 3 +- Marlin/src/feature/spindle_laser.cpp | 2 +- Marlin/src/feature/tmc_util.cpp | 3 +- Marlin/src/gcode/bedlevel/G26.cpp | 1 - Marlin/src/gcode/bedlevel/G42.cpp | 1 - Marlin/src/gcode/bedlevel/abl/G29.cpp | 4 +- Marlin/src/gcode/calibrate/G76_M871.cpp | 2 +- Marlin/src/gcode/calibrate/M100.cpp | 14 +-- Marlin/src/gcode/config/M43.cpp | 11 +- Marlin/src/gcode/config/M550.cpp | 11 +- Marlin/src/gcode/control/M108_M112_M410.cpp | 6 +- Marlin/src/gcode/control/M226.cpp | 5 +- Marlin/src/gcode/control/M42.cpp | 4 +- Marlin/src/gcode/control/M80_M81.cpp | 4 +- Marlin/src/gcode/control/M999.cpp | 4 +- Marlin/src/gcode/feature/camera/M240.cpp | 6 +- .../src/gcode/feature/filwidth/M404-M407.cpp | 1 - .../src/gcode/feature/power_monitor/M430.cpp | 1 - Marlin/src/gcode/gcode.cpp | 4 +- Marlin/src/gcode/gcode_d.cpp | 2 +- Marlin/src/gcode/geometry/M206_M428.cpp | 1 - Marlin/src/gcode/host/M16.cpp | 4 +- Marlin/src/gcode/host/M876.cpp | 1 - Marlin/src/gcode/lcd/M0_M1.cpp | 3 +- Marlin/src/gcode/lcd/M414.cpp | 1 - Marlin/src/gcode/motion/G2_G3.cpp | 2 +- Marlin/src/gcode/motion/G5.cpp | 1 - Marlin/src/gcode/probe/G38.cpp | 9 +- Marlin/src/gcode/probe/M102.cpp | 3 +- Marlin/src/gcode/queue.cpp | 10 +- Marlin/src/gcode/scara/M360-M364.cpp | 3 +- Marlin/src/gcode/sd/M1001.cpp | 3 +- Marlin/src/gcode/sd/M24_M25.cpp | 4 +- Marlin/src/gcode/sd/M32.cpp | 4 +- Marlin/src/gcode/stats/M75-M78.cpp | 2 +- Marlin/src/inc/MarlinConfig.h | 1 + Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 8 +- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 6 +- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 8 +- .../lcd/dogm/status_screen_lite_ST7920.cpp | 8 +- Marlin/src/lcd/e3v2/common/encoder.cpp | 4 +- Marlin/src/lcd/e3v2/creality/dwin.cpp | 14 +-- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 10 +- .../lcd/e3v2/marlinui/ui_status_480x272.cpp | 2 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 25 ++-- Marlin/src/lcd/e3v2/proui/dwin_popup.cpp | 2 +- Marlin/src/lcd/e3v2/proui/gcode_preview.cpp | 2 +- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 2 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 2 +- .../extui/dgus/fysetc/DGUSScreenHandler.cpp | 2 +- .../extui/dgus/hiprecy/DGUSScreenHandler.cpp | 2 +- .../lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 7 +- .../extui/dgus/origin/DGUSScreenHandler.cpp | 2 +- .../extui/dgus_reloaded/DGUSScreenHandler.cpp | 4 +- .../ftdi_eve_touch_ui/ftdi_eve_lib/compat.h | 2 + .../lcd/extui/ia_creality/ia_creality_rts.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp | 4 +- Marlin/src/lcd/extui/mks_ui/draw_printing.cpp | 6 +- Marlin/src/lcd/extui/mks_ui/draw_set.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/draw_ui.cpp | 4 +- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 9 +- Marlin/src/lcd/extui/nextion/nextion_tft.cpp | 4 +- Marlin/src/lcd/extui/ui_api.cpp | 10 +- Marlin/src/lcd/marlinui.cpp | 17 +-- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_tramming.cpp | 2 +- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_delta_calibrate.cpp | 2 +- Marlin/src/lcd/menu/menu_filament.cpp | 10 +- Marlin/src/lcd/menu/menu_info.cpp | 2 +- Marlin/src/lcd/menu/menu_item.h | 3 +- Marlin/src/lcd/menu/menu_language.cpp | 1 - Marlin/src/lcd/menu/menu_main.cpp | 4 +- Marlin/src/lcd/menu/menu_mmu2.cpp | 16 ++- Marlin/src/lcd/sovol_rts/sovol_rts.cpp | 9 +- Marlin/src/lcd/tft/touch.cpp | 9 +- Marlin/src/lcd/tft/ui_color_ui.cpp | 6 +- .../src/lcd/tft/ui_move_axis_screen_1024.cpp | 2 +- .../src/lcd/tft/ui_move_axis_screen_320.cpp | 2 +- .../src/lcd/tft/ui_move_axis_screen_480.cpp | 2 +- Marlin/src/lcd/utf8.cpp | 1 - Marlin/src/libs/nozzle.cpp | 1 - Marlin/src/module/delta.cpp | 1 - Marlin/src/module/endstops.cpp | 4 +- Marlin/src/module/motion.cpp | 8 +- Marlin/src/module/motion.h | 6 +- Marlin/src/module/planner.cpp | 6 +- Marlin/src/module/planner.h | 2 +- Marlin/src/module/planner_bezier.cpp | 3 +- Marlin/src/module/polargraph.cpp | 1 - Marlin/src/module/printcounter.cpp | 1 - Marlin/src/module/probe.cpp | 18 ++- Marlin/src/module/scara.cpp | 1 - Marlin/src/module/settings.cpp | 9 +- Marlin/src/module/stepper.cpp | 1 - Marlin/src/module/temperature.cpp | 111 +++++++++--------- Marlin/src/module/tool_change.cpp | 6 +- Marlin/src/pins/pinsDebug.h | 6 +- Marlin/src/pins/pinsDebug_list.h | 2 +- Marlin/src/sd/Sd2Card.cpp | 2 - Marlin/src/sd/SdBaseFile.cpp | 1 - Marlin/src/sd/SdVolume.cpp | 2 - Marlin/src/sd/cardreader.cpp | 12 +- docs/Queue.md | 6 +- 154 files changed, 501 insertions(+), 531 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.cpp b/Marlin/src/HAL/AVR/HAL.cpp index 97173c63f9..4fbab8941f 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -119,7 +119,6 @@ void MarlinHAL::reboot() { #if ENABLED(USE_WATCHDOG) #include - #include "../../MarlinCore.h" // Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s. void MarlinHAL::watchdog_init() { @@ -154,7 +153,7 @@ void MarlinHAL::reboot() { ISR(WDT_vect) { sei(); // With the interrupt driven serial we need to allow interrupts. SERIAL_ERROR_MSG(STR_WATCHDOG_FIRED); - minkill(); // interrupt-safe final kill and infinite loop + marlin.minkill(); // interrupt-safe final kill and infinite loop } #endif diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index e7a82a3b83..02c5d42beb 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -206,7 +206,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask() {} // Reset diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index d070731418..750776c4be 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -41,7 +41,6 @@ #if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)) #include "MarlinSerial.h" -#include "../../MarlinCore.h" #if ENABLED(DIRECT_STEPPING) #include "../../feature/direct_stepping.h" diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp index 9b3cf1a516..19a174259a 100644 --- a/Marlin/src/HAL/DUE/HAL.cpp +++ b/Marlin/src/HAL/DUE/HAL.cpp @@ -27,7 +27,6 @@ #ifdef ARDUINO_ARCH_SAM #include "../../inc/MarlinConfig.h" -#include "../../MarlinCore.h" #include #include "usb/usb_task.h" diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 54a977c2d8..f83668ca9d 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -132,7 +132,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask(); // Reset diff --git a/Marlin/src/HAL/DUE/MarlinSerial.cpp b/Marlin/src/HAL/DUE/MarlinSerial.cpp index 90efe55fc2..2e80b4c8d1 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerial.cpp @@ -31,7 +31,6 @@ #include "MarlinSerial.h" #include "InterruptVectors.h" -#include "../../MarlinCore.h" template typename MarlinSerial::ring_buffer_r MarlinSerial::rx_buffer = { 0, 0, { 0 } }; template typename MarlinSerial::ring_buffer_t MarlinSerial::tx_buffer = { 0 }; diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 36b8ea53fc..cd9e738be3 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -194,7 +194,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask(); // Reset diff --git a/Marlin/src/HAL/HC32/MarlinHAL.h b/Marlin/src/HAL/HC32/MarlinHAL.h index 86dc3c7e53..ba3ac4c731 100644 --- a/Marlin/src/HAL/HC32/MarlinHAL.h +++ b/Marlin/src/HAL/HC32/MarlinHAL.h @@ -67,7 +67,7 @@ public: static void delay_ms(const int ms); - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask(); // Reset diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index 68e0e1062c..66e4036fdc 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -126,7 +126,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask() {} // Reset diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 9a68cdf748..052d6637c8 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -160,7 +160,7 @@ public: static bool watchdog_timed_out() IF_DISABLED(USE_WATCHDOG, { return false; }); static void watchdog_clear_timeout_flag() IF_DISABLED(USE_WATCHDOG, {}); - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask(); // Reset diff --git a/Marlin/src/HAL/LPC1768/Servo.h b/Marlin/src/HAL/LPC1768/Servo.h index 221001c948..d7f0a2a555 100644 --- a/Marlin/src/HAL/LPC1768/Servo.h +++ b/Marlin/src/HAL/LPC1768/Servo.h @@ -49,6 +49,8 @@ #include +#include "../../MarlinCore.h" + class libServo: public Servo { public: void move(const int value) { diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index 661c502f22..b3b66d54d3 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -197,7 +197,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask(); // Reset diff --git a/Marlin/src/HAL/RP2040/HAL.h b/Marlin/src/HAL/RP2040/HAL.h index 206847053b..a1305bd135 100644 --- a/Marlin/src/HAL/RP2040/HAL.h +++ b/Marlin/src/HAL/RP2040/HAL.h @@ -144,7 +144,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask() { TERN_(HAS_SD_HOST_DRIVE, tuh_task()); } // Reset diff --git a/Marlin/src/HAL/SAMD21/HAL.h b/Marlin/src/HAL/SAMD21/HAL.h index e95f0e6f70..5545630ce3 100644 --- a/Marlin/src/HAL/SAMD21/HAL.h +++ b/Marlin/src/HAL/SAMD21/HAL.h @@ -144,7 +144,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask() {} // Reset diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 51fed64e35..65dcce966d 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -121,7 +121,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask() {} // Reset diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index a8ef51bcfc..8f9b56704c 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -157,7 +157,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask(); // Reset diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 68773bdf27..2c7321403f 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -187,7 +187,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask(); // Reset diff --git a/Marlin/src/HAL/STM32F1/Servo.cpp b/Marlin/src/HAL/STM32F1/Servo.cpp index 7aa8fe3d00..00caec287b 100644 --- a/Marlin/src/HAL/STM32F1/Servo.cpp +++ b/Marlin/src/HAL/STM32F1/Servo.cpp @@ -29,8 +29,6 @@ uint8_t ServoCount = 0; #include "Servo.h" -//#include "Servo.h" - #include #include #include diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 03610c65f8..b98ee9eb39 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -142,7 +142,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask() {} // Reset diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 0f229000d4..85d02cec8c 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -147,7 +147,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask() {} // Reset diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index f884db6684..fc75539e9b 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -160,7 +160,7 @@ public: static void delay_ms(const int ms) { delay(ms); } - // Tasks, called from idle() + // Tasks, called from marlin.idle() static void idletask() {} // Reset diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index b6a47ec744..c5ceb15943 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -160,10 +160,6 @@ #include "feature/spindle_laser.h" #endif -#if HAS_MEDIA - CardReader card; -#endif - #if ENABLED(DELTA) #include "module/delta.h" #elif ENABLED(POLARGRAPH) @@ -264,33 +260,51 @@ #include "feature/rs485.h" #endif +/** + * Spin in place here while keeping temperature processing alive + */ +void safe_delay(millis_t ms) { + while (ms > 50) { + ms -= 50; + delay(50); + thermalManager.task(); + } + delay(ms); + thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made +} + +// Singleton for Marlin global data and methods +Marlin marlin; + +// Marlin static data +#if ENABLED(CONFIGURABLE_MACHINE_NAME) + MString<64> Marlin::machine_name; +#endif + +// Global state of the firmware +MarlinState Marlin::state = MarlinState::MF_INITIALIZING; + +// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop +bool Marlin::wait_for_heatup = false; + #if !HAS_MEDIA CardReader card; // Stub instance with "no media" methods #endif PGMSTR(M112_KILL_STR, "M112 Shutdown"); -#if ENABLED(CONFIGURABLE_MACHINE_NAME) - MString<64> machine_name; -#endif - -MarlinState marlin_state = MarlinState::MF_INITIALIZING; - -// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop -bool wait_for_heatup = false; - // For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop #if HAS_RESUME_CONTINUE - bool wait_for_user; // = false + bool Marlin::wait_for_user; // = false - void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) { + void Marlin::wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) { UNUSED(no_sleep); KEEPALIVE_STATE(PAUSED_FOR_USER); - wait_for_user = true; + wait_start(); if (ms) ms += millis(); // expire time while (wait_for_user && !(ms && ELAPSED(millis(), ms))) idle(TERN_(ADVANCED_PAUSE_FEATURE, no_sleep)); - wait_for_user = false; + user_resume(); while (ui.button_pressed()) safe_delay(50); } @@ -320,7 +334,7 @@ bool wait_for_heatup = false; #pragma GCC diagnostic ignored "-Wnarrowing" #pragma GCC diagnostic ignored "-Wsign-compare" -bool pin_is_protected(const pin_t pin) { +bool Marlin::pin_is_protected(const pin_t pin) { #define pgm_read_pin(P) (sizeof(pin_t) == 2 ? (pin_t)pgm_read_word(P) : (pin_t)pgm_read_byte(P)) for (uint8_t i = 0; i < COUNT(sensitive_dio); ++i) if (pin == pgm_read_pin(&sensitive_dio[i])) return true; @@ -331,28 +345,28 @@ bool pin_is_protected(const pin_t pin) { #pragma GCC diagnostic pop -bool printer_busy() { +bool Marlin::printer_busy() { return planner.has_blocks_queued() || printingIsActive(); } /** * A Print Job exists when the timer is running or SD is printing */ -bool printJobOngoing() { return print_job_timer.isRunning() || card.isStillPrinting(); } +bool Marlin::printJobOngoing() { return print_job_timer.isRunning() || card.isStillPrinting(); } /** * Printing is active when a job is underway but not paused */ -bool printingIsActive() { return !did_pause_print && printJobOngoing(); } +bool Marlin::printingIsActive() { return !did_pause_print && printJobOngoing(); } /** * Printing is paused according to SD or host indicators */ -bool printingIsPaused() { +bool Marlin::printingIsPaused() { return did_pause_print || print_job_timer.isPaused() || card.isPaused(); } -void startOrResumeJob() { +void Marlin::startOrResumeJob() { if (!printingIsPaused()) { TERN_(GCODE_REPEAT_MARKERS, repeat.reset()); TERN_(CANCEL_OBJECTS, cancelable.reset()); @@ -378,7 +392,7 @@ void startOrResumeJob() { TERN(HAS_CUTTER, cutter.kill(), thermalManager.zero_fan_speeds()); // Full cutter shutdown including ISR control - wait_for_heatup = false; + marlin.heatup_done(); TERN_(POWER_LOSS_RECOVERY, recovery.purge()); @@ -390,8 +404,8 @@ void startOrResumeJob() { } inline void finishSDPrinting() { - if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued - marlin_state = MarlinState::MF_RUNNING; // Signal to stop trying + if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued + marlin.setState(MarlinState::MF_RUNNING); // Signal to stop trying TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine()); TERN_(DGUS_LCD_UI_MKS, screen.sdPrintingFinished()); } @@ -412,7 +426,7 @@ void startOrResumeJob() { * - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT) * - Pulse FET_SAFETY_PIN if it exists */ -inline void manage_inactivity(const bool no_stepper_sleep=false) { +void Marlin::manage_inactivity(const bool no_stepper_sleep/*=false*/) { queue.get_available_commands(); @@ -708,7 +722,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { #if ENABLED(DUAL_X_CARRIAGE) // handle delayed move timeout - if (delayed_move_time && ELAPSED(ms, delayed_move_time) && IsRunning()) { + if (delayed_move_time && ELAPSED(ms, delayed_move_time) && isRunning()) { // travel moves have been received so enact them delayed_move_time = 0xFFFFFFFFUL; // force moves to be done destination = current_position; @@ -737,7 +751,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED); } #endif -} // manage_inactivity() + +} // Marlin::manage_inactivity() #if ALL(EP_BABYSTEPPING, EMERGENCY_PARSER) #include "feature/babystep.h" @@ -765,14 +780,14 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { * - Update the Průša MMU2 * - Handle Joystick jogging */ -void idle(const bool no_stepper_sleep/*=false*/) { +void Marlin::idle(const bool no_stepper_sleep/*=false*/) { #ifdef MAX7219_DEBUG_PROFILE CodeProfiler idle_profiler; #endif #if ENABLED(MARLIN_DEV_MODE) static uint16_t idle_depth = 0; - if (++idle_depth > 5) SERIAL_ECHOLNPGM("idle() call depth: ", idle_depth); + if (++idle_depth > 5) SERIAL_ECHOLNPGM("Marlin::idle() call depth: ", idle_depth); #endif // Bed Distance Sensor task @@ -788,7 +803,7 @@ void idle(const bool no_stepper_sleep/*=false*/) { TERN_(MAX7219_DEBUG, max7219.idle_tasks()); // Return if setup() isn't completed - if (marlin_state == MarlinState::MF_INITIALIZING) goto IDLE_DONE; + if (state == MarlinState::MF_INITIALIZING) goto IDLE_DONE; // TODO: Still causing errors TERN_(TOOL_SENSOR, (void)check_tool_sensor_stats(active_extruder, true)); @@ -888,13 +903,14 @@ void idle(const bool no_stepper_sleep/*=false*/) { TERN_(MARLIN_DEV_MODE, idle_depth--); return; -} // idle() + +} // Marlin::idle() /** * Kill all activity and lock the machine. * After this the machine will need to be reset. */ -void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { +void Marlin::kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { thermalManager.disable_all_heaters(); TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control @@ -920,7 +936,7 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp minkill(steppers_off); } -void minkill(const bool steppers_off/*=false*/) { +void Marlin::minkill(const bool steppers_off/*=false*/) { // Wait a short time (allows messages to get out before shutting down. for (int i = 1000; i--;) DELAY_US(600); @@ -960,13 +976,14 @@ void minkill(const bool steppers_off/*=false*/) { for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle #endif -} + +} // Marlin::minkill /** * Turn off heaters and stop the print in progress * After a stop the machine may be resumed with M999 */ -void stop() { +void Marlin::stop() { thermalManager.disable_all_heaters(); // 'unpause' taken care of in here print_job_timer.stop(); @@ -975,13 +992,13 @@ void stop() { thermalManager.set_fans_paused(false); // Un-pause fans for safety #endif - if (!IsStopped()) { + if (!isStopped()) { SERIAL_ERROR_MSG(STR_ERR_STOPPED); LCD_MESSAGE(MSG_STOPPED); - safe_delay(350); // allow enough time for messages to get out before stopping - marlin_state = MarlinState::MF_STOPPED; + safe_delay(350); // Allow enough time for messages to get out before stopping + state = MarlinState::MF_STOPPED; } -} // stop() +} // Marlin::stop() inline void tmc_standby_setup() { #if PIN_EXISTS(X_STDBY) @@ -1692,7 +1709,7 @@ void setup() { SETUP_RUN(ftMotion.init()); #endif - marlin_state = MarlinState::MF_RUNNING; + marlin.setState(MarlinState::MF_RUNNING); #ifdef STARTUP_TUNE // Play a short startup tune before continuing. @@ -1708,7 +1725,7 @@ void setup() { /** * The main Marlin program loop * - * - Call idle() to handle all tasks between G-code commands + * - Call marlin.idle() to handle all tasks between G-code commands * Note that no G-codes from the queue can be executed during idle() * but many G-codes can be called directly anytime like macros. * - Check whether SD card auto-start is needed now. @@ -1720,11 +1737,11 @@ void setup() { */ void loop() { do { - idle(); + marlin.idle(); #if HAS_MEDIA if (card.flag.abort_sd_printing) abortSDPrinting(); - if (marlin_state == MarlinState::MF_SD_COMPLETE) finishSDPrinting(); + if (marlin.is(MarlinState::MF_SD_COMPLETE)) finishSDPrinting(); #endif queue.advance(); diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index 6f27b9998e..cfc5eeca80 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -27,19 +27,6 @@ #include #include -void stop(); - -// Pass true to keep steppers from timing out -void idle(const bool no_stepper_sleep=false); -inline void idle_no_sleep() { idle(true); } - -void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false); -void minkill(const bool steppers_off=false); - -#if ENABLED(CONFIGURABLE_MACHINE_NAME) - extern MString<64> machine_name; -#endif - // Global State of the firmware enum class MarlinState : uint8_t { MF_INITIALIZING = 0, @@ -51,35 +38,81 @@ enum class MarlinState : uint8_t { MF_WAITING, }; -extern MarlinState marlin_state; -inline bool IsRunning() { return marlin_state >= MarlinState::MF_RUNNING; } -inline bool IsStopped() { return marlin_state == MarlinState::MF_STOPPED; } +typedef bool (*testFunc_t)(); -bool printingIsActive(); -bool printJobOngoing(); -bool printingIsPaused(); -void startOrResumeJob(); +// Delay ensuring that temperatures are updated and the watchdog is kept alive +void safe_delay(millis_t ms); -bool printer_busy(); +// Singleton for Marlin global data and methods -extern bool wait_for_heatup; - -#if HAS_RESUME_CONTINUE - extern bool wait_for_user; - void wait_for_user_response(millis_t ms=0, const bool no_sleep=false); -#endif - -bool pin_is_protected(const pin_t pin); - -#if HAS_SUICIDE - inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_STATE); } -#endif - -#if HAS_KILL - #ifndef KILL_PIN_STATE - #define KILL_PIN_STATE LOW +class Marlin { +public: + #if ENABLED(CONFIGURABLE_MACHINE_NAME) + static MString<64> machine_name; #endif - inline bool kill_state() { return READ(KILL_PIN) == KILL_PIN_STATE; } -#endif + + static MarlinState state; + static void setState(const MarlinState s) { state = s; } + static bool is(const MarlinState s) { return state == s; } + static bool isStopped() { return is(MarlinState::MF_STOPPED); } + static bool isRunning() { return state >= MarlinState::MF_RUNNING; } + + static bool printingIsActive(); + static bool printJobOngoing(); + static bool printingIsPaused(); + static void startOrResumeJob(); + + static bool printer_busy(); + + static void stop(); + + // Maintain all important activities + static void manage_inactivity(const bool no_stepper_sleep=false); + + // Pass true to keep steppers from timing out + static void idle(const bool no_stepper_sleep=false); + static void idle_no_sleep() { idle(true); } + + static void kill(FSTR_P const lcd_error=nullptr, FSTR_P const lcd_component=nullptr, const bool steppers_off=false); + static void minkill(const bool steppers_off=false); + + #if HAS_RESUME_CONTINUE + // Global waiting for user response + static bool wait_for_user; + static void wait_start() { wait_for_user = true; } + static void user_resume() { wait_for_user = false; } + static void wait_for_user_response(millis_t ms=0, const bool no_sleep=false); + #endif + + // Global waiting for heatup state + static bool wait_for_heatup; + static bool is_heating() { return wait_for_heatup; } + static void heatup_start() { wait_for_heatup = true; } + static void heatup_done() { wait_for_heatup = false; } + static void end_waiting() { TERN_(HAS_RESUME_CONTINUE, wait_for_user =) wait_for_heatup = false; } + + // Shared function for M42 / M43 + static bool pin_is_protected(const pin_t pin); + + #if HAS_SUICIDE + static void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_STATE); } + #endif + + static bool kill_state() { + return ( + #if HAS_KILL + #ifndef KILL_PIN_STATE + #define KILL_PIN_STATE LOW + #endif + READ(KILL_PIN) == KILL_PIN_STATE + #else + false + #endif + ); + } + +}; + +extern Marlin marlin; extern const char M112_KILL_STR[]; diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index e0a31db9ab..837f3885b9 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -210,6 +210,8 @@ #define STR_KILL_BUTTON "KILL button/pin" // temperature.cpp strings +#define STR_WAIT_FOR_HOTEND "Wait for hotend heating..." +#define STR_WAIT_FOR_BED "Wait for bed heating..." #define STR_PID_AUTOTUNE "PID Autotune" #define STR_PID_AUTOTUNE_START " start" #define STR_PID_BAD_HEATER_ID " failed! Bad heater id" @@ -230,6 +232,8 @@ #define STR_PID_DEBUG_INPUT ": Input " #define STR_PID_DEBUG_OUTPUT " Output " #define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !" + +// MPCTEMP strings #define STR_MPC_AUTOTUNE_START "MPC Autotune start for " STR_E #define STR_MPC_AUTOTUNE_INTERRUPTED "MPC Autotune interrupted!" #define STR_MPC_AUTOTUNE_FINISHED "MPC Autotune finished! Put the constants below into Configuration.h" @@ -238,6 +242,7 @@ #define STR_MPC_MEASURING_AMBIENT "Measuring ambient heatloss at " #define STR_MPC_TEMPERATURE_ERROR "Temperature error" +// Temperature Sensors #define STR_HEATER_BED "bed" #define STR_HEATER_CHAMBER "chamber" #define STR_COOLER "cooler" @@ -247,6 +252,7 @@ #define STR_REDUNDANT "redundant " #define STR_LASER_TEMP "laser temperature" +// Misc. Errors, Thermal Runaway #define STR_STOPPED_HEATER ", system stopped! Heater_ID: " #define STR_DETECTED_TEMP_B " (temp: " #define STR_DETECTED_TEMP_E ")" @@ -269,6 +275,7 @@ #define STR_DEBUG_COMMUNICATION "COMMUNICATION" #define STR_DEBUG_DETAIL "DETAIL" +// Password Security #define STR_PRINTER_LOCKED "Printer locked! (Unlock with M511 or LCD)" #define STR_WRONG_PASSWORD "Incorrect Password" #define STR_PASSWORD_TOO_LONG "Password too long" diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index c8b903ecc2..f6b8b304c0 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -22,26 +22,16 @@ #include "utility.h" -#include "../MarlinCore.h" #include "../module/temperature.h" #if ENABLED(MARLIN_DEV_MODE) MarlinError marlin_error_number; // Error Number - Marlin can beep X times periodically, display, and emit... #endif -void safe_delay(millis_t ms) { - while (ms > 50) { - ms -= 50; - delay(50); - thermalManager.task(); - } - delay(ms); - thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made -} - // A delay to provide brittle hosts time to receive bytes #if ENABLED(SERIAL_OVERRUN_PROTECTION) + #include "../MarlinCore.h" // for safe_delay #include "../gcode/gcode.h" // for set_autoreport_paused void serial_delay(const millis_t ms) { diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index 77e8bac016..b8b4de7f28 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -25,8 +25,6 @@ #include "../core/types.h" #include "../core/millis_t.h" -void safe_delay(millis_t ms); // Delay ensuring that temperatures are updated and the watchdog is kept alive. - #if ENABLED(SERIAL_OVERRUN_PROTECTION) void serial_delay(const millis_t ms); #else diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index 6a4929e60f..d61784517b 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -25,7 +25,6 @@ #if ENABLED(BABYSTEPPING) #include "babystep.h" -#include "../MarlinCore.h" #include "../module/motion.h" // for axis_should_home(), BABYSTEP_ALLOWED #include "../module/planner.h" // for axis_steps_per_mm[] #include "../module/stepper.h" diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.cpp b/Marlin/src/feature/bedlevel/bdl/bdl.cpp index ea4bcc0607..45c7792d5c 100644 --- a/Marlin/src/feature/bedlevel/bdl/bdl.cpp +++ b/Marlin/src/feature/bedlevel/bdl/bdl.cpp @@ -24,7 +24,6 @@ #if ENABLED(BD_SENSOR) -#include "../../../MarlinCore.h" #include "../../../gcode/gcode.h" #include "../../../module/settings.h" #include "../../../module/motion.h" @@ -110,7 +109,7 @@ float BDS_Leveling::read() { } void BDS_Leveling::process() { - if (config_state == BDS_IDLE && printingIsActive()) return; + if (config_state == BDS_IDLE && marlin.printingIsActive()) return; static millis_t next_check_ms = 0; // starting at T=0 static float zpos = 0.0f; const millis_t ms = millis(); @@ -156,7 +155,7 @@ void BDS_Leveling::process() { } else if (config_state == BDS_HOMING_Z) { SERIAL_ECHOLNPGM("Read:", tmp); - kill(F("BDsensor connect Err!")); + marlin.kill(F("BDsensor connect Err!")); } DEBUG_ECHOLNPGM("BD:", tmp & 0x3FF, " Z:", cur_z, "|", current_position.z); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index e1f2ed4c16..2357437633 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -28,7 +28,6 @@ unified_bed_leveling bedlevel; -#include "../../../MarlinCore.h" #include "../../../gcode/gcode.h" #include "../../../module/settings.h" @@ -221,7 +220,7 @@ void unified_bed_leveling::display_map(const uint8_t map_type) { if (human) SERIAL_CHAR(is_current ? ']' : ' '); SERIAL_FLUSHTX(); - idle_no_sleep(); + marlin.idle_no_sleep(); } if (!lcd) SERIAL_EOL(); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index e14d7b2a38..6341933bfb 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -26,7 +26,6 @@ #include "../bedlevel.h" -#include "../../../MarlinCore.h" #include "../../../HAL/shared/eeprom_api.h" #include "../../../libs/hex_print.h" #include "../../../module/settings.h" @@ -375,7 +374,7 @@ void unified_bed_leveling::G29() { bool invalidate_all = count >= GRID_MAX_POINTS; if (!invalidate_all) { while (count--) { - if ((count & 0x0F) == 0x0F) idle(); + if ((count & 0x0F) == 0x0F) marlin.idle(); const mesh_index_pair closest = find_closest_mesh_point_of_type(REAL, param.XY_pos); // No more REAL mesh points to invalidate? Assume the user meant // to invalidate the ENTIRE mesh, which can't be done with @@ -856,7 +855,7 @@ void set_message_with_feedback(FSTR_P const fstr) { ui.quick_feedback(false); // Preserve button state for click-and-hold const millis_t nxt = millis() + 1500UL; while (ui.button_pressed()) { // Loop while the encoder is pressed. Uses hardware flag! - idle(); // idle, of course + marlin.idle(); // idle, of course if (ELAPSED(millis(), nxt)) { // After 1.5 seconds ui.quick_feedback(); if (func) (*func)(); @@ -872,7 +871,7 @@ void set_message_with_feedback(FSTR_P const fstr) { void unified_bed_leveling::move_z_with_encoder(const float multiplier) { ui.wait_for_release(); while (!ui.button_pressed()) { - idle(); + marlin.idle(); gcode.reset_stepper_timeout(); // Keep steppers powered if (encoder_diff) { do_blocking_move_to_z(current_position.z + float(encoder_diff) * multiplier); @@ -1088,7 +1087,7 @@ void set_message_with_feedback(FSTR_P const fstr) { SET_SOFT_ENDSTOP_LOOSE(true); do { - idle_no_sleep(); + marlin.idle_no_sleep(); new_z = ui.ubl_mesh_value(); TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited SERIAL_FLUSH(); // Prevent host M105 buffer overrun. @@ -1728,7 +1727,7 @@ void unified_bed_leveling::smart_fill_mesh() { const float ez = -lsf_results.D - lsf_results.A * ppos.x - lsf_results.B * ppos.y; z_values[ix][iy] = ez; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy])); - idle(); // housekeeping + marlin.idle(); // housekeeping } } } @@ -1785,7 +1784,7 @@ void unified_bed_leveling::smart_fill_mesh() { SERIAL_EOL(); #if HAS_KILL - SERIAL_ECHOLNPGM("Kill pin on :", KILL_PIN, " state:", kill_state()); + SERIAL_ECHOLNPGM("Kill pin on :", KILL_PIN, " state:", marlin.kill_state()); #endif SERIAL_EOL(); @@ -1823,7 +1822,7 @@ void unified_bed_leveling::smart_fill_mesh() { SERIAL_ECHO_MSG("EEPROM Dump:"); persistentStore.access_start(); for (uint16_t i = 0; i < persistentStore.capacity(); i += 16) { - if (!(i & 0x3)) idle(); + if (!(i & 0x3)) marlin.idle(); print_hex_word(i); SERIAL_ECHOPGM(": "); for (uint16_t j = 0; j < 16; j++) { diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index be9fb7b947..b6b9ec4368 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -32,7 +32,6 @@ #include "../../../module/delta.h" #endif -#include "../../../MarlinCore.h" #include //#define DEBUG_UBL_MOTION diff --git a/Marlin/src/feature/dac/dac_dac084s085.cpp b/Marlin/src/feature/dac/dac_dac084s085.cpp index 772bb68de4..1338e5979d 100644 --- a/Marlin/src/feature/dac/dac_dac084s085.cpp +++ b/Marlin/src/feature/dac/dac_dac084s085.cpp @@ -10,7 +10,6 @@ #include "dac_dac084s085.h" -#include "../../MarlinCore.h" #include "../../HAL/shared/Delay.h" dac084s085::dac084s085() { } diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index 13cf71e076..08cda561b1 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -175,7 +175,7 @@ namespace DirectStepping { template void SerialPageManager::write_responses() { if (fatal_error) { - kill(GET_TEXT_F(MSG_BAD_PAGE)); + marlin.kill(GET_TEXT_F(MSG_BAD_PAGE)); return; } diff --git a/Marlin/src/feature/e_parser.cpp b/Marlin/src/feature/e_parser.cpp index 9e974f2e83..bda1232154 100644 --- a/Marlin/src/feature/e_parser.cpp +++ b/Marlin/src/feature/e_parser.cpp @@ -49,9 +49,6 @@ bool EmergencyParser::killed_by_M112, // = false // Global instance EmergencyParser emergency_parser; -// External references -extern bool wait_for_user, wait_for_heatup; - #if ENABLED(EP_BABYSTEPPING) #include "babystep.h" #endif @@ -208,7 +205,7 @@ void EmergencyParser::update(EmergencyParser::State &state, const uint8_t c) { default: if (ISEOL(c)) { if (enabled) switch (state) { - case EP_M108: wait_for_user = wait_for_heatup = false; break; + case EP_M108: marlin.end_waiting(); break; case EP_M112: killed_by_M112 = true; break; case EP_M410: quickstop_by_M410 = true; break; #if ENABLED(FTM_RESONANCE_TEST) diff --git a/Marlin/src/feature/easythreed_ui.cpp b/Marlin/src/feature/easythreed_ui.cpp index bfa51096f5..7180c4dbcd 100644 --- a/Marlin/src/feature/easythreed_ui.cpp +++ b/Marlin/src/feature/easythreed_ui.cpp @@ -91,7 +91,7 @@ void EasythreedUI::blinkLED() { // Load/Unload buttons are a 3 position switch with a common center ground. // void EasythreedUI::loadButton() { - if (printingIsActive()) return; + if (marlin.printingIsActive()) return; enum FilamentStatus : uint8_t { FS_IDLE, FS_PRESS, FS_CHECK, FS_PROCEED }; static uint8_t filament_status = FS_IDLE; @@ -185,7 +185,7 @@ void EasythreedUI::printButton() { if (PENDING(ms, key_time, 1200 - BTN_DEBOUNCE_MS)) { // Register a press < 1.2 seconds switch (print_key_flag) { case PF_START: { // The "Print" button starts an SD card print - if (printingIsActive()) break; // Already printing? (find another line that checks for 'is planner doing anything else right now?') + if (marlin.printingIsActive()) break; // Already printing? (find another line that checks for 'is planner doing anything else right now?') blink_interval_ms = LED_BLINK_2; // Blink the indicator LED at 1 second intervals print_key_flag = PF_PAUSE; // The "Print" button now pauses the print card.mount(); // Force SD card to mount - now! @@ -201,13 +201,13 @@ void EasythreedUI::printButton() { card.openAndPrintFile(card.filename); // Start printing it } break; case PF_PAUSE: { // Pause printing (not currently firing) - if (!printingIsActive()) break; + if (!marlin.printingIsActive()) break; blink_interval_ms = LED_ON; // Set indicator to steady ON queue.inject(F("M25")); // Queue Pause print_key_flag = PF_RESUME; // The "Print" button now resumes the print } break; case PF_RESUME: { // Resume printing - if (printingIsActive()) break; + if (marlin.printingIsActive()) break; blink_interval_ms = LED_BLINK_2; // Blink the indicator LED at 1 second intervals queue.inject(F("M24")); // Queue resume print_key_flag = PF_PAUSE; // The "Print" button now pauses the print @@ -215,7 +215,7 @@ void EasythreedUI::printButton() { } } else { // Register a longer press - if (print_key_flag == PF_START && !printingIsActive()) { // While not printing, this moves Z up 10mm + if (print_key_flag == PF_START && !marlin.printingIsActive()) { // While not printing, this moves Z up 10mm blink_interval_ms = LED_ON; queue.inject(F("G91\nG0 Z10 F600\nG90")); // Raise Z soon after returning to main loop } diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index 5a47600792..7c83053b89 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -149,7 +149,7 @@ void I2CPositionEncoder::update() { #ifdef I2CPE_ERR_THRESH_ABORT if (ABS(error) > I2CPE_ERR_THRESH_ABORT * planner.settings.axis_steps_per_mm[encoderAxis]) { - //kill(F("Significant Error")); + //marlin.kill(F("Significant Error")); SERIAL_ECHOLNPGM("Axis error over threshold, aborting!", error); safe_delay(5000); } diff --git a/Marlin/src/feature/fancheck.cpp b/Marlin/src/feature/fancheck.cpp index 339eb16aa9..d0582ed97a 100644 --- a/Marlin/src/feature/fancheck.cpp +++ b/Marlin/src/feature/fancheck.cpp @@ -93,7 +93,7 @@ void FanCheck::compute_speed(uint16_t elapsedTime) { // Drop the error when all fans are ok if (!fan_error_msk && error == TachoError::REPORTED) error = TachoError::FIXED; - if (error == TachoError::FIXED && !printJobOngoing() && !printingIsPaused()) { + if (error == TachoError::FIXED && !marlin.printJobOngoing() && !marlin.printingIsPaused()) { error = TachoError::NONE; // if the issue has been fixed while the printer is idle, reenable immediately ui.reset_alert_level(); } @@ -106,17 +106,17 @@ void FanCheck::compute_speed(uint16_t elapsedTime) { } void FanCheck::report_speed_error(uint8_t fan) { - if (printJobOngoing()) { + if (marlin.printJobOngoing()) { if (error == TachoError::NONE) { if (thermalManager.degTargetHotend(fan) != 0) { - kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT)); + marlin.kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT)); error = TachoError::REPORTED; } else error = TachoError::DETECTED; // Plans error for next processed command } } - else if (!printingIsPaused()) { + else if (!marlin.printingIsPaused()) { thermalManager.setTargetHotend(0, fan); // Always disable heating if (error == TachoError::NONE) error = TachoError::REPORTED; } diff --git a/Marlin/src/feature/fancheck.h b/Marlin/src/feature/fancheck.h index 3c295b3020..fed6a798e1 100644 --- a/Marlin/src/feature/fancheck.h +++ b/Marlin/src/feature/fancheck.h @@ -25,7 +25,6 @@ #if HAS_FANCHECK -#include "../MarlinCore.h" #include "../lcd/marlinui.h" #if ENABLED(AUTO_REPORT_FANS) @@ -74,7 +73,11 @@ class FanCheck { static void check_deferred_error() { if (error == TachoError::DETECTED) { error = TachoError::REPORTED; - TERN(PARK_HEAD_ON_PAUSE, queue.inject(F("M125")), kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT))); + #if ENABLED(PARK_HEAD_ON_PAUSE) + queue.inject(F("M125")); + #else + marlin.kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT)); + #endif } } diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index 538aa92e91..94bc4db011 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -87,10 +87,6 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { PGMSTR(CONTINUE_STR, "Continue"); PGMSTR(DISMISS_STR, "Dismiss"); - #if HAS_RESUME_CONTINUE - extern bool wait_for_user; - #endif - void HostUI::notify(const char * const cstr) { PORT_REDIRECT(SerialMask::All); action(F("notification "), false); @@ -205,7 +201,7 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { } break; case PROMPT_USER_CONTINUE: - TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); + TERN_(HAS_RESUME_CONTINUE, marlin.user_resume()); break; case PROMPT_PAUSE_RESUME: #if ALL(ADVANCED_PAUSE_FEATURE, HAS_MEDIA) diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index eb16781fdd..a779efeaff 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -43,7 +43,7 @@ millis_t HotendIdleProtection::next_protect_ms = 0; hotend_idle_settings_t HotendIdleProtection::cfg; // Initialized by settings.load void HotendIdleProtection::check_hotends(const millis_t &ms) { - const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued()); + const bool busy = (TERN0(HAS_RESUME_CONTINUE, marlin.wait_for_user) || planner.has_blocks_queued()); bool do_prot = false; if (!busy && cfg.timeout != 0) { HOTEND_LOOP() { diff --git a/Marlin/src/feature/max7219.h b/Marlin/src/feature/max7219.h index 799524dc5f..9c39541a7c 100644 --- a/Marlin/src/feature/max7219.h +++ b/Marlin/src/feature/max7219.h @@ -74,14 +74,13 @@ #ifdef MAX7219_DEBUG_PROFILE // This class sums up the amount of time for which its instances exist. - // By default there is one instantiated for the duration of the idle() - // function. But an instance can be created in any code block to measure - // the time spent from the point of instantiation until the CPU leaves - // block. Be careful about having multiple instances of CodeProfiler as - // it does not guard against double counting. In general mixing ISR and - // non-ISR use will require critical sections but note that mode setting - // is atomic so the total or average times can safely be read if you set - // mode to FREEZE first. + // By default there is one instantiated for the duration of marlin.idle() + // but an instance can be created in any code block to measure time spent + // from instantiation until the CPU leaves the block. + // Be careful about having multiple instances of CodeProfiler as it does + // not guard against double counting. In general mixing ISR and non-ISR + // use will require critical sections but note that mode setting is atomic + // so the total or average times can safely be read if you set mode to FREEZE first. class CodeProfiler { public: enum Mode : uint8_t { ACCUMULATE_AVERAGE, ACCUMULATE_TOTAL, FREEZE }; diff --git a/Marlin/src/feature/mmu/mmu.cpp b/Marlin/src/feature/mmu/mmu.cpp index 58c49ed224..b1e66cc425 100644 --- a/Marlin/src/feature/mmu/mmu.cpp +++ b/Marlin/src/feature/mmu/mmu.cpp @@ -24,7 +24,6 @@ #if HAS_PRUSA_MMU1 -#include "../../MarlinCore.h" #include "../../module/planner.h" #include "../../module/stepper.h" diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index b976150ed9..76e2b8505f 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -40,7 +40,6 @@ MMU2 mmu2; #include "../../module/temperature.h" #include "../../module/planner.h" #include "../../module/stepper.h" -#include "../../MarlinCore.h" #if ENABLED(HOST_PROMPT_SUPPORT) #include "../host_actions.h" @@ -446,7 +445,7 @@ bool MMU2::rx_ok() { void MMU2::check_version(const uint16_t buildnr) { if (buildnr < MMU_REQUIRED_FW_BUILDNR) { SERIAL_ERROR_MSG("Invalid MMU2 firmware. Version >= " STRINGIFY(MMU_REQUIRED_FW_BUILDNR) " required."); - kill(GET_TEXT_F(MSG_KILL_MMU2_FIRMWARE)); + marlin.kill(GET_TEXT_F(MSG_KILL_MMU2_FIRMWARE)); } } @@ -786,10 +785,10 @@ void MMU2::command(const uint8_t mmu_cmd) { * Wait for response from MMU */ bool MMU2::get_response() { - while (cmd != MMU_CMD_NONE) idle(); + while (cmd != MMU_CMD_NONE) marlin.idle(); while (!ready) { - idle(); + marlin.idle(); if (state != 3) break; } @@ -985,7 +984,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { mmu2_attn_buzz(); TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_MMU2_EJECT_RECOVER))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_MMU2_EJECT_RECOVER))); - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); + TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response()); mmu2_attn_buzz(); command(MMU_CMD_R0); diff --git a/Marlin/src/feature/mmu3/mmu3.cpp b/Marlin/src/feature/mmu3/mmu3.cpp index f2c7be3f6a..9727c07829 100644 --- a/Marlin/src/feature/mmu3/mmu3.cpp +++ b/Marlin/src/feature/mmu3/mmu3.cpp @@ -274,7 +274,7 @@ namespace MMU3 { */ void MMU3::checkFINDARunout() { if (!findaDetectsFilament() - //&& printJobOngoing() + //&& marlin.printJobOngoing() && parser.codenum != 600 && TERN1(HAS_LEVELING, planner.leveling_active) && xy_are_trusted() @@ -857,7 +857,7 @@ namespace MMU3 { for (;;) { // in our new implementation, we know the exact state of the MMU at any moment, we do not have to wait for a timeout // So in this case we should decide if the operation is: - // - still running -> wait normally in idle() + // - still running -> wait normally in marlin.idle() // - failed -> then do the safety moves on the printer like before // - finished ok -> proceed with reading other commands safe_delay_keep_alive(0); // calls logicStep() and remembers its return status diff --git a/Marlin/src/feature/mmu3/mmu3_marlin1.cpp b/Marlin/src/feature/mmu3/mmu3_marlin1.cpp index 2c4effe106..f12d83772a 100644 --- a/Marlin/src/feature/mmu3/mmu3_marlin1.cpp +++ b/Marlin/src/feature/mmu3/mmu3_marlin1.cpp @@ -122,15 +122,15 @@ namespace MMU3 { #endif } - bool marlin_printingIsActive() { return printingIsActive(); } + bool marlin_printingIsActive() { return marlin.printingIsActive(); } void marlin_manage_heater() { thermalManager.task(); } - void marlin_manage_inactivity(const bool b) { idle(b); } + void marlin_manage_inactivity(const bool b) { marlin.idle(b); } - void marlin_idle(bool b) { + void marlin_idle(const bool b) { thermalManager.task(); - idle(b); + marlin.idle(b); } void marlin_refresh_print_state_in_ram() { @@ -157,7 +157,7 @@ namespace MMU3 { void thermal_setTargetHotend(int16_t t) { thermalManager.setTargetHotend(t, 0); } void safe_delay_keep_alive(uint16_t t) { - idle(true); + marlin.idle(true); safe_delay(t); } diff --git a/Marlin/src/feature/mmu3/mmu3_reporting.cpp b/Marlin/src/feature/mmu3/mmu3_reporting.cpp index 426aa4d825..b0527937ea 100644 --- a/Marlin/src/feature/mmu3/mmu3_reporting.cpp +++ b/Marlin/src/feature/mmu3/mmu3_reporting.cpp @@ -213,7 +213,7 @@ namespace MMU3 { void EndReport(CommandInProgress /*cip*/, ProgressCode /*ec*/) { // clear the status msg line - let the printed filename get visible again - if (!printJobOngoing()) ui.reset_status(); + if (!marlin.printJobOngoing()) ui.reset_status(); //custom_message_type = CustomMsg::Status; } diff --git a/Marlin/src/feature/mmu3/ultralcd.cpp b/Marlin/src/feature/mmu3/ultralcd.cpp index 96e019740f..3b8f52beb3 100644 --- a/Marlin/src/feature/mmu3/ultralcd.cpp +++ b/Marlin/src/feature/mmu3/ultralcd.cpp @@ -187,7 +187,7 @@ } // Wait for 5 seconds before displaying the next text. for (uint8_t i = 0; i < 100; ++i) { - idle(true); + marlin.idle(true); safe_delay(50); if (ui.use_click()) { if (fmsg_next == nullptr) { diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index e48a0f8ec4..715ec087e1 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -160,10 +160,10 @@ static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=P if (wait) return thermalManager.wait_for_hotend(active_extruder); // Allow interruption by Emergency Parser M108 - wait_for_heatup = TERN1(PREVENT_COLD_EXTRUSION, !thermalManager.allow_cold_extrude); - while (wait_for_heatup && ABS(thermalManager.wholeDegHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > (TEMP_WINDOW)) - idle(); - wait_for_heatup = false; + marlin.wait_for_heatup = TERN1(PREVENT_COLD_EXTRUSION, !thermalManager.allow_cold_extrude); + while (marlin.is_heating() && ABS(thermalManager.wholeDegHotend(active_extruder) - thermalManager.degTargetHotend(active_extruder)) > (TEMP_WINDOW)) + marlin.idle(); + marlin.heatup_done(); #if ENABLED(PREVENT_COLD_EXTRUSION) // A user can cancel wait-for-heating with M108 @@ -206,7 +206,7 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len first_impatient_beep(max_beep_count); KEEPALIVE_STATE(PAUSED_FOR_USER); - wait_for_user = true; // LCD click or M108 will clear this + marlin.wait_start(); // LCD click or M108 will clear this TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENTLOAD))); @@ -215,19 +215,19 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len hostui.prompt_do(PROMPT_USER_CONTINUE, F("Load Filament T"), tool, FPSTR(CONTINUE_STR)); #endif - while (wait_for_user) { + while (marlin.wait_for_user) { impatient_beep(max_beep_count); #if ALL(HAS_FILAMENT_SENSOR, FILAMENT_CHANGE_RESUME_ON_INSERT) #if MULTI_FILAMENT_SENSOR - #define _CASE_INSERTED(N) case N-1: if (!FILAMENT_IS_OUT(N)) wait_for_user = false; break; + #define _CASE_INSERTED(N) case N-1: if (!FILAMENT_IS_OUT(N)) marlin.user_resume(); break; switch (active_extruder) { REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED) } #else - if (!FILAMENT_IS_OUT()) wait_for_user = false; + if (!FILAMENT_IS_OUT()) marlin.user_resume(); #endif #endif - idle_no_sleep(); + marlin.idle_no_sleep(); } } @@ -270,10 +270,10 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE))); TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE))); - wait_for_user = true; // A click or M108 breaks the purge_length loop - for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count) + marlin.wait_start(); // A click or M108 breaks the purge_length loop + for (float purge_count = purge_length; purge_count > 0 && marlin.wait_for_user; --purge_count) unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE); - wait_for_user = false; + marlin.user_resume(); #else @@ -297,14 +297,14 @@ bool load_filament(const float slow_load_length/*=0*/, const float fast_load_len if (show_lcd) { // Show "Purge More" / "Resume" menu and wait for reply KEEPALIVE_STATE(PAUSED_FOR_USER); - wait_for_user = false; + marlin.user_resume(); #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI) ui.pause_show_message(PAUSE_MESSAGE_OPTION); // MarlinUI and MKS UI also set PAUSE_RESPONSE_WAIT_FOR #else pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; TERN_(SOVOL_SV06_RTS, rts.gotoPage(ID_PurgeMore_L, ID_PurgeMore_D)); #endif - while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle_no_sleep(); + while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) marlin.idle_no_sleep(); } #endif @@ -553,8 +553,8 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep KEEPALIVE_STATE(PAUSED_FOR_USER); TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_NOZZLE_PARKED))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_NOZZLE_PARKED))); - wait_for_user = true; // LCD click or M108 will clear this - while (wait_for_user) { + marlin.wait_start(); // LCD click or M108 will clear this + while (marlin.wait_for_user) { impatient_beep(max_beep_count); // If the nozzle has timed out... @@ -579,7 +579,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_HEATER_TIMEOUT)); #endif - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(0, true)); // Wait for LCD click or M108 + TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response(0, true)); // Wait for LCD click or M108 TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_INFO, GET_TEXT_F(MSG_REHEATING))); @@ -606,12 +606,12 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep LCD_MESSAGE(MSG_REHEATDONE); #endif - IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true); + IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, marlin.wait_start()); nozzle_timed_out = false; first_impatient_beep(max_beep_count); } - idle_no_sleep(); + marlin.idle_no_sleep(); } TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext)); } diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index a28d95d967..2068558fe9 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -119,7 +119,7 @@ void Power::power_on() { * Processes any PSU_POWEROFF_GCODE and makes a PS_OFF_SOUND if enabled. */ void Power::power_off() { - TERN_(HAS_SUICIDE, suicide()); + TERN_(HAS_SUICIDE, marlin.suicide()); if (!psu_on) return; @@ -208,7 +208,7 @@ void Power::power_off() { // If any of the stepper drivers are enabled... if (stepper.axis_enabled.bits) return true; - if (printJobOngoing() || printingIsPaused()) return true; + if (marlin.printJobOngoing() || marlin.printingIsPaused()) return true; #if ENABLED(AUTO_POWER_FANS) FANS_LOOP(i) if (thermalManager.fan_speed[i]) return true; diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 6925ed7a34..0dd19808bc 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -321,7 +321,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW 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() + if (lock) return; // No re-entrance from marlin.idle() during retract_and_lift() lock = true; #endif @@ -355,7 +355,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW sync_plan_position(); } else - kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); + marlin.kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); } #endif // POWER_LOSS_PIN || DEBUG_POWER_LOSS_RECOVERY diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 1cd90b0bb2..7881af4e38 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -31,7 +31,6 @@ #include "../module/stepper.h" // for block_t #include "../gcode/queue.h" #include "pause.h" // for did_pause_print -#include "../MarlinCore.h" // for printingIsActive() #include "../inc/MarlinConfig.h" @@ -64,7 +63,7 @@ typedef Flags< > runout_flags_t; void event_filament_runout(const uint8_t extruder); -inline bool should_monitor_runout() { return did_pause_print || printingIsActive(); } +inline bool should_monitor_runout() { return did_pause_print || marlin.printingIsActive(); } template class TFilamentMonitor; diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 5f0ea7dd7b..dd8d859bde 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -112,7 +112,7 @@ void SpindleLaser::init() { const millis_t duration = (float(SPEED_POWER_MAX) * (60000.f / 2550.f) / float(acceleration_spindle_deg_per_s2)) * abs_diff; millis_t next_ocr_change = millis() + duration; while (current_ocr != ocr) { - while (PENDING(millis(), next_ocr_change)) idle(); + while (PENDING(millis(), next_ocr_change)) marlin.idle(); current_ocr += diff > 0 ? 1 : -1; hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), current_ocr ^ SPINDLE_LASER_PWM_OFF); next_ocr_change += duration; diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index b1fc69f88a..a91d435355 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -31,7 +31,6 @@ */ #include "tmc_util.h" -#include "../MarlinCore.h" #include "../module/stepper/indirection.h" #include "../module/printcounter.h" @@ -283,7 +282,7 @@ if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit"); TERN_(TMC_DEBUG, tmc_report_all()); TERN_(SOVOL_SV06_RTS, rts.gotoPage(ID_DriverError_L, ID_DriverError_D)); - kill(F("Driver error")); + marlin.kill(F("Driver error")); } #endif diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index ba4647e6f5..899498faae 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -105,7 +105,6 @@ #include "../gcode.h" #include "../../feature/bedlevel/bedlevel.h" -#include "../../MarlinCore.h" #include "../../module/planner.h" #include "../../module/motion.h" #include "../../module/tool_change.h" diff --git a/Marlin/src/gcode/bedlevel/G42.cpp b/Marlin/src/gcode/bedlevel/G42.cpp index 44f5ceada8..4b9b028419 100644 --- a/Marlin/src/gcode/bedlevel/G42.cpp +++ b/Marlin/src/gcode/bedlevel/G42.cpp @@ -25,7 +25,6 @@ #if HAS_MESH #include "../gcode.h" -#include "../../MarlinCore.h" // for IsRunning() #include "../../module/motion.h" #include "../../feature/bedlevel/bedlevel.h" diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index c306274aec..058d4ea4ab 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -759,7 +759,7 @@ G29_TYPE GcodeSuite::G29() { for (;;) { pos = planner.get_axis_position_mm(axis); if (inInc > 0 ? (pos >= cmp) : (pos <= cmp)) break; - idle_no_sleep(); + marlin.idle_no_sleep(); } //if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM_P(axis == Y_AXIS ? PSTR("Y=") : PSTR("X=", pos); @@ -803,7 +803,7 @@ G29_TYPE GcodeSuite::G29() { #endif abl.reenable = false; // Don't re-enable after modifying the mesh - idle_no_sleep(); + marlin.idle_no_sleep(); } // inner } // outer diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index a909ef4c84..35f7ac3174 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -96,7 +96,7 @@ void GcodeSuite::G76() { auto report_temps = [](millis_t &ntr, millis_t timeout=0) { - idle_no_sleep(); + marlin.idle_no_sleep(); const millis_t ms = millis(); if (ELAPSED(ms, ntr)) { ntr = ms + 1000; diff --git a/Marlin/src/gcode/calibrate/M100.cpp b/Marlin/src/gcode/calibrate/M100.cpp index ddfed4afe1..822ce969ec 100644 --- a/Marlin/src/gcode/calibrate/M100.cpp +++ b/Marlin/src/gcode/calibrate/M100.cpp @@ -28,8 +28,6 @@ #include "../queue.h" #include "../../libs/hex_print.h" -#include "../../MarlinCore.h" // for idle() - /** * M100: Free Memory Watcher * @@ -178,7 +176,7 @@ inline int32_t count_test_bytes(const char * const start_free_memory) { SERIAL_EOL(); start_free_memory += 16; serial_delay(25); - idle(); + marlin.idle(); } } @@ -209,12 +207,12 @@ inline int check_for_free_memory_corruption(FSTR_P const title) { if (end_free_memory < start_free_memory) { SERIAL_ECHOPGM(" end_free_memory < Heap "); //SET_INPUT_PULLUP(63); // if the developer has a switch wired up to their controller board - //safe_delay(5); // this code can be enabled to pause the display as soon as the - //while ( READ(63)) // malfunction is detected. It is currently defaulting to a switch - // idle(); // being on pin-63 which is unassigend and available on most controller - //safe_delay(20); // boards. + //safe_delay(5); // this code can be enabled to pause the display as soon as the + //while ( READ(63)) // malfunction is detected. It is currently defaulting to a switch + // marlin.idle(); // being on pin-63 which is unassigend and available on most controller + //safe_delay(20); // boards. //while ( !READ(63)) - // idle(); + // marlin.idle(); serial_delay(20); #if ENABLED(M100_FREE_MEMORY_DUMPER) M100_dump_routine(F(" Memory corruption detected with end_free_memory -1) { - if (pin_is_protected(pin)) + if (marlin.pin_is_protected(pin)) protected_pin_err(); else { int target = LOW; @@ -51,7 +50,7 @@ void GcodeSuite::M226() { case 0: target = LOW; break; case -1: target = !extDigitalRead(pin); break; } - while (int(extDigitalRead(pin)) != target) idle(); + while (int(extDigitalRead(pin)) != target) marlin.idle(); } } // pin_state -1 0 1 && pin > -1 } // parser.seen('P') diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index 4ac7834f90..717b0695a4 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -37,8 +37,6 @@ #define OUTPUT_OPEN_DRAIN OUTPUT_OPEN_DRAIN #endif -bool pin_is_protected(const pin_t pin); - void protected_pin_err() { SERIAL_ERROR_MSG(STR_ERR_PROTECTED_PIN); } @@ -63,7 +61,7 @@ void GcodeSuite::M42() { const pin_t pin = GET_PIN_MAP_PIN(pin_index); - if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err(); + if (!parser.boolval('I') && marlin.pin_is_protected(pin)) return protected_pin_err(); bool avoidWrite = false; if (parser.seenval('T')) { diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index a37b0af680..a7653a4037 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -93,7 +93,7 @@ void GcodeSuite::M81() { safe_delay(1000); // Wait 1 second before switching off #if ENABLED(CONFIGURABLE_MACHINE_NAME) - ui.set_status(&MString<30>(&machine_name, ' ', F(STR_OFF), '.')); + ui.set_status(&MString<30>(&marlin.machine_name, ' ', F(STR_OFF), '.')); #else LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF "."); #endif @@ -125,6 +125,6 @@ void GcodeSuite::M81() { #if ENABLED(PSU_CONTROL) powerManager.power_off_soon(); #elif HAS_SUICIDE - suicide(); + marlin.suicide(); #endif } diff --git a/Marlin/src/gcode/control/M999.cpp b/Marlin/src/gcode/control/M999.cpp index b4278fccad..e1408a576a 100644 --- a/Marlin/src/gcode/control/M999.cpp +++ b/Marlin/src/gcode/control/M999.cpp @@ -23,7 +23,7 @@ #include "../gcode.h" #include "../../lcd/marlinui.h" // for ui.reset_alert_level -#include "../../MarlinCore.h" // for marlin_state +#include "../../MarlinCore.h" // for setState #include "../queue.h" // for flush_and_request_resend /** @@ -36,7 +36,7 @@ * existing command buffer. */ void GcodeSuite::M999() { - marlin_state = MarlinState::MF_RUNNING; + marlin.setState(MarlinState::MF_RUNNING); ui.reset_alert_level(); if (parser.boolval('S')) return; diff --git a/Marlin/src/gcode/feature/camera/M240.cpp b/Marlin/src/gcode/feature/camera/M240.cpp index 23ec4ea1e7..8bf0f5d539 100644 --- a/Marlin/src/gcode/feature/camera/M240.cpp +++ b/Marlin/src/gcode/feature/camera/M240.cpp @@ -31,10 +31,6 @@ millis_t chdk_timeout; // = 0 #endif -#if defined(PHOTO_POSITION) && PHOTO_DELAY_MS > 0 - #include "../../../MarlinCore.h" // for idle() -#endif - #ifdef PHOTO_RETRACT_MM #define _PHOTO_RETRACT_MM (PHOTO_RETRACT_MM + 0) @@ -185,7 +181,7 @@ void GcodeSuite::M240() { #ifdef PHOTO_POSITION #if PHOTO_DELAY_MS > 0 const millis_t timeout = millis() + parser.intval('P', PHOTO_DELAY_MS); - while (PENDING(millis(), timeout)) idle(); + while (PENDING(millis(), timeout)) marlin.idle(); #endif do_blocking_move_to(old_pos, fr_mm_s); #ifdef PHOTO_RETRACT_MM diff --git a/Marlin/src/gcode/feature/filwidth/M404-M407.cpp b/Marlin/src/gcode/feature/filwidth/M404-M407.cpp index ff174ecf13..5b906760ed 100644 --- a/Marlin/src/gcode/feature/filwidth/M404-M407.cpp +++ b/Marlin/src/gcode/feature/filwidth/M404-M407.cpp @@ -26,7 +26,6 @@ #include "../../../feature/filwidth.h" #include "../../../module/planner.h" -#include "../../../MarlinCore.h" #include "../../gcode.h" /** diff --git a/Marlin/src/gcode/feature/power_monitor/M430.cpp b/Marlin/src/gcode/feature/power_monitor/M430.cpp index 6bbb475a7d..178494790d 100644 --- a/Marlin/src/gcode/feature/power_monitor/M430.cpp +++ b/Marlin/src/gcode/feature/power_monitor/M430.cpp @@ -25,7 +25,6 @@ #if HAS_POWER_MONITOR #include "../../../feature/power_monitor.h" -#include "../../../MarlinCore.h" #include "../../gcode.h" /** diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 6dab1eb3bb..c5b05583e2 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -252,7 +252,7 @@ void GcodeSuite::get_destination_from_command() { */ void GcodeSuite::dwell(const millis_t time) { const millis_t start_ms = millis(); - while (PENDING(millis(), start_ms, time)) idle(); + while (PENDING(millis(), start_ms, time)) marlin.idle(); } /** @@ -286,7 +286,7 @@ void GcodeSuite::dwell(const millis_t time) { #ifdef ACTION_ON_CANCEL hostui.cancel(); #endif - kill(GET_TEXT_F(MSG_LCD_PROBING_FAILED)); + marlin.kill(GET_TEXT_F(MSG_LCD_PROBING_FAILED)); #endif } diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index bc0d640b73..1e472e0f6e 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -58,7 +58,7 @@ void GcodeSuite::D(const int16_t dcode) { break; case 10: - kill(F("D10"), F("KILL TEST"), parser.seen_test('P')); + marlin.kill(F("D10"), F("KILL TEST"), parser.seen_test('P')); break; case 1: { diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 3cecbbca43..17bd2b1ff6 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -28,7 +28,6 @@ #include "../../module/motion.h" #include "../../lcd/marlinui.h" #include "../../libs/buzzer.h" -#include "../../MarlinCore.h" /** * M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y diff --git a/Marlin/src/gcode/host/M16.cpp b/Marlin/src/gcode/host/M16.cpp index fc41ba3322..3b4020b594 100644 --- a/Marlin/src/gcode/host/M16.cpp +++ b/Marlin/src/gcode/host/M16.cpp @@ -33,8 +33,8 @@ */ void GcodeSuite::M16() { - if (TERN(CONFIGURABLE_MACHINE_NAME, strcmp(parser.string_arg, machine_name), strcmp_P(parser.string_arg, PSTR(MACHINE_NAME)))) - kill(GET_TEXT_F(MSG_KILL_EXPECTED_PRINTER)); + if (TERN(CONFIGURABLE_MACHINE_NAME, strcmp(parser.string_arg, marlin.machine_name), strcmp_P(parser.string_arg, PSTR(MACHINE_NAME)))) + marlin.kill(GET_TEXT_F(MSG_KILL_EXPECTED_PRINTER)); } diff --git a/Marlin/src/gcode/host/M876.cpp b/Marlin/src/gcode/host/M876.cpp index c2a519d0ac..d2f7bf5ecc 100644 --- a/Marlin/src/gcode/host/M876.cpp +++ b/Marlin/src/gcode/host/M876.cpp @@ -26,7 +26,6 @@ #include "../../feature/host_actions.h" #include "../gcode.h" -#include "../../MarlinCore.h" /** * M876: Handle Prompt Response diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index c600bd5da6..81c16ebdfe 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -29,7 +29,6 @@ #include "../gcode.h" #include "../../module/planner.h" // for synchronize() -#include "../../MarlinCore.h" // for wait_for_user_response() #if HAS_MARLINUI_MENU #include "../../lcd/marlinui.h" @@ -93,7 +92,7 @@ void GcodeSuite::M0_M1() { hostui.continue_prompt(parser.codenum ? F("M1 Stop") : F("M0 Stop")); #endif - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms)); + TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response(ms)); TERN_(HAS_MARLINUI_MENU, ui.reset_status()); } diff --git a/Marlin/src/gcode/lcd/M414.cpp b/Marlin/src/gcode/lcd/M414.cpp index 4b961ad8ca..ec0fe7913f 100644 --- a/Marlin/src/gcode/lcd/M414.cpp +++ b/Marlin/src/gcode/lcd/M414.cpp @@ -25,7 +25,6 @@ #if HAS_MULTI_LANGUAGE #include "../gcode.h" -#include "../../MarlinCore.h" #include "../../lcd/marlinui.h" /** diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index e8051d2c2a..9c5dd27f0f 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -321,7 +321,7 @@ void plan_arc( const millis_t ms = millis(); if (ELAPSED(ms, next_idle_ms)) { next_idle_ms = ms + 200UL; - idle(); + marlin.idle(); } #if N_ARC_CORRECTION > 1 diff --git a/Marlin/src/gcode/motion/G5.cpp b/Marlin/src/gcode/motion/G5.cpp index fe1e664f13..64aafffba2 100644 --- a/Marlin/src/gcode/motion/G5.cpp +++ b/Marlin/src/gcode/motion/G5.cpp @@ -39,7 +39,6 @@ */ #include "../gcode.h" -#include "../../MarlinCore.h" // for IsRunning() /** * G5: Cubic B-spline diff --git a/Marlin/src/gcode/probe/G38.cpp b/Marlin/src/gcode/probe/G38.cpp index 34cab07ed6..cd10b7295d 100644 --- a/Marlin/src/gcode/probe/G38.cpp +++ b/Marlin/src/gcode/probe/G38.cpp @@ -44,7 +44,14 @@ inline void G38_single_probe(const uint8_t move_value) { sync_plan_position(); } -inline bool G38_run_probe() { +/** + * Handle G38.N where N is the sub-code for the type of probe: + * 2 - Probe toward workpiece, stop on contact, signal error if failure + * 3 - Probe toward workpiece, stop on contact + * 4 - Probe away from workpiece, stop on contact break, signal error if failure + * 5 - Probe away from workpiece, stop on contact break + */ +FORCE_INLINE bool G38_run_probe() { bool G38_pass_fail = false; diff --git a/Marlin/src/gcode/probe/M102.cpp b/Marlin/src/gcode/probe/M102.cpp index f24a723ed7..509d1c4da2 100644 --- a/Marlin/src/gcode/probe/M102.cpp +++ b/Marlin/src/gcode/probe/M102.cpp @@ -30,7 +30,6 @@ #include "../gcode.h" #include "../../feature/bedlevel/bdl/bdl.h" -#include "../../MarlinCore.h" // for printingIsActive /** * M102: Configure the Bed Distance Sensor @@ -53,7 +52,7 @@ void GcodeSuite::M102() { const int8_t command = parser.value_int(); if (command == BDS_READ_MM) SERIAL_ECHOLNPGM("Bed Distance:", bdl.read(), "mm"); - else if ((command < BDS_IDLE) && printingIsActive()) + else if ((command < BDS_IDLE) && marlin.printingIsActive()) return; else bdl.config_state = command; diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 632e3173ea..d733a0e3be 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -191,8 +191,8 @@ bool GCodeQueue::process_injected_command() { * Enqueue and return only when commands are actually enqueued. * Never call this from a G-code handler! */ -void GCodeQueue::enqueue_one_now(const char * const cmd) { while (!enqueue_one(cmd)) idle(); } -void GCodeQueue::enqueue_one_now(FSTR_P const fcmd) { while (!enqueue_one(fcmd)) idle(); } +void GCodeQueue::enqueue_one_now(const char * const cmd) { while (!enqueue_one(cmd)) marlin.idle(); } +void GCodeQueue::enqueue_one_now(FSTR_P const fcmd) { while (!enqueue_one(fcmd)) marlin.idle(); } /** * Attempt to enqueue a single G-code command @@ -520,7 +520,7 @@ void GCodeQueue::get_serial_commands() { // Movement commands give an alert when the machine is stopped // - if (IsStopped()) { + if (marlin.isStopped()) { char* gpos = strchr(command, 'G'); if (gpos) { switch (strtol(gpos + 1, nullptr, 10)) { @@ -538,8 +538,8 @@ void GCodeQueue::get_serial_commands() { #if DISABLED(EMERGENCY_PARSER) // Process critical commands early if (command[0] == 'M') switch (command[3]) { - case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_MARLINUI_MENU, wait_for_user = false); } break; - case '2': if (command[2] == '1' && command[1] == '1') kill(FPSTR(M112_KILL_STR), nullptr, true); break; + case '8': if (command[2] == '0' && command[1] == '1') { marlin.end_waiting(); } break; + case '2': if (command[2] == '1' && command[1] == '1') marlin.kill(FPSTR(M112_KILL_STR), nullptr, true); break; case '0': if (command[1] == '4' && command[2] == '1') quickstop_stepper(); break; } #endif diff --git a/Marlin/src/gcode/scara/M360-M364.cpp b/Marlin/src/gcode/scara/M360-M364.cpp index f32fa09de0..ad142a09ba 100644 --- a/Marlin/src/gcode/scara/M360-M364.cpp +++ b/Marlin/src/gcode/scara/M360-M364.cpp @@ -27,10 +27,9 @@ #include "../gcode.h" #include "../../module/scara.h" #include "../../module/motion.h" -#include "../../MarlinCore.h" // for IsRunning() inline bool SCARA_move_to_cal(const uint8_t delta_a, const uint8_t delta_b) { - if (IsRunning()) { + if (marlin.isRunning()) { forward_kinematics(delta_a, delta_b); do_blocking_move_to_xy(cartes); return true; diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index a8213f3fa1..e78e6b3c21 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -43,7 +43,6 @@ #endif #if HAS_LEDS_OFF_FLAG - #include "../../MarlinCore.h" // for wait_for_user_response() #include "../../feature/leds/printer_event_leds.h" #endif @@ -100,7 +99,7 @@ void GcodeSuite::M1001() { printerEventLEDs.onPrintCompleted(); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE))); TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_PRINT_DONE))); - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30)))); + TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30)))); printerEventLEDs.onResumeAfterWait(); } #endif diff --git a/Marlin/src/gcode/sd/M24_M25.cpp b/Marlin/src/gcode/sd/M24_M25.cpp index 9c230947a6..6eb1375db4 100644 --- a/Marlin/src/gcode/sd/M24_M25.cpp +++ b/Marlin/src/gcode/sd/M24_M25.cpp @@ -45,8 +45,6 @@ #include "../../lcd/extui/dgus/DGUSDisplayDef.h" #endif -#include "../../MarlinCore.h" // for startOrResumeJob - /** * M24: Start or Resume Media Print * @@ -76,7 +74,7 @@ void GcodeSuite::M24() { if (card.isFileOpen()) { card.startOrResumeFilePrinting(); // SD card will now be read for commands - startOrResumeJob(); // Start (or resume) the print job timer + marlin.startOrResumeJob(); // Start (or resume) the print job timer TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); } diff --git a/Marlin/src/gcode/sd/M32.cpp b/Marlin/src/gcode/sd/M32.cpp index 552a75cdf4..904dea1ebc 100644 --- a/Marlin/src/gcode/sd/M32.cpp +++ b/Marlin/src/gcode/sd/M32.cpp @@ -28,8 +28,6 @@ #include "../../sd/cardreader.h" #include "../../module/planner.h" // for synchronize() -#include "../../MarlinCore.h" // for startOrResumeJob - /** * M32: Select file and start SD Print * @@ -52,7 +50,7 @@ void GcodeSuite::M32() { card.startOrResumeFilePrinting(); // Procedure calls count as normal print time. - if (!call_procedure) startOrResumeJob(); + if (!call_procedure) marlin.startOrResumeJob(); } } diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 4e1b1aff9d..b5daa8809c 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -40,7 +40,7 @@ * included in the command, print it in the header. */ void GcodeSuite::M75() { - startOrResumeJob(); // ... ExtUI::onPrintTimerStarted() + marlin.startOrResumeJob(); // ... ExtUI::onPrintTimerStarted() #if ENABLED(DWIN_LCD_PROUI) // TODO: Remove if M75 is never used if (!card.isStillPrinting()) dwinPrintHeader(parser.has_string() ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); diff --git a/Marlin/src/inc/MarlinConfig.h b/Marlin/src/inc/MarlinConfig.h index 70f34944c9..85c9644af8 100644 --- a/Marlin/src/inc/MarlinConfig.h +++ b/Marlin/src/inc/MarlinConfig.h @@ -52,6 +52,7 @@ #include "../core/mstring.h" #include "../core/serial.h" #include "../core/endianness.h" + #include "../MarlinCore.h" #endif diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index fd45c41ba1..81063d5e2e 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -850,7 +850,7 @@ void MarlinUI::draw_status_message(const bool blink) { #if ENABLED(SHOW_REMAINING_TIME) void MarlinUI::drawRemain() { - if (printJobOngoing()) { + if (marlin.printJobOngoing()) { char buffer[8]; const duration_t remaint = get_remaining_time(); #if LCD_INFO_SCREEN_STYLE == 0 @@ -873,7 +873,7 @@ void MarlinUI::draw_status_message(const bool blink) { #if ENABLED(SHOW_INTERACTION_TIME) void MarlinUI::drawInter() { const duration_t interactt = interaction_time; - if (printingIsActive() && interactt.value) { + if (marlin.printingIsActive() && interactt.value) { char buffer[8]; #if LCD_INFO_SCREEN_STYLE == 0 const uint8_t timepos = TPOFFSET - interactt.toDigital(buffer); @@ -894,7 +894,7 @@ void MarlinUI::draw_status_message(const bool blink) { #if ENABLED(SHOW_ELAPSED_TIME) void MarlinUI::drawElapsed() { - if (printJobOngoing()) { + if (marlin.printJobOngoing()) { char buffer[8]; const duration_t elapsedt = print_job_timer.duration(); #if LCD_INFO_SCREEN_STYLE == 0 @@ -1072,7 +1072,7 @@ void MarlinUI::draw_status_screen() { #else // !HAS_DUAL_MIXING - const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, printingIsActive())); + const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, marlin.printingIsActive())); if (show_e_total) { #if ENABLED(LCD_SHOW_E_TOTAL) diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index d772447551..cdb18a74b7 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -607,7 +607,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #endif #if ENABLED(SHOW_REMAINING_TIME) void MarlinUI::drawRemain() { - if (printJobOngoing()) { + if (marlin.printJobOngoing()) { const duration_t remaint = ui.get_remaining_time(); char buffer[10]; const uint8_t timepos = TPOFFSET - remaint.toDigital(buffer); @@ -620,7 +620,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if ENABLED(SHOW_INTERACTION_TIME) void MarlinUI::drawInter() { const duration_t interactt = ui.interaction_time; - if (printingIsActive() && interactt.value) { + if (marlin.printingIsActive() && interactt.value) { char buffer[10]; const uint8_t timepos = TPOFFSET - interactt.toDigital(buffer); lcd_moveto(timepos, 1); @@ -631,7 +631,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #endif #if ENABLED(SHOW_ELAPSED_TIME) void MarlinUI::drawElapsed() { - if (printJobOngoing()) { + if (marlin.printJobOngoing()) { const duration_t elapsedt = print_job_timer.duration(); char buffer[10]; const uint8_t timepos = TPOFFSET - elapsedt.toDigital(buffer); diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 34d64df465..7fd3052772 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -506,19 +506,19 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #endif #if ENABLED(SHOW_REMAINING_TIME) void MarlinUI::drawRemain() { - if (printJobOngoing() && get_remaining_time() != 0) + if (marlin.printJobOngoing() && get_remaining_time() != 0) prepare_time_string(get_remaining_time(), 'R'); } #endif #if ENABLED(SHOW_INTERACTION_TIME) void MarlinUI::drawInter() { - if (printingIsActive() && interaction_time) + if (marlin.printingIsActive() && interaction_time) prepare_time_string(interaction_time, 'C'); } #endif #if ENABLED(SHOW_ELAPSED_TIME) void MarlinUI::drawElapsed() { - if (printJobOngoing()) + if (marlin.printJobOngoing()) prepare_time_string(print_job_timer.duration(), 'E'); } #endif @@ -549,7 +549,7 @@ void MarlinUI::draw_status_screen() { static char wstring[5], mstring[4]; #endif - const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, printingIsActive())); + const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, marlin.printingIsActive())); #if HAS_PRINT_PROGRESS static u8g_uint_t progress_bar_solid_width = 0; diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index 703c18515a..af0330402c 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -611,7 +611,7 @@ void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool // If position is unknown, flash the labels. const unsigned char alt_label = position_trusted ? 0 : (ui.get_blink() ? ' ' : 0); - if (TERN0(LCD_SHOW_E_TOTAL, printingIsActive())) { + if (TERN0(LCD_SHOW_E_TOTAL, marlin.printingIsActive())) { #if ENABLED(LCD_SHOW_E_TOTAL) char tmp[15]; const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // After 100m switch to cm @@ -694,7 +694,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { void MarlinUI::drawRemain() { lightUI.drawRemain(); } void ST7920_Lite_Status_Screen::drawRemain() { const duration_t remaint = TERN0(SET_REMAINING_TIME, ui.get_remaining_time()); - if (printJobOngoing() && remaint.value) { + if (marlin.printJobOngoing() && remaint.value) { draw_progress_string(PPOS, prepare_time_string(remaint, 'R')); } } @@ -703,7 +703,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { void MarlinUI::drawInter() { lightUI.drawInter(); } void ST7920_Lite_Status_Screen::drawInter() { const duration_t interactt = ui.interaction_time; - if (printingIsActive() && interactt.value) { + if (marlin.printingIsActive() && interactt.value) { draw_progress_string(PPOS, prepare_time_string(interactt, 'C')); } } @@ -711,7 +711,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { #if ENABLED(SHOW_ELAPSED_TIME) void MarlinUI::drawElapsed() { lightUI.drawElapsed(); } void ST7920_Lite_Status_Screen::drawElapsed() { - if (printJobOngoing()) { + if (marlin.printJobOngoing()) { const duration_t elapsedt = print_job_timer.duration(); draw_progress_string(PPOS, prepare_time_string(elapsedt, 'E')); } diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index 2ae16f8bb1..2f050e92fd 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -68,8 +68,8 @@ EncoderState encoderReceiveAnalyze() { ui.refresh_brightness(); return ENCODER_DIFF_NO; } - const bool was_waiting = wait_for_user; - wait_for_user = false; + const bool was_waiting = marlin.wait_for_user; + marlin.user_resume(); return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER; } else return ENCODER_DIFF_NO; diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index affb4695f9..875dfd5fd1 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -312,7 +312,7 @@ void iconResume() { } void iconResumeOrPause() { - if (printingIsPaused() || hmiFlag.pause_flag || hmiFlag.pause_action) + if (marlin.printingIsPaused() || hmiFlag.pause_flag || hmiFlag.pause_action) iconResume(); else iconPause(); @@ -1982,11 +1982,11 @@ void hmiSDCardUpdate() { if (checkkey == ID_SelectFile) { redrawSDList(); } - else if (checkkey == ID_PrintProcess || checkkey == ID_Tune || printingIsActive()) { + else if (checkkey == ID_PrintProcess || checkkey == ID_Tune || marlin.printingIsActive()) { // TODO: Move card removed abort handling // to CardReader::manage_media. card.abortFilePrintSoon(); - wait_for_heatup = wait_for_user = false; + marlin.end_waiting(); dwin_abort_flag = true; // Reset feedrate, return to Home } } @@ -2389,7 +2389,7 @@ void hmiPauseOrStop() { else if (select_print.now == PRINT_STOP) { if (hmiFlag.select_flag) { checkkey = ID_BackMain; - wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user + marlin.end_waiting(); // 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 @@ -4141,15 +4141,15 @@ void eachMomentUpdate() { dwinDrawRectangle(1, COLOR_BG_BLACK, 0, 250, DWIN_WIDTH - 1, STATUS_Y); dwinIconShow(ICON, hmiIsChinese() ? ICON_Confirm_C : ICON_Confirm_E, 86, 283); } - else if (hmiFlag.pause_flag != printingIsPaused()) { + else if (hmiFlag.pause_flag != marlin.printingIsPaused()) { // print status update - hmiFlag.pause_flag = printingIsPaused(); + hmiFlag.pause_flag = marlin.printingIsPaused(); iconResumeOrPause(); } } // pause after homing - if (hmiFlag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) { + if (hmiFlag.pause_action && marlin.printingIsPaused() && !planner.has_blocks_queued()) { hmiFlag.pause_action = false; #if ENABLED(PAUSE_HEAT) TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.degTargetHotend(0)); diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 557a8f0c7c..1ddd54904d 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -4595,7 +4595,7 @@ void JyersDWIN::printScreenControl() { case PRINT_PAUSE_RESUME: if (paused) { if (sdprint) { - wait_for_user = false; + marlin.user_resume(); #if ENABLED(PARK_HEAD_ON_PAUSE) card.startOrResumeFilePrinting(); TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); @@ -4780,15 +4780,15 @@ void JyersDWIN::confirmControl() { break; case Popup_FilInsert: popupHandler(Popup_FilChange); - wait_for_user = false; + marlin.user_resume(); break; case Popup_HeaterTime: popupHandler(Popup_Heating); - wait_for_user = false; + marlin.user_resume(); break; default: redrawMenu(true, true, false); - wait_for_user = false; + marlin.user_resume(); break; } } @@ -4935,7 +4935,7 @@ void JyersDWIN::stateUpdate() { if (process == Proc_Print) printScreenIcons(); if (process == Proc_Wait && !paused) redrawMenu(true, true); } - if (wait_for_user && !(process == Proc_Confirm) && !print_job_timer.isPaused()) + if (marlin.wait_for_user && !(process == Proc_Confirm) && !print_job_timer.isPaused()) confirmHandler(Popup_UserInput); #if ENABLED(ADVANCED_PAUSE_FEATURE) if (process == Proc_Popup && popup == Popup_PurgeMore) { diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 798a3b2e44..dbeb02dc67 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -308,7 +308,7 @@ void MarlinUI::draw_status_screen() { // Axis values const xyz_pos_t lpos = current_position.asLogical(); - const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, printingIsActive())); + const bool show_e_total = TERN1(HAS_X_AXIS, TERN0(LCD_SHOW_E_TOTAL, marlin.printingIsActive())); constexpr int16_t cpy = TERN(DWIN_MARLINUI_PORTRAIT, 195, 117); if (show_e_total) { diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index a82e055acf..baf95d942f 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -39,7 +39,6 @@ #include "../../utf8.h" #include "../../marlinui.h" #include "../../extui/ui_api.h" -#include "../../../MarlinCore.h" #include "../../../module/temperature.h" #include "../../../module/printcounter.h" #include "../../../module/motion.h" @@ -294,7 +293,7 @@ MenuItem *fanSpeedItem = nullptr; MenuItem *mMeshMoveZItem = nullptr; MenuItem *editZValueItem = nullptr; -bool isPrinting() { return printingIsActive() || printingIsPaused(); } +bool isPrinting() { return marlin.printingIsActive() || marlin.printingIsPaused(); } bool sdPrinting() { return isPrinting() && card.isStillPrinting(); } bool hostPrinting() { return isPrinting() && !card.isStillPrinting(); } @@ -668,7 +667,7 @@ void drawPrintDone() { } void gotoPrintDone() { - wait_for_user = true; + marlin.wait_start(); if (checkkey != ID_PrintDone) { checkkey = ID_PrintDone; drawPrintDone(); @@ -1214,7 +1213,7 @@ void hmiPrinting() { switch (select_print.now) { case PRINT_SETUP: drawTuneMenu(); break; case PRINT_PAUSE_RESUME: - if (printingIsPaused()) { // If printer is already in pause + if (marlin.printingIsPaused()) { // If printer is already in pause ExtUI::resumePrint(); break; } @@ -1275,7 +1274,7 @@ void hmiWaitForUser() { hmiReturnScreen(); return; } - if (!wait_for_user) { + if (!marlin.wait_for_user) { switch (checkkey) { case ID_PrintDone: select_page.reset(); gotoMainMenu(); break; default: ui.reset_status(true); hmiReturnScreen(); break; @@ -1366,8 +1365,8 @@ void eachMomentUpdate() { dwinPrintFinished(); } - if ((hmiFlag.pause_flag != printingIsPaused()) && !hmiFlag.home_flag) { - hmiFlag.pause_flag = printingIsPaused(); + if ((hmiFlag.pause_flag != marlin.printingIsPaused()) && !hmiFlag.home_flag) { + hmiFlag.pause_flag = marlin.printingIsPaused(); if (hmiFlag.pause_flag) dwinPrintPause(); else if (hmiFlag.abort_flag) @@ -1517,14 +1516,14 @@ void hmiSaveProcessID(const uint8_t id) { TERN_(HAS_BED_PROBE, case ID_Leveling:) TERN_(HAS_ESDIAG, case ID_ESDiagProcess:) TERN_(PROUI_ITEM_PLOT, case ID_PlotProcess:) - wait_for_user = true; + marlin.wait_start(); default: break; } } void hmiReturnScreen() { checkkey = last_checkkey; - wait_for_user = false; + marlin.user_resume(); drawMainArea(); } @@ -1823,7 +1822,7 @@ void dwinPrintFinished() { TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel()); hmiFlag.abort_flag = false; hmiFlag.pause_flag = false; - wait_for_heatup = false; + marlin.heatup_done(); planner.finish_and_disable(); thermalManager.cooldown(); gotoPrintDone(); @@ -1960,9 +1959,9 @@ void MarlinUI::update() { void MarlinUI::_set_brightness() { dwinLCDBrightness(backlight ? brightness : 0); if (!backlight) - wait_for_user = true; + marlin.wait_start(); else if (checkkey != ID_PrintDone) - wait_for_user = false; + marlin.user_resume(); } #endif @@ -2133,7 +2132,7 @@ void gotoConfirmToPrint() { // Reset Printer void rebootPrinter() { - wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user + marlin.end_waiting(); // Stop waiting for heating/user thermalManager.disable_all_heaters(); planner.finish_and_disable(); dwinRebootScreen(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp index d499151e3f..f0ed1a6c07 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -79,7 +79,7 @@ void gotoPopup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick/*=nu } void hmiPopup() { - if (!wait_for_user) { + if (!marlin.wait_for_user) { if (popupClick) popupClick(); return; } diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index 9ad098f149..ddd73d72b5 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -191,7 +191,7 @@ bool Preview::hasPreview() { void Preview::drawFromSD() { if (!hasPreview()) { hmiFlag.select_flag = 1; - wait_for_user = false; + marlin.user_resume(); return; } diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index b4e1978283..6de7683843 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -612,7 +612,7 @@ void ChironTFT::panelAction(uint8_t req) { break; case 12: // A12 Kill printer - kill(); // from marlincore.h + marlin.kill(); // from MarlinCore.h break; case 13: // A13 Select file 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 8930cc37c2..bc212bf42c 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -627,7 +627,7 @@ void AnycubicTFT::getCommandFromTFT() { break; case 12: // A12 kill - kill(F(STR_ERR_KILLED)); + marlin.kill(F(STR_ERR_KILLED)); break; case 13: // A13 SELECTION FILE diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp index f4c7db544b..2cf8193c74 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp @@ -213,7 +213,7 @@ void DGUSScreenHandler::handleManualMove(DGUS_VP_Variable &var, void *val_ptr) { snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed); queue.enqueue_one_now(buf); } - //while (!enqueue_and_echo_command(buf)) idle(); + //while (!enqueue_and_echo_command(buf)) marlin.idle(); if (!old_relative_mode) queue.enqueue_now(F("G90")); } diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp index a62d3a2ffc..f718ee16af 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp @@ -215,7 +215,7 @@ void DGUSScreenHandler::handleManualMove(DGUS_VP_Variable &var, void *val_ptr) { snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed); queue.enqueue_one_now(buf); } - //while (!enqueue_and_echo_command(buf)) idle(); + //while (!enqueue_and_echo_command(buf)) marlin.idle(); if (!old_relative_mode) queue.enqueue_now(F("G90")); } diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 2965d75da3..d39c3079be 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -28,7 +28,6 @@ #include "../../../../inc/MarlinConfig.h" -#include "../../../../MarlinCore.h" #include "../../../../module/settings.h" #include "../../../../module/temperature.h" #include "../../../../module/motion.h" @@ -287,7 +286,7 @@ void DGUSScreenHandler::screenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { // can change any page to use this function and it will check whether a print // job is active. If so DGUS will go to the printing page to continue the job. // - //if (printJobOngoing() || printingIsPaused()) { + //if (marlin.printJobOngoing() || marlin.printingIsPaused()) { // if (target == MKSLCD_PAUSE_SETTING_MOVE || target == MKSLCD_PAUSE_SETTING_EX // || target == MKSLCD_SCREEN_PRINT || target == MKSLCD_SCREEN_PAUSE // ) { @@ -321,7 +320,7 @@ void DGUSScreenHandlerMKS::screenBackChange(DGUS_VP_Variable &var, void *val_ptr void DGUSScreenHandlerMKS::zOffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) { settings.save(); - if (printJobOngoing()) + if (marlin.printJobOngoing()) gotoScreen(MKSLCD_SCREEN_PRINT); else if (print_job_timer.isPaused) gotoScreen(MKSLCD_SCREEN_PAUSE); @@ -1192,7 +1191,7 @@ bool DGUSScreenHandlerMKS::loop() { } #if ENABLED(DGUS_MKS_RUNOUT_SENSOR) - if (booted && printingIsActive()) runoutIdle(); + if (booted && marlin.printingIsActive()) runoutIdle(); #endif #endif // SHOW_BOOTSCREEN diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp index ac73c8cf65..f577047e3a 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp @@ -215,7 +215,7 @@ void DGUSScreenHandler::handleManualMove(DGUS_VP_Variable &var, void *val_ptr) { snprintf_P(buf, 32, PSTR("G0 F%d"), backup_speed); queue.enqueue_one_now(buf); } - //while (!enqueue_and_echo_command(buf)) idle(); + //while (!enqueue_and_echo_command(buf)) marlin.idle(); if (!old_relative_mode) queue.enqueue_now(F("G90")); } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp index bb31a1d71a..ae9b00feb1 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp @@ -117,7 +117,7 @@ void DGUSScreenHandler::loop() { } if (current_screenID == DGUS_ScreenID::WAIT - && ((wait_continue && !wait_for_user) || (!wait_continue && isPrinterIdle())) + && ((wait_continue && !marlin.wait_for_user) || (!wait_continue && isPrinterIdle())) ) { moveToScreen(wait_return_screenID, true); return; @@ -453,7 +453,7 @@ void DGUSScreenHandler::moveToScreen(const DGUS_ScreenID screenID, bool abort_wa if (!abort_wait) return; - if (wait_continue && wait_for_user) + if (wait_continue && marlin.wait_for_user) ExtUI::setUserConfirmed(); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h index a9f77a518b..08f8ca0d8f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h @@ -27,6 +27,8 @@ #define FTDI_EXTENDED #endif + #define safe_delay safe_delay + #else // !__MARLIN_FIRMWARE__ #include diff --git a/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp b/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp index ca372e12f2..ca0a22d391 100644 --- a/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp +++ b/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp @@ -100,7 +100,7 @@ void RTS::onStartup() { delay_ms(400); // Delay to allow screen to configure #if ENABLED(CONFIGURABLE_MACHINE_NAME) - const MString<32> ready(machine_name, " Ready"); + const MString<32> ready(marlin.machine_name, " Ready"); onStatusChanged(ready); #else onStatusChanged(F(MACHINE_NAME " Ready")); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp index 1989724370..5be5e96e13 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp @@ -112,7 +112,7 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) { #endif } else if (DIALOG_IS(TYPE_STOP)) { - wait_for_heatup = false; + marlin.heatup_done(); stop_print_time(); lv_clear_dialog(); lv_draw_ready_print(); @@ -129,7 +129,7 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) { } #if ENABLED(ADVANCED_PAUSE_FEATURE) else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT)) - wait_for_user = false; + marlin.user_resume(); else if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp index ee913d6465..0027ee6194 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp @@ -27,7 +27,7 @@ #include "draw_ui.h" #include -#include "../../../MarlinCore.h" // for marlin_state +#include "../../../MarlinCore.h" // for is, setState #include "../../../module/temperature.h" #include "../../../module/motion.h" #include "../../../sd/cardreader.h" @@ -294,7 +294,7 @@ void setProBarRate() { lv_label_set_text(bar1ValueText, public_buf_l); lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0); - if (marlin_state == MarlinState::MF_SD_COMPLETE) { + if (marlin.is(MarlinState::MF_SD_COMPLETE)) { if (once_flag == 0) { stop_print_time(); @@ -309,7 +309,7 @@ void setProBarRate() { if (gCfgItems.finish_power_off) { gcode.process_subcommands_now(F("M1001")); queue.inject(F("M81")); - marlin_state = MarlinState::MF_RUNNING; + marlin.setState(MarlinState::MF_RUNNING); } #endif } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_set.cpp b/Marlin/src/lcd/extui/mks_ui/draw_set.cpp index f991b615f6..4e6775bb6a 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_set.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_set.cpp @@ -57,7 +57,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { if (event != LV_EVENT_RELEASED) return; if (obj->mks_obj_id == ID_S_CONTINUE) return; if (obj->mks_obj_id == ID_S_MOTOR_OFF) { - TERN(HAS_SUICIDE, suicide(), queue.enqueue_now(F("M84"))); + TERN(HAS_SUICIDE, marlin.suicide(), queue.enqueue_now(F("M84"))); return; } lv_clear_set(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 2779db5b02..8f91279e8c 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -34,7 +34,7 @@ #include -#include "../../../MarlinCore.h" // for marlin_state +#include "../../../MarlinCore.h" // for marlin.is() #include "../../../sd/cardreader.h" #include "../../../module/motion.h" #include "../../../module/planner.h" @@ -757,7 +757,7 @@ void GUI_RefreshPage() { disp_print_time(); disp_fan_Zpos(); } - if (printing_rate_update_flag || marlin_state == MarlinState::MF_SD_COMPLETE) { + if (printing_rate_update_flag || marlin.is(MarlinState::MF_SD_COMPLETE)) { printing_rate_update_flag = false; if (!gcode_preview_over) setProBarRate(); } diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index 31f08d2852..8a83ff62c0 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -2081,7 +2081,7 @@ void get_wifi_commands() { while (*command == ' ') command++; // skip any leading spaces // Movement commands alert when stopped - if (IsStopped()) { + if (marlin.isStopped()) { char* gpos = strchr(command, 'G'); if (gpos) { switch (strtol(gpos + 1, nullptr, 10)) { @@ -2097,11 +2097,8 @@ void get_wifi_commands() { #if DISABLED(EMERGENCY_PARSER) // Process critical commands early - if (strcmp_P(command, PSTR("M108")) == 0) { - wait_for_heatup = false; - TERN_(HAS_MARLINUI_MENU, wait_for_user = false); - } - if (strcmp_P(command, PSTR("M112")) == 0) kill(FPSTR(M112_KILL_STR), nullptr, true); + if (strcmp_P(command, PSTR("M108")) == 0) marlin.end_waiting(); + if (strcmp_P(command, PSTR("M112")) == 0) marlin.kill(FPSTR(M112_KILL_STR), nullptr, true); if (strcmp_P(command, PSTR("M410")) == 0) quickstop_stepper(); #endif diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index 53af67f3d9..93b2ce5144 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -67,7 +67,7 @@ void NextionTFT::startup() { SEND_TXT("tmppage.compiled", __DATE__ " / " __TIME__); SEND_VALasTXT("tmppage.extruder", EXTRUDERS); #if ENABLED(CONFIGURABLE_MACHINE_NAME) - SEND_VALasTXT("tmppage.printer", &machine_name); + SEND_VALasTXT("tmppage.printer", &marlin.machine_name); #else SEND_TXT("tmppage.printer", MACHINE_NAME); #endif @@ -230,7 +230,7 @@ void NextionTFT::panelInfo(uint8_t req) { SEND_TXT("tmppage.compiled", __DATE__ " / " __TIME__); SEND_VALasTXT("tmppage.extruder", EXTRUDERS); #if ENABLED(CONFIGURABLE_MACHINE_NAME) - SEND_VALasTXT("tmppage.printer", &machine_name); + SEND_VALasTXT("tmppage.printer", &marlin.machine_name); #else SEND_TXT("tmppage.printer", MACHINE_NAME); #endif diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 0e8a84bf5b..2f96d08c10 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -1021,9 +1021,9 @@ namespace ExtUI { void coolDown() { thermalManager.cooldown(); } bool awaitingUserConfirm() { - return TERN0(HAS_RESUME_CONTINUE, wait_for_user) || TERN0(HOST_KEEPALIVE_FEATURE, getHostKeepaliveIsPaused()); + return TERN0(HAS_RESUME_CONTINUE, marlin.wait_for_user) || TERN0(HOST_KEEPALIVE_FEATURE, getHostKeepaliveIsPaused()); } - void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); } + void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, marlin.user_resume()); } #if ENABLED(ADVANCED_PAUSE_FEATURE) void setPauseMenuResponse(PauseMenuResponse response) { pause_menu_response = response; } @@ -1068,7 +1068,7 @@ namespace ExtUI { bool isPrintingFromMediaPaused() { return card.isPaused(); } bool isPrinting() { - return commandsInQueue() || isPrintingFromMedia() || printJobOngoing() || printingIsPaused(); + return commandsInQueue() || isPrintingFromMedia() || marlin.printJobOngoing() || marlin.printingIsPaused(); } bool isPrintingPaused() { @@ -1076,7 +1076,7 @@ namespace ExtUI { } bool isOngoingPrintJob() { - return isPrintingFromMedia() || printJobOngoing(); + return isPrintingFromMedia() || marlin.printJobOngoing(); } bool isMediaMounted() { return card.isMounted(); } @@ -1112,7 +1112,7 @@ namespace ExtUI { void onSurviveInKilled() { thermalManager.disable_all_heaters(); flags.printer_killed = 0; - marlin_state = MarlinState::MF_RUNNING; + marlin.setState(MarlinState::MF_RUNNING); //SERIAL_ECHOLNPGM("survived at: ", millis()); } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 8a6d18dc2d..b9f7749c97 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -22,7 +22,6 @@ #include "../inc/MarlinConfig.h" -#include "../MarlinCore.h" // for printingIsPaused, machine_name #include "../gcode/parser.h" // for axis_is_rotational, using_inch_units #if HAS_LED_POWEROFF_TIMEOUT || ALL(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) || (HAS_BACKLIGHT_TIMEOUT && defined(NEOPIXEL_BKGD_INDEX_FIRST)) @@ -994,8 +993,8 @@ void MarlinUI::init() { // Ignore the click when clearing wait_for_user or waking the screen. auto do_click = [&]{ wait_for_unclick = true; - lcd_clicked = !wait_for_user && !display_is_asleep(); - wait_for_user = false; + lcd_clicked = !marlin.wait_for_user && !display_is_asleep(); + marlin.user_resume(); quick_feedback(); }; @@ -1562,7 +1561,7 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, */ void MarlinUI::reset_status(const bool no_welcome) { FSTR_P msg; - if (printingIsPaused()) + if (marlin.printingIsPaused()) msg = GET_TEXT_F(MSG_PRINT_PAUSED); #if HAS_MEDIA else if (card.isStillPrinting()) @@ -1584,7 +1583,7 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, else if (!no_welcome) { #if ENABLED(CONFIGURABLE_MACHINE_NAME) char new_status[MAX_MESSAGE_SIZE + 1]; - expand_u8str_P(new_status, GET_TEXT(WELCOME_MSG), 0, &machine_name); + expand_u8str_P(new_status, GET_TEXT(WELCOME_MSG), 0, &marlin.machine_name); _set_status_and_level(new_status, -1); return; #else @@ -1761,13 +1760,9 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, #if HAS_DISPLAY - #if HAS_MEDIA - extern bool wait_for_user, wait_for_heatup; - #endif - void MarlinUI::abort_print() { #if HAS_MEDIA - wait_for_heatup = wait_for_user = false; + marlin.end_waiting(); if (card.isStillPrinting()) card.abortFilePrintSoon(); else if (card.isMounted()) @@ -1834,7 +1829,7 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind, void MarlinUI::resume_print() { reset_status(); - TERN_(PARK_HEAD_ON_PAUSE, wait_for_heatup = wait_for_user = false); + TERN_(PARK_HEAD_ON_PAUSE, marlin.end_waiting()); TERN_(HAS_MEDIA, if (card.isPaused()) queue.inject_P(M24_STR)); #ifdef ACTION_ON_RESUME hostui.resume(); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index fa3f748b8e..0ef1ed1b3f 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -684,7 +684,7 @@ void menu_backlash(); void menu_advanced_settings() { #if ANY(POLARGRAPH, SHAPING_MENU, HAS_BED_PROBE, EDITABLE_STEPS_PER_UNIT) - const bool is_busy = printer_busy(); + const bool is_busy = marlin.printer_busy(); #endif #if ENABLED(SD_FIRMWARE_UPDATE) diff --git a/Marlin/src/lcd/menu/menu_bed_tramming.cpp b/Marlin/src/lcd/menu/menu_bed_tramming.cpp index 6302faf5b2..01de15f800 100644 --- a/Marlin/src/lcd/menu/menu_bed_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_bed_tramming.cpp @@ -270,7 +270,7 @@ static void _lcd_goto_next_corner() { endstops.hit_on_purpose(); TERN_(BED_TRAMMING_AUDIO_FEEDBACK, BUZZ(200, 600)); } - idle(); + marlin.idle(); } TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.stow()); ui.goto_screen(_lcd_draw_probing); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index d2849ccd1b..cf1a5996f0 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -575,7 +575,7 @@ void menu_advanced_settings(); #endif // CUSTOM_MENU_CONFIG void menu_configuration() { - const bool busy = printer_busy(); + const bool busy = marlin.printer_busy(); START_MENU(); BACK_ITEM(MSG_MAIN_MENU); diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index 5fae531e4a..a0e60bae26 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -67,7 +67,7 @@ void _man_probe_pt(const xy_pos_t &xy) { ui.defer_status_screen(); TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_DELTA_CALIBRATION_IN_PROGRESS))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_DELTA_CALIBRATION_IN_PROGRESS))); - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); + TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response()); ui.goto_previous_screen_no_defer(); return current_position.z; } diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 8d6e1b8adb..d2d6342185 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -35,7 +35,7 @@ #if HAS_FILAMENT_SENSOR #include "../../feature/runout.h" #endif -#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) +#if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) #include "../../MarlinCore.h" #endif @@ -110,14 +110,10 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { /** * "Change Filament" submenu */ -#if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - bool printingIsPaused(); -#endif - void menu_change_filament() { #if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) // Say "filament change" when no print is active - editable.int8 = printingIsPaused() ? PAUSE_MODE_PAUSE_PRINT : PAUSE_MODE_CHANGE_FILAMENT; + editable.int8 = marlin.printingIsPaused() ? PAUSE_MODE_PAUSE_PRINT : PAUSE_MODE_CHANGE_FILAMENT; #if E_STEPPERS > 1 && ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS) bool too_cold = false; @@ -126,7 +122,7 @@ void menu_change_filament() { #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - const bool is_busy = printer_busy(); + const bool is_busy = marlin.printer_busy(); #endif START_MENU(); diff --git a/Marlin/src/lcd/menu/menu_info.cpp b/Marlin/src/lcd/menu/menu_info.cpp index 31d83bd873..fb1f0fe76c 100644 --- a/Marlin/src/lcd/menu/menu_info.cpp +++ b/Marlin/src/lcd/menu/menu_info.cpp @@ -251,7 +251,7 @@ void menu_info_board() { STATIC_ITEM_F(F(SHORT_BUILD_VERSION)); // x.x.x-Branch STATIC_ITEM_F(F(STRING_DISTRIBUTION_DATE)); // YYYY-MM-DD HH:MM #if ENABLED(CONFIGURABLE_MACHINE_NAME) - STATIC_ITEM_C(&machine_name, SS_DEFAULT|SS_INVERT); // My3DPrinter + STATIC_ITEM_C(&marlin.machine_name, SS_DEFAULT|SS_INVERT); // My3DPrinter #else STATIC_ITEM_F(F(MACHINE_NAME), SS_DEFAULT|SS_INVERT); // My3DPrinter #endif diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index c3544f3c67..ec680665bf 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -413,8 +413,7 @@ class MenuItem_bool : public MenuEditItemBase { #define STATIC_ITEM_C(CSTR, V...) STATIC_ITEM_N_F_C(0, F("$"), CSTR, ##V) -// PSTRING_ITEM is like STATIC_ITEM -// but also takes a PSTR and style. +// PSTRING_ITEM is like STATIC_ITEM but also takes a PSTR and style. #define PSTRING_ITEM_F_P(FLABEL, PVAL, STYL) do{ \ constexpr int m = 20; \ diff --git a/Marlin/src/lcd/menu/menu_language.cpp b/Marlin/src/lcd/menu/menu_language.cpp index c92b860950..d406bec694 100644 --- a/Marlin/src/lcd/menu/menu_language.cpp +++ b/Marlin/src/lcd/menu/menu_language.cpp @@ -29,7 +29,6 @@ #if HAS_MENU_MULTI_LANGUAGE #include "menu_item.h" -#include "../../MarlinCore.h" #include "../../module/settings.h" static void set_lcd_language(const uint8_t inlang) { diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 13fe4e89e2..f89aa5f741 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -246,7 +246,7 @@ void menu_configuration(); #endif // CUSTOM_MENU_MAIN void menu_main() { - const bool busy = printingIsActive(); + const bool busy = marlin.printingIsActive(); #if HAS_MEDIA const bool card_is_mounted = card.isMounted(), card_open = card_is_mounted && card.isFileOpen(); @@ -410,7 +410,7 @@ void menu_main() { INJECT_MENU_ITEMS(media_menu_items()); #endif - if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) + if (TERN0(MACHINE_CAN_PAUSE, marlin.printingIsPaused())) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print); #if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START) diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index 332f96ffe2..7e725bd20c 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -24,8 +24,6 @@ #if ENABLED(MMU_MENUS) -#include "../../MarlinCore.h" - #if HAS_PRUSA_MMU3 #include "../../feature/mmu3/mmu3.h" #include "../../feature/mmu3/mmu3_reporting.h" @@ -101,7 +99,7 @@ void action_mmu2_unload_filament() { LCD_MESSAGE(MSG_MMU2_UNLOADING_FILAMENT); while (!TERN(HAS_PRUSA_MMU3, mmu3.unload(), mmu2.unload())) { safe_delay(50); - TERN(HAS_PRUSA_MMU3, MMU3::marlin_idle(true), idle()); + TERN(HAS_PRUSA_MMU3, MMU3::marlin_idle(true), marlin.idle()); } ui.reset_status(); } @@ -154,7 +152,7 @@ void menu_mmu3_fail_stats_last_print() { sprintf_P(buffer2, PSTR("%hu"), load_fail_num); START_SCREEN(); - STATIC_ITEM_F(printJobOngoing() ? GET_TEXT_F(MSG_MMU_CURRENT_PRINT_FAILURES) : GET_TEXT_F(MSG_MMU_LAST_PRINT_FAILURES), SS_INVERT); + STATIC_ITEM_F(marlin.printJobOngoing() ? GET_TEXT_F(MSG_MMU_CURRENT_PRINT_FAILURES) : GET_TEXT_F(MSG_MMU_LAST_PRINT_FAILURES), SS_INVERT); #ifndef __AVR__ // TODO: I couldn't make this work on AVR PSTRING_ITEM(MSG_MMU_FAILS, buffer1, SS_FULL); @@ -216,7 +214,7 @@ void menu_mmu3_toolchange_stat_total() { STATIC_ITEM(MSG_MMU_MATERIAL_CHANGES, SS_INVERT); #ifndef __AVR__ // TODO: I couldn't make this work on AVR - if (printJobOngoing()) + if (marlin.printJobOngoing()) PSTRING_ITEM(MSG_MMU_CURRENT_PRINT, buffer1, SS_FULL); else PSTRING_ITEM(MSG_MMU_LAST_PRINT, buffer1, SS_FULL); @@ -233,7 +231,7 @@ void menu_mmu3_statistics() { ACTION_ITEM(MSG_MMU_DEV_INCREMENT_LOAD_FAILS, menu_mmu3_dev_increment_load_fail_stat); #endif - SUBMENU_F(printJobOngoing() ? GET_TEXT_F(MSG_MMU_CURRENT_PRINT_FAILURES) : GET_TEXT_F(MSG_MMU_LAST_PRINT_FAILURES), menu_mmu3_fail_stats_last_print); + SUBMENU_F(marlin.printJobOngoing() ? GET_TEXT_F(MSG_MMU_CURRENT_PRINT_FAILURES) : GET_TEXT_F(MSG_MMU_LAST_PRINT_FAILURES), menu_mmu3_fail_stats_last_print); SUBMENU(MSG_MMU_TOTAL_FAILURES, menu_mmu3_fail_stas_total); SUBMENU(MSG_MMU_MATERIAL_CHANGES, menu_mmu3_toolchange_stat_total); CONFIRM_ITEM(MSG_MMU_RESET_FAIL_STATS, @@ -269,7 +267,7 @@ void action_mmu2_reset() { } void menu_mmu2() { - const bool busy = printJobOngoing(); // printingIsActive(); + const bool busy = marlin.printJobOngoing(); // printingIsActive() START_MENU(); BACK_ITEM(MSG_MAIN_MENU); @@ -377,14 +375,14 @@ void mmu2_M600(const bool automatic/*=false*/) { ui.defer_status_screen(); ui.goto_screen(menu_mmu2_pause); wait_for_mmu_menu = true; - while (wait_for_mmu_menu) idle(); + while (wait_for_mmu_menu) marlin.idle(); } uint8_t mmu2_choose_filament() { ui.defer_status_screen(); ui.goto_screen(menu_mmu2_choose_filament); wait_for_mmu_menu = true; - while (wait_for_mmu_menu) idle(); + while (wait_for_mmu_menu) marlin.idle(); ui.return_to_status(); return feeder_index; } diff --git a/Marlin/src/lcd/sovol_rts/sovol_rts.cpp b/Marlin/src/lcd/sovol_rts/sovol_rts.cpp index c982a2cc32..b79d9541a8 100644 --- a/Marlin/src/lcd/sovol_rts/sovol_rts.cpp +++ b/Marlin/src/lcd/sovol_rts/sovol_rts.cpp @@ -38,7 +38,6 @@ RTS rts; #include #include #include -#include "../../MarlinCore.h" #include "../../sd/cardreader.h" #include "../../module/temperature.h" #include "../../module/planner.h" @@ -518,7 +517,7 @@ void RTS::sdCardStop() { updateTempE0(); updateTempBed(); thermalManager.zero_fan_speeds(); - wait_for_heatup = wait_for_user = false; + marlin.end_waiting(); poweroff_continue = false; #if ALL(HAS_MEDIA, POWER_LOSS_RECOVERY) if (card.flag.mounted) card.removeJobRecoveryFile(); @@ -1102,7 +1101,7 @@ void RTS::handleData() { } #endif - wait_for_heatup = wait_for_user = false; + marlin.end_waiting(); print_state = 0; break; } @@ -1364,7 +1363,7 @@ void RTS::handleData() { case 1: if (FILAMENT_IS_OUT()) break; case 2: updateTempE0(); - wait_for_heatup = wait_for_user = false; + marlin.end_waiting(); break; case 3: pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; break; case 4: pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; break; @@ -1617,7 +1616,7 @@ void RTS::onIdle() { } } - if (pause_action_flag && !sdcard_pause_check && printingIsPaused() && !planner.has_blocks_queued()) { + if (pause_action_flag && !sdcard_pause_check && marlin.printingIsPaused() && !planner.has_blocks_queued()) { pause_action_flag = false; queue.enqueue_now(F("G0 F3000 X0 Y0\nM18 S0")); } diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index cefd7cb779..de664695e6 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -53,9 +53,6 @@ TouchControlType Touch::touch_control_type = NONE; #if HAS_DISPLAY_SLEEP millis_t Touch::next_sleep_ms; // = 0 #endif -#if HAS_RESUME_CONTINUE - extern bool wait_for_user; -#endif void Touch::init() { TERN_(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration_reset()); @@ -91,10 +88,10 @@ void Touch::idle() { #if HAS_RESUME_CONTINUE // UI is waiting for a click anywhere? - if (wait_for_user) { + if (marlin.wait_for_user) { touch_control_type = CLICK; ui.lcd_clicked = true; - if (ui.external_control) wait_for_user = false; + if (ui.external_control) marlin.user_resume(); return; } #endif @@ -203,7 +200,7 @@ void Touch::touch(touch_control_t * const control) { // Specifically, Click to Continue #if HAS_RESUME_CONTINUE - case RESUME_CONTINUE: extern bool wait_for_user; wait_for_user = false; break; + case RESUME_CONTINUE: marlin.user_resume(); break; #endif // Page Up button diff --git a/Marlin/src/lcd/tft/ui_color_ui.cpp b/Marlin/src/lcd/tft/ui_color_ui.cpp index 3287285f69..a81ff3ccc6 100644 --- a/Marlin/src/lcd/tft/ui_color_ui.cpp +++ b/Marlin/src/lcd/tft/ui_color_ui.cpp @@ -295,7 +295,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(LCD_SHOW_E_TOTAL) && defined(E_MARK_X) && defined(E_MARK_Y) && defined(E_VALUE_X) && defined(E_VALUE_Y) tft.add_text(E_MARK_X, E_MARK_Y, COLOR_AXIS_HOMED, "E"); - if (printingIsActive()) { + if (marlin.printingIsActive()) { const uint8_t escale = e_move_accumulator >= 10000.0f ? 10 : 1; // After 10m switch to cm to fit into 4 digits output of ftostr4sign() tft_string.set(ftostr4sign(e_move_accumulator / escale)); const uint16_t e_value_x = E_VALUE_X; @@ -333,7 +333,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(TOUCH_SCREEN) add_control(MENU_ICON_X, MENU_ICON_Y, menu_main, imgSettings); #if HAS_MEDIA - const bool cm = card.isMounted(), pa = printingIsActive(); + const bool cm = card.isMounted(), pa = marlin.printingIsActive(); if (cm && pa) add_control(SDCARD_ICON_X, SDCARD_ICON_Y, STOP, imgCancel, true, COLOR_CONTROL_CANCEL); else @@ -382,7 +382,7 @@ void MarlinUI::draw_status_screen() { tft.canvas(REMAINING_TIME_X, REMAINING_TIME_Y, REMAINING_TIME_W, REMAINING_TIME_H); tft.set_background(COLOR_BACKGROUND); tft_string.set(buffer); - color = printingIsActive() ? COLOR_PRINT_TIME : COLOR_INACTIVE; + color = marlin.printingIsActive() ? COLOR_PRINT_TIME : COLOR_INACTIVE; #if defined(REMAINING_TIME_IMAGE_X) && defined(REMAINING_TIME_IMAGE_Y) tft.add_image(REMAINING_TIME_IMAGE_X, REMAINING_TIME_IMAGE_Y, imgTimeRemaining, color); #endif diff --git a/Marlin/src/lcd/tft/ui_move_axis_screen_1024.cpp b/Marlin/src/lcd/tft/ui_move_axis_screen_1024.cpp index a15c05d25e..0aebd39629 100644 --- a/Marlin/src/lcd/tft/ui_move_axis_screen_1024.cpp +++ b/Marlin/src/lcd/tft/ui_move_axis_screen_1024.cpp @@ -137,7 +137,7 @@ void MarlinUI::move_axis_screen() { TERN_(TOUCH_SCREEN, touch.clear()); - const bool busy = printingIsActive(); + const bool busy = marlin.printingIsActive(); // Babysteps during printing? Select babystep for Z probe offset #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/lcd/tft/ui_move_axis_screen_320.cpp b/Marlin/src/lcd/tft/ui_move_axis_screen_320.cpp index 5b1fbaf958..022d6ea270 100644 --- a/Marlin/src/lcd/tft/ui_move_axis_screen_320.cpp +++ b/Marlin/src/lcd/tft/ui_move_axis_screen_320.cpp @@ -150,7 +150,7 @@ void MarlinUI::move_axis_screen() { TERN_(TOUCH_SCREEN, touch.clear()); - const bool busy = printingIsActive(); + const bool busy = marlin.printingIsActive(); // Babysteps during printing? Select babystep for Z probe offset #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/lcd/tft/ui_move_axis_screen_480.cpp b/Marlin/src/lcd/tft/ui_move_axis_screen_480.cpp index 9e42411580..e769825bd4 100644 --- a/Marlin/src/lcd/tft/ui_move_axis_screen_480.cpp +++ b/Marlin/src/lcd/tft/ui_move_axis_screen_480.cpp @@ -150,7 +150,7 @@ void MarlinUI::move_axis_screen() { TERN_(TOUCH_SCREEN, touch.clear()); - const bool busy = printingIsActive(); + const bool busy = marlin.printingIsActive(); // Babysteps during printing? Select babystep for Z probe offset #if ENABLED(BABYSTEP_ZPROBE_OFFSET) diff --git a/Marlin/src/lcd/utf8.cpp b/Marlin/src/lcd/utf8.cpp index 2fe6c14490..5eddb0aff5 100644 --- a/Marlin/src/lcd/utf8.cpp +++ b/Marlin/src/lcd/utf8.cpp @@ -35,7 +35,6 @@ #if HAS_WIRED_LCD #include "marlinui.h" - #include "../MarlinCore.h" #endif #include "utf8.h" diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 0f92bac812..bfe51ed97a 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -28,7 +28,6 @@ Nozzle nozzle; -#include "../MarlinCore.h" #include "../module/motion.h" #if NOZZLE_CLEAN_MIN_TEMP > 20 diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 5c913cb5c4..d211c3a133 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -35,7 +35,6 @@ #include "planner.h" #include "endstops.h" #include "../lcd/marlinui.h" -#include "../MarlinCore.h" #if HAS_BED_PROBE #include "probe.h" diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 821bb2df48..6528e15a2f 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -235,7 +235,7 @@ void Endstops::enable(const bool onoff) { hit_on_purpose(); else { TERN_(SOVOL_SV06_RTS, rts.gotoPageBeep(ID_KillHome_L, ID_KillHome_D)); - kill(GET_TEXT_F(MSG_KILL_HOMING_FAILED)); + marlin.kill(GET_TEXT_F(MSG_KILL_HOMING_FAILED)); } } #endif @@ -893,7 +893,7 @@ void Endstops::update() { #if ENABLED(SPI_ENDSTOPS) - // Called from idle() to read Trinamic stall states + // Called from marlin.idle() to read Trinamic stall states bool Endstops::tmc_spi_homing_check() { bool hit = false; diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 0a3a5a5f5e..bbf4f59bd7 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -621,10 +621,10 @@ void report_current_position_projected() { } /** - * Set a Grbl-compatible state from the current marlin_state + * Set a Grbl-compatible state from the current marlin.state */ M_StateEnum grbl_state_for_marlin_state() { - switch (marlin_state) { + switch (marlin.state) { case MarlinState::MF_INITIALIZING: return M_INIT; case MarlinState::MF_SD_COMPLETE: return M_ALARM; case MarlinState::MF_WAITING: return M_IDLE; @@ -1427,7 +1427,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { const millis_t ms = millis(); if (ELAPSED(ms, next_idle_ms)) { next_idle_ms = ms + 200UL; - return idle(); + return marlin.idle(); } thermalManager.task(); // Returns immediately on most calls } @@ -2576,7 +2576,7 @@ void prepare_line_to_destination() { if (endstops.state(es)) { SERIAL_ECHO_MSG("Bad ", C(AXIS_CHAR(axis)), " Endstop?"); - kill(GET_TEXT_F(MSG_KILL_HOMING_FAILED)); + marlin.kill(GET_TEXT_F(MSG_KILL_HOMING_FAILED)); } #endif // DETECT_BROKEN_ENDSTOP diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 0ebd1b5748..fbce0166a9 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -484,12 +484,12 @@ inline bool all_axes_trusted() { return main_axes_mask == void home_if_needed(const bool keeplev=false); #if ENABLED(NO_MOTION_BEFORE_HOMING) - #define MOTION_CONDITIONS (IsRunning() && !homing_needed_error()) + #define MOTION_CONDITIONS (marlin.isRunning() && !homing_needed_error()) #else - #define MOTION_CONDITIONS IsRunning() + #define MOTION_CONDITIONS marlin.isRunning() #endif -#define BABYSTEP_ALLOWED() ((ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_trusted()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy())) +#define BABYSTEP_ALLOWED() ((ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_trusted()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || marlin.printer_busy())) #if HAS_HOME_OFFSET extern xyz_pos_t home_offset; diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 59c7c3638b..6bee1890e3 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1606,7 +1606,7 @@ bool Planner::busy() { } void Planner::finish_and_disable() { - while (has_blocks_queued() || cleaning_buffer_counter) idle(); + while (has_blocks_queued() || cleaning_buffer_counter) marlin.idle(); stepper.disable_all_steppers(); } @@ -1666,7 +1666,7 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { /** * Block until the planner is finished processing */ -void Planner::synchronize() { while (busy()) idle(); } +void Planner::synchronize() { while (busy()) marlin.idle(); } /** * @brief Add a new linear movement to the planner queue (in terms of steps). @@ -3040,7 +3040,7 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const feedRate_t fr_mm_s void Planner::buffer_page(const page_idx_t page_idx, const uint8_t extruder, const uint16_t num_steps) { if (!last_page_step_rate) { - kill(GET_TEXT_F(MSG_BAD_PAGE_SPEED)); + marlin.kill(GET_TEXT_F(MSG_BAD_PAGE_SPEED)); return; } diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 891357dbe3..2afec3b4ab 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -875,7 +875,7 @@ class Planner { FORCE_INLINE static block_t* get_next_free_block(uint8_t &next_buffer_head, const uint8_t count=1) { // Wait until there are enough slots free - while (moves_free() < count) { idle(); } + while (moves_free() < count) { marlin.idle(); } // Return the first available block next_buffer_head = next_block_index(block_buffer_head); diff --git a/Marlin/src/module/planner_bezier.cpp b/Marlin/src/module/planner_bezier.cpp index bc39d278f1..b88301b2f0 100644 --- a/Marlin/src/module/planner_bezier.cpp +++ b/Marlin/src/module/planner_bezier.cpp @@ -34,7 +34,6 @@ #include "motion.h" #include "temperature.h" -#include "../MarlinCore.h" #include "../gcode/queue.h" // See the meaning in the documentation of cubic_b_spline(). @@ -130,7 +129,7 @@ void cubic_b_spline( millis_t now = millis(); if (ELAPSED(now, next_idle_ms)) { next_idle_ms = now + 200UL; - idle(); + marlin.idle(); } // First try to reduce the step in order to make it sufficiently diff --git a/Marlin/src/module/polargraph.cpp b/Marlin/src/module/polargraph.cpp index 534ec17ef8..10e596efed 100644 --- a/Marlin/src/module/polargraph.cpp +++ b/Marlin/src/module/polargraph.cpp @@ -35,7 +35,6 @@ #include "planner.h" #include "endstops.h" #include "../lcd/marlinui.h" -#include "../MarlinCore.h" // Initialized by settings.load float segments_per_second, polargraph_max_belt_len; diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index f3d9ec8a9d..ec5bd8c456 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -34,7 +34,6 @@ Stopwatch print_job_timer; // Global Print Job Timer instance #endif #include "printcounter.h" -#include "../MarlinCore.h" #include "../HAL/shared/eeprom_api.h" #if HAS_SOUND && SERVICE_WARNING_BUZZES > 0 diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index ae688a864e..3a8bb2b6c6 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -38,8 +38,6 @@ #include "../gcode/gcode.h" #include "../lcd/marlinui.h" -#include "../MarlinCore.h" // for stop(), disable_e_steppers(), wait_for_user_response() - #if HAS_LEVELING #include "../feature/bedlevel/bedlevel.h" #endif @@ -169,7 +167,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load ui.return_to_status(); TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(F("Deploy TouchMI"))); - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); + TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response()); ui.reset_status(); ui.goto_screen(prev_screen); @@ -392,9 +390,9 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { // Wait for the probe to be attached or detached before asking for explicit user confirmation // Allow the user to interrupt KEEPALIVE_STATE(PAUSED_FOR_USER); - TERN_(HAS_RESUME_CONTINUE, wait_for_user = true); - while (deploy == PROBE_TRIGGERED() && TERN1(HAS_RESUME_CONTINUE, wait_for_user)) idle_no_sleep(); - TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); + TERN_(HAS_RESUME_CONTINUE, marlin.wait_start()); + while (deploy == PROBE_TRIGGERED() && TERN1(HAS_RESUME_CONTINUE, marlin.wait_for_user)) marlin.idle_no_sleep(); + TERN_(HAS_RESUME_CONTINUE, marlin.user_resume()); OKAY_BUZZ(); } #endif @@ -405,7 +403,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #elif ENABLED(EXTENSIBLE_UI) ExtUI::onUserConfirmRequired(ds_fstr); #endif - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); + TERN_(HAS_RESUME_CONTINUE, marlin.wait_for_user_response()); ui.reset_alert_level(); //ui.reset_status(); @@ -528,7 +526,7 @@ void Probe::probe_error_stop() { SERIAL_ECHOPGM(STR_STOP_BLTOUCH); #endif SERIAL_ECHOLNPGM(STR_STOP_POST); - stop(); + marlin.stop(); } /** @@ -578,11 +576,11 @@ bool Probe::set_deployed(const bool deploy, const bool no_return/*=false*/) { } if (PROBE_TRIGGERED() == deploy) { // Unchanged after deploy/stow action? - if (IsRunning()) { + if (marlin.isRunning()) { SERIAL_ERROR_MSG("Z-Probe failed"); LCD_ALERTMESSAGE_F("Err: ZPROBE"); } - stop(); + marlin.stop(); return true; } diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index 8274335862..7d1f9ce2ca 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -34,7 +34,6 @@ #if ENABLED(AXEL_TPARA) #include "endstops.h" - #include "../MarlinCore.h" #endif float segments_per_second = DEFAULT_SEGMENTS_PER_SECOND; diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 85f837b063..4a3b01c2ed 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -54,7 +54,6 @@ #include "../lcd/marlinui.h" #include "../libs/vector_3.h" // for matrix_3x3 #include "../gcode/gcode.h" -#include "../MarlinCore.h" #if ANY(EEPROM_SETTINGS, SD_FIRMWARE_UPDATE) #include "../HAL/shared/eeprom_api.h" @@ -1698,7 +1697,7 @@ void MarlinSettings::postprocess() { // CONFIGURABLE_MACHINE_NAME // #if ENABLED(CONFIGURABLE_MACHINE_NAME) - EEPROM_WRITE(machine_name); + EEPROM_WRITE(marlin.machine_name); #endif // @@ -2824,7 +2823,7 @@ void MarlinSettings::postprocess() { // CONFIGURABLE_MACHINE_NAME // #if ENABLED(CONFIGURABLE_MACHINE_NAME) - EEPROM_READ(machine_name); + EEPROM_READ(marlin.machine_name); #endif // @@ -3075,7 +3074,7 @@ void MarlinSettings::postprocess() { #if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503) // Report the EEPROM settings - if (!validating && TERN1(EEPROM_BOOT_SILENT, IsRunning())) report(); + if (!validating && TERN1(EEPROM_BOOT_SILENT, marlin.isRunning())) report(); #endif return eeprom_error; @@ -3440,7 +3439,7 @@ void MarlinSettings::reset() { // // CONFIGURABLE_MACHINE_NAME // - TERN_(CONFIGURABLE_MACHINE_NAME, machine_name = PSTR(MACHINE_NAME)); + TERN_(CONFIGURABLE_MACHINE_NAME, marlin.machine_name = PSTR(MACHINE_NAME)); // // TOUCH_SCREEN_CALIBRATION diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index cb1926c318..76efc17e4f 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -84,7 +84,6 @@ Stepper stepper; // Singleton #include "../lcd/marlinui.h" #include "../gcode/queue.h" #include "../sd/cardreader.h" -#include "../MarlinCore.h" #include "../HAL/shared/Delay.h" #if ENABLED(BD_SENSOR) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 6bda47b573..9672e9c895 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -681,7 +681,7 @@ volatile bool Temperature::raw_temps_ready = false; /** * Run the minimal required activities during a tuning loop. - * TODO: Allow tuning routines to call idle() for more complete keepalive. + * TODO: Allow tuning routines to call marlin.idle() for more complete keepalive. */ bool Temperature::tuning_idle(const millis_t &ms) { @@ -856,8 +856,7 @@ void Temperature::factory_reset() { LCD_MESSAGE(MSG_HEATING); // PID Tuning loop - wait_for_heatup = true; - while (wait_for_heatup) { // Can be interrupted with M108 + for (marlin.heatup_start(); marlin.is_heating(); ) { // Can be interrupted with M108 const millis_t ms = millis(); @@ -1020,7 +1019,7 @@ void Temperature::factory_reset() { goto EXIT_M303; } } - wait_for_heatup = false; + marlin.heatup_done(); disable_all_heaters(); @@ -1057,7 +1056,7 @@ void Temperature::factory_reset() { } Temperature::MPC_autotuner::~MPC_autotuner() { - wait_for_heatup = false; + marlin.heatup_done(); ui.reset_status(); @@ -1082,9 +1081,8 @@ void Temperature::factory_reset() { const millis_t test_interval_ms = 10000UL; millis_t next_test_ms = curr_time_ms + test_interval_ms; ambient_temp = current_temp = degHotend(e); - wait_for_heatup = true; - for (;;) { // Can be interrupted with M108 + for (marlin.heatup_start(); ;) { // Can be interrupted with M108 if (housekeeping() == CANCELLED) return CANCELLED; if (ELAPSED(curr_time_ms, next_test_ms)) { @@ -1096,7 +1094,7 @@ void Temperature::factory_reset() { next_test_ms += test_interval_ms; } } - wait_for_heatup = false; + marlin.heatup_done(); #if ENABLED(MPC_AUTOTUNE_DEBUG) SERIAL_ECHOLNPGM("MPC_autotuner::measure_ambient_temp() Completed\n=====\n" @@ -1125,8 +1123,7 @@ void Temperature::factory_reset() { temp_samples[0] = temp_samples[1] = temp_samples[2] = current_temp; time_fastest = rate_fastest = 0; - wait_for_heatup = true; - for (;;) { // Can be interrupted with M108 + for (marlin.heatup_start(); ;) { // Can be interrupted with M108 if (housekeeping() == CANCELLED) return CANCELLED; if (ELAPSED(curr_time_ms, next_test_time_ms)) { @@ -1172,7 +1169,7 @@ void Temperature::factory_reset() { } } } - wait_for_heatup = false; + marlin.heatup_done(); hotend.soft_pwm_amount = 0; @@ -1210,8 +1207,7 @@ void Temperature::factory_reset() { #endif float last_temp = current_temp; - wait_for_heatup = true; - for (;;) { // Can be interrupted with M108 + for (marlin.heatup_start(); ;) { // Can be interrupted with M108 if (housekeeping() == CANCELLED) return CANCELLED; if (ELAPSED(curr_time_ms, next_test_ms)) { @@ -1240,11 +1236,11 @@ void Temperature::factory_reset() { if (!WITHIN(current_temp, get_sample_3_temp() - 15.0f, hotend.target + 15.0f)) { SERIAL_ECHOLNPGM(STR_MPC_TEMPERATURE_ERROR); TERN_(EXTENSIBLE_UI, ExtUI::onMPCTuning(ExtUI::mpcresult_t::MPC_TEMP_ERROR)); - wait_for_heatup = false; + marlin.heatup_done(); return FAILED; } } - wait_for_heatup = false; + marlin.heatup_done(); power_fan0 = total_energy_fan0 / MS_TO_SEC_PRECISE(test_duration); TERN_(HAS_FAN, power_fan255 = (total_energy_fan255 * 1000) / test_duration); @@ -1275,7 +1271,7 @@ void Temperature::factory_reset() { SERIAL_EOL(); } - if (!wait_for_heatup) { + if (!marlin.is_heating()) { SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_INTERRUPTED); TERN_(EXTENSIBLE_UI, ExtUI::onMPCTuning(ExtUI::mpcresult_t::MPC_INTERRUPTED)); return MeasurementState::CANCELLED; @@ -1560,7 +1556,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { * @param heater_id: The heater that caused the error */ inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) { - marlin_state = MarlinState::MF_KILLED; + marlin.setState(MarlinState::MF_KILLED); thermalManager.disable_all_heaters(); #if HAS_BEEPER for (uint8_t i = 20; i--;) { @@ -1586,7 +1582,7 @@ inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) { _FSTR_E(h,1) _FSTR_E(h,2) _FSTR_E(h,3) _FSTR_E(h,4) \ _FSTR_E(h,5) _FSTR_E(h,6) _FSTR_E(h,7) F(STR_E0) - kill(lcd_msg, HEATER_FSTR(heater_id)); + marlin.kill(lcd_msg, HEATER_FSTR(heater_id)); } /** @@ -1606,7 +1602,7 @@ void Temperature::_temp_error( #endif static uint8_t killed = 0; - if (IsRunning() && killed == TERN(HAS_BOGUS_TEMPERATURE_GRACE_PERIOD, 2, 0)) { + if (marlin.isRunning() && killed == TERN(HAS_BOGUS_TEMPERATURE_GRACE_PERIOD, 2, 0)) { SERIAL_ERROR_START(); SERIAL_ECHO(serial_msg); SERIAL_ECHOPGM(STR_STOPPED_HEATER); @@ -2314,14 +2310,15 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T * - Update the heated bed PID output value */ void Temperature::task() { - if (marlin_state == MarlinState::MF_INITIALIZING) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! + if (marlin.is(MarlinState::MF_INITIALIZING)) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! static bool no_reentry = false; // Prevent recursion if (no_reentry) return; REMEMBER(mh, no_reentry, true); #if ENABLED(EMERGENCY_PARSER) - if (emergency_parser.killed_by_M112) kill(FPSTR(M112_KILL_STR), nullptr, true); + if (emergency_parser.killed_by_M112) + marlin.kill(FPSTR(M112_KILL_STR), nullptr, true); if (emergency_parser.quickstop_by_M410) { emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! @@ -2586,7 +2583,7 @@ void Temperature::task() { SERIAL_ERROR_START(); SERIAL_ECHO(e); SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM); - kill(); + marlin.kill(); return 0; } @@ -3517,7 +3514,7 @@ void Temperature::disable_all_heaters() { void Temperature::auto_job_check_timer(const bool can_start, const bool can_stop) { if (auto_job_over_threshold()) { - if (can_start) startOrResumeJob(); + if (can_start) marlin.startOrResumeJob(); } else if (can_stop) { print_job_timer.stop(); @@ -4539,7 +4536,7 @@ void Temperature::isr() { #if ENABLED(AUTO_REPORT_TEMPERATURES) AutoReporter Temperature::auto_reporter; void Temperature::AutoReportTemp::report() { - if (wait_for_heatup) return; + if (marlin.is_heating()) return; print_heater_states(active_extruder OPTARG(HAS_TEMP_REDUNDANT, ENABLED(AUTO_REPORT_REDUNDANT))); SERIAL_EOL(); } @@ -4605,8 +4602,7 @@ void Temperature::isr() { bool wants_to_cool = false; celsius_float_t target_temp = -1.0, old_temp = 9999.0; millis_t now, next_temp_ms = 0, cool_check_ms = 0; - wait_for_heatup = true; - do { + for (marlin.heatup_start(); marlin.is_heating() && TEMP_CONDITIONS; ) { // Target temperature might be changed during the loop if (target_temp != degTargetHotend(target_extruder)) { wants_to_cool = isCoolingHotend(target_extruder); @@ -4631,7 +4627,7 @@ void Temperature::isr() { SERIAL_EOL(); } - idle(); + marlin.idle(); gcode.reset_stepper_timeout(); // Keep steppers powered const celsius_float_t temp = degHotend(target_extruder); @@ -4672,16 +4668,17 @@ void Temperature::isr() { #if G26_CLICK_CAN_CANCEL if (click_to_cancel && ui.use_click()) { - wait_for_heatup = false; + marlin.heatup_done(); TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); } #endif - } while (wait_for_heatup && TEMP_CONDITIONS); + } // for ... is_heating ... // If wait_for_heatup is set, temperature was reached, no cancel - if (wait_for_heatup) { - wait_for_heatup = false; + // TODO: Use a common function to reset wait_for_heatup and update UI + if (marlin.is_heating()) { + marlin.heatup_done(); #if ENABLED(DWIN_CREALITY_LCD) hmiFlag.heat_flag = 0; duration_t elapsed = print_job_timer.duration(); // Print timer @@ -4698,12 +4695,12 @@ void Temperature::isr() { } return false; - } + } // Temperature::wait_for_hotend #if ENABLED(WAIT_FOR_HOTEND) void Temperature::wait_for_hotend_heating(const uint8_t target_extruder) { if (isHeatingHotend(target_extruder)) { - SERIAL_ECHOLNPGM("Wait for hotend heating..."); + SERIAL_ECHOLNPGM(STR_WAIT_FOR_HOTEND); LCD_MESSAGE(MSG_HEATING); wait_for_hotend(target_extruder); ui.reset_status(); @@ -4799,7 +4796,7 @@ void Temperature::isr() { bool wants_to_cool = false; celsius_float_t target_temp = -1, old_temp = 9999; millis_t now, next_temp_ms = 0, cool_check_ms = 0; - wait_for_heatup = true; + marlin.heatup_start(); do { // Target temperature might be changed during the loop if (target_temp != degTargetBed()) { @@ -4825,7 +4822,7 @@ void Temperature::isr() { SERIAL_EOL(); } - idle(); + marlin.idle(); gcode.reset_stepper_timeout(); // Keep steppers powered const celsius_float_t temp = degBed(); @@ -4864,7 +4861,7 @@ void Temperature::isr() { #if G26_CLICK_CAN_CANCEL if (click_to_cancel && ui.use_click()) { - wait_for_heatup = false; + marlin.heatup_done(); TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); } #endif @@ -4873,11 +4870,12 @@ void Temperature::isr() { first_loop = false; #endif - } while (wait_for_heatup && TEMP_BED_CONDITIONS); + } while (marlin.is_heating() && TEMP_BED_CONDITIONS); // If wait_for_heatup is set, temperature was reached, no cancel - if (wait_for_heatup) { - wait_for_heatup = false; + // TODO: Use a common function to reset wait_for_heatup and update UI + if (marlin.is_heating()) { + marlin.heatup_done(); ui.reset_status(); return true; } @@ -4887,7 +4885,7 @@ void Temperature::isr() { void Temperature::wait_for_bed_heating() { if (isHeatingBed()) { - SERIAL_ECHOLNPGM("Wait for bed heating..."); + SERIAL_ECHOLNPGM(STR_WAIT_FOR_BED); LCD_MESSAGE(MSG_BED_HEATING); wait_for_bed(); ui.reset_status(); @@ -4918,8 +4916,8 @@ void Temperature::isr() { float old_temp = 9999; millis_t next_temp_ms = 0, next_delta_check_ms = 0; - wait_for_heatup = true; - while (will_wait && wait_for_heatup) { + marlin.heatup_start(); + while (will_wait && marlin.is_heating()) { // Print Temp Reading every 10 seconds while heating up. millis_t now = millis(); @@ -4929,7 +4927,7 @@ void Temperature::isr() { SERIAL_EOL(); } - idle(); + marlin.idle(); gcode.reset_stepper_timeout(); // Keep steppers powered // Break after MIN_DELTA_SLOPE_TIME_PROBE seconds if the temperature @@ -4954,8 +4952,9 @@ void Temperature::isr() { } // If wait_for_heatup is set, temperature was reached, no cancel - if (wait_for_heatup) { - wait_for_heatup = false; + // TODO: Use a common function to reset wait_for_heatup and update UI + if (marlin.is_heating()) { + marlin.heatup_done(); ui.reset_status(); return true; } @@ -4994,7 +4993,7 @@ void Temperature::isr() { bool wants_to_cool = false; float target_temp = -1, old_temp = 9999; millis_t now, next_temp_ms = 0, cool_check_ms = 0; - wait_for_heatup = true; + marlin.heatup_start(); do { // Target temperature might be changed during the loop if (target_temp != degTargetChamber()) { @@ -5020,7 +5019,7 @@ void Temperature::isr() { SERIAL_EOL(); } - idle(); + marlin.idle(); gcode.reset_stepper_timeout(); // Keep steppers powered const float temp = degChamber(); @@ -5052,11 +5051,12 @@ void Temperature::isr() { old_temp = temp; } } - } while (wait_for_heatup && TEMP_CHAMBER_CONDITIONS); + } while (marlin.is_heating() && TEMP_CHAMBER_CONDITIONS); // If wait_for_heatup is set, temperature was reached, no cancel - if (wait_for_heatup) { - wait_for_heatup = false; + // TODO: Use a common function to reset wait_for_heatup and update UI + if (marlin.is_heating()) { + marlin.heatup_done(); ui.reset_status(); return true; } @@ -5094,7 +5094,7 @@ void Temperature::isr() { bool wants_to_cool = false; float target_temp = -1, previous_temp = 9999; millis_t now, next_temp_ms = 0, next_cooling_check_ms = 0; - wait_for_heatup = true; + marlin.heatup_start(); do { // Target temperature might be changed during the loop if (target_temp != degTargetCooler()) { @@ -5120,7 +5120,7 @@ void Temperature::isr() { SERIAL_EOL(); } - idle(); + marlin.idle(); gcode.reset_stepper_timeout(); // Keep steppers powered const celsius_float_t current_temp = degCooler(); @@ -5153,11 +5153,12 @@ void Temperature::isr() { } } - } while (wait_for_heatup && TEMP_COOLER_CONDITIONS); + } while (marlin.is_heating() && TEMP_COOLER_CONDITIONS); // If wait_for_heatup is set, temperature was reached, no cancel - if (wait_for_heatup) { - wait_for_heatup = false; + // TODO: Use a common function to reset wait_for_heatup and update UI + if (marlin.is_heating()) { + marlin.heatup_done(); ui.reset_status(); return true; } diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 85254ea598..ab5e7fd5a7 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -430,7 +430,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. } else if (kill_on_error && (!tool_sensor_disabled || disable)) { sensor_tries++; - if (sensor_tries > 10) kill(F("Tool Sensor error")); + if (sensor_tries > 10) marlin.kill(F("Tool Sensor error")); safe_delay(5); } else { @@ -853,7 +853,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. const float xhome = x_home_pos(active_extruder); if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE // If Auto-Park mode is enabled - && IsRunning() && !no_move // ...and movement is permitted + && marlin.isRunning() && !no_move // ...and movement is permitted && (delayed_move_time || current_position.x != xhome) // ...and delayed_move_time is set OR not "already parked"... ) { DEBUG_ECHOLNPGM("MoveX to ", xhome); @@ -1333,7 +1333,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #endif // Return to position and lower again - const bool should_move = safe_to_move && !no_move && IsRunning(); + const bool should_move = safe_to_move && !no_move && marlin.isRunning(); if (should_move) { #if ANY(SINGLENOZZLE_STANDBY_TEMP, SINGLENOZZLE_STANDBY_FAN) diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index f897343ffc..5df96e3837 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -163,7 +163,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #include "pinsDebug_list.h" - #line 168 + #line 167 }; @@ -173,8 +173,6 @@ const PinInfo pin_array[] PROGMEM = { #define M43_NEVER_TOUCH(Q) false #endif -bool pin_is_protected(const pin_t pin); - static void printPinIOState(const bool isout) { SERIAL_ECHO(isout ? F("Output ") : F("Input ")); } @@ -221,7 +219,7 @@ inline void printPinStateExt(const pin_t pin, const bool ignore, const bool exte } printPinNameByIndex(x); if (extended) { - if (pin_is_protected(pin) && !ignore) + if (marlin.pin_is_protected(pin) && !ignore) SERIAL_ECHOPGM("protected "); else { if (alt_pin_echo(pin)) { diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 4bc2eeed52..a6807f5c69 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -33,7 +33,7 @@ #define ANALOG_OK(PN) WITHIN(PN, 0, NUM_ANALOG_INPUTS - 1) #endif -#line 35 // set __LINE__ to a known value for both passes +#line 37 // set __LINE__ to a known value for both passes // // Analog Pin Assignments diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index 97157f9718..c31501edd9 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -38,8 +38,6 @@ #include "Sd2Card.h" -#include "../MarlinCore.h" - #if DISABLED(SD_NO_DEFAULT_TIMEOUT) #ifndef SD_INIT_TIMEOUT #define SD_INIT_TIMEOUT 2000U // (ms) Init timeout diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index cc14ca9c29..fb3b51b47d 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -39,7 +39,6 @@ #include "SdBaseFile.h" -#include "../MarlinCore.h" SdBaseFile *SdBaseFile::cwd_ = 0; // Pointer to Current Working Directory // callback function for date/time diff --git a/Marlin/src/sd/SdVolume.cpp b/Marlin/src/sd/SdVolume.cpp index 1b8cdbdcae..875673be1e 100644 --- a/Marlin/src/sd/SdVolume.cpp +++ b/Marlin/src/sd/SdVolume.cpp @@ -35,8 +35,6 @@ #include "SdVolume.h" -#include "../MarlinCore.h" - #if !USE_MULTIPLE_CARDS // raw block cache uint32_t SdVolume::cacheBlockNumber_; // current block number diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 723f86a07e..9d91173d7b 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -32,7 +32,6 @@ #include "cardreader.h" -#include "../MarlinCore.h" #include "../libs/hex_print.h" #include "../lcd/marlinui.h" @@ -74,6 +73,9 @@ PGMSTR(M21_STR, "M21"); PGMSTR(M23_STR, "M23 %s"); PGMSTR(M24_STR, "M24"); +// Functional instance. Stub instance maintained in MarlinCore.cpp. +CardReader card; + // public: card_flags_t CardReader::flag; @@ -502,7 +504,7 @@ void CardReader::mount() { cdroot(); else { #if ANY(HAS_SD_DETECT, HAS_USB_FLASH_DRIVE) - if (marlin_state != MarlinState::MF_INITIALIZING) { + if (!marlin.is(MarlinState::MF_INITIALIZING)) { if (isSDCardSelected()) LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL_SD); else if (isFlashDriveSelected()) @@ -807,7 +809,7 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ // Too deep? The firmware has to bail. if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) { SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:", SD_PROCEDURE_DEPTH); - kill(GET_TEXT_F(MSG_KILL_SUBCALL_OVERFLOW)); + marlin.kill(GET_TEXT_F(MSG_KILL_SUBCALL_OVERFLOW)); return; } @@ -1646,8 +1648,8 @@ void CardReader::fileHasFinished() { endFilePrintNow(TERN_(SD_RESORT, true)); - flag.sdprintdone = true; // Stop getting bytes from the SD card - marlin_state = MarlinState::MF_SD_COMPLETE; // Tell Marlin to enqueue M1001 soon + flag.sdprintdone = true; // Stop getting bytes from the SD card + marlin.setState(MarlinState::MF_SD_COMPLETE); // Tell Marlin to enqueue M1001 soon } #if ENABLED(AUTO_REPORT_SD_STATUS) diff --git a/docs/Queue.md b/docs/Queue.md index e0f50e7807..5d2fef0cae 100644 --- a/docs/Queue.md +++ b/docs/Queue.md @@ -39,10 +39,10 @@ Here's a basic flowchart of Marlin command processing: +--------------------------------------+ ``` -Marlin is a single-threaded application with a main `loop()` that manages the command queue and an `idle()` routine that manages the hardware. The command queue is handled in two stages: +Marlin is a single-threaded application with a main `loop()` that manages the command queue and a `marlin.idle()` routine to manage the hardware. The command queue is handled in two stages: -1. The `idle()` routine reads all inputs and attempts to enqueue any completed command lines. -2. The main `loop()` gets the command at the front the G-code queue (if any) and runs it. Each G-code command blocks the main loop, preventing the queue from advancing until it returns. To keep essential tasks and the UI running, any commands that run a long process need to call `idle()` frequently. +1. The `marlin.idle()` routine reads all inputs and attempts to enqueue any completed command lines. +2. The main `loop()` gets the command at the front the G-code queue (if any) and runs it. Each G-code command blocks the main loop, preventing the queue from advancing until it returns. To keep essential tasks and the UI running, any commands that run a long process must call `marlin.idle()` frequently. ## Synchronization From 333608a69242b10a75d2ef25c66ca4e4af99f7fa Mon Sep 17 00:00:00 2001 From: thinkyhead Date: Tue, 2 Dec 2025 00:33:25 +0000 Subject: [PATCH 39/39] [cron] Bump distribution date (2025-12-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 c884bcea7a..545d23b782 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 "2025-12-01" +//#define STRING_DISTRIBUTION_DATE "2025-12-02" /** * The protocol for communication to the host. Protocol indicates communication diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 3aa89f99b0..2c8d257744 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 "2025-12-01" + #define STRING_DISTRIBUTION_DATE "2025-12-02" #endif /**