From c3585bc6965d584a8a22d69ab8b1dfb4f655b350 Mon Sep 17 00:00:00 2001 From: michalprusa Date: Tue, 26 Sep 2017 14:14:17 +0100 Subject: [PATCH] Automatic recovery typo fix Failures statistics in eeprom --- Firmware/Configuration.h | 14 ++++++++---- Firmware/Marlin_main.cpp | 26 ++++++++++++++++++++-- Firmware/ultralcd.cpp | 48 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index f7ec8ebd..34c2c647 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -60,10 +60,16 @@ #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) +// 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) +// Crash detection counter +#define EEPROM_CRASH_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-15) +// Filament runout/error coutner +#define EEPROM_FERROR_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-16) +// Power loss errors +#define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17) // 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/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 68ba76ca..55cccf7b 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -712,6 +712,12 @@ void fsensor_update() { MYSERIAL.println("fsensor_update - ERROR!!!"); fsensor_stop_and_save_print(); + + // Increment filament failure counter + uint8_t ferror_count = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT); + ferror_count++; + eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, ferror_count); + enquecommand_front_P((PSTR("M600"))); fsensor_M600 = true; fsensor_enabled = false; @@ -5829,7 +5835,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp break; case 10: // D10 - Tell the printer that XYZ calibration went OK calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST); - break; + break; + + case 12: //D12 - Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print ) + eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, 0x00); + eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00); + eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00); case 999: { MYSERIAL.println("D999 - crash"); @@ -5844,6 +5855,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp lcd_update_enable(true); lcd_implementation_clear(); lcd_update(2); + + // Increment crash counter + uint8_t crash_count = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT); + crash_count++; + eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, crash_count); + #ifdef AUTOMATIC_RECOVERY_AFTER_CRASH bool yesno = true; #else @@ -7071,7 +7088,12 @@ void uvlo_() st_synchronize(); #endif disable_z(); - + + // Increment power failure counter + uint8_t power_count = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); + power_count++; + eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, power_count); + SERIAL_ECHOLNPGM("UVLO - end"); cli(); while(1); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 46eb4f82..6ad7f66b 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -189,6 +189,8 @@ static void prusa_stat_temperatures(); static void prusa_stat_printinfo(); static void lcd_farm_no(); static void lcd_menu_extruder_info(); +static void lcd_menu_fails_stats(); + #ifdef DOGLCD static void lcd_set_contrast(); #endif @@ -961,6 +963,47 @@ static void lcd_menu_extruder_info() } } +static void lcd_menu_fails_stats() +{ + + // Display screen info + + lcd.setCursor(0, 0); + lcd.print("Failure stats "); + + // Display power failures + uint8_t power_count = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT); + lcd.setCursor(0, 1); + lcd.print(" Power failures: "); + lcd.setCursor(17, 1); + lcd.print(itostr3((int)power_count)); + + + // Display Crash detected + uint8_t crash_count = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT); + lcd.setCursor(0, 2); + lcd.print(" Crash detected: "); + lcd.setCursor(17, 2); + lcd.print(itostr3((int)crash_count)); + + + // Display filament failures + uint8_t ferror_count = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT); + lcd.setCursor(0, 3); + lcd.print(" Filament fails: "); + lcd.setCursor(17, 3); + lcd.print(itostr3((int)ferror_count)); + + + + if (lcd_clicked()) + { + lcd_quick_feedback(); + lcd_return_to_status(); + } + +} + static void lcd_menu_temperatures() { lcd.setCursor(1, 1); @@ -1066,6 +1109,9 @@ static void lcd_support_menu() MENU_ITEM(function, PSTR("XYZ cal. details"), lcd_service_mode_show_result); } MENU_ITEM(submenu, MSG_INFO_EXTRUDER, lcd_menu_extruder_info); + + MENU_ITEM(submenu, PSTR("Fail stats"), lcd_menu_fails_stats); + MENU_ITEM(submenu, PSTR("Temperatures"), lcd_menu_temperatures); if (fans_check_enabled == true) { MENU_ITEM(function, PSTR("Check fans [EN]"), lcd_set_fan_check); @@ -1077,7 +1123,7 @@ static void lcd_support_menu() #ifdef AUTOMATIC_RECOVERY_AFTER_CRASH MENU_ITEM(back, PSTR("Auto recover crash"), lcd_main_menu); -#else +#endif END_MENU(); }