Refactor code which resets crash detection setting
Add function crashdet_use_eeprom_setting Change in memory: Flash: -52 bytes SRAM: 0 bytes
This commit is contained in:
parent
30d0da4698
commit
e1e0b0afa1
|
|
@ -631,12 +631,16 @@ void crashdet_detected(uint8_t mask)
|
|||
|
||||
void crashdet_recover()
|
||||
{
|
||||
if (!print_job_timer.isPaused()) crashdet_restore_print_and_continue();
|
||||
if (lcd_crash_detect_enabled()) tmc2130_sg_stop_on_crash = true;
|
||||
if (!print_job_timer.isPaused()) crashdet_restore_print_and_continue();
|
||||
crashdet_use_eeprom_setting();
|
||||
}
|
||||
|
||||
/// Crash detection cancels the print
|
||||
void crashdet_cancel() {
|
||||
// Restore crash detection
|
||||
crashdet_use_eeprom_setting();
|
||||
|
||||
// Abort the print
|
||||
print_stop();
|
||||
}
|
||||
|
||||
|
|
@ -1269,14 +1273,11 @@ void setup()
|
|||
if (silentMode == 0xff) silentMode = 0;
|
||||
tmc2130_mode = TMC2130_MODE_NORMAL;
|
||||
|
||||
if (lcd_crash_detect_enabled() && !farm_mode)
|
||||
{
|
||||
lcd_crash_detect_enable();
|
||||
puts_P(_N("CrashDetect ENABLED!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_crash_detect_disable();
|
||||
tmc2130_sg_stop_on_crash = eeprom_init_default_byte((uint8_t*)EEPROM_CRASH_DET, farm_mode ? false : true);
|
||||
|
||||
if (tmc2130_sg_stop_on_crash) {
|
||||
puts_P(_N("CrashDetect ENABLED!"));
|
||||
} else {
|
||||
puts_P(_N("CrashDetect DISABLED"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -390,6 +390,9 @@ void tmc2130_st_isr()
|
|||
}
|
||||
}
|
||||
|
||||
void crashdet_use_eeprom_setting() {
|
||||
tmc2130_sg_stop_on_crash = eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET);
|
||||
}
|
||||
|
||||
bool tmc2130_update_sg()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ extern void tmc2130_sg_measure_start(uint8_t axis);
|
|||
//stop current stallguard measuring and report result
|
||||
extern uint16_t tmc2130_sg_measure_stop();
|
||||
|
||||
// Enable or Disable crash detection according to EEPROM
|
||||
void crashdet_use_eeprom_setting();
|
||||
|
||||
extern void tmc2130_setup_chopper(uint8_t axis, uint8_t mres);
|
||||
|
||||
//set holding current for any axis (M911)
|
||||
|
|
|
|||
|
|
@ -3412,7 +3412,7 @@ static void lcd_silent_mode_set() {
|
|||
#endif //TMC2130
|
||||
|
||||
#ifdef TMC2130
|
||||
if (lcd_crash_detect_enabled() && (SilentModeMenu != SILENT_MODE_NORMAL))
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET) && (SilentModeMenu != SILENT_MODE_NORMAL))
|
||||
menu_submenu(lcd_crash_mode_info2);
|
||||
#endif //TMC2130
|
||||
}
|
||||
|
|
@ -3420,8 +3420,8 @@ static void lcd_silent_mode_set() {
|
|||
#ifdef TMC2130
|
||||
static void crash_mode_switch()
|
||||
{
|
||||
if (lcd_crash_detect_enabled()) lcd_crash_detect_disable();
|
||||
else lcd_crash_detect_enable();
|
||||
eeprom_toggle((uint8_t*)EEPROM_CRASH_DET);
|
||||
crashdet_use_eeprom_setting();
|
||||
}
|
||||
#endif //TMC2130
|
||||
|
||||
|
|
@ -4114,7 +4114,7 @@ static void SETTINGS_SILENT_MODE()
|
|||
{
|
||||
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), eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET) ? _T(MSG_ON) : _T(MSG_OFF), crash_mode_switch);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -6204,7 +6204,7 @@ static void reset_crash_det(uint8_t axis) {
|
|||
current_position[axis] += 10;
|
||||
plan_buffer_line_curposXYZE(manual_feedrate[0] / 60);
|
||||
st_synchronize();
|
||||
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET)) tmc2130_sg_stop_on_crash = true;
|
||||
crashdet_use_eeprom_setting();
|
||||
}
|
||||
|
||||
static bool lcd_selfcheck_axis_sg(uint8_t axis) {
|
||||
|
|
@ -7348,30 +7348,6 @@ void menu_lcd_lcdupdate_func(void)
|
|||
if (lcd_commands_type == LcdCommands::Layer1Cal) lcd_commands();
|
||||
}
|
||||
|
||||
#ifdef TMC2130
|
||||
//! @brief Is crash detection enabled?
|
||||
//!
|
||||
//! @retval true crash detection enabled
|
||||
//! @retval false crash detection disabled
|
||||
bool lcd_crash_detect_enabled()
|
||||
{
|
||||
return eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET);
|
||||
}
|
||||
|
||||
void lcd_crash_detect_enable()
|
||||
{
|
||||
tmc2130_sg_stop_on_crash = true;
|
||||
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0xFF);
|
||||
}
|
||||
|
||||
void lcd_crash_detect_disable()
|
||||
{
|
||||
tmc2130_sg_stop_on_crash = false;
|
||||
tmc2130_sg_crash = 0;
|
||||
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TMC2130
|
||||
void UserECool_toggle(){
|
||||
// this is only called when the experimental menu is visible, thus the first condition for enabling of the ECool mode is met in this place
|
||||
|
|
|
|||
|
|
@ -71,12 +71,6 @@ void lcd_status_screen(); // NOT static due to using ins
|
|||
void lcd_menu_extruder_info(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
|
||||
void lcd_menu_show_sensors_state(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
|
||||
|
||||
#ifdef TMC2130
|
||||
bool lcd_crash_detect_enabled();
|
||||
void lcd_crash_detect_enable();
|
||||
void lcd_crash_detect_disable();
|
||||
#endif
|
||||
|
||||
enum LCDButtonChoice : uint_fast8_t {
|
||||
LCD_LEFT_BUTTON_CHOICE = 0,
|
||||
LCD_MIDDLE_BUTTON_CHOICE = 1,
|
||||
|
|
|
|||
Loading…
Reference in New Issue