Commit | Line | Data |
---|---|---|
abe97b79 | 1 | /* |
2 | This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). | |
3 | Smoothie 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. | |
4 | Smoothie 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. | |
5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. | |
6 | */ | |
7 | ||
8 | /* | |
9 | TemperatureSwitch is an optional module that will automatically turn on or off a switch | |
10 | based on a setpoint temperature. It is commonly used to turn on/off a cooling fan or water pump | |
11 | to cool the hot end's cold zone. Specifically, it turns one of the small MOSFETs on or off. | |
12 | ||
13 | Author: Michael Hackney, mhackney@eclecticangler.com | |
14 | */ | |
15 | ||
16 | #ifndef TEMPERATURESWITCH_MODULE_H | |
17 | #define TEMPERATURESWITCH_MODULE_H | |
18 | ||
19 | using namespace std; | |
20 | ||
21 | #include "libs/Module.h" | |
22 | #include <string> | |
23 | #include <vector> | |
24 | ||
abe97b79 | 25 | class TemperatureSwitch : public Module |
26 | { | |
27 | public: | |
28 | TemperatureSwitch(); | |
93ea6adb | 29 | ~TemperatureSwitch(); |
abe97b79 | 30 | void on_module_loaded(); |
abe97b79 | 31 | void on_second_tick(void *argument); |
81300c80 | 32 | void on_gcode_received(void *argument); |
93ea6adb JM |
33 | TemperatureSwitch* load_config(uint16_t modcs); |
34 | ||
35 | bool is_armed() const { return armed; } | |
57235957 | 36 | |
abe97b79 | 37 | private: |
cb32dae3 JM |
38 | enum TRIGGER_TYPE {LEVEL, RISING, FALLING}; |
39 | enum STATE {NONE, HIGH_TEMP, LOW_TEMP}; | |
40 | ||
604c4d0a JM |
41 | // get the highest temperature from the set of configured temperature controllers |
42 | float get_highest_temperature(); | |
43 | ||
abe97b79 | 44 | // turn the switch on or off |
45 | void set_switch(bool cooler_state); | |
604c4d0a | 46 | |
cb32dae3 JM |
47 | // temperature has changed state |
48 | void set_state(STATE state); | |
49 | ||
c0c375b0 | 50 | // the set of temperature controllers that match the required designator prefix |
5cbf2253 | 51 | vector<uint16_t> temp_controllers; |
57235957 | 52 | |
abe97b79 | 53 | // temperatureswitch.hotend.threshold_temp |
54 | float temperatureswitch_threshold_temp; | |
57235957 | 55 | |
fe3323e7 JM |
56 | // temperatureswitch.hotend.switch |
57 | uint16_t temperatureswitch_switch_cs; | |
57235957 | 58 | |
abe97b79 | 59 | // check temps on heatup every X seconds |
60 | // this can be set in config: temperatureswitch.hotend.heatup_poll | |
57235957 JM |
61 | uint16_t temperatureswitch_heatup_poll; |
62 | ||
abe97b79 | 63 | // check temps on cooldown every X seconds |
64 | // this can be set in config: temperatureswitch.hotend.cooldown_poll | |
57235957 JM |
65 | uint16_t temperatureswitch_cooldown_poll; |
66 | ||
abe97b79 | 67 | // our internal second counter |
57235957 JM |
68 | uint16_t second_counter; |
69 | ||
abe97b79 | 70 | // we are delaying for this many seconds |
57235957 JM |
71 | uint16_t current_delay; |
72 | ||
81300c80 JM |
73 | // the mcode that will arm the switch, 0 means always armed |
74 | uint16_t arm_mcode; | |
75 | ||
c0c375b0 | 76 | struct { |
c0c375b0 | 77 | bool inverted:1; |
81300c80 | 78 | bool armed:1; |
c0c375b0 | 79 | TRIGGER_TYPE trigger:2; |
cb32dae3 | 80 | STATE current_state:2; |
c0c375b0 | 81 | }; |
abe97b79 | 82 | }; |
83 | ||
84 | #endif |