Browse Source

Merge pull request #8200 from thinkyhead/bf1_asterisk_not_special

[1.1.x] CNC_COORDINATE_SYSTEMS
Scott Lahteine 7 years ago
parent
commit
95296191a2
No account linked to committer's email address
40 changed files with 549 additions and 103 deletions
  1. 1
    1
      .travis.yml
  2. 1
    1
      Marlin/Conditionals_post.h
  3. 8
    0
      Marlin/Configuration_adv.h
  4. 2
    15
      Marlin/I2CPositionEncoder.h
  5. 8
    0
      Marlin/Marlin.h
  6. 155
    59
      Marlin/Marlin_main.cpp
  7. 4
    0
      Marlin/SanityCheck.h
  8. 97
    11
      Marlin/configuration_store.cpp
  9. 8
    0
      Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h
  10. 8
    0
      Marlin/example_configurations/Anet/A6/Configuration_adv.h
  11. 8
    0
      Marlin/example_configurations/Anet/A8/Configuration_adv.h
  12. 8
    0
      Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h
  13. 8
    0
      Marlin/example_configurations/BQ/Hephestos_2/Configuration_adv.h
  14. 8
    0
      Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h
  15. 8
    0
      Marlin/example_configurations/Cartesio/Configuration_adv.h
  16. 8
    0
      Marlin/example_configurations/Creality/CR-10/Configuration_adv.h
  17. 8
    0
      Marlin/example_configurations/Felix/Configuration_adv.h
  18. 8
    0
      Marlin/example_configurations/FolgerTech/i3-2020/Configuration_adv.h
  19. 8
    0
      Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h
  20. 8
    0
      Marlin/example_configurations/Malyan/M150/Configuration_adv.h
  21. 8
    0
      Marlin/example_configurations/Micromake/C1/enhanced/Configuration_adv.h
  22. 8
    0
      Marlin/example_configurations/RigidBot/Configuration_adv.h
  23. 8
    0
      Marlin/example_configurations/SCARA/Configuration_adv.h
  24. 8
    0
      Marlin/example_configurations/Sanguinololu/Configuration_adv.h
  25. 8
    0
      Marlin/example_configurations/TinyBoy2/Configuration_adv.h
  26. 8
    0
      Marlin/example_configurations/Velleman/K8200/Configuration_adv.h
  27. 8
    0
      Marlin/example_configurations/Velleman/K8400/Configuration_adv.h
  28. 8
    0
      Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h
  29. 8
    0
      Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h
  30. 8
    0
      Marlin/example_configurations/delta/generic/Configuration_adv.h
  31. 8
    0
      Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h
  32. 8
    0
      Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h
  33. 8
    0
      Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h
  34. 8
    0
      Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h
  35. 8
    0
      Marlin/example_configurations/makibox/Configuration_adv.h
  36. 8
    0
      Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h
  37. 8
    0
      Marlin/example_configurations/wt150/Configuration_adv.h
  38. 20
    0
      Marlin/gcode.cpp
  39. 5
    0
      Marlin/gcode.h
  40. 16
    16
      Marlin/planner_bezier.cpp

+ 1
- 1
.travis.yml View File

@@ -86,7 +86,7 @@ script:
86 86
   - opt_set TEMP_SENSOR_0 -2
87 87
   - opt_set TEMP_SENSOR_1 1
88 88
   - opt_set TEMP_SENSOR_BED 1
89
-  - opt_enable PIDTEMPBED FIX_MOUNTED_PROBE Z_SAFE_HOMING ARC_P_CIRCLES CNC_WORKSPACE_PLANES
89
+  - opt_enable PIDTEMPBED FIX_MOUNTED_PROBE Z_SAFE_HOMING ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS
90 90
   - opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS
91 91
   - opt_enable BLINKM PCA9632 RGB_LED NEOPIXEL_LED
92 92
   - opt_enable AUTO_BED_LEVELING_LINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE

+ 1
- 1
Marlin/Conditionals_post.h View File

@@ -1036,7 +1036,7 @@
1036 1036
   #define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y))
1037 1037
 
1038 1038
   // Add commands that need sub-codes to this list
1039
-  #define USE_GCODE_SUBCODES ENABLED(G38_PROBE_TARGET)
1039
+  #define USE_GCODE_SUBCODES ENABLED(G38_PROBE_TARGET) || ENABLED(CNC_COORDINATE_SYSTEMS)
1040 1040
 
1041 1041
   // MESH_BED_LEVELING overrides PROBE_MANUALLY
1042 1042
   #if ENABLED(MESH_BED_LEVELING)

+ 8
- 0
Marlin/Configuration_adv.h View File

@@ -1268,6 +1268,14 @@
1268 1268
 #endif
1269 1269
 
1270 1270
 /**
1271
+ * CNC Coordinate Systems
1272
+ *
1273
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1274
+ * and G92.1 to reset the workspace to native machine space.
1275
+ */
1276
+//#define CNC_COORDINATE_SYSTEMS
1277
+
1278
+/**
1271 1279
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1272 1280
  */
1273 1281
 //#define PINS_DEBUGGING

+ 2
- 15
Marlin/I2CPositionEncoder.h View File

@@ -127,10 +127,7 @@
127 127
               invert              = false,
128 128
               ec                  = true;
129 129
 
130
-    float     axisOffset          = 0;
131
-
132
-    int32_t   axisOffsetTicks     = 0,
133
-              zeroOffset          = 0,
130
+    int32_t   zeroOffset          = 0,
134 131
               lastPosition        = 0,
135 132
               position;
136 133
 
@@ -168,7 +165,7 @@
168 165
     }
169 166
 
170 167
     FORCE_INLINE float get_position_mm() { return mm_from_count(get_position()); }
