rename the temperature switch config entrythat specifies the switch to use, this...
[clinton/Smoothieware.git] / src / modules / tools / temperatureswitch / TemperatureSwitch.h
CommitLineData
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/*
9TemperatureSwitch is an optional module that will automatically turn on or off a switch
10based on a setpoint temperature. It is commonly used to turn on/off a cooling fan or water pump
11to cool the hot end's cold zone. Specifically, it turns one of the small MOSFETs on or off.
12
13Author: Michael Hackney, mhackney@eclecticangler.com
14*/
15
16#ifndef TEMPERATURESWITCH_MODULE_H
17#define TEMPERATURESWITCH_MODULE_H
18
19using namespace std;
20
21#include "libs/Module.h"
22#include <string>
23#include <vector>
24
abe97b79 25class TemperatureSwitch : public Module
26{
27 public:
28 TemperatureSwitch();
29 void on_module_loaded();
abe97b79 30 void on_second_tick(void *argument);
57235957 31
abe97b79 32 private:
5cbf2253
JM
33 bool load_config(uint16_t modcs);
34
abe97b79 35 // turn the switch on or off
36 void set_switch(bool cooler_state);
5cbf2253
JM
37 // the set of temperature controllers that match the reuired designator prefix
38 vector<uint16_t> temp_controllers;
57235957 39
abe97b79 40 // get the highest temperature from the set of configured temperature controllers
41 float get_highest_temperature();
57235957 42
abe97b79 43 // temperatureswitch.hotend.threshold_temp
44 float temperatureswitch_threshold_temp;
57235957 45
fe3323e7
JM
46 // temperatureswitch.hotend.switch
47 uint16_t temperatureswitch_switch_cs;
57235957 48
abe97b79 49 // check temps on heatup every X seconds
50 // this can be set in config: temperatureswitch.hotend.heatup_poll
57235957
JM
51 uint16_t temperatureswitch_heatup_poll;
52
abe97b79 53 // check temps on cooldown every X seconds
54 // this can be set in config: temperatureswitch.hotend.cooldown_poll
57235957
JM
55 uint16_t temperatureswitch_cooldown_poll;
56
abe97b79 57 // our internal second counter
57235957
JM
58 uint16_t second_counter;
59
abe97b79 60 // we are delaying for this many seconds
57235957
JM
61 uint16_t current_delay;
62
5cbf2253
JM
63 // is the switch currently on (1) or off (0)?
64 bool temperatureswitch_state;
abe97b79 65};
66
67#endif