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 }