Fix G53 as prefix, G28 with CNC_COORDINATE_SYSTEMS (#15069)

2.0.x
Luu Lac 5 years ago committed by Scott Lahteine
parent ca084dcfe8
commit 081e4506ca

@ -453,6 +453,7 @@ void GcodeSuite::G28(const bool always_home_all) {
ui.refresh();
report_current_position();
#if ENABLED(NANODLP_Z_SYNC)
#if ENABLED(NANODLP_ALL_AXIS)
#define _HOME_SYNC true // For any axis, output sync text.

@ -27,23 +27,21 @@
#include "../../module/stepper.h"
//#define DEBUG_M53
/**
* Select a coordinate system and update the workspace offset.
* System index -1 is used to specify machine-native.
*/
bool GcodeSuite::select_coordinate_system(const int8_t _new) {
if (active_coordinate_system == _new) return false;
planner.synchronize();
float old_offset[XYZ] = { 0 }, new_offset[XYZ] = { 0 };
if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
COPY(old_offset, coordinate_system[active_coordinate_system]);
active_coordinate_system = _new;
float new_offset[XYZ] = { 0 };
if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1))
COPY(new_offset, coordinate_system[_new]);
active_coordinate_system = _new;
LOOP_XYZ(i) {
const float diff = new_offset[i] - old_offset[i];
if (diff) {
position_shift[i] += diff;
if (position_shift[i] != new_offset[i]) {
position_shift[i] = new_offset[i];
update_workspace_offset((AxisEnum)i);
}
}
@ -60,11 +58,20 @@ bool GcodeSuite::select_coordinate_system(const int8_t _new) {
* Marlin also uses G53 on a line by itself to go back to native space.
*/
void GcodeSuite::G53() {
const int8_t _system = active_coordinate_system;
active_coordinate_system = -1;
if (parser.chain()) { // If this command has more following...
process_parsed_command();
active_coordinate_system = _system;
const int8_t old_system = active_coordinate_system;
select_coordinate_system(-1); // Always remove workspace offsets
#ifdef DEBUG_M53
SERIAL_ECHOLNPGM("Go to native space");
report_current_position();
#endif
if (parser.chain()) { // Command to chain?
process_parsed_command(); // ...process the chained command
select_coordinate_system(old_system);
#ifdef DEBUG_M53
SERIAL_ECHOLNPAIR("Go back to workspace ", old_system);
report_current_position();
#endif
}
}

@ -52,12 +52,9 @@ void GcodeSuite::G92() {
case 1: {
// Zero the G92 values and restore current position
#if !IS_SCARA
LOOP_XYZ(i) {
const float v = position_shift[i];
if (v) {
position_shift[i] = 0;
update_workspace_offset((AxisEnum)i);
}
LOOP_XYZ(i) if (position_shift[i]) {
position_shift[i] = 0;
update_workspace_offset((AxisEnum)i);
}
#endif // Not SCARA
} return;

@ -1325,11 +1325,6 @@ void set_axis_is_at_home(const AxisEnum axis) {
SBI(axis_known_position, axis);
SBI(axis_homed, axis);
#if HAS_POSITION_SHIFT
position_shift[axis] = 0;
update_workspace_offset(axis);
#endif
#if ENABLED(DUAL_X_CARRIAGE)
if (axis == X_AXIS && (active_extruder == 1 || dual_x_carriage_mode == DXC_DUPLICATION_MODE)) {
current_position[X_AXIS] = x_home_pos(active_extruder);

Loading…
Cancel
Save