Close

Update: code cleanup, minor bug fixes

A project log for Alarm Clock with Remote USB Interface

A device I designed to fuse 74-series logic with an ATmega328PB microcontroller

zachary-murtishiZachary Murtishi 12/11/2024 at 02:030 Comments

I finally got around to some housekeeping on the code:

  1. 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. 
    1. 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.
  2. 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.
  3. 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.
  4. 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