void setup() { ebox_init(); uart3.begin(9600); ds.begin(400000); t.year = 15; t.month = 7; t.date = 3; t.hour = 23; t.min = 59; t.sec = 55; }
void WeatherStation::init( DataConfig *p_dataConfig, uint8_t dataNum ) { uint8_t i, index; DataConfig *p_dataConfigRecord = NULL; /**init config table**/ p_dataConfigRecord = p_dataConfig; index = 0; DBG_PRINTLN("measure table:"); for( i = 0; i < dataNum; i++ ) { a_measureData[index].p_sensor = sensorMgt.creatObject( p_dataConfigRecord->sensorID, p_dataConfigRecord->attachPin, p_dataConfigRecord->auxiliaryPin ); if ( NULL == a_measureData[index].p_sensor ) { String info; info = "Error: Rule No."; info += (i+1); showErrInfo( info ); break; } a_measureData[index].dataType = p_dataConfigRecord->type; a_measureData[index].valid = true; dataHouse.addDataTypeIndex(a_measureData[index].dataType); DBG_PRINTLN_VAR(index, DEC); DBG_PRINTLN_VAR((word)a_measureData[index].p_sensor, HEX); index++; p_dataConfigRecord++; } measureNum = index; //todo enable power digitalWrite( PALETTE_PIN_MVCC, LOW ); pinMode( PALETTE_PIN_MVCC, OUTPUT ); delay(500); //waiting power stable /**init devices**/ Wire.begin(); RTCObj.begin(); lcd.init(); lcd.backlight(); setCurrentDate(); dataHouse.init( currentYear, currentMonth, currentDate, currentHour ); sensorMgt.start(); /**get the state of Switch**/ pinMode(PALETTE_PIN_SW, INPUT_PULLUP); switchState = digitalRead(PALETTE_PIN_SW); /**attach interrupt**/ pinMode(STAION_PIN_RTC_INT, INPUT_PULLUP); pinMode(STAION_PIN_BUTTON, INPUT ); PCattachInterrupt( STAION_PIN_RTC_INT ); PCattachInterrupt( STAION_PIN_BUTTON ); RTCObj.clearINTStatus(); #if _DEBUG RTCObj.enableInterrupts(EveryMinute); #else RTCObj.enableInterrupts(EveryHour); #endif /**Start**/ pinMode(PALETTE_PIN_BLK, OUTPUT); digitalWrite(PALETTE_PIN_BLK,HIGH); startTime = (uint8_t)(millis()/1000); /**emulate pushing button**/ setEvent( STAION_PIN_BUTTON ); }