Skip to content

Commit 7e14b18

Browse files
authored
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
2 parents 8b21564 + 381aeb9 commit 7e14b18

File tree

3 files changed

+40
-54
lines changed

3 files changed

+40
-54
lines changed

Marlin/src/gcode/feature/ft_motion/M493.cpp

+14-28
Original file line numberDiff line numberDiff line change
@@ -190,25 +190,18 @@ void GcodeSuite::M493_report(const bool forReplay/*=true*/) {
190190
* R 0.00 Set the vibration tolerance for the Y axis
191191
*/
192192
void GcodeSuite::M493() {
193-
struct { bool update:1, reset_ft:1, report_h:1; } flag = { false };
193+
struct { bool update:1, report:1; } flag = { false };
194194

195195
if (!parser.seen_any())
196-
flag.report_h = true;
196+
flag.report = true;
197197

198198
// Parse 'S' mode parameter.
199199
if (parser.seen('S')) {
200200
const bool active = parser.value_bool();
201-
202201
if (active != ftMotion.cfg.active) {
203-
switch (active) {
204-
case false:
205-
flag.reset_ft = true;
206-
// fall-thru
207-
case true:
208-
flag.report_h = true;
209-
ftMotion.cfg.active = active;
210-
break;
211-
}
202+
stepper.ftMotion_syncPosition();
203+
ftMotion.cfg.active = active;
204+
flag.report = true;
212205
}
213206
}
214207

@@ -228,7 +221,7 @@ void GcodeSuite::M493() {
228221
case ftMotionShaper_3HEI:
229222
case ftMotionShaper_MZV:
230223
ftMotion.cfg.shaper[axis] = newsh;
231-
flag.update = flag.report_h = true;
224+
flag.update = flag.report = true;
232225
break;
233226
}
234227
}
@@ -249,7 +242,7 @@ void GcodeSuite::M493() {
249242
if (parser.seen('P')) {
250243
const bool val = parser.value_bool();
251244
ftMotion.cfg.linearAdvEna = val;
252-
flag.report_h = true;
245+
flag.report = true;
253246
SERIAL_ECHO_TERNARY(val, "Linear Advance ", "en", "dis", "abled.\n");
254247
}
255248

@@ -258,7 +251,7 @@ void GcodeSuite::M493() {
258251
const float val = parser.value_float();
259252
if (val >= 0.0f) {
260253
ftMotion.cfg.linearAdvK = val;
261-
flag.report_h = true;
254+
flag.report = true;
262255
}
263256
else // Value out of range.
264257
SERIAL_ECHOLNPGM("Linear Advance gain out of range.");
@@ -281,7 +274,7 @@ void GcodeSuite::M493() {
281274
#endif
282275
case dynFreqMode_DISABLED:
283276
ftMotion.cfg.dynFreqMode = val;
284-
flag.report_h = true;
277+
flag.report = true;
285278
break;
286279
default:
287280
SERIAL_ECHOLNPGM("?Invalid Dynamic Frequency Mode [D] value.");
@@ -309,7 +302,7 @@ void GcodeSuite::M493() {
309302
// TODO: Frequency minimum is dependent on the shaper used; the above check isn't always correct.
310303
if (WITHIN(val, FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2)) {
311304
ftMotion.cfg.baseFreq.x = val;
312-
flag.update = flag.reset_ft = flag.report_h = true;
305+
flag.update = flag.report = true;
313306
}
314307
else // Frequency out of range.
315308
SERIAL_ECHOLNPGM("Invalid [", C('A'), "] frequency value.");
@@ -323,7 +316,7 @@ void GcodeSuite::M493() {
323316
if (parser.seenval('F')) {
324317
if (modeUsesDynFreq) {
325318
ftMotion.cfg.dynFreqK.x = parser.value_float();
326-
flag.report_h = true;
319+
flag.report = true;
327320
}
328321
else
329322
SERIAL_ECHOLNPGM("Wrong mode for [", C('F'), "] frequency scaling.");
@@ -370,7 +363,7 @@ void GcodeSuite::M493() {
370363
const float val = parser.value_float();
371364
if (WITHIN(val, FTM_MIN_SHAPE_FREQ, (FTM_FS) / 2)) {
372365
ftMotion.cfg.baseFreq.y = val;
373-
flag.update = flag.reset_ft = flag.report_h = true;
366+
flag.update = flag.report = true;
374367
}
375368
else // Frequency out of range.
376369
SERIAL_ECHOLNPGM("Invalid frequency [", C('B'), "] value.");
@@ -384,7 +377,7 @@ void GcodeSuite::M493() {
384377
if (parser.seenval('H')) {
385378
if (modeUsesDynFreq) {
386379
ftMotion.cfg.dynFreqK.y = parser.value_float();
387-
flag.report_h = true;
380+
flag.report = true;
388381
}
389382
else
390383
SERIAL_ECHOLNPGM("Wrong mode for [", C('H'), "] frequency scaling.");
@@ -423,16 +416,9 @@ void GcodeSuite::M493() {
423416

424417
#endif // HAS_Y_AXIS
425418

426-
planner.synchronize();
427-
428419
if (flag.update) ftMotion.update_shaping_params();
429420

430-
if (flag.reset_ft) {
431-
stepper.ftMotion_syncPosition();
432-
ftMotion.reset();
433-
}
434-
435-
if (flag.report_h) say_shaping();
421+
if (flag.report) say_shaping();
436422
}
437423

438424
#endif // FT_MOTION

Marlin/src/lcd/menu/menu_motion.cpp

+25-25
Original file line numberDiff line numberDiff line change
@@ -351,44 +351,44 @@ void menu_move() {
351351
}
352352
#endif
353353

354-
void ftm_menu_set_cmpn(const AxisEnum axis, const ftMotionShaper_t s) {
354+
void ftm_menu_set_shaper(const AxisEnum axis, const ftMotionShaper_t s) {
355355
ftMotion.cfg.shaper[axis] = s;
356356
ftMotion.update_shaping_params();
357357
ui.go_back();
358358
}
359359

360-
inline void menu_ftm_cmpn_x() {
360+
inline void menu_ftm_shaper_x() {
361361
const ftMotionShaper_t shaper = ftMotion.cfg.shaper.x;
362362
START_MENU();
363363
BACK_ITEM(MSG_FIXED_TIME_MOTION);
364364

365-
if (shaper != ftMotionShaper_NONE) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_NONE); });
366-
if (shaper != ftMotionShaper_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_ZV); });
367-
if (shaper != ftMotionShaper_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_ZVD); });
368-
if (shaper != ftMotionShaper_ZVDD) ACTION_ITEM(MSG_FTM_ZVDD, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_ZVDD); });
369-
if (shaper != ftMotionShaper_ZVDDD) ACTION_ITEM(MSG_FTM_ZVDDD,[]{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_ZVDDD); });
370-
if (shaper != ftMotionShaper_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_EI); });
371-
if (shaper != ftMotionShaper_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_2HEI); });
372-
if (shaper != ftMotionShaper_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_3HEI); });
373-
if (shaper != ftMotionShaper_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_set_cmpn(X_AXIS, ftMotionShaper_MZV); });
365+
if (shaper != ftMotionShaper_NONE) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_NONE); });
366+
if (shaper != ftMotionShaper_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_ZV); });
367+
if (shaper != ftMotionShaper_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_ZVD); });
368+
if (shaper != ftMotionShaper_ZVDD) ACTION_ITEM(MSG_FTM_ZVDD, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_ZVDD); });
369+
if (shaper != ftMotionShaper_ZVDDD) ACTION_ITEM(MSG_FTM_ZVDDD,[]{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_ZVDDD); });
370+
if (shaper != ftMotionShaper_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_EI); });
371+
if (shaper != ftMotionShaper_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_2HEI); });
372+
if (shaper != ftMotionShaper_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_3HEI); });
373+
if (shaper != ftMotionShaper_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_set_shaper(X_AXIS, ftMotionShaper_MZV); });
374374

