mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-29 14:57:05 +00:00
🩹 Fix FT Motion toggle in active job (#27335)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
4a36520820
commit
381aeb94c6
@ -190,25 +190,18 @@ void GcodeSuite::M493_report(const bool forReplay/*=true*/) {
|
||||
* R 0.00 Set the vibration tolerance for the Y axis
|
||||
*/
|
||||
void GcodeSuite::M493() {
|
||||
struct { bool update:1, reset_ft:1, report_h:1; } flag = { false };
|
||||
struct { bool update:1, report:1; } flag = { false };
|
||||
|
||||
if (!parser.seen_any())
|
||||
flag.report_h = true;
|
||||
flag.report = true;
|
||||
|
||||
// Parse 'S' mode parameter.
|
||||
if (parser.seen('S')) {
|
||||
const bool active = parser.value_bool();
|
||||
|
||||
if (active != ftMotion.cfg.active) {
|
||||
switch (active) {
|
||||
case false:
|
||||
flag.reset_ft = true;
|
||||
// fall-thru
|
||||
case true:
|
||||
flag.report_h = true;
|
||||
ftMotion.cfg.active = active;
|
||||
break;
|
||||
}
|
||||
stepper.ftMotion_syncPosition();
|
||||
ftMotion.cfg.active = active;
|
||||
flag.report = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,7 +221,7 @@ void GcodeSuite::M493() {
|
||||
case ftMotionShaper_3HEI:
|
||||
case ftMotionShaper_MZV:
|
||||
ftMotion.cfg.shaper[axis] = newsh;
|
||||
flag.update = flag.report_h = true;
|
||||
flag.update = flag.report = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -249,7 +242,7 @@ void GcodeSuite::M493() {
|
||||
if (parser.seen('P')) {
|
||||
const bool val = parser.value_bool();
|
||||
ftMotion.cfg.linearAdvEna = val;
|
||||
flag.report_h = true;
|
||||
flag.report = true;
|
||||
SERIAL_ECHO_TERNARY(val, "Linear Advance ", "en", "dis", "abled.\n");
|
||||
}
|
||||
|
||||
@ -258,7 +251,7 @@ void GcodeSuite::M493() {
|
||||
const float val = parser.value_float();
|
||||
if (val >= 0.0f) {
|
||||
ftMotion.cfg.linearAdvK = val;
|
||||
flag.report_h = true;
|
||||
flag.report = true;
|
||||
}
|
||||
else // Value out of range.
|
||||
SERIAL_ECHOLNPGM("Linear Advance gain out of range.");
|
||||
@ -281,7 +274,7 @@ void GcodeSuite::M493() {
|
||||
#endif
|
||||
case dynFreqMode_DISABLED:
|
||||
ftMotion.cfg.dynFreqMode = val;
|
||||
flag.report_h = true;
|
||||
flag.report = true;
|
||||
break;
|
||||
default:
|
||||
SERIAL_ECHOLNPGM("?Invalid Dynamic Frequency Mode [D] value.");
|
||||
@ -309,7 +302,7 @@ void GcodeSuite::M493() {
|
||||
// TODO: Frequency minimum is dependent on the shaper used; the above check isn't always correct.
|
||||
if (WITHIN(val, FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2)) {
|
||||
ftMotion.cfg.baseFreq.x = val;
|
||||
flag.update = flag.reset_ft = flag.report_h = true;
|
||||
flag.update = flag.report = true;
|
||||
}
|
||||
else // Frequency out of range.
|
||||
SERIAL_ECHOLNPGM("Invalid [", C('A'), "] frequency value.");
|
||||
@ -323,7 +316,7 @@ void GcodeSuite::M493() {
|
||||
if (parser.seenval('F')) {
|
||||
if (modeUsesDynFreq) {
|
||||
ftMotion.cfg.dynFreqK.x = parser.value_float();
|
||||
flag.report_h = true;
|
||||
flag.report = true;
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLNPGM("Wrong mode for [", C('F'), "] frequency scaling.");
|
||||
@ -370,7 +363,7 @@ void GcodeSuite::M493() {
|
||||
const float val = parser.value_float();
|
||||
if (WITHIN(val, FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2)) {
|
||||
ftMotion.cfg.baseFreq.y = val;
|
||||
flag.update = flag.reset_ft = flag.report_h = true;
|
||||
flag.update = flag.report = true;
|
||||
}
|
||||
else // Frequency out of range.
|
||||
SERIAL_ECHOLNPGM("Invalid frequency [", C('B'), "] value.");
|
||||
@ -384,7 +377,7 @@ void GcodeSuite::M493() {
|
||||
if (parser.seenval('H')) {
|
||||
if (modeUsesDynFreq) {
|
||||
ftMotion.cfg.dynFreqK.y = parser.value_float();
|
||||
flag.report_h = true;
|
||||
flag.report = true;
|
||||
}
|
||||
else
|
||||
SERIAL_ECHOLNPGM("Wrong mode for [", C('H'), "] frequency scaling.");
|
||||
@ -423,16 +416,9 @@ void GcodeSuite::M493() {
|
||||
|
||||
#endif // HAS_Y_AXIS
|
||||
|
||||
planner.synchronize();
|
||||
|
||||
if (flag.update) ftMotion.update_shaping_params();
|
||||
|
||||
if (flag.reset_ft) {
|
||||
stepper.ftMotion_syncPosition();
|
||||
ftMotion.reset();
|
||||
}
|
||||
|
||||
if (flag.report_h) say_shaping();
|
||||
if (flag.report) say_shaping();
|
||||
}
|
||||
|
||||
#endif // FT_MOTION
|
||||
|
@ -351,44 +351,44 @@ void menu_move() {
|
||||
}
|
||||
#endif
|
||||
|
||||
void ftm_menu_set_cmpn(const AxisEnum axis, const ftMotionShaper_t s) {
|
||||
void ftm_menu_set_shaper(const AxisEnum axis, const ftMotionShaper_t s) {
|
||||
ftMotion.cfg.shaper[axis] = s;
|
||||
ftMotion.update_shaping_params();
|
||||
ui.go_back();
|
||||
}
|
||||
|
||||
inline void menu_ftm_cmpn_x() {
|
||||
inline void menu_ftm_shaper_x() {
|
||||
const ftMotionShaper_t shaper = ftMotion.cfg.shaper.x;
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_FIXED_TIME_MOTION);
|
||||
|
||||
if (shaper != ftMotionShaper_NONE) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_NONE); });
|
||||
if (shaper != ftMotionShaper_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_ZV); });
|
||||
if (shaper != ftMotionShaper_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_ZVD); });
|
||||
if (shaper != ftMotionShaper_ZVDD) ACTION_ITEM(MSG_FTM_ZVDD, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_ZVDD); });
|
||||
if (shaper != ftMotionShaper_ZVDDD) ACTION_ITEM(MSG_FTM_ZVDDD,[]{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_ZVDDD); });
|
||||
if (shaper != ftMotionShaper_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_EI); });
|
||||
if (shaper != ftMotionShaper_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_2HEI); });
|
||||
if (shaper != ftMotionShaper_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_3HEI); });
|
||||
if (shaper != ftMotionShaper_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_MZV); });
|
||||
if (shaper != ftMotionShaper_NONE) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_NONE); });
|
||||
if (shaper != ftMotionShaper_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_ZV); });
|
||||
if (shaper != ftMotionShaper_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_ZVD); });
|
||||
if (shaper != ftMotionShaper_ZVDD) ACTION_ITEM(MSG_FTM_ZVDD, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_ZVDD); });
|
||||
if (shaper != ftMotionShaper_ZVDDD) ACTION_ITEM(MSG_FTM_ZVDDD,[]{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_ZVDDD); });
|
||||
if (shaper != ftMotionShaper_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_EI); });
|
||||
if (shaper != ftMotionShaper_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_2HEI); });
|
||||
if (shaper != ftMotionShaper_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_3HEI); });
|
||||
if (shaper != ftMotionShaper_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_MZV); });
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
inline void menu_ftm_cmpn_y() {
|
||||
inline void menu_ftm_shaper_y() {
|
||||
const ftMotionShaper_t shaper = ftMotion.cfg.shaper.y;
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_FIXED_TIME_MOTION);
|
||||
|
||||
if (shaper != ftMotionShaper_NONE) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_NONE); });
|
||||
if (shaper != ftMotionShaper_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_ZV); });
|
||||
if (shaper != ftMotionShaper_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_ZVD); });
|
||||
if (shaper != ftMotionShaper_ZVDD) ACTION_ITEM(MSG_FTM_ZVDD, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_ZVDD); });
|
||||
if (shaper != ftMotionShaper_ZVDDD) ACTION_ITEM(MSG_FTM_ZVDDD,[]{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_ZVDDD); });
|
||||
if (shaper != ftMotionShaper_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_EI); });
|
||||
if (shaper != ftMotionShaper_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_2HEI); });
|
||||
if (shaper != ftMotionShaper_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_3HEI); });
|
||||
if (shaper != ftMotionShaper_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_MZV); });
|
||||
if (shaper != ftMotionShaper_NONE) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_NONE); });
|
||||
if (shaper != ftMotionShaper_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_ZV); });
|
||||
if (shaper != ftMotionShaper_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_ZVD); });
|
||||
if (shaper != ftMotionShaper_ZVDD) ACTION_ITEM(MSG_FTM_ZVDD, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_ZVDD); });
|
||||
if (shaper != ftMotionShaper_ZVDDD) ACTION_ITEM(MSG_FTM_ZVDDD,[]{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_ZVDDD); });
|
||||
if (shaper != ftMotionShaper_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_EI); });
|
||||
if (shaper != ftMotionShaper_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_2HEI); });
|
||||
if (shaper != ftMotionShaper_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_3HEI); });
|
||||
if (shaper != ftMotionShaper_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_MZV); });
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
@ -438,7 +438,7 @@ void menu_move() {
|
||||
|
||||
if (c.active) {
|
||||
#if HAS_X_AXIS
|
||||
SUBMENU_N(X_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_cmpn_x);
|
||||
SUBMENU_N(X_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_shaper_x);
|
||||
MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(shaper_name[X_AXIS]); MENU_ITEM_ADDON_END();
|
||||
|
||||
if (AXIS_HAS_SHAPER(X)) {
|
||||
@ -449,7 +449,7 @@ void menu_move() {
|
||||
}
|
||||
#endif
|
||||
#if HAS_Y_AXIS
|
||||
SUBMENU_N(Y_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_cmpn_y);
|
||||
SUBMENU_N(Y_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_shaper_y);
|
||||
MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(shaper_name[Y_AXIS]); MENU_ITEM_ADDON_END();
|
||||
|
||||
if (AXIS_HAS_SHAPER(Y)) {
|
||||
@ -495,11 +495,11 @@ void menu_move() {
|
||||
START_MENU();
|
||||
|
||||
#if HAS_X_AXIS
|
||||
SUBMENU_N(X_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_cmpn_x);
|
||||
SUBMENU_N(X_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_shaper_x);
|
||||
MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(shaper_name[X_AXIS]); MENU_ITEM_ADDON_END();
|
||||
#endif
|
||||
#if HAS_Y_AXIS
|
||||
SUBMENU_N(Y_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_cmpn_y);
|
||||
SUBMENU_N(Y_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_shaper_y);
|
||||
MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(shaper_name[Y_AXIS]); MENU_ITEM_ADDON_END();
|
||||
#endif
|
||||
|
||||
|
@ -3422,7 +3422,7 @@ void Stepper::set_axis_position(const AxisEnum a, const int32_t &v) {
|
||||
#if ENABLED(FT_MOTION)
|
||||
|
||||
void Stepper::ftMotion_syncPosition() {
|
||||
//planner.synchronize(); planner already synchronized in M493
|
||||
planner.synchronize();
|
||||
|
||||
// Update stepper positions from the planner
|
||||
AVR_ATOMIC_SECTION_START();
|
||||
|
Loading…
Reference in New Issue
Block a user