Move TMC2130 g-codes to cpp
This commit is contained in:
parent
19dde5be03
commit
2e89685154
@ -95,6 +95,10 @@
|
||||
#include "HAL/HAL_endstop_interrupts.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(HAVE_TMC2130)
|
||||
#include "feature/tmc2130.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
CardReader card;
|
||||
#endif
|
||||
@ -114,10 +118,6 @@
|
||||
#include "feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
#include "feature/tmc2130.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE) && ENABLED(PAUSE_PARK_NO_STEPPER_TIMEOUT)
|
||||
#include "feature/pause.h"
|
||||
#endif
|
||||
@ -359,19 +359,6 @@ void quickstop_stepper() {
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
}
|
||||
|
||||
#if ENABLED(HAVE_TMC2130)
|
||||
#include "feature/tmc2130.h"
|
||||
#include "gcode/feature/trinamic/M906.h"
|
||||
#include "gcode/feature/trinamic/M911.h"
|
||||
#include "gcode/feature/trinamic/M912.h"
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
#include "gcode/feature/trinamic/M913.h"
|
||||
#endif
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
#include "gcode/feature/trinamic/M914.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "gcode/feature/digipot/M907.h"
|
||||
|
||||
#if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
|
||||
|
@ -20,12 +20,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_get_current(TMC2130Stepper &st, const char name) {
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(HAVE_TMC2130)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/tmc2130.h"
|
||||
#include "../../../module/stepper_indirection.h"
|
||||
|
||||
inline void tmc2130_get_current(TMC2130Stepper &st, const char name) {
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOPGM(" axis driver current: ");
|
||||
SERIAL_ECHOLN(st.getCurrent());
|
||||
}
|
||||
static void tmc2130_set_current(TMC2130Stepper &st, const char name, const int mA) {
|
||||
inline void tmc2130_set_current(TMC2130Stepper &st, const char name, const int mA) {
|
||||
st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
|
||||
tmc2130_get_current(st, name);
|
||||
}
|
||||
@ -37,7 +45,7 @@ static void tmc2130_set_current(TMC2130Stepper &st, const char name, const int m
|
||||
* S1: Enable automatic current control
|
||||
* S0: Disable
|
||||
*/
|
||||
void gcode_M906() {
|
||||
void GcodeSuite::M906() {
|
||||
uint16_t values[XYZE];
|
||||
LOOP_XYZE(i)
|
||||
values[i] = parser.intval(axis_codes[i]);
|
||||
@ -63,3 +71,5 @@ void gcode_M906() {
|
||||
if (parser.seen('S')) auto_current_control = parser.value_bool();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAVE_TMC2130
|
@ -20,7 +20,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(HAVE_TMC2130)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/tmc2130.h"
|
||||
#include "../../../module/stepper_indirection.h"
|
||||
|
||||
inline void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
|
||||
serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false"));
|
||||
@ -31,7 +39,7 @@ static void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
|
||||
* M911: Report TMC2130 stepper driver overtemperature pre-warn flag
|
||||
* The flag is held by the library and persist until manually cleared by M912
|
||||
*/
|
||||
void gcode_M911() {
|
||||
void GcodeSuite::M911() {
|
||||
const bool reportX = parser.seen('X'), reportY = parser.seen('Y'), reportZ = parser.seen('Z'), reportE = parser.seen('E'),
|
||||
reportAll = (!reportX && !reportY && !reportZ && !reportE) || (reportX && reportY && reportZ && reportE);
|
||||
#if ENABLED(X_IS_TMC2130)
|
||||
@ -47,3 +55,5 @@ void gcode_M911() {
|
||||
if (reportE || reportAll) tmc2130_report_otpw(stepperE0, 'E');
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAVE_TMC2130
|
@ -20,7 +20,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(HAVE_TMC2130)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/tmc2130.h"
|
||||
#include "../../../module/stepper_indirection.h"
|
||||
|
||||
inline void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
|
||||
st.clear_otpw();
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOLNPGM(" prewarn flag cleared");
|
||||
@ -29,7 +37,7 @@ static void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
|
||||
/**
|
||||
* M912: Clear TMC2130 stepper driver overtemperature pre-warn flag held by the library
|
||||
*/
|
||||
void gcode_M912() {
|
||||
void GcodeSuite::M912() {
|
||||
const bool clearX = parser.seen('X'), clearY = parser.seen('Y'), clearZ = parser.seen('Z'), clearE = parser.seen('E'),
|
||||
clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
|
||||
#if ENABLED(X_IS_TMC2130)
|
||||
@ -45,3 +53,5 @@ void gcode_M912() {
|
||||
if (clearE || clearAll) tmc2130_clear_otpw(stepperE0, 'E');
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAVE_TMC2130
|
@ -20,12 +20,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_get_pwmthrs(TMC2130Stepper &st, const char name, const uint16_t spmm) {
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(HAVE_TMC2130) && ENABLED(HYBRID_THRESHOLD)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/tmc2130.h"
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../module/stepper_indirection.h"
|
||||
|
||||
inline void tmc2130_get_pwmthrs(TMC2130Stepper &st, const char name, const uint16_t spmm) {
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOPGM(" stealthChop max speed set to ");
|
||||
SERIAL_ECHOLN(12650000UL * st.microsteps() / (256 * st.stealth_max_speed() * spmm));
|
||||
}
|
||||
static void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32_t thrs, const uint32_t spmm) {
|
||||
inline void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32_t thrs, const uint32_t spmm) {
|
||||
st.stealth_max_speed(12650000UL * st.microsteps() / (256 * thrs * spmm));
|
||||
tmc2130_get_pwmthrs(st, name, spmm);
|
||||
}
|
||||
@ -33,7 +42,7 @@ static void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32
|
||||
/**
|
||||
* M913: Set HYBRID_THRESHOLD speed.
|
||||
*/
|
||||
void gcode_M913() {
|
||||
void GcodeSuite::M913() {
|
||||
uint16_t values[XYZE];
|
||||
LOOP_XYZE(i)
|
||||
values[i] = parser.intval(axis_codes[i]);
|
||||
@ -55,3 +64,5 @@ void gcode_M913() {
|
||||
else tmc2130_get_pwmthrs(stepperE0, 'E', planner.axis_steps_per_mm[E_AXIS]);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAVE_TMC2130 && HYBRID_THRESHOLD
|
@ -20,12 +20,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
static void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(HAVE_TMC2130) && ENABLED(SENSORLESS_HOMING)
|
||||
|
||||
#include "../../gcode.h"
|
||||
#include "../../../feature/tmc2130.h"
|
||||
#include "../../../module/stepper_indirection.h"
|
||||
|
||||
inline void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
|
||||
SERIAL_CHAR(name);
|
||||
SERIAL_ECHOPGM(" driver homing sensitivity set to ");
|
||||
SERIAL_ECHOLN(st.sgt());
|
||||
}
|
||||
static void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
|
||||
inline void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
|
||||
st.sgt(sgt_val);
|
||||
tmc2130_get_sgt(st, name);
|
||||
}
|
||||
@ -33,7 +41,7 @@ static void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sg
|
||||
/**
|
||||
* M914: Set SENSORLESS_HOMING sensitivity.
|
||||
*/
|
||||
void gcode_M914() {
|
||||
void GcodeSuite::M914() {
|
||||
#if ENABLED(X_IS_TMC2130)
|
||||
if (parser.seen(axis_codes[X_AXIS])) tmc2130_set_sgt(stepperX, 'X', parser.value_int());
|
||||
else tmc2130_get_sgt(stepperX, 'X');
|
||||
@ -43,3 +51,5 @@ void gcode_M914() {
|
||||
else tmc2130_get_sgt(stepperY, 'Y');
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAVE_TMC2130 && SENSORLESS_HOMING
|
@ -122,11 +122,6 @@ extern void gcode_M165();
|
||||
extern void gcode_M350();
|
||||
extern void gcode_M351();
|
||||
extern void gcode_M355();
|
||||
extern void gcode_M906();
|
||||
extern void gcode_M911();
|
||||
extern void gcode_M912();
|
||||
extern void gcode_M913();
|
||||
extern void gcode_M914();
|
||||
extern void gcode_M907();
|
||||
extern void gcode_M908();
|
||||
extern void gcode_M909();
|
||||
@ -660,12 +655,6 @@ void GcodeSuite::process_next_command() {
|
||||
case 900: M900(); break; // M900: Set advance K factor.
|
||||
#endif
|
||||
|
||||
#if ENABLED(HAVE_TMC2130)
|
||||
case 906: // M906: Set motor current in milliamps using axis codes X, Y, Z, E
|
||||
gcode_M906();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 907: // M907: Set digital trimpot motor current using axis codes.
|
||||
gcode_M907();
|
||||
break;
|
||||
@ -691,24 +680,14 @@ void GcodeSuite::process_next_command() {
|
||||
#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT
|
||||
|
||||
#if ENABLED(HAVE_TMC2130)
|
||||
case 911: // M911: Report TMC2130 prewarn triggered flags
|
||||
gcode_M911();
|
||||
break;
|
||||
|
||||
case 912: // M911: Clear TMC2130 prewarn triggered flags
|
||||
gcode_M912();
|
||||
break;
|
||||
|
||||
case 906: M906(); break; // M906: Set motor current in milliamps using axis codes X, Y, Z, E
|
||||
case 911: M911(); break; // M911: Report TMC2130 prewarn triggered flags
|
||||
case 912: M912(); break; // M912: Clear TMC2130 prewarn triggered flags
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
case 913: // M913: Set HYBRID_THRESHOLD speed.
|
||||
gcode_M913();
|
||||
break;
|
||||
case 913: M913(); break; // M913: Set HYBRID_THRESHOLD speed.
|
||||
#endif
|
||||
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
case 914: // M914: Set SENSORLESS_HOMING sensitivity.
|
||||
gcode_M914();
|
||||
break;
|
||||
case 914: M914(); break; // M914: Set SENSORLESS_HOMING sensitivity.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user