mmu2_fsensor.cpp 813 B

123456789101112131415161718192021222324252627
  1. #include "mmu2_fsensor.h"
  2. #include "Filament_sensor.h"
  3. namespace MMU2 {
  4. FilamentState WhereIsFilament(){
  5. return fsensor.getFilamentPresent() ? FilamentState::AT_FSENSOR : FilamentState::NOT_PRESENT;
  6. }
  7. BlockRunoutRAII::BlockRunoutRAII() {
  8. #ifdef FILAMENT_SENSOR
  9. fsensor.setRunoutEnabled(false); //suppress filament runouts while loading filament.
  10. fsensor.setAutoLoadEnabled(false); //suppress filament autoloads while loading filament.
  11. #if (FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
  12. fsensor.setJamDetectionEnabled(false); //suppress filament jam detection while loading filament.
  13. #endif //(FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125)
  14. #endif
  15. }
  16. BlockRunoutRAII::~BlockRunoutRAII() {
  17. #ifdef FILAMENT_SENSOR
  18. fsensor.settings_init(); // restore filament runout state.
  19. #endif
  20. }
  21. } // namespace MMU2