aboutsummaryrefslogtreecommitdiff
path: root/Marlin/src/feature/controllerfan.h
diff options
context:
space:
mode:
authorGeorgiy Bondarenko <69736697+nehilo@users.noreply.github.com>2021-03-04 20:54:23 +0300
committerGeorgiy Bondarenko <69736697+nehilo@users.noreply.github.com>2021-03-04 20:54:23 +0300
commite8701195e66f2d27ffe17fb514eae8173795aaf7 (patch)
tree9f519c4abf6556b9ae7190a6210d87ead1dfadde /Marlin/src/feature/controllerfan.h
downloadkp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.tar.xz
kp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.zip
Initial commit
Diffstat (limited to 'Marlin/src/feature/controllerfan.h')
-rw-r--r--Marlin/src/feature/controllerfan.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/Marlin/src/feature/controllerfan.h b/Marlin/src/feature/controllerfan.h
new file mode 100644
index 0000000..55f2d5c
--- /dev/null
+++ b/Marlin/src/feature/controllerfan.h
@@ -0,0 +1,72 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+#pragma once
+
+#include "../inc/MarlinConfigPre.h"
+
+typedef struct {
+ uint8_t active_speed, // 0-255 (fullspeed); Speed with enabled stepper motors
+ idle_speed; // 0-255 (fullspeed); Speed after idle period with all motors are disabled
+ uint16_t duration; // Duration in seconds for the fan to run after all motors are disabled
+ bool auto_mode; // Default true
+} controllerFan_settings_t;
+
+#ifndef CONTROLLERFAN_SPEED_ACTIVE
+ #define CONTROLLERFAN_SPEED_ACTIVE 255
+#endif
+#ifndef CONTROLLERFAN_SPEED_IDLE
+ #define CONTROLLERFAN_SPEED_IDLE 0
+#endif
+#ifndef CONTROLLERFAN_IDLE_TIME
+ #define CONTROLLERFAN_IDLE_TIME 60
+#endif
+
+static constexpr controllerFan_settings_t controllerFan_defaults = {
+ CONTROLLERFAN_SPEED_ACTIVE,
+ CONTROLLERFAN_SPEED_IDLE,
+ CONTROLLERFAN_IDLE_TIME,
+ true
+};
+
+#if ENABLED(USE_CONTROLLER_FAN)
+
+class ControllerFan {
+ private:
+ static uint8_t speed;
+ static void set_fan_speed(const uint8_t s);
+
+ public:
+ #if ENABLED(CONTROLLER_FAN_EDITABLE)
+ static controllerFan_settings_t settings;
+ #else
+ static const controllerFan_settings_t &settings;
+ #endif
+ static inline bool state() { return speed > 0; }
+ static inline void init() { reset(); }
+ static inline void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); }
+ static void setup();
+ static void update();
+};
+
+extern ControllerFan controllerFan;
+
+#endif