This commit is contained in:
Paul
2020-05-25 23:18:30 +02:00
parent d3953d90ca
commit 69646c1a1c
21 changed files with 335 additions and 104 deletions

View File

@@ -26,15 +26,25 @@ uint64_t get_uptime_ms() {
static uint32_t high_millis = 0;
static uint32_t low_millis = 0;
uint32_t now_millis = ::millis();
if (now_millis < low_millis) {
if (get_uptime() < low_millis) {
high_millis++;
}
low_millis = now_millis;
low_millis = get_uptime();
return ((uint64_t)high_millis << 32) | low_millis;
}
// added by proddy
static uint32_t now_millis; // added by proddy
void set_uptime() {
now_millis = ::millis();
}
uint32_t get_uptime() {
return now_millis;
}
} // namespace uuid

View File

@@ -21,6 +21,7 @@
namespace uuid {
void loop() {
set_uptime(); // added by proddy
get_uptime_ms();
}

View File

@@ -86,6 +86,9 @@ void loop();
*/
uint64_t get_uptime_ms();
uint32_t get_uptime(); // added by proddy
void set_uptime();
} // namespace uuid
#endif