From 67fd467ebe6f1b6f56667c06ce55fb55e26fe99b Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 5 Mar 2018 21:42:04 +0100 Subject: [PATCH] Add fail statistics menu item for MK25. As there is only filament sensor and no crash and power interruption detection, squash everything into single screen. --- Firmware/Configuration_prusa.h | 2 +- Firmware/Marlin_main.cpp | 4 +-- Firmware/ultralcd.cpp | 46 +++++++++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index 46c75104..014c2f7f 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -168,7 +168,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed -#define PAT9125 +#define PAT9125 //!< Filament sensor #define FANCHECK diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index baa618fe..e71c9957 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -681,6 +681,7 @@ void crashdet_cancel() card.closefile(); tmc2130_sg_stop_on_crash = true; } +#endif //TMC2130 void failstats_reset_print() { @@ -690,7 +691,6 @@ void failstats_reset_print() eeprom_update_byte((uint8_t *)EEPROM_POWER_COUNT, 0); } -#endif //TMC2130 #ifdef MESH_BED_LEVELING @@ -4081,10 +4081,8 @@ void process_commands() card.openFile(strchr_pointer + 4,true); break; case 24: //M24 - Start SD print -#ifdef TMC2130 if (!card.paused) failstats_reset_print(); -#endif //TMC2130 card.startFileprint(); starttime=millis(); break; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index df8276f6..eb44ef36 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -204,9 +204,9 @@ static void prusa_stat_temperatures(); static void prusa_stat_printinfo(); static void lcd_farm_no(); static void lcd_menu_extruder_info(); -#ifdef TMC2130 +#if defined(TMC2130) || defined(PAT9125) static void lcd_menu_fails_stats(); -#endif //TMC2130 +#endif //TMC2130 or PAT9125 void lcd_finishstatus(); @@ -1537,7 +1537,7 @@ static void lcd_menu_extruder_info() } } -#ifdef TMC2130 +#if defined(TMC2130) && defined(PAT9125) static void lcd_menu_fails_stats_total() { //01234567890123456789 @@ -1579,7 +1579,13 @@ static void lcd_menu_fails_stats_print() lcd_goto_menu(lcd_menu_fails_stats, 2); } } - +/** + * @brief Open fail statistics menu + * + * This version of function is used, when there is filament sensor, + * power failure and crash detection. + * There are Last print and Total menu items. + */ static void lcd_menu_fails_stats() { START_MENU(); @@ -1588,6 +1594,34 @@ static void lcd_menu_fails_stats() MENU_ITEM(submenu, PSTR("Total"), lcd_menu_fails_stats_total); END_MENU(); } +#else if defined(PAT9125) +/** + * @brief Print last print and total filament run outs + * + * This version of function is used, when there is filament sensor, + * but no other sensors (e.g. power failure, crash detection). + * + * Example screen: + * @code + * 01234567890123456789 + * Last print failures + * Filam. runouts 0 + * Total failures + * Filam. runouts 5 + * @endcode + */ +static void lcd_menu_fails_stats() +{ + uint8_t filamentLast = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT); + uint16_t filamentTotal = eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT); + fprintf_P(lcdout, PSTR(ESC_H(0,0)"Last print failures"ESC_H(1,1)"Filam. runouts %-3d"ESC_H(0,2)"Total failures"ESC_H(1,3)"Filam. runouts %-3d"), filamentLast, filamentTotal); + if (lcd_clicked()) + { + lcd_quick_feedback(); + //lcd_return_to_status(); + lcd_goto_menu(lcd_main_menu, 8); //TODO: Remove hard coded encoder value. + } +} #endif //TMC2130 @@ -5221,9 +5255,9 @@ static void lcd_main_menu() MENU_ITEM(submenu, MSG_STATISTICS, lcd_menu_statistics); } -#ifdef TMC2130 +#if defined(TMC2130) || defined(PAT9125) MENU_ITEM(submenu, PSTR("Fail stats"), lcd_menu_fails_stats); -#endif //TMC2130 +#endif MENU_ITEM(submenu, MSG_SUPPORT, lcd_support_menu);