add statistics and idler sensor state

This commit is contained in:
PavelSindler 2018-12-13 00:12:00 +01:00
parent 665f1d7ffe
commit a9829b6a1a
3 changed files with 68 additions and 16 deletions

View File

@ -688,6 +688,12 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0);
eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0);
eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0);
lcd_menu_statistics();
break;
@ -714,6 +720,11 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0);
eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0);
eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0);
#ifdef FILAMENT_SENSOR
fsensor_enable();
fsensor_autoload_set(true);
@ -1388,6 +1399,12 @@ void setup()
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0);
#ifdef SNMM
if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM
int _z = BOWDEN_LENGTH;

View File

@ -459,6 +459,8 @@ void manage_response(bool move_axes, bool turn_off_nozzle, uint8_t move)
{
response = mmu_get_response(move); //wait for "ok" from mmu
if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit
eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) + 1);
eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) + 1);
if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater
if (lcd_update_enabled) {
lcd_update_was_enabled = true;
@ -1231,6 +1233,8 @@ void mmu_continue_loading()
manage_response(true, true, MMU_LOAD_MOVE);
}
if (PIN_GET(MMU_IDLER_SENSOR_PIN) != 0) {
eeprom_update_byte((uint8_t*)EEPROM_MMU_FAIL, eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) + 1);
eeprom_update_word((uint16_t*)EEPROM_MMU_FAIL_TOT, eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) + 1);
char cmd[3];
//pause print, show error message and then repeat last T-code
stop_and_save_print_to_ram(0, 0);

View File

@ -38,7 +38,7 @@
#include "mmu.h"
#include "static_assert.h"
#include "io_atmega2560.h"
extern bool fans_check_enabled;
@ -1955,7 +1955,7 @@ static void lcd_menu_fails_stats_print()
lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Last print failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY);
menu_back_if_clicked_fb();
}
/*
static void lcd_menu_fails_stats_mmu_print()
{
//01234567890123456789
@ -1965,33 +1965,30 @@ static void lcd_menu_fails_stats_mmu_print()
// Crash X 000 Y 000
//////////////////////
lcd_timeoutToStatus.stop(); //infinite timeout
uint8_t power = eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT);
uint8_t filam = eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT);
uint8_t crashX = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X);
uint8_t crashY = eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y);
uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL);
uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL);
// lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY);
lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Last print failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY);
lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Last print failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails);
menu_back_if_clicked_fb();
}
static void lcd_menu_fails_stats_mmu_total()
{
//01234567890123456789
//Total failures
//Last print failures
// Power failures 000
// Filam. runouts 000
// Crash X 000 Y 000
//////////////////////
lcd_timeoutToStatus.stop(); //infinite timeout
uint16_t power = eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT);
uint16_t filam = eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT);
uint16_t crashX = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT);
uint16_t crashY = eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT);
// lcd_printf_P(PSTR(ESC_H(0,0) "Total failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY);
lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3) "%S X %-3d Y %-3d"), _i("Total failures"), _i("Power failures"), power, _i("Filam. runouts"), filam, _i("Crash"), crashX, crashY);
uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL_TOT);
uint16_t load_fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL_TOT);
// lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Power failures %-3d" ESC_H(1,2) "Filam. runouts %-3d" ESC_H(1,3) "Crash X %-3d Y %-3d"), power, filam, crashX, crashY);
lcd_printf_P(PSTR(ESC_H(0,0) "%S" ESC_H(1,1) "%S %-3d" ESC_H(1,2) "%S %-3d" ESC_H(1,3)), _i("Total failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails);
menu_back_if_clicked_fb();
}
*/
/**
* @brief Open fail statistics menu
*
@ -2007,6 +2004,16 @@ static void lcd_menu_fails_stats()
MENU_ITEM_SUBMENU_P(_i("Total"), lcd_menu_fails_stats_total);
MENU_END();
}
static void lcd_menu_fails_stats_mmu()
{
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_MAIN));
MENU_ITEM_SUBMENU_P(_i("Last print"), lcd_menu_fails_stats_mmu_print);
MENU_ITEM_SUBMENU_P(_i("Total"), lcd_menu_fails_stats_mmu_total);
MENU_END();
}
#elif defined(FILAMENT_SENSOR)
/**
* @brief Print last print and total filament run outs
@ -3634,6 +3641,27 @@ if(LCD_CLICKED)
}
#endif // defined TMC2130
#ifdef TMC2130
static void lcd_show_idler_state()
{
lcd_set_cursor(0, 0);
lcd_puts_P((PSTR("Idler state")));
lcd_set_cursor(0, 2);
lcd_puts_P((PIN_GET(MMU_IDLER_SENSOR_PIN) == 0)?(PSTR("ON")):(PSTR("OFF"))); // !!! both strings must have same length (due to dynamic refreshing)
}
static void lcd_menu_show_idler_state()
{
lcd_timeoutToStatus.stop();
lcd_show_idler_state();
if(LCD_CLICKED)
{
lcd_timeoutToStatus.start();
menu_back();
}
}
#endif // defined TMC2130
void prusa_statistics(int _message, uint8_t _fil_nr) {
@ -5900,7 +5928,10 @@ static void lcd_main_menu()
#if defined(TMC2130) || defined(FILAMENT_SENSOR)
MENU_ITEM_SUBMENU_P(_i("Fail stats"), lcd_menu_fails_stats);
#endif
if (mmu_enabled) {
MENU_ITEM_SUBMENU_P(_i("Fail stats MMU"), lcd_menu_fails_stats_mmu);
MENU_ITEM_SUBMENU_P(_i("Show idler state"), lcd_menu_show_idler_state);
}
MENU_ITEM_SUBMENU_P(_i("Support"), lcd_support_menu);////MSG_SUPPORT c=0 r=0
#ifdef LCD_TEST
MENU_ITEM_SUBMENU_P(_i("W25x20CL init"), lcd_test_menu);////MSG_SUPPORT c=0 r=0