diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 81d30c39..f7ec8ebd 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -60,6 +60,10 @@ #define EEPROM_UVLO_MESH_BED_LEVELING (EEPROM_FAN_CHECK_ENABLED - 9*2) #define EEPROM_UVLO_Z_MICROSTEPS (EEPROM_UVLO_MESH_BED_LEVELING - 2) +// Crash detection mode EEPROM setting +#define EEPROM_CRASH_DET (EEPROM_UVLO_MESH_BED_LEVELING-12) +// Filament sensor on/off EEPROM setting +#define EEPROM_FSENSOR (EEPROM_UVLO_MESH_BED_LEVELING-14) // Currently running firmware, each digit stored as uint16_t. // The flavor differentiates a dev, alpha, beta, release candidate or a release version. diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index 36b1cd35..36de0d47 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -79,6 +79,9 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o //DEBUG #define DEBUG_DCODES //D codes #if 1 +//#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD +//#define DEBUG_RESUME_PRINT //Resume/save print debug enable +//#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output //#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored //#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored //#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored @@ -88,7 +91,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define DEBUG_DISABLE_STARTMSGS //no startup messages //#define DEBUG_DISABLE_MINTEMP //mintemp error ignored //#define DEBUG_DISABLE_SWLIMITS //sw limits ignored -#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line +//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line //#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed #define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages //#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index fbf913f6..9f2b8dc9 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -371,6 +371,7 @@ void serialecho_temperatures(); void uvlo_(); void recover_print(); +void recover_print(uint8_t automatic); void setup_uvlo_interrupt(); extern void recover_machine_state_after_power_panic(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4b849416..63d98e79 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -567,15 +567,24 @@ static void lcd_language_menu(); void stop_and_save_print_to_ram(float z_move, float e_move); void restore_print_from_ram_and_continue(float e_move); +extern int8_t CrashDetectMenu; + void crashdet_enable() { + MYSERIAL.println("crashdet_enable"); tmc2130_sg_stop_on_crash = true; + eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0xFF); + CrashDetectMenu = 1; + } void crashdet_disable() { + MYSERIAL.println("crashdet_disable"); tmc2130_sg_stop_on_crash = false; + eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00); + CrashDetectMenu = 0; } void crashdet_stop_and_save_print() @@ -586,7 +595,7 @@ void crashdet_stop_and_save_print() void crashdet_restore_print_and_continue() { restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change - babystep_apply(); +// babystep_apply(); } @@ -630,6 +639,9 @@ uint8_t fsensor_err_cnt = 0; //#define FSENS_MAXERR 2 //filament sensor max error count #define FSENS_MAXERR 5 //filament sensor max error count +extern int8_t FSensorStateMenu; + + void fsensor_enable() { MYSERIAL.println("fsensor_enable"); @@ -639,12 +651,16 @@ void fsensor_enable() fsensor_enabled = true; fsensor_ignore_error = true; fsensor_M600 = false; + eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0xFF); + FSensorStateMenu = 1; } void fsensor_disable() { MYSERIAL.println("fsensor_disable"); fsensor_enabled = false; + eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, 0x00); + FSensorStateMenu = 0; } void fsensor_update() @@ -882,11 +898,36 @@ void setup() #ifdef TMC2130 uint8_t silentMode = eeprom_read_byte((uint8_t*)EEPROM_SILENT); tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL; + uint8_t crashdet = eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET); + if (crashdet) + { + crashdet_enable(); + MYSERIAL.println("CrashDetect ENABLED!"); + } + else + { + crashdet_disable(); + MYSERIAL.println("CrashDetect DISABLED"); + } + #endif //TMC2130 #ifdef PAT9125 MYSERIAL.print("PAT9125_init:"); MYSERIAL.println(pat9125_init(200, 200)); + + uint8_t fsensor = eeprom_read_byte((uint8_t*)EEPROM_FSENSOR); + if (fsensor) + { + fsensor_enable(); + MYSERIAL.println("Filament Sensor ENABLED!"); + } + else + { + fsensor_disable(); + MYSERIAL.println("Filament Sensor DISABLED"); + } + #endif //PAT9125 st_init(); // Initialize stepper, this enables interrupts! diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index f320c952..e80b141b 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -453,6 +453,7 @@ void tmc2130_check_overtemp() checktime = millis(); tmc2130_sg_change = true; } +#ifdef DEBUG_CRASHDET_COUNTERS if (tmc2130_sg_change) { for (int i = 0; i < 4; i++) @@ -463,6 +464,7 @@ void tmc2130_check_overtemp() lcd.print(' '); } } +#endif DEBUG_CRASHDET_COUNTERS } void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_t current_r) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index dc798cef..b2c628b5 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2544,12 +2544,12 @@ static void lcd_silent_mode_set() { static void lcd_crash_mode_set() { - if (!CrashDetectMenu==0) { + CrashDetectMenu = !CrashDetectMenu; //set also from crashdet_enable() and crashdet_disable() + if (CrashDetectMenu==0) { crashdet_disable(); }else{ crashdet_enable(); } - CrashDetectMenu = !CrashDetectMenu; lcd_goto_menu(lcd_settings_menu, 7); } @@ -2566,12 +2566,12 @@ static void lcd_set_lang(unsigned char lang) { static void lcd_fsensor_state_set() { - if (!FSensorStateMenu==0) { + FSensorStateMenu = !FSensorStateMenu; //set also from fsensor_enable() and fsensor_disable() + if (FSensorStateMenu==0) { fsensor_disable(); }else{ fsensor_enable(); } - FSensorStateMenu = !FSensorStateMenu; lcd_goto_menu(lcd_settings_menu, 7); } @@ -4078,11 +4078,26 @@ static void lcd_tune_menu() MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_colorprint_change);//7 #endif - if (SilentModeMenu == 0) { - MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set_tune); + if (FSensorStateMenu == 0) { + MENU_ITEM(function, MSG_FSENSOR_OFF, lcd_fsensor_state_set); } else { - MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set_tune); + MENU_ITEM(function, MSG_FSENSOR_ON, lcd_fsensor_state_set); } + + if (SilentModeMenu == 0) { + MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); + } else { + MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set); + } + + if (SilentModeMenu == 0) { + if (CrashDetectMenu == 0) { + MENU_ITEM(function, MSG_CRASHDETECT_OFF, lcd_crash_mode_set); + } else { + MENU_ITEM(function, MSG_CRASHDETECT_ON, lcd_crash_mode_set); + } + } + END_MENU(); }