171
-    FORCE_INLINE int32_t get_position() { return get_raw_count() - zeroOffset - axisOffsetTicks; }
168
+    FORCE_INLINE int32_t get_position() { return get_raw_count() - zeroOffset; }
172 169
 
173 170
     int32_t get_axis_error_steps(const bool report);
174 171
     float get_axis_error_mm(const bool report);
@@ -219,16 +216,6 @@
219 216
 
220 217
     FORCE_INLINE int get_stepper_ticks() { return stepperTicks; }
221 218
     FORCE_INLINE void set_stepper_ticks(const int ticks) { stepperTicks = ticks; }
222
-
223
-    FORCE_INLINE float get_axis_offset() { return axisOffset; }
224
-    FORCE_INLINE void set_axis_offset(const float newOffset) {
225
-      axisOffset = newOffset;
226
-      axisOffsetTicks = int32_t(axisOffset * get_encoder_ticks_mm());
227
-    }
228
-
229
-    FORCE_INLINE void set_current_position(const float newPositionMm) {
230
-      set_axis_offset(get_position_mm() - newPositionMm + axisOffset);
231
-    }
232 219
   };
233 220
 
234 221
   class I2CPositionEncodersMgr {

+ 8
- 0
Marlin/Marlin.h View File

@@ -290,6 +290,14 @@ extern float soft_endstop_min[XYZ], soft_endstop_max[XYZ];
290 290
   void update_software_endstops(const AxisEnum axis);
291 291
 #endif
292 292
 
293
+#if ENABLED(CNC_COORDINATE_SYSTEMS)
294
+  #define MAX_COORDINATE_SYSTEMS 9
295
+  extern float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
296
+  bool select_coordinate_system(const int8_t _new);
297
+#endif
298
+
299
+void report_current_position();
300
+
293 301
 #if IS_KINEMATIC
294 302
   extern float delta[ABC];
295 303
   void inverse_kinematics(const float raw[XYZ]);

+ 155
- 59
Marlin/Marlin_main.cpp View File

@@ -364,6 +364,11 @@
364 364
   #define LED_WHITE 0, 0, 0, 255
365 365
 #endif
366 366
 
367
+#if ENABLED(CNC_COORDINATE_SYSTEMS)
368
+  int8_t active_coordinate_system = -1; // machine space
369
+  float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
370
+#endif
371
+
367 372
 bool Running = true;
368 373
 
369 374
 uint8_t marlin_debug_flags = DEBUG_NONE;
@@ -745,6 +750,7 @@ void stop();
745 750
 
746 751
 void get_available_commands();
747 752
 void process_next_command();
753
+void process_parsed_command();
748 754
 void prepare_move_to_destination();
749 755
 
750 756
 void get_cartesian_from_steppers();
@@ -3672,6 +3678,73 @@ inline void gcode_G4() {
3672 3678
 
3673 3679
 #endif // CNC_WORKSPACE_PLANES
3674 3680
 
3681
+#if ENABLED(CNC_COORDINATE_SYSTEMS)
3682
+
3683
+  /**
3684
+   * Select a coordinate system and update the current position.
3685
+   * System index -1 is used to specify machine-native.
3686
+   */
3687
+  bool select_coordinate_system(const int8_t _new) {
3688
+    if (active_coordinate_system == _new) return false;
3689
+    float old_offset[XYZ] = { 0 }, new_offset[XYZ] = { 0 };
3690
+    if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
3691
+      COPY(old_offset, coordinate_system[active_coordinate_system]);
3692
+    if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1))
3693
+      COPY(new_offset, coordinate_system[_new]);
3694
+    active_coordinate_system = _new;
3695
+    bool didXYZ = false;
3696
+    LOOP_XYZ(i) {
3697
+      const float diff = new_offset[i] - old_offset[i];
3698
+      if (diff) {
3699
+        position_shift[i] += diff;
3700
+        update_software_endstops((AxisEnum)i);
3701
+        didXYZ = true;
3702
+      }
3703
+    }
3704
+    if (didXYZ) SYNC_PLAN_POSITION_KINEMATIC();
3705
+    return true;
3706
+  }
3707
+
3708
+  /**
3709
+   * In CNC G-code G53 is like a modifier
3710
+   * It precedes a movement command (or other modifiers) on the same line.
3711
+   * This is the first command to use parser.chain() to make this possible.
3712
+   */
3713
+  inline void gcode_G53() {
3714
+    // If this command has more following...
3715
+    if (parser.chain()) {
3716
+      const int8_t _system = active_coordinate_system;
3717
+      active_coordinate_system = -1;
3718
+      process_parsed_command();
3719
+      active_coordinate_system = _system;
3720
+    }
3721
+  }
3722
+
3723
+  /**
3724
+   * G54-G59.3: Select a new workspace
3725
+   *
3726
+   * A workspace is an XYZ offset to the machine native space.
3727
+   * All workspaces default to 0,0,0 at start, or with EEPROM
3728
+   * support they may be restored from a previous session.
3729
+   *
3730
+   * G92 is used to set the current workspace's offset.
3731
+   */
3732
+  inline void gcode_G54_59(uint8_t subcode=0) {
3733
+    const int8_t _space = parser.codenum - 54 + subcode;
3734
+    if (select_coordinate_system(_space)) {
3735
+      SERIAL_PROTOCOLLNPAIR("Select workspace ", _space);
3736
+      report_current_position();
3737
+    }
3738
+  }
3739
+  FORCE_INLINE void gcode_G54() { gcode_G54_59(); }
3740
+  FORCE_INLINE void gcode_G55() { gcode_G54_59(); }
3741
+  FORCE_INLINE void gcode_G56() { gcode_G54_59(); }
3742
+  FORCE_INLINE void gcode_G57() { gcode_G54_59(); }
3743
+  FORCE_INLINE void gcode_G58() { gcode_G54_59(); }
3744
+  FORCE_INLINE void gcode_G59() { gcode_G54_59(parser.subcode); }
3745
+
3746
+#endif
3747
+
3675 3748
 #if ENABLED(INCH_MODE_SUPPORT)
