mirror of
https://github.com/thelsing/knx.git
synced 2025-08-13 13:46:20 +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/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
|
||||
SamdPlatform platform;
|
||||
Bau07B0 bau(platform);
|
||||
#elif ARDUINO_ARCH_ESP8266
|
||||
#else
|
||||
EspPlatform platform;
|
||||
Bau57B0 bau(platform);
|
||||
#elif __linux__ //linux
|
||||
// noops on linux
|
||||
#define digitalWrite(a, b)
|
||||
#define pinMode(a, b)
|
||||
#define attachInterrupt(a, b, c)
|
||||
#endif
|
||||
|
||||
#ifndef __linux__
|
||||
KnxFacade knx(bau);
|
||||
|
||||
#include "knx/bits.h"
|
||||
|
||||
void buttonUp()
|
||||
{
|
||||
if (knx.progMode())
|
||||
{
|
||||
#ifdef LED_PIN_HIGH_ACTIVE
|
||||
digitalWrite(knx.ledPin(), HIGH);
|
||||
#endif
|
||||
#ifdef LED_PIN_LOW_ACTIVE
|
||||
digitalWrite(knx.ledPin(), LOW);
|
||||
#endif
|
||||
if (knx.ledPinActiveOn())
|
||||
{
|
||||
digitalWrite(knx.ledPin(), HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(knx.ledPin(), LOW);
|
||||
}
|
||||
knx.progMode(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef LED_PIN_HIGH_ACTIVE
|
||||
digitalWrite(knx.ledPin(), LOW);
|
||||
#endif
|
||||
#ifdef LED_PIN_LOW_ACTIVE
|
||||
digitalWrite(knx.ledPin(), HIGH);
|
||||
#endif
|
||||
if (knx.ledPinActiveOn())
|
||||
{
|
||||
digitalWrite(knx.ledPin(), LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(knx.ledPin(), HIGH);
|
||||
}
|
||||
knx.progMode(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
KnxFacade::KnxFacade(BauSystemB& bau) : _bau(bau)
|
||||
{
|
||||
@ -72,12 +62,14 @@ bool KnxFacade::progMode()
|
||||
|
||||
void KnxFacade::progMode(bool value)
|
||||
{
|
||||
print("progmode ");
|
||||
if (value)
|
||||
println("on");
|
||||
else
|
||||
println("off");
|
||||
|
||||
if (value)
|
||||
{
|
||||
println("progmode on");
|
||||
}
|
||||
else
|
||||
{
|
||||
println("progmode off");
|
||||
}
|
||||
_bau.deviceObject().progMode(value);
|
||||
}
|
||||
|
||||
@ -86,6 +78,16 @@ bool KnxFacade::configured()
|
||||
return _bau.configured();
|
||||
}
|
||||
|
||||
bool KnxFacade::ledPinActiveOn()
|
||||
{
|
||||
return _ledPinActiveOn;
|
||||
}
|
||||
|
||||
void KnxFacade::ledPinActiveOn(bool value)
|
||||
{
|
||||
_ledPinActiveOn = value;
|
||||
}
|
||||
|
||||
uint32_t KnxFacade::ledPin()
|
||||
{
|
||||
return _ledPin;
|
||||
@ -131,11 +133,6 @@ void KnxFacade::bauNumber(uint32_t value)
|
||||
_bau.deviceObject().bauNumber(value);
|
||||
}
|
||||
|
||||
uint16_t KnxFacade::induvidualAddress()
|
||||
{
|
||||
return _bau.deviceObject().induvidualAddress();
|
||||
}
|
||||
|
||||
void KnxFacade::orderNumber(const char* value)
|
||||
{
|
||||
_bau.deviceObject().orderNumber(value);
|
||||
@ -154,6 +151,15 @@ void KnxFacade::version(uint16_t value)
|
||||
void KnxFacade::start()
|
||||
{
|
||||
pinMode(_ledPin, OUTPUT);
|
||||
|
||||
if (knx.ledPinActiveOn())
|
||||
{
|
||||
digitalWrite(_ledPin, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(_ledPin, LOW);
|
||||
}
|
||||
|
||||
pinMode(_buttonPin, INPUT_PULLUP);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user