Browse Source

Move M900 to cpp

Scott Lahteine 7 years ago
parent
commit
19dde5be03
3 changed files with 13 additions and 10 deletions
  1. 0
    4
      Marlin/src/Marlin.cpp
  2. 12
    2
      Marlin/src/gcode/feature/advance/M900.cpp
  3. 1
    4
      Marlin/src/gcode/gcode.cpp

+ 0
- 4
Marlin/src/Marlin.cpp View File

@@ -359,10 +359,6 @@ void quickstop_stepper() {
359 359
   SYNC_PLAN_POSITION_KINEMATIC();
360 360
 }
361 361
 
362
-#if ENABLED(LIN_ADVANCE)
363
-  #include "gcode/feature/advance/M900.h"
364
-#endif
365
-
366 362
 #if ENABLED(HAVE_TMC2130)
367 363
   #include "feature/tmc2130.h"
368 364
   #include "gcode/feature/trinamic/M906.h"

Marlin/src/gcode/feature/advance/M900.h → Marlin/src/gcode/feature/advance/M900.cpp View File

@@ -20,6 +20,14 @@
20 20
  *
21 21
  */
22 22
 
23
+#include "../../../inc/MarlinConfig.h"
24
+
25
+#if ENABLED(LIN_ADVANCE)
26
+
27
+#include "../../gcode.h"
28
+#include "../../../module/planner.h"
29
+#include "../../../module/stepper.h"
30
+
23 31
 /**
24 32
  * M900: Set and/or Get advance K factor and WH/D ratio
25 33
  *
@@ -27,7 +35,7 @@
27 35
  *  R<ratio>                   Set ratio directly (overrides WH/D)
28 36
  *  W<width> H<height> D<diam> Set ratio from WH/D
29 37
  */
30
-void gcode_M900() {
38
+void GcodeSuite::M900() {
31 39
   stepper.synchronize();
32 40
 
33 41
   const float newK = parser.floatval('K', -1);
@@ -39,7 +47,7 @@ void gcode_M900() {
39 47
                 newW = parser.floatval('W', -1),
40 48
                 newH = parser.floatval('H', -1);
41 49
     if (newD >= 0 && newW >= 0 && newH >= 0)
42
-      newR = newD ? (newW * newH) / (sq(newD * 0.5) * M_PI) : 0;
50
+      newR = newD ? (newW * newH) / CIRCLE_AREA(newD * 0.5) : 0;
43 51
   }
44 52
   if (newR >= 0) planner.advance_ed_ratio = newR;
45 53
 
@@ -50,3 +58,5 @@ void gcode_M900() {
50 58
   if (ratio) SERIAL_ECHO(ratio); else SERIAL_ECHOPGM("Auto");
51 59
   SERIAL_EOL();
52 60
 }
61
+
62
+#endif // LIN_ADVANCE

+ 1
- 4
Marlin/src/gcode/gcode.cpp View File

@@ -122,7 +122,6 @@ extern void gcode_M165();
122 122
 extern void gcode_M350();
123 123
 extern void gcode_M351();
124 124
 extern void gcode_M355();
125
-extern void gcode_M900();
126 125
 extern void gcode_M906();
127 126
 extern void gcode_M911();
128 127
 extern void gcode_M912();
@@ -658,9 +657,7 @@ void GcodeSuite::process_next_command() {
658 657
       #endif
659 658
 
660 659
       #if ENABLED(LIN_ADVANCE)
661
-        case 900: // M900: Set advance K factor.
662
-          gcode_M900();
663
-          break;
660
+        case 900: M900(); break;  // M900: Set advance K factor.
664 661
       #endif
665 662
 
666 663
       #if ENABLED(HAVE_TMC2130)

Loading…
Cancel
Save