-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatusScreen.cpp
More file actions
62 lines (54 loc) · 1.41 KB
/
StatusScreen.cpp
File metadata and controls
62 lines (54 loc) · 1.41 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
#include <stdlib.h>
#include <string.h>
#include "StatusScreen.h"
#include <HardwareSerial.h>
void StatusScreen::init(LiquidCrystal *lcd, float *temperature,
float *humidity, TimerTrigger *timerTrigger) {
_lcd = lcd;
_temperature = temperature;
_humidity = humidity;
_timerTrigger = timerTrigger;
}
void StatusScreen::refresh () {
char str[3];
unsigned long timeLeft;
_lcd->clear();
_lcd->print(F("T:"));
_lcd->setCursor(8,0);
_lcd->print(F("H:"));
updateSensor (_temperature, 2, 0, 'C');
updateSensor (_humidity, 10, 0, '%');
_lcd->setCursor(0,1);
if (_timerTrigger->isActive()){
if (_timerTrigger->getOnState()) {
_lcd->print(F("Eggs turning "));
} else {
_lcd->print(F("Turn in "));
_lcd->setCursor(8,1);
timeLeft = _timerTrigger->getTimeLeft();
itoa(timeLeft/3600, str, 10);
_lcd->print(str);
_lcd->print(':');
itoa((timeLeft%3600)/60, str, 10);
if (strlen(str) < 2)
_lcd->print('0');
_lcd->print(str);
_lcd->print(':');
itoa(timeLeft%60, str, 10);
if (strlen(str) < 2)
_lcd->print('0');
_lcd->print(str);
}
}
else {
_lcd->print(F("Turner off"));
}
}
void StatusScreen::updateSensor(const float *sensor, uint8_t col, uint8_t row, char measureUnit)
{
char str[5];
dtostrf(*sensor, 4, 1, str);
_lcd->setCursor(col,row);
_lcd->print(str);
_lcd->print(measureUnit);
}