SpoolJoin.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /// @file
  2. #pragma once
  3. #include <stdint.h>
  4. #include "eeprom.h"
  5. // See documentation here: https://help.prusa3d.com/article/spooljoin-mmu2s_134252
  6. namespace SpoolJoin {
  7. class SpoolJoin {
  8. public:
  9. SpoolJoin();
  10. enum class EEPROM : uint8_t {
  11. Unknown, ///< SpoolJoin is unknown while printer is booting up
  12. Enabled, ///< SpoolJoin is enabled in EEPROM
  13. Disabled, ///< SpoolJoin is disabled in EEPROM
  14. Empty = 0xFF ///< EEPROM has not been set before and all bits are 1 (0xFF) - either a new printer or user erased the memory
  15. };
  16. /// @brief Called when EEPROM is ready to be read
  17. void initSpoolJoinStatus();
  18. /// @brief Enable SpoolJoin
  19. inline void enableSpoolJoin() { updateSpoolJoinStatus(EEPROM::Enabled); };
  20. /// @brief Disable SpoolJoin
  21. inline void disableSpoolJoin() { updateSpoolJoinStatus(EEPROM::Disabled); };
  22. /// @brief Toggle SpoolJoin
  23. static void toggleSpoolJoin();
  24. /// @brief Check if SpoolJoin is enabled
  25. uint8_t isSpoolJoinEnabled();
  26. /// @brief Fetch the next slot number should count from 0 to 4.
  27. /// When filament slot 4 is depleted, the next slot should be 0.
  28. /// @returns the next slot, ranges from 0 to 4
  29. uint8_t nextSlot();
  30. private:
  31. /// @brief Update EEPROM
  32. /// @param newStatus Status to write into EEPROM
  33. void updateSpoolJoinStatus(EEPROM newStatus);
  34. /// @brief SpoolJoin status
  35. enum EEPROM status;
  36. /// @brief Currently used slot, ranges from 0 to 4
  37. uint8_t currentMMUSlot;
  38. };
  39. extern SpoolJoin spooljoin;
  40. } // namespace SpoolJoin