@@ -43,7 +43,7 @@ local actionsIndex = {
43
43
}
44
44
45
45
function setState (name )
46
- if pageStatus [name ] ~= nil then
46
+ if pageStatus [name ] then
47
47
if name == " displayMenu" then
48
48
-- open menu
49
49
menuActive = 1
@@ -63,7 +63,6 @@ function setLock(x) lockedInp = x end
63
63
64
64
function isInpLocked (x )
65
65
if lockedInp == x then
66
- print (" logging: input was locked and is released!! " , x )
67
66
lockedInp = 0
68
67
return 1
69
68
end
@@ -182,7 +181,7 @@ function stepPage(inc)
182
181
end
183
182
184
183
function gotoPage (x )
185
- if PageFiles [x ] ~= nil then
184
+ if PageFiles [x ] then
186
185
currentPage = x
187
186
Page = nil
188
187
currentLine = 1
@@ -228,7 +227,7 @@ local function drawScreen()
228
227
local screen_title = Page .title
229
228
local val = " ---"
230
229
231
- if Page .fields [currentLine ] ~= nil then
230
+ if Page .fields [currentLine ] then
232
231
local currentLineY = Page .fields [currentLine ].y
233
232
if currentLineY <= Page .fields [1 ].y then
234
233
scrollPixelsY = 0
@@ -361,9 +360,9 @@ function run_ui(event)
361
360
if currentState == pageStatus [st ] then
362
361
for t , action in pairs (actionsIndex [i ]) do
363
362
local actionTbl = ctrlSchema [st ][action ]
364
- if actionTbl .cond ~= nil then
363
+ if actionTbl .cond then
365
364
if actionTbl .cond (event , userEvent ) then
366
- if actionTbl .func ~= nil and not isInpLocked (st .. " ." .. action ) then
365
+ if actionTbl .func and not isInpLocked (st .. " ." .. action ) then
367
366
actionTbl .func (event , userEvent )
368
367
end
369
368
break
@@ -418,17 +417,25 @@ function pre_ui(event)
418
417
Page = assert (loadScript (radio .templateHome .. PageFiles [currentPage ]))()
419
418
end
420
419
421
- if Page .run ~= nil and type (Page .run ) == " function" then
420
+ if not Page .didInit and Page .init then
421
+ Page .init ()
422
+ Page .didInit = 1
423
+ end
424
+
425
+ if Page .run then
422
426
if ctrlSchema .display .prevPage .cond (event , userEvent ) or
423
- ctrlSchema .display .nextPage .cond (event , userEvent ) then
427
+ ctrlSchema .display .nextPage .cond (event , userEvent ) or
428
+ ctrlSchema .display .home .cond (event , userEvent ) then
424
429
return run_ui (event )
425
430
end
426
431
427
432
-- reset locked state from home action
428
433
isInpLocked (" display.menu" )
429
434
430
435
lcd .clear ()
431
- return assert (Page .run )(event )
436
+ collectgarbage ()
437
+
438
+ return Page .run (event )
432
439
else
433
440
return run_ui (event )
434
441
end
0 commit comments