Bläddra i källkod

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 år sedan
förälder
incheckning
fa44130734
1 ändrade filer med 43 tillägg och 1 borttagningar
  1. 43
    1
      Marlin/Marlin_main.cpp

+ 43
- 1
Marlin/Marlin_main.cpp Visa fil

@@ -173,6 +173,7 @@
173 173
  * M260 - i2c Send Data (Requires EXPERIMENTAL_I2CBUS)
174 174
  * M261 - i2c Request Data (Requires EXPERIMENTAL_I2CBUS)
175 175
  * M280 - Set servo position absolute: "M280 P<index> S<angle|µs>". (Requires servos)
176
+ * M290 - Babystepping (Requires BABYSTEPPING)
176 177
  * M300 - Play beep sound S<frequency Hz> P<duration ms>
177 178
  * M301 - Set PID parameters P I and D. (Requires PIDTEMP)
178 179
  * M302 - Allow cold extrudes, or set the minimum extrude S<temperature>. (Requires PREVENT_COLD_EXTRUSION)
@@ -8958,6 +8959,41 @@ inline void gcode_M226() {
8958 8959
 
8959 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 8997
 #if HAS_BUZZER
8962 8998
 
8963 8999
   /**
@@ -11411,7 +11447,7 @@ void process_next_command() {
11411 11447
         case 218: // M218: Set a tool offset
11412 11448
           gcode_M218();
11413 11449
           break;
11414
-      #endif
11450
+      #endif // HOTENDS > 1
11415 11451
 
11416 11452
       case 220: // M220: Set Feedrate Percentage: S<percent> ("FR" on your LCD)
11417 11453
         gcode_M220();
@@ -11431,6 +11467,12 @@ void process_next_command() {
11431 11467
           break;
11432 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 11476
       #if HAS_BUZZER
11435 11477
         case 300: // M300: Play beep tone
11436 11478
           gcode_M300();

Laddar…
Avbryt
Spara