Quiet M906/M913/M914 with axes. Patch for DISTINCT_E_FACTORS.

2.0.x
Scott Lahteine 7 years ago
parent c95450016b
commit cfc13ed7f3

@ -331,6 +331,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
} }
} }
#endif #endif
#if ENABLED(HAVE_TMC2208) #if ENABLED(HAVE_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) { switch (i) {

@ -55,7 +55,6 @@ void tmc_get_current(TMC &st, const TMC_AxisEnum axis) {
template<typename TMC> template<typename TMC>
void tmc_set_current(TMC &st, const TMC_AxisEnum axis, const int mA) { void tmc_set_current(TMC &st, const TMC_AxisEnum axis, const int mA) {
st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER); st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
tmc_get_current(st, axis);
} }
template<typename TMC> template<typename TMC>
void tmc_report_otpw(TMC &st, const TMC_AxisEnum axis) { void tmc_report_otpw(TMC &st, const TMC_AxisEnum axis) {
@ -73,7 +72,6 @@ void tmc_get_pwmthrs(TMC &st, const TMC_AxisEnum axis, const uint16_t spmm) {
template<typename TMC> template<typename TMC>
void tmc_set_pwmthrs(TMC &st, const TMC_AxisEnum axis, const int32_t thrs, const uint32_t spmm) { void tmc_set_pwmthrs(TMC &st, const TMC_AxisEnum axis, const int32_t thrs, const uint32_t spmm) {
st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm)); st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
tmc_get_pwmthrs(st, axis, spmm);
} }
template<typename TMC> template<typename TMC>
void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) { void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) {
@ -82,7 +80,6 @@ void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) {
template<typename TMC> template<typename TMC>
void tmc_set_sgt(TMC &st, const TMC_AxisEnum axis, const int8_t sgt_val) { void tmc_set_sgt(TMC &st, const TMC_AxisEnum axis, const int8_t sgt_val) {
st.sgt(sgt_val); st.sgt(sgt_val);
tmc_get_sgt(st, axis);
} }
void monitor_tmc_driver(); void monitor_tmc_driver();

@ -33,46 +33,100 @@
* Report driver currents when no axis specified * Report driver currents when no axis specified
*/ */
void GcodeSuite::M906() { void GcodeSuite::M906() {
uint16_t values[XYZE]; #define TMC_SAY_CURRENT(Q) tmc_get_current(stepper##Q, TMC_##Q)
LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]); #define TMC_SET_CURRENT(Q) tmc_set_current(stepper##Q, TMC_##Q, value)
#define TMC_SET_GET_CURRENT(P,Q) do { \ bool report = true;
if (values[P##_AXIS]) tmc_set_current(stepper##Q, TMC_##Q, values[P##_AXIS]); \ LOOP_XYZE(i) if (uint16_t value = parser.intval(axis_codes[i])) {
else tmc_get_current(stepper##Q, TMC_##Q); } while(0) report = false;
switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC
TMC_SET_CURRENT(X);
#endif
#if X2_IS_TRINAMIC
TMC_SET_CURRENT(X2);
#endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC
TMC_SET_CURRENT(Y);
#endif
#if Y2_IS_TRINAMIC
TMC_SET_CURRENT(Y2);
#endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC
TMC_SET_CURRENT(Z);
#endif
#if Z2_IS_TRINAMIC
TMC_SET_CURRENT(Z2);
#endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC
TMC_SET_CURRENT(E0);
#endif
#if E1_IS_TRINAMIC
TMC_SET_CURRENT(E1);
#endif
#if E2_IS_TRINAMIC
TMC_SET_CURRENT(E2);
#endif
#if E3_IS_TRINAMIC
TMC_SET_CURRENT(E3);
#endif
#if E4_IS_TRINAMIC
TMC_SET_CURRENT(E4);
#endif
break;
}
}
#if X_IS_TRINAMIC if (report) LOOP_XYZE(i) switch (i) {
TMC_SET_GET_CURRENT(X,X); case X_AXIS:
#endif #if X_IS_TRINAMIC
#if X2_IS_TRINAMIC TMC_SAY_CURRENT(X);
TMC_SET_GET_CURRENT(X,X2); #endif
#endif #if X2_IS_TRINAMIC
#if Y_IS_TRINAMIC TMC_SAY_CURRENT(X2);
TMC_SET_GET_CURRENT(Y,Y); #endif
#endif break;
#if Y2_IS_TRINAMIC case Y_AXIS:
TMC_SET_GET_CURRENT(Y,Y2); #if Y_IS_TRINAMIC
#endif TMC_SAY_CURRENT(Y);
#if Z_IS_TRINAMIC #endif
TMC_SET_GET_CURRENT(Z,Z); #if Y2_IS_TRINAMIC
#endif TMC_SAY_CURRENT(Y2);
#if Z2_IS_TRINAMIC #endif
TMC_SET_GET_CURRENT(Z,Z2); break;
#endif case Z_AXIS:
#if E0_IS_TRINAMIC #if Z_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E0); TMC_SAY_CURRENT(Z);
#endif #endif
#if E1_IS_TRINAMIC #if Z2_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E1); TMC_SAY_CURRENT(Z2);
#endif #endif
#if E2_IS_TRINAMIC break;
TMC_SET_GET_CURRENT(E,E2); case E_AXIS:
#endif #if E0_IS_TRINAMIC
#if E3_IS_TRINAMIC TMC_SAY_CURRENT(E0);
TMC_SET_GET_CURRENT(E,E3); #endif
#endif #if E1_IS_TRINAMIC
#if E4_IS_TRINAMIC TMC_SAY_CURRENT(E1);
TMC_SET_GET_CURRENT(E,E4); #endif
#endif #if E2_IS_TRINAMIC
TMC_SAY_CURRENT(E2);
#endif
#if E3_IS_TRINAMIC
TMC_SAY_CURRENT(E3);
#endif
#if E4_IS_TRINAMIC
TMC_SAY_CURRENT(E4);
#endif
break;
}
} }
#endif // HAS_TRINAMIC #endif // HAS_TRINAMIC

