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();