375375
END_MENU();
376376
}
377377

378-
inline void menu_ftm_cmpn_y() {
378+
inline void menu_ftm_shaper_y() {
379379
const ftMotionShaper_t shaper = ftMotion.cfg.shaper.y;
380380
START_MENU();
381381
BACK_ITEM(MSG_FIXED_TIME_MOTION);
382382

383-
if (shaper != ftMotionShaper_NONE) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_NONE); });
384-
if (shaper != ftMotionShaper_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_ZV); });
385-
if (shaper != ftMotionShaper_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_ZVD); });
386-
if (shaper != ftMotionShaper_ZVDD) ACTION_ITEM(MSG_FTM_ZVDD, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_ZVDD); });
387-
if (shaper != ftMotionShaper_ZVDDD) ACTION_ITEM(MSG_FTM_ZVDDD,[]{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_ZVDDD); });
388-
if (shaper != ftMotionShaper_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_EI); });
389-
if (shaper != ftMotionShaper_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_2HEI); });
390-
if (shaper != ftMotionShaper_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_3HEI); });
391-
if (shaper != ftMotionShaper_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_set_cmpn(Y_AXIS, ftMotionShaper_MZV); });
383+
if (shaper != ftMotionShaper_NONE) ACTION_ITEM(MSG_LCD_OFF, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_NONE); });
384+
if (shaper != ftMotionShaper_ZV) ACTION_ITEM(MSG_FTM_ZV, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_ZV); });
385+
if (shaper != ftMotionShaper_ZVD) ACTION_ITEM(MSG_FTM_ZVD, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_ZVD); });
386+
if (shaper != ftMotionShaper_ZVDD) ACTION_ITEM(MSG_FTM_ZVDD, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_ZVDD); });
387+
if (shaper != ftMotionShaper_ZVDDD) ACTION_ITEM(MSG_FTM_ZVDDD,[]{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_ZVDDD); });
388+
if (shaper != ftMotionShaper_EI) ACTION_ITEM(MSG_FTM_EI, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_EI); });
389+
if (shaper != ftMotionShaper_2HEI) ACTION_ITEM(MSG_FTM_2HEI, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_2HEI); });
390+
if (shaper != ftMotionShaper_3HEI) ACTION_ITEM(MSG_FTM_3HEI, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_3HEI); });
391+
if (shaper != ftMotionShaper_MZV) ACTION_ITEM(MSG_FTM_MZV, []{ ftm_menu_set_shaper(Y_AXIS, ftMotionShaper_MZV); });
392392

