add information (like atis)

This commit is contained in:
damage committed 2026-10-20 20:09:42 +02:00
1 parent 599137c7b4
commit 9af88bdde9
1 file changed
+30 -12
+30 -12
View File
@@ -13,13 +13,22 @@
#define ODD 1 #define ODD 1
#define EVEN 2 #define EVEN 2
#define TEMP_UNDEFINED -99
#define DELAY 600000 // 10 minutes
//#define DELAY 5000 // 5 seconds
OneWire oneWire( ONE_WIRE_BUS ); OneWire oneWire( ONE_WIRE_BUS );
DallasTemperature DS18B20( &oneWire ); DallasTemperature DS18B20( &oneWire );
U8G2_SSD1306_128X64_NONAME_F_HW_I2C display(U8G2_R0); U8G2_SSD1306_128X64_NONAME_F_HW_I2C display(U8G2_R0);
int status = STATUS_OK; 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() { void setup() {
Serial.begin(115200); Serial.begin(115200);
@@ -32,13 +41,21 @@ void setup() {
} }
void loop() { void loop() {
char tempStr[6]; char tempStr[8], tempHeadStr[16];
long uptimeSec = millis() / 1000; long uptimeSec = millis() / 1000;
DS18B20.requestTemperatures(); 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(uptimeSec);
Serial.print(": "); Serial.print(": ");
@@ -55,13 +72,7 @@ void loop() {
break; break;
case STATUS_OK: case STATUS_OK:
default: default:
if (oddEvenLoop == ODD) { display.drawStr(0, 11, tempHeadStr);
display.drawStr(0, 11, "Temperatur *");
oddEvenLoop = EVEN;
} else {
display.drawStr(0, 11, "Temperatur #");
oddEvenLoop = ODD;
}
} }
display.setFont(u8g2_font_fub42_tn); display.setFont(u8g2_font_fub42_tn);
display.drawStr(8, 63, tempStr); display.drawStr(8, 63, tempStr);
@@ -72,6 +83,8 @@ void loop() {
if (fd) { if (fd) {
fd.print(uptimeSec); fd.print(uptimeSec);
fd.print(";"); fd.print(";");
fd.print(ident[curIdent]);
fd.print(";");
fd.println(tempStr); fd.println(tempStr);
fd.close(); fd.close();
status = STATUS_OK; status = STATUS_OK;
@@ -80,5 +93,10 @@ void loop() {
} }
} }
delay(5000); curIdent++;
if (curIdent >= sizeof(ident)) {
curIdent = 0;
}
delay(DELAY);
} }