mirror of
https://github.com/thelsing/knx.git
synced 2025-08-26 13:51:28 +02:00
Update knx_facade.cpp
This commit is contained in:
parent
fc2ebf96f2
commit
718b8892be
@ -1,53 +1,43 @@
|
|||||||
#include "knx_facade.h"
|
#include "knx_facade.h"
|
||||||
#include "knx/bits.h"
|
|
||||||
|
|
||||||
// definition for connecting the led of the different boards
|
|
||||||
// for example the circuit on WeMos D1 R2 board --> GPIO--RESISTOR--LED--GND (high active)
|
|
||||||
// for example the circuit on NODE MCU board --> GPIO--LED--RESISTOR--VDD (low active)
|
|
||||||
|
|
||||||
//#define LED_PIN_HIGH_ACTIVE
|
|
||||||
#define LED_PIN_LOW_ACTIVE
|
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_SAMD
|
#ifdef ARDUINO_ARCH_SAMD
|
||||||
SamdPlatform platform;
|
SamdPlatform platform;
|
||||||
Bau07B0 bau(platform);
|
Bau07B0 bau(platform);
|
||||||
#elif ARDUINO_ARCH_ESP8266
|
#else
|
||||||
EspPlatform platform;
|
EspPlatform platform;
|
||||||
Bau57B0 bau(platform);
|
Bau57B0 bau(platform);
|
||||||
#elif __linux__ //linux
|
|
||||||
// noops on linux
|
|
||||||
#define digitalWrite(a, b)
|
|
||||||
#define pinMode(a, b)
|
|
||||||
#define attachInterrupt(a, b, c)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __linux__
|
|
||||||
KnxFacade knx(bau);
|
KnxFacade knx(bau);
|
||||||
|
|
||||||
|
#include "knx/bits.h"
|
||||||
|
|
||||||
void buttonUp()
|
void buttonUp()
|
||||||
{
|
{
|
||||||
if (knx.progMode())
|
if (knx.progMode())
|
||||||
{
|
{
|
||||||
#ifdef LED_PIN_HIGH_ACTIVE
|
if (knx.ledPinActiveOn())
|
||||||
digitalWrite(knx.ledPin(), HIGH);
|
{
|
||||||
#endif
|
digitalWrite(knx.ledPin(), HIGH);
|
||||||
#ifdef LED_PIN_LOW_ACTIVE
|
}
|
||||||
digitalWrite(knx.ledPin(), LOW);
|
else
|
||||||
#endif
|
{
|
||||||
|
digitalWrite(knx.ledPin(), LOW);
|
||||||
|
}
|
||||||
knx.progMode(false);
|
knx.progMode(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef LED_PIN_HIGH_ACTIVE
|
if (knx.ledPinActiveOn())
|
||||||
digitalWrite(knx.ledPin(), LOW);
|
{
|
||||||
#endif
|
digitalWrite(knx.ledPin(), LOW);
|
||||||
#ifdef LED_PIN_LOW_ACTIVE
|
}
|
||||||
digitalWrite(knx.ledPin(), HIGH);
|
else
|
||||||
#endif
|
{
|
||||||
|
digitalWrite(knx.ledPin(), HIGH);
|
||||||
|
}
|
||||||
knx.progMode(true);
|
knx.progMode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
KnxFacade::KnxFacade(BauSystemB& bau) : _bau(bau)
|
KnxFacade::KnxFacade(BauSystemB& bau) : _bau(bau)
|
||||||
{
|
{
|
||||||
@ -72,12 +62,14 @@ bool KnxFacade::progMode()
|
|||||||
|
|
||||||
void KnxFacade::progMode(bool value)
|
void KnxFacade::progMode(bool value)
|
||||||
{
|
{
|
||||||
print("progmode ");
|
if (value)
|
||||||
if (value)
|
{
|
||||||
println("on");
|
println("progmode on");
|
||||||
else
|
}
|
||||||
println("off");
|
else
|
||||||
|
{
|
||||||
|
println("progmode off");
|
||||||
|
}
|
||||||
_bau.deviceObject().progMode(value);
|
_bau.deviceObject().progMode(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +78,16 @@ bool KnxFacade::configured()
|
|||||||
return _bau.configured();
|
return _bau.configured();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KnxFacade::ledPinActiveOn()
|
||||||
|
{
|
||||||
|
return _ledPinActiveOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KnxFacade::ledPinActiveOn(bool value)
|
||||||
|
{
|
||||||
|
_ledPinActiveOn = value;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t KnxFacade::ledPin()
|
uint32_t KnxFacade::ledPin()
|
||||||
{
|
{
|
||||||
return _ledPin;
|
return _ledPin;
|
||||||
@ -131,11 +133,6 @@ void KnxFacade::bauNumber(uint32_t value)
|
|||||||
_bau.deviceObject().bauNumber(value);
|
_bau.deviceObject().bauNumber(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t KnxFacade::induvidualAddress()
|
|
||||||
{
|
|
||||||
return _bau.deviceObject().induvidualAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KnxFacade::orderNumber(const char* value)
|
void KnxFacade::orderNumber(const char* value)
|
||||||
{
|
{
|
||||||
_bau.deviceObject().orderNumber(value);
|
_bau.deviceObject().orderNumber(value);
|
||||||
@ -155,6 +152,15 @@ void KnxFacade::start()
|
|||||||
{
|
{
|
||||||
pinMode(_ledPin, OUTPUT);
|
pinMode(_ledPin, OUTPUT);
|
||||||
|
|
||||||
|
if (knx.ledPinActiveOn())
|
||||||
|
{
|
||||||
|
digitalWrite(_ledPin, HIGH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
digitalWrite(_ledPin, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
pinMode(_buttonPin, INPUT_PULLUP);
|
pinMode(_buttonPin, INPUT_PULLUP);
|
||||||
|
|
||||||
attachInterrupt(_buttonPin, buttonUp, RISING);
|
attachInterrupt(_buttonPin, buttonUp, RISING);
|
||||||
|
Loading…
Reference in New Issue
Block a user