mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
compiling version
This commit is contained in:
35
include/items/SensorDallas.h
Normal file
35
include/items/SensorDallas.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "Global.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
extern DallasTemperature sensors;
|
||||
extern OneWire* oneWire;
|
||||
|
||||
class SensorDallas;
|
||||
|
||||
typedef std::vector<SensorDallas> 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;
|
||||
|
||||
|
||||
52
src/items/SensorDallas.cpp
Normal file
52
src/items/SensorDallas.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "items/SensorDallas.h"
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "ItemsCmd.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
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));
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user