|
@@ -27,23 +27,21 @@
|
27
|
27
|
|
28
|
28
|
#include "../../module/stepper.h"
|
29
|
29
|
|
|
30
|
+//#define DEBUG_M53
|
|
31
|
+
|
30
|
32
|
/**
|
31
|
33
|
* Select a coordinate system and update the workspace offset.
|
32
|
34
|
* System index -1 is used to specify machine-native.
|
33
|
35
|
*/
|
34
|
36
|
bool GcodeSuite::select_coordinate_system(const int8_t _new) {
|
35
|
37
|
if (active_coordinate_system == _new) return false;
|
36
|
|
- planner.synchronize();
|
37
|
|
- float old_offset[XYZ] = { 0 }, new_offset[XYZ] = { 0 };
|
38
|
|
- if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
|
39
|
|
- COPY(old_offset, coordinate_system[active_coordinate_system]);
|
|
38
|
+ active_coordinate_system = _new;
|
|
39
|
+ float new_offset[XYZ] = { 0 };
|
40
|
40
|
if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1))
|
41
|
41
|
COPY(new_offset, coordinate_system[_new]);
|
42
|
|
- active_coordinate_system = _new;
|
43
|
42
|
LOOP_XYZ(i) {
|
44
|
|
- const float diff = new_offset[i] - old_offset[i];
|
45
|
|
- if (diff) {
|
46
|
|
- position_shift[i] += diff;
|
|
43
|
+ if (position_shift[i] != new_offset[i]) {
|
|
44
|
+ position_shift[i] = new_offset[i];
|
47
|
45
|
update_workspace_offset((AxisEnum)i);
|
48
|
46
|
}
|
49
|
47
|
}
|
|
@@ -60,11 +58,20 @@ bool GcodeSuite::select_coordinate_system(const int8_t _new) {
|
60
|
58
|
* Marlin also uses G53 on a line by itself to go back to native space.
|
61
|
59
|
*/
|
62
|
60
|
void GcodeSuite::G53() {
|
63
|
|
- const int8_t _system = active_coordinate_system;
|
64
|
|
- active_coordinate_system = -1;
|
65
|
|
- if (parser.chain()) { // If this command has more following...
|
66
|
|
- process_parsed_command();
|
67
|
|
- active_coordinate_system = _system;
|
|
61
|
+ const int8_t old_system = active_coordinate_system;
|
|
62
|
+ select_coordinate_system(-1); // Always remove workspace offsets
|
|
63
|
+ #ifdef DEBUG_M53
|
|
64
|
+ SERIAL_ECHOLNPGM("Go to native space");
|
|
65
|
+ report_current_position();
|
|
66
|
+ #endif
|
|
67
|
+
|
|
68
|
+ if (parser.chain()) { // Command to chain?
|
|
69
|
+ process_parsed_command(); // ...process the chained command
|
|
70
|
+ select_coordinate_system(old_system);
|
|
71
|
+ #ifdef DEBUG_M53
|
|
72
|
+ SERIAL_ECHOLNPAIR("Go back to workspace ", old_system);
|
|
73
|
+ report_current_position();
|
|
74
|
+ #endif
|
68
|
75
|
}
|
69
|
76
|
}
|
70
|
77
|
|