Przeglądaj źródła

Add M905 R for setting the E/D ratio directly

Scott Lahteine 7 lat temu
rodzic
commit
eb2d073dae
1 zmienionych plików z 21 dodań i 15 usunięć
  1. 21
    15
      Marlin/Marlin_main.cpp

+ 21
- 15
Marlin/Marlin_main.cpp Wyświetl plik

@@ -8797,28 +8797,34 @@ inline void gcode_M503() {
8797 8797
 
8798 8798
 #if ENABLED(LIN_ADVANCE)
8799 8799
   /**
8800
-   * M905: Set advance factor
8800
+   * M905: Set and/or Get advance K factor and WH/D ratio
8801
+   *
8802
+   *  K<factor>                  Set advance K factor
8803
+   *  R<ratio>                   Set ratio directly (overrides WH/D)
8804
+   *  W<width> H<height> D<diam> Set ratio from WH/D
8801 8805
    */
8802 8806
   inline void gcode_M905() {
8803 8807
     stepper.synchronize();
8804 8808
 
8805
-    const float newK = code_seen('K') ? code_value_float() : -1,
8806
-                newD = code_seen('D') ? code_value_float() : -1,
8807
-                newW = code_seen('W') ? code_value_float() : -1,
8808
-                newH = code_seen('H') ? code_value_float() : -1;
8809
+    const float newK = code_seen('K') ? code_value_float() : -1;
8810
+    if (newK >= 0) planner.set_extruder_advance_k(newK);
8809 8811
 
8810
-    if (newK >= 0.0) planner.set_extruder_advance_k(newK);
8812
+    float newR = code_seen('R') ? code_value_float() : -1;
8813
+    if (newR < 0) {
8814
+      const float newD = code_seen('D') ? code_value_float() : -1,
8815
+                  newW = code_seen('W') ? code_value_float() : -1,
8816
+                  newH = code_seen('H') ? code_value_float() : -1;
8817
+      if (newD >= 0 && newW >= 0 && newH >= 0)
8818
+        newR = newD ? (newW * newH) / (sq(newD * 0.5) * M_PI) : 0;
8819
+    }
8820
+    if (newR >= 0) planner.set_advance_ed_ratio(newR);
8811 8821
 
8812 8822
     SERIAL_ECHO_START;
8813
-    SERIAL_ECHOLNPAIR("Advance factor: ", planner.get_extruder_advance_k());
8814
-
8815
-    if (newD >= 0 || newW >= 0 || newH >= 0) {
8816
-      const float ratio = (!newD || !newW || !newH) ? 0 : (newW * newH) / (sq(newD * 0.5) * M_PI);
8817
-      planner.set_advance_ed_ratio(ratio);
8818
-      SERIAL_ECHO_START;
8819
-      SERIAL_ECHOPGM("E/D ratio: ");
8820
-      if (ratio) SERIAL_ECHOLN(ratio); else SERIAL_ECHOLNPGM("Automatic");
8821
-    }
8823
+    SERIAL_ECHOPAIR("Advance K=", planner.get_extruder_advance_k());
8824
+    SERIAL_ECHOPGM(" E/D=");
8825
+    const float ratio = planner.get_advance_ed_ratio();
8826
+    ratio ? SERIAL_ECHO(ratio) : SERIAL_ECHOPGM("Auto");
8827
+    SERIAL_EOL;
8822 8828
   }
8823 8829
 #endif // LIN_ADVANCE
8824 8830
 

Ładowanie…
Anuluj
Zapisz