included showing detection of external temperature sensors in startup and 'autodetect' also re-checks for new external sensors. #238

This commit is contained in:
Paul
2020-01-11 16:29:51 +01:00
parent 9f37dfb802
commit c3905e0b33
4 changed files with 60 additions and 23 deletions

View File

@@ -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;