mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-04-28 21:08:15 +00:00
Some serious restructuring to be able to swap between implementations
This commit is contained in:
10
lib/Uptime/include/Uptime.h
Normal file
10
lib/Uptime/include/Uptime.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef _UPTIME_H
|
||||
#define _UPTIME_H
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
static uint32_t _uptime_last_value = 0;
|
||||
static uint32_t _uptime_rollovers = 0;
|
||||
uint64_t millis64();
|
||||
|
||||
#endif
|
||||
8
lib/Uptime/src/Uptime.cpp
Normal file
8
lib/Uptime/src/Uptime.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "Uptime.h"
|
||||
|
||||
uint64_t millis64() {
|
||||
uint32_t new_low32 = millis();
|
||||
if (new_low32 < _uptime_last_value) _uptime_rollovers++;
|
||||
_uptime_last_value = new_low32;
|
||||
return (uint64_t) _uptime_rollovers << 32 | _uptime_last_value;
|
||||
}
|
||||
Reference in New Issue
Block a user