From 053476718e07276f0fae92eba8bbed2a19598d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomislav=20Kopi=C4=87?= Date: Tue, 11 Jun 2024 19:12:09 +0200 Subject: [PATCH] first commit --- Cubegotchi.ino | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Cubegotchi.ino b/Cubegotchi.ino index 8723f61..4b5fdac 100644 --- a/Cubegotchi.ino +++ b/Cubegotchi.ino @@ -75,8 +75,17 @@ static void hal_sleep_until(timestamp_t ts) { if (remaining <= 0) { break; } - delayMicroseconds(remaining+5000); // Delay for remaining microseconds - Serial.println(remaining); + + // Adjust the delay duration based on the remaining time + if (remaining >= 1000) { + delayMicroseconds(1000); // Delay for 1000 microseconds (1 millisecond) + } else if (remaining > 100) { + delayMicroseconds(100); // Delay for 100 microseconds + } else if (remaining > 10) { + delayMicroseconds(10); // Delay for 10 microseconds + } else if (remaining > 0) { + delayMicroseconds(1); // Delay for 1 microsecond + } } #endif } @@ -339,7 +348,7 @@ void setup() { tamalib_register_hal(&hal); tamalib_set_framerate(TAMA_DISPLAY_FRAMERATE); - tamalib_init(1000000); + tamalib_init(1010000); #if defined(ENABLE_SAVE_STATUS) || defined(AUTO_SAVE_MINUTES) || defined(ENABLE_LOAD_STATE_FROM_EEPROM) initEEPROM();