diff --git a/include/items/SensorDallas.h b/include/items/SensorDallas.h new file mode 100644 index 00000000..fc3bd449 --- /dev/null +++ b/include/items/SensorDallas.h @@ -0,0 +1,35 @@ +#pragma once +#include "Global.h" +#include + +extern DallasTemperature sensors; +extern OneWire* oneWire; + +class SensorDallas; + +typedef std::vector MySensorDallasVector; + +class SensorDallas { + public: + + SensorDallas(unsigned long period,unsigned int pin, uint8_t deviceAddress, String key); + ~SensorDallas(); + + void loop(); + + private: + + unsigned long currentMillis; + unsigned long prevMillis; + unsigned long _period; + String _key; + unsigned int _pin; + uint8_t _deviceAddress; + + void readDallas(); + +}; + +extern MySensorDallasVector* mySensorDallas2; + + diff --git a/include/items/SensorDallasClass2.h b/include/items/SensorDallasClass2.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/items/SensorDallas.cpp b/src/items/SensorDallas.cpp new file mode 100644 index 00000000..9cae8a0f --- /dev/null +++ b/src/items/SensorDallas.cpp @@ -0,0 +1,52 @@ +#include "items/SensorDallas.h" +#include "Class/LineParsing.h" +#include "Global.h" +#include "ItemsCmd.h" +#include + +SensorDallas::SensorDallas(unsigned long period, unsigned int pin, uint8_t deviceAddress, String key) { + _period = period * 1000; + _key = key; + _pin = pin; + _deviceAddress = deviceAddress; + + oneWire = new OneWire((uint8_t)_pin); + sensors.setOneWire(oneWire); + sensors.begin(); + sensors.setResolution(12); +} + +SensorDallas::~SensorDallas() {} + +void SensorDallas::loop() { + currentMillis = millis(); + unsigned long difference = currentMillis - prevMillis; + if (difference >= _period) { + prevMillis = millis(); + + } +} + +void readDallas() { + +} + + +MySensorDallasVector* mySensorDallas2 = nullptr; + +//void logging() { +// myLineParsing.update(); +// String loggingValueKey = myLineParsing.gval(); +// String key = myLineParsing.gkey(); +// String interv = myLineParsing.gint(); +// String maxcnt = myLineParsing.gcnt(); +// myLineParsing.clear(); +// +// loggingKeyList += key + ","; +// +// static bool firstTime = true; +// if (firstTime) myLogging = new MySensorDallasVector(); +// firstTime = false; +// myLogging->push_back(SensorDallas(interv.toInt(), maxcnt.toInt(), loggingValueKey, key)); +//} +