save some ram by not making public data returns static data
[clinton/Smoothieware.git] / src / modules / tools / temperaturecontrol / TemperatureControl.h
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 #ifndef temperaturecontrol_h
9 #define temperaturecontrol_h
10
11 #include "Module.h"
12 #include "Pwm.h"
13 #include "TempSensor.h"
14 #include "TemperatureControlPublicAccess.h"
15
16 class TemperatureControl : public Module {
17
18 public:
19 TemperatureControl(uint16_t name, int index);
20 ~TemperatureControl();
21
22 void on_module_loaded();
23 void on_main_loop(void* argument);
24 void on_gcode_execute(void* argument);
25 void on_gcode_received(void* argument);
26 void on_config_reload(void* argument);
27 void on_second_tick(void* argument);
28 void on_get_public_data(void* argument);
29 void on_set_public_data(void* argument);
30
31 void set_desired_temperature(float desired_temperature);
32
33 float get_temperature();
34
35 friend class PID_Autotuner;
36
37 private:
38 uint32_t thermistor_read_tick(uint32_t dummy);
39 void pid_process(float);
40
41 int pool_index;
42
43 float target_temperature;
44
45 float preset1;
46 float preset2;
47
48 TempSensor *sensor;
49
50 // PID runtime
51 float i_max;
52
53 int o;
54
55 float last_reading;
56
57 float readings_per_second;
58
59 uint16_t name_checksum;
60
61 Pwm heater_pin;
62
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 };
70
71 uint16_t set_m_code;
72 uint16_t set_and_wait_m_code;
73 uint16_t get_m_code;
74 struct pad_temperature public_data_return;
75
76 string designator;
77
78 void setPIDp(float p);
79 void setPIDi(float i);
80 void setPIDd(float d);
81
82 float hysteresis;
83 float iTerm;
84 float lastInput;
85 // PID settings
86 float p_factor;
87 float i_factor;
88 float d_factor;
89 float PIDdt;
90 };
91
92 #endif