Skip to content

Commit

Permalink
fix digital_out: active_low
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Oct 10, 2024
1 parent 1c3b1f5 commit 08f5c4b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/analogsensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void AnalogSensor::reload(bool get_nvs) {
sensor.set_offset(EMSESP::nvs_.getChar(sensor.name().c_str()));
}
}
digitalWrite(sensor.gpio(), sensor.offset() * sensor.factor() > 0 ? 1 : 0);
digitalWrite(sensor.gpio(), (sensor.offset() == 0) ^ (sensor.factor() != 0));
sensor.set_value(sensor.offset());
}
publish_sensor(sensor);
Expand Down Expand Up @@ -754,7 +754,7 @@ bool AnalogSensor::command_setvalue(const char * value, const int8_t gpio) {
sensor.set_offset(v);
sensor.set_value(v);
pinMode(sensor.gpio(), OUTPUT);
digitalWrite(sensor.gpio(), sensor.offset() * sensor.factor() > 0 ? 1 : 0);
digitalWrite(sensor.gpio(), (sensor.offset() == 0) ^ (sensor.factor() != 0));
if (sensor.uom() == 0 && EMSESP::nvs_.getChar(sensor.name().c_str()) != (int8_t)sensor.offset()) {
EMSESP::nvs_.putChar(sensor.name().c_str(), (int8_t)sensor.offset());
}
Expand Down

0 comments on commit 08f5c4b

Please sign in to comment.