mmu2_progress_converter.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "mmu2_progress_converter.h"
  2. #include "language.h"
  3. #include "mmu2/progress_codes.h"
  4. #include <avr/pgmspace.h>
  5. namespace MMU2 {
  6. //01234567890123456789
  7. static const char MSG_PROGRESS_OK[] PROGMEM_I1 = ISTR("OK"); ////MSG_PROGRESS_OK c=4
  8. static const char MSG_PROGRESS_ENGAGE_IDLER[] PROGMEM_I1 = ISTR("Engaging idler"); ////MSG_PROGRESS_ENGAGE_IDLER c=20
  9. static const char MSG_PROGRESS_DISENGAGE_IDLER[] PROGMEM_I1 = ISTR("Disengaging idler"); ////MSG_PROGRESS_DISENGAGE_IDLER c=20
  10. static const char MSG_PROGRESS_UNLOAD_FINDA[] PROGMEM_I1 = ISTR("Unloading to FINDA"); ////MSG_PROGRESS_UNLOAD_FINDA c=20
  11. static const char MSG_PROGRESS_UNLOAD_PULLEY[] PROGMEM_I1 = ISTR("Unloading to pulley"); ////MSG_PROGRESS_UNLOAD_PULLEY c=20
  12. static const char MSG_PROGRESS_FEED_FINDA[] PROGMEM_I1 = ISTR("Feeding to FINDA"); ////MSG_PROGRESS_FEED_FINDA c=20
  13. static const char MSG_PROGRESS_FEED_EXTRUDER[] PROGMEM_I1 = ISTR("Feeding to extruder"); ////MSG_PROGRESS_FEED_EXTRUDER c=20
  14. static const char MSG_PROGRESS_FEED_NOZZLE[] PROGMEM_I1 = ISTR("Feeding to nozzle"); ////MSG_PROGRESS_FEED_NOZZLE c=20
  15. static const char MSG_PROGRESS_AVOID_GRIND[] PROGMEM_I1 = ISTR("Avoiding grind"); ////MSG_PROGRESS_AVOID_GRIND c=20
  16. static const char MSG_PROGRESS_WAIT_USER[] PROGMEM_I1 = ISTR("ERR Wait for User"); ////MSG_PROGRESS_WAIT_USER c=20
  17. static const char MSG_PROGRESS_ERR_INTERNAL[] PROGMEM_I1 = ISTR("ERR Internal"); ////MSG_PROGRESS_ERR_INTERNAL c=20
  18. static const char MSG_PROGRESS_ERR_HELP_FIL[] PROGMEM_I1 = ISTR("ERR Help filament"); ////MSG_PROGRESS_ERR_HELP_FIL c=20
  19. static const char MSG_PROGRESS_ERR_TMC[] PROGMEM_I1 = ISTR("ERR TMC failed"); ////MSG_PROGRESS_ERR_TMC c=20
  20. static const char MSG_PROGRESS_SELECT_SLOT[] PROGMEM_I1 = ISTR("Selecting fil. slot"); ////MSG_PROGRESS_SELECT_SLOT c=20
  21. static const char MSG_PROGRESS_PREPARE_BLADE[] PROGMEM_I1 = ISTR("Preparing blade"); ////MSG_PROGRESS_PREPARE_BLADE c=20
  22. static const char MSG_PROGRESS_PUSH_FILAMENT[] PROGMEM_I1 = ISTR("Pushing filament"); ////MSG_PROGRESS_PUSH_FILAMENT c=20
  23. static const char MSG_PROGRESS_PERFORM_CUT[] PROGMEM_I1 = ISTR("Performing cut"); ////MSG_PROGRESS_PERFORM_CUT c=20
  24. static const char MSG_PROGRESS_RETURN_SELECTOR[] PROGMEM_I1 = ISTR("Returning selector"); ////MSG_PROGRESS_RETURN_SELECTOR c=20
  25. static const char MSG_PROGRESS_PARK_SELECTOR[] PROGMEM_I1 = ISTR("Parking selector"); ////MSG_PROGRESS_PARK_SELECTOR c=20
  26. static const char MSG_PROGRESS_EJECT_FILAMENT[] PROGMEM_I1 = ISTR("Ejecting filament"); ////MSG_PROGRESS_EJECT_FILAMENT c=20 //@@todo duplicate
  27. static const char MSG_PROGRESS_RETRACT_FINDA[] PROGMEM_I1 = ISTR("Retract from FINDA"); ////MSG_PROGRESS_RETRACT_FINDA c=20
  28. static const char MSG_PROGRESS_HOMING[] PROGMEM_I1 = ISTR("Homing"); ////MSG_PROGRESS_HOMING c=20
  29. static const char MSG_PROGRESS_MOVING_SELECTOR[] PROGMEM_I1 = ISTR("Moving selector"); ////MSG_PROGRESS_MOVING_SELECTOR c=20
  30. static const char MSG_PROGRESS_FEED_FSENSOR[] PROGMEM_I1 = ISTR("Feeding to FSensor"); ////MSG_PROGRESS_FEED_FSENSOR c=20
  31. static const char * const progressTexts[] PROGMEM = {
  32. _R(MSG_PROGRESS_OK),
  33. _R(MSG_PROGRESS_ENGAGE_IDLER),
  34. _R(MSG_PROGRESS_DISENGAGE_IDLER),
  35. _R(MSG_PROGRESS_UNLOAD_FINDA),
  36. _R(MSG_PROGRESS_UNLOAD_PULLEY),
  37. _R(MSG_PROGRESS_FEED_FINDA),
  38. _R(MSG_PROGRESS_FEED_EXTRUDER),
  39. _R(MSG_PROGRESS_FEED_NOZZLE),
  40. _R(MSG_PROGRESS_AVOID_GRIND),
  41. _R(MSG_FINISHING_MOVEMENTS), //reuse from messages.cpp
  42. _R(MSG_PROGRESS_DISENGAGE_IDLER), // err disengaging idler is the same text
  43. _R(MSG_PROGRESS_ENGAGE_IDLER), // engage dtto.
  44. _R(MSG_PROGRESS_WAIT_USER),
  45. _R(MSG_PROGRESS_ERR_INTERNAL),
  46. _R(MSG_PROGRESS_ERR_HELP_FIL),
  47. _R(MSG_PROGRESS_ERR_TMC),
  48. _R(MSG_UNLOADING_FILAMENT), //reuse from messages.cpp
  49. _R(MSG_LOADING_FILAMENT), //reuse from messages.cpp
  50. _R(MSG_PROGRESS_SELECT_SLOT),
  51. _R(MSG_PROGRESS_PREPARE_BLADE),
  52. _R(MSG_PROGRESS_PUSH_FILAMENT),
  53. _R(MSG_PROGRESS_PERFORM_CUT),
  54. _R(MSG_PROGRESS_RETURN_SELECTOR),
  55. _R(MSG_PROGRESS_PARK_SELECTOR),
  56. _R(MSG_PROGRESS_EJECT_FILAMENT),
  57. _R(MSG_PROGRESS_RETRACT_FINDA),
  58. _R(MSG_PROGRESS_HOMING),
  59. _R(MSG_PROGRESS_MOVING_SELECTOR),
  60. _R(MSG_PROGRESS_FEED_FSENSOR)
  61. };
  62. const char * const ProgressCodeToText(uint16_t pc){
  63. // @@TODO ?? a better fallback option?
  64. return ( pc <= (sizeof(progressTexts) / sizeof(progressTexts[0])) )
  65. ? static_cast<const char * const>(pgm_read_ptr(&progressTexts[pc]))
  66. : static_cast<const char * const>(pgm_read_ptr(&progressTexts[0]));
  67. }
  68. } // namespace MMU2