Skip to content

Commit 30f8a9e

Browse files
committed
Added battery menu
1 parent 1a90024 commit 30f8a9e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/SCRIPTS/BF/PAGES/battery.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
local template = assert(loadScript(radio.template))()
2+
local margin = template.margin
3+
local indent = template.indent
4+
local lineSpacing = template.lineSpacing
5+
local tableSpacing = template.tableSpacing
6+
local sp = template.listSpacing.field
7+
local yMinLim = radio.yMinLimit
8+
local x = margin
9+
local y = yMinLim - lineSpacing
10+
local inc = { x = function(val) x = x + val return x end, y = function(val) y = y + val return y end }
11+
local labels = {}
12+
local fields = {}
13+
14+
labels[#labels + 1] = { t = "Voltage Settings", x = x, y = inc.y(lineSpacing) }
15+
fields[#fields + 1] = { t = "Minimum Cell", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 500, vals = { 8, 9 }, scale = 100 }
16+
fields[#fields + 1] = { t = "Maximum Cell", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 500, vals = { 10, 11 }, scale = 100 }
17+
fields[#fields + 1] = { t = "Warning Cell", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 500, vals = { 12, 13 }, scale = 100 }
18+
19+
labels[#labels + 1] = { t = "Capacity Settings", x = x, y = inc.y(lineSpacing) }
20+
fields[#fields + 1] = { t = "Battery Capacity", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, steps = 25, max = 10000, vals = { 4, 5 } }
21+
22+
return {
23+
read = 32, -- MSP_BATTERY_CONFIG
24+
write = 33, -- MSP_SET_BATTERY_CONFIG
25+
title = "Battery",
26+
reboot = false,
27+
eepromWrite = true,
28+
minBytes = 13,
29+
labels = labels,
30+
fields = fields
31+
}

src/SCRIPTS/BF/pages.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ if apiVersion >= 1.16 then
4040
PageFiles[#PageFiles + 1] = { title = "System / Motor", script = "pwm.lua", init = "PAGES/INIT/pwm.lua" }
4141
end
4242

43+
if apiVersion >= 1.45 then
44+
PageFiles[#PageFiles + 1] = { title = "Battery", script = "battery.lua" }
45+
end
46+
4347
if apiVersion >= 1.16 then
4448
PageFiles[#PageFiles + 1] = { title = "Receiver", script = "rx.lua" }
4549
end

0 commit comments

Comments
 (0)