add astylerc and apply code formatting

This commit is contained in:
technyon
2024-10-20 14:03:18 +02:00
parent a149f2e6b6
commit eb4db32b89
17 changed files with 5755 additions and 2914 deletions

View File

@@ -12,7 +12,7 @@
Gpio* Gpio::_inst = nullptr;
Gpio::Gpio(Preferences* preferences)
: _preferences(preferences)
: _preferences(preferences)
{
_inst = this;
loadPinConfiguration();
@@ -80,35 +80,35 @@ void Gpio::onTimer()
{
switch(entry.role)
{
case PinRole::InputLock:
case PinRole::InputUnlock:
case PinRole::InputUnlatch:
case PinRole::InputLockNgo:
case PinRole::InputLockNgoUnlatch:
case PinRole::InputElectricStrikeActuation:
case PinRole::InputActivateRTO:
case PinRole::InputActivateCM:
case PinRole::InputDeactivateRtoCm:
case PinRole::InputDeactivateRTO:
case PinRole::InputDeactivateCM:
case PinRole::GeneralInputPullDown:
case PinRole::GeneralInputPullUp:
if(isTriggered(entry))
{
_inst->notify(getGpioAction(entry.role), entry.pin);
}
break;
case PinRole::OutputHighLocked:
case PinRole::OutputHighUnlocked:
case PinRole::OutputHighMotorBlocked:
case PinRole::OutputHighRtoActive:
case PinRole::OutputHighCmActive:
case PinRole::OutputHighRtoOrCmActive:
case PinRole::GeneralOutput:
case PinRole::Ethernet:
// ignore. This case should not occur since pins are configured as output
default:
break;
case PinRole::InputLock:
case PinRole::InputUnlock:
case PinRole::InputUnlatch:
case PinRole::InputLockNgo:
case PinRole::InputLockNgoUnlatch:
case PinRole::InputElectricStrikeActuation:
case PinRole::InputActivateRTO:
case PinRole::InputActivateCM:
case PinRole::InputDeactivateRtoCm:
case PinRole::InputDeactivateRTO:
case PinRole::InputDeactivateCM:
case PinRole::GeneralInputPullDown:
case PinRole::GeneralInputPullUp:
if(isTriggered(entry))
{
_inst->notify(getGpioAction(entry.role), entry.pin);
}
break;
case PinRole::OutputHighLocked:
case PinRole::OutputHighUnlocked:
case PinRole::OutputHighMotorBlocked:
case PinRole::OutputHighRtoActive:
case PinRole::OutputHighCmActive:
case PinRole::OutputHighRtoOrCmActive:
case PinRole::GeneralOutput:
case PinRole::Ethernet:
// ignore. This case should not occur since pins are configured as output
default:
break;
}
}
}
@@ -139,37 +139,37 @@ void Gpio::init()
switch(entry.role)
{
case PinRole::InputLock:
case PinRole::InputUnlock:
case PinRole::InputUnlatch:
case PinRole::InputLockNgo:
case PinRole::InputLockNgoUnlatch:
case PinRole::InputElectricStrikeActuation:
case PinRole::InputActivateRTO:
case PinRole::InputActivateCM:
case PinRole::InputDeactivateRtoCm:
case PinRole::InputDeactivateRTO:
case PinRole::InputDeactivateCM:
case PinRole::GeneralInputPullUp:
pinMode(entry.pin, INPUT_PULLUP);
hasInputPin = true;
break;
case PinRole::GeneralInputPullDown:
pinMode(entry.pin, INPUT_PULLDOWN);
hasInputPin = true;
break;
case PinRole::OutputHighLocked:
case PinRole::OutputHighUnlocked:
case PinRole::OutputHighMotorBlocked:
case PinRole::OutputHighRtoActive:
case PinRole::OutputHighCmActive:
case PinRole::OutputHighRtoOrCmActive:
case PinRole::GeneralOutput:
pinMode(entry.pin, OUTPUT);
break;
case PinRole::Ethernet:
default:
break;
case PinRole::InputLock:
case PinRole::InputUnlock:
case PinRole::InputUnlatch:
case PinRole::InputLockNgo:
case PinRole::InputLockNgoUnlatch:
case PinRole::InputElectricStrikeActuation:
case PinRole::InputActivateRTO:
case PinRole::InputActivateCM:
case PinRole::InputDeactivateRtoCm:
case PinRole::InputDeactivateRTO:
case PinRole::InputDeactivateCM:
case PinRole::GeneralInputPullUp:
pinMode(entry.pin, INPUT_PULLUP);
hasInputPin = true;
break;
case PinRole::GeneralInputPullDown:
pinMode(entry.pin, INPUT_PULLDOWN);
hasInputPin = true;
break;
case PinRole::OutputHighLocked:
case PinRole::OutputHighUnlocked:
case PinRole::OutputHighMotorBlocked:
case PinRole::OutputHighRtoActive:
case PinRole::OutputHighCmActive:
case PinRole::OutputHighRtoOrCmActive:
case PinRole::GeneralOutput:
pinMode(entry.pin, OUTPUT);
break;
case PinRole::Ethernet:
default:
break;
}
}
@@ -221,7 +221,10 @@ void Gpio::loadPinConfiguration()
if(std::find(disabledPins.begin(), disabledPins.end(), entry.pin) == disabledPins.end())
{
if(entry.role == PinRole::Ethernet) entry.role = PinRole::Disabled;
if(entry.role == PinRole::Ethernet)
{
entry.role = PinRole::Disabled;
}
entry.role = (PinRole) serialized[(i * 2 + 1)];
Log->println("Not found in Ethernet disabled pins");
Log->print(F("Role: "));
@@ -234,7 +237,10 @@ void Gpio::loadPinConfiguration()
Log->print(F("Role: "));
Log->println(getRoleDescription(entry.role));
}
if(entry.role != PinRole::Disabled) _pinConfiguration.push_back(entry);
if(entry.role != PinRole::Disabled)
{
_pinConfiguration.push_back(entry);
}
}
}
@@ -244,90 +250,94 @@ const std::vector<int> Gpio::getDisabledPins() const
switch(_preferences->getInt(preference_network_hardware, 0))
{
case 2:
disabledPins.push_back(ETH_PHY_CS_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_IRQ_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_RST_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_SPI_SCK_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_SPI_MISO_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_SPI_MOSI_GENERIC_W5500);
break;
case 3:
disabledPins.push_back(ETH_PHY_CS_M5_W5500);
disabledPins.push_back(ETH_PHY_IRQ_M5_W5500);
disabledPins.push_back(ETH_PHY_RST_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_SCK_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_MISO_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_MOSI_M5_W5500);
break;
case 10:
disabledPins.push_back(ETH_PHY_CS_M5_W5500_S3);
disabledPins.push_back(ETH_PHY_IRQ_M5_W5500);
disabledPins.push_back(ETH_PHY_RST_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_SCK_M5_W5500_S3);
disabledPins.push_back(ETH_PHY_SPI_MISO_M5_W5500_S3);
disabledPins.push_back(ETH_PHY_SPI_MOSI_M5_W5500_S3);
break;
case 9:
disabledPins.push_back(ETH_PHY_CS_ETH01EVO);
disabledPins.push_back(ETH_PHY_IRQ_ETH01EVO);
disabledPins.push_back(ETH_PHY_RST_ETH01EVO);
disabledPins.push_back(ETH_PHY_SPI_SCK_ETH01EVO);
disabledPins.push_back(ETH_PHY_SPI_MISO_ETH01EVO);
disabledPins.push_back(ETH_PHY_SPI_MOSI_ETH01EVO);
break;
case 6:
disabledPins.push_back(ETH_PHY_CS_M5_W5500);
disabledPins.push_back(ETH_PHY_IRQ_M5_W5500);
disabledPins.push_back(ETH_PHY_RST_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_SCK_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_MISO_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_MOSI_M5_W5500);
break;
case 11:
disabledPins.push_back(_preferences->getInt(preference_network_custom_cs, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_irq, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_rst, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_sck, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_miso, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_mosi, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_pwr, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_mdc, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_mdio, -1));
break;
#if defined(CONFIG_IDF_TARGET_ESP32)
case 4:
disabledPins.push_back(12);
disabledPins.push_back(ETH_RESET_PIN_LAN8720);
disabledPins.push_back(ETH_PHY_MDC_LAN8720);
disabledPins.push_back(ETH_PHY_MDIO_LAN8720);
break;
case 5:
disabledPins.push_back(16);
disabledPins.push_back(ETH_RESET_PIN_LAN8720);
disabledPins.push_back(ETH_PHY_MDC_LAN8720);
disabledPins.push_back(ETH_PHY_MDIO_LAN8720);
break;
case 8:
disabledPins.push_back(5);
disabledPins.push_back(ETH_RESET_PIN_LAN8720);
disabledPins.push_back(ETH_PHY_MDC_LAN8720);
disabledPins.push_back(ETH_PHY_MDIO_LAN8720);
break;
case 7:
disabledPins.push_back(-1);
disabledPins.push_back(ETH_RESET_PIN_LAN8720);
disabledPins.push_back(ETH_PHY_MDC_LAN8720);
disabledPins.push_back(ETH_PHY_MDIO_LAN8720);
break;
#endif
default:
break;
case 2:
disabledPins.push_back(ETH_PHY_CS_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_IRQ_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_RST_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_SPI_SCK_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_SPI_MISO_GENERIC_W5500);
disabledPins.push_back(ETH_PHY_SPI_MOSI_GENERIC_W5500);
break;
case 3:
disabledPins.push_back(ETH_PHY_CS_M5_W5500);
disabledPins.push_back(ETH_PHY_IRQ_M5_W5500);
disabledPins.push_back(ETH_PHY_RST_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_SCK_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_MISO_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_MOSI_M5_W5500);
break;
case 10:
disabledPins.push_back(ETH_PHY_CS_M5_W5500_S3);
disabledPins.push_back(ETH_PHY_IRQ_M5_W5500);
disabledPins.push_back(ETH_PHY_RST_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_SCK_M5_W5500_S3);
disabledPins.push_back(ETH_PHY_SPI_MISO_M5_W5500_S3);
disabledPins.push_back(ETH_PHY_SPI_MOSI_M5_W5500_S3);
break;
case 9:
disabledPins.push_back(ETH_PHY_CS_ETH01EVO);
disabledPins.push_back(ETH_PHY_IRQ_ETH01EVO);
disabledPins.push_back(ETH_PHY_RST_ETH01EVO);
disabledPins.push_back(ETH_PHY_SPI_SCK_ETH01EVO);
disabledPins.push_back(ETH_PHY_SPI_MISO_ETH01EVO);
disabledPins.push_back(ETH_PHY_SPI_MOSI_ETH01EVO);
break;
case 6:
disabledPins.push_back(ETH_PHY_CS_M5_W5500);
disabledPins.push_back(ETH_PHY_IRQ_M5_W5500);
disabledPins.push_back(ETH_PHY_RST_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_SCK_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_MISO_M5_W5500);
disabledPins.push_back(ETH_PHY_SPI_MOSI_M5_W5500);
break;
case 11:
disabledPins.push_back(_preferences->getInt(preference_network_custom_cs, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_irq, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_rst, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_sck, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_miso, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_mosi, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_pwr, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_mdc, -1));
disabledPins.push_back(_preferences->getInt(preference_network_custom_mdio, -1));
break;
#if defined(CONFIG_IDF_TARGET_ESP32)
case 4:
disabledPins.push_back(12);
disabledPins.push_back(ETH_RESET_PIN_LAN8720);
disabledPins.push_back(ETH_PHY_MDC_LAN8720);
disabledPins.push_back(ETH_PHY_MDIO_LAN8720);
break;
case 5:
disabledPins.push_back(16);
disabledPins.push_back(ETH_RESET_PIN_LAN8720);
disabledPins.push_back(ETH_PHY_MDC_LAN8720);
disabledPins.push_back(ETH_PHY_MDIO_LAN8720);
break;
case 8:
disabledPins.push_back(5);
disabledPins.push_back(ETH_RESET_PIN_LAN8720);
disabledPins.push_back(ETH_PHY_MDC_LAN8720);
disabledPins.push_back(ETH_PHY_MDIO_LAN8720);
break;
case 7:
disabledPins.push_back(-1);
disabledPins.push_back(ETH_RESET_PIN_LAN8720);
disabledPins.push_back(ETH_PHY_MDC_LAN8720);
disabledPins.push_back(ETH_PHY_MDIO_LAN8720);
break;
#endif
default:
break;
}
Log->print(F("GPIO Ethernet disabled pins:"));
for_each_n(disabledPins.begin(), disabledPins.size(),
[](int x) { Log->print(" "); Log->print(x); });
[](int x)
{
Log->print(" ");
Log->print(x);
});
Log->println();
return disabledPins;
}
@@ -393,52 +403,52 @@ String Gpio::getRoleDescription(const PinRole& role) const
{
switch(role)
{
case PinRole::Disabled:
return "Disabled";
case PinRole::InputLock:
return "Input: Lock";
case PinRole::InputUnlock:
return "Input: Unlock";
case PinRole::InputUnlatch:
return "Input: Unlatch";
case PinRole::InputLockNgo:
return "Input: Lock n Go";
case PinRole::InputLockNgoUnlatch:
return "Input: Lock n Go and unlatch";
case PinRole::InputElectricStrikeActuation:
return "Input: Electric strike actuation";
case PinRole::InputActivateRTO:
return "Input: Activate RTO";
case PinRole::InputActivateCM:
return "Input: Activate CM";
case PinRole::InputDeactivateRtoCm:
return "Input: Deactivate RTO/CM";
case PinRole::InputDeactivateRTO:
return "Input: Deactivate RTO";
case PinRole::InputDeactivateCM:
return "Input: Deactivate CM";
case PinRole::OutputHighLocked:
return "Output: High when locked";
case PinRole::OutputHighUnlocked:
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";
case PinRole::GeneralOutput:
return "General output";
case PinRole::GeneralInputPullDown:
return "General input (Pull-down)";
case PinRole::GeneralInputPullUp:
return "General input (Pull-up)";
case PinRole::Ethernet:
return "Ethernet";
default:
return "Unknown";
case PinRole::Disabled:
return "Disabled";
case PinRole::InputLock:
return "Input: Lock";
case PinRole::InputUnlock:
return "Input: Unlock";
case PinRole::InputUnlatch:
return "Input: Unlatch";
case PinRole::InputLockNgo:
return "Input: Lock n Go";
case PinRole::InputLockNgoUnlatch:
return "Input: Lock n Go and unlatch";
case PinRole::InputElectricStrikeActuation:
return "Input: Electric strike actuation";
case PinRole::InputActivateRTO:
return "Input: Activate RTO";
case PinRole::InputActivateCM:
return "Input: Activate CM";
case PinRole::InputDeactivateRtoCm:
return "Input: Deactivate RTO/CM";
case PinRole::InputDeactivateRTO:
return "Input: Deactivate RTO";
case PinRole::InputDeactivateCM:
return "Input: Deactivate CM";
case PinRole::OutputHighLocked:
return "Output: High when locked";
case PinRole::OutputHighUnlocked:
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";
case PinRole::GeneralOutput:
return "General output";
case PinRole::GeneralInputPullDown:
return "General input (Pull-down)";
case PinRole::GeneralInputPullUp:
return "General input (Pull-up)";
case PinRole::Ethernet:
return "Ethernet";
default:
return "Unknown";
}
}
@@ -447,46 +457,47 @@ GpioAction Gpio::getGpioAction(const PinRole &role) const
{
switch(role)
{
case PinRole::Disabled:
return GpioAction::None;
case PinRole::InputLock:
return GpioAction::Lock;
case PinRole::InputUnlock:
return GpioAction::Unlock;
case PinRole::InputUnlatch:
return GpioAction::Unlatch;
case PinRole::InputLockNgo:
return GpioAction::LockNgo;
case PinRole::InputLockNgoUnlatch:
return GpioAction::LockNgoUnlatch;
case PinRole::InputElectricStrikeActuation:
return GpioAction::ElectricStrikeActuation;
case PinRole::InputActivateRTO:
return GpioAction::ActivateRTO;
case PinRole::InputActivateCM:
return GpioAction::ActivateCM;
case PinRole::InputDeactivateRtoCm:
return GpioAction::DeactivateRtoCm;
case PinRole::InputDeactivateRTO:
return GpioAction::DeactivateRTO;
case PinRole::InputDeactivateCM:
return GpioAction::DeactivateCM;
case PinRole::Disabled:
return GpioAction::None;
case PinRole::InputLock:
return GpioAction::Lock;
case PinRole::InputUnlock:
return GpioAction::Unlock;
case PinRole::InputUnlatch:
return GpioAction::Unlatch;
case PinRole::InputLockNgo:
return GpioAction::LockNgo;
case PinRole::InputLockNgoUnlatch:
return GpioAction::LockNgoUnlatch;
case PinRole::InputElectricStrikeActuation:
return GpioAction::ElectricStrikeActuation;
case PinRole::InputActivateRTO:
return GpioAction::ActivateRTO;
case PinRole::InputActivateCM:
return GpioAction::ActivateCM;
case PinRole::InputDeactivateRtoCm:
return GpioAction::DeactivateRtoCm;
case PinRole::InputDeactivateRTO:
return GpioAction::DeactivateRTO;
case PinRole::InputDeactivateCM:
return GpioAction::DeactivateCM;
case PinRole::GeneralInputPullDown:
case PinRole::GeneralInputPullUp:
return GpioAction::GeneralInput;
case PinRole::GeneralInputPullDown:
case PinRole::GeneralInputPullUp:
return GpioAction::GeneralInput;
case PinRole::GeneralOutput:
case PinRole::Ethernet:
case PinRole::OutputHighLocked:
case PinRole::OutputHighUnlocked:
case PinRole::OutputHighMotorBlocked:
case PinRole::OutputHighRtoActive:
case PinRole::OutputHighCmActive:
case PinRole::OutputHighRtoOrCmActive:
default:
return GpioAction::None;
}}
case PinRole::GeneralOutput:
case PinRole::Ethernet:
case PinRole::OutputHighLocked:
case PinRole::OutputHighUnlocked:
case PinRole::OutputHighMotorBlocked:
case PinRole::OutputHighRtoActive:
case PinRole::OutputHighCmActive:
case PinRole::OutputHighRtoOrCmActive:
default:
return GpioAction::None;
}
}
void Gpio::getConfigurationText(String& text, const std::vector<PinEntry>& pinConfiguration, const String& linebreak) const