Asynchronous M114 and (R)ealtime position option (#17032)

This commit is contained in:
Scott Lahteine
2020-03-02 21:52:53 -06:00
committed by GitHub
parent 5171e9da93
commit 3a07b4412d
8 changed files with 131 additions and 36 deletions

View File

@ -34,7 +34,7 @@
#include "../../core/debug_out.h"
#endif
void report_xyze(const xyze_pos_t &pos, const uint8_t n=4, const uint8_t precision=3) {
void report_xyze(const xyze_pos_t &pos, const uint8_t n=XYZE, const uint8_t precision=3) {
char str[12];
for (uint8_t a = 0; a < n; a++) {
SERIAL_CHAR(' ', axis_codes[a], ':');
@ -42,6 +42,7 @@
}
SERIAL_EOL();
}
inline void report_xyz(const xyze_pos_t &pos) { report_xyze(pos, 3); }
void report_xyz(const xyz_pos_t &pos, const uint8_t precision=3) {
char str[12];
@ -51,23 +52,26 @@
}
SERIAL_EOL();
}
inline void report_xyz(const xyze_pos_t &pos) { report_xyze(pos, 3); }
void report_current_position_detail() {
// Position as sent by G-code
SERIAL_ECHOPGM("\nLogical:");
report_xyz(current_position.asLogical());
// Cartesian position in native machine space
SERIAL_ECHOPGM("Raw: ");
report_xyz(current_position);
xyze_pos_t leveled = current_position;
#if HAS_LEVELING
// Current position with leveling applied
SERIAL_ECHOPGM("Leveled:");
planner.apply_leveling(leveled);
report_xyz(leveled);
// Test planner un-leveling. This should match the Raw result.
SERIAL_ECHOPGM("UnLevel:");
xyze_pos_t unleveled = leveled;
planner.unapply_leveling(unleveled);
@ -75,6 +79,7 @@
#endif
#if IS_KINEMATIC
// Kinematics applied to the leveled position
#if IS_SCARA
SERIAL_ECHOPGM("ScaraK: ");
#else
@ -180,12 +185,21 @@
#endif // M114_DETAIL
/**
* M114: Report current position to host
* M114: Report the current position to host.
* Since steppers are moving, the count positions are
* projected by using planner calculations.
* D - Report more detail. This syncs the planner. (Requires M114_DETAIL)
* E - Report E stepper position (Requires M114_DETAIL)
* R - Report the realtime position instead of projected.
*/
void GcodeSuite::M114() {
#if ENABLED(M114_DETAIL)
if (parser.seen('D')) {
#if DISABLED(M114_LEGACY)
planner.synchronize();
#endif
report_current_position();
report_current_position_detail();
return;
}
@ -195,6 +209,12 @@ void GcodeSuite::M114() {
}
#endif
planner.synchronize();
report_current_position();
#if ENABLED(M114_REALTIME)
if (parser.seen('R')) { report_real_position(); return; }
#endif
#if ENABLED(M114_LEGACY)
planner.synchronize();
#endif
report_current_position_projected();
}