Move M907-M910 to cpp

This commit is contained in:
Scott Lahteine
2017-09-17 18:45:21 -05:00
parent 2e89685154
commit 6e0503eab2
9 changed files with 101 additions and 58 deletions

View File

@ -20,10 +20,24 @@
*
*/
#include "../../gcode.h"
#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
#include "../../../module/stepper.h"
#endif
#if ENABLED(DIGIPOT_I2C)
#include "../../../feature/digipot/digipot.h"
#endif
#if ENABLED(DAC_STEPPER_CURRENT)
#include "../../../feature/dac/stepper_dac.h"
#endif
/**
* M907: Set digital trimpot motor current using axis codes X, Y, Z, E, B, S
*/
void gcode_M907() {
void GcodeSuite::M907() {
#if HAS_DIGIPOTSS
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.digipot_current(i, parser.value_int());

View File

@ -20,20 +20,36 @@
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
#include "../../gcode.h"
#if HAS_DIGIPOTSS
#include "../../../module/stepper.h"
#endif
#if ENABLED(DAC_STEPPER_CURRENT)
#include "../../../feature/dac/stepper_dac.h"
#endif
/**
* M908: Control digital trimpot directly (M908 P<pin> S<current>)
*/
void gcode_M908() {
void GcodeSuite::M908() {
#if HAS_DIGIPOTSS
stepper.digitalPotWrite(
parser.intval('P'),
parser.intval('S')
);
#endif
#ifdef DAC_STEPPER_CURRENT
#if ENABLED(DAC_STEPPER_CURRENT)
dac_current_raw(
parser.byteval('P', -1),
parser.ushortval('S', 0)
);
#endif
}
#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT

View File

@ -20,8 +20,17 @@
*
*/
void gcode_M909() {
#include "../../../inc/MarlinConfig.h"
#if ENABLED(DAC_STEPPER_CURRENT)
#include "../../gcode.h"
#include "../../../feature/dac/stepper_dac.h"
void GcodeSuite::M909() {
dac_print_values();
}
#endif // DAC_STEPPER_CURRENT

View File

@ -20,8 +20,17 @@
*
*/
void gcode_M910() {
#include "../../../inc/MarlinConfig.h"
#if ENABLED(DAC_STEPPER_CURRENT)
#include "../../gcode.h"
#include "../../../feature/dac/stepper_dac.h"
void GcodeSuite::M910() {
dac_commit_eeprom();
}
#endif // DAC_STEPPER_CURRENT

View File

@ -122,10 +122,6 @@ extern void gcode_M165();
extern void gcode_M350();
extern void gcode_M351();
extern void gcode_M355();
extern void gcode_M907();
extern void gcode_M908();
extern void gcode_M909();
extern void gcode_M910();
extern void gcode_M999();
extern void gcode_T(uint8_t tmp_extruder);
@ -655,29 +651,15 @@ void GcodeSuite::process_next_command() {
case 900: M900(); break; // M900: Set advance K factor.
#endif
case 907: // M907: Set digital trimpot motor current using axis codes.
gcode_M907();
break;
case 907: M907(); break; // M907: Set digital trimpot motor current using axis codes.
#if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
case 908: // M908: Control digital trimpot directly.
gcode_M908();
break;
case 908: M908(); break; // M908: Control digital trimpot directly.
#if ENABLED(DAC_STEPPER_CURRENT) // As with Printrbot RevF
case 909: // M909: Print digipot/DAC current value
gcode_M909();
break;
case 910: // M910: Commit digipot/DAC value to external EEPROM
gcode_M910();
break;
case 909: M909(); break; // M909: Print digipot/DAC current value
case 910: M910(); break; // M910: Commit digipot/DAC value to external EEPROM
#endif
#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT
#endif
#if ENABLED(HAVE_TMC2130)
case 906: M906(); break; // M906: Set motor current in milliamps using axis codes X, Y, Z, E