Merge pull request #4053 from vintagepc/2477-redux
#2477 Improved M-code control for stealth mode/normal mode
This commit is contained in:
commit
07d7bfa8a4
|
|
@ -173,6 +173,7 @@ void manage_inactivity(bool ignore_stepper_queue=false);
|
|||
#define enable_z() poweron_z()
|
||||
#define disable_z() poweroff_z()
|
||||
#else
|
||||
extern bool bEnableForce_z; // Used by ultralcd stealth toggle
|
||||
void init_force_z();
|
||||
void check_force_z();
|
||||
void enable_force_z();
|
||||
|
|
@ -440,6 +441,7 @@ extern int8_t busy_state;
|
|||
#define FORCE_HIGH_POWER_END force_high_power_mode(false)
|
||||
|
||||
void force_high_power_mode(bool start_high_power_section);
|
||||
void change_power_mode_live(uint8_t mode);
|
||||
|
||||
#endif //TMC2130
|
||||
|
||||
|
|
|
|||
|
|
@ -2409,25 +2409,30 @@ void retract(bool retracting, bool swapretract = false) {
|
|||
|
||||
|
||||
#ifdef TMC2130
|
||||
void force_high_power_mode(bool start_high_power_section) {
|
||||
#ifdef PSU_Delta
|
||||
if (start_high_power_section == true) enable_force_z();
|
||||
#endif //PSU_Delta
|
||||
uint8_t silent;
|
||||
silent = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
||||
if (silent == 1) {
|
||||
//we are in silent mode, set to normal mode to enable crash detection
|
||||
|
||||
// Wait for the planner queue to drain and for the stepper timer routine to reach an idle state.
|
||||
void change_power_mode_live(uint8_t mode)
|
||||
{
|
||||
// Wait for the planner queue to drain and for the stepper timer routine to reach an idle state.
|
||||
st_synchronize();
|
||||
cli();
|
||||
tmc2130_mode = (start_high_power_section == true) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT;
|
||||
tmc2130_mode = mode;
|
||||
update_mode_profile();
|
||||
tmc2130_init(TMCInitParams(FarmOrUserECool()));
|
||||
// We may have missed a stepper timer interrupt due to the time spent in the tmc2130_init() routine.
|
||||
// Be safe than sorry, reset the stepper timer before re-enabling interrupts.
|
||||
st_reset_timer();
|
||||
sei();
|
||||
}
|
||||
|
||||
void force_high_power_mode(bool start_high_power_section) {
|
||||
#ifdef PSU_Delta
|
||||
if (start_high_power_section == true) enable_force_z();
|
||||
#endif //PSU_Delta
|
||||
uint8_t silent;
|
||||
silent = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
||||
if (silent == 1 || tmc2130_mode == TMC2130_MODE_SILENT) {
|
||||
//we are in silent mode, set to normal mode to enable crash detection
|
||||
change_power_mode_live((start_high_power_section == true) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT);
|
||||
}
|
||||
}
|
||||
#endif //TMC2130
|
||||
|
|
@ -8172,30 +8177,64 @@ Sigma_Exit:
|
|||
}
|
||||
break;
|
||||
|
||||
/*!
|
||||
#endif // TMC2130_SERVICE_CODES_M910_M918
|
||||
/*!
|
||||
### M914 - Set TMC2130 normal mode <a href="https://reprap.org/wiki/G-code#M914:_Set_TMC2130_normal_mode">M914: Set TMC2130 normal mode</a>
|
||||
Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code.
|
||||
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
|
||||
#### Usage
|
||||
|
||||
M914 [ P | R ]
|
||||
|
||||
#### Parameters
|
||||
- `P` - Make the mode change permanent (write to EEPROM)
|
||||
- `R` - Revert to EEPROM value
|
||||
*/
|
||||
case 914:
|
||||
{
|
||||
tmc2130_mode = TMC2130_MODE_NORMAL;
|
||||
update_mode_profile();
|
||||
tmc2130_init(TMCInitParams(false, FarmOrUserECool()));
|
||||
}
|
||||
break;
|
||||
|
||||
/*!
|
||||
### M915 - Set TMC2130 silent mode <a href="https://reprap.org/wiki/G-code#M915:_Set_TMC2130_silent_mode">M915: Set TMC2130 silent mode</a>
|
||||
Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code.
|
||||
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
|
||||
#### Usage
|
||||
|
||||
M915 [ P | R ]
|
||||
|
||||
#### Parameters
|
||||
- `P` - Make the mode change permanent (write to EEPROM)
|
||||
- `R` - Revert to EEPROM value
|
||||
*/
|
||||
#ifdef TMC2130
|
||||
case 914:
|
||||
case 915:
|
||||
{
|
||||
tmc2130_mode = TMC2130_MODE_SILENT;
|
||||
update_mode_profile();
|
||||
tmc2130_init(TMCInitParams(false, FarmOrUserECool()));
|
||||
uint8_t newMode = (mcode_in_progress==914) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT;
|
||||
//printf_P(_n("tmc2130mode/smm/eep: %d %d %d %d"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT), bEnableForce_z);
|
||||
if (code_seen('R'))
|
||||
{
|
||||
newMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
||||
}
|
||||
else if (code_seen('P'))
|
||||
{
|
||||
uint8_t newMenuMode = (mcode_in_progress==914) ? SILENT_MODE_NORMAL : SILENT_MODE_STEALTH;
|
||||
eeprom_update_byte((unsigned char *)EEPROM_SILENT, newMenuMode);
|
||||
SilentModeMenu = newMenuMode;
|
||||
//printf_P(_n("tmc2130mode/smm/eep: %d %d %d %d"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT), bEnableForce_z);
|
||||
}
|
||||
|
||||
if (tmc2130_mode != newMode
|
||||
#ifdef PSU_Delta
|
||||
|| !bEnableForce_z
|
||||
#endif
|
||||
)
|
||||
{
|
||||
#ifdef PSU_Delta
|
||||
enable_force_z();
|
||||
#endif
|
||||
change_power_mode_live(newMode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#endif // TMC2130
|
||||
#ifdef TMC2130_SERVICE_CODES_M910_M918
|
||||
/*!
|
||||
### M916 - Set TMC2130 Stallguard sensitivity threshold <a href="https://reprap.org/wiki/G-code#M916:_Set_TMC2130_Stallguard_sensitivity_threshold">M916: Set TMC2130 Stallguard sensitivity threshold</a>
|
||||
Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code.
|
||||
|
|
|
|||
|
|
@ -953,7 +953,12 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
|
|||
bool high_deviation_occured = false;
|
||||
bedPWMDisabled = 1;
|
||||
#ifdef TMC2130
|
||||
FORCE_HIGH_POWER_START;
|
||||
bool bHighPowerForced = false;
|
||||
if (tmc2130_mode == TMC2130_MODE_SILENT)
|
||||
{
|
||||
FORCE_HIGH_POWER_START;
|
||||
bHighPowerForced = true;
|
||||
}
|
||||
#endif
|
||||
//printf_P(PSTR("Min. Z: %f\n"), minimum_z);
|
||||
#ifdef SUPPORT_VERBOSITY
|
||||
|
|
@ -1047,7 +1052,7 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
|
|||
enable_z_endstop(endstop_z_enabled);
|
||||
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 3");
|
||||
#ifdef TMC2130
|
||||
FORCE_HIGH_POWER_END;
|
||||
if (bHighPowerForced) FORCE_HIGH_POWER_END;
|
||||
#endif
|
||||
bedPWMDisabled = 0;
|
||||
return true;
|
||||
|
|
@ -1057,7 +1062,7 @@ error:
|
|||
enable_endstops(endstops_enabled);
|
||||
enable_z_endstop(endstop_z_enabled);
|
||||
#ifdef TMC2130
|
||||
FORCE_HIGH_POWER_END;
|
||||
if (bHighPowerForced) FORCE_HIGH_POWER_END;
|
||||
#endif
|
||||
bedPWMDisabled = 0;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -4091,15 +4091,31 @@ static void SETTINGS_SILENT_MODE()
|
|||
if (!farm_mode)
|
||||
{ // dont show in menu if we are in farm mode
|
||||
#ifdef TMC2130
|
||||
if (eeprom_read_byte((uint8_t *)EEPROM_SILENT) == SILENT_MODE_NORMAL)
|
||||
uint8_t eeprom_mode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
||||
bool bDesync = tmc2130_mode ^ eeprom_mode;
|
||||
if (eeprom_mode == SILENT_MODE_NORMAL)
|
||||
{
|
||||
if (bDesync)
|
||||
{
|
||||
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), PSTR("M915"), lcd_silent_mode_set);
|
||||
}
|
||||
else
|
||||
{
|
||||
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_NORMAL), lcd_silent_mode_set);
|
||||
MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), lcd_crash_detect_enabled() ? _T(MSG_ON) : _T(MSG_OFF), crash_mode_switch);
|
||||
}
|
||||
MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), lcd_crash_detect_enabled() ? _T(MSG_ON) : _T(MSG_OFF), crash_mode_switch);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bDesync)
|
||||
{
|
||||
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), PSTR("M914") , lcd_silent_mode_set);
|
||||
}
|
||||
else
|
||||
{
|
||||
MENU_ITEM_TOGGLE_P(_T(MSG_MODE), _T(MSG_STEALTH), lcd_silent_mode_set);
|
||||
MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), NULL, lcd_crash_mode_info);
|
||||
}
|
||||
MENU_ITEM_TOGGLE_P(_T(MSG_CRASHDETECT), NULL, lcd_crash_mode_info);
|
||||
}
|
||||
#else // TMC2130
|
||||
switch (eeprom_read_byte((uint8_t *)EEPROM_SILENT))
|
||||
|
|
|
|||
Loading…
Reference in New Issue