diff --git a/Firmware/mmu2_progress_converter.cpp b/Firmware/mmu2_progress_converter.cpp index c9d37e5e7..f82012f19 100644 --- a/Firmware/mmu2_progress_converter.cpp +++ b/Firmware/mmu2_progress_converter.cpp @@ -1,6 +1,72 @@ #include "mmu2_progress_converter.h" +#include "language.h" +#include "mmu2/progress_codes.h" +#include namespace MMU2 { -//@@TODO -void TranslateProgress(uint16_t pc, char *dst, size_t dstSize) { } + +static const char progressOk[] PROGMEM_I1 = ISTR("OK"); +static const char progressEngageIdler[] PROGMEM_I1 = ISTR("Engaging idler"); +static const char progressDisengeIdler[] PROGMEM_I1 = ISTR("Disengaging idler"); +static const char progressUnloadFinda[] PROGMEM_I1 = ISTR("Unloading to FINDA"); +static const char progressUnloadPulley[] PROGMEM_I1 = ISTR("Unloading to pulley"); +static const char progressFeedFinda[] PROGMEM_I1 = ISTR("Feeding to FINDA"); +static const char progressFeedBondtech[] PROGMEM_I1 = ISTR("Feeding to drive gear"); +static const char progressFeedNozzle[] PROGMEM_I1 = ISTR("Feeding to nozzle"); +static const char progressAvoidGrind[] PROGMEM_I1 = ISTR("Avoiding grind"); +static const char progressFinishMoves[] PROGMEM_I1 = ISTR("Finishing moves"); +static const char progressWaitForUser[] PROGMEM_I1 = ISTR("ERR Wait for User"); +static const char progressErrInternal[] PROGMEM_I1 = ISTR("ERR Internal"); +static const char progressErrHelpFil[] PROGMEM_I1 = ISTR("ERR Helping filament"); +static const char progressErrTmc[] PROGMEM_I1 = ISTR("ERR TMC failed"); +static const char progressUnloadFilament[] PROGMEM_I1 = ISTR("Unloading filament"); +static const char progressLoadFilament[] PROGMEM_I1 = ISTR("Loading filament"); +static const char progressSelectSlot[] PROGMEM_I1 = ISTR("Selecting filament slot"); +static const char progressPrepareBlade[] PROGMEM_I1 = ISTR("Preparing blade"); +static const char progressPushFilament[] PROGMEM_I1 = ISTR("Pushing filament"); +static const char progressPerformCut[] PROGMEM_I1 = ISTR("Performing cut"); +static const char progressReturnSelector[] PROGMEM_I1 = ISTR("Returning selector"); +static const char progressParkSelector[] PROGMEM_I1 = ISTR("Parking selector"); +static const char progressEjectFilament[] PROGMEM_I1 = ISTR("Ejecting filament"); +static const char progressRetractFinda[] PROGMEM_I1 = ISTR("Retracting from FINDA"); +static const char progressHoming[] PROGMEM_I1 = ISTR("Homing"); + +static const char * const progressTexts[] PROGMEM = { + progressOk, + progressEngageIdler, + progressDisengeIdler, + progressUnloadFinda, + progressUnloadPulley, + progressFeedFinda, + progressFeedBondtech, + progressFeedNozzle, + progressAvoidGrind, + progressFinishMoves, + progressDisengeIdler, // err disengaging idler is the same text + progressEngageIdler, // engage dtto. + progressWaitForUser, + progressErrInternal, + progressErrHelpFil, + progressErrTmc, + progressUnloadFilament, + progressLoadFilament, + progressSelectSlot, + progressPrepareBlade, + progressPushFilament, + progressPerformCut, + progressReturnSelector, + progressParkSelector, + progressEjectFilament, + progressRetractFinda, + progressHoming, +}; + +const char * const ProgressCodeToText(uint16_t pc){ + return ( pc <= 26 ) ? progressTexts[pc] : progressTexts[0]; // @@TODO ?? a better fallback option? +} + +void TranslateProgress(uint16_t pc, char *dst, size_t dstSize) { + strncpy_P(dst, ProgressCodeToText(pc), dstSize); // @@TODO temporarily to prevent removal of the texts at LTO +} + } // namespace MMU2 diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index 18549ac35..1bc638c25 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -1,21 +1,32 @@ #include "mmu2_reporting.h" - -// @@TODO implement the interface for MK3 +#include "ultralcd.h" namespace MMU2 { -void BeginReport(CommandInProgress cip, uint16_t ec) { } +const char * const ProgressCodeToText(uint16_t pc); // we may join progress convertor and reporter together -void EndReport(CommandInProgress cip, uint16_t ec) { } +void BeginReport(CommandInProgress cip, uint16_t ec) { + custom_message_type = CustomMsg::MMUProgress; + lcd_setstatuspgm( ProgressCodeToText(ec) ); +} -void ReportErrorHook(CommandInProgress cip, uint16_t ec) { } +void EndReport(CommandInProgress cip, uint16_t ec) { + // clear the status msg line - let the printed filename get visible again + custom_message_type = CustomMsg::Status; +} -void ReportProgressHook(CommandInProgress cip, uint16_t ec) { } +void ReportErrorHook(CommandInProgress cip, uint16_t ec) { + // @@TODO - display an error screen - we still don't know how that will look like + // The only thing we know is the fact, that the screen must not block the MMU automaton +} -Buttons ButtonPressed(uint16_t ec) { } +void ReportProgressHook(CommandInProgress cip, uint16_t ec) { + custom_message_type = CustomMsg::MMUProgress; + lcd_setstatuspgm( ProgressCodeToText(ec) ); +} -bool MMUAvailable() { } - -bool UseMMU() { } +Buttons ButtonPressed(uint16_t ec) { + // query the MMU error screen if a button has been pressed/selected +} } // namespace MMU2 diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0e38e11f8..4f5a4c46a 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -548,8 +548,7 @@ void lcdui_print_time(void) } //! @Brief Print status line on status screen -void lcdui_print_status_line(void) -{ +void lcdui_print_status_line(void) { if (heating_status != HeatingStatus::NO_HEATING) { // If heating flag, show progress of heating heating_status_counter++; if (heating_status_counter > 13) { @@ -614,24 +613,23 @@ void lcdui_print_status_line(void) case CustomMsg::Status: // Nothing special, print status message normally case CustomMsg::M0Wait: // M0/M1 Wait command working even from SD lcd_print(lcd_status_message); - break; + break; case CustomMsg::MeshBedLeveling: // If mesh bed leveling in progress, show the status if (custom_message_state > 10) { lcd_set_cursor(0, 3); lcd_space(LCD_WIDTH); lcd_puts_at_P(0, 3, _T(MSG_CALIBRATE_Z_AUTO)); lcd_puts_P(PSTR(" : ")); - lcd_print(custom_message_state-10); + lcd_print(custom_message_state - 10); } else { - if (custom_message_state == 3) - { + if (custom_message_state == 3) { lcd_setstatuspgm(MSG_WELCOME); custom_message_type = CustomMsg::Status; } - if (custom_message_state > 3 && custom_message_state <= 10 ) { + if (custom_message_state > 3 && custom_message_state <= 10) { lcd_set_cursor(0, 3); lcd_space(19); - lcd_puts_at_P(0, 3, _i("Calibration done"));////MSG_HOMEYZ_DONE c=20 + lcd_puts_at_P(0, 3, _i("Calibration done")); ////MSG_HOMEYZ_DONE c=20 custom_message_state--; } } @@ -652,23 +650,26 @@ void lcdui_print_status_line(void) lcd_set_cursor(0, 3); lcd_printf_P(PSTR("%-12.12S%-d/6"), _T(MSG_PINDA_CALIBRATION), custom_message_state); break; - case CustomMsg::TempCompPreheat: // temp compensation preheat - lcd_puts_at_P(0, 3, _i("PINDA Heating"));////MSG_PINDA_PREHEAT c=20 + case CustomMsg::TempCompPreheat: // temp compensation preheat + lcd_puts_at_P(0, 3, _i("PINDA Heating")); ////MSG_PINDA_PREHEAT c=20 if (custom_message_state <= PINDA_HEAT_T) { lcd_puts_P(PSTR(": ")); - lcd_print(custom_message_state); //seconds + lcd_print(custom_message_state); // seconds lcd_print(' '); } break; - case CustomMsg::Resuming: //Resuming + case CustomMsg::Resuming: // Resuming lcd_puts_at_P(0, 3, _T(MSG_RESUMING_PRINT)); break; + case CustomMsg::MMUProgress: + // set up at mmu2_reporting.cpp, just do nothing here + break; } } // Fill the rest of line to have nice and clean output - for(uint8_t fillspace = 0; fillspace < LCD_WIDTH; fillspace++) - if ((lcd_status_message[fillspace] <= 31 )) + for (uint8_t fillspace = 0; fillspace < LCD_WIDTH; fillspace++) + if ((lcd_status_message[fillspace] <= 31)) lcd_print(' '); } diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 8e6f6e485..101109de8 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -122,7 +122,8 @@ enum class CustomMsg : uint_least8_t TempCompPreheat, //!< Temperature compensation preheat M0Wait, //!< M0/M1 Wait command working even from SD M117, //!< M117 Set the status line message on the LCD - Resuming, //!< Resuming message + Resuming, //!< Resuming message + MMUProgress, ///< MMU progress message }; extern CustomMsg custom_message_type;