void KEYS::enableInterrupt(uint8_t pin, void(*selfCheckFunction)(void)) { _pcintPin = pin; #if ARDUINO >= 100 ::pinMode(pin, INPUT_PULLUP); #else ::pinMode(pin, INPUT); ::digitalWrite(pin, HIGH); #endif PCattachInterrupt(pin, selfCheckFunction, FALLING); }
void PCF8574::enableInterrupt(uint8_t pin, void (*selfCheckFunction)(void)) { /* Store interrupt pin number */ _pcintPin = pin; /* Setup interrupt pin */ #if ARDUINO >= 100 ::pinMode(pin, INPUT_PULLUP); // /!\ pinMode form THE ARDUINO CORE #else ::pinMode(pin, INPUT); // /!\ pinMode form THE ARDUINO CORE ::digitalWrite(pin, HIGH); // /!\ digitalWrite form THE ARDUINO CORE #endif /* Attach interrupt handler */ PCattachInterrupt(pin, selfCheckFunction, FALLING); }
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 ); }
void PCF8574::enableInterrupt(int pin,void(* selfCheckFunction)(void)){ PCFIntPin = pin; pinMode(PCFIntPin,INPUT); PCattachInterrupt(PCFIntPin,selfCheckFunction,FALLING); }