Alpha Clock Five Revised Firmware

Created Diff never expires
/*
/*


AlphaClock.ino
AlphaClock.ino
-- Alpha Clock Five Firmware, version 2.1 --
-- Alpha Clock Five Firmware, version 2.1 --
Version 2.1.0 - January 31, 2013
Version 2.1.0 - January 31, 2013
Copyright (c) 2013 Windell H. Oskay. All right reserved.
Copyright (c) 2013 Windell H. Oskay. All right reserved.
http://www.evilmadscientist.com/
http://www.evilmadscientist.com/
------------------------------------------------------------
------------------------------------------------------------
Designed for Alpha Clock Five, a five letter word clock designed by
Designed for Alpha Clock Five, a five letter word clock designed by
Evil Mad Scientist Laboratories http://www.evilmadscientist.com
Evil Mad Scientist Laboratories http://www.evilmadscientist.com
Target: ATmega644A, clock at 16 MHz.
Target: ATmega644A, clock at 16 MHz.
Designed to work with Arduino 1.0.3; untested with other versions.
Designed to work with Arduino 1.0.3; untested with other versions.
For additional requrements, please see:
For additional requrements, please see:
http://wiki.evilmadscience.com/Alpha_Clock_Firmware_v2
http://wiki.evilmadscience.com/Alpha_Clock_Firmware_v2
Thanks to Trammell Hudson for inspiration and helpful discussion.
Thanks to Trammell Hudson for inspiration and helpful discussion.
https://bitbucket.org/hudson/alphaclock
https://bitbucket.org/hudson/alphaclock
Thanks to William Phelps - wm (at) usa.net, for several important
Thanks to William Phelps - wm (at) usa.net, for several important
bug fixes. https://github.com/wbphelps/AlphaClock
bug fixes. https://github.com/wbphelps/AlphaClock
------------------------------------------------------------
------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
(at your option) any later version.
This library is distributed in the hope that it will be useful,
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this library. If not, see <http://www.gnu.org/licenses/>.
along with this library. If not, see <http://www.gnu.org/licenses/>.
Note that the two word lists included with this distribution are NOT licensed under the GPL.
Note that the two word lists included with this distribution are NOT licensed under the GPL.
- The list in fiveletterwords.h is derived from SCOWL, http://wordlist.sourceforge.net
- The list in fiveletterwords.h is derived from SCOWL, http://wordlist.sourceforge.net
Please see README-SCOWL.txt for copyright restrictions on the use and redistribution of this word list.
Please see README-SCOWL.txt for copyright restrictions on the use and redistribution of this word list.
- The alternative list in fiveletterwordspd.h is in the PUBLIC DOMAIN,
- The alternative list in fiveletterwordspd.h is in the PUBLIC DOMAIN,
and cannot be restricted by the GPL or other copyright licenses.
and cannot be restricted by the GPL or other copyright licenses.
*/
*/




#include "alphafive.h" // Alpha Clock Five library
#include "alphafive.h" // Alpha Clock Five library


// Comment out exactly one of the following two lines
// Comment out exactly one of the following two lines
#include "fiveletterwords.h" // Standard word list --
#include "fiveletterwords.h" // Standard word list --
//#include "fiveletterwordspd.h" // Public domain alternative
//#include "fiveletterwordspd.h" // Public domain alternative




#include <Time.h> // The Arduino Time library, http://www.arduino.cc/playground/Code/Time
#include <Time.h> // The Arduino Time library, http://www.arduino.cc/playground/Code/Time
#include <Wire.h> // For optional RTC module
#include <Wire.h> // For optional RTC module
#include <DS1307RTC.h> // For optional RTC module. (This library included with the Arduino Time library)
#include <DS1307RTC.h> // For optional RTC module. (This library included with the Arduino Time library)
#include <EEPROM.h> // For saving settings
#include <EEPROM.h> // For saving settings


// "Factory" default configuration can be configured here:
// "Factory" default configuration can be configured here:
#define a5brightLevelDefault 9
#define a5brightLevelDefault 9
#define a5HourMode24Default 0
#define a5HourMode24Default 0
#define a5AlarmEnabledDefault 0
#define a5AlarmEnabledDefault 0
#define a5AlarmHrDefault 7
#define a5AlarmHrDefault 7
#define a5AlarmMinDefault 30
#define a5AlarmMinDefault 30
#define a5NightLightTypeDefault 0
#define a5NightLightTypeDefault 0
#define a5AlarmToneDefault 2
#define a5AlarmToneDefault 2
#define a5NumberCharSetDefault 2;
#define a5NumberCharSetDefault 2;
#define a5DisplayModeDefault 0;
#define a5DisplayModeDefault 0;


// Clock mode variables
// Clock mode variables


byte HourMode24;
byte HourMode24;
byte AlarmEnabled; // If the "ALARM" function is currently turned on or off.
byte AlarmEnabled; // If the "ALARM" function is currently turned on or off.
byte AlarmTimeHr;
byte AlarmTimeHr;
byte AlarmTimeMin;
byte AlarmTimeMin;
int8_t AlarmTone;
int8_t AlarmTone;


int8_t NightLightType;
int8_t NightLightType;
byte NightLightSign;
byte NightLightSign;
unsigned int NightLightStep;
unsigned int NightLightStep;






// Configuration menu:
// Configuration menu:
byte menuItem; //Current position within options menu
byte menuItem; //Current position within options menu
int8_t optionValue;
int8_t optionValue;
#define MenuItemsMax 10
#define MenuItemsMax 10


#define AMPM24HRMenuItem 0
#define AMPM24HRMenuItem 0
#define NightLightMenuItem 1
#define NightLightMenuItem 1
#define AlarmToneMenuItem 2
#define AlarmToneMenuItem 2
#define SoundTestMenuItem 3
#define SoundTestMenuItem 3
#define numberCharSetMenuItem 4
#define numberCharSetMenuItem 4
#define DisplayStyleMenuItem 5
#define DisplayStyleMenuItem 5
#define SetYearMenuItem 6
#define SetYearMenuItem 6
#define SetMonthMenuItem 7
#define SetMonthMenuItem 7
#define SetDayMenuItem 8
#define SetDayMenuItem 8
#define SetSecondsMenuItem 9
#define SetSecondsMenuItem 9
#define AltModeMenuItem 10
#define AltModeMenuItem 10






