Files
IoTManager/include/items/vSensorDallas.h

45 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifdef EnableSensorDallas
#pragma once
#include <Arduino.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "Global.h"
//ИНТЕГРИРУЮ: Объявляем глагольные переменные необходимые интегрируемой библиотеке
extern DallasTemperature sensors;
extern OneWire* oneWire;
//ИНТЕГРИРУЮ: следим за наименованиями далее
class SensorDallas;
typedef std::vector<SensorDallas> MySensorDallasVector;
class SensorDallas {
public:
//ИНТЕГРИРУЮ: обращаем внимание на параметры, берутся из таблицы настроек
SensorDallas(unsigned long interval, unsigned int pin, unsigned int index, String addr, String key);
~SensorDallas();
void loop();
void readDallas();
private:
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long difference;
unsigned long _interval;
String _key;
String _addr;
unsigned int _pin;
unsigned int _index;
//для работы библиотеки с несколькими линиями необходимо обеспечить каждый экземпляр класса ссылками на объекты настроенные на эти линии
OneWire* oneWire;
DallasTemperature* sensors;
};
extern MySensorDallasVector* mySensorDallas2;
extern void dallas();
#endif