From 6a46a2f9b93eea11e7b4547871114ee57b4b691e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomislav=20Kopi=C4=87?= Date: Wed, 12 Jun 2024 11:00:12 +0000 Subject: [PATCH] Update CubeGotchi.ino --- CubeGotchi.ino | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/CubeGotchi.ino b/CubeGotchi.ino index cef906f..3ecdb85 100644 --- a/CubeGotchi.ino +++ b/CubeGotchi.ino @@ -68,14 +68,10 @@ static void hal_log(log_level_t level, char *buff, ...) { static void hal_sleep_until(timestamp_t ts) { #ifdef ENABLE_REAL_TIME - while (true) { - // Calculate the remaining time until the target timestamp - int32_t remaining = (int32_t)(ts - hal_get_timestamp()); - // Exit the loop if the target time has been reached or passed - if (remaining <= 0) { - break; - } - delayMicroseconds(remaining); // Delay for remaining microseconds + int32_t remaining = (int32_t) (ts - hal_get_timestamp()); + if (remaining > 0) { + delayMicroseconds(remaining); + delayMicroseconds(1000); } #endif }