// Clock display mode:
// Clock display mode:
int8_t DisplayMode;
int8_t DisplayMode;
int8_t DisplayModeLocalLast;
int8_t DisplayModeLocalLast;
byte DisplayModePhase;
byte DisplayModePhase;
byte DisplayModePhaseCount;
byte DisplayModePhaseCount;
byte VCRmode;
byte VCRmode;
byte modeShowMenu;
byte modeShowMenu;
byte modeShowDateViaButtons;
byte modeShowDateViaButtons;
byte modeLEDTest;
byte modeLEDTest;
byte UpdateEE;
byte UpdateEE;
int8_t numberCharSet;
int8_t numberCharSet;




// Other global variables:
// Other global variables:
byte UseRTC;
byte UseRTC;
unsigned long NextClockUpdate, NextAlarmCheck;
unsigned long NextClockUpdate, NextAlarmCheck;
unsigned long milliTemp;
unsigned long milliTemp;
unsigned int FLWoffset; // Counter variable for FLW (Five Letter Word) display mode
unsigned int FLWoffset; // Counter variable for FLW (Five Letter Word) display mode


// Text Display Variables:
// Text Display Variables:
unsigned long DisplayWordEndTime;
unsigned long DisplayWordEndTime;
char wordCache[5];
char wordCache[5];
char dpCache[5];
char dpCache[5];


byte wordSequence;
byte wordSequence;
byte wordSequenceStep;
byte wordSequenceStep;
byte modeShowText;
byte modeShowText;



byte RedrawNow, RedrawNow_NoFade;
byte RedrawNow, RedrawNow_NoFade;




// Button Management:
// Button Management:
#define ButtonCheckInterval 20 // Time delay between responding to button state, ms
#define ButtonCheckInterval 20 // Time delay between responding to button state, ms
#define HoldDownTime 2000 // How long to hold buttons to acces smenus requiring holding two buttons
#define HoldDownTime 2000 // How long to hold buttons to acces smenus requiring holding two buttons
byte buttonStateLast;
byte buttonStateLast;
byte buttonMonitor;
byte buttonMonitor;
unsigned long Btn1_AlrmSet_StartTime, Btn2_TimeSet_StartTime, Btn3_Plus_StartTime, Btn4_Minus_StartTime;
unsigned long Btn1_AlrmSet_StartTime, Btn2_TimeSet_StartTime, Btn3_Plus_StartTime, Btn4_Minus_StartTime;
unsigned long NextButtonCheck, LastButtonPress;
unsigned long NextButtonCheck, LastButtonPress;




byte UpdateAlarmState, UpdateBrightness;
byte UpdateAlarmState, UpdateBrightness;
byte AlarmTimeChanged, TimeChanged;
byte AlarmTimeChanged, TimeChanged;
byte holdDebounce;
byte holdDebounce;




// Brightness steps for manual brightness adjustment
// Brightness steps for manual brightness adjustment
byte Brightness;
byte Brightness;
#define BrightnessMax 11
#define BrightnessMax 11
byte MBlevel[] = {
byte MBlevel[] = {
0, 1, 5,10,15,19,15,19, 5,10,15,19};
0, 1, 5,10,15,19,15,19, 5,10,15,19};
byte MBmode[] = {
byte MBmode[] = {
0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2};
0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2};


// For fade and update management:
// For fade and update management:
byte SecLast;
byte SecLast;
byte MinNowOnesLast;
byte MinNowOnesLast;
byte MinAlarmOnesLast;
byte MinAlarmOnesLast;




//Alarm variables
//Alarm variables
byte AlarmTimeSnoozeMin;
byte AlarmTimeSnoozeMin;
byte AlarmTimeSnoozeHr;
byte AlarmTimeSnoozeHr;
byte snoozed;
byte snoozed;
byte alarmPrimed;
byte alarmPrimed;
byte alarmNow;
byte alarmNow;


byte modeShowAlarmTime;
byte modeShowAlarmTime;
byte SoundSequence;
byte SoundSequence;


void incrementAlarm(void)
void incrementAlarm(void)
{ // Advance alarm time by one minute
{ // Advance alarm time by one minute


AlarmTimeMin += 1;
AlarmTimeMin += 1;
if (AlarmTimeMin > 59)
if (AlarmTimeMin > 59)
{
{
AlarmTimeMin = 0;
AlarmTimeMin = 0;
AlarmTimeHr += 1;
AlarmTimeHr += 1;
if (AlarmTimeHr > 23)
if (AlarmTimeHr > 23)
AlarmTimeHr = 0;
AlarmTimeHr = 0;
}
}
UpdateEE = 1;
UpdateEE = 1;
}
}


void decrementAlarm(void)
void decrementAlarm(void)
{ // Retard alarm time by one minute
{ // Retard alarm time by one minute


if (AlarmTimeMin > 0)
if (AlarmTimeMin > 0)
AlarmTimeMin--;
AlarmTimeMin--;
else
else
{
{
AlarmTimeMin = 59;
AlarmTimeMin = 59;
if (AlarmTimeHr > 0)
if (AlarmTimeHr > 0)
AlarmTimeHr--;
AlarmTimeHr--;
else
else
AlarmTimeHr = 23;
AlarmTimeHr = 23;
}
}
UpdateEE = 1;
UpdateEE = 1;
}
}


void TurnOffAlarm(void)
void TurnOffAlarm(void)
{ // This cancels the alarm when it is going off (or snoozed).
{ // This cancels the alarm when it is going off (or snoozed).
// It does leave the alarm enabled for next time, however.
// It does leave the alarm enabled for next time, however.
if (alarmNow || snoozed){
if (alarmNow || snoozed){
snoozed = 0;
snoozed = 0;
alarmNow = 0;
alarmNow = 0;
a5noTone();
a5noTone();


if (modeShowMenu == 0)
if (modeShowMenu == 0)
DisplayWordSequence(2); // Display: "ALARM OFF", EXCEPT if we are in the menus.
DisplayWordSequence(2); // Display: "ALARM OFF", EXCEPT if we are in the menus.
}
}
}
}


