Change pin handling part 5

This commit is contained in:
Theo Arends 2020-04-27 17:16:52 +02:00
parent 1dda2ac663
commit ae4ec4325d
6 changed files with 12 additions and 12 deletions

View File

@ -1694,7 +1694,7 @@ void CmndAltitude(void)
void CmndLedPower(void)
{
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_LEDS)) {
if (99 == Pin(GPIO_LEDLNK)) { XdrvMailbox.index = 1; }
if (!PinUsed(GPIO_LEDLNK)) { XdrvMailbox.index = 1; }
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 2)) {
Settings.ledstate &= 8; // Disable power control
uint32_t mask = 1 << (XdrvMailbox.index -1); // Led to control
@ -1713,14 +1713,14 @@ void CmndLedPower(void)
break;
}
blinks = 0;
if (99 == Pin(GPIO_LEDLNK)) {
if (!PinUsed(GPIO_LEDLNK)) {
SetLedPower(Settings.ledstate &8);
} else {
SetLedPowerIdx(XdrvMailbox.index -1, (led_power & mask));
}
}
bool state = bitRead(led_power, XdrvMailbox.index -1);
if (99 == Pin(GPIO_LEDLNK)) {
if (!PinUsed(GPIO_LEDLNK)) {
state = bitRead(Settings.ledstate, 3);
}
ResponseCmndIdxChar(GetStateText(state));

View File

@ -338,7 +338,7 @@ void SetPowerOnState(void)
void SetLedPowerIdx(uint32_t led, uint32_t state)
{
if ((99 == Pin(GPIO_LEDLNK)) && (0 == led)) { // Legacy - LED1 is link led only if LED2 is present
if (!PinUsed(GPIO_LEDLNK) && (0 == led)) { // Legacy - LED1 is link led only if LED2 is present
if (PinUsed(GPIO_LED1, 1)) {
led = 1;
}
@ -362,7 +362,7 @@ void SetLedPowerIdx(uint32_t led, uint32_t state)
void SetLedPower(uint32_t state)
{
if (99 == Pin(GPIO_LEDLNK)) { // Legacy - Only use LED1 and/or LED2
if (!PinUsed(GPIO_LEDLNK)) { // Legacy - Only use LED1 and/or LED2
SetLedPowerIdx(0, state);
} else {
power_t mask = 1;
@ -1534,7 +1534,7 @@ void GpioInit(void)
for (uint32_t i = 0; i < MAX_LEDS; i++) {
if (PinUsed(GPIO_LED1, i)) {
#ifdef USE_ARILUX_RF
if ((3 == i) && (leds_present < 2) && (99 == Pin(GPIO_ARIRFSEL))) {
if ((3 == i) && (leds_present < 2) && !PinUsed(GPIO_ARIRFSEL)) {
SetPin(Pin(GPIO_LED4), GPIO_ARIRFSEL); // Legacy support where LED4 was Arilux RF enable
SetPin(99, GPIO_LED4);
} else {

View File

@ -266,7 +266,7 @@ void KeeloqInit()
\*********************************************************************************************/
bool Xdrv36(uint8_t function)
{
if ((99 == Pin(GPIO_CC1101_GDO0)) || (99 == Pin(GPIO_CC1101_GDO2))) { return false; }
if (!PinUsed(GPIO_CC1101_GDO0) || !PinUsed(GPIO_CC1101_GDO2)) { return false; }
bool result = false;

View File

@ -254,7 +254,7 @@ void HlwDrvInit(void)
Hlw.model_type = 1; // HJL-01/BL0937
}
if (PinUsed(GPIO_HLW_CF)) { // HLW8012 or HJL-01 based device Power monitor
if (PinUsed(GPIO_HLW_CF)) { // HLW8012 or HJL-01 based device Power monitor
Hlw.ui_flag = true; // Voltage on high
if (PinUsed(GPIO_NRG_SEL_INV)) {
@ -263,8 +263,8 @@ void HlwDrvInit(void)
Hlw.ui_flag = false; // Voltage on low
}
if (PinUsed(GPIO_NRG_CF1)) { // Voltage and/or Current monitor
if (99 == Pin(GPIO_NRG_SEL)) { // Voltage and/or Current selector
if (PinUsed(GPIO_NRG_CF1)) { // Voltage and/or Current monitor
if (!PinUsed(GPIO_NRG_SEL)) { // Voltage and/or Current selector
Energy.current_available = false; // Assume Voltage
}
} else {

View File

@ -244,7 +244,7 @@ void PmsInit(void)
if (PmsSerial->begin(9600)) {
if (PmsSerial->hardwareSerial()) { ClaimSerial(); }
if (99 == Pin(GPIO_PMS5003_TX)) { // setting interval not supported if TX pin not connected
if (!PinUsed(GPIO_PMS5003_TX)) { // setting interval not supported if TX pin not connected
Settings.pms_wake_interval = 0;
Pms.ready = 1;
}

View File

@ -40,7 +40,7 @@ TasmotaSerial* sonar_serial = nullptr;
uint8_t Sr04TModeDetect(void)
{
sr04_type = 0;
if (99 == Pin(GPIO_SR04_ECHO)) { return sr04_type; }
if (!PinUsed(GPIO_SR04_ECHO)) { return sr04_type; }
int sr04_echo_pin = Pin(GPIO_SR04_ECHO);
int sr04_trig_pin = (PinUsed(GPIO_SR04_TRIG)) ? Pin(GPIO_SR04_TRIG) : Pin(GPIO_SR04_ECHO); // if GPIO_SR04_TRIG is not configured use single PIN mode with GPIO_SR04_ECHO only