-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.lua` to 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.lua` to 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.lua` to include the new battery settings page in the UI menu. * Add the new battery settings page to the UI menu.
- Loading branch information
1 parent
1a90024
commit 6f2f282
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
local MSP_SET_BATTERY_CONFIG = 210 | ||
local MSP_BATTERY_CONFIG = 211 | ||
|
||
local batteryConfig = { | ||
warningVoltage = 0, | ||
minVoltage = 0, | ||
batteryType = 0 | ||
} | ||
|
||
local function processMspReply(cmd, payload, err) | ||
if cmd == MSP_BATTERY_CONFIG and not err then | ||
batteryConfig.warningVoltage = payload[1] | ||
batteryConfig.minVoltage = payload[2] | ||
batteryConfig.batteryType = payload[3] | ||
end | ||
end | ||
|
||
local function getBatteryConfig() | ||
protocol.mspRead(MSP_BATTERY_CONFIG) | ||
mspProcessTxQ() | ||
processMspReply(mspPollReply()) | ||
end | ||
|
||
local function setBatteryConfig() | ||
local values = { | ||
batteryConfig.warningVoltage, | ||
batteryConfig.minVoltage, | ||
batteryConfig.batteryType | ||
} | ||
protocol.mspWrite(MSP_SET_BATTERY_CONFIG, values) | ||
mspProcessTxQ() | ||
processMspReply(mspPollReply()) | ||
end | ||
|
||
local function init() | ||
getBatteryConfig() | ||
end | ||
|
||
local function run(event) | ||
if event == EVT_VIRTUAL_ENTER then | ||
setBatteryConfig() | ||
end | ||
return 0 | ||
end | ||
|
||
return { init = init, run = run } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters