Cleanup, share more M914/5/FORCE code
This commit is contained in:
parent
7214584723
commit
13f7ba81ff
|
|
@ -453,6 +453,7 @@ extern int8_t busy_state;
|
||||||
#define FORCE_HIGH_POWER_END force_high_power_mode(false)
|
#define FORCE_HIGH_POWER_END force_high_power_mode(false)
|
||||||
|
|
||||||
void force_high_power_mode(bool start_high_power_section);
|
void force_high_power_mode(bool start_high_power_section);
|
||||||
|
void change_power_mode_live(uint8_t mode);
|
||||||
|
|
||||||
#endif //TMC2130
|
#endif //TMC2130
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2416,25 +2416,30 @@ void retract(bool retracting, bool swapretract = false) {
|
||||||
|
|
||||||
|
|
||||||
#ifdef TMC2130
|
#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();
|
st_synchronize();
|
||||||
cli();
|
cli();
|
||||||
tmc2130_mode = (start_high_power_section == true) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT;
|
tmc2130_mode = mode;
|
||||||
update_mode_profile();
|
update_mode_profile();
|
||||||
tmc2130_init(TMCInitParams(FarmOrUserECool()));
|
tmc2130_init(TMCInitParams(FarmOrUserECool()));
|
||||||
// We may have missed a stepper timer interrupt due to the time spent in the tmc2130_init() routine.
|
// 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.
|
// Be safe than sorry, reset the stepper timer before re-enabling interrupts.
|
||||||
st_reset_timer();
|
st_reset_timer();
|
||||||
sei();
|
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
|
#endif //TMC2130
|
||||||
|
|
@ -8235,58 +8240,52 @@ Sigma_Exit:
|
||||||
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
|
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
|
||||||
#### Usage
|
#### Usage
|
||||||
|
|
||||||
M914 [P]
|
M914 [ P | R ]
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
- `P` - Make the mode change permanent (write to EEPROM)
|
- `P` - Make the mode change permanent (write to EEPROM)
|
||||||
|
- `R` - Revert to EEPROM value
|
||||||
*/
|
*/
|
||||||
#ifdef TMC2130
|
|
||||||
case 914:
|
|
||||||
{
|
|
||||||
if (code_seen('P'))
|
|
||||||
{
|
|
||||||
eeprom_update_byte((unsigned char *)EEPROM_SILENT, SILENT_MODE_NORMAL);
|
|
||||||
SilentModeMenu = SILENT_MODE_NORMAL;
|
|
||||||
}
|
|
||||||
//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 != TMC2130_MODE_NORMAL)
|
|
||||||
{
|
|
||||||
tmc2130_mode = TMC2130_MODE_NORMAL;
|
|
||||||
update_mode_profile();
|
|
||||||
tmc2130_init(TMCInitParams(false, FarmOrUserECool()));
|
|
||||||
//printf_P(_n("tmc2130mode/smm/eep: %d %d %d\n"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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>
|
### M915 - Set TMC2130 silent mode <a href="https://reprap.org/wiki/G-code#M915:_Set_TMC2130_silent_mode">M915: Set TMC2130 silent mode</a>
|
||||||
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
|
Updates EEPROM only if "P" is given, otherwise temporary (lasts until reset or motor idle timeout)
|
||||||
#### Usage
|
#### Usage
|
||||||
|
|
||||||
M915 [P]
|
M915 [ P | R ]
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
- `P` - Make the mode change permanent (write to EEPROM)
|
- `P` - Make the mode change permanent (write to EEPROM)
|
||||||
|
- `R` - Revert to EEPROM value
|
||||||
*/
|
*/
|
||||||
|
#ifdef TMC2130
|
||||||
|
case 914:
|
||||||
case 915:
|
case 915:
|
||||||
{
|
{
|
||||||
if (code_seen('P'))
|
uint8_t newMode = (mcode_in_progress==914) ? TMC2130_MODE_NORMAL : TMC2130_MODE_SILENT;
|
||||||
{
|
|
||||||
eeprom_update_byte((unsigned char *)EEPROM_SILENT, SILENT_MODE_STEALTH);
|
|
||||||
SilentModeMenu = SILENT_MODE_STEALTH;
|
|
||||||
}
|
|
||||||
//printf_P(_n("tmc2130mode/smm/eep: %d %d %d %d"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT), bEnableForce_z);
|
//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 != TMC2130_MODE_SILENT)
|
if (code_seen('R'))
|
||||||
{ // This is basically the equivalent of force_high_power_mode for silent mode.
|
{
|
||||||
st_synchronize();
|
newMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
|
||||||
cli();
|
}
|
||||||
tmc2130_mode = TMC2130_MODE_SILENT;
|
else if (code_seen('P'))
|
||||||
update_mode_profile();
|
{
|
||||||
tmc2130_init(TMCInitParams(false, FarmOrUserECool()));
|
uint8_t newMenuMode = (mcode_in_progress==914) ? SILENT_MODE_NORMAL : SILENT_MODE_STEALTH;
|
||||||
//printf_P(_n("tmc2130mode/smm/eep: %d %d %d\n"),tmc2130_mode,SilentModeMenu,eeprom_read_byte((uint8_t*)EEPROM_SILENT));
|
eeprom_update_byte((unsigned char *)EEPROM_SILENT, newMenuMode);
|
||||||
st_reset_timer();
|
SilentModeMenu = newMenuMode;
|
||||||
sei();
|
//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;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -953,7 +953,12 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
|
||||||
bool high_deviation_occured = false;
|
bool high_deviation_occured = false;
|
||||||
bedPWMDisabled = 1;
|
bedPWMDisabled = 1;
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
FORCE_HIGH_POWER_START;
|
bool bHighPowerForced = false;
|
||||||
|
if (tmc2130_mode == TMC2130_MODE_SILENT)
|
||||||
|
{
|
||||||
|
FORCE_HIGH_POWER_START;
|
||||||
|
bHighPowerForced = true;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
//printf_P(PSTR("Min. Z: %f\n"), minimum_z);
|
//printf_P(PSTR("Min. Z: %f\n"), minimum_z);
|
||||||
#ifdef SUPPORT_VERBOSITY
|
#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);
|
enable_z_endstop(endstop_z_enabled);
|
||||||
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 3");
|
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 3");
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
FORCE_HIGH_POWER_END;
|
if (bHighPowerForced) FORCE_HIGH_POWER_END;
|
||||||
#endif
|
#endif
|
||||||
bedPWMDisabled = 0;
|
bedPWMDisabled = 0;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1057,7 +1062,7 @@ error:
|
||||||
enable_endstops(endstops_enabled);
|
enable_endstops(endstops_enabled);
|
||||||
enable_z_endstop(endstop_z_enabled);
|
enable_z_endstop(endstop_z_enabled);
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
FORCE_HIGH_POWER_END;
|
if (bHighPowerForced) FORCE_HIGH_POWER_END;
|
||||||
#endif
|
#endif
|
||||||
bedPWMDisabled = 0;
|
bedPWMDisabled = 0;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue