Add gpio output for MQTT status (#698)
This commit is contained in:
19
src/Gpio.cpp
19
src/Gpio.cpp
@@ -178,6 +178,7 @@ void Gpio::setPins()
|
||||
case PinRole::OutputHighCmActive:
|
||||
case PinRole::OutputHighRtoOrCmActive:
|
||||
case PinRole::GeneralOutput:
|
||||
case PinRole::OutputHighMqttConnected:
|
||||
pinMode(entry.pin, OUTPUT);
|
||||
break;
|
||||
case PinRole::Ethernet:
|
||||
@@ -434,6 +435,21 @@ const PinRole Gpio::getPinRole(const int &pin) const
|
||||
return PinRole::Disabled;
|
||||
}
|
||||
|
||||
const std::vector<uint8_t> Gpio::getPinsWithRole(PinRole role) const
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
|
||||
for (uint8_t pin : _availablePins)
|
||||
{
|
||||
if (getPinRole(pin) == role)
|
||||
{
|
||||
result.push_back(pin);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String Gpio::getRoleDescription(const PinRole& role) const
|
||||
{
|
||||
switch(role)
|
||||
@@ -482,6 +498,8 @@ String Gpio::getRoleDescription(const PinRole& role) const
|
||||
return "General input (Pull-up)";
|
||||
case PinRole::Ethernet:
|
||||
return "Ethernet";
|
||||
case PinRole::OutputHighMqttConnected:
|
||||
return "Output: High when MQTT connected";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
@@ -529,6 +547,7 @@ GpioAction Gpio::getGpioAction(const PinRole &role) const
|
||||
case PinRole::OutputHighRtoActive:
|
||||
case PinRole::OutputHighCmActive:
|
||||
case PinRole::OutputHighRtoOrCmActive:
|
||||
case PinRole::OutputHighMqttConnected:
|
||||
default:
|
||||
return GpioAction::None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user