add information (like atis)
This commit is contained in:
1 parent
599137c7b4
commit
9af88bdde9
1 file changed
+30
-12
+30
-12
@@ -13,13 +13,22 @@
|
||||
#define ODD 1
|
||||
#define EVEN 2
|
||||
|
||||
#define TEMP_UNDEFINED -99
|
||||
|
||||
#define DELAY 600000 // 10 minutes
|
||||
//#define DELAY 5000 // 5 seconds
|
||||
|
||||
OneWire oneWire( ONE_WIRE_BUS );
|
||||
DallasTemperature DS18B20( &oneWire );
|
||||
U8G2_SSD1306_128X64_NONAME_F_HW_I2C display(U8G2_R0);
|
||||
|
||||
|
||||
int status = STATUS_OK;
|
||||
int oddEvenLoop = ODD;
|
||||
char ident[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
|
||||
int curIdent = 0;
|
||||
|
||||
float tempMin = TEMP_UNDEFINED;
|
||||
float tempMax = TEMP_UNDEFINED;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
@@ -32,13 +41,21 @@ void setup() {
|
||||
}
|
||||
|
||||
void loop() {
|
||||
char tempStr[6];
|
||||
char tempStr[8], tempHeadStr[16];
|
||||
long uptimeSec = millis() / 1000;
|
||||
|
||||
DS18B20.requestTemperatures();
|
||||
float tempFl = DS18B20.getTempCByIndex(0);
|
||||
float temp = DS18B20.getTempCByIndex(0);
|
||||
|
||||
dtostrf(tempFl, 4, 1, tempStr);
|
||||
if (temp < tempMin || tempMin == TEMP_UNDEFINED) {
|
||||
tempMin = temp;
|
||||
}
|
||||
if (temp > tempMax || tempMax == TEMP_UNDEFINED) {
|
||||
tempMax = temp;
|
||||
}
|
||||
|
||||
sprintf(tempStr, "%0.1f", temp);
|
||||
sprintf(tempHeadStr, "L %0.1f H %0.1f %c", tempMin, tempMax, ident[curIdent]);
|
||||
|
||||
Serial.print(uptimeSec);
|
||||
Serial.print(": ");
|
||||
@@ -55,13 +72,7 @@ void loop() {
|
||||
break;
|
||||
case STATUS_OK:
|
||||
default:
|
||||
if (oddEvenLoop == ODD) {
|
||||
display.drawStr(0, 11, "Temperatur *");
|
||||
oddEvenLoop = EVEN;
|
||||
} else {
|
||||
display.drawStr(0, 11, "Temperatur #");
|
||||
oddEvenLoop = ODD;
|
||||
}
|
||||
display.drawStr(0, 11, tempHeadStr);
|
||||
}
|
||||
display.setFont(u8g2_font_fub42_tn);
|
||||
display.drawStr(8, 63, tempStr);
|
||||
@@ -72,6 +83,8 @@ void loop() {
|
||||
if (fd) {
|
||||
fd.print(uptimeSec);
|
||||
fd.print(";");
|
||||
fd.print(ident[curIdent]);
|
||||
fd.print(";");
|
||||
fd.println(tempStr);
|
||||
fd.close();
|
||||
status = STATUS_OK;
|
||||
@@ -79,6 +92,11 @@ void loop() {
|
||||
status = STATUS_SD_WRITE_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
curIdent++;
|
||||
if (curIdent >= sizeof(ident)) {
|
||||
curIdent = 0;
|
||||
}
|
||||
|
||||
delay(5000);
|
||||
delay(DELAY);
|
||||
}
|
||||
Reference in new issue
Block a user