mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-06 08:36:15 +00:00
Only show temp if sensor is attached. Added common functions to get temp and vcc
This commit is contained in:
32
src/HwTools.h
Normal file
32
src/HwTools.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _HWTOOLS_H
|
||||
#define _HWTOOLS_H
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#elif defined(ESP32)
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
#include <DallasTemperature.h>
|
||||
#include <OneWire.h>
|
||||
|
||||
class HwTools {
|
||||
public:
|
||||
static double getVcc();
|
||||
static double getTemperature();
|
||||
|
||||
HwTools() {
|
||||
#if defined TEMP_SENSOR_PIN
|
||||
oneWire = new OneWire(TEMP_SENSOR_PIN);
|
||||
tempSensor = new DallasTemperature(this->oneWire);
|
||||
#endif
|
||||
};
|
||||
private:
|
||||
bool tempSensorInit, hasTempSensor;
|
||||
OneWire *oneWire;
|
||||
DallasTemperature *tempSensor;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user