template = assert(loadScript(radio.template))()
local margin = template.margin
local indent = template.indent
local lineSpacing = template.lineSpacing
local tableSpacing = template.tableSpacing
local sp = template.listSpacing.field
local yMinLim = radio.yMinLimit
local x = margin
local y = yMinLim - lineSpacing
local inc = { x = function(val) x = x + val return x end, y = function(val) y = y + val return y end }
local labels = {}
local fields = {}
if apiVersion >= 1.45 then
fields[#fields + 1] = { t = "Cell V min.", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 500, vals = { 8, 9 }, scale = 100, mult = 10} --vbatmincellvoltage
fields[#fields + 1] = { t = "Cell V max.", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 500, vals = { 10, 11 }, scale = 100, mult = 10} --vbatmaxcellvoltage
fields[#fields + 1] = { t = "Cell warning V", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 500, vals = { 12, 13 }, scale = 100, mult = 10 } --vbatwarningcellvoltage
fields[#fields + 1] = { t = "Capacity [Ah]", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 8000, vals = { 4, 5 }, scale = 1000, mult = 10 } --vbatwarningcellvoltage
end
return {
read = 32, -- MSP_BATTERY_CONFIG
write = 33, -- MSP_SET_BATTERY_CONFIG
title = "Battery",
reboot = false,
eepromWrite = true,
minBytes = 8,
labels = labels,
fields = fields,
preSave = function(self)
self.values[1] = -1
return self.values
end,
}