25 March 2025
Running overnight, the clock module seems to be keeping time well. I managed to minimize the hum it generates by wiggling the USB connection of the WCH-LinkE programming adapter, which is where the module and my development board are getting their power.
Another thought I had to minimize the excessive noise is to display the time one segment at a time, completely obviating the function of the TM1637 chip. I think I will save that trick for when I am implementing a direct-drive LED interface using just the -203 chip.
I’m also considering whether or not to implement the flashing colon function at all. To have it flash on and off at 1 Hz, I would need to let the once-per-second interrupt handler update the time display with the colon on, then trigger a separate timer function to interrupt after a half a second has passed, then just re-write only the second digit, this time with the colon bit cleared. But in reality, the flashing colon might prove too distracting in actual operation.
Alternately, I could halve the RTC prescaler and get a 2 Hz interrupt, eliminating the need to involve a second timer in the process. So many options! And yet, maybe not even worth doing in any case.
But today I should really focus on designing and implementing the user interface for this little clock so that I can easily set the time, when needed. I would also like to implement a simpler way to toggle daylight saving time on and off, rather than force the user to go through the whole time-setting procedure twice a year.
OK, I’ve decided to leave the colon on all the time, at least for now. I also moved a little code around so that the LED module only gets updated once a minute, instead of every second.
Now, about that user interface… The simplest thing I can get away with on this project is two push buttons, one to set the hours and the other to set the minutes. Each press and release will increment the count by one, while holding the button down will cause it to count up at around 2 Hz, rolling over when it reaches its maximum count. A bonus feature will be to toggle the daylight savings time mode by pushing both buttons at once.
I connected two momentary contact push button switches to GPIO pins PB3 and PB4, mostly because those were the next pins in the completely arbitrary sequence with which I have been assigning GPIO pins. Now to alter the GPIO initialization code to set them up as inputs with pull-up resistors enabled.