void do_setup() { initialiseEpoch(); // initialize time reference for millis() and micros() os.begin(); // OpenSprinkler init os.options_setup(); // Setup options pd.init(); // ProgramData init if (os.start_network()) { // initialize network DEBUG_PRINTLN("network established."); os.status.network_fails = 0; } else { DEBUG_PRINTLN("network failed."); os.status.network_fails = 1; } os.status.req_network = 0; }
// ====================== // Setup Function // ====================== void do_setup() { /* Clear WDT reset flag. */ MCUSR &= ~(1<<WDRF); DEBUG_BEGIN(9600); DEBUG_PRINTLN("started."); os.begin(); // OpenSprinkler init os.options_setup(); // Setup options pd.init(); // ProgramData init setSyncInterval(RTC_SYNC_INTERVAL); // RTC sync interval // if rtc exists, sets it as time sync source setSyncProvider(RTC.get); os.lcd_print_time(os.now_tz()); // display time to LCD // enable WDT /* In order to change WDE or the prescaler, we need to * set WDCE (This will allow updates for 4 clock cycles). */ WDTCSR |= (1<<WDCE) | (1<<WDE); /* set new watchdog timeout prescaler value */ WDTCSR = 1<<WDP3 | 1<<WDP0; // 8.0 seconds /* Enable the WD interrupt (note no reset). */ WDTCSR |= _BV(WDIE); if (os.start_network()) { // initialize network os.status.network_fails = 0; } else { os.status.network_fails = 1; } os.status.req_network = 0; os.status.req_ntpsync = 1; os.apply_all_station_bits(); // reset station bits os.button_timeout = LCD_BACKLIGHT_TIMEOUT; }