Skip to content

Commit c726802

Browse files
authored
Memory savings (#214)
Memory savings
2 parents bbb244d + 49c019c commit c726802

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

src/SCRIPTS/BF/HORUS/horuspre.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ PageFiles =
1212
"gpspids.lua",
1313
}
1414

15-
backgroundFill = TEXT_BGCOLOR
16-
foregroundColor = LINE_COLOR
17-
globalTextOptions = TEXT_COLOR
18-
1915
MenuBox = { x=120, y=100, w=200, x_offset=68, h_line=20, h_offset=6 }
2016
SaveBox = { x=120, y=100, w=180, x_offset=12, h=60, h_offset=12 }
2117
NoTelem = { 192, LCD_H - 28, "No Telemetry", TEXT_COLOR + INVERS + BLINK }

src/SCRIPTS/BF/ui.lua

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ local lastRunTS = 0
2929
local killEnterBreak = 0
3030
local scrollPixelsY = 0
3131

32-
Page = nil
32+
local Page = nil
3333

34-
backgroundFill = backgroundFill or ERASE
35-
foregroundColor = foregroundColor or SOLID
34+
local backgroundFill = TEXT_BGCOLOR or ERASE
35+
local foregroundColor = LINE_COLOR or SOLID
3636

37-
globalTextOptions = globalTextOptions or 0
37+
local globalTextOptions = TEXT_COLOR or 0
3838

3939
local function saveSettings(new)
4040
if Page.values then
@@ -120,16 +120,16 @@ local function processMspReply(cmd,rx_buf)
120120

121121
for i=1,#(Page.fields) do
122122
if (#(Page.values) or 0) >= Page.minBytes then
123-
local f = Page.fields[i]
124-
if f.vals then
125-
f.value = 0;
126-
for idx=1, #(f.vals) do
127-
local raw_val = (Page.values[f.vals[idx]] or 0)
128-
raw_val = bit32.lshift(raw_val, (idx-1)*8)
129-
f.value = bit32.bor(f.value, raw_val)
130-
end
131-
f.value = f.value/(f.scale or 1)
132-
end
123+
local f = Page.fields[i]
124+
if f.vals then
125+
f.value = 0;
126+
for idx=1, #(f.vals) do
127+
local raw_val = (Page.values[f.vals[idx]] or 0)
128+
raw_val = bit32.lshift(raw_val, (idx-1)*8)
129+
f.value = bit32.bor(f.value, raw_val)
130+
end
131+
f.value = f.value/(f.scale or 1)
132+
end
133133
end
134134
end
135135
if Page.postLoad then
@@ -139,22 +139,22 @@ local function processMspReply(cmd,rx_buf)
139139
end
140140

141141
local function incMax(val, inc, base)
142-
return ((val + inc + base - 1) % base) + 1
142+
return ((val + inc + base - 1) % base) + 1
143143
end
144144

145145
local function incPage(inc)
146-
currentPage = incMax(currentPage, inc, #(PageFiles))
147-
Page = nil
148-
currentLine = 1
149-
collectgarbage()
146+
currentPage = incMax(currentPage, inc, #(PageFiles))
147+
Page = nil
148+
currentLine = 1
149+
collectgarbage()
150150
end
151151

152152
local function incLine(inc)
153-
currentLine = clipValue(currentLine + inc, 1, #(Page.fields))
153+
currentLine = clipValue(currentLine + inc, 1, #(Page.fields))
154154
end
155155

156156
local function incMenu(inc)
157-
menuActive = clipValue(menuActive + inc, 1, #(menuList))
157+
menuActive = clipValue(menuActive + inc, 1, #(menuList))
158158
end
159159

160160
local function requestPage()
@@ -201,7 +201,7 @@ local function drawScreen()
201201
local heading_options = text_options
202202
local value_options = text_options
203203
if i == currentLine then
204-
value_options = text_options + INVERS
204+
value_options = text_options + INVERS
205205
if currentState == pageStatus.editing then
206206
value_options = value_options + BLINK
207207
end

0 commit comments

Comments
 (0)