Browse Source

Add M290 babystepping (#8014)

* Add M290 babystepping

* Allow `Z` for `M290`

* fix spacing

* Support BABYSTEP_XY in M290

* Not just Z

* Extend M290 for BABYSTEP_ZPROBE_OFFSET

* tweak
tweichselbaumer 7 years ago
parent
commit
fa44130734
1 changed files with 43 additions and 1 deletions
  1. 43
    1
      Marlin/Marlin_main.cpp

+ 43
- 1
Marlin/Marlin_main.cpp View File

173
  * M260 - i2c Send Data (Requires EXPERIMENTAL_I2CBUS)
173
  * M260 - i2c Send Data (Requires EXPERIMENTAL_I2CBUS)
174
  * M261 - i2c Request Data (Requires EXPERIMENTAL_I2CBUS)
174
  * M261 - i2c Request Data (Requires EXPERIMENTAL_I2CBUS)
175
  * M280 - Set servo position absolute: "M280 P<index> S<angle|µs>". (Requires servos)
175
  * M280 - Set servo position absolute: "M280 P<index> S<angle|µs>". (Requires servos)
176
+ * M290 - Babystepping (Requires BABYSTEPPING)
176
  * M300 - Play beep sound S<frequency Hz> P<duration ms>
177
  * M300 - Play beep sound S<frequency Hz> P<duration ms>
177
  * M301 - Set PID parameters P I and D. (Requires PIDTEMP)
178
  * M301 - Set PID parameters P I and D. (Requires PIDTEMP)
178
  * M302 - Allow cold extrudes, or set the minimum extrude S<temperature>. (Requires PREVENT_COLD_EXTRUSION)
179
  * M302 - Allow cold extrudes, or set the minimum extrude S<temperature>. (Requires PREVENT_COLD_EXTRUSION)
8958
 
8959
 
8959
 #endif // HAS_SERVOS
8960
 #endif // HAS_SERVOS
8960
 
8961
 
8962
+#if ENABLED(BABYSTEPPING)
8963
+
8964
+  /**
8965
+   * M290: Babystepping
8966
+   */
8967
+  inline void gcode_M290() {
8968
+    #if ENABLED(BABYSTEP_XY)
8969
+      for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
8970
+        if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
8971
+          float offs = parser.value_axis_units(a);
8972
+          constrain(offs, -2, 2);
8973
+          #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
8974
+            if (a == Z_AXIS) {
8975
+              zprobe_zoffset += offs;
8976
+              refresh_zprobe_zoffset(true); // 'true' to not babystep
8977
+            }
8978
+          #endif
8979
+          thermalManager.babystep_axis(a, offs * planner.axis_steps_per_mm[a]);
8980
+        }
8981
+    #else
8982
+      if (parser.seenval('Z') || parser.seenval('S')) {
8983
+        float offs = parser.value_axis_units(Z_AXIS);
8984
+        constrain(offs, -2, 2);
8985
+        #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
8986
+          zprobe_zoffset += offs;
8987
+          refresh_zprobe_zoffset(); // This will babystep the axis
8988
+        #else
8989
+          thermalManager.babystep_axis(Z_AXIS, parser.value_axis_units(Z_AXIS) * planner.axis_steps_per_mm[Z_AXIS]);
8990
+        #endif
8991
+      }
8992
+    #endif
8993
+  }
8994
+
8995
+#endif // BABYSTEPPING
8996
+
8961
 #if HAS_BUZZER
8997
 #if HAS_BUZZER
8962
 
8998
 
8963
   /**
8999
   /**
11411
         case 218: // M218: Set a tool offset
11447
         case 218: // M218: Set a tool offset
11412
           gcode_M218();
11448
           gcode_M218();
11413
           break;
11449
           break;
11414
-      #endif
11450
+      #endif // HOTENDS > 1
11415
 
11451
 
11416
       case 220: // M220: Set Feedrate Percentage: S<percent> ("FR" on your LCD)
11452
       case 220: // M220: Set Feedrate Percentage: S<percent> ("FR" on your LCD)
11417
         gcode_M220();
11453
         gcode_M220();
11431
           break;
11467
           break;
11432
       #endif // HAS_SERVOS
11468
       #endif // HAS_SERVOS
11433
 
11469
 
11470
+      #if ENABLED(BABYSTEPPING)
11471
+        case 290: // M290: Babystepping
11472
+          gcode_M290();
11473
+          break;
11474
+      #endif // BABYSTEPPING
11475
+
11434
       #if HAS_BUZZER
11476
       #if HAS_BUZZER
11435
         case 300: // M300: Play beep tone
11477
         case 300: // M300: Play beep tone
11436
           gcode_M300();
11478
           gcode_M300();

Loading…
Cancel
Save