@@ -34,6 +34,10 @@ local saveTimeout = 0
34
34
local saveRetries = 0
35
35
local saveMaxRetries = 0
36
36
37
+ backgroundFill = backgroundFill or ERASE
38
+ foregroundColor = foregroundColor or SOLID
39
+ globalTextOptions = globalTextOptions or 0
40
+
37
41
local function saveSettings (new )
38
42
local page = SetupPages [currentPage ]
39
43
if page .values then
@@ -153,21 +157,26 @@ local function requestPage(page)
153
157
end
154
158
end
155
159
160
+ function drawScreenTitle (screen_title )
161
+ lcd .drawFilledRectangle (0 , 0 , LCD_W , 10 , SOLID )
162
+ lcd .drawText (1 ,1 ,screen_title ,INVERS )
163
+ end
164
+
156
165
local function drawScreen (page ,page_locked )
157
166
158
167
local screen_title = page .title
159
168
160
- lcd . drawText ( 1 , 1 , " Betaflight / " .. screen_title , INVERS )
169
+ drawScreenTitle ( " Betaflight / " .. screen_title )
161
170
162
171
for i = 1 ,# (page .text ) do
163
172
local f = page .text [i ]
164
- lcd .drawText (f .x , f .y , f .t , text_options )
173
+ lcd .drawText (f .x , f .y , f .t , globalTextOptions )
165
174
end
166
175
167
176
for i = 1 ,# (page .fields ) do
168
177
local f = page .fields [i ]
169
178
170
- local text_options = 0
179
+ local text_options = globalTextOptions
171
180
if i == currentLine then
172
181
text_options = INVERS
173
182
if gState == EDITING then
@@ -178,7 +187,7 @@ local function drawScreen(page,page_locked)
178
187
local spacing = 20
179
188
180
189
if f .t ~= nil then
181
- lcd .drawText (f .x , f .y , f .t .. " :" , 0 )
190
+ lcd .drawText (f .x , f .y , f .t .. " :" , globalTextOptions )
182
191
183
192
-- draw some value
184
193
if f .sp ~= nil then
@@ -231,16 +240,17 @@ local function drawMenu()
231
240
local h_line = MenuBox .h_line
232
241
local h_offset = MenuBox .h_offset
233
242
local h = # (menuList ) * h_line + h_offset * 2
234
- lcd .drawFilledRectangle (x ,y ,w ,h ,ERASE )
235
- lcd .drawRectangle (x ,y ,w - 1 ,h - 1 ,SOLID )
236
- lcd .drawText (x + h_line / 2 ,y + h_offset ," Menu:" )
243
+
244
+ lcd .drawFilledRectangle (x ,y ,w ,h ,backgroundFill )
245
+ lcd .drawRectangle (x ,y ,w - 1 ,h - 1 ,foregroundColor )
246
+ lcd .drawText (x + h_line / 2 ,y + h_offset ," Menu:" ,globalTextOptions )
237
247
238
248
for i ,e in ipairs (menuList ) do
249
+ local text_options = globalTextOptions
239
250
if menuActive == i then
240
- lcd .drawText (x + MenuBox .x_offset ,y + (i - 1 )* h_line + h_offset ,e .t ,INVERS )
241
- else
242
- lcd .drawText (x + MenuBox .x_offset ,y + (i - 1 )* h_line + h_offset ,e .t )
251
+ text_options = text_options + INVERS
243
252
end
253
+ lcd .drawText (x + MenuBox .x_offset ,y + (i - 1 )* h_line + h_offset ,e .t ,text_options )
244
254
end
245
255
end
246
256
@@ -271,9 +281,15 @@ local function run_ui(event)
271
281
mspProcessTxQ ()
272
282
273
283
-- navigation
274
- if (event == EVT_MENU_LONG ) then
284
+ if (event == EVT_MENU_LONG ) then -- Taranis QX7 / X9
275
285
menuActive = 1
276
286
gState = MENU_DISP
287
+
288
+ elseif EVT_PAGEUP_FIRST and (event == EVT_ENTER_LONG ) then -- Horus
289
+ menuActive = 1
290
+ killEnterBreak = 1
291
+ gState = MENU_DISP
292
+
277
293
-- menu is currently displayed
278
294
elseif gState == MENU_DISP then
279
295
if event == EVT_EXIT_BREAK then
@@ -283,12 +299,18 @@ local function run_ui(event)
283
299
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
284
300
incMenu (1 )
285
301
elseif event == EVT_ENTER_BREAK then
286
- gState = PAGE_DISPLAY
287
- menuList [menuActive ].f ()
302
+ if killEnterBreak == 1 then
303
+ killEnterBreak = 0
304
+ else
305
+ gState = PAGE_DISPLAY
306
+ menuList [menuActive ].f ()
307
+ end
288
308
end
289
309
-- normal page viewing
290
310
elseif gState <= PAGE_DISPLAY then
291
- if event == EVT_MENU_BREAK then
311
+ if event == EVT_PAGEUP_FIRST then
312
+ incPage (- 1 )
313
+ elseif event == EVT_MENU_BREAK or event == EVT_PAGEDN_FIRST then
292
314
incPage (1 )
293
315
elseif event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
294
316
incLine (- 1 )
@@ -324,21 +346,24 @@ local function run_ui(event)
324
346
325
347
-- draw screen
326
348
lcd .clear ()
349
+ if TEXT_BGCOLOR then
350
+ lcd .drawFilledRectangle (0 , 0 , LCD_W , LCD_H , TEXT_BGCOLOR )
351
+ end
327
352
drawScreen (page ,page_locked )
328
353
329
354
-- do we have valid telemetry data?
330
355
if getValue (" RSSI" ) == 0 then
331
356
-- No!
332
357
lcd .drawText (NoTelem [1 ],NoTelem [2 ],NoTelem [3 ],NoTelem [4 ])
333
- invalidatePages ()
358
+ -- invalidatePages()
334
359
end
335
360
336
361
if gState == MENU_DISP then
337
362
drawMenu ()
338
363
elseif gState == PAGE_SAVING then
339
- lcd .drawFilledRectangle (SaveBox .x ,SaveBox .y ,SaveBox .w ,SaveBox .h ,ERASE )
364
+ lcd .drawFilledRectangle (SaveBox .x ,SaveBox .y ,SaveBox .w ,SaveBox .h ,backgroundFill )
340
365
lcd .drawRectangle (SaveBox .x ,SaveBox .y ,SaveBox .w ,SaveBox .h ,SOLID )
341
- lcd .drawText (SaveBox .x + SaveBox .x_offset ,SaveBox .y + SaveBox .h_offset ," Saving..." ,DBLSIZE + BLINK )
366
+ lcd .drawText (SaveBox .x + SaveBox .x_offset ,SaveBox .y + SaveBox .h_offset ," Saving..." ,DBLSIZE + BLINK + ( globalTextOptions ) )
342
367
end
343
368
344
369
processMspReply (mspPollReply ())
0 commit comments