void initialize(void) { // read eeprom g_24h_clock = eeprom_read_byte(&b_24h_clock); g_show_temp = eeprom_read_byte(&b_show_temp); g_brightness = eeprom_read_byte(&b_brightness); g_volume = eeprom_read_byte(&b_volume); PIEZO_DDR |= _BV(PIEZO_LOW_BIT); PIEZO_DDR |= _BV(PIEZO_HIGH_BIT); PIEZO_LOW_OFF; PIEZO_HIGH_OFF; // Set buttons as inputs BUTTON_DDR &= ~(_BV(BUTTON1_BIT)); BUTTON_DDR &= ~(_BV(BUTTON2_BIT)); SWITCH_DDR &= ~(_BV(SWITCH_BIT)); // Enable pullups for buttons BUTTON_PORT |= _BV(BUTTON1_BIT); BUTTON_PORT |= _BV(BUTTON2_BIT); SWITCH_PORT |= _BV(SWITCH_BIT); LED_DDR |= _BV(LED_BIT); // indicator led for (int i = 0; i < 5; i++) { LED_HIGH; _delay_ms(100); LED_LOW; _delay_ms(100); } sei(); twi_init_master(); rtc_init(); rtc_set_ds1307(); //rtc_set_time_s(16, 59, 50); //rtc_set_alarm_s(17,0,0); display_init(g_brightness); g_alarm_switch = get_alarm_switch(); // set up interrupt for alarm switch PCICR |= (1 << PCIE2); PCMSK2 |= (1 << PCINT18); }
void initialize(void) { PIEZO_DDR |= _BV(PIEZO_LOW_BIT); PIEZO_DDR |= _BV(PIEZO_HIGH_BIT); PIEZO_LOW_OFF; PIEZO_HIGH_OFF; // Set buttons as inputs BUTTON_DDR &= ~(_BV(BUTTON1_BIT)); BUTTON_DDR &= ~(_BV(BUTTON2_BIT)); SWITCH_DDR &= ~(_BV(SWITCH_BIT)); // Enable pullups for buttons BUTTON_PORT |= _BV(BUTTON1_BIT); BUTTON_PORT |= _BV(BUTTON2_BIT); SWITCH_PORT |= _BV(SWITCH_BIT); LED_DDR |= _BV(LED_BIT); // indicator led for (int i = 0; i < 5; i++) { LED_HIGH; _delay_ms(100); LED_LOW; _delay_ms(100); } sei(); twi_init_master(); rtc_init(); rtc_set_ds1307(); //rtc_set_time_s(16, 59, 50); //rtc_set_alarm_s(17,0,0); piezo_init(); beep(440, 1); globals_init(); display_init(g_brightness); g_alarm_switch = get_alarm_switch(); #ifdef FEATURE_FLW g_has_eeprom = has_eeprom(); // if (!g_has_eeprom) beep(440,2); // debug if (!g_has_eeprom) g_flw_enabled = false; if (tm_ && g_has_eeprom) seed_random(tm_->Hour * 10000 + tm_->Minute + 100 + tm_->Second); #endif beep(1320, 1); menu_init(); // must come after display, flw init rtc_get_alarm_s(&alarm_hour, &alarm_min, &alarm_sec); // set up interrupt for alarm switch PCICR |= (1 << PCIE2); PCMSK2 |= (1 << PCINT18); #ifdef FEATURE_WmGPS // setup uart for GPS gps_init(g_gps_enabled); #endif #ifdef FEATURE_AUTO_DST if (g_DST_mode) DSTinit(tm_, g_DST_Rules); // re-compute DST start, end #endif }