mirror of
https://github.com/thelsing/knx.git
synced 2026-02-23 13:50:35 +01:00
change last pull request a bit
This commit is contained in:
@@ -10,7 +10,7 @@ uint8_t* popByte(uint8_t& b, uint8_t* data)
|
||||
void printHex(const char* suffix, const uint8_t *data, size_t length)
|
||||
{
|
||||
print(suffix);
|
||||
for (uint i = 0; i < length; i++) {
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
if (data[i] < 0x10) { print("0"); }
|
||||
print(data[i], HEX);
|
||||
print(" ");
|
||||
|
||||
@@ -1,45 +1,30 @@
|
||||
#include "knx_facade.h"
|
||||
|
||||
#include "knx/bits.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAMD
|
||||
SamdPlatform platform;
|
||||
Bau07B0 bau(platform);
|
||||
#else
|
||||
#elif ARDUINO_ARCH_ESP8266
|
||||
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
|
||||
KnxFacade knx(bau);
|
||||
|
||||
#include "knx/bits.h"
|
||||
#ifndef __linux__
|
||||
KnxFacade knx(bau);
|
||||
|
||||
void buttonUp()
|
||||
{
|
||||
if (knx.progMode())
|
||||
{
|
||||
if (knx.ledPinActiveOn())
|
||||
{
|
||||
digitalWrite(knx.ledPin(), HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(knx.ledPin(), LOW);
|
||||
}
|
||||
knx.progMode(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (knx.ledPinActiveOn())
|
||||
{
|
||||
digitalWrite(knx.ledPin(), LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(knx.ledPin(), HIGH);
|
||||
}
|
||||
knx.progMode(true);
|
||||
}
|
||||
knx.progMode(!knx.progMode());
|
||||
}
|
||||
#endif
|
||||
|
||||
KnxFacade::KnxFacade(BauSystemB& bau) : _bau(bau)
|
||||
KnxFacade::KnxFacade(BauSystemB &bau) : _bau(bau)
|
||||
{
|
||||
manufacturerId(0xfa);
|
||||
_bau.addSaveRestore(this);
|
||||
@@ -62,14 +47,17 @@ bool KnxFacade::progMode()
|
||||
|
||||
void KnxFacade::progMode(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
println("progmode on");
|
||||
}
|
||||
else
|
||||
{
|
||||
println("progmode off");
|
||||
}
|
||||
if (value)
|
||||
{
|
||||
println("progmode on");
|
||||
digitalWrite(knx.ledPin(), _ledPinActiveOn);
|
||||
}
|
||||
else
|
||||
{
|
||||
println("progmode off");
|
||||
digitalWrite(knx.ledPin(), HIGH - _ledPinActiveOn);
|
||||
}
|
||||
|
||||
_bau.deviceObject().progMode(value);
|
||||
}
|
||||
|
||||
@@ -78,12 +66,12 @@ bool KnxFacade::configured()
|
||||
return _bau.configured();
|
||||
}
|
||||
|
||||
bool KnxFacade::ledPinActiveOn()
|
||||
uint32_t KnxFacade::ledPinActiveOn()
|
||||
{
|
||||
return _ledPinActiveOn;
|
||||
}
|
||||
|
||||
void KnxFacade::ledPinActiveOn(bool value)
|
||||
void KnxFacade::ledPinActiveOn(uint32_t value)
|
||||
{
|
||||
_ledPinActiveOn = value;
|
||||
}
|
||||
@@ -133,12 +121,17 @@ void KnxFacade::bauNumber(uint32_t value)
|
||||
_bau.deviceObject().bauNumber(value);
|
||||
}
|
||||
|
||||
void KnxFacade::orderNumber(const char* value)
|
||||
uint16_t KnxFacade::induvidualAddress()
|
||||
{
|
||||
return _bau.deviceObject().induvidualAddress();
|
||||
}
|
||||
|
||||
void KnxFacade::orderNumber(const char *value)
|
||||
{
|
||||
_bau.deviceObject().orderNumber(value);
|
||||
}
|
||||
|
||||
void KnxFacade::hardwareType(uint8_t* value)
|
||||
void KnxFacade::hardwareType(uint8_t *value)
|
||||
{
|
||||
_bau.deviceObject().hardwareType(value);
|
||||
}
|
||||
@@ -151,27 +144,20 @@ void KnxFacade::version(uint16_t value)
|
||||
void KnxFacade::start()
|
||||
{
|
||||
pinMode(_ledPin, OUTPUT);
|
||||
|
||||
if (knx.ledPinActiveOn())
|
||||
{
|
||||
digitalWrite(_ledPin, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(_ledPin, LOW);
|
||||
}
|
||||
|
||||
digitalWrite(_ledPin, HIGH - _ledPinActiveOn);
|
||||
|
||||
pinMode(_buttonPin, INPUT_PULLUP);
|
||||
|
||||
|
||||
attachInterrupt(_buttonPin, buttonUp, RISING);
|
||||
enabled(true);
|
||||
}
|
||||
|
||||
uint8_t* KnxFacade::paramData(uint32_t addr)
|
||||
uint8_t *KnxFacade::paramData(uint32_t addr)
|
||||
{
|
||||
if (!_bau.configured())
|
||||
return nullptr;
|
||||
|
||||
|
||||
return _bau.parameters().data(addr);
|
||||
}
|
||||
|
||||
@@ -199,38 +185,33 @@ uint32_t KnxFacade::paramInt(uint32_t addr)
|
||||
return _bau.parameters().getInt(addr);
|
||||
}
|
||||
|
||||
|
||||
void KnxFacade::setSaveCallback(saveRestoreCallback func)
|
||||
{
|
||||
_saveCallback = func;
|
||||
}
|
||||
|
||||
|
||||
void KnxFacade::setRestoreCallback(saveRestoreCallback func)
|
||||
{
|
||||
_restoreCallback = func;
|
||||
}
|
||||
|
||||
|
||||
uint8_t* KnxFacade::save(uint8_t* buffer)
|
||||
uint8_t *KnxFacade::save(uint8_t *buffer)
|
||||
{
|
||||
if (_saveCallback != 0)
|
||||
return _saveCallback(buffer);
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
uint8_t* KnxFacade::restore(uint8_t* buffer)
|
||||
uint8_t *KnxFacade::restore(uint8_t *buffer)
|
||||
{
|
||||
if (_restoreCallback != 0)
|
||||
return _restoreCallback(buffer);
|
||||
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
GroupObject& KnxFacade::getGroupObject(uint16_t goNr)
|
||||
GroupObject &KnxFacade::getGroupObject(uint16_t goNr)
|
||||
{
|
||||
return _bau.groupObjectTable().get(goNr);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
#ifdef ARDUINO_ARCH_SAMD
|
||||
#include "samd_platform.h"
|
||||
#include "knx/bau07B0.h"
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
#elif ARDUINO_ARCH_ESP8266
|
||||
#include "esp_platform.h"
|
||||
#include "knx/bau57B0.h"
|
||||
#else
|
||||
#include "linux_platform.h"
|
||||
#include "knx/bau57B0.h"
|
||||
#define LED_BUILTIN 0
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
#endif
|
||||
|
||||
|
||||
@@ -22,20 +26,24 @@ public:
|
||||
bool progMode();
|
||||
void progMode(bool value);
|
||||
bool configured();
|
||||
bool ledPinActiveOn();
|
||||
/**
|
||||
* returns HIGH if led is active on HIGH, LOW otherwise
|
||||
*/
|
||||
uint32_t ledPinActiveOn();
|
||||
/**
|
||||
* @brief To adapt the output to hardware.
|
||||
* To adapt the output to hardware.
|
||||
*
|
||||
* @param ledPinActiveOn = "0" or "low" --> GPIO--LED--RESISTOR--VDD (for example NODE MCU)
|
||||
* @param ledPinActiveOn = "1" or "high" --> GPIO--RESISTOR--LED--GND (for example WeMos D1 R2)
|
||||
*/
|
||||
void ledPinActiveOn(bool value);
|
||||
void ledPinActiveOn(uint32_t value);
|
||||
uint32_t ledPin();
|
||||
void ledPin(uint32_t value);
|
||||
uint32_t buttonPin();
|
||||
void buttonPin(uint32_t value);
|
||||
void readMemory();
|
||||
void writeMemory();
|
||||
uint16_t induvidualAddress();
|
||||
void loop();
|
||||
void manufacturerId(uint16_t value);
|
||||
void bauNumber(uint32_t value);
|
||||
@@ -52,7 +60,7 @@ public:
|
||||
GroupObject& getGroupObject(uint16_t goNr);
|
||||
private:
|
||||
BauSystemB& _bau;
|
||||
bool _ledPinActiveOn = 0;
|
||||
uint32_t _ledPinActiveOn = LOW;
|
||||
uint32_t _ledPin = LED_BUILTIN;
|
||||
uint32_t _buttonPin = 0;
|
||||
#ifdef USE_STATES
|
||||
@@ -65,4 +73,6 @@ private:
|
||||
uint8_t* restore(uint8_t* buffer);
|
||||
};
|
||||
|
||||
#ifndef __linux__
|
||||
extern KnxFacade knx;
|
||||
#endif
|
||||
Reference in New Issue
Block a user