Browse Source

Move M900 to cpp

pull/1/head
Scott Lahteine 7 years ago
parent
commit
19dde5be03
  1. 4
      Marlin/src/Marlin.cpp
  2. 14
      Marlin/src/gcode/feature/advance/M900.cpp
  3. 5
      Marlin/src/gcode/gcode.cpp

4
Marlin/src/Marlin.cpp

@ -359,10 +359,6 @@ void quickstop_stepper() {
SYNC_PLAN_POSITION_KINEMATIC(); SYNC_PLAN_POSITION_KINEMATIC();
} }
#if ENABLED(LIN_ADVANCE)
#include "gcode/feature/advance/M900.h"
#endif
#if ENABLED(HAVE_TMC2130) #if ENABLED(HAVE_TMC2130)
#include "feature/tmc2130.h" #include "feature/tmc2130.h"
#include "gcode/feature/trinamic/M906.h" #include "gcode/feature/trinamic/M906.h"

14
Marlin/src/gcode/feature/advance/M900.h → Marlin/src/gcode/feature/advance/M900.cpp

@ -20,6 +20,14 @@
* *
*/ */
#include "../../../inc/MarlinConfig.h"
#if ENABLED(LIN_ADVANCE)
#include "../../gcode.h"
#include "../../../module/planner.h"
#include "../../../module/stepper.h"
/** /**
* M900: Set and/or Get advance K factor and WH/D ratio * M900: Set and/or Get advance K factor and WH/D ratio
* *
@ -27,7 +35,7 @@
* R<ratio> Set ratio directly (overrides WH/D) * R<ratio> Set ratio directly (overrides WH/D)
* W<width> H<height> D<diam> Set ratio from WH/D * W<width> H<height> D<diam> Set ratio from WH/D
*/ */
void gcode_M900() { void GcodeSuite::M900() {
stepper.synchronize(); stepper.synchronize();
const float newK = parser.floatval('K', -1); const float newK = parser.floatval('K', -1);
@ -39,7 +47,7 @@ void gcode_M900() {
newW = parser.floatval('W', -1), newW = parser.floatval('W', -1),
newH = parser.floatval('H', -1); newH = parser.floatval('H', -1);
if (newD >= 0 && newW >= 0 && newH >= 0) if (newD >= 0 && newW >= 0 && newH >= 0)
newR = newD ? (newW * newH) / (sq(newD * 0.5) * M_PI) : 0; newR = newD ? (newW * newH) / CIRCLE_AREA(newD * 0.5) : 0;
} }
if (newR >= 0) planner.advance_ed_ratio = newR; if (newR >= 0) planner.advance_ed_ratio = newR;
@ -50,3 +58,5 @@ void gcode_M900() {
if (ratio) SERIAL_ECHO(ratio); else SERIAL_ECHOPGM("Auto"); if (ratio) SERIAL_ECHO(ratio); else SERIAL_ECHOPGM("Auto");
SERIAL_EOL(); SERIAL_EOL();
} }
#endif // LIN_ADVANCE

5
Marlin/src/gcode/gcode.cpp

@ -122,7 +122,6 @@ extern void gcode_M165();
extern void gcode_M350(); extern void gcode_M350();
extern void gcode_M351(); extern void gcode_M351();
extern void gcode_M355(); extern void gcode_M355();
extern void gcode_M900();
extern void gcode_M906(); extern void gcode_M906();
extern void gcode_M911(); extern void gcode_M911();
extern void gcode_M912(); extern void gcode_M912();
@ -658,9 +657,7 @@ void GcodeSuite::process_next_command() {
#endif #endif
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
case 900: // M900: Set advance K factor. case 900: M900(); break; // M900: Set advance K factor.
gcode_M900();
break;
#endif #endif
#if ENABLED(HAVE_TMC2130) #if ENABLED(HAVE_TMC2130)

Loading…
Cancel
Save