mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
add example to correct folder
This commit is contained in:
parent
809de53cc8
commit
ff5dabad3b
@ -1,11 +1,7 @@
|
|||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include "knx_esp.h"
|
#include "knx_esp.h"
|
||||||
|
|
||||||
float currentValue = 0;
|
// declare array of all groupobjects with their sizes in byte
|
||||||
float maxValue = 0;
|
|
||||||
float minValue = RAND_MAX;
|
|
||||||
long lastsend = 0;
|
|
||||||
|
|
||||||
GroupObject groupObjects[]
|
GroupObject groupObjects[]
|
||||||
{
|
{
|
||||||
GroupObject(2),
|
GroupObject(2),
|
||||||
@ -14,13 +10,20 @@ GroupObject groupObjects[]
|
|||||||
GroupObject(1)
|
GroupObject(1)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// create named references for easy access to group objects
|
||||||
GroupObject& goCurrent = groupObjects[0];
|
GroupObject& goCurrent = groupObjects[0];
|
||||||
GroupObject& goMax = groupObjects[1];
|
GroupObject& goMax = groupObjects[1];
|
||||||
GroupObject& goMin = groupObjects[2];
|
GroupObject& goMin = groupObjects[2];
|
||||||
GroupObject& goReset = groupObjects[3];
|
GroupObject& goReset = groupObjects[3];
|
||||||
|
|
||||||
|
float currentValue = 0;
|
||||||
|
float maxValue = 0;
|
||||||
|
float minValue = RAND_MAX;
|
||||||
|
long lastsend = 0;
|
||||||
|
|
||||||
void measureTemp()
|
void measureTemp()
|
||||||
{
|
{
|
||||||
|
|
||||||
long now = millis();
|
long now = millis();
|
||||||
if ((now - lastsend) < 2000)
|
if ((now - lastsend) < 2000)
|
||||||
return;
|
return;
|
||||||
@ -30,6 +33,7 @@ void measureTemp()
|
|||||||
currentValue = (r * 1.0) / (RAND_MAX * 1.0);
|
currentValue = (r * 1.0) / (RAND_MAX * 1.0);
|
||||||
currentValue *= 100 * 100;
|
currentValue *= 100 * 100;
|
||||||
|
|
||||||
|
// write new value to groupobject
|
||||||
goCurrent.objectWriteFloat(currentValue);
|
goCurrent.objectWriteFloat(currentValue);
|
||||||
|
|
||||||
if (currentValue > maxValue)
|
if (currentValue > maxValue)
|
||||||
@ -45,6 +49,7 @@ void measureTemp()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// callback from reset-GO
|
||||||
void resetCallback(GroupObject& go)
|
void resetCallback(GroupObject& go)
|
||||||
{
|
{
|
||||||
if (go.objectReadBool())
|
if (go.objectReadBool())
|
||||||
@ -61,11 +66,15 @@ void setup()
|
|||||||
|
|
||||||
randomSeed(millis());
|
randomSeed(millis());
|
||||||
|
|
||||||
|
// register group objects
|
||||||
knx.registerGroupObjects(groupObjects, 4);
|
knx.registerGroupObjects(groupObjects, 4);
|
||||||
|
// read adress table, association table, groupobject table and parameters from eeprom
|
||||||
knx.readMemory();
|
knx.readMemory();
|
||||||
|
|
||||||
|
// register callback for reset GO
|
||||||
goReset.updateHandler = resetCallback;
|
goReset.updateHandler = resetCallback;
|
||||||
|
|
||||||
|
// print values of parameters if device is already configured
|
||||||
if (knx.configured())
|
if (knx.configured())
|
||||||
{
|
{
|
||||||
Serial.printf("Timeout: %d\n", knx.paramByte(0));
|
Serial.printf("Timeout: %d\n", knx.paramByte(0));
|
||||||
@ -75,12 +84,16 @@ void setup()
|
|||||||
Serial.printf("Abgleich %d\n", knx.paramByte(4));
|
Serial.printf("Abgleich %d\n", knx.paramByte(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start the framework. Will get wifi first.
|
||||||
knx.start();
|
knx.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
// don't delay here to much. Otherwise you might lose packages or mess up the timing with ETS
|
||||||
knx.loop();
|
knx.loop();
|
||||||
|
|
||||||
|
// only run the application code if the device was configured with ETS
|
||||||
if (!knx.configured())
|
if (!knx.configured())
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user