diff --git a/src/knx_facade.h b/src/knx_facade.h index d059a17..5328ac9 100644 --- a/src/knx_facade.h +++ b/src/knx_facade.h @@ -31,7 +31,7 @@ template class KnxFacade : private SaveRestore manufacturerId(0xfa); _bau.addSaveRestore(this); } - + virtual ~KnxFacade() { if (_bauPtr) @@ -61,27 +61,27 @@ template class KnxFacade : private SaveRestore { return _bau.enabled(); } - + void enabled(bool value) { _bau.enabled(true); } - + bool progMode() { return _bau.deviceObject().progMode(); } - + void progMode(bool value) { _bau.deviceObject().progMode(value); } - + bool configured() { return _bau.configured(); } - + /** * returns HIGH if led is active on HIGH, LOW otherwise */ @@ -89,7 +89,7 @@ template class KnxFacade : private SaveRestore { return _ledPinActiveOn; } - + /** * Sets if the programming led is active on HIGH or LOW. * @@ -99,42 +99,60 @@ template class KnxFacade : private SaveRestore { _ledPinActiveOn = value; } - + uint32_t ledPin() { return _ledPin; } - + void ledPin(uint32_t value) { _ledPin = value; } - + + /** + * returns RISING if interrupt is created in a rising signal, FALLING otherwise + */ + uint32_t buttonPinInterruptOn() + { + return _buttonPinInterruptOn; + } + + /** + * Sets if the programming button creates a RISING or a FALLING signal. + * + * Set to RISING for GPIO--BUTTON--VDD or to FALLING for GPIO--BUTTON--GND + */ + void buttonPinInterruptOn(uint32_t value) + { + _buttonPinInterruptOn = value; + } + uint32_t buttonPin() { return _buttonPin; } - + void buttonPin(uint32_t value) { _buttonPin = value; } - + void readMemory() { _bau.readMemory(); } - + void writeMemory() { _bau.writeMemory(); } - + uint16_t induvidualAddress() { return _bau.deviceObject().induvidualAddress(); } - + void loop() { if (progMode() != _progLedState) @@ -158,32 +176,32 @@ template class KnxFacade : private SaveRestore } _bau.loop(); } - + void manufacturerId(uint16_t value) { _bau.deviceObject().manufacturerId(value); } - + void bauNumber(uint32_t value) { _bau.deviceObject().bauNumber(value); } - + void orderNumber(const char* value) { _bau.deviceObject().orderNumber(value); } - + void hardwareType(uint8_t* value) { _bau.deviceObject().hardwareType(value); } - + void version(uint16_t value) { _bau.deviceObject().version(value); } - + void start() { pinMode(_ledPin, OUTPUT); @@ -192,20 +210,20 @@ template class KnxFacade : private SaveRestore pinMode(_buttonPin, INPUT_PULLUP); - attachInterrupt(_buttonPin, buttonUp, RISING); + attachInterrupt(_buttonPin, buttonUp, _buttonPinInterruptOn); enabled(true); } - + void setSaveCallback(saveRestoreCallback func) { _saveCallback = func; } - + void setRestoreCallback(saveRestoreCallback func) { _restoreCallback = func; } - + uint8_t* paramData(uint32_t addr) { if (!_bau.configured()) @@ -213,7 +231,7 @@ template class KnxFacade : private SaveRestore return _bau.parameters().data(addr); } - + uint8_t paramByte(uint32_t addr) { if (!_bau.configured()) @@ -229,7 +247,7 @@ template class KnxFacade : private SaveRestore return _bau.parameters().getWord(addr); } - + uint32_t paramInt(uint32_t addr) { if (!_bau.configured()) @@ -237,12 +255,12 @@ template class KnxFacade : private SaveRestore return _bau.parameters().getInt(addr); } - + GroupObject& getGroupObject(uint16_t goNr) { return _bau.groupObjectTable().get(goNr); } - + void restart(uint16_t individualAddress) { _bau.restartRequest(individualAddress); @@ -252,14 +270,15 @@ template class KnxFacade : private SaveRestore P* _platformPtr = 0; B* _bauPtr = 0; B& _bau; - uint32_t _ledPinActiveOn = LOW; + uint32_t _ledPinActiveOn = LOW; uint32_t _ledPin = LED_BUILTIN; + uint32_t _buttonPinInterruptOn = RISING; uint32_t _buttonPin = 0; saveRestoreCallback _saveCallback = 0; saveRestoreCallback _restoreCallback = 0; bool _toogleProgMode = false; bool _progLedState = false; - + uint8_t* save(uint8_t* buffer) { if (_saveCallback != 0) @@ -267,7 +286,7 @@ template class KnxFacade : private SaveRestore return buffer; } - + uint8_t* restore(uint8_t* buffer) { if (_restoreCallback != 0)