3676 3749
   /**
3677 3750
    * G20: Set input mode to inches
@@ -4153,13 +4226,12 @@ inline void gcode_G28(const bool always_home_all) {
4153 4226
 
4154 4227
   // Restore the active tool after homing
4155 4228
   #if HOTENDS > 1
4156
-    tool_change(old_tool_index, 0,
4157
-      #if ENABLED(PARKING_EXTRUDER)
4158
-        false // fetch the previous toolhead
4159
-      #else
4160
-        true
4161
-      #endif
4162
-    );
4229
+    #if ENABLED(PARKING_EXTRUDER)
4230
+      #define NO_FETCH false // fetch the previous toolhead
4231
+    #else
4232
+      #define NO_FETCH true
4233
+    #endif
4234
+    tool_change(old_tool_index, 0, NO_FETCH);
4163 4235
   #endif
4164 4236
 
4165 4237
   lcd_refresh();
@@ -5498,16 +5570,18 @@ void home_all_axes() { gcode_G28(true); }
5498 5570
                     dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
5499 5571
       #endif
5500 5572
 
5501
-          LOOP_CAL_ALL(axis) z_at_pt[axis] = 0.0;
5573
+      LOOP_CAL_ALL(axis) z_at_pt[axis] = 0.0;
5502 5574
 
5503 5575
       if (!_0p_calibration) {
5504 5576
 
5505 5577
         if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
5506
-          #if ENABLED(PROBE_MANUALLY)
5507
-            z_at_pt[CEN] += lcd_probe_pt(0, 0);
5508
-          #else
5509
-            z_at_pt[CEN] += probe_pt(dx, dy, stow_after_each, 1, false);
5510
-          #endif
5578
+          z_at_pt[CEN] +=
5579
+            #if ENABLED(PROBE_MANUALLY)
5580
+              lcd_probe_pt(0, 0)
5581
+            #else
5582
+              probe_pt(dx, dy, stow_after_each, 1, false)
5583
+            #endif
5584
+          ;
5511 5585
         }
5512 5586
 
5513 5587
         if (_7p_calibration) { // probe extra center points
@@ -5516,11 +5590,13 @@ void home_all_axes() { gcode_G28(true); }
5516 5590
           I_LOOP_CAL_PT(axis, start, steps) {
5517 5591
             const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
5518 5592
                         r = delta_calibration_radius * 0.1;
5519
-            #if ENABLED(PROBE_MANUALLY)
5520
-              z_at_pt[CEN] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5521
-            #else
5522
-              z_at_pt[CEN] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
5523
-            #endif
5593
+            z_at_pt[CEN] +=
5594
+              #if ENABLED(PROBE_MANUALLY)
5595
+                lcd_probe_pt(cos(a) * r, sin(a) * r)
5596
+              #else
5597
+                probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1)
5598
+              #endif
5599
+            ;
5524 5600
           }
5525 5601
           z_at_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
5526 5602
         }
@@ -5543,29 +5619,22 @@ void home_all_axes() { gcode_G28(true); }
5543 5619
               const float a = RADIANS(210 + (360 / NPP) *  (axis - 1)),
5544 5620
                           r = delta_calibration_radius * (1 + 0.1 * (zig_zag ? circle : - circle)),
5545 5621
                           interpol = fmod(axis, 1);
5546
-              #if ENABLED(PROBE_MANUALLY)
5547
-                 float z_temp = lcd_probe_pt(cos(a) * r, sin(a) * r);
5548
-              #else
5549
-                float z_temp = probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
5550
-              #endif
5622
+              const float z_temp =
5623
+                #if ENABLED(PROBE_MANUALLY)
5624
+                  lcd_probe_pt(cos(a) * r, sin(a) * r)
5625
+                #else
5626
+                  probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1)
5627
+                #endif
5628
+              ;
5551 5629
               // split probe point to neighbouring calibration points
5552
-              z_at_pt[round(axis - interpol + NPP - 1) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
5553
-              z_at_pt[round(axis - interpol) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
5630
+              z_at_pt[uint8_t(round(axis - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
5631
+              z_at_pt[uint8_t(round(axis - interpol          )) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
5554 5632
             }
5555 5633
             zig_zag = !zig_zag;
5556 5634
           }
5557 5635
           if (_7p_intermed_points)
5558
-            LOOP_CAL_RAD(axis) {
5559
-/*
5560
-            // average intermediate points to towers and opposites - only required with _7P_STEP >= 2
5561
-              for (int8_t i = 1; i < _7P_STEP; i++) {
5562
-                const float interpol = i * (1.0 / _7P_STEP);
5563
-                z_at_pt[axis] += (z_at_pt[(axis + NPP - i - 1) % NPP + 1]
5564
-                                 + z_at_pt[axis + i]) * sq(cos(RADIANS(interpol * 90)));
5565
-              }
5566
-*/
5636
+            LOOP_CAL_RAD(axis)
5567 5637
               z_at_pt[axis] /= _7P_STEP  / steps;
5568
-            }
5569 5638
         }
5570 5639
 
5571 5640
 
