fix(lua): Re-implement luaSetSerialBaudrate (#4501)

This commit is contained in:
Raphael Coeffic
2024-01-03 13:29:02 +10:00
committed by GitHub
parent 34913d9e95
commit 317766dab7
7 changed files with 51 additions and 32 deletions
+4 -12
View File
@@ -202,7 +202,7 @@ bool isSourceAvailable(int source)
if (source >= MIXSRC_FIRST_SPACEMOUSE && source <= MIXSRC_LAST_SPACEMOUSE)
return false;
#elif defined(PCBHORUS) && defined(SPACEMOUSE)
if ((hasSerialMode(UART_MODE_SPACEMOUSE) == -1) &&
if ((serialGetModePort(UART_MODE_SPACEMOUSE) < 0) &&
(source >= MIXSRC_FIRST_SPACEMOUSE && source <= MIXSRC_LAST_SPACEMOUSE))
return false;
#endif
@@ -424,14 +424,6 @@ bool isSwitchAvailable(int swtch, SwitchContext context)
return true;
}
int hasSerialMode(int mode)
{
for (int p = 0; p < MAX_SERIAL_PORTS; p++) {
if (serialGetMode(p) == mode) return p;
}
return -1;
}
bool isSerialModeAvailable(uint8_t port_nr, int mode)
{
#if defined(USB_SERIAL)
@@ -492,7 +484,7 @@ bool isSerialModeAvailable(uint8_t port_nr, int mode)
return false;
#endif
auto p = hasSerialMode(mode);
auto p = serialGetModePort(mode);
if (p >= 0 && p != port_nr) return false;
return true;
}
@@ -1014,7 +1006,7 @@ bool isTrainerModeAvailable(int mode)
if (mode == TRAINER_MODE_MASTER_SERIAL) {
#if defined(SBUS_TRAINER)
return hasSerialMode(UART_MODE_SBUS_TRAINER) >= 0;
return serialGetModePort(UART_MODE_SBUS_TRAINER) >= 0;
#else
return false;
#endif
@@ -1227,4 +1219,4 @@ uint8_t getPotType(int index)
void setPotType(int index, int value)
{
g_eeGeneral.potsConfig = bfSet<potconfig_t>(g_eeGeneral.potsConfig, value, (POT_CFG_BITS * index), POT_CFG_TYPE_BITS);
}
}