pin info: show conflicts

* set.cpp: reject non-ADC pins as analog button pins (bugfix)
* pinmanager:
record conflicts
added getOwnerText(PinOwner tag) and getPinConflicts(int gpio)

GPIO    | Assigned to           | Info
--------|-----------------------|------------
i/o   0   Button            !! Conflict with AudioReactive (UM) !!        (default) I2S MCLK
i/o   1   debug output            Serial TX
i/o   2   ./.                     (default) LED pin
i/o   3   ./.                     Serial RX
i/o   5   ./.                     (default) SPI SS
i/o  13   Button            !! Conflict with IR Receiver !!

PIN ALLOC error: GPIO19 for analog button #2 is not an analog pin!
This commit is contained in:
Frank
2022-12-04 02:22:50 +01:00
parent 4bafc222f9
commit d2d8a86d81
5 changed files with 51 additions and 18 deletions

View File

@@ -169,7 +169,14 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
btnPin[i] = hw_btn_pin;
buttonType[i] = request->arg(be).toInt();
#ifdef ESP32
pinMode(btnPin[i], buttonType[i]==BTN_TYPE_PUSH_ACT_HIGH ? INPUT_PULLDOWN : INPUT_PULLUP);
if (((buttonType[i] == BTN_TYPE_ANALOG) || (buttonType[i] == BTN_TYPE_ANALOG_INVERTED)) && (digitalPinToAnalogChannel(btnPin[i]) < 0)) { // WLEDMM
// not an ADC analog pin
DEBUG_PRINTF("PIN ALLOC error: GPIO%d for analog button #%d is not an analog pin!\n", btnPin[i], i);
btnPin[i] = -1;
pinManager.deallocatePin(hw_btn_pin,PinOwner::Button);
} else { // WLEDMM end
pinMode(btnPin[i], buttonType[i]==BTN_TYPE_PUSH_ACT_HIGH ? INPUT_PULLDOWN : INPUT_PULLUP);
}
#else
pinMode(btnPin[i], INPUT_PULLUP);
#endif