Progbutton interrupt (#35)

* corrected float with DPT9

* Switch Programming-LED also via Bus/ETS

* Again: Prog-LED switchable from bus/ETS

* DPT16 (to bus) implemented

* - Allows ProgButton interrupts on FALLING signal
This commit is contained in:
mumpf 2019-09-14 18:24:34 +02:00 committed by thelsing
parent 6c3bbfe5a5
commit 4a0b46e062

View File

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