void checkButtons(void )
void checkButtons(void )
{
{
buttonMonitor |= a5GetButtons();
buttonMonitor |= a5GetButtons();


if (milliTemp >= NextButtonCheck) // Typically, go through this every 20 ms.
if (milliTemp >= NextButtonCheck) // Typically, go through this every 20 ms.
{
{
NextButtonCheck = milliTemp + ButtonCheckInterval;
NextButtonCheck = milliTemp + ButtonCheckInterval;
/*
/*
#define a5alarmSetBtn 1 // Snooze/Set alarm button
#define a5alarmSetBtn 1 // Snooze/Set alarm button
#define a5timeSetBtn 2 // Set time button
#define a5timeSetBtn 2 // Set time button
#define a5plusBtn 4 // + button
#define a5plusBtn 4 // + button
#define a5minusBtn 8 // - button
#define a5minusBtn 8 // - button
*/
*/


if (buttonMonitor){ // If any buttons have been down in last ButtonCheckInterval
if (buttonMonitor){ // If any buttons have been down in last ButtonCheckInterval


if (VCRmode)
if (VCRmode)
EndVCRmode(); // Turn off VCR-blink mode, if it was still on.
EndVCRmode(); // Turn off VCR-blink mode, if it was still on.




// Check to see if any of the buttons has JUST been depressed:
// Check to see if any of the buttons has JUST been depressed:


if (( buttonMonitor & a5_alarmSetBtn) && ((buttonStateLast & a5_alarmSetBtn) == 0))
if (( buttonMonitor & a5_alarmSetBtn) && ((buttonStateLast & a5_alarmSetBtn) == 0))
{ // If Alarm Set button was just depressed
{ // If Alarm Set button was just depressed


Btn1_AlrmSet_StartTime = milliTemp;
Btn1_AlrmSet_StartTime = milliTemp;


if (alarmNow){ // If alarm is going off, this button is the SNOOZE button.
if (alarmNow){ // If alarm is going off, this button is the SNOOZE button.


if (modeShowMenu)
if (modeShowMenu)
{
{
TurnOffAlarm();
TurnOffAlarm();
}
}
else{
else{
alarmNow = 0;
alarmNow = 0;
a5noTone();
a5noTone();
snoozed = 1;
snoozed = 1;


a5editFontChar ('a', 54, 1, 37); // Define special character
a5editFontChar ('a', 54, 1, 37); // Define special character
DisplayWord ("SNaZE", 1500);
DisplayWord ("SNaZE", 1500);


AlarmTimeSnoozeMin = minute() + 9;
AlarmTimeSnoozeMin = minute() + 9;
AlarmTimeSnoozeHr = hour();
AlarmTimeSnoozeHr = hour();


if ( AlarmTimeSnoozeMin > 59){
if ( AlarmTimeSnoozeMin > 59){
AlarmTimeSnoozeMin -= 60;
AlarmTimeSnoozeMin -= 60;
AlarmTimeSnoozeHr += 1;
AlarmTimeSnoozeHr += 1;
}
}
if (AlarmTimeSnoozeHr > 23)
if (AlarmTimeSnoozeHr > 23)
AlarmTimeSnoozeHr -= 24;
AlarmTimeSnoozeHr -= 24;
}
}


}
}
}
}


if (( buttonMonitor & a5_timeSetBtn) && ((buttonStateLast & a5_timeSetBtn) == 0)){
if (( buttonMonitor & a5_timeSetBtn) && ((buttonStateLast & a5_timeSetBtn) == 0)){
// Button S2 just depressed.
// Button S2 just depressed.
Btn2_TimeSet_StartTime = milliTemp;
Btn2_TimeSet_StartTime = milliTemp;
TimeChanged = 0;
TimeChanged = 0;
}
}
if (( buttonMonitor & a5_plusBtn) && ((buttonStateLast & a5_plusBtn) == 0))
if (( buttonMonitor & a5_plusBtn) && ((buttonStateLast & a5_plusBtn) == 0))
Btn3_Plus_StartTime = milliTemp;
Btn3_Plus_StartTime = milliTemp;
if (( buttonMonitor & a5_minusBtn) && ((buttonStateLast & a5_minusBtn) == 0))
if (( buttonMonitor & a5_minusBtn) && ((buttonStateLast & a5_minusBtn) == 0))
Btn4_Minus_StartTime = milliTemp;
Btn4_Minus_StartTime = milliTemp;
}
}
else if ((buttonStateLast == 0 ) && ( buttonMonitor == 0))
else if ((buttonStateLast == 0 ) && ( buttonMonitor == 0))
{
{
// Reset some variables if all buttons are up, and have not just been released:
// Reset some variables if all buttons are up, and have not just been released:
TimeChanged = 0;
TimeChanged = 0;
AlarmTimeChanged = 0;
AlarmTimeChanged = 0;
holdDebounce = 1;
holdDebounce = 1;
}
}


if (modeShowMenu || buttonMonitor)
if (modeShowMenu || buttonMonitor)
LastButtonPress = milliTemp; //Reset EEPROM Save Timer if menu shown, or if a button pressed.
LastButtonPress = milliTemp; //Reset EEPROM Save Timer if menu shown, or if a button pressed.


if (modeShowMenu && holdDebounce){ // Button behavior, when in Config menu mode:
if (modeShowMenu && holdDebounce){ // Button behavior, when in Config menu mode:


// Check to see if AlarmSet button was JUST released::
// Check to see if AlarmSet button was JUST released::
if ( ((buttonMonitor & a5_alarmSetBtn) == 0) && (buttonStateLast & a5_alarmSetBtn))
if ( ((buttonMonitor & a5_alarmSetBtn) == 0) && (buttonStateLast & a5_alarmSetBtn))
{
{
if ( menuItem > 0) //Decrement current position within options menu
if ( menuItem > 0) //Decrement current position within options menu
menuItem--;
menuItem--;
else
else
menuItem = MenuItemsMax; // Wrap-around at low-end of menu
menuItem = MenuItemsMax; // Wrap-around at low-end of menu
optionValue = 0;
optionValue = 0;
TurnOffAlarm();
TurnOffAlarm();
DisplayMenuOptionName();
DisplayMenuOptionName();
}
}


// If TimeSet button was just released::
// If TimeSet button was just released::
if (( (buttonMonitor & a5_timeSetBtn) == 0) && (buttonStateLast & a5_timeSetBtn))
if (( (buttonMonitor & a5_timeSetBtn) == 0) && (buttonStateLast & a5_timeSetBtn))
{
{
if ((alarmNow) || (snoozed)){ // Just Turn Off Alarm
if ((alarmNow) || (snoozed)){ // Just Turn Off Alarm
TurnOffAlarm();
TurnOffAlarm();
}
}
else { // If we are in a configuration menu
else { // If we are in a configuration menu
menuItem++;
menuItem++;
if ( menuItem > MenuItemsMax) //Decrement current position within options menu
if ( menuItem > MenuItemsMax) //Decrement current position within options menu
menuItem = 0; // Wrap-around at high-end of menu
menuItem = 0; // Wrap-around at high-end of menu
optionValue = 0;
optionValue = 0;
TurnOffAlarm();
TurnOffAlarm();
DisplayMenuOptionName();
DisplayMenuOptionName();
}
}
}
}


if (( (buttonMonitor & a5_plusBtn) == 0) && (buttonStateLast & a5_plusBtn))
if (( (buttonMonitor & a5_plusBtn) == 0) && (buttonStateLast & a5_plusBtn))
{ // The "+" button has just been released.
{ // The "+" button has just been released.
optionValue = 1;
optionValue = 1;
UpdateEE = 1;
UpdateEE = 1;
RedrawNow = 1;
RedrawNow = 1;
}
}


if (( (buttonMonitor & a5_minusBtn) == 0) && (buttonStateLast & a5_minusBtn))
if (( (buttonMonitor & a5_minusBtn) == 0) && (buttonStateLast & a5_minusBtn))
{ // The "-" Button has just been released.
{ // The "-" Button has just been released.
optionValue = -1;
optionValue = -1;
UpdateEE = 1;
UpdateEE = 1;
RedrawNow = 1;
RedrawNow = 1;
}
}
}
}
else
else
{ // Button behavior, when NOT in Config menu mode:
{ // Button behavior, when NOT in Config menu mode:


///////////////////////////// Time-Of-Day Adjustments /////////////////////////////
///////////////////////////// Time-Of-Day Adjustments /////////////////////////////


// Check to see if both time-set button and plus button are both currently depressed:
// Check to see if both time-set button and plus button are both currently depressed:


if (( buttonMonitor & a5_TimeSetPlusBtns) == a5_TimeSetPlusBtns)
if (( buttonMonitor & a5_TimeSetPlusBtns) == a5_TimeSetPlusBtns)
if (TimeChanged < 2)
if (TimeChanged < 2)
{
{
adjustTime(60); // Add one minute
adjustTime(60); // Add one minute
RedrawNow = 1;
RedrawNow = 1;
TimeChanged = 2; // One-time press: detected
TimeChanged = 2; // One-time press: detected
if (UseRTC)
if (UseRTC)
RTC.set(now());
RTC.set(now());
}
}
else if ( milliTemp >= (Btn3_Plus_StartTime + 400))
else if ( milliTemp >= (Btn3_Plus_StartTime + 400))
{
{
adjustTime(60); // Add one minute
adjustTime(60); // Add one minute
RedrawNow_NoFade = 1;
RedrawNow_NoFade = 1;
if (UseRTC)
if (UseRTC)
RTC.set(now());
RTC.set(now());
}
}


// Check to see if both time-set button and minus button are both currently depressed:
// Check to see if both time-set button and minus button are both currently depressed:
if (( buttonMonitor & a5_TimeSetMinusBtns) == a5_TimeSetMinusBtns)
if (( buttonMonitor & a5_TimeSetMinusBtns) == a5_TimeSetMinusBtns)
if (TimeChanged < 2)
if (TimeChanged < 2)
{
{
adjustTime(-60); // Subtract one minute
adjustTime(-60); // Subtract one minute
RedrawNow = 1;
RedrawNow = 1;
TimeChanged = 2;
TimeChanged = 2;
if (UseRTC)
if (UseRTC)
RTC.set(now());
RTC.set(now());
}
}
else if ( milliTemp > (Btn4_Minus_StartTime + 400 ))
else if ( milliTemp > (Btn4_Minus_StartTime + 400 ))
{
{
adjustTime(-60); // Subtract one minute
adjustTime(-60); // Subtract one minute
RedrawNow_NoFade = 1;
RedrawNow_NoFade = 1;
// TimeChanged = 1;
// TimeChanged = 1;
if (UseRTC)
if (UseRTC)
RTC.set(now());
RTC.set(now());
}
}


///////////////////////////// Time-Of-Alarm Adjustments /////////////////////////////
///////////////////////////// Time-Of-Alarm Adjustments /////////////////////////////


// Entering alarm mode:
// Entering alarm mode:
// If Alarm button has been down 40 ms,
// If Alarm button has been down 40 ms,
// (to avoid displaying alarm if Alarm+Time buttons are pressed at the same time)
// (to avoid displaying alarm if Alarm+Time buttons are pressed at the same time)
// the Set Time button is not down,
// the Set Time button is not down,
// and no other high-priority modes are enabled...
// and no other high-priority modes are enabled...




if (( buttonMonitor & a5_alarmSetBtn) && (modeShowAlarmTime == 0))
if (( buttonMonitor & a5_alarmSetBtn) && (modeShowAlarmTime == 0))
if ((( buttonMonitor & a5_timeSetBtn) == 0) && (modeShowText == 0))
if ((( buttonMonitor & a5_timeSetBtn) == 0) && (modeShowText == 0))
if ( milliTemp >= (Btn1_AlrmSet_StartTime + 40 )) // of those "ifs," Check hold-time LAST.
if ( milliTemp >= (Btn1_AlrmSet_StartTime + 40 )) // of those "ifs," Check hold-time LAST.
{
{
modeShowAlarmTime = 1;
modeShowAlarmTime = 1;
RedrawNow = 1;
RedrawNow = 1;
AlarmTimeChanged = 0;
AlarmTimeChanged = 0;
}
}


// Check to see if both alarm-set button and plus button are both currently depressed:
// Check to see if both alarm-set button and plus button are both currently depressed:
if (( buttonMonitor & a5_AlarmSetPlusBtns) == a5_AlarmSetPlusBtns)
if (( buttonMonitor & a5_AlarmSetPlusBtns) == a5_AlarmSetPlusBtns)
if (TimeChanged < 2)
if (TimeChanged < 2)
{
{
incrementAlarm(); // Add one minute
incrementAlarm(); // Add one minute
RedrawNow = 1;
RedrawNow = 1;
TimeChanged = 2; // One-time press: detected
TimeChanged = 2; // One-time press: detected
snoozed = 0; // Recalculating alarm time *turns snooze off.*
snoozed = 0; // Recalculating alarm time *turns snooze off.*
}
}
else if ( milliTemp >= (Btn3_Plus_StartTime + 400))
else if ( milliTemp >= (Btn3_Plus_StartTime + 400))
{
{
incrementAlarm(); // Add one minute
incrementAlarm(); // Add one minute
RedrawNow_NoFade = 1;
RedrawNow_NoFade = 1;
// TimeChanged = 1;
// TimeChanged = 1;
}
}


// Check to see if both alarm-set button and minus button are both currently depressed:
// Check to see if both alarm-set button and minus button are both currently depressed:
if (( buttonMonitor & a5_AlarmSetMinusBtns) == a5_AlarmSetMinusBtns)
if (( buttonMonitor & a5_AlarmSetMinusBtns) == a5_AlarmSetMinusBtns)
if (TimeChanged < 2)
if (TimeChanged < 2)
{
{
decrementAlarm(); // Subtract one minute
decrementAlarm(); // Subtract one minute
RedrawNow = 1;
RedrawNow = 1;
TimeChanged = 2; // One-time press: detected
TimeChanged = 2; // One-time press: detected
snoozed = 0; // Recalculating alarm time *turns snooze off.*
snoozed = 0; // Recalculating alarm time *turns snooze off.*
}
}
else if ( milliTemp > (Btn4_Minus_StartTime + 400))
else if ( milliTemp > (Btn4_Minus_StartTime + 400))
{
{
decrementAlarm(); // Subtract one minute
decrementAlarm(); // Subtract one minute
RedrawNow_NoFade = 1;
RedrawNow_NoFade = 1;
// TimeChanged = 1;
// TimeChanged = 1;
}
}




// Check to see if both S1 and S2 are both currently depressed:
// Check to see if both S1 and S2 are both currently depressed:
if (( buttonMonitor & a5_alarmSetBtn) && ( buttonMonitor & a5_timeSetBtn))
if (( buttonMonitor & a5_alarmSetBtn) && ( buttonMonitor & a5_timeSetBtn))
{
{
if (modeShowDateViaButtons == 0)
if (modeShowDateViaButtons == 0)
{ // Display date
{ // Display date
modeShowDateViaButtons = 1;
modeShowDateViaButtons = 1;
TimeChanged = 1; // This overrides the usual alarm on/off function of the time set button.
TimeChanged = 1; // This overrides the usual alarm on/off function of the time set button.
RedrawNow = 1;
RedrawNow = 1;
}
}
}
}






///////////////////////////// ENTERING & LEAVING LED TEST MODE /////////////////////////////
///////////////////////////// ENTERING & LEAVING LED TEST MODE /////////////////////////////
// Check to see if both S1 and S2 are both currently held down:
// Check to see if both S1 and S2 are both currently held down:
if (( buttonMonitor & a5_alarmSetBtn) && ( buttonMonitor & a5_timeSetBtn))
if (( buttonMonitor & a5_alarmSetBtn) && ( buttonMonitor & a5_timeSetBtn))
{
{
if( (milliTemp >= (Btn1_AlrmSet_StartTime + 2 * HoldDownTime )) && (milliTemp >= (Btn2_TimeSet_StartTime + 2 * HoldDownTime )))
if( (milliTemp >= (Btn1_AlrmSet_StartTime + 2 * HoldDownTime )) && (milliTemp >= (Btn2_TimeSet_StartTime + 2 * HoldDownTime )))
{
{
Btn1_AlrmSet_StartTime = milliTemp; // Reset hold-down timer
Btn1_AlrmSet_StartTime = milliTemp; // Reset hold-down timer
Btn2_TimeSet_StartTime = milliTemp; // Reset hold-down timer
Btn2_TimeSet_StartTime = milliTemp; // Reset hold-down timer
holdDebounce = 0;
holdDebounce = 0;
if (modeLEDTest) // If we are currently in the LED Test mode,
if (modeLEDTest) // If we are currently in the LED Test mode,
{
{
modeLEDTest = 0; // Exit LED Test Mode
modeLEDTest = 0; // Exit LED Test Mode
RedrawNow = 1;
RedrawNow = 1;
DisplayWord ("-END-", 1500);
DisplayWord ("-END-", 1500);
}
}
else
else
{
{
// Display version and enter LED Test Mode
// Display version and enter LED Test Mode
modeLEDTest = 1;
modeLEDTest = 1;
DisplayWordSequence(5);
DisplayWordSequence(5);
SoundSequence = 0;
SoundSequence = 0;
}
}
}
}
}
}




// Check to see if AlarmSet button was JUST released::
// Check to see if AlarmSet button was JUST released::
if ( ((buttonMonitor & a5_alarmSetBtn) == 0) && (buttonStateLast & a5_alarmSetBtn))
if ( ((buttonMonitor & a5_alarmSetBtn) == 0) && (buttonStateLast & a5_alarmSetBtn))
{
{
if (modeShowAlarmTime && holdDebounce){
if (modeShowAlarmTime && holdDebounce){
modeShowAlarmTime = 0;
modeShowAlarmTime = 0;
RedrawNow = 1;
RedrawNow = 1;
}
}


if (modeShowDateViaButtons == 1)
if (modeShowDateViaButtons == 1)
{
{
modeShowDateViaButtons = 0;
modeShowDateViaButtons = 0;
RedrawNow = 1;
RedrawNow = 1;
}
}
}
}




// If TimeSet button was just released::
// If TimeSet button was just released::
if (( (buttonMonitor & a5_timeSetBtn) == 0) && (buttonStateLast & a5_timeSetBtn))
if (( (buttonMonitor & a5_timeSetBtn) == 0) && (buttonStateLast & a5_timeSetBtn))
{
{
if (holdDebounce)
if (holdDebounce)
{
{
if ((alarmNow) || (snoozed)){ // Just Turn Off Alarm
if ((alarmNow) || (snoozed)){ // Just Turn Off Alarm
TurnOffAlarm();
TurnOffAlarm();
}
}
else if (TimeChanged == 0){ // If the time has just been adjusted, DO NOT change alarm status.
else if (TimeChanged == 0){ // If the time has just been adjusted, DO NOT change alarm status.
RedrawNow = 1;
RedrawNow = 1;
UpdateEE = 1;
UpdateEE = 1;
if (AlarmEnabled)
if (AlarmEnabled)
AlarmEnabled = 0;
AlarmEnabled = 0;
else
else
{
{
AlarmEnabled = 1;
AlarmEnabled = 1;
}
}
}
}
else
else
{
{
if (UseRTC)
if (UseRTC)
RTC.set(now());
RTC.set(now());
}
}
}
}


}
}




if (( (buttonMonitor & a5_plusBtn) == 0) && (buttonStateLast & a5_plusBtn))
if (( (buttonMonitor & a5_plusBtn) == 0) && (buttonStateLast & a5_plusBtn))
{ // The "+" button has just been released.
{ // The "+" button has just been released.
if (holdDebounce)
if (holdDebounce)
{
{
if (TimeChanged > 0)
if (TimeChanged > 0)
TimeChanged = 1; // Acknowledge that the button has been released, for purposes of time editing.
TimeChanged = 1; // Acknowledge that the button has been released, for purposes of time editing.
if (AlarmTimeChanged > 0)
if (AlarmTimeChanged > 0)
AlarmTimeChanged = 1; // Acknowledge that the button has been released, for purposes of time editing.
AlarmTimeChanged = 1; // Acknowledge that the button has been released, for purposes of time editing.


// IF no other buttons are down, increase brightness:
// IF no other buttons are down, increase brightness:
if (((buttonMonitor & a5_allButtonsButPlus) == 0) && (AlarmTimeChanged + TimeChanged == 0))
if (((buttonMonitor & a5_allButtonsButPlus) == 0) && (AlarmTimeChanged + TimeChanged == 0))
if (Brightness < BrightnessMax)
if (Brightness < BrightnessMax)
{
{
Brightness++;
Brightness++;
UpdateBrightness = 1;
UpdateBrightness = 1;
UpdateEE = 1;
UpdateEE = 1;
}
}
}
}
}
}


if (( (buttonMonitor & a5_minusBtn) == 0) && (buttonStateLast & a5_minusBtn))
if (( (buttonMonitor & a5_minusBtn) == 0) && (buttonStateLast & a5_minusBtn))
{ // The "-" Button has just been released.
{ // The "-" Button has just been released.
if (holdDebounce){
if (holdDebounce){
if (TimeChanged > 0)
if (TimeChanged > 0)
TimeChanged = 1; // Acknowledge that the button has been released, for purposes of time editing.
TimeChanged = 1; // Acknowledge that the button has been released, for purposes of time editing.
if (AlarmTimeChanged > 0)
if (AlarmTimeChanged > 0)
AlarmTimeChanged = 1; // Acknowledge that the button has been released, for purposes of time editing.
AlarmTimeChanged = 1; // Acknowledge that the button has been released, for purposes of time editing.


// IF no other buttons are down, and times have not been adjusted, decrease brightness:
// IF no other buttons are down, and times have not been adjusted, decrease brightness:
if(((buttonMonitor & a5_allButtonsButMinus) == 0) && (AlarmTimeChanged + TimeChanged == 0))
if(((buttonMonitor & a5_allButtonsButMinus) == 0) && (AlarmTimeChanged + TimeChanged == 0))
if (Brightness > 0)
if (Brightness > 0)
{
{
Brightness--;
Brightness--;
UpdateBrightness = 1;
UpdateBrightness = 1;
UpdateEE = 1;
UpdateEE = 1;
}
}
}
}
}
}
} // End not-in-config-menu statements
} // End not-in-config-menu statements






///////////////////////////// ENTERING & LEAVING CONFIG MENU /////////////////////////////
///////////////////////////// ENTERING & LEAVING CONFIG MENU /////////////////////////////


// Check to see if both S3 and S4 are both currently held down:
// Check to see if both S3 and S4 are both currently held down:
if (( buttonMonitor & a5_plusBtn) && ( buttonMonitor & a5_minusBtn))
if (( buttonMonitor & a5_plusBtn) && ( buttonMonitor & a5_minusBtn))
{
{


if( (milliTemp >= (Btn3_Plus_StartTime + HoldDownTime )) && (milliTemp >= (Btn4_Minus_StartTime + HoldDownTime )))
if( (milliTemp >= (Btn3_Plus_StartTime + HoldDownTime )) && (milliTemp >= (Btn4_Minus_StartTime + HoldDownTime )))
{
{
Btn3_Plus_StartTime = milliTemp; // Reset hold-down timer
Btn3_Plus_StartTime = milliTemp; // Reset hold-down timer
Btn4_Minus_StartTime = milliTemp; // Reset hold-down timer
Btn4_Minus_StartTime = milliTemp; // Reset hold-down timer
holdDebounce = 0;
holdDebounce = 0;
TurnOffAlarm();
TurnOffAlarm();
if (modeShowMenu) // If we are currently in the configuration menu,
if (modeShowMenu) // If we are currently in the configuration menu,
{
{
modeShowMenu = 0; // Exit configuration menu
modeShowMenu = 0; // Exit configuration menu
DisplayWord (" ", 500);
DisplayWord (" ", 500);
}
}
else
else
{
{
modeShowMenu = 1; // Enter configuration menu
modeShowMenu = 1; // Enter configuration menu
menuItem = 0;
menuItem = 0;
DisplayWord (" ", 500);
DisplayWord (" ", 500);
}
}


}
}
}
}


buttonStateLast = buttonMonitor;
buttonStateLast = buttonMonitor;
buttonMonitor = 0;
buttonMonitor = 0;
}
}
}
}




