For most of the last 9 months, I've successfully avoided unplugging this clock. It's something I've specifically avoided as every power cycle requires pulling the clock off the wall, holding the timezone button for 5 seconds and then remounting on the wall. This is not a terrible burden by any measure, but apparently it's enough of an annoyance to warrant spending multiple hours updating the firmware.
Storing a single byte in eeprom on an AVR is straight forward - a call to eeprom_write_byte here, a call to eeprom_read_byte there. The challenge for this project is fitting another 72 bytes of code into the remaining 30 bytes of the ATtiny13a's flash space!
Having already made multiple size-reducing passes on this code previously, I wasn't hopeful that significant savings could be made. Minor tweaks could be made, but It would be a mission to find 42 bytes worth of those. Thankfully I managed to extract the required space with just two changes (commit):
- 30 bytes: Consolidated three places where digits were selectively blanked into a common "clear display" function
- 14 bytes: Dropped the unused day, month and year fields from the NMEA string parsing
With space freed up, the eeprom save/restore was an easy add (commit). Hopefully no further additions are needed as there's just two bytes of code space free.
Edit: I noticed a stupid late-night bug immediately after posting this which required freeing a further 8 bytes (commit)! The code usage is now exactly 100% at 1024 bytes.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.