Repository navigation
Expand file tree
/
Copy pathBrewpi.cpp
More file actions
152 lines (123 loc) · 4.04 KB
/
Copy pathBrewpi.cpp
File metadata and controls
152 lines (123 loc) · 4.04 KB
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
/*
* Copyright 2012-2013 BrewPi/Elco Jacobs.
*
* This file is part of BrewPi.
*
* BrewPi 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.
*
* BrewPi 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 BrewPi. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This Atmel Studio 6 project automatically includes all needed Arduino source files, you just have to point it to the right directories.
* To compile this project on your computer, you will have to set an environment variable to find your local Arduino installation.
* Set the variable ARDUINO_HOME to point to your local Arduino path, without trailing slash, e.g. 'D:\arduino-1.01'. Instructions on the wiki here:
* http://wiki.brewpi.com/index.php/Setting_up_the_brewpi-avr_Project
* 'ArduinoFunctions.cpp' includes all the source files from Arduino that are used. You might have to edit it if you are not using a Leonardo.
* That is all that is needed! No hassle with makefiles and compiling libraries.
*/
#include "Brewpi.h"
#include "Ticks.h"
#include "Display.h"
#include "TempControl.h"
#include "PiLink.h"
#include "Menu.h"
#include "Pins.h"
#include "RotaryEncoder.h"
#include "Buzzer.h"
#include "TempSensor.h"
#include "TempSensorMock.h"
#include "TempSensorExternal.h"
#include "Ticks.h"
#include "Sensor.h"
#include "SettingsManager.h"
#include "EepromFormat.h"
#if BREWPI_SIMULATE
#include "Simulator.h"
#endif
// global class objects static and defined in class cpp and h files
// instantiate and configure the sensors, actuators and controllers we want to use
//void loop (void);
/* Configure the counter and delay timer. The actual type of these will vary depending upon the environment.
* They are non-virtual to keep code size minimal, so typedefs and preprocessing are used to select the actual compile-time type used. */
/*TicksImpl ticks = TicksImpl(TICKS_IMPL_CONFIG);
DelayImpl wait = DelayImpl(DELAY_IMPL_CONFIG);
DisplayType realDisplay;
DisplayType DISPLAY_REF display = realDisplay;
ValueActuator alarmActuator;*/
/*
void setup()
{
#if defined(ESP8266)
// We need to initialize the EEPROM on ESP8266
EEPROM.begin(MAX_EEPROM_SIZE_LIMIT);
#endif
#if BREWPI_BUZZER
buzzer.init();
buzzer.beep(2, 500);
#endif
piLink.init();
logDebug("started");
tempControl.init();
settingsManager.loadSettings();
#if BREWPI_SIMULATE
simulator.step();
// initialize the filters with the assigned initial temp value
tempControl.beerSensor->init();
tempControl.fridgeSensor->init();
#endif
display.init();
display.printStationaryText();
display.printState();
rotaryEncoder.init();
logDebug("init complete");
}
void brewpiLoop(void)
{
static unsigned long lastUpdate = 0;
uint8_t oldState;
if(ticks.millis() - lastUpdate >= (1000)) { //update settings every second
lastUpdate = ticks.millis();
#if BREWPI_BUZZER
buzzer.setActive(alarmActuator.isActive() && !buzzer.isActive());
#endif
tempControl.updateTemperatures();
tempControl.detectPeaks();
tempControl.updatePID();
oldState = tempControl.getState();
tempControl.updateState();
if(oldState != tempControl.getState()){
piLink.printTemperatures(); // add a data point at every state transition
}
tempControl.updateOutputs();
#if BREWPI_MENU
if(rotaryEncoder.pushed()){
rotaryEncoder.resetPushed();
menu.pickSettingToChange();
}
#endif
// update the lcd for the chamber being displayed
display.printState();
display.printAllTemperatures();
display.printMode();
display.updateBacklight();
}
//listen for incoming serial connections while waiting to update
piLink.receive();
}
void loop() {
#if BREWPI_SIMULATE
simulateLoop();
#else
brewpiLoop();
#endif
}
*/