void DisplayMenuOptionName(void){
void DisplayMenuOptionName(void){
// Display title of menu name after switching to new menu utem.
// Display title of menu name after switching to new menu utem.


switch (menuItem) {
switch (menuItem) {
case NightLightMenuItem:
case NightLightMenuItem:
DisplayWordSequence(4); // Night Light
DisplayWordSequence(4); // Night Light
break;
break;
case AlarmToneMenuItem:
case AlarmToneMenuItem:
DisplayWordSequence(6); // Alarm Tone
DisplayWordSequence(6); // Alarm Tone
break;
break;
case SoundTestMenuItem:
case SoundTestMenuItem:
DisplayWordSequence(3); // Sound-test menu item, 3. Display "TEST" "SOUND" "USE+-"
DisplayWordSequence(3); // Sound-test menu item, 3. Display "TEST" "SOUND" "USE+-"
break;
break;
case numberCharSetMenuItem:
case numberCharSetMenuItem:
DisplayWordSequence(7); // Font Style
DisplayWordSequence(7); // Font Style
break;
break;
case DisplayStyleMenuItem:
case DisplayStyleMenuItem:
DisplayWordSequence(8); // Clock Style
DisplayWordSequence(8); // Clock Style
break;
break;
case SetYearMenuItem:
case SetYearMenuItem:
DisplayWord ("YEAR ", 800);
DisplayWord ("YEAR ", 800);
DisplayWordDP("___12");
DisplayWordDP("___12");
break;
break;
case SetMonthMenuItem:
case SetMonthMenuItem:
DisplayWord ("MONTH", 800);
DisplayWord ("MONTH", 800);
break;
break;
case SetDayMenuItem:
case SetDayMenuItem:
DisplayWord ("DAY ", 800);
DisplayWord ("DAY ", 800);
DisplayWordDP("__12_");
DisplayWordDP("__12_");
break;
break;
case SetSecondsMenuItem:
case SetSecondsMenuItem:
DisplayWord ("SECS ", 800);
DisplayWord ("SECS ", 800);
DisplayWordDP("___12");
DisplayWordDP("___12");
break;
break;
case AltModeMenuItem:
case AltModeMenuItem:
DisplayWordSequence(9); // "TIME AND..."
DisplayWordSequence(9); // "TIME AND..."
// DisplayWord ("ALTW/", 2000);
// DisplayWord ("ALTW/", 2000);
// DisplayWordDP("__11_");
// DisplayWordDP("__11_");
break;
break;
default: // do nothing!
default: // do nothing!
break;
break;
}
}
}
}








