Update CubeGotchi.ino

This commit is contained in:
Tomislav Kopić 2024-06-12 11:00:12 +00:00
parent c59b5c1e45
commit 6a46a2f9b9

View File

@ -68,14 +68,10 @@ static void hal_log(log_level_t level, char *buff, ...) {
static void hal_sleep_until(timestamp_t ts) { static void hal_sleep_until(timestamp_t ts) {
#ifdef ENABLE_REAL_TIME #ifdef ENABLE_REAL_TIME
while (true) { int32_t remaining = (int32_t) (ts - hal_get_timestamp());
// Calculate the remaining time until the target timestamp if (remaining > 0) {
int32_t remaining = (int32_t)(ts - hal_get_timestamp()); delayMicroseconds(remaining);
// Exit the loop if the target time has been reached or passed delayMicroseconds(1000);
if (remaining <= 0) {
break;
}
delayMicroseconds(remaining); // Delay for remaining microseconds
} }
#endif #endif
} }