Browse Source

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

pull/1/head
Luu Lac 5 years ago
committed by Scott Lahteine
parent
commit
081e4506ca
  1. 1
      Marlin/src/gcode/calibrate/G28.cpp
  2. 33
      Marlin/src/gcode/geometry/G53-G59.cpp
  3. 5
      Marlin/src/gcode/geometry/G92.cpp
  4. 5
      Marlin/src/module/motion.cpp

1
Marlin/src/gcode/calibrate/G28.cpp

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

33
Marlin/src/gcode/geometry/G53-G59.cpp

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

5
Marlin/src/gcode/geometry/G92.cpp

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

5
Marlin/src/module/motion.cpp

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

Loading…
Cancel
Save