diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 82468241..1c41284c 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -57,6 +57,8 @@ int16_t mmu_buildnr = -1; uint32_t mmu_last_request = 0; uint32_t mmu_last_response = 0; +uint16_t mmu_power_failures = 0; + //clear rx buffer 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_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; } else if ((mmu_last_response + 300) < millis()) //request every 300ms @@ -348,6 +358,15 @@ void mmu_loop(void) mmu_state = 1; } 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 (mmu_idler_sensor_detected) { - current_position[E_AXIS] += 3f; + current_position[E_AXIS] += 3.0f; } else { - current_position[E_AXIS] + 7.2f; + current_position[E_AXIS] += 7.2f; } 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); diff --git a/Firmware/mmu.h b/Firmware/mmu.h index c3416cbc..a4b3d458 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -16,6 +16,8 @@ extern bool mmu_idler_sensor_detected; extern int16_t mmu_version; extern int16_t mmu_buildnr; +extern uint16_t mmu_power_failures; + #define MMU_FILAMENT_UNKNOWN 255 #define MMU_NO_MOVE 0 @@ -45,7 +47,7 @@ extern int16_t mmu_buildnr; #define MMU_CMD_E3 0x53 #define MMU_CMD_E4 0x54 #define MMU_CMD_R0 0x60 - +#define MMU_CMD_S3 0x73 extern int mmu_puts_P(const char* str); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 093ddb74..6501ca24 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1960,11 +1960,12 @@ static void lcd_menu_fails_stats_mmu_total() // MMU load fails 000 // ////////////////////// + mmu_command(MMU_CMD_S3); lcd_timeoutToStatus.stop(); //infinite timeout 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); + 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(); }