Re-order ::enable() for clarity
@@ -32,7 +32,11 @@ MAX31856Thermocouple::MAX31856Thermocouple(Adafruit_MAX31856* max31856,
void MAX31856Thermocouple::enable() {
// Must be at least 500 to allow time for temperature "conversion".
- if (sensor_detected_) {
+ if (!sensor_detected_) {
+ debugE("MAX31856 not enabled: no sensor detected.");
+ return;
+ }
+ else {
if (read_delay_ < 500) {
read_delay_ = 500;
}
@@ -43,8 +47,7 @@ void MAX31856Thermocouple::enable() {
this->emit(temp);
});
});
- } else
- debugE("MAX31856 not enabled: no sensor detected.");
+ }
}
void MAX31856Thermocouple::get_configuration(JsonObject& root) {
