forked from OSCSYS/brewtroller
-
Notifications
You must be signed in to change notification settings - Fork 4
/
BrewCore.pde
124 lines (101 loc) · 2.83 KB
/
BrewCore.pde
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
/*
Copyright (C) 2009, 2010 Matt Reba, Jeremiah Dillingham
This file is part of BrewTroller.
BrewTroller 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.
BrewTroller 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.
You should have received a copy of the GNU General Public License
along with BrewTroller. If not, see <http://www.gnu.org/licenses/>.
BrewTroller - Open Source Brewing Computer
Software Lead: Matt Reba (matt_AT_brewtroller_DOT_com)
Hardware Lead: Jeremiah Dillingham (jeremiah_AT_brewtroller_DOT_com)
Documentation, Forums and more information available at http://www.brewtroller.com
*/
byte scheduler;
enum schedulerTasks {
SCHEDULETASK_TIMERS,
#ifndef NOUI
SCHEDULETASK_LCD,
#endif
SCHEDULETASK_TEMPS,
SCHEDULETASK_BUZZER,
SCHEDULETASK_VOLS,
#ifdef FLOWRATE_CALCS
SCHEDULETASK_FLOWRATES,
#endif
SCHEDULETASK_PROGRAMS,
SCHEDULETASK_COMS,
#ifdef PVOUT
SCHEDULETASK_OUTPUTPROFILES,
#endif
SCHEDULETASK_COUNT
};
void brewCore() {
//START HIGH PRIORITY: Time-sensitive updates perfromed on each iteration
#ifdef HEARTBEAT
heartbeat();
#endif
processHeatOutputs();
//END HIGH PRIORITY
//START NORMAL PRIORITY: Updated in turn
switch (scheduler) {
#ifndef NOUI
case SCHEDULETASK_LCD:
LCD.update();
break;
#endif
case SCHEDULETASK_TIMERS:
//Timers: Timer.pde
updateTimers();
break;
case SCHEDULETASK_TEMPS:
//temps: Temp.pde
updateTemps();
break;
case SCHEDULETASK_BUZZER:
//Alarm update allows to have a beeping alarm
updateBuzzer();
break;
case SCHEDULETASK_VOLS:
//Volumes: Volume.pde
updateVols();
break;
#ifdef FLOWRATE_CALCS
case SCHEDULETASK_FLOWRATES:
updateFlowRates();
break;
#endif
case SCHEDULETASK_PROGRAMS:
//Step Logic: StepLogic.pde
stepCore();
break;
case SCHEDULETASK_COMS:
//Communications: Com.pde
updateCom();
break;
#ifdef PVOUT
case SCHEDULETASK_OUTPUTPROFILES:
//Auto Valve Logic: Outputs.pde
processAutoValve();
//Set Valve Outputs based on active valve profiles (if changed): Outputs.pde
updateValves();
break;
#endif
}
if(++scheduler >= SCHEDULETASK_COUNT)
scheduler = 0;
}
#ifdef HEARTBEAT
unsigned long hbStart = 0;
void heartbeat() {
if (millis() - hbStart > 750) {
hbPin.toggle();
hbStart = millis();
}
}
#endif