Bytesize Updates: 9 minute snooze

Another update on my LED clock.

Just finished writing code for Snooze function! It seems to be working, although kind of hard to test 🙂

While Alarm sounds pressing Menu button, turns on 9 minute snooze. After 9 minutes alarm sounds again, and so on until it’s been 1 hour after original alarm (reArm Alarm function takes care of that).

What’s interesting is origins of 9 minute snooze. I always wondered why my off the shelf alarm clock has 9 minute snooze. When I started to write a code, I thought how hard it would be calculate snooze time, use various variables, epoch time, etc.  But I’m really glad that I googled “9 minute snooze”

If the snooze button is 9 minutes then the digital clock would only have to keep track of the last digit, because the last digit would go down by 1.

Brilliant in it’s simplicity.

Form that I derived algorithm for my Snooze function:

Set Snooze:

IF (CURRENT_TIME_MIN_LASTDIGIT==0) SNOOZE_TIME=9
ELSE SNOOZE_TIME = CURRENT_TIME_MIN_LASTDIGIT – 1

 Use Snooze:

IF (CURRENT_TIME_MIN_LASTDIGIT == SNOOZE_TIME) THEN SOUND ALARM
 

 

 

Tags: , , , , ,