void ManageAlarm (void) {
void ManageAlarm (void) {


if ((SoundSequence == 0) && (modeShowMenu == 0))
if ((SoundSequence == 0) && (modeShowMenu == 0))
DisplayWord ("ALARM", 400); // Synchronize with sounds!
DisplayWord ("ALARM", 400); // Synchronize with sounds!
//RedrawNow_NoFade = 1;
//RedrawNow_NoFade = 1;


if ( (TIMSK1 & _BV(OCIE1A)) == 0) { // If last tone has finished
if ( (TIMSK1 & _BV(OCIE1A)) == 0) { // If last tone has finished


if (AlarmTone == 0) // X-Low Tone
if (AlarmTone == 0) // X-Low Tone
{
{
if (SoundSequence < 8)
if (SoundSequence < 8)
{
{
if (SoundSequence & 1)
if (SoundSequence & 1)
a5tone( 50, 300);
a5tone( 50, 300);
else
else
a5tone(0, 300);
a5tone(0, 300);
SoundSequence++;
SoundSequence++;
}
}
else
else
{
{
a5tone(0, 1200);
a5tone(0, 1200);
SoundSequence = 0;
SoundSequence = 0;
}
}
}
}
else if (AlarmTone == 1) // Low Tone
else if (AlarmTone == 1) // Low Tone
{
{
if (SoundSequence < 8)
if (SoundSequence < 8)
{
{
if (SoundSequence & 1)
if (SoundSequence & 1)
a5tone( 100, 200);
a5tone( 100, 200);
else
else
a5tone(0, 200);
a5tone(0, 200);
SoundSequence++;
SoundSequence++;
}
}
else
else
{
{
a5tone(0, 1200);
a5tone(0, 1200);
SoundSequence = 0;
SoundSequence = 0;
}
}
}
}
else if (AlarmTone == 2) // Med Tone
else if (AlarmTone == 2) // Med Tone
{
{
if (SoundSequence < 6)
if (SoundSequence < 6)
{
{
if (SoundSequence & 1)
if (SoundSequence & 1)
a5tone( 1000, 200);
a5tone( 1000, 200);
else
else
a5tone( 0, 200);
a5tone( 0, 200);
SoundSequence++;
SoundSequence++;
}
}
else
else
{
{
a5tone( 0, 1400);
a5tone( 0, 1400);
SoundSequence = 0;
SoundSequence = 0;
}
}
}
}
else if (AlarmTone == 3) // High Tone
else if (AlarmTone == 3) // High Tone
{
{
if (SoundSequence < 6)
if (SoundSequence < 6)
{
{
if (SoundSequence & 1)
if (SoundSequence & 1)
a5tone( 2050, 300);
a5tone( 2050, 300);
else
else
a5tone( 0, 200);
a5tone( 0, 200);
SoundSequence++;
SoundSequence++;
}
}
else
else
{
{
a5tone(0, 1000);
a5tone(0, 1000);
SoundSequence = 0;
SoundSequence = 0;
}
}
}
}
else if (AlarmTone == 4) // Siren Tone
else if (AlarmTone == 4) // Siren Tone
{
{
if (SoundSequence < 254)
if (SoundSequence < 254)
{
{
a5tone(20 + 4 * SoundSequence, 2);
a5tone(20 + 4 * SoundSequence, 2);
SoundSequence++;
SoundSequence++;
}
}
else if (SoundSequence == 254)
else if (SoundSequence == 254)
{
{
a5tone(20 + 4 * SoundSequence, 1500);
a5tone(20 + 4 * SoundSequence, 1500);
SoundSequence++;
SoundSequence++;
}
}
else {
else {
a5tone(0, 1000);
a5tone(0, 1000);
SoundSequence = 0;
SoundSequence = 0;
}
}
}
}
else if (AlarmTone == 5) // "Tink" Tone
else if (AlarmTone == 5) // "Tink" Tone
{
{
if (SoundSequence == 0)
if (SoundSequence == 0)
{
{
a5tone( 1000, 50); // was 50
a5tone( 1000, 50); // was 50
SoundSequence++;
SoundSequence++;
}
}
else if (SoundSequence == 1)
else if (SoundSequence == 1)
{
{
a5tone(0, 1900);
a5tone(0, 1900);
SoundSequence++;
SoundSequence++;
}
}
else
else
{
{
a5tone(0, 50);
a5tone(0, 50);
SoundSequence = 0;
SoundSequence = 0;
}
}
}
}
}
}
}
}


