show power failures in fail stats menu, shorter load to nozzle if idler sensor detected

This commit is contained in:
PavelSindler 2018-12-21 20:56:45 +01:00
parent d292e877df
commit 5462d451e1
3 changed files with 26 additions and 4 deletions

View File

@ -57,6 +57,8 @@ int16_t mmu_buildnr = -1;
uint32_t mmu_last_request = 0; uint32_t mmu_last_request = 0;
uint32_t mmu_last_response = 0; uint32_t mmu_last_response = 0;
uint16_t mmu_power_failures = 0;
//clear rx buffer //clear rx buffer
void mmu_clr_rx_buf(void) void mmu_clr_rx_buf(void)
@ -283,6 +285,14 @@ void mmu_loop(void)
mmu_puts_P(PSTR("R0\n")); //send recover after eject mmu_puts_P(PSTR("R0\n")); //send recover after eject
mmu_state = 3; // wait for response mmu_state = 3; // wait for response
} }
else if (mmu_cmd == MMU_CMD_S3)
{
#ifdef MMU_DEBUG
printf_P(PSTR("MMU <= 'S3'\n"));
#endif //MMU_DEBUG
mmu_puts_P(PSTR("S3\n")); //send power failures request
mmu_state = 4; // power failures response
}
mmu_cmd = 0; mmu_cmd = 0;
} }
else if ((mmu_last_response + 300) < millis()) //request every 300ms else if ((mmu_last_response + 300) < millis()) //request every 300ms
@ -348,6 +358,15 @@ void mmu_loop(void)
mmu_state = 1; mmu_state = 1;
} }
return; return;
case 4:
if (mmu_rx_ok() > 0)
{
fscanf_P(uart2io, PSTR("%d"), &mmu_power_failures); //scan finda from buffer
}
else if ((mmu_last_request + MMU_CMD_TIMEOUT) < millis())
{ //resend request after timeout (5 min)
mmu_state = 1;
}
} }
} }
@ -610,11 +629,11 @@ void mmu_load_to_nozzle()
if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true; if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = true;
if (mmu_idler_sensor_detected) if (mmu_idler_sensor_detected)
{ {
current_position[E_AXIS] += 3f; current_position[E_AXIS] += 3.0f;
} }
else else
{ {
current_position[E_AXIS] + 7.2f; current_position[E_AXIS] += 7.2f;
} }
float feedrate = 562; float feedrate = 562;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate / 60, active_extruder);

View File

@ -16,6 +16,8 @@ extern bool mmu_idler_sensor_detected;
extern int16_t mmu_version; extern int16_t mmu_version;
extern int16_t mmu_buildnr; extern int16_t mmu_buildnr;
extern uint16_t mmu_power_failures;
#define MMU_FILAMENT_UNKNOWN 255 #define MMU_FILAMENT_UNKNOWN 255
#define MMU_NO_MOVE 0 #define MMU_NO_MOVE 0
@ -45,7 +47,7 @@ extern int16_t mmu_buildnr;
#define MMU_CMD_E3 0x53 #define MMU_CMD_E3 0x53
#define MMU_CMD_E4 0x54 #define MMU_CMD_E4 0x54
#define MMU_CMD_R0 0x60 #define MMU_CMD_R0 0x60
#define MMU_CMD_S3 0x73
extern int mmu_puts_P(const char* str); extern int mmu_puts_P(const char* str);

View File

@ -1960,11 +1960,12 @@ static void lcd_menu_fails_stats_mmu_total()
// MMU load fails 000 // MMU load fails 000
// //
////////////////////// //////////////////////
mmu_command(MMU_CMD_S3);
lcd_timeoutToStatus.stop(); //infinite timeout lcd_timeoutToStatus.stop(); //infinite timeout
uint8_t fails = eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL_TOT); 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); 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) "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); 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 %-3d"), _i("Total failures"), _i("MMU fails"), fails, _i("MMU load fails"), load_fails, _i("MMU power fails"), mmu_power_failures);
menu_back_if_clicked_fb(); menu_back_if_clicked_fb();
} }