393393
END_MENU();
394394
}
@@ -438,7 +438,7 @@ void menu_move() {
438438

439439
if (c.active) {
440440
#if HAS_X_AXIS
441-
SUBMENU_N(X_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_cmpn_x);
441+
SUBMENU_N(X_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_shaper_x);
442442
MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(shaper_name[X_AXIS]); MENU_ITEM_ADDON_END();
443443

444444
if (AXIS_HAS_SHAPER(X)) {
@@ -449,7 +449,7 @@ void menu_move() {
449449
}
450450
#endif
451451
#if HAS_Y_AXIS
452-
SUBMENU_N(Y_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_cmpn_y);
452+
SUBMENU_N(Y_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_shaper_y);
453453
MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(shaper_name[Y_AXIS]); MENU_ITEM_ADDON_END();
454454

455455
if (AXIS_HAS_SHAPER(Y)) {
@@ -495,11 +495,11 @@ void menu_move() {
495495
START_MENU();
496496

497497
#if HAS_X_AXIS
498-
SUBMENU_N(X_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_cmpn_x);
498+
SUBMENU_N(X_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_shaper_x);
499499
MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(shaper_name[X_AXIS]); MENU_ITEM_ADDON_END();
500500
#endif
501501
#if HAS_Y_AXIS
502-
SUBMENU_N(Y_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_cmpn_y);
502+
SUBMENU_N(Y_AXIS, MSG_FTM_CMPN_MODE, menu_ftm_shaper_y);
503503
MENU_ITEM_ADDON_START_RJ(5); lcd_put_u8str(shaper_name[Y_AXIS]); MENU_ITEM_ADDON_END();
504504
#endif
505505

Marlin/src/module/stepper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3422,7 +3422,7 @@ void Stepper::set_axis_position(const AxisEnum a, const int32_t &v) {
34223422
#if ENABLED(FT_MOTION)
34233423

34243424
void Stepper::ftMotion_syncPosition() {
3425-
//planner.synchronize(); planner already synchronized in M493
3425+
planner.synchronize();
34263426

34273427
// Update stepper positions from the planner
34283428
AVR_ATOMIC_SECTION_START();

0 commit comments

Comments
 (0)