UI and stall reset for extra TMC axes (#17818)

This commit is contained in:
Scott Lahteine 2020-04-30 22:52:33 -05:00 committed by GitHub
parent 6edc2c3690
commit a226b281af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 97 deletions

View File

@ -34,27 +34,9 @@ void StepperBumpSensitivityScreen::onRedraw(draw_mode_t what) {
widgets_t w(what);
w.precision(0, BaseNumericAdjustmentScreen::DEFAULT_LOWEST);
w.heading( GET_TEXT_F(MSG_TMC_HOMING_THRS));
w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getTMCBumpSensitivity(X),
#if X_SENSORLESS
true
#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.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_AXIS_X), getTMCBumpSensitivity(X), ENABLED(X_SENSORLESS));
w.color(y_axis) .adjuster( 4, GET_TEXT_F(MSG_AXIS_Y), getTMCBumpSensitivity(Y), ENABLED(Y_SENSORLESS));
w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_AXIS_Z), getTMCBumpSensitivity(Z), ENABLED(Z_SENSORLESS));
w.increments();
}
@ -62,11 +44,11 @@ bool StepperBumpSensitivityScreen::onTouchHeld(uint8_t tag) {
const float increment = getIncrement();
switch (tag) {
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 5: UI_INCREMENT(TMCBumpSensitivity, Y ); break;
case 5: UI_INCREMENT(TMCBumpSensitivity, Y2 ); break;
case 6: UI_DECREMENT(TMCBumpSensitivity, Z ); break;
case 7: UI_INCREMENT(TMCBumpSensitivity, Z ); break;
case 7: UI_INCREMENT(TMCBumpSensitivity, Z2 ); break;
default:
return false;
}

View File

@ -490,8 +490,13 @@ namespace ExtUI {
int getTMCBumpSensitivity(const axis_t axis) {
switch (axis) {
TERN_(X_SENSORLESS, case X: return stepperX.homing_threshold());
TERN_(X2_SENSORLESS, case X2: return stepperX2.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;
}
}
@ -502,12 +507,27 @@ namespace ExtUI {
#if X_SENSORLESS
case X: stepperX.homing_threshold(value); break;
#endif
#if X2_SENSORLESS
case X2: stepperX2.homing_threshold(value); break;
#endif
#if Y_SENSORLESS
case Y: stepperY.homing_threshold(value); break;
#endif
#if Y2_SENSORLESS
case Y2: stepperY2.homing_threshold(value); break;
#endif
#if Z_SENSORLESS
case Z: stepperZ.homing_threshold(value); break;
#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
UNUSED(value);
#endif

View File

@ -52,7 +52,7 @@ namespace ExtUI {
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 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 };

View File

@ -157,15 +157,27 @@ void menu_tmc_current() {
BACK_ITEM(MSG_TMC_DRIVERS);
#if X_SENSORLESS
TMC_EDIT_STORED_SGT(X);
#endif
#if X2_SENSORLESS
TMC_EDIT_STORED_SGT(X2);
#endif
#endif
#if Y_SENSORLESS
TMC_EDIT_STORED_SGT(Y);
#if Y2_SENSORLESS
TMC_EDIT_STORED_SGT(Y2);
#endif
#endif
#if Z_SENSORLESS
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
END_MENU();
}

View File

@ -117,16 +117,12 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#endif
#ifndef TMC_BAUD_RATE
#if HAS_TMC_SW_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
// 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
// platforms.
#define TMC_BAUD_RATE 57600
#else
#define TMC_BAUD_RATE 115200
#endif
#define TMC_BAUD_RATE TERN(HAS_TMC_SW_SERIAL, 57600, 115200)
#endif
#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;
st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(hyb_thrs);
#else
UNUSED(hyb_thrs);
#endif
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
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;
st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(hyb_thrs);
#else
UNUSED(hyb_thrs);
#endif
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
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;
st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(hyb_thrs);
#else
UNUSED(hyb_thrs);
#endif
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
st.GSTAT(0b111); // Clear
delay(200);
@ -535,11 +519,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
pwmconf.pwm_ofs = 36;
st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(hyb_thrs);
#else
UNUSED(hyb_thrs);
#endif
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
st.GSTAT(0b111); // Clear
delay(200);
@ -597,11 +577,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
pwmconf.pwm_ampl = 180;
st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(hyb_thrs);
#else
UNUSED(hyb_thrs);
#endif
TERN(HYBRID_THRESHOLD, st.set_pwm_thrs(hyb_thrs), UNUSED(hyb_thrs));
st.GSTAT(); // Clear GSTAT
}
@ -700,25 +676,7 @@ void restore_trinamic_drivers() {
}
void reset_trinamic_drivers() {
static constexpr bool stealthchop_by_axis[] = {
#if ENABLED(STEALTHCHOP_XY)
true
#else
false
#endif
,
#if ENABLED(STEALTHCHOP_Z)
true
#else
false
#endif
,
#if ENABLED(STEALTHCHOP_E)
true
#else
false
#endif
};
static constexpr bool stealthchop_by_axis[] = { ENABLED(STEALTHCHOP_XY), ENABLED(STEALTHCHOP_Z), ENABLED(STEALTHCHOP_E) };
#if AXIS_IS_TMC(X)
TMC_INIT(X, STEALTH_AXIS_XY);
@ -770,14 +728,30 @@ void reset_trinamic_drivers() {
#endif
#if USE_SENSORLESS
TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY));
TERN_(X2_SENSORLESS, stepperX2.homing_threshold(X2_STALL_SENSITIVITY));
TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY));
TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(Y2_STALL_SENSITIVITY));
TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY));
TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(Z2_STALL_SENSITIVITY));
TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(Z3_STALL_SENSITIVITY));
TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(Z4_STALL_SENSITIVITY));
#if X_SENSORLESS
stepperX.homing_threshold(X_STALL_SENSITIVITY);
#if AXIS_HAS_STALLGUARD(X2)
stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY));
#endif
#endif
#if Y_SENSORLESS
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
#ifdef TMC_ADV