Merge pull request #4207 from gudnimg/crashdet_cancel-fixup

`crashdet_cancel()` doesnt cleanup all variables when USB printing
This commit is contained in:
3d-gussner 2023-12-01 17:41:33 +01:00 committed by GitHub
commit 4dfc484265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 60 deletions

View File

@ -632,19 +632,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;
crashdet_use_eeprom_setting();
}
void crashdet_cancel()
{
saved_printing = false;
tmc2130_sg_stop_on_crash = true;
if (saved_printing_type == PowerPanic::PRINT_TYPE_SD) {
/// Crash detection cancels the print
void crashdet_cancel() {
// Restore crash detection
crashdet_use_eeprom_setting();
// Abort the print
print_stop();
}else if(saved_printing_type == PowerPanic::PRINT_TYPE_USB){
SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); //for Octoprint: works the same as clicking "Abort" button in Octoprint GUI
cmdqueue_reset();
}
}
#endif //TMC2130
@ -1276,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();
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
{
lcd_crash_detect_disable();
} else {
puts_P(_N("CrashDetect DISABLED"));
}
@ -9715,10 +9709,6 @@ void UnconditionalStop()
cmdqueue_reset();
cmdqueue_serial_disabled = false;
// Reset the sd status
card.sdprinting = false;
card.closefile();
st_reset_timer();
CRITICAL_SECTION_END;
}

View File

@ -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()
{

View File

@ -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)

View File

@ -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
{
@ -5655,7 +5655,11 @@ void print_stop(bool interactive)
// called by the main loop one iteration later.
UnconditionalStop();
if (!card.sdprinting) {
if (card.sdprinting) {
// Reset the sd status
card.sdprinting = false;
card.closefile();
} else {
SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_CANCEL); // for Octoprint
}
@ -6209,7 +6213,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) {
@ -7353,30 +7357,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

View File

@ -75,12 +75,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,