@@ -6204,7 +6273,30 @@ inline void gcode_G92() {
6204 6273
 
6205 6274
   if (!didE) stepper.synchronize();
6206 6275
 
6207
-  LOOP_XYZE(i) {
6276
+  #if ENABLED(CNC_COORDINATE_SYSTEMS)
6277
+    switch (parser.subcode) {
6278
+      case 1:
6279
+        // Zero the G92 values and restore current position
6280
+        #if !IS_SCARA
6281
+          LOOP_XYZ(i) {
6282
+            const float v = position_shift[i];
6283
+            if (v) {
6284
+              position_shift[i] = 0;
6285
+              update_software_endstops((AxisEnum)i);
6286
+            }
6287
+          }
6288
+        #endif // Not SCARA
6289
+        return;
6290
+    }
6291
+  #endif
6292
+
6293
+  #if ENABLED(CNC_COORDINATE_SYSTEMS)
6294
+    #define IS_G92_0 (parser.subcode == 0)
6295
+  #else
6296
+    #define IS_G92_0 true
6297
+  #endif
6298
+
6299
+  if (IS_G92_0) LOOP_XYZE(i) {
6208 6300
     if (parser.seenval(axis_codes[i])) {
6209 6301
       #if IS_SCARA
6210 6302
         if (i != E_AXIS) didXYZ = true;
@@ -6219,16 +6311,18 @@ inline void gcode_G92() {
6219 6311
           #if HAS_POSITION_SHIFT
6220 6312
             position_shift[i] += v - p; // Offset the coordinate space
6221 6313
             update_software_endstops((AxisEnum)i);
6222
-
6223
-            #if ENABLED(I2C_POSITION_ENCODERS)
6224
-              I2CPEM.encoders[I2CPEM.idx_from_axis((AxisEnum)i)].set_axis_offset(position_shift[i]);
6225
-            #endif
6226
-
6227 6314
           #endif
6228 6315
         }
6229 6316
       #endif
6230 6317
     }
6231 6318
   }
6319
+
6320
+  #if ENABLED(CNC_COORDINATE_SYSTEMS)
6321
+    // Apply workspace offset to the active coordinate system
6322
+    if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1))
6323
+      COPY(coordinate_system[active_coordinate_system], position_shift);
6324
+  #endif
6325
+
6232 6326
   if (didXYZ)
6233 6327
     SYNC_PLAN_POSITION_KINEMATIC();
6234 6328
   else if (didE)
@@ -10713,7 +10807,7 @@ inline void invalid_extruder_error(const uint8_t e) {
10713 10807
     #endif
10714 10808
   }
10715 10809
 
