summaryrefslogtreecommitdiffstats
path: root/src/tempmodule/indicator.c
diff options
context:
space:
mode:
authorGravatar Gediminas Jakutis <gediminas@varciai.lt> 2018-04-27 13:53:54 +0300
committerGravatar Gediminas Jakutis <gediminas@varciai.lt> 2018-04-27 13:53:54 +0300
commitd5ac1ee5534710e105b699d2069b6b6f9b6869d3 (patch)
treec4b660b9a64edea7a8e8b37c26c97fe49d0ba866 /src/tempmodule/indicator.c
parentefb5d035b11f97f1d83302147e5f691f81439a3a (diff)
downloadcoffeetemp-d5ac1ee5534710e105b699d2069b6b6f9b6869d3.tar.gz
coffeetemp-d5ac1ee5534710e105b699d2069b6b6f9b6869d3.tar.bz2
coffeetemp-d5ac1ee5534710e105b699d2069b6b6f9b6869d3.zip
tempmodule: report error state by turning on all temperatre LEDs.
Diffstat (limited to 'src/tempmodule/indicator.c')
-rw-r--r--src/tempmodule/indicator.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/tempmodule/indicator.c b/src/tempmodule/indicator.c
index 4c1b958..2968958 100644
--- a/src/tempmodule/indicator.c
+++ b/src/tempmodule/indicator.c
@@ -28,8 +28,8 @@ struct indicator {
unsigned int red;
unsigned int green;
unsigned int blue;
- unsigned int current_temp;
- unsigned int calibration[4];
+ int current_temp;
+ int calibration[4];
};
static struct indicator state;
@@ -39,9 +39,9 @@ static const unsigned int blueled = 14; /* D5 */
static void indicator_set_state(unsigned int red, unsigned int green, unsigned int blue);
-void indicator_init(unsigned int temp, unsigned int const * const calibration)
+void indicator_init(int temp, unsigned int const * const calibration)
{
- static const unsigned int default_calibration[] = {3430, 3330, 3230, 3130};
+ static const int default_calibration[] = {3430, 3330, 3230, 3130};
pinMode(redled, OUTPUT);
pinMode(greenled, OUTPUT);
@@ -57,14 +57,16 @@ void indicator_init(unsigned int temp, unsigned int const * const calibration)
}
-void indicator_update(const unsigned int temp, const unsigned int on)
+void indicator_update(const int temp, const unsigned int on)
{
if (!on) {
indicator_set_state(0, 0, 0);
return;
}
- if (temp > state.calibration[0]) {
+ if (temp == -1) {
+ indicator_set_state(1, 1, 1);
+ } else if (temp > state.calibration[0]) {
indicator_set_state(1, 0, 0);
} else if (temp > state.calibration[1]) {
indicator_set_state(1, 1, 0);
@@ -77,7 +79,7 @@ void indicator_update(const unsigned int temp, const unsigned int on)
}
}
-void indicator_calibrate(unsigned int const * const calibration)
+void indicator_calibrate(int const * const calibration)
{
memcpy(state.calibration, calibration, sizeof(state.calibration));
indicator_update(state.current_temp, 1);