clean up the way events are handled and use std::function
[clinton/Smoothieware.git] / src / modules / tools / temperaturecontrol / TemperatureControl.h
CommitLineData
df27a6a3 1/*
3c132bd0
AW
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.
df27a6a3 5 you should have received a copy of the gnu general public license along with smoothie. if not, see <http://www.gnu.org/licenses/>.
cd011f58
AW
6*/
7
3c132bd0
AW
8#ifndef temperaturecontrol_h
9#define temperaturecontrol_h
ded56b35 10
aa4d694a 11#include "Module.h"
827a49ca 12#include "Pwm.h"
9d955060 13#include "TempSensor.h"
2fa50ca0 14#include "TemperatureControlPublicAccess.h"
e84c3be3 15
ded56b35 16class TemperatureControl : public Module {
47339e4a 17
b19aa09d 18 public:
8e8b938e 19 TemperatureControl(uint16_t name, int index);
d8baddd9 20 ~TemperatureControl();
907d5e8a 21
ded56b35 22 void on_module_loaded();
b6c86164 23 void on_main_loop(void* argument);
ded56b35 24 void on_gcode_execute(void* argument);
b0be67b5 25 void on_gcode_received(void* argument);
7dd8133c 26 void on_config_reload(void* argument);
8ccab7cf 27 void on_second_tick(void* argument);
b19aa09d 28 void on_get_public_data(void* argument);
77047e76 29 void on_set_public_data(void* argument);
8ccab7cf 30
1ad23cd3 31 void set_desired_temperature(float desired_temperature);
10e66797 32
8e8b938e
JM
33 float get_temperature();
34
10e66797
JM
35 friend class PID_Autotuner;
36
37 private:
d8baddd9 38 uint32_t thermistor_read_tick(uint32_t dummy);
1ad23cd3 39 void pid_process(float);
907d5e8a 40
8e8b938e
JM
41 int pool_index;
42
1ad23cd3 43 float target_temperature;
ded56b35 44
1ad23cd3
MM
45 float preset1;
46 float preset2;
f4bd4fc3 47
d8baddd9 48 TempSensor *sensor;
2fa50ca0 49
907d5e8a 50 // PID runtime
1ad23cd3 51 float i_max;
907d5e8a 52
907d5e8a
MM
53 int o;
54
1ad23cd3 55 float last_reading;
907d5e8a 56
1ad23cd3 57 float readings_per_second;
ded56b35 58
3c132bd0
AW
59 uint16_t name_checksum;
60
7dee00e4 61 Pwm heater_pin;
907d5e8a 62
86fa0b93
JM
63 struct {
64 bool use_bangbang:1;
65 bool waiting:1;
66 bool min_temp_violated:1;
67 bool link_to_tool:1;
68 bool active:1;
69 };
3c132bd0 70
1306ba99
AW
71 uint16_t set_m_code;
72 uint16_t set_and_wait_m_code;
73 uint16_t get_m_code;
2fa50ca0 74 struct pad_temperature public_data_return;
7b625dcc 75
e0d0ea84 76 std::string designator;
3c308aeb 77
1ad23cd3
MM
78 void setPIDp(float p);
79 void setPIDi(float i);
80 void setPIDd(float d);
201e6dcf 81
989d0e94 82 float hysteresis;
1ad23cd3
MM
83 float iTerm;
84 float lastInput;
201e6dcf 85 // PID settings
1ad23cd3
MM
86 float p_factor;
87 float i_factor;
88 float d_factor;
89 float PIDdt;
ded56b35
AW
90};
91
92#endif