TMC updates, capture LCD changes (#14074)
This commit is contained in:
committed by
Scott Lahteine
parent
74f44783ac
commit
1c86fbc60b
@ -313,8 +313,6 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
#define HAS_HW_COMMS(ST) AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2160) || AXIS_DRIVER_TYPE(ST, TMC2660) || AXIS_DRIVER_TYPE(ST, TMC5130) || AXIS_DRIVER_TYPE(ST, TMC5160) || (AXIS_DRIVER_TYPE(ST, TMC2208) && defined(ST##_HARDWARE_SERIAL))
|
||||
|
||||
void monitor_tmc_driver() {
|
||||
static millis_t next_poll = 0;
|
||||
const millis_t ms = millis();
|
||||
@ -330,43 +328,43 @@
|
||||
}
|
||||
#endif
|
||||
if (need_update_error_counters || need_debug_reporting) {
|
||||
#if HAS_HW_COMMS(X)
|
||||
#if AXIS_IS_TMC(X)
|
||||
monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(Y)
|
||||
#if AXIS_IS_TMC(Y)
|
||||
monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(Z)
|
||||
#if AXIS_IS_TMC(Z)
|
||||
monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(X2)
|
||||
#if AXIS_IS_TMC(X2)
|
||||
monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(Y2)
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(Z2)
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(Z3)
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(E0)
|
||||
#if AXIS_IS_TMC(E0)
|
||||
monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(E1)
|
||||
#if AXIS_IS_TMC(E1)
|
||||
monitor_tmc_driver(stepperE1, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(E2)
|
||||
#if AXIS_IS_TMC(E2)
|
||||
monitor_tmc_driver(stepperE2, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(E3)
|
||||
#if AXIS_IS_TMC(E3)
|
||||
monitor_tmc_driver(stepperE3, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(E4)
|
||||
#if AXIS_IS_TMC(E4)
|
||||
monitor_tmc_driver(stepperE4, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
#if HAS_HW_COMMS(E5)
|
||||
#if AXIS_IS_TMC(E5)
|
||||
monitor_tmc_driver(stepperE5, need_update_error_counters, need_debug_reporting);
|
||||
#endif
|
||||
|
||||
@ -471,8 +469,8 @@
|
||||
template<class TMC>
|
||||
static void print_vsense(TMC &st) { serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); }
|
||||
|
||||
#if HAS_TMCX1X0
|
||||
static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
|
||||
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130)
|
||||
static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
|
||||
switch (i) {
|
||||
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
|
||||
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
|
||||
@ -480,6 +478,8 @@
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if HAS_TMCX1X0
|
||||
static void _tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) {
|
||||
switch (i) {
|
||||
case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('X'); break;
|
||||
@ -492,10 +492,13 @@
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5160)
|
||||
template<char AXIS_LETTER, char DRIVER_ID> void print_vsense(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID> &st) { UNUSED(st); }
|
||||
template<char AXIS_LETTER, char DRIVER_ID> void print_vsense(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID> &st) { UNUSED(st); }
|
||||
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
||||
void print_vsense(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &) { }
|
||||
|
||||
static void tmc_status(TMC2160Stepper &st, const TMC_debug_enum i) {
|
||||
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
||||
void print_vsense(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &) { }
|
||||
|
||||
static void _tmc_status(TMC2160Stepper &st, const TMC_debug_enum i) {
|
||||
switch (i) {
|
||||
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
|
||||
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
|
||||
@ -513,7 +516,7 @@
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER(TMC2208)
|
||||
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
|
||||
static void _tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
|
||||
switch (i) {
|
||||
case TMC_PWM_SCALE: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break;
|
||||
case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break;
|
||||
@ -539,7 +542,7 @@
|
||||
#endif
|
||||
|
||||
template <typename TMC>
|
||||
static void tmc_status(TMC &st, const TMC_debug_enum i, const float spmm) {
|
||||
static void tmc_status(TMC &st, const TMC_debug_enum i) {
|
||||
SERIAL_CHAR('\t');
|
||||
switch (i) {
|
||||
case TMC_CODES: st.printLabel(); break;
|
||||
@ -573,9 +576,9 @@
|
||||
}
|
||||
break;
|
||||
case TMC_TPWMTHRS_MMS: {
|
||||
uint32_t tpwmthrs_val = st.TPWMTHRS();
|
||||
uint32_t tpwmthrs_val = st.get_pwm_thrs();
|
||||
if (tpwmthrs_val)
|
||||
SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm));
|
||||
SERIAL_ECHO(tpwmthrs_val);
|
||||
else
|
||||
SERIAL_CHAR('-');
|
||||
}
|
||||
@ -588,13 +591,13 @@
|
||||
case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break;
|
||||
case TMC_HEND: SERIAL_PRINT(st.hysteresis_end(), DEC); break;
|
||||
case TMC_HSTRT: SERIAL_PRINT(st.hysteresis_start(), DEC); break;
|
||||
default: tmc_status(st, i); break;
|
||||
default: _tmc_status(st, i); break;
|
||||
}
|
||||
}
|
||||
|
||||
#if HAS_DRIVER(TMC2660)
|
||||
template<char AXIS_LETTER, char DRIVER_ID>
|
||||
void tmc_status(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> &st, const TMC_debug_enum i, const float) {
|
||||
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
||||
void tmc_status(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const TMC_debug_enum i) {
|
||||
SERIAL_CHAR('\t');
|
||||
switch (i) {
|
||||
case TMC_CODES: st.printLabel(); break;
|
||||
@ -649,72 +652,52 @@
|
||||
static void tmc_debug_loop(const TMC_debug_enum i, const bool print_x, const bool print_y, const bool print_z, const bool print_e) {
|
||||
if (print_x) {
|
||||
#if AXIS_IS_TMC(X)
|
||||
tmc_status(stepperX, i, planner.settings.axis_steps_per_mm[X_AXIS]);
|
||||
tmc_status(stepperX, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
tmc_status(stepperX2, i, planner.settings.axis_steps_per_mm[X_AXIS]);
|
||||
tmc_status(stepperX2, i);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (print_y) {
|
||||
#if AXIS_IS_TMC(Y)
|
||||
tmc_status(stepperY, i, planner.settings.axis_steps_per_mm[Y_AXIS]);
|
||||
tmc_status(stepperY, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
tmc_status(stepperY2, i, planner.settings.axis_steps_per_mm[Y_AXIS]);
|
||||
tmc_status(stepperY2, i);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (print_z) {
|
||||
#if AXIS_IS_TMC(Z)
|
||||
tmc_status(stepperZ, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
|
||||
tmc_status(stepperZ, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
tmc_status(stepperZ2, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
|
||||
tmc_status(stepperZ2, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
tmc_status(stepperZ3, i, planner.settings.axis_steps_per_mm[Z_AXIS]);
|
||||
tmc_status(stepperZ3, i);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (print_e) {
|
||||
#if AXIS_IS_TMC(E0)
|
||||
tmc_status(stepperE0, i, planner.settings.axis_steps_per_mm[E_AXIS]);
|
||||
tmc_status(stepperE0, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
tmc_status(stepperE1, i, planner.settings.axis_steps_per_mm[E_AXIS
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
+ 1
|
||||
#endif
|
||||
]);
|
||||
tmc_status(stepperE1, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E2)
|
||||
tmc_status(stepperE2, i, planner.settings.axis_steps_per_mm[E_AXIS
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
+ 2
|
||||
#endif
|
||||
]);
|
||||
tmc_status(stepperE2, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E3)
|
||||
tmc_status(stepperE3, i, planner.settings.axis_steps_per_mm[E_AXIS
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
+ 3
|
||||
#endif
|
||||
]);
|
||||
tmc_status(stepperE3, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E4)
|
||||
tmc_status(stepperE4, i, planner.settings.axis_steps_per_mm[E_AXIS
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
+ 4
|
||||
#endif
|
||||
]);
|
||||
tmc_status(stepperE4, i);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E5)
|
||||
tmc_status(stepperE5, i, planner.settings.axis_steps_per_mm[E_AXIS
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
+ 5
|
||||
#endif
|
||||
]);
|
||||
tmc_status(stepperE5, i);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -877,8 +860,8 @@
|
||||
}
|
||||
#endif
|
||||
#if HAS_DRIVER(TMC2660)
|
||||
template <char AXIS_LETTER, char DRIVER_ID>
|
||||
static void tmc_get_registers(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> &st, const TMC_get_registers_enum i) {
|
||||
template <char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
||||
static void tmc_get_registers(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const TMC_get_registers_enum i) {
|
||||
switch (i) {
|
||||
case TMC_AXIS_CODES: SERIAL_CHAR('\t'); st.printLabel(); break;
|
||||
PRINT_TMC_REGISTER(DRVCONF);
|
||||
@ -1118,49 +1101,4 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
|
||||
if (axis_connection) ui.set_status_P(PSTR("TMC CONNECTION ERROR"));
|
||||
}
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
void init_tmc_section() {
|
||||
#if AXIS_IS_TMC(X)
|
||||
stepperX.init_lcd_variables(X_AXIS);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y)
|
||||
stepperY.init_lcd_variables(Y_AXIS);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z)
|
||||
stepperZ.init_lcd_variables(Z_AXIS);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
stepperX2.init_lcd_variables(X_AXIS);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
stepperY2.init_lcd_variables(Y_AXIS);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
stepperZ2.init_lcd_variables(Z_AXIS);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
stepperZ3.init_lcd_variables(Z_AXIS);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E0)
|
||||
stepperE0.init_lcd_variables(E_AXIS);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
stepperE1.init_lcd_variables(E_AXIS_N(1));
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E2)
|
||||
stepperE2.init_lcd_variables(E_AXIS_N(2));
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E3)
|
||||
stepperE3.init_lcd_variables(E_AXIS_N(3));
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E4)
|
||||
stepperE4.init_lcd_variables(E_AXIS_N(4));
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E5)
|
||||
stepperE5.init_lcd_variables(E_AXIS_N(5));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HAS_TRINAMIC
|
||||
|
@ -23,12 +23,11 @@
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
#include "../lcd/ultralcd.h"
|
||||
|
||||
#if HAS_TRINAMIC
|
||||
#include <TMCStepper.h>
|
||||
#endif
|
||||
#if HAS_LCD_MENU
|
||||
#include "../module/planner.h"
|
||||
#endif
|
||||
|
||||
#include <TMCStepper.h>
|
||||
#include "../module/planner.h"
|
||||
|
||||
#define TMC_X_LABEL 'X', '0'
|
||||
#define TMC_Y_LABEL 'Y', '0'
|
||||
@ -57,7 +56,7 @@
|
||||
#define MONITOR_DRIVER_STATUS_INTERVAL_MS 500u
|
||||
#endif
|
||||
|
||||
constexpr uint16_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) {
|
||||
constexpr uint16_t _tmc_thrs(const uint16_t msteps, const uint32_t thrs, const uint32_t spmm) {
|
||||
return 12650000UL * msteps / (256 * thrs * spmm);
|
||||
}
|
||||
|
||||
@ -92,13 +91,13 @@ class TMCStorage {
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
uint8_t hybrid_thrs = 0;
|
||||
#endif
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
#if USE_SENSORLESS
|
||||
int8_t homing_thrs = 0;
|
||||
#endif
|
||||
} stored;
|
||||
};
|
||||
|
||||
template<class TMC, char AXIS_LETTER, char DRIVER_ID>
|
||||
template<class TMC, char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
||||
class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
||||
public:
|
||||
TMCMarlin(uint16_t cs_pin, float RS) :
|
||||
@ -121,30 +120,40 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
||||
inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
|
||||
inline bool get_stealthChop_status() { return this->en_pwm_mode(); }
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
inline void init_lcd_variables(const AxisEnum spmm_id) {
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
this->stored.hybrid_thrs = _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[spmm_id]);
|
||||
#endif
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
this->stored.homing_thrs = this->sgt();
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
uint32_t get_pwm_thrs() {
|
||||
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
|
||||
}
|
||||
void set_pwm_thrs(const uint32_t thrs) {
|
||||
TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
|
||||
#if HAS_LCD_MENU
|
||||
this->stored.hybrid_thrs = thrs;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if USE_SENSORLESS
|
||||
inline int8_t sgt() { return TMC::sgt(); }
|
||||
void sgt(const int8_t sgt_val) {
|
||||
TMC::sgt(sgt_val);
|
||||
#if HAS_LCD_MENU
|
||||
this->stored.homing_thrs = sgt_val;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
inline void refresh_stepper_current() { rms_current(this->val_mA); }
|
||||
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
inline void refresh_hybrid_thrs(float spmm) { this->TPWMTHRS(_tmc_thrs(this->microsteps(), this->stored.hybrid_thrs, spmm)); }
|
||||
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
|
||||
#endif
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
inline void refresh_homing_thrs() { this->sgt(this->stored.homing_thrs); }
|
||||
#if USE_SENSORLESS
|
||||
inline void refresh_homing_thrs() { sgt(this->stored.homing_thrs); }
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
template<char AXIS_LETTER, char DRIVER_ID>
|
||||
class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID> : public TMC2208Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
||||
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
||||
class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC2208Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
||||
public:
|
||||
TMCMarlin(Stream * SerialPort, float RS, bool has_rx=true) :
|
||||
TMC2208Stepper(SerialPort, RS, has_rx=true)
|
||||
@ -166,24 +175,28 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID> : public TMC2208Stepper,
|
||||
inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); }
|
||||
inline bool get_stealthChop_status() { return !this->en_spreadCycle(); }
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
inline void init_lcd_variables(const AxisEnum spmm_id) {
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
this->stored.hybrid_thrs = _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[spmm_id]);
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
uint32_t get_pwm_thrs() {
|
||||
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
|
||||
}
|
||||
void set_pwm_thrs(const uint32_t thrs) {
|
||||
TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
|
||||
#if HAS_LCD_MENU
|
||||
this->stored.hybrid_thrs = thrs;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
inline void refresh_stepper_current() { rms_current(this->val_mA); }
|
||||
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
inline void refresh_hybrid_thrs(float spmm) { this->TPWMTHRS(_tmc_thrs(this->microsteps(), this->stored.hybrid_thrs, spmm)); }
|
||||
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
template<char AXIS_LETTER, char DRIVER_ID>
|
||||
class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> : public TMC2660Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
||||
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
||||
class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC2660Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
||||
public:
|
||||
TMCMarlin(uint16_t cs_pin, float RS) :
|
||||
TMC2660Stepper(cs_pin, RS)
|
||||
@ -197,30 +210,30 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> : public TMC2660Stepper,
|
||||
TMC2660Stepper::rms_current(mA);
|
||||
}
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
inline void init_lcd_variables(const AxisEnum spmm_id) {
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
this->stored.homing_thrs = this->sgt();
|
||||
#if USE_SENSORLESS
|
||||
inline int8_t sgt() { return TMC2660Stepper::sgt(); }
|
||||
void sgt(const int8_t sgt_val) {
|
||||
TMC2660Stepper::sgt(sgt_val);
|
||||
#if HAS_LCD_MENU
|
||||
this->stored.homing_thrs = sgt_val;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
inline void refresh_stepper_current() { rms_current(this->val_mA); }
|
||||
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
inline void refresh_homing_thrs() { this->sgt(this->stored.homing_thrs); }
|
||||
#if USE_SENSORLESS
|
||||
inline void refresh_homing_thrs() { sgt(this->stored.homing_thrs); }
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename TMC>
|
||||
void tmc_get_current(TMC &st) {
|
||||
void tmc_print_current(TMC &st) {
|
||||
st.printLabel();
|
||||
SERIAL_ECHOLNPAIR(" driver current: ", st.getMilliamps());
|
||||
}
|
||||
template<typename TMC>
|
||||
void tmc_set_current(TMC &st, const int mA) {
|
||||
st.rms_current(mA);
|
||||
}
|
||||
|
||||
#if ENABLED(MONITOR_DRIVER_STATUS)
|
||||
template<typename TMC>
|
||||
@ -237,25 +250,21 @@ void tmc_set_current(TMC &st, const int mA) {
|
||||
SERIAL_ECHOLNPGM(" prewarn flag cleared");
|
||||
}
|
||||
#endif
|
||||
template<typename TMC>
|
||||
void tmc_get_pwmthrs(TMC &st, const uint16_t spmm) {
|
||||
st.printLabel();
|
||||
SERIAL_ECHOLNPAIR(" stealthChop max speed: ", _tmc_thrs(st.microsteps(), st.TPWMTHRS(), spmm));
|
||||
}
|
||||
template<typename TMC>
|
||||
void tmc_set_pwmthrs(TMC &st, const int32_t thrs, const uint32_t spmm) {
|
||||
st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
|
||||
}
|
||||
template<typename TMC>
|
||||
void tmc_get_sgt(TMC &st) {
|
||||
st.printLabel();
|
||||
SERIAL_ECHOPGM(" homing sensitivity: ");
|
||||
SERIAL_PRINTLN(st.sgt(), DEC);
|
||||
}
|
||||
template<typename TMC>
|
||||
void tmc_set_sgt(TMC &st, const int8_t sgt_val) {
|
||||
st.sgt(sgt_val);
|
||||
}
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
template<typename TMC>
|
||||
void tmc_print_pwmthrs(TMC &st) {
|
||||
st.printLabel();
|
||||
SERIAL_ECHOLNPAIR(" stealthChop max speed: ", st.get_pwm_thrs());
|
||||
}
|
||||
#endif
|
||||
#if USE_SENSORLESS
|
||||
template<typename TMC>
|
||||
void tmc_print_sgt(TMC &st) {
|
||||
st.printLabel();
|
||||
SERIAL_ECHOPGM(" homing sensitivity: ");
|
||||
SERIAL_PRINTLN(st.sgt(), DEC);
|
||||
}
|
||||
#endif
|
||||
|
||||
void monitor_tmc_driver();
|
||||
void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z, const bool test_e);
|
||||
@ -268,10 +277,6 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
|
||||
void tmc_get_registers(const bool print_x, const bool print_y, const bool print_z, const bool print_e);
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
void init_tmc_section();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* TMC2130 specific sensorless homing using stallGuard2.
|
||||
* stallGuard2 only works when in spreadCycle mode.
|
||||
@ -295,3 +300,5 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
|
||||
#if TMC_HAS_SPI
|
||||
void tmc_init_cs_pins();
|
||||
#endif
|
||||
|
||||
#endif // HAS_TRINAMIC
|
||||
|
Reference in New Issue
Block a user