I finally got around to some housekeeping on the code:
- Fixed a bug from the method I'm using to blank the display. This bug would leave the display blanked if it an alarm was snoozed or disabled during the off period of the display flashing.
- It feels wrong to use the port direction register to accomplish this so I'm just using the same technique I use to blank the digits mid-refresh - send the null character (0xFF) to the 74LS47 at all times.
- Changed how the buzzer works. Instead of leaving the Timer1 overflow interrupt on the entire time and toggling the port direction register to activate the buzzer, the Timer1 overflow interrupt is enabled upon activation of an alarm.
- Got rid of modulo operations wherever I could. They weren't necessarily an issue as far as program execution speed went, but conditionals are easier for people to follow + have an inherent speed advantage on the ATmega328PB, which doesn't have any floating point hardware.
- Cleaned up the code. Moved all functions to a header file and removed their dependencies on global variables - now, global variables are passed and updated through pointers. I still have more to do, but this is a start.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.