char wordOut[5];


void GetWordStep(char WordIn[], int length, int wordStep) {
unsigned int wordSize = length;
int tempWordSize = wordSize + 8;
char tempWord[tempWordSize];
for(int i = 0; i < tempWordSize; i++) {
if(i < 4 || i >= wordSize+4) {
tempWord[i] = ' ';
} else {
tempWord[i] = WordIn[i-4];
}
}


wordOut[0] = tempWord[wordStep-1];
wordOut[1] = tempWord[wordStep];
wordOut[2] = tempWord[wordStep+1];
wordOut[3] = tempWord[wordStep+2];
wordOut[4] = tempWord[wordStep+3];
}




void DisplayWordSequence (byte sequence)
void DisplayWordSequence (byte sequence)
{ // Usage: // DisplayWordSequence(1); // displays "HELLO" "WORLD"
{ // Usage: // DisplayWordSequence(1); // displays "HELLO" "WORLD"


if (sequence != wordSequence)
if (sequence != wordSequence)
{
{
wordSequence = sequence;
wordSequence = sequence;
wordSequenceStep = 0;
wordSequenceStep = 0;
}
}


DisplayWordDP("_____"); // Blank DPs unless stated otherwise.
DisplayWordDP("_____"); // Blank DPs unless stated otherwise.
wordSequenceStep++;
wordSequenceStep++;


switch (sequence) {
switch (sequence) {
case 1: //Display "HELLO" "WORLD"
case 1: //Display "HELLO" "WORLD"
if (wordSequenceStep == 1)
if (wordSequenceStep >= 1 && wordSequenceStep < 16){
DisplayWord ("HELLO", 800);
GetWordStep("HELLO WORLD", 11, wordSequenceStep);
else if (wordSequenceStep == 3)
DisplayWord(wordOut, 500);
DisplayWord ("WORLD", 800);
}
else if (wordSequenceStep < 5)
DisplayWord (" ", 300);
else
else
wordSequence = 0;
wordSequence = 0;
break;
break;
case 2: //Display "ALARM" " OFF "
case 2: //Display "ALARM" " OFF "
if (wordSequenceStep == 1)
if (wordSequenceStep == 1)
DisplayWord ("ALARM", 800);
DisplayWord ("ALARM", 800);
else if (wordSequenceStep == 3)
else if (wordSequenceStep == 3)
DisplayWord (" OFF ", 800);
DisplayWord (" OFF ", 800);
else if (wordSequenceStep < 5)
else if (wordSequenceStep < 5)
DisplayWord (" ", 100);
DisplayWord (" ", 100);
else
else
wordSequence = 0;
wordSequence = 0;
break;
break;
case 3: //Display "TEST" "SOUND" "USE+-"
case 3: //Display "TEST" "SOUND" "USE+-"
if (wordSequenceStep == 1)
if (wordSequenceStep == 1)
DisplayWord ("TEST ", 600);
DisplayWord ("TEST ", 600);
else if (wordSequenceStep == 3)
else if (wordSequenceStep == 3)
DisplayWord ("SOUND", 600);
DisplayWord ("SOUND", 600);
else if (wordSequenceStep == 5)
else if (wordSequenceStep == 5)
DisplayWord ("USE+-", 600);
DisplayWord ("USE+-", 600);
else if (wordSequenceStep < 7)
else if (wordSequenceStep < 7)
DisplayWord (" ", 200);
DisplayWord (" ", 200);
else
else
wordSequence = 0;
wordSequence = 0;
break;
break;
case 4: //Display "NIGHT" "LIGHT"
case 4: //Display "NIGHT" "LIGHT"
if (wordSequenceStep == 1)
if (wordSequenceStep == 1)
DisplayWord ("NIGHT", 600);
DisplayWord ("NIGHT", 600);
else if (wordSequenceStep == 3)
else if (wordSequenceStep == 3)
DisplayWord ("LIGHT", 600);
DisplayWord ("LIGHT", 600);
else if (wordSequenceStep < 5)
else if (wordSequenceStep < 5)
DisplayWord (" ", 100);
DisplayWord (" ", 100);
else
else
wordSequence = 0;
wordSequence = 0;
break;
break;
case 5: //Display "VER21" " LED " "TEST " // Display software version number, 2.1
case 5: //Display "VER21" " LED " "TEST " // Display software version number, 2.1


if (wordSequenceStep == 1){
if (wordSequenceStep == 1){
DisplayWord ("VER21", 2000);
DisplayWord ("VER21", 2000);
DisplayWordDP("___1_");
DisplayWordDP("___1_");
}
}
else if (wordSequenceStep == 3)
else if (wordSequenceStep == 3)
DisplayWord (" LED ", 1000);
DisplayWord (" LED ", 1000);
else if (wordSequenceStep == 5)
else if (wordSequenceStep == 5)
DisplayWord ("TEST ", 1000);
DisplayWord ("TEST ", 1000);
else if (wordSequenceStep < 7)
else if (wordSequenceStep < 7)
DisplayWord (" ", 200);
DisplayWord (" ", 200);
else
else
wordSequence = 0;
wordSequence = 0;
break;
break;
case 6: //Display "ALARM" "TONE"
case 6: //Display "ALARM" "TONE"
if (wordSequenceStep == 1)
if (wordSequenceStep == 1)
DisplayWord ("ALARM", 700);
DisplayWord ("ALARM", 700);
else if (wordSequenceStep == 3)
else if (wordSequenceStep == 3)
DisplayWord (" TONE", 700);
DisplayWord (" TONE", 700);
else if (wordSequenceStep < 5)
else if (wordSequenceStep < 5)
DisplayWord (" ", 100);
DisplayWord (" ", 100);
else
else
wordSequence = 0;
wordSequence = 0;
break;
break;


case 7: //Display "FONT " "STYLE"
case 7: //Display "FONT " "STYLE"
if (wordSequenceStep == 1)
if (wordSequenceStep == 1)
DisplayWord ("FONT ", 700);
DisplayWord ("FONT ", 700);
else if (wordSequenceStep == 3)
else if (w
DisplayWord ("STYLE", 700);
else if (wordSequenceStep < 5)
DisplayWord (" ", 100);
else
wordSequence = 0;
break;

case 8: //Display "CLOCK" "STYLE"
if (wordSequenceStep == 1)
DisplayWord ("CLOCK", 700);
else if (wordSequenceStep == 3)
DisplayWord ("STYLE", 700);
else if (wordSequenceStep < 5)
DisplayWord (" ", 100);
else
wordSequence = 0;
break;
case 9: /