add output of opener states via gpio
This commit is contained in:
6
Gpio.cpp
6
Gpio.cpp
@@ -157,6 +157,12 @@ String Gpio::getRoleDescription(PinRole role) const
|
||||
return "Output: High when unlocked";
|
||||
case PinRole::OutputHighMotorBlocked:
|
||||
return "Output: High when motor blocked";
|
||||
case PinRole::OutputHighRtoActive:
|
||||
return "Output: High when RTO active";
|
||||
case PinRole::OutputHighCmActive:
|
||||
return "Output: High when CM active";
|
||||
case PinRole::OutputHighRtoOrCmActive:
|
||||
return "Output: High when RTO or CM active";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
8
Gpio.h
8
Gpio.h
@@ -17,6 +17,9 @@ enum class PinRole
|
||||
OutputHighLocked,
|
||||
OutputHighUnlocked,
|
||||
OutputHighMotorBlocked,
|
||||
OutputHighRtoActive,
|
||||
OutputHighCmActive,
|
||||
OutputHighRtoOrCmActive
|
||||
};
|
||||
|
||||
enum class GpioAction
|
||||
@@ -72,7 +75,10 @@ private:
|
||||
PinRole::InputActivateCM,
|
||||
PinRole::InputDeactivateRtoCm,
|
||||
PinRole::OutputHighLocked,
|
||||
PinRole::OutputHighUnlocked
|
||||
PinRole::OutputHighUnlocked,
|
||||
PinRole::OutputHighRtoActive,
|
||||
PinRole::OutputHighCmActive,
|
||||
PinRole::OutputHighRtoOrCmActive,
|
||||
};
|
||||
|
||||
std::vector<PinEntry> _pinConfiguration;
|
||||
|
||||
@@ -334,6 +334,7 @@ void NukiOpenerWrapper::updateKeyTurnerState()
|
||||
else
|
||||
{
|
||||
_network->publishKeyTurnerState(_keyTurnerState, _lastKeyTurnerState);
|
||||
updateGpioOutputs();
|
||||
|
||||
if(_keyTurnerState.nukiState == NukiOpener::State::ContinuousMode)
|
||||
{
|
||||
@@ -744,3 +745,31 @@ void NukiOpenerWrapper::disableWatchdog()
|
||||
{
|
||||
_restartBeaconTimeout = -1;
|
||||
}
|
||||
|
||||
void NukiOpenerWrapper::updateGpioOutputs()
|
||||
{
|
||||
using namespace NukiOpener;
|
||||
|
||||
const auto& pinConfiguration = _gpio->pinConfiguration();
|
||||
|
||||
const LockState& lockState = _keyTurnerState.lockState;
|
||||
|
||||
bool rtoActive = _keyTurnerState.lockState == LockState::RTOactive;
|
||||
bool cmActive = _keyTurnerState.nukiState == State::ContinuousMode;
|
||||
|
||||
for(const auto& entry : pinConfiguration)
|
||||
{
|
||||
switch(entry.role)
|
||||
{
|
||||
case PinRole::OutputHighRtoActive:
|
||||
_gpio->setPinOutput(entry.pin, rtoActive ? HIGH : LOW);
|
||||
break;
|
||||
case PinRole::OutputHighCmActive:
|
||||
_gpio->setPinOutput(entry.pin, cmActive ? HIGH : LOW);
|
||||
break;
|
||||
case PinRole::OutputHighRtoOrCmActive:
|
||||
_gpio->setPinOutput(entry.pin, rtoActive || cmActive ? HIGH : LOW);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,8 @@ private:
|
||||
void updateKeypad();
|
||||
void postponeBleWatchdog();
|
||||
|
||||
void updateGpioOutputs();
|
||||
|
||||
void readConfig();
|
||||
void readAdvancedConfig();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user