Timer: uptime report demo
parent
a4e0a69165
commit
50a70f5725
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue