From 0d472a324706c3cecf179f85ec400540064b5ba9 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Thu, 16 Feb 2023 20:18:34 +0100 Subject: [PATCH 01/23] Add baud rate requirement --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2464a14..0f40f74 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ - TBS Crossfire/Tracer TX / RX - v2.11 or newer; - FrSky TX / RX with support for SmartPort - While most receivers with SmartPort support work fine, it is recommended to update the receiver to the most recent firmware version to correct any known bugs in telemetry. - ImmersionRC Ghost - Latest firmware. +- Baud rate - Set to 400K in EdgeTX/OpenTX for Crossfire, Tracer, ExpressLRS and Ghost. ## Installing From 7bf0f044e16fd7427c5c9dcc75a94f9f0e2edca1 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Sun, 5 Mar 2023 22:59:10 +0100 Subject: [PATCH 02/23] Add level angle limit --- src/SCRIPTS/BF/PAGES/pid_advanced.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/SCRIPTS/BF/PAGES/pid_advanced.lua b/src/SCRIPTS/BF/PAGES/pid_advanced.lua index 16d54cf..5be23f1 100644 --- a/src/SCRIPTS/BF/PAGES/pid_advanced.lua +++ b/src/SCRIPTS/BF/PAGES/pid_advanced.lua @@ -11,6 +11,14 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y = local labels = {} local fields = {} +if apiVersion >= 1.31 then + labels[#labels + 1] = { t = "Angle/Horizon", x = x, y = inc.y(lineSpacing) } + fields[#fields + 1] = { t = "Angle Limit", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 10, max = 90, vals = { 18 } } + if apiVersion < 1.36 then + fields[#fields + 1] = { t = "Stick Sensitivity", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 10, max = 200, vals = { 19 } } + end +end + if apiVersion >= 1.40 then labels[#labels + 1] = { t = "Acro Trainer", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Angle Limit", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 20, max = 80, vals = { 32 } } From e2597af37aa0a3ee24c97acdcc12ea00f2f1c94e Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Sun, 12 Mar 2023 20:29:27 +0100 Subject: [PATCH 03/23] Skip vtx tables download if not available --- src/SCRIPTS/BF/MSP/common.lua | 9 +++------ src/SCRIPTS/BF/PAGES/vtx.lua | 5 +++-- src/SCRIPTS/BF/acc_cal.lua | 4 ++-- src/SCRIPTS/BF/api_version.lua | 4 ++-- src/SCRIPTS/BF/board_info.lua | 4 ++-- src/SCRIPTS/BF/mcu_id.lua | 4 ++-- src/SCRIPTS/BF/rssi.lua | 4 ++-- src/SCRIPTS/BF/rtc.lua | 4 ++-- src/SCRIPTS/BF/ui.lua | 4 ++-- src/SCRIPTS/BF/vtx_tables.lua | 9 +++++++-- 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/SCRIPTS/BF/MSP/common.lua b/src/SCRIPTS/BF/MSP/common.lua index dc20f9b..467c1ce 100644 --- a/src/SCRIPTS/BF/MSP/common.lua +++ b/src/SCRIPTS/BF/MSP/common.lua @@ -6,6 +6,7 @@ local MSP_STARTFLAG = bit32.lshift(1,4) local mspSeq = 0 local mspRemoteSeq = 0 local mspRxBuf = {} +local mspRxError = false local mspRxSize = 0 local mspRxCRC = 0 local mspRxReq = 0 @@ -65,17 +66,13 @@ end function mspReceivedReply(payload) local idx = 1 local status = payload[idx] - local err = bit32.btest(status, 0x80) local version = bit32.rshift(bit32.band(status, 0x60), 5) local start = bit32.btest(status, 0x10) local seq = bit32.band(status, 0x0F) idx = idx + 1 - if err then - mspStarted = false - return nil - end if start then mspRxBuf = {} + mspRxError = bit32.btest(status, 0x80) mspRxSize = payload[idx] mspRxReq = mspLastReq idx = idx + 1 @@ -117,7 +114,7 @@ function mspPollReply() return nil elseif mspReceivedReply(mspData) then mspLastReq = 0 - return mspRxReq, mspRxBuf + return mspRxReq, mspRxBuf, mspRxError end end end diff --git a/src/SCRIPTS/BF/PAGES/vtx.lua b/src/SCRIPTS/BF/PAGES/vtx.lua index e2a978e..b40e912 100644 --- a/src/SCRIPTS/BF/PAGES/vtx.lua +++ b/src/SCRIPTS/BF/PAGES/vtx.lua @@ -12,8 +12,9 @@ local labels = {} local fields = {} local vtx_tables -if apiVersion >= 1.42 then - vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"))() +local f = loadScript("VTX_TABLES/"..mcuId..".lua") +if apiVersion >= 1.42 and f then + vtx_tables = f() else vtx_tables = assert(loadScript("VTX_TABLES/vtx_defaults.lua"))() end diff --git a/src/SCRIPTS/BF/acc_cal.lua b/src/SCRIPTS/BF/acc_cal.lua index 582d459..0ebfc17 100644 --- a/src/SCRIPTS/BF/acc_cal.lua +++ b/src/SCRIPTS/BF/acc_cal.lua @@ -3,8 +3,8 @@ local accCalibrated = false local lastRunTS = 0 local INTERVAL = 500 -local function processMspReply(cmd,rx_buf) - if cmd == MSP_ACC_CALIBRATION then +local function processMspReply(cmd,rx_buf,err) + if cmd == MSP_ACC_CALIBRATION and not err then accCalibrated = true end end diff --git a/src/SCRIPTS/BF/api_version.lua b/src/SCRIPTS/BF/api_version.lua index c80efb3..5bcb4c2 100644 --- a/src/SCRIPTS/BF/api_version.lua +++ b/src/SCRIPTS/BF/api_version.lua @@ -4,8 +4,8 @@ local apiVersionReceived = false local lastRunTS = 0 local INTERVAL = 50 -local function processMspReply(cmd,rx_buf) - if cmd == MSP_API_VERSION and #rx_buf >= 3 then +local function processMspReply(cmd,rx_buf,err) + if cmd == MSP_API_VERSION and #rx_buf >= 3 and not err then apiVersion = rx_buf[2] + rx_buf[3] / 100 apiVersionReceived = true end diff --git a/src/SCRIPTS/BF/board_info.lua b/src/SCRIPTS/BF/board_info.lua index 10efbe4..2ba3ec1 100644 --- a/src/SCRIPTS/BF/board_info.lua +++ b/src/SCRIPTS/BF/board_info.lua @@ -20,8 +20,8 @@ local i2cRegisteredDeviceCount = 0 local lastRunTS = 0 local INTERVAL = 100 -local function processMspReply(cmd, payload) - if cmd == MSP_BOARD_INFO then +local function processMspReply(cmd, payload, err) + if cmd == MSP_BOARD_INFO and not err then local length local i = 1 length = 4 diff --git a/src/SCRIPTS/BF/mcu_id.lua b/src/SCRIPTS/BF/mcu_id.lua index 26d1e2b..f3c8438 100644 --- a/src/SCRIPTS/BF/mcu_id.lua +++ b/src/SCRIPTS/BF/mcu_id.lua @@ -5,8 +5,8 @@ local MCUIdReceived = false local lastRunTS = 0 local INTERVAL = 100 -local function processMspReply(cmd, payload) - if cmd == MSP_UID then +local function processMspReply(cmd, payload, err) + if cmd == MSP_UID and not err then local i = 1 local id = "" for j = 1, 3 do diff --git a/src/SCRIPTS/BF/rssi.lua b/src/SCRIPTS/BF/rssi.lua index 401e710..dc31dd0 100644 --- a/src/SCRIPTS/BF/rssi.lua +++ b/src/SCRIPTS/BF/rssi.lua @@ -9,8 +9,8 @@ local rssiSource = RSSI_SOURCE_NONE local lastRunTS = 0 local INTERVAL = 50 -local function processMspReply(cmd,rx_buf) - if cmd == MSP_TX_INFO and #rx_buf >= 1 then +local function processMspReply(cmd,rx_buf,err) + if cmd == MSP_TX_INFO and #rx_buf >= 1 and not err then rssiSource = rx_buf[1] rssiSourceReceived = true end diff --git a/src/SCRIPTS/BF/rtc.lua b/src/SCRIPTS/BF/rtc.lua index 148a2fd..f0cd330 100644 --- a/src/SCRIPTS/BF/rtc.lua +++ b/src/SCRIPTS/BF/rtc.lua @@ -4,8 +4,8 @@ local timeIsSet = false local lastRunTS = 0 local INTERVAL = 50 -local function processMspReply(cmd,rx_buf) - if cmd == MSP_SET_RTC then +local function processMspReply(cmd,rx_buf,err) + if cmd == MSP_SET_RTC and not err then timeIsSet = true end end diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index 23f5bb9..8a3722c 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -96,8 +96,8 @@ local function createPopupMenu() end end -local function processMspReply(cmd,rx_buf) - if not Page or not rx_buf then +local function processMspReply(cmd,rx_buf,err) + if not Page or not rx_buf or err then elseif cmd == Page.write then if Page.eepromWrite then eepromWrite() diff --git a/src/SCRIPTS/BF/vtx_tables.lua b/src/SCRIPTS/BF/vtx_tables.lua index 2efa894..1340af8 100644 --- a/src/SCRIPTS/BF/vtx_tables.lua +++ b/src/SCRIPTS/BF/vtx_tables.lua @@ -2,6 +2,7 @@ local MSP_VTX_CONFIG = 88 local MSP_VTXTABLE_BAND = 137 local MSP_VTXTABLE_POWERLEVEL = 138 +local vtxAvailable = true local vtxTableAvailable = false local vtxConfigReceived = false local vtxFrequencyTableReceived = false @@ -18,8 +19,12 @@ local powerTable = {} local lastRunTS = 0 local INTERVAL = 100 -local function processMspReply(cmd, payload) +local function processMspReply(cmd, payload, err) if cmd == MSP_VTX_CONFIG then + if err then + vtxAvailable = false + return + end vtxConfigReceived = true vtxTableAvailable = payload[12] ~= 0 vtxTableConfig.bands = payload[13] @@ -113,7 +118,7 @@ local function getVtxTables() end mspProcessTxQ() processMspReply(mspPollReply()) - return vtxTablesReceived + return vtxTablesReceived or not vtxAvailable end return { f = getVtxTables, t = "Downloading VTX tables" } From 3ea553eda0d04e3a15745705824aaf8abc294a84 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Sun, 12 Mar 2023 21:55:58 +0100 Subject: [PATCH 04/23] Display message if page not available --- src/SCRIPTS/BF/ui.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index 8a3722c..fee070e 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -97,7 +97,7 @@ local function createPopupMenu() end local function processMspReply(cmd,rx_buf,err) - if not Page or not rx_buf or err then + if not Page or not rx_buf then elseif cmd == Page.write then if Page.eepromWrite then eepromWrite() @@ -109,6 +109,9 @@ local function processMspReply(cmd,rx_buf,err) rebootFc() end invalidatePages() + elseif cmd == Page.read and err then + Page.fields = { { x = 6, y = radio.yMinLimit, value = "", ro = true } } + Page.labels = { { x = 6, y = radio.yMinLimit, t = "N/A" } } elseif cmd == Page.read and #rx_buf > 0 then Page.values = rx_buf for i=1,#Page.fields do From 61d302980967f05f3e8a4957dfc45c859559cdf0 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Mon, 13 Mar 2023 14:08:18 +0100 Subject: [PATCH 05/23] Create empty vtx table if not available --- src/SCRIPTS/BF/PAGES/vtx.lua | 5 ++--- src/SCRIPTS/BF/vtx_tables.lua | 14 ++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/SCRIPTS/BF/PAGES/vtx.lua b/src/SCRIPTS/BF/PAGES/vtx.lua index b40e912..e2a978e 100644 --- a/src/SCRIPTS/BF/PAGES/vtx.lua +++ b/src/SCRIPTS/BF/PAGES/vtx.lua @@ -12,9 +12,8 @@ local labels = {} local fields = {} local vtx_tables -local f = loadScript("VTX_TABLES/"..mcuId..".lua") -if apiVersion >= 1.42 and f then - vtx_tables = f() +if apiVersion >= 1.42 then + vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"))() else vtx_tables = assert(loadScript("VTX_TABLES/vtx_defaults.lua"))() end diff --git a/src/SCRIPTS/BF/vtx_tables.lua b/src/SCRIPTS/BF/vtx_tables.lua index 1340af8..d7edbba 100644 --- a/src/SCRIPTS/BF/vtx_tables.lua +++ b/src/SCRIPTS/BF/vtx_tables.lua @@ -2,7 +2,6 @@ local MSP_VTX_CONFIG = 88 local MSP_VTXTABLE_BAND = 137 local MSP_VTXTABLE_POWERLEVEL = 138 -local vtxAvailable = true local vtxTableAvailable = false local vtxConfigReceived = false local vtxFrequencyTableReceived = false @@ -12,7 +11,6 @@ local requestedBand = 1 local requestedPowerLevel = 1 local vtxTableConfig = {} local frequencyTable = {} -local frequenciesPerBand = 0 local bandTable = {} local powerTable = {} @@ -22,7 +20,15 @@ local INTERVAL = 100 local function processMspReply(cmd, payload, err) if cmd == MSP_VTX_CONFIG then if err then - vtxAvailable = false + -- Vtx not available. Create empty vtx table to skip future download attempts + frequencyTable[1] = {} + vtxTableConfig.channels = 0 + bandTable = { [0] = "U", "1" } + powerTable = { "LV0" } + vtxConfigReceived = true + vtxTableAvailable = true + vtxFrequencyTableReceived = true + vtxPowerTableReceived = true return end vtxConfigReceived = true @@ -118,7 +124,7 @@ local function getVtxTables() end mspProcessTxQ() processMspReply(mspPollReply()) - return vtxTablesReceived or not vtxAvailable + return vtxTablesReceived end return { f = getVtxTables, t = "Downloading VTX tables" } From 47f9efbbe45c958108862d2ec63fb30a2fc73a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiripolszky=20K=C3=A1roly?= Date: Thu, 25 May 2023 19:02:19 +0200 Subject: [PATCH 06/23] Hide VTX menu when feature is unavailable --- src/SCRIPTS/BF/features.lua | 5 +++++ src/SCRIPTS/BF/ui.lua | 20 +++++++++++++++++++- src/SCRIPTS/BF/ui_init.lua | 13 +++++++++---- src/SCRIPTS/BF/vtx_tables.lua | 2 ++ src/SCRIPTS/TOOLS/bf.lua | 1 + 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/SCRIPTS/BF/features.lua diff --git a/src/SCRIPTS/BF/features.lua b/src/SCRIPTS/BF/features.lua new file mode 100644 index 0000000..d56d8ff --- /dev/null +++ b/src/SCRIPTS/BF/features.lua @@ -0,0 +1,5 @@ +local features = { + vtx = true, +} + +return features diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index fee070e..1dd1161 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -82,6 +82,24 @@ local function confirm(page) collectgarbage() end +local function filterAvailablePages(pageFiles) + local newPageFiles = pageFiles + + local function skipPage(script) + local currentPageFiles = {} + for i = 1, #newPageFiles do + if newPageFiles[i].script ~= script then + currentPageFiles[#currentPageFiles + 1] = newPageFiles[i] + end + end + newPageFiles = currentPageFiles + end + + if not features.vtx then skipPage("vtx.lua") end + + return newPageFiles +end + local function createPopupMenu() popupMenuActive = 1 popupMenu = {} @@ -296,7 +314,7 @@ local function run_ui(event) return 0 end init = nil - PageFiles = assert(loadScript("pages.lua"))() + PageFiles = filterAvailablePages(assert(loadScript("pages.lua"))()) invalidatePages() uiState = prevUiState or uiStatus.mainMenu prevUiState = nil diff --git a/src/SCRIPTS/BF/ui_init.lua b/src/SCRIPTS/BF/ui_init.lua index 29ca80e..1c624c8 100644 --- a/src/SCRIPTS/BF/ui_init.lua +++ b/src/SCRIPTS/BF/ui_init.lua @@ -22,10 +22,15 @@ local function init() mcuIdReceived = getMCUId.f() if mcuIdReceived then getMCUId = nil - local f = loadScript("VTX_TABLES/"..mcuId..".lua") - if f and f() then - vtxTablesReceived = true - f = nil + local f = loadScript("VTX_TABLES/" .. mcuId .. ".lua") + if f then + local table = f() + if table then + vtxTablesReceived = true + features.vtx = 0 < table.frequenciesPerBand + f = nil + table = nil + end end collectgarbage() f = loadScript("BOARD_INFO/"..mcuId..".lua") diff --git a/src/SCRIPTS/BF/vtx_tables.lua b/src/SCRIPTS/BF/vtx_tables.lua index d7edbba..13f0526 100644 --- a/src/SCRIPTS/BF/vtx_tables.lua +++ b/src/SCRIPTS/BF/vtx_tables.lua @@ -29,10 +29,12 @@ local function processMspReply(cmd, payload, err) vtxTableAvailable = true vtxFrequencyTableReceived = true vtxPowerTableReceived = true + features.vtx = false return end vtxConfigReceived = true vtxTableAvailable = payload[12] ~= 0 + features.vtx = vtxTableAvailable vtxTableConfig.bands = payload[13] vtxTableConfig.channels = payload[14] vtxTableConfig.powerLevels = payload[15] diff --git a/src/SCRIPTS/TOOLS/bf.lua b/src/SCRIPTS/TOOLS/bf.lua index 3c4ee8b..2b42f18 100644 --- a/src/SCRIPTS/TOOLS/bf.lua +++ b/src/SCRIPTS/TOOLS/bf.lua @@ -12,6 +12,7 @@ if scriptsCompiled then radio = assert(loadScript("radios.lua"))().msp assert(loadScript(protocol.mspTransport))() assert(loadScript("MSP/common.lua"))() + features = assert(loadScript("features.lua"))() run = assert(loadScript("ui.lua"))() else run = assert(loadScript("COMPILE/compile.lua"))() From 59b9d74d73231ca19b5ff54d1f277f8d671a31a6 Mon Sep 17 00:00:00 2001 From: adarkthinline <48429025+adarkthinline@users.noreply.github.com> Date: Tue, 29 Aug 2023 12:31:27 +0000 Subject: [PATCH 07/23] Modified Readme.md Ghost Race250 requirement for LUA script --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0f40f74..5611d6f 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,14 @@ ## Requirements - Betaflight - As a best practice, it is recommended to use the most recent stable release of Betaflight to obtain the best possible results; -- Telemetry - Telemetry has to be enabled and supported by the TX / RX for the scripts to be able to communicate with the flight controller; +- Telemetry - Telemetry has to be enabled in Betaflight Receiver tab and supported by the TX / RX for the scripts to be able to communicate with the flight controller; - OpenTX - 2.3.12 or newer; - EdgeTX - 2.4.0 or newer; - ExpressLRS - 2.0.1 or newer; - TBS Crossfire/Tracer TX / RX - v2.11 or newer; - FrSky TX / RX with support for SmartPort - While most receivers with SmartPort support work fine, it is recommended to update the receiver to the most recent firmware version to correct any known bugs in telemetry. -- ImmersionRC Ghost - Latest firmware. -- Baud rate - Set to 400K in EdgeTX/OpenTX for Crossfire, Tracer, ExpressLRS and Ghost. +- ImmersionRC Ghost RX module - Latest firmware and module set to RF Mode "Race250" - see (Ghost receiver manual pg 36-38) (Other RF Modes have issues or do not have telemetry to allow Betaflight LUA to work). +- Baud rate - Set to 400K in EdgeTX/OpenTX for Crossfire, Tracer, ExpressLRS. ## Installing From 64903c6668c9904907c3440a21d0d53e5bcd689a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiripolszky=20K=C3=A1roly?= Date: Fri, 20 Oct 2023 14:52:47 +0200 Subject: [PATCH 08/23] Information about hiding the menu, followup to #480 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5611d6f..67a520b 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ Depending on the size of the vtx tables and the telemetry protocol used, downloa ![Download VTX tables](docs/assets/images/download_vtx_tables.gif) +Please note that if the "VTX" feature wasn't included in your Betaflight firmware build, the downloading of the VTX tables will be skipped and the VTX menu item won't be available. The initial setup of the VTX/VTX tables must be done using the [Configurator](https://github.com/betaflight/betaflight-configurator). + ### Betaflight CMS **!! IMPORTANT: TBS Crossfire/Tracer only !!** From 1f890f533f7c752e3b7ee9e01c3ad161c07b01fe Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Mon, 8 Jan 2024 15:23:34 +0100 Subject: [PATCH 09/23] Migrate hub to gh See: actions/runner-images#8362 Usage: https://cli.github.com/manual/gh_release_edit --- .github/workflows/build-release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index dbf60c7..fba4d04 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -28,12 +28,12 @@ jobs: - name: Attach assets to release run: | set -x - assets=() + ASSETS=() for asset in Assets/*.zip; do - assets+=("-a" "$asset") + ASSETS+=("-a" "$asset") echo "$asset" done - tag_name="${GITHUB_REF##*/}" - hub release edit "${assets[@]}" -m "" "$tag_name" + TAG_NAME="${GITHUB_REF##*/}" + gh release edit "${ASSETS[@]}" "{TAG_NAME}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 8c3dcd33d70297b460e07e0c9c3f202599ac51c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiripolszky=20K=C3=A1roly?= Date: Sun, 14 Jan 2024 13:02:39 +0100 Subject: [PATCH 10/23] Hide GPS settings if unavailable --- src/SCRIPTS/BF/PAGES/vtx.lua | 2 -- src/SCRIPTS/BF/features.lua | 1 + src/SCRIPTS/BF/features_info.lua | 52 ++++++++++++++++++++++++++++++++ src/SCRIPTS/BF/pages.lua | 6 ++-- src/SCRIPTS/BF/ui.lua | 20 +----------- src/SCRIPTS/BF/ui_init.lua | 13 ++++++-- 6 files changed, 68 insertions(+), 26 deletions(-) create mode 100644 src/SCRIPTS/BF/features_info.lua diff --git a/src/SCRIPTS/BF/PAGES/vtx.lua b/src/SCRIPTS/BF/PAGES/vtx.lua index e2a978e..0e002b4 100644 --- a/src/SCRIPTS/BF/PAGES/vtx.lua +++ b/src/SCRIPTS/BF/PAGES/vtx.lua @@ -1,8 +1,6 @@ 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 diff --git a/src/SCRIPTS/BF/features.lua b/src/SCRIPTS/BF/features.lua index d56d8ff..383252a 100644 --- a/src/SCRIPTS/BF/features.lua +++ b/src/SCRIPTS/BF/features.lua @@ -1,5 +1,6 @@ local features = { vtx = true, + gps = true, } return features diff --git a/src/SCRIPTS/BF/features_info.lua b/src/SCRIPTS/BF/features_info.lua new file mode 100644 index 0000000..bb28ecf --- /dev/null +++ b/src/SCRIPTS/BF/features_info.lua @@ -0,0 +1,52 @@ +local MSP_GPS_CONFIG = 135 +local MSP_VTX_CONFIG = 88 + +local isGpsRead = false +local isVtxRead = true -- Checking VTX is done in `vtx_tables.lua` + +local lastRunTS = 0 +local INTERVAL = 100 + +local returnTable = { + f = nil, + t = "", +} + +local function processMspReply(cmd, payload, err) + local isOkay = not err + if cmd == MSP_GPS_CONFIG then + isGpsRead = true + local providerSet = payload[1] ~= 0 + features.gps = isOkay and providerSet + elseif cmd == MSP_VTX_CONFIG then + isVtxRead = true + local vtxTableAvailable = payload[12] ~= 0 + features.vtx = isOkay and vtxTableAvailable + end +end + +local function updateFeatures() + if lastRunTS + INTERVAL < getTime() then + lastRunTS = getTime() + local cmd + if not isGpsRead then + cmd = MSP_GPS_CONFIG + returnTable.t = "Checking GPS..." + elseif not isVtxRead then + cmd = MSP_VTX_CONFIG + returnTable.t = "Checking VTX..." + end + if cmd then + protocol.mspRead(cmd) + else + return true + end + end + mspProcessTxQ() + processMspReply(mspPollReply()) + return false +end + +returnTable.f = updateFeatures + +return returnTable diff --git a/src/SCRIPTS/BF/pages.lua b/src/SCRIPTS/BF/pages.lua index d1f1e01..979b733 100644 --- a/src/SCRIPTS/BF/pages.lua +++ b/src/SCRIPTS/BF/pages.lua @@ -1,6 +1,6 @@ local PageFiles = {} -if apiVersion >= 1.36 then +if apiVersion >= 1.36 and features.vtx then PageFiles[#PageFiles + 1] = { title = "VTX Settings", script = "vtx.lua" } end @@ -48,11 +48,11 @@ if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Failsafe", script = "failsafe.lua" } end -if apiVersion >= 1.41 then +if apiVersion >= 1.41 and features.gps then PageFiles[#PageFiles + 1] = { title = "GPS Rescue", script = "rescue.lua" } end -if apiVersion >= 1.41 then +if apiVersion >= 1.41 and features.gps then PageFiles[#PageFiles + 1] = { title = "GPS PIDs", script = "gpspids.lua" } end diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index 1dd1161..fee070e 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -82,24 +82,6 @@ local function confirm(page) collectgarbage() end -local function filterAvailablePages(pageFiles) - local newPageFiles = pageFiles - - local function skipPage(script) - local currentPageFiles = {} - for i = 1, #newPageFiles do - if newPageFiles[i].script ~= script then - currentPageFiles[#currentPageFiles + 1] = newPageFiles[i] - end - end - newPageFiles = currentPageFiles - end - - if not features.vtx then skipPage("vtx.lua") end - - return newPageFiles -end - local function createPopupMenu() popupMenuActive = 1 popupMenu = {} @@ -314,7 +296,7 @@ local function run_ui(event) return 0 end init = nil - PageFiles = filterAvailablePages(assert(loadScript("pages.lua"))()) + PageFiles = assert(loadScript("pages.lua"))() invalidatePages() uiState = prevUiState or uiStatus.mainMenu prevUiState = nil diff --git a/src/SCRIPTS/BF/ui_init.lua b/src/SCRIPTS/BF/ui_init.lua index 1c624c8..939307f 100644 --- a/src/SCRIPTS/BF/ui_init.lua +++ b/src/SCRIPTS/BF/ui_init.lua @@ -2,7 +2,8 @@ local apiVersionReceived = false local vtxTablesReceived = false local mcuIdReceived = false local boardInfoReceived = false -local getApiVersion, getVtxTables, getMCUId, getBoardInfo +local featuresReceived = false +local getApiVersion, getVtxTables, getMCUId, getBoardInfo, getFeaturesInfo local returnTable = { f = nil, t = "" } local function init() @@ -56,10 +57,18 @@ local function init() getBoardInfo = nil collectgarbage() end + elseif not featuresReceived and apiVersion >= 1.41 then + getFeaturesInfo = getFeaturesInfo or assert(loadScript("features_info.lua"))() + returnTable.t = getFeaturesInfo.t + featuresReceived = getFeaturesInfo.f() + if featuresReceived then + getFeaturesInfo = nil + collectgarbage() + end else return true end - return apiVersionReceived and vtxTablesReceived and mcuId and boardInfoReceived + return apiVersionReceived and vtxTablesReceived and mcuId and boardInfoReceived and featuresReceived end returnTable.f = init From 571dfd52ec1b5f45ae42db9877952c4362dce8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiripolszky=20K=C3=A1roly?= Date: Tue, 23 Jan 2024 18:05:48 +0100 Subject: [PATCH 11/23] Do not download VTX table prematurely --- src/SCRIPTS/BF/CONFIRM/vtx_tables.lua | 3 --- src/SCRIPTS/BF/PAGES/INIT/vtx.lua | 11 +++++++++++ src/SCRIPTS/BF/PAGES/vtx.lua | 2 +- src/SCRIPTS/BF/features_info.lua | 2 +- src/SCRIPTS/BF/pages.lua | 2 +- src/SCRIPTS/BF/ui.lua | 19 +++++++++++++++++-- src/SCRIPTS/BF/ui_init.lua | 27 +-------------------------- 7 files changed, 32 insertions(+), 34 deletions(-) create mode 100644 src/SCRIPTS/BF/PAGES/INIT/vtx.lua diff --git a/src/SCRIPTS/BF/CONFIRM/vtx_tables.lua b/src/SCRIPTS/BF/CONFIRM/vtx_tables.lua index 5d51e61..f619fda 100644 --- a/src/SCRIPTS/BF/CONFIRM/vtx_tables.lua +++ b/src/SCRIPTS/BF/CONFIRM/vtx_tables.lua @@ -1,9 +1,6 @@ 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 diff --git a/src/SCRIPTS/BF/PAGES/INIT/vtx.lua b/src/SCRIPTS/BF/PAGES/INIT/vtx.lua new file mode 100644 index 0000000..ac5dbe3 --- /dev/null +++ b/src/SCRIPTS/BF/PAGES/INIT/vtx.lua @@ -0,0 +1,11 @@ +local function precondition() + local hasVtxTable = loadScript("VTX_TABLES/"..mcuId..".lua") + collectgarbage() + if hasVtxTable then + return nil + else + return "CONFIRM/vtx_tables.lua" + end +end + +return precondition() diff --git a/src/SCRIPTS/BF/PAGES/vtx.lua b/src/SCRIPTS/BF/PAGES/vtx.lua index 0e002b4..7c61da3 100644 --- a/src/SCRIPTS/BF/PAGES/vtx.lua +++ b/src/SCRIPTS/BF/PAGES/vtx.lua @@ -11,7 +11,7 @@ local fields = {} local vtx_tables if apiVersion >= 1.42 then - vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"))() + vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"), "No VTX table!")() else vtx_tables = assert(loadScript("VTX_TABLES/vtx_defaults.lua"))() end diff --git a/src/SCRIPTS/BF/features_info.lua b/src/SCRIPTS/BF/features_info.lua index bb28ecf..d37e21d 100644 --- a/src/SCRIPTS/BF/features_info.lua +++ b/src/SCRIPTS/BF/features_info.lua @@ -2,7 +2,7 @@ local MSP_GPS_CONFIG = 135 local MSP_VTX_CONFIG = 88 local isGpsRead = false -local isVtxRead = true -- Checking VTX is done in `vtx_tables.lua` +local isVtxRead = false local lastRunTS = 0 local INTERVAL = 100 diff --git a/src/SCRIPTS/BF/pages.lua b/src/SCRIPTS/BF/pages.lua index 979b733..63c4b23 100644 --- a/src/SCRIPTS/BF/pages.lua +++ b/src/SCRIPTS/BF/pages.lua @@ -1,7 +1,7 @@ local PageFiles = {} if apiVersion >= 1.36 and features.vtx then - PageFiles[#PageFiles + 1] = { title = "VTX Settings", script = "vtx.lua" } + PageFiles[#PageFiles + 1] = { title = "VTX Settings", script = "vtx.lua", init = "PAGES/INIT/vtx.lua" } end if apiVersion >= 1.16 then diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index fee070e..f849223 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -385,8 +385,23 @@ local function run_ui(event) end end if not Page then - Page = assert(loadScript("PAGES/"..PageFiles[currentPage].script))() - collectgarbage() + local function selectPage(page) + Page = assert(loadScript("PAGES/"..page))() + collectgarbage() + end + + local selectedPage = PageFiles[currentPage] + if selectedPage.init then + local initScript = assert(loadScript(selectedPage.init), "Missing init script")() + collectgarbage() + if initScript then + confirm(initScript) + else + selectPage(selectedPage.script) + end + else + selectPage(selectedPage.script) + end end if not Page.values and pageState == pageStatus.display then requestPage() diff --git a/src/SCRIPTS/BF/ui_init.lua b/src/SCRIPTS/BF/ui_init.lua index 939307f..89d2a9b 100644 --- a/src/SCRIPTS/BF/ui_init.lua +++ b/src/SCRIPTS/BF/ui_init.lua @@ -1,9 +1,8 @@ local apiVersionReceived = false -local vtxTablesReceived = false local mcuIdReceived = false local boardInfoReceived = false local featuresReceived = false -local getApiVersion, getVtxTables, getMCUId, getBoardInfo, getFeaturesInfo +local getApiVersion, getMCUId, getBoardInfo, getFeaturesInfo local returnTable = { f = nil, t = "" } local function init() @@ -23,30 +22,6 @@ local function init() mcuIdReceived = getMCUId.f() if mcuIdReceived then getMCUId = nil - local f = loadScript("VTX_TABLES/" .. mcuId .. ".lua") - if f then - local table = f() - if table then - vtxTablesReceived = true - features.vtx = 0 < table.frequenciesPerBand - f = nil - table = nil - end - end - collectgarbage() - f = loadScript("BOARD_INFO/"..mcuId..".lua") - if f and f() then - boardInfoReceived = true - f = nil - end - collectgarbage() - end - elseif not vtxTablesReceived and apiVersion >= 1.42 then - getVtxTables = getVtxTables or assert(loadScript("vtx_tables.lua"))() - returnTable.t = getVtxTables.t - vtxTablesReceived = getVtxTables.f() - if vtxTablesReceived then - getVtxTables = nil collectgarbage() end elseif not boardInfoReceived and apiVersion >= 1.44 then From 1204ebdd26f458e74abcdb67ee8193142471365e Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Wed, 7 Feb 2024 17:16:33 +0100 Subject: [PATCH 12/23] Bump workflow actions --- .github/workflows/build-release.yml | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/nightly.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index fba4d04..102ca5f 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Code Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Fetch build artifacts uses: actions/download-artifact@v3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e10e5e5..2b9f24e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Code Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Lua run: sudo apt-get -y install lua5.2 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f2116b8..62eab7d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Code Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Fetch build artifacts uses: actions/download-artifact@v3 From 1c0f49dffa9bfb830cf81d08b5e99525d0b0a120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiripolszky=20K=C3=A1roly?= Date: Fri, 16 Feb 2024 13:10:47 +0100 Subject: [PATCH 13/23] Download board info if necessary --- src/SCRIPTS/BF/CONFIRM/pwm.lua | 21 +++++++++++++++++++++ src/SCRIPTS/BF/PAGES/INIT/pwm.lua | 15 +++++++++++++++ src/SCRIPTS/BF/pages.lua | 2 +- src/SCRIPTS/BF/ui.lua | 3 +++ src/SCRIPTS/BF/ui_init.lua | 13 ++----------- 5 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 src/SCRIPTS/BF/CONFIRM/pwm.lua create mode 100644 src/SCRIPTS/BF/PAGES/INIT/pwm.lua diff --git a/src/SCRIPTS/BF/CONFIRM/pwm.lua b/src/SCRIPTS/BF/CONFIRM/pwm.lua new file mode 100644 index 0000000..f2c9023 --- /dev/null +++ b/src/SCRIPTS/BF/CONFIRM/pwm.lua @@ -0,0 +1,21 @@ +local template = assert(loadScript(radio.template))() +local margin = template.margin +local lineSpacing = template.lineSpacing +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 = {} + +labels[#labels + 1] = { t = "Download Board Info? Press", x = x, y = inc.y(lineSpacing) } +labels[#labels + 1] = { t = "[ENTER] to download, or", x = x, y = inc.y(lineSpacing) } +labels[#labels + 1] = { t = "[EXIT] to cancel.", x = x, y = inc.y(lineSpacing) } +fields[#fields + 1] = { x = x, y = inc.y(lineSpacing), value = "", ro = true } + +return { + title = "Board Info", + labels = labels, + fields = fields, + init = assert(loadScript("board_info.lua"))(), +} diff --git a/src/SCRIPTS/BF/PAGES/INIT/pwm.lua b/src/SCRIPTS/BF/PAGES/INIT/pwm.lua new file mode 100644 index 0000000..34232f8 --- /dev/null +++ b/src/SCRIPTS/BF/PAGES/INIT/pwm.lua @@ -0,0 +1,15 @@ +local function precondition() + if apiVersion < 1.44 then + -- BOARD_INFO is unavailable below 1.44 + return nil + end + local hasBoardInfo = loadScript("BOARD_INFO/"..mcuId..".lua") + collectgarbage() + if hasBoardInfo then + return nil + else + return "CONFIRM/pwm.lua" + end +end + +return precondition() diff --git a/src/SCRIPTS/BF/pages.lua b/src/SCRIPTS/BF/pages.lua index 63c4b23..9e5fd8d 100644 --- a/src/SCRIPTS/BF/pages.lua +++ b/src/SCRIPTS/BF/pages.lua @@ -37,7 +37,7 @@ if apiVersion >= 1.42 then end if apiVersion >= 1.16 then - PageFiles[#PageFiles + 1] = { title = "System / Motor", script = "pwm.lua" } + PageFiles[#PageFiles + 1] = { title = "System / Motor", script = "pwm.lua", init = "PAGES/INIT/pwm.lua" } end if apiVersion >= 1.16 then diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index f849223..df45bba 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -94,6 +94,9 @@ local function createPopupMenu() if apiVersion >= 1.42 then popupMenu[#popupMenu + 1] = { t = "vtx tables", f = function() confirm("CONFIRM/vtx_tables.lua") end } end + if apiVersion >= 1.44 then + popupMenu[#popupMenu + 1] = { t = "board info", f = function() confirm("CONFIRM/pwm.lua") end } + end end local function processMspReply(cmd,rx_buf,err) diff --git a/src/SCRIPTS/BF/ui_init.lua b/src/SCRIPTS/BF/ui_init.lua index 89d2a9b..c00f035 100644 --- a/src/SCRIPTS/BF/ui_init.lua +++ b/src/SCRIPTS/BF/ui_init.lua @@ -1,8 +1,7 @@ local apiVersionReceived = false local mcuIdReceived = false -local boardInfoReceived = false local featuresReceived = false -local getApiVersion, getMCUId, getBoardInfo, getFeaturesInfo +local getApiVersion, getMCUId, getFeaturesInfo local returnTable = { f = nil, t = "" } local function init() @@ -24,14 +23,6 @@ local function init() getMCUId = nil collectgarbage() end - elseif not boardInfoReceived and apiVersion >= 1.44 then - getBoardInfo = getBoardInfo or assert(loadScript("board_info.lua"))() - returnTable.t = getBoardInfo.t - boardInfoReceived = getBoardInfo.f() - if boardInfoReceived then - getBoardInfo = nil - collectgarbage() - end elseif not featuresReceived and apiVersion >= 1.41 then getFeaturesInfo = getFeaturesInfo or assert(loadScript("features_info.lua"))() returnTable.t = getFeaturesInfo.t @@ -43,7 +34,7 @@ local function init() else return true end - return apiVersionReceived and vtxTablesReceived and mcuId and boardInfoReceived and featuresReceived + return apiVersionReceived and mcuId and featuresReceived end returnTable.f = init From 3a9121d4305446ae37b2403fa5281ea421c4ea05 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Tue, 19 Mar 2024 16:04:31 +0100 Subject: [PATCH 14/23] Release assets upload fix --- .github/workflows/build-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 102ca5f..07bae5b 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -30,10 +30,10 @@ jobs: set -x ASSETS=() for asset in Assets/*.zip; do - ASSETS+=("-a" "$asset") + ASSETS+=("$asset") echo "$asset" done TAG_NAME="${GITHUB_REF##*/}" - gh release edit "${ASSETS[@]}" "{TAG_NAME}" + gh release upload "${TAG_NAME}" "${ASSETS[@]}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 61e8f4c6cd0584fbab69e207b05cdd0599c98fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiripolszky=20K=C3=A1roly?= Date: Wed, 24 Jan 2024 19:17:54 +0100 Subject: [PATCH 15/23] Hide OSD (SD) settings --- src/SCRIPTS/BF/PAGES/pos_osd.lua | 6 ++-- src/SCRIPTS/BF/features.lua | 6 ++-- src/SCRIPTS/BF/features_info.lua | 62 ++++++++++++++++++++++++++++---- src/SCRIPTS/BF/pages.lua | 2 +- 4 files changed, 63 insertions(+), 13 deletions(-) diff --git a/src/SCRIPTS/BF/PAGES/pos_osd.lua b/src/SCRIPTS/BF/PAGES/pos_osd.lua index 3417ac2..2e5c262 100644 --- a/src/SCRIPTS/BF/PAGES/pos_osd.lua +++ b/src/SCRIPTS/BF/PAGES/pos_osd.lua @@ -1,9 +1,7 @@ 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 @@ -133,12 +131,12 @@ return { self.values[3] = bit32.rshift(combineValue, 8) return self.values end, - checkProfile = function(self, value, profileFirst, profileSecond, profileThird) + checkProfile = function(_, value, profileFirst, profileSecond, profileThird) local profiles = profileFirst + bit32.lshift(profileSecond, 1) + bit32.lshift(profileThird, 2) local output = bit32.replace(value, profiles, 11, 3) return output end, - splitVal = function(self, inputFirstVal, inputSecondVal) + splitVal = function(_, inputFirstVal, inputSecondVal) local inputVal = inputFirstVal + bit32.lshift(inputSecondVal, 8) local profiles = bit32.extract(inputVal, 11, 3) local fieldPos = bit32.extract(inputVal, 0, 11) diff --git a/src/SCRIPTS/BF/features.lua b/src/SCRIPTS/BF/features.lua index 383252a..c76251c 100644 --- a/src/SCRIPTS/BF/features.lua +++ b/src/SCRIPTS/BF/features.lua @@ -1,6 +1,8 @@ local features = { - vtx = true, - gps = true, + vtx = true, + gps = true, + osdSD = true, + blackbox = true, } return features diff --git a/src/SCRIPTS/BF/features_info.lua b/src/SCRIPTS/BF/features_info.lua index d37e21d..5fe599b 100644 --- a/src/SCRIPTS/BF/features_info.lua +++ b/src/SCRIPTS/BF/features_info.lua @@ -1,20 +1,61 @@ local MSP_GPS_CONFIG = 135 local MSP_VTX_CONFIG = 88 +local MSP_OSD_CONFIG = 84 + +local MSP_BUILD_INFO = 5 + +local BUILD_OPTION_GPS = 16412 +local BUILD_OPTION_VTX = 16421 +local BUILD_OPTION_OSD_SD = 16416 local isGpsRead = false local isVtxRead = false +local isOsdSDRead = false local lastRunTS = 0 local INTERVAL = 100 +local isInFlight = false local returnTable = { f = nil, t = "", } +local function processBuildInfoReply(payload) + local headLength = 26 -- DATE(11) + TIME(8) + REVISION(7) + local optionsLength = #payload - headLength + if (optionsLength <= 0) or ((optionsLength % 2) ~= 0) then + return -- invalid payload + end + + features.gps = false + features.vtx = false + features.osdSD = false + for i = headLength + 1, #payload, 2 do + local byte1 = bit32.lshift(payload[i], 0) + local byte2 = bit32.lshift(payload[i + 1], 8) + local word = bit32.bor(byte1, byte2) + if word == BUILD_OPTION_GPS then + features.gps = true + elseif word == BUILD_OPTION_VTX then + features.vtx = true + elseif word == BUILD_OPTION_OSD_SD then + features.osdSD = true + end + end +end + local function processMspReply(cmd, payload, err) + isInFlight = false local isOkay = not err - if cmd == MSP_GPS_CONFIG then + if cmd == MSP_BUILD_INFO then + isGpsRead = true + isVtxRead = true + isOsdSDRead = true + if isOkay then + processBuildInfoReply(payload) + end + elseif cmd == MSP_GPS_CONFIG then isGpsRead = true local providerSet = payload[1] ~= 0 features.gps = isOkay and providerSet @@ -22,6 +63,10 @@ local function processMspReply(cmd, payload, err) isVtxRead = true local vtxTableAvailable = payload[12] ~= 0 features.vtx = isOkay and vtxTableAvailable + elseif cmd == MSP_OSD_CONFIG then + isOsdSDRead = true + local osdSDAvailable = payload[1] ~= 0 + features.osdSD = isOkay and osdSDAvailable end end @@ -29,22 +74,27 @@ local function updateFeatures() if lastRunTS + INTERVAL < getTime() then lastRunTS = getTime() local cmd - if not isGpsRead then + if apiVersion >= 1.46 then + cmd = MSP_BUILD_INFO + returnTable.t = "Checking options..." + elseif not isGpsRead then cmd = MSP_GPS_CONFIG returnTable.t = "Checking GPS..." elseif not isVtxRead then cmd = MSP_VTX_CONFIG returnTable.t = "Checking VTX..." + elseif not isOsdSDRead then + cmd = MSP_OSD_CONFIG + returnTable.t = "Checking OSD (SD)..." end - if cmd then + if cmd and not isInFlight then protocol.mspRead(cmd) - else - return true + isInFlight = true end end mspProcessTxQ() processMspReply(mspPollReply()) - return false + return isGpsRead and isVtxRead and isOsdSDRead end returnTable.f = updateFeatures diff --git a/src/SCRIPTS/BF/pages.lua b/src/SCRIPTS/BF/pages.lua index 9e5fd8d..9763e1c 100644 --- a/src/SCRIPTS/BF/pages.lua +++ b/src/SCRIPTS/BF/pages.lua @@ -60,7 +60,7 @@ if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Trim Accelerometer", script = "acc_trim.lua" } end -if apiVersion >= 1.45 then +if apiVersion >= 1.45 and features.osdSD then PageFiles[#PageFiles + 1] = { title = "OSD Elements", script = "pos_osd.lua" } end From 0978a0e500e57eae8fc847beb7d4fe6851aa94c5 Mon Sep 17 00:00:00 2001 From: 3djc <3djc@gh.com> Date: Thu, 16 May 2024 14:51:38 +0200 Subject: [PATCH 16/23] feat: add 480x320 support --- src/SCRIPTS/BF/TEMPLATES/480x320.lua | 7 ++++++ src/SCRIPTS/BF/radios.lua | 32 ++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/SCRIPTS/BF/TEMPLATES/480x320.lua diff --git a/src/SCRIPTS/BF/TEMPLATES/480x320.lua b/src/SCRIPTS/BF/TEMPLATES/480x320.lua new file mode 100644 index 0000000..cf01908 --- /dev/null +++ b/src/SCRIPTS/BF/TEMPLATES/480x320.lua @@ -0,0 +1,7 @@ +return { + margin = 5, + indent = 15, + lineSpacing = 22, + listSpacing = { line = 20, field = 170 }, + tableSpacing = { row = 25, col = 60, header = 20 }, +} diff --git a/src/SCRIPTS/BF/radios.lua b/src/SCRIPTS/BF/radios.lua index 13eecaa..2e7abf2 100644 --- a/src/SCRIPTS/BF/radios.lua +++ b/src/SCRIPTS/BF/radios.lua @@ -109,7 +109,35 @@ local supportedRadios = } }, }, - ["320x480"] = + ["480x320"] = + { + msp = { + template = "TEMPLATES/480x320.lua", + highRes = true, + MenuBox = { x=120, y=100, w=200, x_offset=68, h_line=20, h_offset=6 }, + SaveBox = { x=120, y=100, w=180, x_offset=12, h=60, h_offset=12 }, + NoTelem = { 192, LCD_H - 28, "No Telemetry", (TEXT_COLOR or 0) + INVERS + BLINK }, + textSize = 0, + yMinLimit = 35, + yMaxLimit = 280, + }, + cms = { + rows = 9, + cols = 32, + pixelsPerRow = 24, + pixelsPerChar = 14, + xIndent = 14, + yOffset = 32, + textSize = MIDSIZE, + refresh = { + event = EVT_VIRTUAL_ENTER, + text = "Refresh: [ENT]", + top = 1, + left = 300, + } + }, + }, + ["320x480"] = { msp = { template = "TEMPLATES/320x480.lua", @@ -128,4 +156,4 @@ local supportedRadios = local resolution = LCD_W.."x"..LCD_H local radio = assert(supportedRadios[resolution], resolution.." not supported") -return radio +return radio \ No newline at end of file From a999c65d5c10c5d5a0e12517a87953c8e13682c7 Mon Sep 17 00:00:00 2001 From: 3djc <3djc@gh.com> Date: Thu, 16 May 2024 15:22:46 +0200 Subject: [PATCH 17/23] chore:EOF line --- src/SCRIPTS/BF/radios.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SCRIPTS/BF/radios.lua b/src/SCRIPTS/BF/radios.lua index 2e7abf2..b6d5e22 100644 --- a/src/SCRIPTS/BF/radios.lua +++ b/src/SCRIPTS/BF/radios.lua @@ -156,4 +156,4 @@ local supportedRadios = local resolution = LCD_W.."x"..LCD_H local radio = assert(supportedRadios[resolution], resolution.." not supported") -return radio \ No newline at end of file +return radio From f259f036fd9a8173fef0c59aaad4c7e2fe2a90d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:39:29 +0000 Subject: [PATCH 18/23] Bump actions/download-artifact from 3 to 4.1.7 in /.github/workflows Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v3...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/build-release.yml | 2 +- .github/workflows/nightly.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 07bae5b..7d7fe79 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v4 - name: Fetch build artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4.1.7 - name: List assets run: ls -al Assets diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 62eab7d..c60f425 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -35,7 +35,7 @@ jobs: uses: actions/checkout@v4 - name: Fetch build artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4.1.7 - name: Select release notes id: notes From b5e2d989daa44ffafe96bdd13ab9126163ca12bc Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Fri, 25 Jul 2025 13:25:04 +0200 Subject: [PATCH 19/23] Fix CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b9f24e..905afc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: run: make release - name: Publish build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Assets path: ./release/*.zip From a4969ab2450e460d9a139be72c36c52e88a12486 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Fri, 25 Jul 2025 16:29:49 +0200 Subject: [PATCH 20/23] Use specific version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 905afc7..b9c9b0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: run: make release - name: Publish build artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v4.3.0 with: name: Assets path: ./release/*.zip From a76cd41cadee98dd190b6723d67b4c4905b267c8 Mon Sep 17 00:00:00 2001 From: Marc Ole Bulling Date: Sun, 3 Aug 2025 21:45:18 +0200 Subject: [PATCH 21/23] Added battery menu Changed API to 1.41 --- src/SCRIPTS/BF/PAGES/battery.lua | 31 +++++++++++++++++++++++++++++++ src/SCRIPTS/BF/pages.lua | 4 ++++ 2 files changed, 35 insertions(+) create mode 100644 src/SCRIPTS/BF/PAGES/battery.lua diff --git a/src/SCRIPTS/BF/PAGES/battery.lua b/src/SCRIPTS/BF/PAGES/battery.lua new file mode 100644 index 0000000..75c008c --- /dev/null +++ b/src/SCRIPTS/BF/PAGES/battery.lua @@ -0,0 +1,31 @@ +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 = {} + +labels[#labels + 1] = { t = "Voltage Settings", x = x, y = inc.y(lineSpacing) } +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 } +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 } +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 } + +labels[#labels + 1] = { t = "Capacity Settings", x = x, y = inc.y(lineSpacing) } +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 } } + +return { + read = 32, -- MSP_BATTERY_CONFIG + write = 33, -- MSP_SET_BATTERY_CONFIG + title = "Battery", + reboot = false, + eepromWrite = true, + minBytes = 13, + labels = labels, + fields = fields +} diff --git a/src/SCRIPTS/BF/pages.lua b/src/SCRIPTS/BF/pages.lua index 9763e1c..4deddf5 100644 --- a/src/SCRIPTS/BF/pages.lua +++ b/src/SCRIPTS/BF/pages.lua @@ -40,6 +40,10 @@ if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "System / Motor", script = "pwm.lua", init = "PAGES/INIT/pwm.lua" } end +if apiVersion >= 1.41 then + PageFiles[#PageFiles + 1] = { title = "Battery", script = "battery.lua" } +end + if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Receiver", script = "rx.lua" } end From 1acac3c709ef09e4b88d4f8a042e2d7612118db4 Mon Sep 17 00:00:00 2001 From: Marc Ole Bulling Date: Sun, 3 Aug 2025 22:02:08 +0200 Subject: [PATCH 22/23] Removed spaces again, fixed formatting --- src/SCRIPTS/BF/PAGES/battery.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SCRIPTS/BF/PAGES/battery.lua b/src/SCRIPTS/BF/PAGES/battery.lua index 75c008c..39c2293 100644 --- a/src/SCRIPTS/BF/PAGES/battery.lua +++ b/src/SCRIPTS/BF/PAGES/battery.lua @@ -12,12 +12,12 @@ local labels = {} local fields = {} labels[#labels + 1] = { t = "Voltage Settings", x = x, y = inc.y(lineSpacing) } -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 } -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 } -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 } +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 } +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 } +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 } labels[#labels + 1] = { t = "Capacity Settings", x = x, y = inc.y(lineSpacing) } -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 } } +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 } } return { read = 32, -- MSP_BATTERY_CONFIG From 49ea1aed2ef703d8aae9bdfb279bcb174d76dc91 Mon Sep 17 00:00:00 2001 From: Marc Ole Bulling Date: Sun, 10 Aug 2025 10:12:50 +0200 Subject: [PATCH 23/23] Fix battery capacity steps, changed max capacity to 20000 --- src/SCRIPTS/BF/PAGES/battery.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SCRIPTS/BF/PAGES/battery.lua b/src/SCRIPTS/BF/PAGES/battery.lua index 39c2293..43a08f1 100644 --- a/src/SCRIPTS/BF/PAGES/battery.lua +++ b/src/SCRIPTS/BF/PAGES/battery.lua @@ -17,7 +17,7 @@ fields[#fields + 1] = { t = "Maximum Cell", x = x + indent, y = inc.y(li 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 } labels[#labels + 1] = { t = "Capacity Settings", x = x, y = inc.y(lineSpacing) } -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 } } +fields[#fields + 1] = { t = "Battery Capacity", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, mult = 25, max = 20000, vals = { 4, 5 } } return { read = 32, -- MSP_BATTERY_CONFIG