application: display uptime

This commit is contained in:
King Kévin 2020-12-12 14:45:36 +01:00
parent 492fd1e6a0
commit 695394255a
1 changed files with 6 additions and 0 deletions

View File

@ -519,6 +519,12 @@ void main(void)
sensor_ds18b20_convert(0); // start next conversion
printf("heater temperature: %.01f °C\n", heater_temp);
}
// update uptime
const uint32_t uptime = rtc_to_seconds() - boot_time; // get time from internal RTC
char strtime[12]; // to store time representation
snprintf(strtime, sizeof(strtime), "%u.%02u:%02u:%02u", uptime / (24 * 60 * 60), (uptime / (60 * 60)) % 24, (uptime / 60) % 60, uptime % 60); // get uptime representation
oled_text_line(strtime, 1); // add text to display buffer
oled_text_update(); // display new text
}
if (sensor_sr04_distance) { // distance measurement is available
printf("distance: %u mm\n", sensor_sr04_distance); // start measurement