From eb9ad3c75a73a7a56d78c00e22b230e101c12351 Mon Sep 17 00:00:00 2001 From: shufps Date: Mon, 9 Sep 2024 18:51:15 +0200 Subject: [PATCH] fixed overflowing 32bit us in history --- src/mining_nerdnos.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mining_nerdnos.cpp b/src/mining_nerdnos.cpp index d96fc11..be002fd 100644 --- a/src/mining_nerdnos.cpp +++ b/src/mining_nerdnos.cpp @@ -65,7 +65,9 @@ static void calculate_hashrate(history_t *history, uint32_t diff) { // add and store the newest sample history->sum += diff; history->diffs[history->newest % ASIC_HISTORY_SIZE] = diff; - history->timestamps[history->newest % ASIC_HISTORY_SIZE] = micros(); + + // micros() wraps around after about 71.58min because it's 32bit casted from 64bit timer :facepalm: + history->timestamps[history->newest % ASIC_HISTORY_SIZE] = esp_timer_get_time(); uint64_t oldest_timestamp = history->timestamps[history->oldest % ASIC_HISTORY_SIZE]; uint64_t newest_timestamp = history->timestamps[history->newest % ASIC_HISTORY_SIZE];