Display also humidity and pressure
Display update triggered by value change, not interval
This commit is contained in:
29
tube.ino
29
tube.ino
@@ -10,21 +10,42 @@ void initTube() {
|
||||
tube.setBlinkRate(BLINK_OFF);
|
||||
}
|
||||
|
||||
void rotateTube() {
|
||||
displaySensor = (displaySensor + 1) % SENSORS;
|
||||
tubeRotated = true;
|
||||
}
|
||||
|
||||
void updateTube() {
|
||||
char newText[5];
|
||||
bool highPoint = false, lowPoint = false;
|
||||
uint value = countdown;
|
||||
|
||||
if (countdown <= 0) {
|
||||
sprintf(newText, "%4u", (unsigned int) (temperature * 100.0));
|
||||
lowPoint = true;
|
||||
} else {
|
||||
sprintf(newText, "%4u", countdown);
|
||||
switch (displaySensor) {
|
||||
case TEMPERATURE:
|
||||
value = (uint) (sensorValue[TEMPERATURE] * 100);
|
||||
lowPoint = true;
|
||||
break;
|
||||
case HUMIDITY:
|
||||
// TODO: add % sign?
|
||||
value = (uint) (sensorValue[HUMIDITY]);
|
||||
break;
|
||||
case PRESSURE:
|
||||
value = (uint) (sensorValue[PRESSURE] / 100);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sprintf(newText, "%4u", value);
|
||||
|
||||
// TODO: In the current mode of display refresh (displayNeedsUpdate) it should not be necessary to check previous text
|
||||
// Maybe add LED switching for case when the strings match as a rough check before removing comparison?
|
||||
// Or LED switching when display is updated?
|
||||
if (strcmp(tubeText, newText)) {
|
||||
strcpy(tubeText, newText);
|
||||
tube.displayString(tubeText);
|
||||
tube.setPoint(highPoint, lowPoint);
|
||||
tube.display();
|
||||
}
|
||||
|
||||
displayNeedsUpdate = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user