@@ -34,6 +34,10 @@ local saveTimeout = 0
3434local saveRetries = 0
3535local saveMaxRetries = 0
3636
37+ backgroundFill = backgroundFill or ERASE
38+ foregroundColor = foregroundColor or SOLID
39+ globalTextOptions = globalTextOptions or 0
40+
3741local function saveSettings (new )
3842 local page = SetupPages [currentPage ]
3943 if page .values then
@@ -153,21 +157,26 @@ local function requestPage(page)
153157 end
154158end
155159
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+
156165local function drawScreen (page ,page_locked )
157166
158167 local screen_title = page .title
159168
160- lcd . drawText ( 1 , 1 , " Betaflight / " .. screen_title , INVERS )
169+ drawScreenTitle ( " Betaflight / " .. screen_title )
161170
162171 for i = 1 ,# (page .text ) do
163172 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 )
165174 end
166175
167176 for i = 1 ,# (page .fields ) do
168177 local f = page .fields [i ]
169178
170- local text_options = 0
179+ local text_options = globalTextOptions
171180 if i == currentLine then
172181 text_options = INVERS
173182 if gState == EDITING then
@@ -178,7 +187,7 @@ local function drawScreen(page,page_locked)
178187 local spacing = 20
179188
180189 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 )
182191
183192 -- draw some value
184193 if f .sp ~= nil then
@@ -231,16 +240,17 @@ local function drawMenu()
231240 local h_line = MenuBox .h_line
232241 local h_offset = MenuBox .h_offset
233242 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 )
237247
238248 for i ,e in ipairs (menuList ) do
249+ local text_options = globalTextOptions
239250 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
243252 end
253+ lcd .drawText (x + MenuBox .x_offset ,y + (i - 1 )* h_line + h_offset ,e .t ,text_options )
244254 end
245255end
246256
@@ -271,9 +281,15 @@ local function run_ui(event)
271281 mspProcessTxQ ()
272282
273283 -- navigation
274- if (event == EVT_MENU_LONG ) then
284+ if (event == EVT_MENU_LONG ) then -- Taranis QX7 / X9
275285 menuActive = 1
276286 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+
277293 -- menu is currently displayed
278294 elseif gState == MENU_DISP then
279295 if event == EVT_EXIT_BREAK then
@@ -283,12 +299,18 @@ local function run_ui(event)
283299 elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
284300 incMenu (1 )
285301 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
288308 end
289309 -- normal page viewing
290310 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
292314 incPage (1 )
293315 elseif event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
294316 incLine (- 1 )
@@ -324,21 +346,24 @@ local function run_ui(event)
324346
325347 -- draw screen
326348 lcd .clear ()
349+ if TEXT_BGCOLOR then
350+ lcd .drawFilledRectangle (0 , 0 , LCD_W , LCD_H , TEXT_BGCOLOR )
351+ end
327352 drawScreen (page ,page_locked )
328353
329354 -- do we have valid telemetry data?
330355 if getValue (" RSSI" ) == 0 then
331356 -- No!
332357 lcd .drawText (NoTelem [1 ],NoTelem [2 ],NoTelem [3 ],NoTelem [4 ])
333- invalidatePages ()
358+ -- invalidatePages()
334359 end
335360
336361 if gState == MENU_DISP then
337362 drawMenu ()
338363 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 )
340365 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 ) )
342367 end
343368
344369 processMspReply (mspPollReply ())
0 commit comments