10716
-  FORCE_INLINE void fanmux_init(void){
10810
+  FORCE_INLINE void fanmux_init(void) {
10717 10811
     SET_OUTPUT(FANMUX0_PIN);
10718 10812
     #if PIN_EXISTS(FANMUX1)
10719 10813
       SET_OUTPUT(FANMUX1_PIN);
@@ -11202,26 +11296,11 @@ inline void gcode_T(const uint8_t tmp_extruder) {
11202 11296
 }
11203 11297
 
11204 11298
 /**
11205
- * Process a single command and dispatch it to its handler
11206
- * This is called from the main loop()
11299
+ * Process the parsed command and dispatch it to its handler
11207 11300
  */
11208
-void process_next_command() {
11209
-  char * const current_command = command_queue[cmd_queue_index_r];
11210
-
11211
-  if (DEBUGGING(ECHO)) {
11212
-    SERIAL_ECHO_START();
11213
-    SERIAL_ECHOLN(current_command);
11214
-    #if ENABLED(M100_FREE_MEMORY_WATCHER)
11215
-      SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
11216
-      M100_dump_routine("   Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
11217
-    #endif
11218
-  }
11219
-
11301
+void process_parsed_command() {
11220 11302
   KEEPALIVE_STATE(IN_HANDLER);
11221 11303
 
11222
-  // Parse the next command in the queue
11223
-  parser.parse(current_command);
11224
-
11225 11304
   // Handle a known G, M, or T
11226 11305
   switch (parser.command_letter) {
11227 11306
     case 'G': switch (parser.codenum) {
@@ -12061,6 +12140,23 @@ void process_next_command() {
12061 12140
   ok_to_send();
12062 12141
 }
12063 12142
 
12143
+void process_next_command() {
12144
+  char * const current_command = command_queue[cmd_queue_index_r];
12145
+
12146
+  if (DEBUGGING(ECHO)) {
12147
+    SERIAL_ECHO_START();
12148
+    SERIAL_ECHOLN(current_command);
12149
+    #if ENABLED(M100_FREE_MEMORY_WATCHER)
12150
+      SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
12151
+      M100_dump_routine("   Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
12152
+    #endif
12153
+  }
12154
+
12155
+  // Parse the next command in the queue
12156
+  parser.parse(current_command);
12157
+  process_parsed_command();
12158
+}
12159
+
12064 12160
 /**
12065 12161
  * Send a "Resend: nnn" message to the host to
12066 12162
  * indicate that a command needs to be re-sent.

+ 4
- 0
Marlin/SanityCheck.h View File

@@ -1483,3 +1483,7 @@ static_assert(COUNT(sanity_arr_3) <= XYZE_N, "DEFAULT_MAX_ACCELERATION has too m
1483 1483
     #endif
1484 1484
   #endif
1485 1485
 #endif // SPINDLE_LASER_ENABLE
1486
+
1487
+#if ENABLED(CNC_COORDINATE_SYSTEMS) && ENABLED(NO_WORKSPACE_OFFSETS)
1488
+  #error "CNC_COORDINATE_SYSTEMS is incompatible with NO_WORKSPACE_OFFSETS."
1489
+#endif

+ 97
- 11
Marlin/configuration_store.cpp View File

@@ -36,13 +36,13 @@
36 36
  *
37 37
  */
38 38
 
39
-#define EEPROM_VERSION "V43"
39
+#define EEPROM_VERSION "V44"
40 40
 
41 41
 // Change EEPROM version if these are changed:
42 42
 #define EEPROM_OFFSET 100
43 43
 
44 44
 /**
45
- * V43 EEPROM Layout:
45
+ * V44 EEPROM Layout:
46 46
  *
47 47
  *  100  Version                                    (char x4)
48 48
  *  104  EEPROM CRC16                               (uint16_t)
@@ -162,8 +162,11 @@
162 162
  *  588  M907 Z    Stepper Z current                (uint32_t)
163 163
  *  592  M907 E    Stepper E current                (uint32_t)
164 164
  *
165
- *  596                                Minimum end-point
166
- * 1917 (596 + 36 + 9 + 288 + 988)     Maximum end-point
165
+ * CNC_COORDINATE_SYSTEMS                           108 bytes
166
+ *  596  G54-G59.3 coordinate_system                (float x 27)
167
+ *
168
+ *  704                                Minimum end-point
169
+ * 2025 (704 + 36 + 9 + 288 + 988)     Maximum end-point
167 170
  *
168 171
  * ========================================================================
169 172
  * meshes_begin (between max and min end-point, directly above)
@@ -209,6 +212,10 @@ MarlinSettings settings;
209 212
   float new_z_fade_height;
210 213
 #endif
211 214
 
215
+#if ENABLED(CNC_COORDINATE_SYSTEMS)
216
+  bool position_changed;
217
+#endif
218
+
212 219
 /**
213 220
 * Post-process after Retrieve or Reset
214 221
 */
@@ -253,6 +260,13 @@ void MarlinSettings::postprocess() {
253 260
   #if HAS_MOTOR_CURRENT_PWM
254 261
     stepper.refresh_motor_power();
255 262
   #endif
263
+
264
+  #if ENABLED(CNC_COORDINATE_SYSTEMS)
265
+    if (position_changed) {
266
+      report_current_position();
267
+      position_changed = false;
268
+    }
269
+  #endif
256 270
 }
257 271
 
258 272
 #if ENABLED(EEPROM_SETTINGS)
@@ -663,6 +677,13 @@ void MarlinSettings::postprocess() {
663 677
       for (uint8_t q = 3; q--;) EEPROM_WRITE(dummyui32);
664 678
     #endif
665 679
 
680
+    #if ENABLED(CNC_COORDINATE_SYSTEMS)
681
+      EEPROM_WRITE(coordinate_system); // 27 floats
682
+    #else
683
+      dummy = 0.0f;
684
+      for (uint8_t q = 27; q--;) EEPROM_WRITE(dummy);
685
+    #endif
686
+
666 687
     if (!eeprom_error) {
667 688
       const int eeprom_size = eeprom_index;
668 689
 
@@ -723,12 +744,16 @@ void MarlinSettings::postprocess() {
723 744
       float dummy = 0;
724 745
       bool dummyb;
725 746
 
726
-      working_crc = 0; //clear before reading first "real data"
747
+      working_crc = 0;  // Init to 0. Accumulated by EEPROM_READ
727 748
 
728 749
       // Number of esteppers may change
729 750
       uint8_t esteppers;
730 751
       EEPROM_READ(esteppers);
731 752
 
753
+      //
754
+      // Planner Motion
755
+      //
756
+
732 757
       // Get only the number of E stepper parameters previously stored
733 758
       // Any steppers added later are set to their defaults
734 759
       const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE;
@@ -752,6 +777,10 @@ void MarlinSettings::postprocess() {
752 777
       EEPROM_READ(planner.min_segment_time_us);
753 778
       EEPROM_READ(planner.max_jerk);
754 779
 
780
+      //
781
+      // Home Offset (M206)
782
+      //
783
+
755 784
       #if !HAS_HOME_OFFSET
756 785
         float home_offset[XYZ];
757 786
       #endif
@@ -763,6 +792,10 @@ void MarlinSettings::postprocess() {
763 792
         home_offset[Z_AXIS] -= DELTA_HEIGHT;
764 793
       #endif
765 794
 
795
+      //
796
+      // Hotend Offsets, if any
797
+      //
798
+
766 799
       #if HOTENDS > 1
767 800
         // Skip hotend 0 which must be 0
768 801
         for (uint8_t e = 1; e < HOTENDS; e++)
@@ -846,6 +879,10 @@ void MarlinSettings::postprocess() {
846 879
           for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummy);
847 880
         }
848 881
 
882
+      //
883
+      // Unified Bed Leveling active state
884
+      //
885
+
849 886
       #if ENABLED(AUTO_BED_LEVELING_UBL)
850 887
         EEPROM_READ(planner.leveling_active);
851 888
         EEPROM_READ(ubl.storage_slot);
@@ -855,6 +892,10 @@ void MarlinSettings::postprocess() {
855 892
         EEPROM_READ(dummyui8);
856 893
       #endif // AUTO_BED_LEVELING_UBL
857 894
 
895
+      //
896
+      // DELTA Geometry or Dual Endstops offsets
897
+      //
898
+
858 899
       #if ENABLED(DELTA)
859 900
         EEPROM_READ(delta_endstop_adj);         // 3 floats
860 901
         EEPROM_READ(delta_radius);              // 1 float
@@ -891,19 +932,26 @@ void MarlinSettings::postprocess() {
891 932
 
892 933
       #endif
893 934
 
935
+      //
936
+      // LCD Preheat settings
937
+      //
938
+
894 939
       #if DISABLED(ULTIPANEL)
895 940
         int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
896 941
       #endif
897
-
898
-      EEPROM_READ(lcd_preheat_hotend_temp);
899
-      EEPROM_READ(lcd_preheat_bed_temp);
900
-      EEPROM_READ(lcd_preheat_fan_speed);
942
+      EEPROM_READ(lcd_preheat_hotend_temp); // 2 floats
943
+      EEPROM_READ(lcd_preheat_bed_temp);    // 2 floats
944
+      EEPROM_READ(lcd_preheat_fan_speed);   // 2 floats
901 945
 
902 946
       //EEPROM_ASSERT(
903 947
       //  WITHIN(lcd_preheat_fan_speed, 0, 255),
904 948
       //  "lcd_preheat_fan_speed out of range"
905 949
       //);
906 950
 
951
+      //
952
+      // Hotend PID
953
+      //
954
+
907 955
       #if ENABLED(PIDTEMP)
908 956
         for (uint8_t e = 0; e < MAX_EXTRUDERS; e++) {
909 957
           EEPROM_READ(dummy); // Kp
@@ -927,11 +975,19 @@ void MarlinSettings::postprocess() {
927 975
         for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy);  // Kp, Ki, Kd, Kc
928 976
       #endif // !PIDTEMP
929 977
 
978
+      //
979
+      // PID Extrusion Scaling
980
+      //
981
+
930 982
       #if DISABLED(PID_EXTRUSION_SCALING)
931 983
         int lpq_len;
932 984
       #endif
933 985
       EEPROM_READ(lpq_len);
934 986
 
987
+      //
988
+      // Heated Bed PID
989
+      //
990
+
935 991
       #if ENABLED(PIDTEMPBED)
936 992
         EEPROM_READ(dummy); // bedKp
937 993
         if (dummy != DUMMY_PID_VALUE) {
@@ -943,11 +999,19 @@ void MarlinSettings::postprocess() {
943 999
         for (uint8_t q=3; q--;) EEPROM_READ(dummy); // bedKp, bedKi, bedKd
944 1000
       #endif
945 1001
 
1002
+      //
1003
+      // LCD Contrast
1004
+      //
1005
+
946 1006
       #if !HAS_LCD_CONTRAST
947 1007
         uint16_t lcd_contrast;
948 1008
       #endif
949 1009
       EEPROM_READ(lcd_contrast);
950 1010
 
1011
+      //
1012
+      // Firmware Retraction
1013
+      //
1014
+
951 1015
       #if ENABLED(FWRETRACT)
952 1016
         EEPROM_READ(autoretract_enabled);
953 1017
         EEPROM_READ(retract_length);
@@ -963,13 +1027,20 @@ void MarlinSettings::postprocess() {
963 1027
         for (uint8_t q=8; q--;) EEPROM_READ(dummy);
964 1028
       #endif
965 1029
 
966
-      EEPROM_READ(volumetric_enabled);
1030
+      //
1031
+      // Volumetric & Filament Size
1032
+      //
967 1033
 
1034
+      EEPROM_READ(volumetric_enabled);
968 1035
       for (uint8_t q = 0; q < MAX_EXTRUDERS; q++) {
969 1036
         EEPROM_READ(dummy);
970 1037
         if (q < COUNT(filament_size)) filament_size[q] = dummy;
971 1038
       }
972 1039
 
1040
+      //
1041
+      // TMC2130 Stepper Current
1042
+      //
1043
+
973 1044
       uint16_t val;
974 1045
       #if ENABLED(HAVE_TMC2130)
975 1046
         EEPROM_READ(val);
@@ -1017,7 +1088,7 @@ void MarlinSettings::postprocess() {
1017 1088
           stepperE4.setCurrent(val, R_SENSE, HOLD_MULTIPLIER);
1018 1089
         #endif
1019 1090
       #else
1020
-        for (uint8_t q = 0; q < 11; q++) EEPROM_READ(val);
1091
+        for (uint8_t q = 11; --q;) EEPROM_READ(val);
1021 1092
       #endif
1022 1093
 
1023 1094
       //
@@ -1032,6 +1103,10 @@ void MarlinSettings::postprocess() {
1032 1103
         EEPROM_READ(dummy);
1033 1104
       #endif
1034 1105
 
1106
+      //
1107
+      // Motor Current PWM
1108
+      //
1109
+
1035 1110
       #if HAS_MOTOR_CURRENT_PWM
1036 1111
         for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
1037 1112
       #else
@@ -1039,6 +1114,17 @@ void MarlinSettings::postprocess() {
1039 1114
         for (uint8_t q = 3; q--;) EEPROM_READ(dummyui32);
1040 1115
       #endif
1041 1116
 
1117
+      //
1118
+      // CNC Coordinate System
1119
+      //
1120
+
1121
+      #if ENABLED(CNC_COORDINATE_SYSTEMS)
1122
+        position_changed = select_coordinate_system(-1); // Go back to machine space
1123
+        EEPROM_READ(coordinate_system);                  // 27 floats
1124
+      #else
1125
+        for (uint8_t q = 27; q--;) EEPROM_READ(dummy);
1126
+      #endif
1127
+
1042 1128
       if (working_crc == stored_crc) {
1043 1129
         postprocess();
1044 1130
         #if ENABLED(EEPROM_CHITCHAT)

+ 8
- 0
Marlin/example_configurations/AlephObjects/TAZ4/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Anet/A6/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Anet/A8/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/BQ/Hephestos/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/BQ/Hephestos_2/Configuration_adv.h View File

@@ -1308,6 +1308,14 @@
1308 1308
 #endif
1309 1309
 
1310 1310
 /**
1311
+ * CNC Coordinate Systems
1312
+ *
1313
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1314
+ * and G92.1 to reset the workspace to native machine space.
1315
+ */
1316
+//#define CNC_COORDINATE_SYSTEMS
1317
+
1318
+/**
1311 1319
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1312 1320
  */
1313 1321
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/BQ/WITBOX/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Creality/CR-10/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/FolgerTech/i3-2020/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 #define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Infitary/i3-M508/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Malyan/M150/Configuration_adv.h View File

@@ -1308,6 +1308,14 @@
1308 1308
 #endif
1309 1309
 
1310 1310
 /**
1311
+ * CNC Coordinate Systems
1312
+ *
1313
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1314
+ * and G92.1 to reset the workspace to native machine space.
1315
+ */
1316
+//#define CNC_COORDINATE_SYSTEMS
1317
+
1318
+/**
1311 1319
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1312 1320
  */
1313 1321
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Micromake/C1/enhanced/Configuration_adv.h View File

@@ -1315,6 +1315,14 @@
1315 1315
 #endif
1316 1316
 
1317 1317
 /**
1318
+ * CNC Coordinate Systems
1319
+ *
1320
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1321
+ * and G92.1 to reset the workspace to native machine space.
1322
+ */
1323
+//#define CNC_COORDINATE_SYSTEMS
1324
+
1325
+/**
1318 1326
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1319 1327
  */
1320 1328
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Sanguinololu/Configuration_adv.h View File

@@ -1278,6 +1278,14 @@
1278 1278
 #endif
1279 1279
 
1280 1280
 /**
1281
+ * CNC Coordinate Systems
1282
+ *
1283
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1284
+ * and G92.1 to reset the workspace to native machine space.
1285
+ */
1286
+//#define CNC_COORDINATE_SYSTEMS
1287
+
1288
+/**
1281 1289
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1282 1290
  */
1283 1291
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/TinyBoy2/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Velleman/K8200/Configuration_adv.h View File

@@ -1319,6 +1319,14 @@
1319 1319
 #endif
1320 1320
 
1321 1321
 /**
1322
+ * CNC Coordinate Systems
1323
+ *
1324
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1325
+ * and G92.1 to reset the workspace to native machine space.
1326
+ */
1327
+//#define CNC_COORDINATE_SYSTEMS
1328
+
1329
+/**
1322 1330
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1323 1331
  */
1324 1332
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/Velleman/K8400/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h View File

@@ -1313,6 +1313,14 @@
1313 1313
 #endif
1314 1314
 
1315 1315
 /**
1316
+ * CNC Coordinate Systems
1317
+ *
1318
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1319
+ * and G92.1 to reset the workspace to native machine space.
1320
+ */
1321
+//#define CNC_COORDINATE_SYSTEMS
1322
+
1323
+/**
1316 1324
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1317 1325
  */
1318 1326
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h View File

@@ -1313,6 +1313,14 @@
1313 1313
 #endif
1314 1314
 
1315 1315
 /**
1316
+ * CNC Coordinate Systems
1317
+ *
1318
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1319
+ * and G92.1 to reset the workspace to native machine space.
1320
+ */
1321
+//#define CNC_COORDINATE_SYSTEMS
1322
+
1323
+/**
1316 1324
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1317 1325
  */
1318 1326
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -1313,6 +1313,14 @@
1313 1313
 #endif
1314 1314
 
1315 1315
 /**
1316
+ * CNC Coordinate Systems
1317
+ *
1318
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1319
+ * and G92.1 to reset the workspace to native machine space.
1320
+ */
1321
+//#define CNC_COORDINATE_SYSTEMS
1322
+
1323
+/**
1316 1324
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1317 1325
  */
1318 1326
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -1313,6 +1313,14 @@
1313 1313
 #endif
1314 1314
 
1315 1315
 /**
1316
+ * CNC Coordinate Systems
1317
+ *
1318
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1319
+ * and G92.1 to reset the workspace to native machine space.
1320
+ */
1321
+//#define CNC_COORDINATE_SYSTEMS
1322
+
1323
+/**
1316 1324
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1317 1325
  */
1318 1326
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -1318,6 +1318,14 @@
1318 1318
 #endif
1319 1319
 
1320 1320
 /**
1321
+ * CNC Coordinate Systems
1322
+ *
1323
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1324
+ * and G92.1 to reset the workspace to native machine space.
1325
+ */
1326
+//#define CNC_COORDINATE_SYSTEMS
1327
+
1328
+/**
1321 1329
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1322 1330
  */
1323 1331
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -1313,6 +1313,14 @@
1313 1313
 #endif
1314 1314
 
1315 1315
 /**
1316
+ * CNC Coordinate Systems
1317
+ *
1318
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1319
+ * and G92.1 to reset the workspace to native machine space.
1320
+ */
1321
+//#define CNC_COORDINATE_SYSTEMS
1322
+
1323
+/**
1316 1324
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1317 1325
  */
1318 1326
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/gCreate/gMax1.5+/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -1311,6 +1311,14 @@
1311 1311
 #endif
1312 1312
 
1313 1313
 /**
1314
+ * CNC Coordinate Systems
1315
+ *
1316
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1317
+ * and G92.1 to reset the workspace to native machine space.
1318
+ */
1319
+//#define CNC_COORDINATE_SYSTEMS
1320
+
1321
+/**
1314 1322
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1315 1323
  */
1316 1324
 //#define PINS_DEBUGGING

+ 8
- 0
Marlin/example_configurations/wt150/Configuration_adv.h View File

@@ -1298,6 +1298,14 @@
1298 1298
 #endif
1299 1299
 
1300 1300
 /**
1301
+ * CNC Coordinate Systems
1302
+ *
1303
+ * Enables G53 and G54-G59.3 commands to select coordinate systems
1304
+ * and G92.1 to reset the workspace to native machine space.
1305
+ */
1306
+//#define CNC_COORDINATE_SYSTEMS
1307
+
1308
+/**
1301 1309
  * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
1302 1310
  */
1303 1311
 //#define PINS_DEBUGGING

+ 20
- 0
Marlin/gcode.cpp View File

@@ -228,6 +228,26 @@ void GCodeParser::parse(char *p) {
228 228
   }
229 229
 }
230 230
 
231
+#if ENABLED(CNC_COORDINATE_SYSTEMS)
232
+
233
+  // Parse the next parameter as a new command
234
+  bool GCodeParser::chain() {
235
+    #if ENABLED(FASTER_GCODE_PARSER)
236
+      char *next_command = command_ptr;
237
+      if (next_command) {
238
+        while (*next_command && *next_command != ' ') ++next_command;
239
+        while (*next_command == ' ') ++next_command;
240
+        if (!*next_command) next_command = NULL;
241
+      }
242
+    #else
243
+      const char *next_command = command_args;
244
+    #endif
245
+    if (next_command) parse(next_command);
246
+    return !!next_command;
247
+  }
248
+
249
+#endif // CNC_COORDINATE_SYSTEMS
250
+
231 251
 void GCodeParser::unknown_command_error() {
232 252
   SERIAL_ECHO_START();
233 253
   SERIAL_ECHOPAIR(MSG_UNKNOWN_COMMAND, command_ptr);

+ 5
- 0
Marlin/gcode.h View File

@@ -169,6 +169,11 @@ public:
169 169
   // This uses 54 bytes of SRAM to speed up seen/value
170 170
   static void parse(char * p);
171 171
 
172
+  #if ENABLED(CNC_COORDINATE_SYSTEMS)
173
+    // Parse the next parameter as a new command
174
+    static bool chain();
175
+  #endif
176
+
172 177
   // The code value pointer was set
173 178
   FORCE_INLINE static bool has_value() { return value_ptr != NULL; }
174 179
 

+ 16
- 16
Marlin/planner_bezier.cpp View File

@@ -107,10 +107,10 @@ inline static float dist1(float x1, float y1, float x2, float y2) { return FABS(
107 107
  */
108 108
 void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS], const float offset[4], float fr_mm_s, uint8_t extruder) {
109 109
   // Absolute first and second control points are recovered.
110
-  float first0 = position[X_AXIS] + offset[0];
111
-  float first1 = position[Y_AXIS] + offset[1];
112
-  float second0 = target[X_AXIS] + offset[2];
113
-  float second1 = target[Y_AXIS] + offset[3];
110
+  const float first0 = position[X_AXIS] + offset[0],
111
+              first1 = position[Y_AXIS] + offset[1],
112
+              second0 = target[X_AXIS] + offset[2],
113
+              second1 = target[Y_AXIS] + offset[3];
114 114
   float t = 0.0;
115 115
 
116 116
   float bez_target[4];
@@ -134,15 +134,15 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
134 134
     bool did_reduce = false;
135 135
     float new_t = t + step;
136 136
     NOMORE(new_t, 1.0);
137
-    float new_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], new_t);
138
-    float new_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], new_t);
137
+    float new_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], new_t),
138
+          new_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], new_t);
139 139
     for (;;) {
140 140
       if (new_t - t < (MIN_STEP)) break;
141
-      float candidate_t = 0.5 * (t + new_t);
142
-      float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t);
143
-      float candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t);
144
-      float interp_pos0 = 0.5 * (bez_target[X_AXIS] + new_pos0);
145
-      float interp_pos1 = 0.5 * (bez_target[Y_AXIS] + new_pos1);
141
+      const float candidate_t = 0.5 * (t + new_t),
142
+                  candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t),
143
+                  candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t),
144
+                  interp_pos0 = 0.5 * (bez_target[X_AXIS] + new_pos0),
145
+                  interp_pos1 = 0.5 * (bez_target[Y_AXIS] + new_pos1);
146 146
       if (dist1(candidate_pos0, candidate_pos1, interp_pos0, interp_pos1) <= (SIGMA)) break;
147 147
       new_t = candidate_t;
148 148
       new_pos0 = candidate_pos0;
@@ -153,12 +153,12 @@ void cubic_b_spline(const float position[NUM_AXIS], const float target[NUM_AXIS]
153 153
     // If we did not reduce the step, maybe we should enlarge it.
154 154
     if (!did_reduce) for (;;) {
155 155
       if (new_t - t > MAX_STEP) break;
156
-      float candidate_t = t + 2.0 * (new_t - t);
156
+      const float candidate_t = t + 2.0 * (new_t - t);
157 157
       if (candidate_t >= 1.0) break;
158
-      float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t);
159
-      float candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t);
160
-      float interp_pos0 = 0.5 * (bez_target[X_AXIS] + candidate_pos0);
161
-      float interp_pos1 = 0.5 * (bez_target[Y_AXIS] + candidate_pos1);
158
+      const float candidate_pos0 = eval_bezier(position[X_AXIS], first0, second0, target[X_AXIS], candidate_t),
159
+                  candidate_pos1 = eval_bezier(position[Y_AXIS], first1, second1, target[Y_AXIS], candidate_t),
160
+                  interp_pos0 = 0.5 * (bez_target[X_AXIS] + candidate_pos0),
161
+                  interp_pos1 = 0.5 * (bez_target[Y_AXIS] + candidate_pos1);
162 162
       if (dist1(new_pos0, new_pos1, interp_pos0, interp_pos1) > (SIGMA)) break;
163 163
       new_t = candidate_t;
164 164
       new_pos0 = candidate_pos0;

Loading…
Cancel
Save