Merge pull request #2123 from mkbel/fix_disable_crash_detection

Fix disable crash detection
This commit is contained in:
DRracer 2019-08-21 15:48:52 +02:00 committed by GitHub
commit 7a38a985d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 44 deletions

View File

@ -524,24 +524,6 @@ bool fans_check_enabled = true;
#ifdef TMC2130 #ifdef TMC2130
extern int8_t CrashDetectMenu;
void crashdet_enable()
{
tmc2130_sg_stop_on_crash = true;
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0xFF);
CrashDetectMenu = 1;
}
void crashdet_disable()
{
tmc2130_sg_stop_on_crash = false;
tmc2130_sg_crash = 0;
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00);
CrashDetectMenu = 0;
}
void crashdet_stop_and_save_print() void crashdet_stop_and_save_print()
{ {
stop_and_save_print_to_ram(10, -default_retraction); //XY - no change, Z 10mm up, E -1mm retract stop_and_save_print_to_ram(10, -default_retraction); //XY - no change, Z 10mm up, E -1mm retract
@ -631,7 +613,7 @@ void crashdet_detected(uint8_t mask)
void crashdet_recover() void crashdet_recover()
{ {
crashdet_restore_print_and_continue(); crashdet_restore_print_and_continue();
tmc2130_sg_stop_on_crash = true; if (lcd_crash_detect_enabled()) tmc2130_sg_stop_on_crash = true;
} }
void crashdet_cancel() void crashdet_cancel()
@ -1262,15 +1244,15 @@ void setup()
uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT); uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT);
if (silentMode == 0xff) silentMode = 0; if (silentMode == 0xff) silentMode = 0;
tmc2130_mode = TMC2130_MODE_NORMAL; tmc2130_mode = TMC2130_MODE_NORMAL;
uint8_t crashdet = eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET);
if (crashdet && !farm_mode) if (lcd_crash_detect_enabled() && !farm_mode)
{ {
crashdet_enable(); lcd_crash_detect_enable();
puts_P(_N("CrashDetect ENABLED!")); puts_P(_N("CrashDetect ENABLED!"));
} }
else else
{ {
crashdet_disable(); lcd_crash_detect_disable();
puts_P(_N("CrashDetect DISABLED")); puts_P(_N("CrashDetect DISABLED"));
} }

View File

@ -58,17 +58,9 @@ uint8_t SilentModeMenu_MMU = 1; //activate mmu unit stealth mode
int8_t FSensorStateMenu = 1; int8_t FSensorStateMenu = 1;
int8_t CrashDetectMenu = 1;
extern bool fsensor_enable(); extern bool fsensor_enable();
extern void fsensor_disable(); extern void fsensor_disable();
#ifdef TMC2130
extern void crashdet_enable();
extern void crashdet_disable();
#endif //TMC2130
#ifdef SDCARD_SORT_ALPHA #ifdef SDCARD_SORT_ALPHA
bool presort_flag = false; bool presort_flag = false;
@ -4448,24 +4440,25 @@ static void lcd_silent_mode_set() {
#endif //TMC2130 #endif //TMC2130
st_current_init(); st_current_init();
#ifdef TMC2130 #ifdef TMC2130
if (CrashDetectMenu && (SilentModeMenu != SILENT_MODE_NORMAL)) if (lcd_crash_detect_enabled() && (SilentModeMenu != SILENT_MODE_NORMAL))
menu_submenu(lcd_crash_mode_info2); menu_submenu(lcd_crash_mode_info2);
lcd_encoder_diff=0; // reset 'encoder buffer' lcd_encoder_diff=0; // reset 'encoder buffer'
#endif //TMC2130 #endif //TMC2130
} }
#ifdef TMC2130 #ifdef TMC2130
static void lcd_crash_mode_set() static void crash_mode_switch()
{ {
CrashDetectMenu = !CrashDetectMenu; //set also from crashdet_enable() and crashdet_disable() if (lcd_crash_detect_enabled())
if (CrashDetectMenu==0) { {
crashdet_disable(); lcd_crash_detect_disable();
}else{ }
crashdet_enable(); else
{
lcd_crash_detect_enable();
} }
if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) menu_goto(lcd_tune_menu, 9, true, true); if (IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) menu_goto(lcd_tune_menu, 9, true, true);
else menu_goto(lcd_settings_menu, 9, true, true); else menu_goto(lcd_settings_menu, 9, true, true);
} }
#endif //TMC2130 #endif //TMC2130
@ -5179,11 +5172,11 @@ do\
else MENU_ITEM_FUNCTION_P(_T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);\ else MENU_ITEM_FUNCTION_P(_T(MSG_STEALTH_MODE_ON), lcd_silent_mode_set);\
if (SilentModeMenu == SILENT_MODE_NORMAL)\ if (SilentModeMenu == SILENT_MODE_NORMAL)\
{\ {\
if (CrashDetectMenu == 0)\ if (lcd_crash_detect_enabled())\
{\ {\
MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), lcd_crash_mode_set);\ MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), crash_mode_switch);\
}\ }\
else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), lcd_crash_mode_set);\ else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), crash_mode_switch);\
}\ }\
else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info);\ else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info);\
}\ }\
@ -6903,8 +6896,8 @@ static void lcd_tune_menu()
if (SilentModeMenu == SILENT_MODE_NORMAL) if (SilentModeMenu == SILENT_MODE_NORMAL)
{ {
if (CrashDetectMenu == 0) MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), lcd_crash_mode_set); if (lcd_crash_detect_enabled()) MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), crash_mode_switch);
else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_ON), lcd_crash_mode_set); else MENU_ITEM_FUNCTION_P(_T(MSG_CRASHDETECT_OFF), crash_mode_switch);
} }
else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info); else MENU_ITEM_SUBMENU_P(_T(MSG_CRASHDETECT_NA), lcd_crash_mode_info);
} }
@ -8645,3 +8638,27 @@ void menu_lcd_lcdupdate_func(void)
lcd_send_status(); lcd_send_status();
if (lcd_commands_type == LcdCommands::Layer1Cal) lcd_commands(); 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

View File

@ -53,6 +53,11 @@ void lcd_menu_statistics();
void lcd_menu_extruder_info(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") 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()") 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
extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines); extern const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines);
extern const char* lcd_display_message_fullscreen_P(const char *msg); extern const char* lcd_display_message_fullscreen_P(const char *msg);