PROGMEM prog_char month_00[]="JAN";
PROGMEM prog_char month_01[]="FEB";
PROGMEM prog_char month_02[]="MAR";
PROGMEM prog_char month_03[]="APR";
PROGMEM prog_char month_04[]="MAY";
PROGMEM prog_char month_05[]="JUN";
PROGMEM prog_char month_06[]="JUL";
PROGMEM prog_char month_07[]="AUG";
PROGMEM prog_char month_08[]="SEP";
PROGMEM prog_char month_09[]="OCT";
PROGMEM prog_char month_10[]="NOV";
PROGMEM prog_char month_11[]="DEC";
PROGMEM const char *month_items[]= {month_00,month_01,month_02,month_03,month_04,month_05,month_06,month_07,month_08,month_09,month_10,month_11};
PROGMEM prog_char dow_00[]="SUN";
PROGMEM prog_char dow_01[]="MON";
PROGMEM prog_char dow_02[]="TUE";
PROGMEM prog_char dow_03[]="WED";
PROGMEM prog_char dow_04[]="THU";
PROGMEM prog_char dow_05[]="FRI";
PROGMEM prog_char dow_06[]="SAT";
PROGMEM const char *dow_items[]= {dow_00,dow_01,dow_02,dow_03,dow_04,dow_05,dow_06};
PROGMEM prog_char alarm_00[]="Off";
PROGMEM prog_char alarm_01[]="Daily";
PROGMEM prog_char alarm_02[]="Weekday";
PROGMEM prog_char alarm_03[]="Weekend";
PROGMEM prog_char alarm_04[]="Once";
PROGMEM const char *alarm_items[]= {alarm_00,alarm_01,alarm_02,alarm_03,alarm_04};
PROGMEM prog_char lcd_chr0[]={64,64,64,64,64,64,64,64,0};// 0
PROGMEM prog_char lcd_chr1[]={64,64,64,64,64,31,31,31,0};//1
PROGMEM prog_char lcd_chr2[]={64,64,64,31,31,64,64,64,0};//2
PROGMEM prog_char lcd_chr3[]={64,64,64,31,31,31,31,31,0};//3 {64,64,64,31,31,64,31,31,0};
PROGMEM prog_char lcd_chr4[]={31,31,31,64,64,64,64,64,0};//4
PROGMEM prog_char lcd_chr5[]={31,31,64,64,64,31,31,31,0};//5
PROGMEM prog_char lcd_chr6[]={31,31,31,31,31,64,64,64,0};//6 {31,31,64,31,31,64,64,64,0}
PROGMEM prog_char lcd_chr7[]={31,31,31,31,31,31,31,31,0};//7 {31,31,64,31,31,64,31,31,0}
PROGMEM const char *chr_item[] = {lcd_chr0, lcd_chr1, lcd_chr2, lcd_chr3, lcd_chr4, lcd_chr5, lcd_chr6, lcd_chr7};// The following lines instantiates a button group to control 6 buttons
byte pins[]={btn_u,btn_d,btn_l,btn_r,btn_b,btn_a}; // The digital pins connected to the 6 buttons.
char mapping[]={'U','D','L','R','B','A'}; // This is a list of names for each button.
phi_button_groups my_btns(mapping, pins, total_buttons);
// This serial keypad is for debugging.
phi_serial_keypads debug_keypad(&Serial,115200);
// The following sets up function keys for phi_prompt library
char up_keys[]={"U"}; ///< All keys that act as the up key are listed here.
char down_keys[]={"D"}; ///< All keys that act as the down key are listed here.
char left_keys[]={"L"}; ///< All keys that act as the left key are listed here.
char right_keys[]={"R"}; ///< All keys that act as the right key are listed here.
char enter_keys[]={"B"}; ///< All keys that act as the enter key are listed here.
char escape_keys[]={"A"}; ///< All keys that act as the escape key are listed here.
char * function_keys[]={up_keys,down_keys,left_keys,right_keys,enter_keys,escape_keys}; ///< All function key names are gathered here fhr phi_prompt.
// The following adds all available keypads as inputs for phi_prompt library
multiple_button_input * keypads[]={&my_btns,&debug_keypad,0};
LiquidCrystal lcd(LCD_RS,LCD_EN,LCD_D4,LCD_D5,LCD_D6,LCD_D7); // Create the lcd object
int rtc[7];
DS1307 RTC=DS1307(); // Create RTC object
alarm_clock clock1(false); // Create an alarm clock
void setup()
{
byte ch_buffer[10]; // This buffer is required for custom characters on the LCD.
lcd.begin(lcd_columns, lcd_rows);
Wire.begin(); // initialize wire
init_phi_prompt(&lcd,keypads,function_keys, lcd_columns, lcd_rows, '~'); // Supply the liquid crystal object, input keypads, and function key names. Also supply the column and row of the lcd, and indicator as '>'. You can also use '\x7e', which is a right arrow.
init_big_font(&lcd);
// Set the two channels to output to drive the buzzer and LED.
pinMode(buzzer,OUTPUT);
digitalWrite(buzzer,LOW);
#ifdef setRTC
// Set/init RTC
RTC.stop();
RTC.set(DS1307_SEC,0);
RTC.set(DS1307_MIN,50);
RTC.set(DS1307_HR,0);
RTC.set(DS1307_DOW,3); // value from 1 to 7. User define whether 1 is sun or mon.
RTC.set(DS1307_DATE,16);
RTC.set(DS1307_MTH,11);
RTC.set(DS1307_YR,10);
RTC.start();
//Set alarms
EEPROM.write(alarm_EEPROM_storage,6); // Alarm 0 hour
EEPROM.write(alarm_EEPROM_storage+1,50); // Alarm 0 minute
EEPROM.write(alarm_EEPROM_storage+2,2); // Alarm 0 frequency M-F
EEPROM.write(alarm_EEPROM_storage+3,7); // Alarm 1 hour
EEPROM.write(alarm_EEPROM_storage+4,00); // Alarm 1 minute
EEPROM.write(alarm_EEPROM_storage+5,2); // Alarm 1 frequency M-F
EEPROM.write(alarm_EEPROM_storage+6,7); // Alarm 2 hour
EEPROM.write(alarm_EEPROM_storage+7,10); // Alarm 2 minute
EEPROM.write(alarm_EEPROM_storage+8,2); // Alarm 2 frequency M-F
EEPROM.write(alarm_EEPROM_storage+9,9); // Alarm 3 hour
EEPROM.write(alarm_EEPROM_storage+10,30); // Alarm 3 minute
EEPROM.write(alarm_EEPROM_storage+11,3); // Alarm 3 frequency Weekend
#else
// Set alarm on the clock from EEPROM.
clock1.set_alarm(0, EEPROM.read(alarm_EEPROM_storage), EEPROM.read(alarm_EEPROM_storage+1), EEPROM.read(alarm_EEPROM_storage+2));
clock1.set_alarm(1, EEPROM.read(alarm_EEPROM_storage+3), EEPROM.read(alarm_EEPROM_storage+4), EEPROM.read(alarm_EEPROM_storage+5));
clock1.set_alarm(2, EEPROM.read(alarm_EEPROM_storage+6), EEPROM.read(alarm_EEPROM_storage+7), EEPROM.read(alarm_EEPROM_storage+8));
clock1.set_alarm(3, EEPROM.read(alarm_EEPROM_storage+9), EEPROM.read(alarm_EEPROM_storage+10), EEPROM.read(alarm_EEPROM_storage+11));
#endif
show_credit();
}
void loop()
{
top_menu(); // See Example_menu.pde
}
void show_credit()
{
// Display credits
phi_prompt_struct myLongMsg;
lcd.clear();
lcd.noBlink();
myLongMsg.ptr.msg_P=msg_00; // Assign the address of the text string to the pointer.
myLongMsg.low.i=0; // Default text starting position. 0 is highly recommended.
myLongMsg.high.i=strlen_P(msg_00); // Position of the last character in the text string, which is size of the string - 1.
myLongMsg.step.c_arr[0]=lcd_rows; // rows to auto fit entire screen
myLongMsg.step.c_arr[1]=lcd_columns; // one col list
myLongMsg.col=0; // Display the text area starting at column 0
myLongMsg.row=0; // Display the text area starting at row 0
myLongMsg.option=0; // Option 0, display classic message, option 1, display message with scroll bar on right.
text_area_P(&myLongMsg);
}