From 27da1995f32e90b11ed2a1d4347c37416ab094a1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 22 Oct 2025 15:06:28 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20FT=20Motion=20toggle()=20more=20?= =?UTF-8?q?safely?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_motion.cpp | 5 +---- Marlin/src/module/ft_motion.h | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index f869436c7d..9e956711cf 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -465,10 +465,7 @@ void menu_move() { BACK_ITEM(MSG_MOTION); bool show_state = c.active; - EDIT_ITEM(bool, MSG_FIXED_TIME_MOTION, &show_state, []{ - FLIP(ftMotion.cfg.active); - ftMotion.update_shaping_params(); - }); + EDIT_ITEM(bool, MSG_FIXED_TIME_MOTION, &show_state, []{ (void)ftMotion.toggle(); }); // Show only when FT Motion is active (or optionally always show) if (c.active || ENABLED(FT_MOTION_NO_MENU_TOGGLE)) { diff --git a/Marlin/src/module/ft_motion.h b/Marlin/src/module/ft_motion.h index a6b3e5fc58..dfe10282e1 100644 --- a/Marlin/src/module/ft_motion.h +++ b/Marlin/src/module/ft_motion.h @@ -41,6 +41,9 @@ #endif #endif +/** + * FTConfig - The active configured state of FT Motion + */ typedef struct FTConfig { bool active = ENABLED(FTM_IS_DEFAULT_MOTION); // Active (else standard motion) bool axis_sync_enabled = true; // Axis synchronization enabled @@ -77,6 +80,9 @@ typedef struct FTConfig { float poly6_acceleration_overshoot; // Overshoot factor for Poly6 (1.25 to 2.0) } ft_config_t; +/** + * FTMotion - Singleton class encapsulating Fixed Time Motion + */ class FTMotion { public: @@ -157,6 +163,13 @@ class FTMotion { static void reset(); // Reset all states of the fixed time conversion to defaults. + static bool toggle() { + stepper.ftMotion_syncPosition(); + FLIP(cfg.active); + update_shaping_params(); + return cfg.active; + } + // Trajectory generator selection static void setTrajectoryType(const TrajectoryType type); static TrajectoryType getTrajectoryType() { return trajectoryType; } @@ -269,8 +282,12 @@ class FTMotion { }; // class FTMotion -extern FTMotion ftMotion; +extern FTMotion ftMotion; // Use ftMotion.thing, not FTMotion::thing. +/** + * Optional behavior to turn FT Motion off for homing/probing. + * Applies when FTM_HOME_AND_PROBE is disabled. + */ typedef struct FTMotionDisableInScope { #if DISABLED(FTM_HOME_AND_PROBE) bool isactive;