Skip to content

Commit 8b0eb7d

Browse files
committed
handle warnings better
1 parent 8ae2b53 commit 8b0eb7d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/SCRIPTS/TOOLS/ExpressLRS/protocol.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ function Protocol.isConnected()
162162
return bit32.btest(Protocol.elrsFlags, 1)
163163
end
164164

165+
function Protocol.isModelMismatch()
166+
return bit32.btest(Protocol.elrsFlags, 0x04)
167+
end
168+
169+
function Protocol.hasCriticalError()
170+
return Protocol.elrsFlags > Protocol.CRSF.ELRS_FLAGS_WARNING_THRESHOLD
171+
end
172+
165173
-- Response timeout for PARAMETER_READ:
166174
-- 0.5s for local TX module, 5s for remote devices relayed over air link.
167175
function Protocol.fieldResponseTimeout()

src/SCRIPTS/TOOLS/ExpressLRS/ui/lvgl.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ local function handleWarning()
584584
end
585585
if Protocol.elrsFlags > Protocol.CRSF.ELRS_FLAGS_STATUS_MASK then
586586
if not UI.warningDialog and not UI.warningDismissed then
587-
if Protocol.elrsFlagsInfo == "Model Mismatch" then
587+
if Protocol.isModelMismatch() then
588588
UI.warningDialog = ModelMismatchDialog.show(function()
589589
UI.warningDismissed = true
590590
UI.warningDismissedAt = getTime()
@@ -593,7 +593,7 @@ local function handleWarning()
593593
UI.warningDismissed = true
594594
App.shouldExit = true
595595
end)
596-
else
596+
elseif Protocol.hasCriticalError() then
597597
Dialogs.showMessage({
598598
title = "Warning",
599599
message = Protocol.elrsFlagsInfo,

0 commit comments

Comments
 (0)