forked from ScribbleJ/sjfw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Temperature.cpp
159 lines (134 loc) · 2.58 KB
/
Temperature.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "Temperature.h"
#include "Time.h"
void Temperature::doreport()
{
if(report_m == 0)
return;
unsigned long now = millis();
if(report_l + report_m < now)
{
report_l = now;
(*report_h).labelnum("T:",getHotend(),false);
(*report_h).labelnum(" B:",getPlatform());
}
}
#ifdef USE_MBIEC
Temperature::Temperature()
: EC(MBIEC::Instance())
{
report_m = 0;
report_l = 0;
report_h = 0;
fanon = false;
}
void Temperature::update()
{
EC.scan_input();
EC.update();
doreport();
}
bool Temperature::setHotend(uint16_t temp)
{
return EC.setHotend(temp);
}
bool Temperature::setPlatform(uint16_t temp)
{
return EC.setPlatform(temp);
}
uint16_t Temperature::getHotend()
{
return EC.getHotend();
}
uint16_t Temperature::getPlatform()
{
return EC.getPlatform();
}
uint16_t Temperature::getHotendST()
{
return EC.getHotendST();
}
uint16_t Temperature::getPlatformST()
{
return EC.getPlatformST();
}
#else
Temperature::Temperature()
: hotend_therm(HOTEND_TEMP_PIN, 0),
platform_therm(PLATFORM_TEMP_PIN, 1),
hotend_heat(HOTEND_HEAT_PIN),
platform_heat(PLATFORM_HEAT_PIN)
{
report_m = 0;
report_l = 0;
report_h = 0;
hotend_therm.init();
platform_therm.init();
hotend_heat.setDirection(true); hotend_heat.setValue(false);
platform_heat.setDirection(true); platform_heat.setValue(false);
}
#define MIN_TEMP_INTERVAL 20
void Temperature::update()
{
unsigned long now = millis();
static unsigned long lasttime = now;
if(now - lasttime > MIN_TEMP_INTERVAL)
{
static bool checkwhich=false;
if(checkwhich)
hotend_therm.update();
else
platform_therm.update();
lasttime = now;
checkwhich = !checkwhich;
}
if(!hotend_heat.isNull())
{
if(hotend_therm.getTemperature() >= hotend_setpoint)
{
hotend_heat.setValue(false);
}
else
{
hotend_heat.setValue(true);
}
}
if(!platform_heat.isNull())
{
if(platform_therm.getTemperature() >= platform_setpoint)
{
platform_heat.setValue(false);
}
else
{
platform_heat.setValue(true);
}
}
doreport();
}
bool Temperature::setHotend(uint16_t temp)
{
hotend_setpoint = temp;
return true;
}
bool Temperature::setPlatform(uint16_t temp)
{
platform_setpoint = temp;
return true;
}
uint16_t Temperature::getHotend()
{
return hotend_therm.getTemperature();
}
uint16_t Temperature::getPlatform()
{
return platform_therm.getTemperature();
}
uint16_t Temperature::getHotendST()
{
return hotend_setpoint;
}
uint16_t Temperature::getPlatformST()
{
return platform_setpoint;
}
#endif // USE_MBIEC