HackRVA / badge2024

HackRVA 2024 badge firmware and emulator
5 stars 0 forks source link

Something's fishy about the clock #4

Closed smcameron closed 7 months ago

smcameron commented 7 months ago

On the simulator, the moonpatrol badge app relies on rtc_get_ms_since_boot() for timing the player, seems to work.

On the badge hardware, in moonpatrol, the time stays at zero.

On the badge hardware, rtc_get_ms_since_boot() relies on get_absolute_time(), on the simulator it relies on timespec_get().

get_absolute_time() seems to be from the pico sdk.

That's all I know about the problem so far.

smcameron commented 7 months ago

Added a clock to the qc app, and the clock appears to work on the hardware badge. Must be a bug in the moonpatrol app.

smcameron commented 7 months ago

Hmm, putting printf's in moonpatrol, I see via USB serial that the time being computed correctly in the game, just not displayed correctly.

the_time = 65829 player.start_time = 32403 elapsed_time_ms = 54125 ms = 125 sec = 54 secs = 54 minute = 0 the_time = 65863 player.start_time = 32403 elapsed_time_ms = 54159 ms = 159 sec = 54 secs = 54 minute = 0

smcameron commented 7 months ago

Fixed by:

Always use inttypes.h PRIu64 instead of %lu or %llu directly.