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/>.
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.
13 Author: Michael Hackney, mhackney@eclecticangler.com
16 #ifndef TEMPERATURESWITCH_MODULE_H
17 #define TEMPERATURESWITCH_MODULE_H
21 #include "libs/Module.h"
25 class TemperatureSwitch
: public Module
29 void on_module_loaded();
30 void on_second_tick(void *argument
);
31 void on_gcode_received(void *argument
);
34 enum TRIGGER_TYPE
{LEVEL
, RISING
, FALLING
};
35 enum STATE
{NONE
, HIGH_TEMP
, LOW_TEMP
};
37 bool load_config(uint16_t modcs
);
39 // get the highest temperature from the set of configured temperature controllers
40 float get_highest_temperature();
42 // turn the switch on or off
43 void set_switch(bool cooler_state
);
45 // temperature has changed state
46 void set_state(STATE state
);
48 // the set of temperature controllers that match the required designator prefix
49 vector
<uint16_t> temp_controllers
;
51 // temperatureswitch.hotend.threshold_temp
52 float temperatureswitch_threshold_temp
;
54 // temperatureswitch.hotend.switch
55 uint16_t temperatureswitch_switch_cs
;
57 // check temps on heatup every X seconds
58 // this can be set in config: temperatureswitch.hotend.heatup_poll
59 uint16_t temperatureswitch_heatup_poll
;
61 // check temps on cooldown every X seconds
62 // this can be set in config: temperatureswitch.hotend.cooldown_poll
63 uint16_t temperatureswitch_cooldown_poll
;
65 // our internal second counter
66 uint16_t second_counter
;
68 // we are delaying for this many seconds
69 uint16_t current_delay
;
71 // the mcode that will arm the switch, 0 means always armed
77 TRIGGER_TYPE trigger
:2;
78 STATE current_state
:2;