@ -80,46 +80,102 @@ void GcodeSuite::M912() {
*/ */
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
void GcodeSuite::M913() { void GcodeSuite::M913() {
uint16_t values[XYZE]; #define TMC_SAY_PWMTHRS(P,Q) tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS])
LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]); #define TMC_SET_PWMTHRS(P,Q) tmc_set_pwmthrs(stepper##Q, TMC_##Q, value, planner.axis_steps_per_mm[P##_AXIS])
#define TMC_SAY_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
#define TMC_SET_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, TMC_E##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
#define TMC_SET_GET_PWMTHRS(P,Q) do { \ bool report = true;
if (values[P##_AXIS]) tmc_set_pwmthrs(stepper##Q, TMC_##Q, values[P##_AXIS], planner.axis_steps_per_mm[P##_AXIS]); \ LOOP_XYZE(i) if (int32_t value = parser.longval(axis_codes[i])) {
else tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS]); } while(0) report = false;
switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC
TMC_SET_PWMTHRS(X,X);
#endif
#if X2_IS_TRINAMIC
TMC_SET_PWMTHRS(X,X2);
#endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC
TMC_SET_PWMTHRS(Y,Y);
#endif
#if Y2_IS_TRINAMIC
TMC_SET_PWMTHRS(Y,Y2);
#endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC
TMC_SET_PWMTHRS(Z,Z);
#endif
#if Z2_IS_TRINAMIC
TMC_SET_PWMTHRS(Z,Z2);
#endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC
TMC_SET_PWMTHRS_E(0);
#endif
#if E1_IS_TRINAMIC
TMC_SET_PWMTHRS_E(1);
#endif
#if E2_IS_TRINAMIC
TMC_SET_PWMTHRS_E(2);
#endif
#if E3_IS_TRINAMIC
TMC_SET_PWMTHRS_E(3);
#endif
#if E4_IS_TRINAMIC
TMC_SET_PWMTHRS_E(4);
#endif
break;
}
}
#if X_IS_TRINAMIC if (report) LOOP_XYZE(i) switch (i) {
TMC_SET_GET_PWMTHRS(X,X); case X_AXIS:
#endif #if X_IS_TRINAMIC
#if X2_IS_TRINAMIC TMC_SAY_PWMTHRS(X,X);
TMC_SET_GET_PWMTHRS(X,X2); #endif
#endif #if X2_IS_TRINAMIC
#if Y_IS_TRINAMIC TMC_SAY_PWMTHRS(X,X2);
TMC_SET_GET_PWMTHRS(Y,Y); #endif
#endif break;
#if Y2_IS_TRINAMIC case Y_AXIS:
TMC_SET_GET_PWMTHRS(Y,Y2); #if Y_IS_TRINAMIC
#endif TMC_SAY_PWMTHRS(Y,Y);
#if Z_IS_TRINAMIC #endif
TMC_SET_GET_PWMTHRS(Z,Z); #if Y2_IS_TRINAMIC
#endif TMC_SAY_PWMTHRS(Y,Y2);
#if Z2_IS_TRINAMIC #endif
TMC_SET_GET_PWMTHRS(Z,Z2); break;
#endif case Z_AXIS:
#if E0_IS_TRINAMIC #if Z_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E0); TMC_SAY_PWMTHRS(Z,Z);
#endif #endif
#if E1_IS_TRINAMIC #if Z2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E1); TMC_SAY_PWMTHRS(Z,Z2);
#endif #endif
#if E2_IS_TRINAMIC break;
TMC_SET_GET_PWMTHRS(E,E2); case E_AXIS:
#endif #if E0_IS_TRINAMIC
#if E3_IS_TRINAMIC TMC_SAY_PWMTHRS_E(0);
TMC_SET_GET_PWMTHRS(E,E3); #endif
#endif #if E1_IS_TRINAMIC
#if E4_IS_TRINAMIC TMC_SAY_PWMTHRS_E(1);
TMC_SET_GET_PWMTHRS(E,E4); #endif
#endif #if E2_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(2);
#endif
#if E3_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(3);
#endif
#if E4_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(4);
#endif
break;
}
} }
#endif // HYBRID_THRESHOLD #endif // HYBRID_THRESHOLD
@ -128,34 +184,67 @@ void GcodeSuite::M912() {
*/ */
#if ENABLED(SENSORLESS_HOMING) #if ENABLED(SENSORLESS_HOMING)
void GcodeSuite::M914() { void GcodeSuite::M914() {
#define TMC_SET_GET_SGT(P,Q) do { \ #define TMC_SAY_SGT(Q) tmc_get_sgt(stepper##Q, TMC_##Q)
if (parser.seen(axis_codes[P##_AXIS])) tmc_set_sgt(stepper##Q, TMC_##Q, parser.value_int()); \ #define TMC_SET_SGT(Q) tmc_set_sgt(stepper##Q, TMC_##Q, value)
else tmc_get_sgt(stepper##Q, TMC_##Q); } while(0)
#ifdef X_HOMING_SENSITIVITY bool report = true;
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) LOOP_XYZ(i) if (parser.seen(axis_codes[i])) {
TMC_SET_GET_SGT(X,X); const int8_t value = (int8_t)constrain(parser.value_int(), -63, 64);
#endif report = false;
#if ENABLED(X2_IS_TMC2130) switch (i) {
TMC_SET_GET_SGT(X,X2); case X_AXIS:
#endif #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
#endif TMC_SET_SGT(X);
#ifdef Y_HOMING_SENSITIVITY #endif
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(X2_IS_TMC2130)
TMC_SET_GET_SGT(Y,Y); TMC_SET_SGT(X2);
#endif #endif
#if ENABLED(Y2_IS_TMC2130) break;
TMC_SET_GET_SGT(Y,Y2); case Y_AXIS:
#endif #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
#endif TMC_SET_SGT(Y);
#ifdef Z_HOMING_SENSITIVITY #endif
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Y2_IS_TMC2130)
TMC_SET_GET_SGT(Z,Z); TMC_SET_SGT(Y2);
#endif #endif
#if ENABLED(Z2_IS_TMC2130) break;
TMC_SET_GET_SGT(Z,Z2); case Z_AXIS:
#endif #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
#endif TMC_SET_SGT(Z);
#endif
#if ENABLED(Z2_IS_TMC2130)
TMC_SET_SGT(Z2);
#endif
break;
}
}
if (report) LOOP_XYZ(i) switch (i) {
case X_AXIS:
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(X);
#endif
#if ENABLED(X2_IS_TMC2130)
TMC_SAY_SGT(X2);
#endif
break;
case Y_AXIS:
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(Y);
#endif
#if ENABLED(Y2_IS_TMC2130)
TMC_SAY_SGT(Y2);
#endif
break;
case Z_AXIS:
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(Z);
#endif
#if ENABLED(Z2_IS_TMC2130)
TMC_SAY_SGT(Z2);
#endif
break;
}
} }
#endif // SENSORLESS_HOMING #endif // SENSORLESS_HOMING

Loading…
Cancel
Save