Swap DMX port to 1, persist user choice of port, validate port vs UART count

This commit is contained in:
Will Tatam 2024-03-07 10:44:07 +00:00 committed by Will Tatam
parent a56014bb66
commit fc4e7a2dee
3 changed files with 5 additions and 2 deletions

View File

@ -527,6 +527,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
CJSON(dmxInputTransmitPin, if_live_dmx[F("inputRxPin")]);
CJSON(dmxInputReceivePin, if_live_dmx[F("inputTxPin")]);
CJSON(dmxInputEnablePin, if_live_dmx[F("inputEnablePin")]);
CJSON(dmxInputPort, if_live_dmx[F("dmxInputPort")]);
#endif
CJSON(arlsForceMaxBri, if_live[F("maxbri")]);
@ -1012,6 +1013,7 @@ void serializeConfig() {
if_live_dmx[F("inputRxPin")] = dmxInputTransmitPin;
if_live_dmx[F("inputTxPin")] = dmxInputReceivePin;
if_live_dmx[F("inputEnablePin")] = dmxInputEnablePin;
if_live_dmx[F("dmxInputPort")] = dmxInputPort;
#endif
if_live[F("timeout")] = realtimeTimeoutMs / 100;

View File

@ -156,7 +156,7 @@ Realtime LED offset: <input name="WO" type="number" min="-255" max="255" require
DMX RX: <input name="IDMR" type="number" min="-1" max="99">RO<br/>
DMX TX: <input name="IDMT" type="number" min="-1" max="99">DI<br/>
DMX Enable: <input name="IDME" type="number" min="-1" max="99">RE+DE<br/>
<div style="display: none">DMX Port: <input name="IDMP" type="number" min="1" max="2"><br/></div>
DMX Port: <input name="IDMP" type="number" min="1" max="2"><br/>
</div>
<div id="dmxInputOff"> <!--WLEDMM-->
<br><em style="color:darkorange">This firmware build does not include DMX Input support. <br></em>

View File

@ -105,6 +105,7 @@ bool DMXInput::installDriver()
{
const auto config = createConfig();
USER_PRINTF("DMX port: %u\n", inputPortNum);
if (!dmx_driver_install(inputPortNum, &config, DMX_INTR_FLAGS_DEFAULT)) {
USER_PRINTF("Error: Failed to install dmx driver\n");
return false;
@ -133,7 +134,7 @@ void DMXInput::init(uint8_t rxPin, uint8_t txPin, uint8_t enPin, uint8_t inputPo
// }
#endif
if (inputPortNum < 3 && inputPortNum > 0) {
if (inputPortNum <= (SOC_UART_NUM - 1) && inputPortNum > 0) {
this->inputPortNum = inputPortNum;
}
else {