ZAdamMac / PETI

A project to brute-force-learn embedded product design techniques by creating a 90s-style virtual pet that runs on the MSP430FR5994 microcontroller.
GNU General Public License v3.0
5 stars 3 forks source link

[BUG] 0.4.0 - Errors in Evolution Timing #47

Open ZAdamMac opened 2 months ago

ZAdamMac commented 2 months ago

Version String: v/0.4.0 - dev

Expected Behaviour: The pet should hatch and evolve at roughly the following cadence: eggs hatch after 5 minutes. The baby evolves an hour after that. Subsequent evolutions are shortly after waking, integer numbers of days therafter.

Issue/Observed Behaviour: When hatching a new egg for the first time after complete device reset (i.e. clearing the save data), the pet hatches after five minutes and evolves again an hour later (or so). The Pet then proceeds to evolve repeatedly on the same day. After an evolution that returns the pet to egg form, the timer is not being adjusted properly and the egg can wait for hours without hatching (presumably now correctly waiting for an integer number of days or at least a rollover in the RTC).

This is likely a consequence of not appropriately considering wall-clock-roundness in the timing logic and needs to be revisted.