Timer: uptime report demo

main
radex 2024-02-14 21:21:02 +01:00
parent a4e0a69165
commit 50a70f5725
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
1 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#include <Arduino.h>
#define DEMO_TRIGGER_MS 1000
#define DEMO_REPORT_SECONDS 2
#define DEMO_TRIGGER_MS DEMO_REPORT_SECONDS * 1000
#if F_CPU != 16000000
#error "Unsupported F_CPU"
@ -26,6 +27,7 @@ void setupTimer() {
// incremented every DEMO_TRIGGER_MS by interrupt,
// read and decremented by main loop
volatile uint8_t timerEvents = 0;
uint8_t demoCounter = 0;
void demoTimer() {
bool shouldTrigger = false;
@ -38,7 +40,10 @@ void demoTimer() {
interrupts();
if (shouldTrigger) {
Serial.println("Timer tick!");
demoCounter += DEMO_REPORT_SECONDS;
Serial.print("Uptime: ");
Serial.print(demoCounter);
Serial.println("s");
}
}