Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display warning/error when changing packet and baud-rate too low #1672

Merged
merged 1 commit into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/LUA/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void sendELRSstatus()
"[ ! Armed ! ]", //warning2, AUX1 high / armed
"", //warning1, reserved for future use
"Not while connected", //critical warning3, trying to change a protected value while connected
"", //critical warning2, reserved for future use
"Baud rate too low", //critical warning2, changing packet rate and baud rate too low
"" //critical warning1, reserved for future use
};
const char * warningInfo = "";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/LUA/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum lua_Flags{
LUA_FLAG_WARNING1,
//bit 5,6,7 are critical warning flag, block the lua screen until user confirm to suppress the warning.
LUA_FLAG_ERROR_CONNECTED,
LUA_FLAG_CRITICAL_WARNING1,
LUA_FLAG_ERROR_BAUDRATE,
LUA_FLAG_CRITICAL_WARNING2,
};

Expand Down
12 changes: 8 additions & 4 deletions src/lib/LUA/tx_devLUA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,19 @@ static void registerLuaParameters()
registerLUAParameter(&luaAirRate, [](struct luaPropertiesCommon *item, uint8_t arg) {
if (arg < RATE_MAX)
{
uint8_t newRate = RATE_MAX - 1 - arg;
newRate = adjustPacketRateForBaud(newRate);
uint8_t selectedRate = RATE_MAX - 1 - arg;
uint8_t actualRate = adjustPacketRateForBaud(selectedRate);
uint8_t newSwitchMode = adjustSwitchModeForAirRate(
(OtaSwitchMode_e)config.GetSwitchMode(), get_elrs_airRateConfig(newRate)->PayloadLength);
(OtaSwitchMode_e)config.GetSwitchMode(), get_elrs_airRateConfig(actualRate)->PayloadLength);
// If the switch mode is going to change, block the change while connected
if (newSwitchMode == OtaSwitchModeCurrent || connectionState == disconnected)
{
config.SetRate(newRate);
config.SetRate(actualRate);
config.SetSwitchMode(newSwitchMode);
if (actualRate != selectedRate)
{
setLuaWarningFlag(LUA_FLAG_ERROR_BAUDRATE, true);
}
}
else
setLuaWarningFlag(LUA_FLAG_ERROR_CONNECTED, true);
Expand Down