Although it is now possible to get a value with a float, the timer value may be swapped back and forth when the value is obtained in succession.
static int update(void* userdata)
PlaydateAPI* pd = userdata;
float t1 = pd->system->getElapsedTime();
for (int i = 0; i < 100; ++i)
float t2 = pd->system->getElapsedTime();
if (t1 > t2)
pd->system->logToConsole("ERR(%2d): t1:%.5f > t2:%.5f", i, t1, t2);
t1 = t2;
This is a sample source.
In this case,
t1 <= t2 should be the case, but
t1 > t2 may be the case only when executed on a device.
This does not occur in the simulator.
Curiously, commenting out
pd->system->drawFPS() prevents this from happening.
HDTimerTest.zip (3.9 KB)
A sample reproduction test is attached.
$ rake build:simulator:debug
$ rake build:device:debug
$ rake run
This procedure will start the simulator, so transfer it directly to the device and check the console log.