My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

controllerfan.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. #include "../inc/MarlinConfigPre.h"
  24. typedef struct {
  25. uint8_t active_speed, // 0-255 (fullspeed); Speed with enabled stepper motors
  26. idle_speed; // 0-255 (fullspeed); Speed after idle period with all motors are disabled
  27. uint16_t duration; // Duration in seconds for the fan to run after all motors are disabled
  28. bool auto_mode; // Default true
  29. } controllerFan_settings_t;
  30. #ifndef CONTROLLERFAN_SPEED_ACTIVE
  31. #define CONTROLLERFAN_SPEED_ACTIVE 255
  32. #endif
  33. #ifndef CONTROLLERFAN_SPEED_IDLE
  34. #define CONTROLLERFAN_SPEED_IDLE 0
  35. #endif
  36. #ifndef CONTROLLERFAN_IDLE_TIME
  37. #define CONTROLLERFAN_IDLE_TIME 60
  38. #endif
  39. static constexpr controllerFan_settings_t controllerFan_defaults = {
  40. CONTROLLERFAN_SPEED_ACTIVE,
  41. CONTROLLERFAN_SPEED_IDLE,
  42. CONTROLLERFAN_IDLE_TIME,
  43. true
  44. };
  45. #if ENABLED(USE_CONTROLLER_FAN)
  46. class ControllerFan {
  47. private:
  48. static uint8_t speed;
  49. static void set_fan_speed(const uint8_t s);
  50. public:
  51. #if ENABLED(CONTROLLER_FAN_EDITABLE)
  52. static controllerFan_settings_t settings;
  53. #else
  54. static const controllerFan_settings_t constexpr &settings = controllerFan_defaults;
  55. #endif
  56. static inline bool state() { return speed > 0; }
  57. static inline void init() { reset(); }
  58. static inline void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); }
  59. static void setup();
  60. static void update();
  61. };
  62. extern ControllerFan controllerFan;
  63. #endif