diff --git a/examples/knx-demo-smal-go/.gitignore b/examples/knx-demo-smal-go/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/examples/knx-demo-smal-go/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/examples/knx-demo-smal-go/knx-demo-ip.knxprod b/examples/knx-demo-smal-go/knx-demo-ip.knxprod new file mode 100644 index 0000000..801f3be Binary files /dev/null and b/examples/knx-demo-smal-go/knx-demo-ip.knxprod differ diff --git a/examples/knx-demo-smal-go/knx-demo-ip.xml b/examples/knx-demo-smal-go/knx-demo-ip.xml new file mode 100644 index 0000000..3cdcf1f --- /dev/null +++ b/examples/knx-demo-smal-go/knx-demo-ip.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/knx-demo-smal-go/knx-demo-rf.knxprod b/examples/knx-demo-smal-go/knx-demo-rf.knxprod new file mode 100644 index 0000000..ece15a9 Binary files /dev/null and b/examples/knx-demo-smal-go/knx-demo-rf.knxprod differ diff --git a/examples/knx-demo-smal-go/knx-demo-rf.xml b/examples/knx-demo-smal-go/knx-demo-rf.xml new file mode 100644 index 0000000..38993f6 --- /dev/null +++ b/examples/knx-demo-smal-go/knx-demo-rf.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/knx-demo-smal-go/knx-demo-tp.knxprod b/examples/knx-demo-smal-go/knx-demo-tp.knxprod new file mode 100644 index 0000000..ccb1363 Binary files /dev/null and b/examples/knx-demo-smal-go/knx-demo-tp.knxprod differ diff --git a/examples/knx-demo-smal-go/knx-demo-tp.xml b/examples/knx-demo-smal-go/knx-demo-tp.xml new file mode 100644 index 0000000..d748668 --- /dev/null +++ b/examples/knx-demo-smal-go/knx-demo-tp.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/knx-demo-smal-go/knx-demo.ino b/examples/knx-demo-smal-go/knx-demo.ino new file mode 100644 index 0000000..d4476db --- /dev/null +++ b/examples/knx-demo-smal-go/knx-demo.ino @@ -0,0 +1,126 @@ +#include + +#ifdef ARDUINO_ARCH_ESP8266 +#include +#endif + +/***************************************** + * changes necessary for SMALL_GROUPOBJECT + * are commented with //** + *****************************************/ + +// create named references for easy access to group objects +#define goCurrent knx.getGroupObject(1) +#define goMax knx.getGroupObject(2) +#define goMin knx.getGroupObject(3) +#define goReset knx.getGroupObject(4) + +float currentValue = 0; +float maxValue = 0; +float minValue = RAND_MAX; +long lastsend = 0; + +void measureTemp() +{ + long now = millis(); + if ((now - lastsend) < 2000) + return; + + lastsend = now; + int r = rand(); + currentValue = (r * 1.0) / (RAND_MAX * 1.0); + currentValue *= 100 * 100; + + // write new value to groupobject + goCurrent.value(currentValue, DPT_Value_Temp); //** each value access needs to done with according DPT parameter + + if (currentValue > maxValue) + { + maxValue = currentValue; + goMax.value(maxValue, DPT_Value_Temp); //** each value access needs to done with according DPT parameter + } + + if (currentValue < minValue) + { + minValue = currentValue; + goMin.value(minValue, DPT_Value_Temp); //** each value access needs to done with according DPT parameter + } +} + +// callback from reset-GO +void resetCallback(GroupObject& go) +{ + //** callbacks are now handled in the class, not per instance, + //** this means, we have to check, which GroupObject is calling back + if (go.asap() == goReset.asap()) + { + if (go.value(DPT_Trigger)) //** each value access needs to done with according DPT parameter + { + maxValue = 0; + minValue = 10000; + } + } +} + +void setup() +{ + Serial.begin(115200); + ArduinoPlatform::SerialDebug = &Serial; + + randomSeed(millis()); + +#ifdef ARDUINO_ARCH_ESP8266 + WiFiManager wifiManager; + wifiManager.autoConnect("knx-demo"); +#endif + + // read adress table, association table, groupobject table and parameters from eeprom + knx.readMemory(); + + // print values of parameters if device is already configured + if (knx.configured()) + { + // register callback for reset GO + GroupObject::classCallback(resetCallback); //** callbacks are now handled per class, not per instance + //** there is no global assignment of DPT for GroupObjects + // goReset.dataPointType(DPT_Trigger); + // goCurrent.dataPointType(DPT_Value_Temp); + // goMin.dataPointType(DPT_Value_Temp); + // goMax.dataPointType(DPT_Value_Temp); + + Serial.print("Timeout: "); + Serial.println(knx.paramByte(0)); + Serial.print("Zykl. senden: "); + Serial.println(knx.paramByte(1)); + Serial.print("Min/Max senden: "); + Serial.println(knx.paramByte(2)); + Serial.print("Aenderung senden: "); + Serial.println(knx.paramByte(3)); + Serial.print("Abgleich: "); + Serial.println(knx.paramByte(4)); + } + + // pin or GPIO the programming led is connected to. Default is LED_BUILTIN + // knx.ledPin(LED_BUILTIN); + // is the led active on HIGH or low? Default is LOW + // knx.ledPinActiveOn(HIGH); + // pin or GPIO programming button is connected to. Default is 0 + // knx.buttonPin(0); + // Is the interrup created in RISING or FALLING signal? Default is RISING + // knx.buttonPinInterruptOn(FALLING); + + // start the framework. + knx.start(); +} + +void loop() +{ + // don't delay here to much. Otherwise you might lose packages or mess up the timing with ETS + knx.loop(); + + // only run the application code if the device was configured with ETS + if (!knx.configured()) + return; + + measureTemp(); +} \ No newline at end of file diff --git a/examples/knx-demo-smal-go/platformio-ci.ini b/examples/knx-demo-smal-go/platformio-ci.ini new file mode 100644 index 0000000..9dc4835 --- /dev/null +++ b/examples/knx-demo-smal-go/platformio-ci.ini @@ -0,0 +1,86 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +;--- SAMD -------------------------------------------------- +[env:adafruit_feather_m0_rf] +platform = atmelsam +board = adafruit_feather_m0 +framework = arduino +lib_deps = + SPI + https://github.com/thelsing/FlashStorage.git + knx + +build_flags = + -DMASK_VERSION=0x27B0 + -Wno-unknown-pragmas + -DUSE_DATASECURE + -DSMALL_GROUPOBJECT +;----------------------------------------------------------- + + +;--- ESP8266 ----------------------------------------------- +[env:nodemcuv2_ip] +platform = espressif8266 +board = nodemcuv2 +framework = arduino +lib_deps = + WifiManager + knx + +build_flags = + -DMASK_VERSION=0x57B0 + -Wno-unknown-pragmas + -DUSE_DATASECURE + -DSMALL_GROUPOBJECT + +[env:nodemcuv2_tp] +platform = espressif8266 +board = nodemcuv2 +framework = arduino +lib_deps = + WifiManager@0.15.0 + knx + +build_flags = + -DMASK_VERSION=0x07B0 + -Wno-unknown-pragmas + -DUSE_DATASECURE + -DSMALL_GROUPOBJECT + +;--------------------------------------------------------- + + +;--- ESP32 ----------------------------------------------- +[env:esp32dev_ip] +platform = espressif32 +board = esp32dev +framework = arduino +lib_deps = + knx + +build_flags = + -DMASK_VERSION=0x57B0 + -Wno-unknown-pragmas + -DUSE_DATASECURE + -DSMALL_GROUPOBJECT + +[env:esp32dev_tp] +platform = espressif32 +board = esp32dev +framework = arduino +lib_deps = + knx + +build_flags = + -DMASK_VERSION=0x07B0 + -Wno-unknown-pragmas + -DUSE_DATASECURE + -DSMALL_GROUPOBJECT diff --git a/examples/knx-demo-smal-go/platformio.ini b/examples/knx-demo-smal-go/platformio.ini new file mode 100644 index 0000000..a919602 --- /dev/null +++ b/examples/knx-demo-smal-go/platformio.ini @@ -0,0 +1,120 @@ +;PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html +[platformio] +; We have to keep libdeps dir out the project directory otherwise, +; library scanner seems to have issues so compilation fails +libdeps_dir = /tmp/libdeps +src_dir = . + +;--- SAMD -------------------------------------------------- +; SMALL_GROUPOBJECT just tested with TP on SAMD, but should work also in other environments +[env:zeroUSB] +platform = atmelsam +board = zeroUSB +framework = arduino +; We consider that the this projects is opened within its project directory +; while working with VS Code. +lib_extra_dirs = ../../../ + +lib_deps = + SPI + https://github.com/thelsing/FlashStorage.git + knx + +build_flags = + -DMASK_VERSION=0x07B0 + -DSMALL_GROUPOBJECT + -Wno-unknown-pragmas + +; [env:adafruit_feather_m0_rf] +; platform = atmelsam +; board = adafruit_feather_m0 +; framework = arduino +; ; We consider that the this projects is opened within its project directory +; ; while working with VS Code. +; lib_extra_dirs = ../../../ + +; lib_deps = +; SPI +; https://github.com/thelsing/FlashStorage.git +; knx + +; build_flags = +; -DMASK_VERSION=0x27B0 +; -Wno-unknown-pragmas +;----------------------------------------------------------- + + +;--- ESP8266 ----------------------------------------------- +#[env:nodemcuv2_ip] +#platform = espressif8266 +#board = nodemcuv2 +#framework = arduino +; We consider that the this projects is opened within its project directory +; while working with VS Code. +#lib_extra_dirs = ../../../ + +#lib_deps = +# WifiManager +# knx + +#build_flags = +# -DMASK_VERSION=0x57B0 +# -Wno-unknown-pragmas + +; [env:nodemcuv2_tp] +; platform = espressif8266 +; board = nodemcuv2 +; framework = arduino +; ; We consider that the this projects is opened within its project directory +; ; while working with VS Code. +; lib_extra_dirs = ../../../ + +; lib_deps = +; WifiManager +; knx + +; build_flags = +; -DMASK_VERSION=0x07B0 +; -Wno-unknown-pragmas + +;--------------------------------------------------------- + + +;--- ESP32 ----------------------------------------------- +; [env:esp32dev_ip] +; platform = espressif32 +; board = esp32dev +; framework = arduino +; ; We consider that the this projects is opened within its project directory +; ; while working with VS Code. +; lib_extra_dirs = ../../../ + +; lib_deps = +; knx + +; build_flags = +; -DMASK_VERSION=0x57B0 +; -Wno-unknown-pragmas + +; [env:esp32dev_tp] +; platform = espressif32 +; board = esp32dev +; framework = arduino +; ; We consider that the this projects is opened within its project directory +; ; while working with VS Code. +; lib_extra_dirs = ../../../ + +; lib_deps = +; knx + +; build_flags = +; -DMASK_VERSION=0x07B0 +; -Wno-unknown-pragmas diff --git a/src/knx/config.h b/src/knx/config.h index 0b3ce64..a042ae3 100644 --- a/src/knx/config.h +++ b/src/knx/config.h @@ -60,6 +60,12 @@ // Define via a compiler -D flag if required // #define USE_DATASECURE +// option to have GroupObjects (KO in German) use 8 bytes mangement information RAM instead of 19 bytes +// see knx-demo-small-go for example +// this option might be also set via compiler flag -DSMALL_GROUPOBJECT if required +//#define SMALL_GROUPOBJECT + + #endif #if !defined(MASK_VERSION)