mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-10 09:49:54 +03:00
included showing detection of external temperature sensors in startup and 'autodetect' also re-checks for new external sensors. #238
This commit is contained in:
20
src/ds18.cpp
20
src/ds18.cpp
@@ -18,23 +18,30 @@ DS18::DS18() {
|
||||
}
|
||||
|
||||
DS18::~DS18() {
|
||||
if (_wire)
|
||||
if (_wire) {
|
||||
delete _wire;
|
||||
}
|
||||
}
|
||||
|
||||
// init
|
||||
uint8_t DS18::setup(uint8_t gpio, bool parasite) {
|
||||
uint8_t count;
|
||||
|
||||
void DS18::setup(uint8_t gpio, bool parasite) {
|
||||
_gpio = gpio;
|
||||
_parasite = (parasite ? 1 : 0);
|
||||
|
||||
// OneWire
|
||||
if (_wire)
|
||||
if (_wire) {
|
||||
delete _wire;
|
||||
}
|
||||
_wire = new OneWire(_gpio);
|
||||
}
|
||||
|
||||
// Search devices
|
||||
// clear list and scan for devices
|
||||
uint8_t DS18::scan() {
|
||||
_devices.clear();
|
||||
|
||||
uint8_t count;
|
||||
|
||||
// start the search
|
||||
count = loadDevices();
|
||||
|
||||
// If no devices found check again pulling up the line
|
||||
@@ -48,6 +55,7 @@ uint8_t DS18::setup(uint8_t gpio, bool parasite) {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
// scan every 2 seconds
|
||||
void DS18::loop() {
|
||||
static uint32_t last = 0;
|
||||
|
||||
Reference in New Issue
Block a user