Can you add the possibility to invert the Pin signals, as some schematics are different
EmileSpecialProducts opened this issue · 0 comments
EmileSpecialProducts commented
enum class OpenThermMode : bool
{
SLAVE = false,
MASTER = true
};
OpenTherm(int inPin = 4, int outPin = 5, OpenThermMode isSlave = OpenThermMode::MASTER, bool InvIn = false, bool InvOut = false);
OpenTherm::OpenTherm(int inPin, int outPin, OpenThermMode isSlave , bool InvIn , bool InvOut ) :
status(OpenThermStatus::NOT_INITIALIZED),
inPin(inPin),
outPin(outPin),
InvIn(InvIn),
InvOut(InvOut),
int IRAM_ATTR OpenTherm::readState() {
if (InvIn)
return 1 ^ digitalRead(inPin);
else
return digitalRead(inPin);
}
void OpenTherm::setActiveState() {
if (InvOut)
digitalWrite(outPin, LOW);
else
digitalWrite(outPin, HIGH);
}
void OpenTherm::setIdleState() {
if (InvOut)
digitalWrite(outPin, HIGH);
else
digitalWrite(outPin, LOW);
}