UI and stall reset for extra TMC axes (#17818)
This commit is contained in:
parent
6edc2c3690
commit
a226b281af
5 changed files with 85 additions and 97 deletions
|
@ -34,39 +34,21 @@ void StepperBumpSensitivityScreen::onRedraw(draw_mode_t what) {
|
||||||
widgets_t w(what);
|
widgets_t w(what);
|
||||||
w.precision(0, BaseNumericAdjustmentScreen::DEFAULT_LOWEST);
|
w.precision(0, BaseNumericAdjustmentScreen::DEFAULT_LOWEST);
|
||||||
w.heading( GET_TEXT_F(MSG_TMC_HOMING_THRS));
|
w.heading( GET_TEXT_F(MSG_TMC_HOMING_THRS));
|
||||||
w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getTMCBumpSensitivity(X),
|
w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getTMCBumpSensitivity(X), ENABLED(X_SENSORLESS));
|
||||||
#if X_SENSORLESS
|
w.color(y_axis) .adjuster( 4, GET_TEXT_F(MSG_AXIS_Y), getTMCBumpSensitivity(Y), ENABLED(Y_SENSORLESS));
|
||||||
true
|
w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getTMCBumpSensitivity(Z), ENABLED(Z_SENSORLESS));
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
w.color(y_axis) .adjuster( 4, GET_TEXT_F(MSG_AXIS_Y), getTMCBumpSensitivity(Y),
|
|
||||||
#if Y_SENSORLESS
|
|
||||||
true
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getTMCBumpSensitivity(Z),
|
|
||||||
#if Z_SENSORLESS
|
|
||||||
true
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
w.increments();
|
w.increments();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StepperBumpSensitivityScreen::onTouchHeld(uint8_t tag) {
|
bool StepperBumpSensitivityScreen::onTouchHeld(uint8_t tag) {
|
||||||
const float increment = getIncrement();
|
const float increment = getIncrement();
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case 2: UI_DECREMENT(TMCBumpSensitivity, X ); break;
|
case 2: UI_DECREMENT(TMCBumpSensitivity, X ); break;
|
||||||
case 3: UI_INCREMENT(TMCBumpSensitivity, X ); break;
|
case 3: UI_INCREMENT(TMCBumpSensitivity, X2 ); break;
|
||||||
case 4: UI_DECREMENT(TMCBumpSensitivity, Y ); break;
|
case 4: UI_DECREMENT(TMCBumpSensitivity, Y ); break;
|
||||||
case 5: UI_INCREMENT(TMCBumpSensitivity, Y ); break;
|
case 5: UI_INCREMENT(TMCBumpSensitivity, Y2 ); break;
|
||||||
case 6: UI_DECREMENT(TMCBumpSensitivity, Z ); break;
|
case 6: UI_DECREMENT(TMCBumpSensitivity, Z ); break;
|
||||||
case 7: UI_INCREMENT(TMCBumpSensitivity, Z ); break;
|
case 7: UI_INCREMENT(TMCBumpSensitivity, Z2 ); break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,9 +489,14 @@ namespace ExtUI {
|
||||||
|
|
||||||
int getTMCBumpSensitivity(const axis_t axis) {
|
int getTMCBumpSensitivity(const axis_t axis) {
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
TERN_(X_SENSORLESS, case X: return stepperX.homing_threshold());
|
TERN_(X_SENSORLESS, case X: return stepperX.homing_threshold());
|
||||||
TERN_(Y_SENSORLESS, case Y: return stepperY.homing_threshold());
|
TERN_(X2_SENSORLESS, case X2: return stepperX2.homing_threshold());
|
||||||
TERN_(Z_SENSORLESS, case Z: return stepperZ.homing_threshold());
|
TERN_(Y_SENSORLESS, case Y: return stepperY.homing_threshold());
|
||||||
|
TERN_(Y2_SENSORLESS, case Y2: return stepperY2.homing_threshold());
|
||||||
|
TERN_(Z_SENSORLESS, case Z: return stepperZ.homing_threshold());
|
||||||
|
TERN_(Z2_SENSORLESS, case Z2: return stepperZ2.homing_threshold());
|
||||||
|
TERN_(Z3_SENSORLESS, case Z3: return stepperZ3.homing_threshold());
|
||||||
|
TERN_(Z4_SENSORLESS, case Z4: return stepperZ4.homing_threshold());
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,14 +505,29 @@ namespace ExtUI {
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
#if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS
|
#if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS
|
||||||
#if X_SENSORLESS
|
#if X_SENSORLESS
|
||||||
case X: stepperX.homing_threshold(value); break;
|
case X: stepperX.homing_threshold(value); break;
|
||||||
|
#endif
|
||||||
|
#if X2_SENSORLESS
|
||||||
|
case X2: stepperX2.homing_threshold(value); break;
|
||||||
#endif
|
#endif
|
||||||
#if Y_SENSORLESS
|
#if Y_SENSORLESS
|
||||||
case Y: stepperY.homing_threshold(value); break;
|
case Y: stepperY.homing_threshold(value); break;
|
||||||
#endif
|
#endif
|
||||||
|
#if Y2_SENSORLESS
|
||||||
|
case Y2: stepperY2.homing_threshold(value); break;
|
||||||
|
#endif
|
||||||
#if Z_SENSORLESS
|
#if Z_SENSORLESS
|
||||||
case Z: stepperZ.homing_threshold(value); break;
|
case Z: stepperZ.homing_threshold(value); break;
|
||||||
#endif
|
#endif
|
||||||
|
#if Z2_SENSORLESS
|
||||||
|
case Z2: stepperZ2.homing_threshold(value); break;
|
||||||
|
#endif
|
||||||
|
#if Z3_SENSORLESS
|
||||||
|
case Z3: stepperZ3.homing_threshold(value); break;
|
||||||
|
#endif
|
||||||
|
#if Z4_SENSORLESS
|
||||||
|
case Z4: stepperZ4.homing_threshold(value); break;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
UNUSED(value);
|
UNUSED(value);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace ExtUI {
|
||||||
|
|
||||||
static constexpr size_t eeprom_data_size = 48;
|
static constexpr size_t eeprom_data_size = 48;
|
||||||
|
|
||||||
enum axis_t : uint8_t { X, Y, Z };
|
enum axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 };
|
||||||
enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 };
|
enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 };
|
||||||
enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER };
|
enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER };
|
||||||
enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 };
|
enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 };
|
||||||
|
|
|
@ -157,15 +157,27 @@ void menu_tmc_current() {
|
||||||
BACK_ITEM(MSG_TMC_DRIVERS);
|
BACK_ITEM(MSG_TMC_DRIVERS);
|
||||||
#if X_SENSORLESS
|
#if X_SENSORLESS
|
||||||
TMC_EDIT_STORED_SGT(X);
|
TMC_EDIT_STORED_SGT(X);
|
||||||
#endif
|
#if X2_SENSORLESS
|
||||||
#if X2_SENSORLESS
|
TMC_EDIT_STORED_SGT(X2);
|
||||||
TMC_EDIT_STORED_SGT(X2);
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if Y_SENSORLESS
|
#if Y_SENSORLESS
|
||||||
TMC_EDIT_STORED_SGT(Y);
|
TMC_EDIT_STORED_SGT(Y);
|
||||||
|
#if Y2_SENSORLESS
|
||||||
|
TMC_EDIT_STORED_SGT(Y2);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if Z_SENSORLESS
|
#if Z_SENSORLESS
|
||||||
TMC_EDIT_STORED_SGT(Z);
|
TMC_EDIT_STORED_SGT(Z);
|
||||||
|
#if Z2_SENSORLESS
|
||||||
|
TMC_EDIT_STORED_SGT(Z2);
|
||||||
|
#endif
|
||||||
|
#if Z3_SENSORLESS
|
||||||
|
TMC_EDIT_STORED_SGT(Z3);
|
||||||
|
#endif
|
||||||
|
#if Z4_SENSORLESS
|
||||||
|
TMC_EDIT_STORED_SGT(Z4);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
END_MENU();
|
END_MENU();
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,16 +117,12 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TMC_BAUD_RATE
|
#ifndef TMC_BAUD_RATE
|
||||||
#if HAS_TMC_SW_SERIAL
|
// Reduce baud rate for boards not already overriding TMC_BAUD_RATE for software serial.
|
||||||
// Reduce baud rate for boards not already overriding TMC_BAUD_RATE for software serial.
|
// Testing has shown that 115200 is not 100% reliable on AVR platforms, occasionally
|
||||||
// Testing has shown that 115200 is not 100% reliable on AVR platforms, occasionally
|
// failing to read status properly. 32-bit platforms typically define an even lower
|
||||||
// failing to read status properly. 32-bit platforms typically define an even lower
|
// TMC_BAUD_RATE, due to differences in how SoftwareSerial libraries work on different
|
||||||
// TMC_BAUD_RATE, due to differences in how SoftwareSerial libraries work on different
|
// platforms.
|
||||||
// platforms.
|
#define TMC_BAUD_RATE TERN(HAS_TMC_SW_SERIAL, 57600, 115200)
|
||||||
#define TMC_BAUD_RATE 57600
|
|
||||||
#else
|
|
||||||
#define TMC_BAUD_RATE 115200
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_DRIVER(TMC2130)
|
#if HAS_DRIVER(TMC2130)
|
||||||
|
@ -158,11 +154,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
||||||
pwmconf.pwm_ampl = 180;
|
pwmconf.pwm_ampl = 180;
|
||||||
st.PWMCONF(pwmconf.sr);
|
st.PWMCONF(pwmconf.sr);
|
||||||
|
|
||||||
#if ENABLED(HYBRID_THRESHOLD)
|
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
||||||
st.set_pwm_thrs(hyb_thrs);
|
|
||||||
#else
|
|
||||||
UNUSED(hyb_thrs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
st.GSTAT(); // Clear GSTAT
|
st.GSTAT(); // Clear GSTAT
|
||||||
}
|
}
|
||||||
|
@ -200,11 +192,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
||||||
pwmconf.pwm_ofs = 36;
|
pwmconf.pwm_ofs = 36;
|
||||||
st.PWMCONF(pwmconf.sr);
|
st.PWMCONF(pwmconf.sr);
|
||||||
|
|
||||||
#if ENABLED(HYBRID_THRESHOLD)
|
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
||||||
st.set_pwm_thrs(hyb_thrs);
|
|
||||||
#else
|
|
||||||
UNUSED(hyb_thrs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
st.GSTAT(); // Clear GSTAT
|
st.GSTAT(); // Clear GSTAT
|
||||||
}
|
}
|
||||||
|
@ -489,11 +477,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
||||||
pwmconf.pwm_ofs = 36;
|
pwmconf.pwm_ofs = 36;
|
||||||
st.PWMCONF(pwmconf.sr);
|
st.PWMCONF(pwmconf.sr);
|
||||||
|
|
||||||
#if ENABLED(HYBRID_THRESHOLD)
|
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
||||||
st.set_pwm_thrs(hyb_thrs);
|
|
||||||
#else
|
|
||||||
UNUSED(hyb_thrs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
st.GSTAT(0b111); // Clear
|
st.GSTAT(0b111); // Clear
|
||||||
delay(200);
|
delay(200);
|
||||||
|
@ -535,11 +519,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
||||||
pwmconf.pwm_ofs = 36;
|
pwmconf.pwm_ofs = 36;
|
||||||
st.PWMCONF(pwmconf.sr);
|
st.PWMCONF(pwmconf.sr);
|
||||||
|
|
||||||
#if ENABLED(HYBRID_THRESHOLD)
|
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
||||||
st.set_pwm_thrs(hyb_thrs);
|
|
||||||
#else
|
|
||||||
UNUSED(hyb_thrs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
st.GSTAT(0b111); // Clear
|
st.GSTAT(0b111); // Clear
|
||||||
delay(200);
|
delay(200);
|
||||||
|
@ -597,11 +577,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
||||||
pwmconf.pwm_ampl = 180;
|
pwmconf.pwm_ampl = 180;
|
||||||
st.PWMCONF(pwmconf.sr);
|
st.PWMCONF(pwmconf.sr);
|
||||||
|
|
||||||
#if ENABLED(HYBRID_THRESHOLD)
|
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
|
||||||
st.set_pwm_thrs(hyb_thrs);
|
|
||||||
#else
|
|
||||||
UNUSED(hyb_thrs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
st.GSTAT(); // Clear GSTAT
|
st.GSTAT(); // Clear GSTAT
|
||||||
}
|
}
|
||||||
|
@ -700,25 +676,7 @@ void restore_trinamic_drivers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_trinamic_drivers() {
|
void reset_trinamic_drivers() {
|
||||||
static constexpr bool stealthchop_by_axis[] = {
|
static constexpr bool stealthchop_by_axis[] = { ENABLED(STEALTHCHOP_XY), ENABLED(STEALTHCHOP_Z), ENABLED(STEALTHCHOP_E) };
|
||||||
#if ENABLED(STEALTHCHOP_XY)
|
|
||||||
true
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
#if ENABLED(STEALTHCHOP_Z)
|
|
||||||
true
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
#if ENABLED(STEALTHCHOP_E)
|
|
||||||
true
|
|
||||||
#else
|
|
||||||
false
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#if AXIS_IS_TMC(X)
|
#if AXIS_IS_TMC(X)
|
||||||
TMC_INIT(X, STEALTH_AXIS_XY);
|
TMC_INIT(X, STEALTH_AXIS_XY);
|
||||||
|
@ -770,14 +728,30 @@ void reset_trinamic_drivers() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_SENSORLESS
|
#if USE_SENSORLESS
|
||||||
TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY));
|
#if X_SENSORLESS
|
||||||
TERN_(X2_SENSORLESS, stepperX2.homing_threshold(X2_STALL_SENSITIVITY));
|
stepperX.homing_threshold(X_STALL_SENSITIVITY);
|
||||||
TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY));
|
#if AXIS_HAS_STALLGUARD(X2)
|
||||||
TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(Y2_STALL_SENSITIVITY));
|
stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY));
|
||||||
TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY));
|
#endif
|
||||||
TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(Z2_STALL_SENSITIVITY));
|
#endif
|
||||||
TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(Z3_STALL_SENSITIVITY));
|
#if Y_SENSORLESS
|
||||||
TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(Z4_STALL_SENSITIVITY));
|
stepperY.homing_threshold(Y_STALL_SENSITIVITY);
|
||||||
|
#if AXIS_HAS_STALLGUARD(Y2)
|
||||||
|
stepperY2.homing_threshold(CAT(TERN(Y2_SENSORLESS, Y2, Y), _STALL_SENSITIVITY));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if Z_SENSORLESS
|
||||||
|
stepperZ.homing_threshold(Z_STALL_SENSITIVITY);
|
||||||
|
#if AXIS_HAS_STALLGUARD(Z2)
|
||||||
|
stepperZ2.homing_threshold(CAT(TERN(Z2_SENSORLESS, Z2, Z), _STALL_SENSITIVITY));
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_STALLGUARD(Z3)
|
||||||
|
stepperZ3.homing_threshold(CAT(TERN(Z3_SENSORLESS, Z3, Z), _STALL_SENSITIVITY));
|
||||||
|
#endif
|
||||||
|
#if AXIS_HAS_STALLGUARD(Z4)
|
||||||
|
stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TMC_ADV
|
#ifdef TMC_ADV
|
||||||
|
|
Reference in a new issue