diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index d1d4bfd0a6..0c5a0b83a7 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -337,6 +337,9 @@ void MarlinUI::init() { #include "lcdprint.h" #include "../module/planner.h" + #if ENABLED(FT_MOTION) + #include "../module/ft_motion.h" + #endif #include "../module/motion.h" #if HAS_MARLINUI_MENU @@ -1161,8 +1164,17 @@ void MarlinUI::init() { } if (lcd_update_ms_elapsed || drawing_screen) { + const auto buffer_runtime = [&]() -> uint16_t { + #if ENABLED(FT_MOTION) + // In ftmotion, the isr only looks at the stepping buffer and the planner buffer is + // consumed from the idle loop. + if (ftMotion.cfg.active) return ftMotion.stepping.buffer_runtime(); + #endif + return planner.block_buffer_runtime(); + }; + // Then we want to use only 50% of the time - const uint16_t bbr2 = planner.block_buffer_runtime() >> 1; + const uint16_t bbr2 = buffer_runtime() >> 1; if ((should_draw() || drawing_screen) && (!bbr2 || bbr2 > max_display_update_time)) { diff --git a/Marlin/src/module/ft_motion/stepping.h b/Marlin/src/module/ft_motion/stepping.h index e389e56c3c..f14aa6372a 100644 --- a/Marlin/src/module/ft_motion/stepping.h +++ b/Marlin/src/module/ft_motion/stepping.h @@ -251,4 +251,11 @@ typedef struct Stepping { return ((stepper_plan_head + 1) & FTM_BUFFER_MASK) == stepper_plan_tail; } + // Buffer runtime in milliseconds (ignoring ticks left in current frame) + FORCE_INLINE uint16_t buffer_runtime() const { + const uint32_t queued_frames = (stepper_plan_head - stepper_plan_tail) & FTM_BUFFER_MASK; + const uint32_t queued_ms = queued_frames * (1000UL * FTM_TS); + return queued_ms; + } + } stepping_t;