Add battery voltage warnings setup via LUA from radio
Related to #505
Add battery voltage warning and minimum values configuration via LUA scripts from the radio.
- New LUA Script: Add
src/SCRIPTS/BF/battery_voltage.luato handle battery voltage warning and minimum values configuration.- Define functions to read and set battery voltage warning values for different battery types (Li-ion, LiPo).
- Use MSP commands to communicate with the flight controller.
- Pages Update: Modify
src/SCRIPTS/BF/pages.luato include a new page entry for battery settings configuration.- Add a new page entry with the title "Battery Settings" and script "battery_voltage.lua".
- UI Update: Modify
src/SCRIPTS/BF/ui.luato include the new battery settings page in the UI menu.- Add the new battery settings page to the UI menu.
Is there a reason why this can't just be a regular page like the rest of them? 🙂
I wanted to built something like this on my own, but saw your PR - thank you and I hope it gets merged at some point.
After compiling the script, I can however not open the battery page, when selecting it on a monochrome display, I get the error that battery_voltage.lua was not found. After moving the file to the SCRIPTS/BF/PAGES folder (currently it is in the SCRIPTS/BF folder), it finds the file, but then I get the error
Syntax error ?:0 attempt to index field 'fields' (a nil value).
Looking through the other page files, all start with
local 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 = {}
and have a different syntax. So I think it needs to be modified to work, before it can be merged.
Also you set the MSP commands to 210 and 211 - however they are defined as
#define MSP_SELECT_SETTING 210 // in message: Select setting number (0-2)
#define MSP_SET_HEADING 211 // in message: Define a new heading hold direction
So would that even work?
This is not the correct way to do it. Closing