Add temperature hysteresis
Do not refresh display if value not changed
This commit is contained in:
22
tube.ino
22
tube.ino
@@ -1,22 +1,30 @@
|
||||
#include "grove_alphanumeric_display.h"
|
||||
|
||||
Seeed_Digital_Tube tube;
|
||||
char tubeText[5] = "";
|
||||
|
||||
void initTube() {
|
||||
// Wire initialized by BME280 sensor
|
||||
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
||||
tube.setBrightness(15);
|
||||
tube.setBlinkRate(BLINK_OFF);
|
||||
tube.setPoint(true,true);
|
||||
}
|
||||
|
||||
void updateTube() {
|
||||
char tube_str[5];
|
||||
char newText[5];
|
||||
bool highPoint = false, lowPoint = false;
|
||||
|
||||
if (countdown <= 0)
|
||||
sprintf(tube_str, "%4u", (unsigned int) (temperature * 100.0));
|
||||
else
|
||||
sprintf(tube_str, "%4u", countdown);
|
||||
if (countdown <= 0) {
|
||||
sprintf(newText, "%4u", (unsigned int) (temperature * 100.0));
|
||||
lowPoint = true;
|
||||
} else {
|
||||
sprintf(newText, "%4u", countdown);
|
||||
}
|
||||
|
||||
tube.displayString(tube_str);
|
||||
if (strcmp(tubeText, newText)) {
|
||||
strcpy(tubeText, newText);
|
||||
tube.displayString(tubeText);
|
||||
tube.setPoint(highPoint, lowPoint);
|
||||
tube.display();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user