summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tempmodule/indicator.c16
-rw-r--r--src/tempmodule/indicator.h6
2 files changed, 12 insertions, 10 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);
diff --git a/src/tempmodule/indicator.h b/src/tempmodule/indicator.h
index d44b7fe..99f4e1c 100644
--- a/src/tempmodule/indicator.h
+++ b/src/tempmodule/indicator.h
@@ -25,9 +25,9 @@
extern "C" {
#endif
-void indicator_init(unsigned int temp, unsigned int const * const calibration);
-void indicator_update(const unsigned int temp, const unsigned int on);
-void indicator_calibrate(unsigned int const * const calibration);
+void indicator_init(int temp, unsigned int const * const calibration);
+void indicator_update(const int temp, const unsigned int on);
+void indicator_calibrate(int const * const calibration);
#ifdef __cplusplus
}