use KnxFacade for linux too

This commit is contained in:
Thomas Kunze
2019-05-18 21:04:49 +02:00
parent b34c3d4ddc
commit 9cbd9a0760
12 changed files with 94 additions and 140 deletions

View File

@@ -58,6 +58,13 @@ protected:
void loadEventLoaded(uint8_t* data);
void loadEventError(uint8_t* data);
void additionalLoadControls(uint8_t* data);
/**
* @brief set the ::LoadState of the interface object.
*
* Calls beforeStateChange().
*
* @param newState the new ::LoadState
*/
void loadState(LoadState newState);
LoadState _state = LS_UNLOADED;
Platform& _platform;

View File

@@ -1,12 +1,21 @@
#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
#ifndef __linux__
KnxFacade knx(bau);
void buttonUp()
@@ -22,6 +31,7 @@ void buttonUp()
knx.progMode(true);
}
}
#endif
KnxFacade::KnxFacade(BauSystemB& bau) : _bau(bau)
{
@@ -46,7 +56,12 @@ bool KnxFacade::progMode()
void KnxFacade::progMode(bool value)
{
Serial.println("progmode");
print("progmode ");
if (value)
println("on");
else
println("off");
_bau.deviceObject().progMode(value);
}
@@ -100,6 +115,11 @@ 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);

View File

@@ -3,14 +3,17 @@
#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
#endif
typedef uint8_t* (*saveRestoreCallback)(uint8_t* buffer);
class KnxFacade : private SaveRestore
@@ -28,6 +31,7 @@ public:
void buttonPin(uint32_t value);
void readMemory();
void writeMemory();
uint16_t induvidualAddress();
void loop();
void manufacturerId(uint16_t value);
void bauNumber(uint32_t value);
@@ -56,4 +60,6 @@ private:
uint8_t* restore(uint8_t* buffer);
};
extern KnxFacade knx;
#ifndef __linux__
extern KnxFacade knx;
#endif