Skip to content

Commit 1e74e66

Browse files
committed
Add separate alert for model mismatch
1 parent a028b19 commit 1e74e66

1 file changed

Lines changed: 54 additions & 8 deletions

File tree

  • src/SCRIPTS/TOOLS/ExpressLRS/ui

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

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ local UI = {
3838
titleShowWarn = nil,
3939
titleShowWarnTimeout = 100,
4040

41+
-- Warning dismissal (model mismatch)
42+
warningDismissed = false,
43+
warningDismissedAt = nil,
44+
4145
-- Command popup spinner
4246
commandRunningIndicator = 1,
4347
}
@@ -94,13 +98,13 @@ end
9498
-- ============================================================================
9599

96100
function UI.handleNoModule()
97-
UI.drawAlert(" No ExpressLRS", {
98-
" Enable a CRSF Internal",
99-
" or External module in",
100-
" Model settings",
101-
" If module is internal",
102-
" also set Internal RF to",
103-
" CRSF in SYS->Hardware",
101+
UI.drawAlert(" No ExpressLRS", {
102+
"Enable a CRSF Internal",
103+
" or External module in",
104+
" Model settings",
105+
" If module is internal",
106+
"also set Internal RF to",
107+
"CRSF in SYS->Hardware",
104108
})
105109
end
106110

@@ -128,6 +132,39 @@ function UI.render(event, _touchState)
128132
UI.forceRedraw = true
129133
end
130134

135+
-- Warning dismissal cooldown (60s before re-showing)
136+
if UI.warningDismissedAt then
137+
if Protocol.elrsFlags <= Protocol.CRSF.ELRS_FLAGS_STATUS_MASK then
138+
if time - UI.warningDismissedAt > 6000 then
139+
UI.warningDismissed = false
140+
UI.warningDismissedAt = nil
141+
end
142+
elseif UI.warningDismissed and time - UI.warningDismissedAt > 6000 then
143+
UI.warningDismissed = false
144+
UI.warningDismissedAt = nil
145+
end
146+
end
147+
148+
-- Model mismatch alert (full-screen, blocks normal rendering)
149+
if Protocol.isModelMismatch() and not UI.warningDismissed then
150+
if event == EVT_VIRTUAL_ENTER then
151+
UI.warningDismissed = true
152+
UI.warningDismissedAt = getTime()
153+
UI.forceRedraw = true
154+
return
155+
elseif event == EVT_VIRTUAL_EXIT then
156+
App.shouldExit = true
157+
return
158+
end
159+
UI.drawAlert("Model Mismatch", {
160+
"RX connected but",
161+
"Model ID doesn't match.",
162+
"To use this receiver:",
163+
"Disable Model Match",
164+
}, { left = "[OK]", right = "[RTN] Change model" })
165+
return
166+
end
167+
131168
-- Force redraw during loading to show progress bar
132169
if #Protocol.loadQueue > 0 then
133170
UI.forceRedraw = true
@@ -146,7 +183,7 @@ end
146183
-- Alert screen (clear screen + title + body messages)
147184
-- ============================================================================
148185

149-
function UI.drawAlert(title, msgs)
186+
function UI.drawAlert(title, msgs, actions)
150187
lcd.clear()
151188
local y = 0
152189
lcd.drawText(2, y, title, MIDSIZE)
@@ -155,6 +192,15 @@ function UI.drawAlert(title, msgs)
155192
lcd.drawText(2, y, msg)
156193
y = y + UI.textSize
157194
end
195+
if actions then
196+
y = y + UI.textSize
197+
if actions.left then
198+
lcd.drawText(2, y, actions.left, 0)
199+
end
200+
if actions.right then
201+
lcd.drawText(LCD_W - 2, y, actions.right, RIGHT)
202+
end
203+
end
158204
end
159205

160206
-- ============================================================================

0 commit comments

Comments
 (0)