From 9523c75ff4897c98c6fe4f921555d85d83cd0849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Daleck=C3=BD?= Date: Wed, 29 Dec 2021 16:04:02 +0100 Subject: [PATCH 01/18] Ghost MSP support --- src/SCRIPTS/BF/MSP/ghst.lua | 28 ++++++++++++++++++++++++++++ src/SCRIPTS/BF/protocols.lua | 12 ++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/SCRIPTS/BF/MSP/ghst.lua diff --git a/src/SCRIPTS/BF/MSP/ghst.lua b/src/SCRIPTS/BF/MSP/ghst.lua new file mode 100644 index 0000000..397b3e1 --- /dev/null +++ b/src/SCRIPTS/BF/MSP/ghst.lua @@ -0,0 +1,28 @@ +-- GHST Frame Types +local GHST_FRAMETYPE_MSP_REQ = 0x21 +local GHST_FRAMETYPE_MSP_WRITE = 0x22 +local GHST_FRAMETYPE_MSP_RESP = 0x28 + +local ghstMspType = 0 + +protocol.mspSend = function(payload) + return protocol.push(ghstMspType, payload) +end + +protocol.mspRead = function(cmd) + ghstMspType = GHST_FRAMETYPE_MSP_REQ + return mspSendRequest(cmd, {}) +end + +protocol.mspWrite = function(cmd, payload) + ghstMspType = GHST_FRAMETYPE_MSP_WRITE + return mspSendRequest(cmd, payload) +end + +protocol.mspPoll = function() + local type, data = ghostTelemetryPop() + if type == GHST_FRAMETYPE_MSP_RESP then + return mspReceivedReply(data) + end + return nil +end diff --git a/src/SCRIPTS/BF/protocols.lua b/src/SCRIPTS/BF/protocols.lua index c415104..8034821 100644 --- a/src/SCRIPTS/BF/protocols.lua +++ b/src/SCRIPTS/BF/protocols.lua @@ -20,6 +20,16 @@ local supportedProtocols = saveMaxRetries = 2, saveTimeout = 150, cms = {}, + }, + ghst = + { + mspTransport = "MSP/ghst.lua", + push = ghostTelemetryPush, + maxTxBufferSize = 10, -- Tx -> Rx (Push) + maxRxBufferSize = 6, -- Rx -> Tx (Pop) + saveMaxRetries = 2, + saveTimeout = 250, + cms = {}, } } @@ -28,6 +38,8 @@ local function getProtocol() return supportedProtocols.smartPort elseif supportedProtocols.crsf.push() ~= nil then return supportedProtocols.crsf + elseif supportedProtocols.ghst.push() ~= nil then + return supportedProtocols.ghst end end From ad053800e83176e0c6f046f8db7c3c8e0b657431 Mon Sep 17 00:00:00 2001 From: blckmn Date: Tue, 14 Jun 2022 16:41:58 +1000 Subject: [PATCH 02/18] Moving to github actions, to attach on release. --- .github/workflows/build-release.yml | 39 ++++++++++++++ .github/workflows/ci.yml | 38 +++++++++++++ .github/workflows/pr.yml | 12 +++++ azure-pipelines.yml | 82 ----------------------------- 4 files changed, 89 insertions(+), 82 deletions(-) create mode 100644 .github/workflows/build-release.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pr.yml delete mode 100644 azure-pipelines.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..a0a2c22 --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,39 @@ +name: Release + +on: + release: + types: [published] + +jobs: + ci: + name: CI + uses: ./.github/workflows/ci.yml + with: + release_build: true + + release: + name: Release + needs: ci + runs-on: ubuntu-20.04 + steps: + - name: Code Checkout + uses: actions/checkout@v2 + + - name: Fetch build artifacts + uses: actions/download-artifact@v2 + + - name: List assets + run: ls -al Assets + + - name: Attach assets to release + run: | + set -x + assets=() + for asset in Assets/*.zip; do + assets+=("-a" "$asset") + echo "$asset" + done + tag_name="${GITHUB_REF##*/}" + hub release edit "${assets[@]}" -m "" "$tag_name" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2c177ff --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +# Builds Betaflight Lua Scripts. +# +# After building, artifacts are kept for 7 days. + +name: CI + +on: + workflow_call: + inputs: + release_build: + description: 'Specifies if it is a debug build or a release build' + default: false + required: false + type: boolean + +jobs: + build: + name: Build + runs-on: ubuntu-20.04 + steps: + - name: Code Checkout + uses: actions/checkout@v2 + + - name: Install Lua + run: sudo apt-get -y install lua5.2 + + - name: Install Zip + run: sudo apt-get -y install zip + + - name: Execute Build + run: make release + + - name: Publish build artifacts + uses: actions/upload-artifact@v3 + with: + name: Assets + path: ./release/*.zip + retention-days: 7 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..c207e7e --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,12 @@ +name: PR + +on: + pull_request: + branches: + - master + - '*-maintenance' + +jobs: + ci: + name: CI + uses: ./.github/workflows/ci.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 837910b..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,82 +0,0 @@ -# Builds the Betaflight TX lua scripts. -# -# After building, artifacts are released to a seperate repository. -# -# Azure Pipelines requires the following extensions to be installed: -# - GitHub Tool: https://marketplace.visualstudio.com/items?itemName=marcelo-formentao.github-tools -# -# You'll also need to setup the follwing pipeline variables: -# "releaseNotes" - This is used to add the release notes in the windows job in the build stage so they can be published as part of the github release in the release stage -# "endpoint" - The name of the github endpoint link setup in AzDo - setup when linking AzDo and GitHub -# "owner" - The owner of the repository to release to e.g. betaflight -# "repoName" - The name of the repository to release to e.g. betaflight-configurator-nightly - -variables: - owner: betaflight - repoName: betaflight-tx-lua-scripts-nightlies - releaseNotes: This is a nightly build off the tip of 'master'. It may be unstable and result in corrupted configurations or data loss. **Use only for testing.** - vmImage: 'ubuntu-20.04' - -name: $(Date:yyyyMMdd).$(BuildID) - -trigger: - batch: true - branches: - include: - - master - -pr: - drafts: false - branches: - include: - - master - - "*-maintenance" - -stages: -- stage: Build - jobs: - - job: 'Linux' - pool: - vmImage: '$(vmImage)' - steps: - - script: sudo apt-get -y install lua5.2 - displayName: 'Install lua compiler.' - - script: make release -C $(System.DefaultWorkingDirectory) - displayName: 'Test and build the release.' - - task: PublishPipelineArtifact@1 - displayName: 'Publish release' - inputs: - artifactName: betaflight-tx-lua-scripts - targetPath: '$(System.DefaultWorkingDirectory)/release' - -- stage: Release - jobs: - - job: Release - pool: - vmImage: '$(vmImage)' - steps: - - task: DownloadPipelineArtifact@2 - inputs: - buildType: 'current' - targetPath: '$(Pipeline.Workspace)' - - task: GitHubReleasePublish@1 - inputs: - githubEndpoint: '$(endpoint)' - manuallySetRepository: true - githubOwner: '$(owner)' - githubRepositoryName: '$(repoName)' - githubReleaseNotes: |+ - $(releaseNotes) - - ### Changes: - $(Build.SourceVersionMessage) - githubReleaseDraft: false - githubReleasePrerelease: false - githubIgnoreAssets: false - githubReleaseAsset: | - $(Pipeline.Workspace)/betaflight-tx-lua-scripts/** - githubReuseRelease: true - githubReuseDraftOnly: true - githubSkipDuplicatedAssets: false - githubEditRelease: false - githubDeleteEmptyTag: false From 8809aa39bd85eadb0df715799fbf8251c1be595f Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Sat, 22 Jan 2022 21:08:51 +0100 Subject: [PATCH 03/18] Read lua input buffer until empty --- src/SCRIPTS/BF/MSP/common.lua | 17 ++++++++--------- src/SCRIPTS/BF/MSP/crsf.lua | 17 +++++++++-------- src/SCRIPTS/BF/MSP/ghst.lua | 11 +++++++---- src/SCRIPTS/BF/MSP/sp.lua | 33 ++++++++++++++++++--------------- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/src/SCRIPTS/BF/MSP/common.lua b/src/SCRIPTS/BF/MSP/common.lua index fb119f6..dc20f9b 100644 --- a/src/SCRIPTS/BF/MSP/common.lua +++ b/src/SCRIPTS/BF/MSP/common.lua @@ -100,25 +100,24 @@ function mspReceivedReply(payload) end if idx > protocol.maxRxBufferSize then mspRemoteSeq = seq - return true + return false end mspStarted = false -- check CRC if mspRxCRC ~= payload[idx] and version == 0 then return nil end - return mspRxBuf + return true end function mspPollReply() while true do - local ret = protocol.mspPoll() - if type(ret) == "table" then + local mspData = protocol.mspPoll() + if mspData == nil then + return nil + elseif mspReceivedReply(mspData) then mspLastReq = 0 - return mspRxReq, ret - else - break - end + return mspRxReq, mspRxBuf + end end - return nil end diff --git a/src/SCRIPTS/BF/MSP/crsf.lua b/src/SCRIPTS/BF/MSP/crsf.lua index 63c9200..9fb4eee 100644 --- a/src/SCRIPTS/BF/MSP/crsf.lua +++ b/src/SCRIPTS/BF/MSP/crsf.lua @@ -6,7 +6,7 @@ local CRSF_FRAMETYPE_MSP_REQ = 0x7A -- response request using msp local CRSF_FRAMETYPE_MSP_RESP = 0x7B -- reply with 60 byte chunked binary local CRSF_FRAMETYPE_MSP_WRITE = 0x7C -- write with 60 byte chunked binary -crsfMspCmd = 0 +local crsfMspCmd = 0 protocol.mspSend = function(payload) local payloadOut = { CRSF_ADDRESS_BETAFLIGHT, CRSF_ADDRESS_RADIO_TRANSMITTER } @@ -27,15 +27,16 @@ protocol.mspWrite = function(cmd, payload) end protocol.mspPoll = function() - local command, data = crossfireTelemetryPop() - if command == CRSF_FRAMETYPE_MSP_RESP then - if data[1] == CRSF_ADDRESS_RADIO_TRANSMITTER and data[2] == CRSF_ADDRESS_BETAFLIGHT then + while true do + local cmd, data = crossfireTelemetryPop() + if cmd == CRSF_FRAMETYPE_MSP_RESP and data[1] == CRSF_ADDRESS_RADIO_TRANSMITTER and data[2] == CRSF_ADDRESS_BETAFLIGHT then local mspData = {} - for i=3, #(data) do - mspData[i-2] = data[i] + for i = 3, #data do + mspData[i - 2] = data[i] end - return mspReceivedReply(mspData) + return mspData + elseif cmd == nil then + return nil end end - return nil end diff --git a/src/SCRIPTS/BF/MSP/ghst.lua b/src/SCRIPTS/BF/MSP/ghst.lua index 397b3e1..53ef616 100644 --- a/src/SCRIPTS/BF/MSP/ghst.lua +++ b/src/SCRIPTS/BF/MSP/ghst.lua @@ -20,9 +20,12 @@ protocol.mspWrite = function(cmd, payload) end protocol.mspPoll = function() - local type, data = ghostTelemetryPop() - if type == GHST_FRAMETYPE_MSP_RESP then - return mspReceivedReply(data) + while true do + local type, data = ghostTelemetryPop() + if type == GHST_FRAMETYPE_MSP_RESP then + return data + elseif type == nil then + return nil + end end - return nil end diff --git a/src/SCRIPTS/BF/MSP/sp.lua b/src/SCRIPTS/BF/MSP/sp.lua index ecc15b1..7d2bc99 100644 --- a/src/SCRIPTS/BF/MSP/sp.lua +++ b/src/SCRIPTS/BF/MSP/sp.lua @@ -42,20 +42,23 @@ local function smartPortTelemetryPop() end protocol.mspPoll = function() - local sensorId, frameId, dataId, value = smartPortTelemetryPop() - if (sensorId == SMARTPORT_REMOTE_SENSOR_ID or sensorId == FPORT_REMOTE_SENSOR_ID) and frameId == REPLY_FRAME_ID then - local payload = {} - payload[1] = bit32.band(dataId,0xFF) - dataId = bit32.rshift(dataId,8) - payload[2] = bit32.band(dataId,0xFF) - payload[3] = bit32.band(value,0xFF) - value = bit32.rshift(value,8) - payload[4] = bit32.band(value,0xFF) - value = bit32.rshift(value,8) - payload[5] = bit32.band(value,0xFF) - value = bit32.rshift(value,8) - payload[6] = bit32.band(value,0xFF) - return mspReceivedReply(payload) + while true do + local sensorId, frameId, dataId, value = smartPortTelemetryPop() + if (sensorId == SMARTPORT_REMOTE_SENSOR_ID or sensorId == FPORT_REMOTE_SENSOR_ID) and frameId == REPLY_FRAME_ID then + local payload = {} + payload[1] = bit32.band(dataId, 0xFF) + dataId = bit32.rshift(dataId, 8) + payload[2] = bit32.band(dataId, 0xFF) + payload[3] = bit32.band(value, 0xFF) + value = bit32.rshift(value, 8) + payload[4] = bit32.band(value, 0xFF) + value = bit32.rshift(value, 8) + payload[5] = bit32.band(value, 0xFF) + value = bit32.rshift(value, 8) + payload[6] = bit32.band(value, 0xFF) + return payload + elseif sensorId == nil then + return nil + end end - return nil end From 188a884c899973244de1ab71477f59fc6c4bac70 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Wed, 14 Sep 2022 19:28:48 +0200 Subject: [PATCH 04/18] Remove gyro/pid rate for BF 4.2 --- src/SCRIPTS/BF/PAGES/pwm.lua | 10 ++++++---- src/SCRIPTS/BF/ui_init.lua | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/SCRIPTS/BF/PAGES/pwm.lua b/src/SCRIPTS/BF/PAGES/pwm.lua index 5a5c425..86a7845 100644 --- a/src/SCRIPTS/BF/PAGES/pwm.lua +++ b/src/SCRIPTS/BF/PAGES/pwm.lua @@ -13,7 +13,7 @@ local fields = {} local gyroSampleRateKhz -if apiVersion >= 1.043 then +if apiVersion >= 1.044 then gyroSampleRateKhz = assert(loadScript("BOARD_INFO/"..mcuId..".lua"))().gyroSampleRateHz / 1000 end @@ -42,12 +42,14 @@ labels[#labels + 1] = { t = "System Config", x = x, y = inc.y(lineSpacing) } if apiVersion >= 1.031 and apiVersion <= 1.040 then fields[#fields + 1] = { t = "32kHz Sampling", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 9 }, table = { [0] = "OFF", "ON" }, upd = function(self) self.updateRateTables(self) end } end -if apiVersion >= 1.043 then +if apiVersion >= 1.044 then fields[#fields + 1] = { t = "Gyro Update", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 32, vals = { 1 }, table = {}, upd = function(self) self.updatePidRateTable(self) end, mult = -1, ro = true } -else +elseif apiVersion <= 1.042 then fields[#fields + 1] = { t = "Gyro Update", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 32, vals = { 1 }, table = {}, upd = function(self) self.updatePidRateTable(self) end, mult = -1 } end -fields[#fields + 1] = { t = "PID Loop", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 16, vals = { 2 }, table = {}, mult = -1 } +if apiVersion <= 1.042 or apiVersion >= 1.044 then + fields[#fields + 1] = { t = "PID Loop", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 16, vals = { 2 }, table = {}, mult = -1 } +end labels[#labels + 1] = { t = "ESC/Motor", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Protocol", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #escProtocols, vals = { 4 }, table = escProtocols } diff --git a/src/SCRIPTS/BF/ui_init.lua b/src/SCRIPTS/BF/ui_init.lua index 632fea6..939aa58 100644 --- a/src/SCRIPTS/BF/ui_init.lua +++ b/src/SCRIPTS/BF/ui_init.lua @@ -43,7 +43,7 @@ local function init() getVtxTables = nil collectgarbage() end - elseif not boardInfoReceived and apiVersion >= 1.043 then + elseif not boardInfoReceived and apiVersion >= 1.044 then getBoardInfo = getBoardInfo or assert(loadScript("board_info.lua"))() returnTable.t = getBoardInfo.t boardInfoReceived = getBoardInfo.f() From 67e7afa8d4c06e6ac5ef882193a21cd47011f07f Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Sun, 2 Oct 2022 23:02:47 +0200 Subject: [PATCH 05/18] Fix api version calculation --- src/SCRIPTS/BF/PAGES/failsafe.lua | 4 ++-- src/SCRIPTS/BF/PAGES/filters1.lua | 30 +++++++++++++-------------- src/SCRIPTS/BF/PAGES/filters2.lua | 10 ++++----- src/SCRIPTS/BF/PAGES/gpspids.lua | 2 +- src/SCRIPTS/BF/PAGES/pid_advanced.lua | 26 +++++++++++------------ src/SCRIPTS/BF/PAGES/pids1.lua | 6 +++--- src/SCRIPTS/BF/PAGES/pids2.lua | 16 +++++++------- src/SCRIPTS/BF/PAGES/pwm.lua | 22 ++++++++++---------- src/SCRIPTS/BF/PAGES/rates.lua | 16 +++++++------- src/SCRIPTS/BF/PAGES/rescue.lua | 6 +++--- src/SCRIPTS/BF/PAGES/rx.lua | 12 +++++------ src/SCRIPTS/BF/PAGES/vtx.lua | 8 +++---- src/SCRIPTS/BF/api_version.lua | 2 +- src/SCRIPTS/BF/background.lua | 2 +- src/SCRIPTS/BF/board_info.lua | 14 ++++++------- src/SCRIPTS/BF/pages.lua | 28 ++++++++++++------------- src/SCRIPTS/BF/rtc.lua | 2 +- src/SCRIPTS/BF/ui.lua | 2 +- src/SCRIPTS/BF/ui_init.lua | 6 +++--- 19 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/SCRIPTS/BF/PAGES/failsafe.lua b/src/SCRIPTS/BF/PAGES/failsafe.lua index 1ce6fba..5269a39 100644 --- a/src/SCRIPTS/BF/PAGES/failsafe.lua +++ b/src/SCRIPTS/BF/PAGES/failsafe.lua @@ -13,11 +13,11 @@ local fields = {} local procedure = { [0] = "Land", "Drop" } -if apiVersion >= 1.039 then +if apiVersion >= 1.39 then procedure[#procedure + 1] = "Rescue" end -if apiVersion >= 1.039 then +if apiVersion >= 1.39 then labels[#labels + 1] = { t = "Failsafe Switch", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Action", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 2, vals = { 5 }, table = { [0] = "Stage 1", "Kill", "Stage 2" } } else diff --git a/src/SCRIPTS/BF/PAGES/filters1.lua b/src/SCRIPTS/BF/PAGES/filters1.lua index 68db6c8..4b85a74 100644 --- a/src/SCRIPTS/BF/PAGES/filters1.lua +++ b/src/SCRIPTS/BF/PAGES/filters1.lua @@ -13,29 +13,29 @@ local fields = {} local gyroFilterType = { [0] = "PT1", "BIQUAD" } -if apiVersion >= 1.044 then +if apiVersion >= 1.44 then gyroFilterType[#gyroFilterType + 1] = "PT2" gyroFilterType[#gyroFilterType + 1] = "PT3" end local dtermFilterType = gyroFilterType -if apiVersion >= 1.036 and apiVersion <= 1.038 then +if apiVersion >= 1.36 and apiVersion <= 1.38 then dtermFilterType = { [0] = "PT1", "BIQUAD", "FIR" } end local dtermFilterType2 = gyroFilterType -if apiVersion >= 1.041 then +if apiVersion >= 1.41 then labels[#labels + 1] = { t = "Gyro Lowpass 1 Dynamic", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Min Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1000, vals = { 30, 31 } } fields[#fields + 1] = { t = "Max Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1000, vals = { 32, 33 } } fields[#fields + 1] = { t = "Filter Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #gyroFilterType, vals = { 25 }, table = gyroFilterType } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then labels[#labels + 1] = { t = "Gyro Lowpass 1", x = x, y = inc.y(lineSpacing) } - if apiVersion >= 1.039 then + if apiVersion >= 1.39 then fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 21, 22 } } fields[#fields + 1] = { t = "Filter Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #gyroFilterType, vals = { 25 }, table = gyroFilterType } else @@ -43,54 +43,54 @@ if apiVersion >= 1.016 then end end -if apiVersion >= 1.039 then +if apiVersion >= 1.39 then labels[#labels + 1] = { t = "Gyro Lowpass 2", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 23, 24 } } fields[#fields + 1] = { t = "Filter Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #gyroFilterType, vals = { 26 }, table = gyroFilterType } end -if apiVersion >= 1.020 then +if apiVersion >= 1.20 then labels[#labels + 1] = { t = "Gyro Notch 1", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Center", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 6, 7 } } fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 8, 9 } } end -if apiVersion >= 1.021 then +if apiVersion >= 1.21 then labels[#labels + 1] = { t = "Gyro Notch 2", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Center", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 14, 15 } } fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 16, 17 } } end -if apiVersion >= 1.041 then +if apiVersion >= 1.41 then labels[#labels + 1] = { t = "D Term Lowpass 1 Dynamic", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Min Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1000, vals = { 34, 35 } } fields[#fields + 1] = { t = "Max Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1000, vals = { 36, 37 } } fields[#fields + 1] = { t = "Filter Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #dtermFilterType, vals = { 18 }, table = dtermFilterType } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then labels[#labels + 1] = { t = "D Term Lowpass 1", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 2, 3 } } - if apiVersion >= 1.036 then + if apiVersion >= 1.36 then fields[#fields + 1] = { t = "Filter Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #dtermFilterType, vals = { 18 }, table = dtermFilterType } end end -if apiVersion >= 1.039 then +if apiVersion >= 1.39 then labels[#labels + 1] = { t = "D Term Lowpass 2", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 27, 28 } } - if apiVersion >= 1.041 then + if apiVersion >= 1.41 then fields[#fields + 1] = { t = "Filter Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #dtermFilterType2, vals = { 29 }, table = dtermFilterType2 } end end -if apiVersion >= 1.020 then +if apiVersion >= 1.20 then labels[#labels + 1] = { t = "D Term Notch", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Center", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 10, 11 } } fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 16000, vals = { 12, 13 } } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then labels[#labels + 1] = { t = "Yaw Lowpass", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 500, vals = { 4, 5 } } end diff --git a/src/SCRIPTS/BF/PAGES/filters2.lua b/src/SCRIPTS/BF/PAGES/filters2.lua index 0ba7714..7fb2e44 100644 --- a/src/SCRIPTS/BF/PAGES/filters2.lua +++ b/src/SCRIPTS/BF/PAGES/filters2.lua @@ -11,21 +11,21 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y = local labels = {} local fields = {} -if apiVersion >= 1.042 then +if apiVersion >= 1.42 then labels[#labels + 1] = { t = "Gyro RPM Filter", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Harmonics", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 3, vals = { 44 } } fields[#fields + 1] = { t = "Min Frequency", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 200, vals = { 45 } } labels[#labels + 1] = { t = "Dynamic Notch Filter", x = x, y = inc.y(lineSpacing) } - if apiVersion < 1.043 then + if apiVersion < 1.43 then fields[#fields + 1] = { t = "Range", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 3, vals = { 38 }, table = { [0]="HIGH", "MEDIUM", "LOW", "AUTO" } } end - if apiVersion >= 1.044 then + if apiVersion >= 1.44 then fields[#fields + 1] = { t = "Count", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 5, vals = { 49 } } else fields[#fields + 1] = { t = "Width %", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 20, vals = { 39 } } end fields[#fields + 1] = { t = "Q", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 1000, vals = { 40, 41 } } - if apiVersion >= 1.043 then + if apiVersion >= 1.43 then fields[#fields + 1] = { t = "Min Frequency", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 60, max = 250, vals = { 42, 43 } } fields[#fields + 1] = { t = "Max Frequency", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 200, max = 1000, vals = { 46, 47 } } else @@ -46,7 +46,7 @@ return { self.rpmHarmonics = self.values[44] end, preSave = function(self) - self.reboot = self.values[44] == 0 and self.rpmHarmonics ~= 0 and apiVersion <= 1.043 + self.reboot = self.values[44] == 0 and self.rpmHarmonics ~= 0 and apiVersion <= 1.43 return self.values end, } diff --git a/src/SCRIPTS/BF/PAGES/gpspids.lua b/src/SCRIPTS/BF/PAGES/gpspids.lua index 9538297..a28685f 100644 --- a/src/SCRIPTS/BF/PAGES/gpspids.lua +++ b/src/SCRIPTS/BF/PAGES/gpspids.lua @@ -11,7 +11,7 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y = local labels = {} local fields = {} -if apiVersion >= 1.041 then +if apiVersion >= 1.41 then x = margin y = yMinLim - tableSpacing.header labels[#labels + 1] = { t = "", x = x, y = inc.y(tableSpacing.header) } diff --git a/src/SCRIPTS/BF/PAGES/pid_advanced.lua b/src/SCRIPTS/BF/PAGES/pid_advanced.lua index 5c136d6..6ec3452 100644 --- a/src/SCRIPTS/BF/PAGES/pid_advanced.lua +++ b/src/SCRIPTS/BF/PAGES/pid_advanced.lua @@ -11,7 +11,7 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y = local labels = {} local fields = {} -if apiVersion >= 1.040 then +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 } } fields[#fields + 1] = { t = "Throttle Boost", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 31 } } @@ -19,45 +19,45 @@ if apiVersion >= 1.040 then fields[#fields + 1] = { t = "I Term Rotation", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 26 }, table = { [0]="OFF", "ON" } } end -if apiVersion >= 1.043 then +if apiVersion >= 1.43 then fields[#fields + 1] = { t = "Motor Output Limit",x = x, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 100, vals = { 48 } } fields[#fields + 1] = { t = "Dynamic Idle", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 50 } } end -if apiVersion >= 1.016 and apiVersion <= 1.043 then +if apiVersion >= 1.16 and apiVersion <= 1.43 then fields[#fields + 1] = { t = "VBAT Compensation", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 8 }, table = { [0]="OFF", "ON" } } end -if apiVersion >= 1.044 then +if apiVersion >= 1.44 then fields[#fields + 1] = { t = "Vbat Sag Comp", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 150, vals = { 56 } } fields[#fields + 1] = { t = "Thrust Linear", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 150, vals = { 57 } } end -if apiVersion >= 1.040 and apiVersion <= 1.041 then +if apiVersion >= 1.40 and apiVersion <= 1.41 then fields[#fields + 1] = { t = "Smart Feedforward", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 27 }, table = { [0] = "OFF", "ON" } } end -if apiVersion >= 1.041 then +if apiVersion >= 1.41 then fields[#fields + 1] = { t = "Integrated Yaw", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 45 }, table = { [0]="OFF", "ON" } } end -if apiVersion >= 1.040 then +if apiVersion >= 1.40 then labels[#labels + 1] = { t = "I Term Relax", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Axes", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 4, vals = { 28 }, table = { [0]="NONE", "RP", "RPY", "RP (inc)", "RPY (inc)" } } fields[#fields + 1] = { t = "Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 29 }, table = { [0]="Gyro", "Setpoint" } } - if apiVersion >= 1.043 then + if apiVersion >= 1.43 then fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 50, vals = { 47 } } - elseif apiVersion >= 1.042 then + elseif apiVersion >= 1.42 then fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 100, vals = { 47 } } end end -if apiVersion >= 1.036 then +if apiVersion >= 1.36 then labels[#labels + 1] = { t = "Anti Gravity", x = x, y = inc.y(lineSpacing) } - if apiVersion >= 1.040 then + if apiVersion >= 1.40 then fields[#fields + 1] = { t = "Mode", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 39 }, table = { [0]="Smooth", "Step" } } end - if apiVersion >= 1.044 then + if apiVersion >= 1.44 then fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 30000, vals = { 22, 23 }, scale = 1000, mult = 100 } else fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 30000, vals = { 22, 23 }, scale = 1000, mult = 100 } @@ -78,7 +78,7 @@ return { self.dynamicIdle = self.values[50] end, preSave = function(self) - self.reboot = self.values[50] ~= self.dynamicIdle and apiVersion <= 1.043 + self.reboot = self.values[50] ~= self.dynamicIdle and apiVersion <= 1.43 return self.values end, } diff --git a/src/SCRIPTS/BF/PAGES/pids1.lua b/src/SCRIPTS/BF/PAGES/pids1.lua index 42c40af..5102e31 100644 --- a/src/SCRIPTS/BF/PAGES/pids1.lua +++ b/src/SCRIPTS/BF/PAGES/pids1.lua @@ -14,12 +14,12 @@ local fields = {} local pidMax = 200 local dLabel = "D" -if apiVersion >= 1.044 then +if apiVersion >= 1.44 then pidMax = 250 dLabel = "D Max" end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then x = margin y = yMinLim - tableSpacing.header @@ -50,7 +50,7 @@ if apiVersion >= 1.016 then labels[#labels + 1] = { t = dLabel, x = x, y = inc.y(tableSpacing.header) } fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 3 } } fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 6 } } - if apiVersion >= 1.041 then + if apiVersion >= 1.41 then fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = pidMax, vals = { 9 } } end end diff --git a/src/SCRIPTS/BF/PAGES/pids2.lua b/src/SCRIPTS/BF/PAGES/pids2.lua index 7fdb1d1..5acca13 100644 --- a/src/SCRIPTS/BF/PAGES/pids2.lua +++ b/src/SCRIPTS/BF/PAGES/pids2.lua @@ -13,11 +13,11 @@ local fields = {} local dMinMax = 100 -if apiVersion >= 1.044 then +if apiVersion >= 1.44 then dMinMax = 250 end -if apiVersion >= 1.040 then +if apiVersion >= 1.40 then x = margin y = yMinLim - tableSpacing.header @@ -34,7 +34,7 @@ if apiVersion >= 1.040 then fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 2000, vals = { 35, 36 } } fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 2000, vals = { 37, 38 } } - if apiVersion >= 1.041 then + if apiVersion >= 1.41 then x = x + tableSpacing.col y = yMinLim - tableSpacing.header @@ -48,9 +48,9 @@ if apiVersion >= 1.040 then y = inc.y(lineSpacing*0.4) end -if apiVersion >= 1.040 then +if apiVersion >= 1.40 then labels[#labels + 1] = { t = "Feedforward", x = x, y = inc.y(lineSpacing) } - if apiVersion >= 1.044 then + if apiVersion >= 1.44 then fields[#fields + 1] = { t = "Jitter Reduction", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 20, vals = { 55 } } fields[#fields + 1] = { t = "Smoothness", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 75, vals = { 52 } } fields[#fields + 1] = { t = "Averaging", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 3, vals = { 51 }, table = { [0] = "OFF", "2_POINT", "3_POINT", "4_POINT" } } @@ -60,15 +60,15 @@ if apiVersion >= 1.040 then fields[#fields + 1] = { t = "Transition", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 9 }, scale = 100 } end -if apiVersion >= 1.041 then +if apiVersion >= 1.41 then labels[#labels + 1] = { t = "D Min", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 43 } } fields[#fields + 1] = { t = "Advance", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 44 } } end -if apiVersion >= 1.021 and apiVersion <= 1.039 then +if apiVersion >= 1.21 and apiVersion <= 1.39 then labels[#labels + 1] = { t = "Dterm Setpoint", x = x, y = inc.y(lineSpacing) } - if apiVersion >= 1.021 and apiVersion <= 1.038 then + if apiVersion >= 1.21 and apiVersion <= 1.38 then fields[#fields + 1] = { t = "Weight", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 254, vals = { 10 }, scale = 100 } else fields[#fields + 1] = { t = "Weight", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 254, vals = { 25 }, scale = 100 } diff --git a/src/SCRIPTS/BF/PAGES/pwm.lua b/src/SCRIPTS/BF/PAGES/pwm.lua index 86a7845..0712d7a 100644 --- a/src/SCRIPTS/BF/PAGES/pwm.lua +++ b/src/SCRIPTS/BF/PAGES/pwm.lua @@ -13,47 +13,47 @@ local fields = {} local gyroSampleRateKhz -if apiVersion >= 1.044 then +if apiVersion >= 1.44 then gyroSampleRateKhz = assert(loadScript("BOARD_INFO/"..mcuId..".lua"))().gyroSampleRateHz / 1000 end local escProtocols = { [0] = "PWM", "OS125", "OS42", "MSHOT" } -if apiVersion >= 1.020 then +if apiVersion >= 1.20 then escProtocols[#escProtocols + 1] = "BRSH" end -if apiVersion >= 1.031 then +if apiVersion >= 1.31 then escProtocols[#escProtocols + 1] = "DS150" escProtocols[#escProtocols + 1] = "DS300" escProtocols[#escProtocols + 1] = "DS600" - if apiVersion < 1.042 then + if apiVersion < 1.42 then escProtocols[#escProtocols + 1] = "DS1200" end - if apiVersion >= 1.036 then + if apiVersion >= 1.36 then escProtocols[#escProtocols + 1] = "PS1000" end end -if apiVersion >= 1.043 then +if apiVersion >= 1.43 then escProtocols[#escProtocols + 1] = "DISABLED" end labels[#labels + 1] = { t = "System Config", x = x, y = inc.y(lineSpacing) } -if apiVersion >= 1.031 and apiVersion <= 1.040 then +if apiVersion >= 1.31 and apiVersion <= 1.40 then fields[#fields + 1] = { t = "32kHz Sampling", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 9 }, table = { [0] = "OFF", "ON" }, upd = function(self) self.updateRateTables(self) end } end -if apiVersion >= 1.044 then +if apiVersion >= 1.44 then fields[#fields + 1] = { t = "Gyro Update", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 32, vals = { 1 }, table = {}, upd = function(self) self.updatePidRateTable(self) end, mult = -1, ro = true } -elseif apiVersion <= 1.042 then +elseif apiVersion <= 1.42 then fields[#fields + 1] = { t = "Gyro Update", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 32, vals = { 1 }, table = {}, upd = function(self) self.updatePidRateTable(self) end, mult = -1 } end -if apiVersion <= 1.042 or apiVersion >= 1.044 then +if apiVersion <= 1.42 or apiVersion >= 1.44 then fields[#fields + 1] = { t = "PID Loop", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 16, vals = { 2 }, table = {}, mult = -1 } end labels[#labels + 1] = { t = "ESC/Motor", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Protocol", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = #escProtocols, vals = { 4 }, table = escProtocols } -if apiVersion >= 1.031 then +if apiVersion >= 1.31 then fields[#fields + 1] = { t = "Idle Throttle %", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 2000, vals = { 7, 8 }, scale = 100 } end fields[#fields + 1] = { t = "Unsynced PWM", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 3 }, table = { [0] = "OFF", "ON" } } diff --git a/src/SCRIPTS/BF/PAGES/rates.lua b/src/SCRIPTS/BF/PAGES/rates.lua index 355674f..55676ab 100644 --- a/src/SCRIPTS/BF/PAGES/rates.lua +++ b/src/SCRIPTS/BF/PAGES/rates.lua @@ -11,7 +11,7 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y = local labels = {} local fields = {} -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then y = yMinLim - tableSpacing.header labels[#labels + 1] = { t = "", x = x, y = inc.y(tableSpacing.header) } @@ -25,7 +25,7 @@ if apiVersion >= 1.016 then labels[#labels + 1] = { t = "RC", x = x, y = inc.y(tableSpacing.header) } labels[#labels + 1] = { t = "Rate", x = x, y = inc.y(tableSpacing.header) } - if apiVersion >= 1.037 then + if apiVersion >= 1.37 then fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 255, vals = { 1 }, scale = 100 } fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 255, vals = { 13 }, scale = 100 } else @@ -48,7 +48,7 @@ if apiVersion >= 1.016 then labels[#labels + 1] = { t = "RC", x = x, y = inc.y(tableSpacing.header) } labels[#labels + 1] = { t = "Expo", x = x, y = inc.y(tableSpacing.header) } - if apiVersion >= 1.037 then + if apiVersion >= 1.37 then fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 100, vals = { 2 }, scale = 100 } fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 100, vals = { 14 }, scale = 100 } else @@ -61,21 +61,21 @@ if apiVersion >= 1.016 then inc.y(lineSpacing*0.4) end -if apiVersion >= 1.043 then +if apiVersion >= 1.43 then fields[#fields + 1] = { t = "Rates Type", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 4, vals = { 23 }, table = { [0] = "BF", "RF", "KISS", "ACTUAL", "QUICK"}, postEdit = function(self) self.updateRatesType(self, true) end } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then labels[#labels + 1] = { t = "Throttle", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Mid", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 7 }, scale = 100 } fields[#fields + 1] = { t = "Expo", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 8 }, scale = 100 } - if apiVersion >= 1.041 then + if apiVersion >= 1.41 then fields[#fields + 1] = { t = "Limit Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 2, vals = { 15 }, table = { [0] = "OFF", "SCALE", "CLIP" } } fields[#fields + 1] = { t = "Limit %", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 25, max = 100, vals = { 16 } } end end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then labels[#labels + 1] = { t = "TPA", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Rate", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 6 } , scale = 100 } fields[#fields + 1] = { t = "Breakpoint", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 2000, vals = { 9, 10 } } @@ -131,7 +131,7 @@ return { self.ratesType = self.getRatesType(self) end, postLoad = function(self) - if apiVersion >= 1.043 then + if apiVersion >= 1.43 then self.updateRatesType(self) end end, diff --git a/src/SCRIPTS/BF/PAGES/rescue.lua b/src/SCRIPTS/BF/PAGES/rescue.lua index c3bc9a2..448de7b 100644 --- a/src/SCRIPTS/BF/PAGES/rescue.lua +++ b/src/SCRIPTS/BF/PAGES/rescue.lua @@ -11,14 +11,14 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y = local labels = {} local fields = {} -if apiVersion >= 1.041 then +if apiVersion >= 1.41 then fields[#fields + 1] = { t = "Min Sats.", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 50, vals = { 16 } } fields[#fields + 1] = { t = "Angle", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 1, 2 } } fields[#fields + 1] = { t = "Initial Altitude", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 20, max = 100, vals = { 3, 4 } } fields[#fields + 1] = { t = "Descent Distance", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 30, max = 500, vals = { 5, 6 } } fields[#fields + 1] = { t = "Ground Speed", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 30, max = 3000, vals = { 7, 8 } } - if apiVersion >= 1.043 then + if apiVersion >= 1.43 then fields[#fields + 1] = { t = "Ascend Rate", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 100, max = 2500, vals = { 17, 18 }, scale = 100 } fields[#fields + 1] = { t = "Descend Rate", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 100, max = 500, vals = { 19, 20 }, scale = 100 } fields[#fields + 1] = { t = "Arm w/o fix", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 21 }, table = { [0]="OFF","ON"} } @@ -31,7 +31,7 @@ if apiVersion >= 1.041 then fields[#fields + 1] = { t = "Hover", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 2000, vals = { 13, 14 } } fields[#fields + 1] = { t = "Max", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 2000, vals = { 11, 12 } } - if apiVersion >= 1.044 then + if apiVersion >= 1.44 then fields[#fields + 1] = { t = "Min Dth", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 50, max = 1000, vals = { 23, 24 } } end end diff --git a/src/SCRIPTS/BF/PAGES/rx.lua b/src/SCRIPTS/BF/PAGES/rx.lua index 8c6cd8f..a78540c 100644 --- a/src/SCRIPTS/BF/PAGES/rx.lua +++ b/src/SCRIPTS/BF/PAGES/rx.lua @@ -11,14 +11,14 @@ local inc = { x = function(val) x = x + val return x end, y = function(val) y = local labels = {} local fields = {} -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then labels[#labels + 1] = { t = "Stick", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Low", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 2000, vals = { 6, 7 } } fields[#fields + 1] = { t = "Center", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 2000, vals = { 4, 5 } } fields[#fields + 1] = { t = "High", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 2000, vals = { 2, 3 } } end -if apiVersion >= 1.044 then +if apiVersion >= 1.44 then labels[#labels + 1] = { t = "RC Smoothing", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Mode", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 25 }, table = { [0] = "ON", "OFF" } } labels[#labels + 1] = { t = "Cutoffs", x = x + indent, y = inc.y(lineSpacing) } @@ -27,7 +27,7 @@ if apiVersion >= 1.044 then labels[#labels + 1] = { t = "Auto Smoothness", x = x + indent, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Setpoint", x = x + indent*2, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 250, vals = { 31 } } else - if apiVersion >= 1.040 then + if apiVersion >= 1.40 then labels[#labels + 1] = { t = "RC Smoothing", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 25 }, table = { [0] = "Interpolation", "Filter" } } fields[#fields + 1] = { t = "Channels", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 4, vals = { 24 }, table = { [0] = "RP", "RPY", "RPYT", "T", "RT" } } @@ -39,17 +39,17 @@ else fields[#fields + 1] = { t = "Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 3, vals = { 29 }, table = { [0] = "Off", "PT1", "BIQUAD", "Auto"} } end - if apiVersion >= 1.020 then + if apiVersion >= 1.20 then fields[#fields + 1] = { t = "Interpolation", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 3, vals = { 13 }, table={ [0]="Off", "Preset", "Auto", "Manual"} } fields[#fields + 1] = { t = "Interval", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 50, vals = { 14 } } end - if apiVersion >= 1.042 then + if apiVersion >= 1.42 then fields[#fields + 1] = { t = "Auto Smoothness", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 50, vals = { 31 } } end end -if apiVersion >= 1.031 then +if apiVersion >= 1.31 then fields[#fields + 1] = { t = "Cam Angle", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 90, vals = { 23 } } end diff --git a/src/SCRIPTS/BF/PAGES/vtx.lua b/src/SCRIPTS/BF/PAGES/vtx.lua index 73a035e..e2a978e 100644 --- a/src/SCRIPTS/BF/PAGES/vtx.lua +++ b/src/SCRIPTS/BF/PAGES/vtx.lua @@ -12,7 +12,7 @@ local labels = {} local fields = {} local vtx_tables -if apiVersion >= 1.042 then +if apiVersion >= 1.42 then vtx_tables = assert(loadScript("VTX_TABLES/"..mcuId..".lua"))() else vtx_tables = assert(loadScript("VTX_TABLES/vtx_defaults.lua"))() @@ -20,7 +20,7 @@ end local deviceTable = { [1]="6705", [3]="SA", [4]="Tramp", [255]="None" } local pitModeTable = { [0]="OFF", "ON" } -if apiVersion >= 1.036 then +if apiVersion >= 1.36 then fields[#fields + 1] = { t = "Band", x = x, y = inc.y(lineSpacing), sp = x + sp, min=0, max=#(vtx_tables.bandTable), vals = { 2 }, table = vtx_tables.bandTable, upd = function(self) self.handleBandChanUpdate(self) end } fields[#fields + 1] = { t = "Channel", x = x, y = inc.y(lineSpacing), sp = x + sp, min=1, max=vtx_tables.frequenciesPerBand, vals = { 3 }, upd = function(self) self.handleBandChanUpdate(self) end } fields[#fields + 1] = { t = "Power", x = x, y = inc.y(lineSpacing), sp = x + sp, min=1, vals = { 4 }, upd = function(self) self.updatePowerTable(self) end } @@ -28,9 +28,9 @@ if apiVersion >= 1.036 then fields[#fields + 1] = { t = "Protocol", x = x, y = inc.y(lineSpacing), sp = x + sp, vals = { 1 }, write = false, ro = true, table = deviceTable } end -if apiVersion >= 1.037 then +if apiVersion >= 1.37 then fields[#fields + 1] = { t = "Frequency", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 5000, max = 5999, vals = { 6 }, upd = function(self) self.handleFreqValUpdate(self) end } -elseif apiVersion >= 1.036 then +elseif apiVersion >= 1.36 then fields[#fields + 1] = { t = "Frequency", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 5000, max = 5999, ro = true } end diff --git a/src/SCRIPTS/BF/api_version.lua b/src/SCRIPTS/BF/api_version.lua index 366fa50..c80efb3 100644 --- a/src/SCRIPTS/BF/api_version.lua +++ b/src/SCRIPTS/BF/api_version.lua @@ -6,7 +6,7 @@ local INTERVAL = 50 local function processMspReply(cmd,rx_buf) if cmd == MSP_API_VERSION and #rx_buf >= 3 then - apiVersion = rx_buf[2] + rx_buf[3] / 1000 + apiVersion = rx_buf[2] + rx_buf[3] / 100 apiVersionReceived = true end end diff --git a/src/SCRIPTS/BF/background.lua b/src/SCRIPTS/BF/background.lua index 239a569..a0086f5 100644 --- a/src/SCRIPTS/BF/background.lua +++ b/src/SCRIPTS/BF/background.lua @@ -21,7 +21,7 @@ local function run_bg() setRtc = nil collectgarbage() end - elseif rssiEnabled and apiVersion >= 1.037 then + elseif rssiEnabled and apiVersion >= 1.37 then rssiTask = rssiTask or assert(loadScript("rssi.lua"))() rssiEnabled = rssiTask() if not rssiEnabled then diff --git a/src/SCRIPTS/BF/board_info.lua b/src/SCRIPTS/BF/board_info.lua index 1fae01e..10efbe4 100644 --- a/src/SCRIPTS/BF/board_info.lua +++ b/src/SCRIPTS/BF/board_info.lua @@ -34,11 +34,11 @@ local function processMspReply(cmd, payload) hardwareRevision = bit32.bor(hardwareRevision, raw_val) i = i + 1 end - if apiVersion >= 1.035 then + if apiVersion >= 1.35 then boardType = payload[i] end i = i + 1 - if apiVersion >= 1.037 then + if apiVersion >= 1.37 then targetCapabilities = payload[i] i = i + 1 length = payload[i] @@ -48,7 +48,7 @@ local function processMspReply(cmd, payload) i = i + 1 end end - if apiVersion >= 1.039 then + if apiVersion >= 1.39 then length = payload[i] i = i + 1 for c = 1, length do @@ -68,14 +68,14 @@ local function processMspReply(cmd, payload) end end i = i + 1 - if apiVersion >= 1.041 then + if apiVersion >= 1.41 then mcuTypeId = payload[i] end i = i + 1 - if apiVersion >= 1.042 then + if apiVersion >= 1.42 then configurationState = payload[i] end - if apiVersion >= 1.043 then + if apiVersion >= 1.43 then for idx = 1, 2 do local raw_val = bit32.lshift(payload[i], (idx-1)*8) gyroSampleRateHz = bit32.bor(gyroSampleRateHz, raw_val) @@ -87,7 +87,7 @@ local function processMspReply(cmd, payload) i = i + 1 end end - if apiVersion >= 1.044 then + if apiVersion >= 1.44 then spiRegisteredDeviceCount = payload[i] i = i + 1 i2cRegisteredDeviceCount = payload[i] diff --git a/src/SCRIPTS/BF/pages.lua b/src/SCRIPTS/BF/pages.lua index 68f95ee..571a390 100644 --- a/src/SCRIPTS/BF/pages.lua +++ b/src/SCRIPTS/BF/pages.lua @@ -1,58 +1,58 @@ local PageFiles = {} -if apiVersion >= 1.036 then +if apiVersion >= 1.36 then PageFiles[#PageFiles + 1] = { title = "VTX Settings", script = "vtx.lua" } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Profiles", script = "profiles.lua" } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "PIDs 1", script = "pids1.lua" } end -if apiVersion >= 1.021 then +if apiVersion >= 1.21 then PageFiles[#PageFiles + 1] = { title = "PIDs 2", script = "pids2.lua" } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Rates", script = "rates.lua" } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Advanced PIDs", script = "pid_advanced.lua" } end -if apiVersion >= 1.044 then +if apiVersion >= 1.44 then PageFiles[#PageFiles + 1] = { title = "Simplified Tuning", script = "simplified_tuning.lua" } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Filters 1", script = "filters1.lua" } end -if apiVersion >= 1.042 then +if apiVersion >= 1.42 then PageFiles[#PageFiles + 1] = { title = "Filters 2", script = "filters2.lua" } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "System / Motor", script = "pwm.lua" } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Receiver", script = "rx.lua" } end -if apiVersion >= 1.016 then +if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Failsafe", script = "failsafe.lua" } end -if apiVersion >= 1.041 then +if apiVersion >= 1.41 then PageFiles[#PageFiles + 1] = { title = "GPS Rescue", script = "rescue.lua" } end -if apiVersion >= 1.041 then +if apiVersion >= 1.41 then PageFiles[#PageFiles + 1] = { title = "GPS PIDs", script = "gpspids.lua" } end diff --git a/src/SCRIPTS/BF/rtc.lua b/src/SCRIPTS/BF/rtc.lua index 955c91e..148a2fd 100644 --- a/src/SCRIPTS/BF/rtc.lua +++ b/src/SCRIPTS/BF/rtc.lua @@ -15,7 +15,7 @@ local function setRtc() -- only send datetime one time after telemetry connection became available -- or when connection is restored after e.g. lipo refresh local values = {} - if apiVersion >= 1.041 then + if apiVersion >= 1.41 then -- format: seconds after the epoch (32) / milliseconds (16) local now = getRtcTime() diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index 01d6e6e..97a2c74 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -91,7 +91,7 @@ local function createPopupMenu() end popupMenu[#popupMenu + 1] = { t = "reboot", f = rebootFc } popupMenu[#popupMenu + 1] = { t = "acc cal", f = function() confirm("CONFIRM/acc_cal.lua") end } - if apiVersion >= 1.042 then + if apiVersion >= 1.42 then popupMenu[#popupMenu + 1] = { t = "vtx tables", f = function() confirm("CONFIRM/vtx_tables.lua") end } end end diff --git a/src/SCRIPTS/BF/ui_init.lua b/src/SCRIPTS/BF/ui_init.lua index 939aa58..29ca80e 100644 --- a/src/SCRIPTS/BF/ui_init.lua +++ b/src/SCRIPTS/BF/ui_init.lua @@ -16,7 +16,7 @@ local function init() getApiVersion = nil collectgarbage() end - elseif not mcuIdReceived and apiVersion >= 1.042 then + elseif not mcuIdReceived and apiVersion >= 1.42 then getMCUId = getMCUId or assert(loadScript("mcu_id.lua"))() returnTable.t = getMCUId.t mcuIdReceived = getMCUId.f() @@ -35,7 +35,7 @@ local function init() end collectgarbage() end - elseif not vtxTablesReceived and apiVersion >= 1.042 then + elseif not vtxTablesReceived and apiVersion >= 1.42 then getVtxTables = getVtxTables or assert(loadScript("vtx_tables.lua"))() returnTable.t = getVtxTables.t vtxTablesReceived = getVtxTables.f() @@ -43,7 +43,7 @@ local function init() getVtxTables = nil collectgarbage() end - elseif not boardInfoReceived and apiVersion >= 1.044 then + elseif not boardInfoReceived and apiVersion >= 1.44 then getBoardInfo = getBoardInfo or assert(loadScript("board_info.lua"))() returnTable.t = getBoardInfo.t boardInfoReceived = getBoardInfo.f() From 50e9c519330a3c11f8be3a216b1dbd7aea9ba9cf Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Tue, 9 Aug 2022 13:37:42 +0200 Subject: [PATCH 06/18] Update PID Profile --- src/SCRIPTS/BF/PAGES/pid_advanced.lua | 6 ++++++ src/SCRIPTS/BF/PAGES/rates.lua | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/SCRIPTS/BF/PAGES/pid_advanced.lua b/src/SCRIPTS/BF/PAGES/pid_advanced.lua index 6ec3452..29d1a5b 100644 --- a/src/SCRIPTS/BF/PAGES/pid_advanced.lua +++ b/src/SCRIPTS/BF/PAGES/pid_advanced.lua @@ -33,6 +33,12 @@ if apiVersion >= 1.44 then fields[#fields + 1] = { t = "Thrust Linear", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 150, vals = { 57 } } end +if apiVersion >= 1.45 then + labels[#labels + 1] = { t = "TPA", x = x, y = inc.y(lineSpacing) } + fields[#fields + 1] = { t = "Rate", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 58 } , scale = 100 } + fields[#fields + 1] = { t = "Breakpoint", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 750, max = 2250, vals = { 59, 60 } } +end + if apiVersion >= 1.40 and apiVersion <= 1.41 then fields[#fields + 1] = { t = "Smart Feedforward", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 27 }, table = { [0] = "OFF", "ON" } } end diff --git a/src/SCRIPTS/BF/PAGES/rates.lua b/src/SCRIPTS/BF/PAGES/rates.lua index 55676ab..a157123 100644 --- a/src/SCRIPTS/BF/PAGES/rates.lua +++ b/src/SCRIPTS/BF/PAGES/rates.lua @@ -75,7 +75,7 @@ if apiVersion >= 1.16 then end end -if apiVersion >= 1.16 then +if apiVersion >= 1.16 and apiVersion <= 1.44 then labels[#labels + 1] = { t = "TPA", x = x, y = inc.y(lineSpacing) } fields[#fields + 1] = { t = "Rate", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 6 } , scale = 100 } fields[#fields + 1] = { t = "Breakpoint", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 2000, vals = { 9, 10 } } From 9e73791c0634f5f4ab504812c0dddf3191cd716a Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Tue, 4 Oct 2022 16:38:57 +0200 Subject: [PATCH 07/18] Increase dynamic idle limit Increase dynamic upper limit to 200 --- src/SCRIPTS/BF/PAGES/pid_advanced.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SCRIPTS/BF/PAGES/pid_advanced.lua b/src/SCRIPTS/BF/PAGES/pid_advanced.lua index 6ec3452..a91928f 100644 --- a/src/SCRIPTS/BF/PAGES/pid_advanced.lua +++ b/src/SCRIPTS/BF/PAGES/pid_advanced.lua @@ -21,7 +21,11 @@ end if apiVersion >= 1.43 then fields[#fields + 1] = { t = "Motor Output Limit",x = x, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 100, vals = { 48 } } - fields[#fields + 1] = { t = "Dynamic Idle", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 50 } } + if apiVersion >= 1.45 then + fields[#fields + 1] = { t = "Dynamic Idle", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 50 } } + else + fields[#fields + 1] = { t = "Dynamic Idle", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 50 } } + end end if apiVersion >= 1.16 and apiVersion <= 1.43 then From 811b462e136a475b09a2f58b97b42f68b314ca84 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Thu, 6 Oct 2022 20:52:38 +0200 Subject: [PATCH 08/18] Update anti gravity --- src/SCRIPTS/BF/PAGES/pid_advanced.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/SCRIPTS/BF/PAGES/pid_advanced.lua b/src/SCRIPTS/BF/PAGES/pid_advanced.lua index 6ec3452..fa07bae 100644 --- a/src/SCRIPTS/BF/PAGES/pid_advanced.lua +++ b/src/SCRIPTS/BF/PAGES/pid_advanced.lua @@ -54,15 +54,19 @@ end if apiVersion >= 1.36 then labels[#labels + 1] = { t = "Anti Gravity", x = x, y = inc.y(lineSpacing) } - if apiVersion >= 1.40 then + if apiVersion >= 1.40 and apiVersion <= 1.44 then fields[#fields + 1] = { t = "Mode", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 39 }, table = { [0]="Smooth", "Step" } } end - if apiVersion >= 1.44 then + if apiVersion >= 1.45 then + fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 250, vals = { 22, 23 } } + elseif apiVersion >= 1.44 then fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 30000, vals = { 22, 23 }, scale = 1000, mult = 100 } else fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1000, max = 30000, vals = { 22, 23 }, scale = 1000, mult = 100 } end - fields[#fields + 1] = { t = "Threshold", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 20, max = 1000, vals = { 20, 21 } } + if apiVersion <= 1.44 then + fields[#fields + 1] = { t = "Threshold", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 20, max = 1000, vals = { 20, 21 } } + end end return { From d8c44d8625a1911aec03f94d49aec2df696a7532 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Fri, 7 Oct 2022 14:18:40 +0200 Subject: [PATCH 09/18] Change anti gravity gain scale --- src/SCRIPTS/BF/PAGES/pid_advanced.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SCRIPTS/BF/PAGES/pid_advanced.lua b/src/SCRIPTS/BF/PAGES/pid_advanced.lua index 55d4b10..f4ffd40 100644 --- a/src/SCRIPTS/BF/PAGES/pid_advanced.lua +++ b/src/SCRIPTS/BF/PAGES/pid_advanced.lua @@ -62,7 +62,7 @@ if apiVersion >= 1.36 then fields[#fields + 1] = { t = "Mode", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 39 }, table = { [0]="Smooth", "Step" } } end if apiVersion >= 1.45 then - fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 250, vals = { 22, 23 } } + fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 250, vals = { 22, 23 }, scale = 10 } elseif apiVersion >= 1.44 then fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 30000, vals = { 22, 23 }, scale = 1000, mult = 100 } else From 21f287b1c6668b14fee9cb4c208758a8ac20d5fe Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Thu, 10 Nov 2022 04:46:07 +0100 Subject: [PATCH 10/18] Fix tpa --- src/SCRIPTS/BF/PAGES/pid_advanced.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/SCRIPTS/BF/PAGES/pid_advanced.lua b/src/SCRIPTS/BF/PAGES/pid_advanced.lua index d81d8c3..16d54cf 100644 --- a/src/SCRIPTS/BF/PAGES/pid_advanced.lua +++ b/src/SCRIPTS/BF/PAGES/pid_advanced.lua @@ -16,7 +16,7 @@ if apiVersion >= 1.40 then fields[#fields + 1] = { t = "Angle Limit", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 20, max = 80, vals = { 32 } } fields[#fields + 1] = { t = "Throttle Boost", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 31 } } fields[#fields + 1] = { t = "Absolute Control", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 20, vals = { 30 } } - fields[#fields + 1] = { t = "I Term Rotation", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 26 }, table = { [0]="OFF", "ON" } } + fields[#fields + 1] = { t = "I Term Rotation", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 26 }, table = { [0] = "OFF", "ON" } } end if apiVersion >= 1.43 then @@ -29,7 +29,7 @@ if apiVersion >= 1.43 then end if apiVersion >= 1.16 and apiVersion <= 1.43 then - fields[#fields + 1] = { t = "VBAT Compensation", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 8 }, table = { [0]="OFF", "ON" } } + fields[#fields + 1] = { t = "VBAT Compensation", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 8 }, table = { [0] = "OFF", "ON" } } end if apiVersion >= 1.44 then @@ -39,8 +39,9 @@ end if apiVersion >= 1.45 then labels[#labels + 1] = { t = "TPA", x = x, y = inc.y(lineSpacing) } - fields[#fields + 1] = { t = "Rate", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 58 } , scale = 100 } - fields[#fields + 1] = { t = "Breakpoint", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 750, max = 2250, vals = { 59, 60 } } + fields[#fields + 1] = { t = "Mode", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 58 }, table = { [0] = "PD", "D" } } + fields[#fields + 1] = { t = "Rate", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 100, vals = { 59 } , scale = 100 } + fields[#fields + 1] = { t = "Breakpoint", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 750, max = 2250, vals = { 60, 61 } } end if apiVersion >= 1.40 and apiVersion <= 1.41 then @@ -48,13 +49,13 @@ if apiVersion >= 1.40 and apiVersion <= 1.41 then end if apiVersion >= 1.41 then - fields[#fields + 1] = { t = "Integrated Yaw", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 45 }, table = { [0]="OFF", "ON" } } + fields[#fields + 1] = { t = "Integrated Yaw", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 45 }, table = { [0] = "OFF", "ON" } } end if apiVersion >= 1.40 then labels[#labels + 1] = { t = "I Term Relax", x = x, y = inc.y(lineSpacing) } - fields[#fields + 1] = { t = "Axes", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 4, vals = { 28 }, table = { [0]="NONE", "RP", "RPY", "RP (inc)", "RPY (inc)" } } - fields[#fields + 1] = { t = "Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 29 }, table = { [0]="Gyro", "Setpoint" } } + fields[#fields + 1] = { t = "Axes", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 4, vals = { 28 }, table = { [0] = "NONE", "RP", "RPY", "RP (inc)", "RPY (inc)" } } + fields[#fields + 1] = { t = "Type", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 29 }, table = { [0] = "Gyro", "Setpoint" } } if apiVersion >= 1.43 then fields[#fields + 1] = { t = "Cutoff", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 1, max = 50, vals = { 47 } } elseif apiVersion >= 1.42 then @@ -65,7 +66,7 @@ end if apiVersion >= 1.36 then labels[#labels + 1] = { t = "Anti Gravity", x = x, y = inc.y(lineSpacing) } if apiVersion >= 1.40 and apiVersion <= 1.44 then - fields[#fields + 1] = { t = "Mode", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 39 }, table = { [0]="Smooth", "Step" } } + fields[#fields + 1] = { t = "Mode", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 1, vals = { 39 }, table = { [0] = "Smooth", "Step" } } end if apiVersion >= 1.45 then fields[#fields + 1] = { t = "Gain", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 250, vals = { 22, 23 }, scale = 10 } From 138c7d49f0d6d546d75630b09c20abd8453d7598 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Sun, 13 Nov 2022 16:21:40 +0100 Subject: [PATCH 11/18] Handle signed values --- src/SCRIPTS/BF/ui.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index 97a2c74..42db07f 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -121,6 +121,10 @@ local function processMspReply(cmd,rx_buf) raw_val = bit32.lshift(raw_val, (idx-1)*8) f.value = bit32.bor(f.value, raw_val) end + local bits = #f.vals * 8 + if f.min < 0 and bit32.btest(f.value, bit32.lshift(1, bits - 1)) then + f.value = f.value - (2 ^ bits) + end f.value = f.value/(f.scale or 1) end end From 9c9c84867e2d96797f45b89aa23ba5549f966355 Mon Sep 17 00:00:00 2001 From: druckgott Date: Mon, 14 Nov 2022 08:00:59 +0100 Subject: [PATCH 12/18] Implement Trim Pitch Roll for ACC --- src/SCRIPTS/BF/PAGES/acc_trim.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/SCRIPTS/BF/PAGES/acc_trim.lua diff --git a/src/SCRIPTS/BF/PAGES/acc_trim.lua b/src/SCRIPTS/BF/PAGES/acc_trim.lua new file mode 100644 index 0000000..96ab089 --- /dev/null +++ b/src/SCRIPTS/BF/PAGES/acc_trim.lua @@ -0,0 +1,27 @@ +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 = "Trim Accelerometer", x = x, y = inc.y(lineSpacing) } +fields[#fields + 1] = { t = "Pitch", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = -300, max = 300, vals = { 1, 2 } } +fields[#fields + 1] = { t = "Roll", x = x + indent, y = inc.y(lineSpacing), sp = x + sp, min = -300, max = 300, vals = { 3, 4 } } + +return { + read = 240, -- MSP_ACC_TRIM + write = 239, -- MSP_SET_ACC_TRIM + title = "Acc", + reboot = false, + eepromWrite = true, + minBytes = 4, + labels = labels, + fields = fields, +} From a2165ace38708b4022596b2843980691f2d53115 Mon Sep 17 00:00:00 2001 From: druckgott Date: Mon, 14 Nov 2022 08:01:43 +0100 Subject: [PATCH 13/18] Add new Page for Trim Acc --- src/SCRIPTS/BF/pages.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SCRIPTS/BF/pages.lua b/src/SCRIPTS/BF/pages.lua index 571a390..db0d078 100644 --- a/src/SCRIPTS/BF/pages.lua +++ b/src/SCRIPTS/BF/pages.lua @@ -56,4 +56,8 @@ if apiVersion >= 1.41 then PageFiles[#PageFiles + 1] = { title = "GPS PIDs", script = "gpspids.lua" } end +if apiVersion >= 1.16 then + PageFiles[#PageFiles + 1] = { title = "Trim Accelerometer", script = "acc_trim.lua" } +end + return PageFiles From 0877a7b5c912fbdbd8dbc3f3a9be4e6d7d9aef60 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Mon, 14 Nov 2022 14:46:47 +0100 Subject: [PATCH 14/18] Check for min attribute --- src/SCRIPTS/BF/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SCRIPTS/BF/ui.lua b/src/SCRIPTS/BF/ui.lua index 42db07f..23f5bb9 100644 --- a/src/SCRIPTS/BF/ui.lua +++ b/src/SCRIPTS/BF/ui.lua @@ -122,7 +122,7 @@ local function processMspReply(cmd,rx_buf) f.value = bit32.bor(f.value, raw_val) end local bits = #f.vals * 8 - if f.min < 0 and bit32.btest(f.value, bit32.lshift(1, bits - 1)) then + if f.min and f.min < 0 and bit32.btest(f.value, bit32.lshift(1, bits - 1)) then f.value = f.value - (2 ^ bits) end f.value = f.value/(f.scale or 1) From 331d5478988fa47f93b3fd604d1f2ef68122ac3f Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Thu, 17 Nov 2022 14:58:55 +0100 Subject: [PATCH 15/18] Fix nightly build --- .github/workflows/build-release.yml | 6 +-- .github/workflows/ci.yml | 4 +- .github/workflows/nightly.yml | 68 +++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index a0a2c22..dbf60c7 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -14,13 +14,13 @@ jobs: release: name: Release needs: ci - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Code Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Fetch build artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 - name: List assets run: ls -al Assets diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c177ff..e10e5e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,10 @@ on: jobs: build: name: Build - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Code Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install Lua run: sudo apt-get -y install lua5.2 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000..f2116b8 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,68 @@ +# You'll need to setup the follwing environment variables: +# env.repo_nightly - The repository to release nightly builds to e.g. betaflight-tx-lua-scripts-nightlies +# env.release_notes - The release notes to be published as part of the github release +# env.debug_release_notes - The release notes to be published as part of the github debug release +# secrets.REPO_TOKEN - A GitHub token with permissions to push and publish releases to the nightly repo + +env: + repo_nightly: betaflight/betaflight-tx-lua-scripts-nightlies + debug_release_notes: > + This is an automated development build. + It may be unstable and result in corrupted configurations or data loss. + **Use only for testing.** + release_notes: This is a release build. + +name: Nightly + +on: + push: + branches: + - master + +jobs: + ci: + name: CI + uses: ./.github/workflows/ci.yml + with: + release_build: false + + release: + name: Nightly release + needs: ci + runs-on: ubuntu-22.04 + steps: + - name: Code Checkout + uses: actions/checkout@v3 + + - name: Fetch build artifacts + uses: actions/download-artifact@v3 + + - name: Select release notes + id: notes + run: | + set -- Assets/*.zip + echo "notes=$(test -e "$1" && echo '${{ env.debug_release_notes }}' || echo '${{ env.release_notes }}')" >> $GITHUB_OUTPUT + - name: Get current date + id: date + run: echo "today=$(date '+%Y%m%d')" >> $GITHUB_OUTPUT + + - name: Release + uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14 + with: + token: ${{ secrets.REPO_TOKEN }} + repository: ${{ env.repo_nightly }} + tag_name: v${{ steps.date.outputs.today }}.${{ github.run_number }} + files: Assets/*.zip + draft: false + prerelease: false + fail_on_unmatched_files: true + body: | + ${{ steps.notes.outputs.notes }} + ### Repository: + ${{ github.repository }} ([link](${{ github.event.repository.html_url }})) + ### Branch: + ${{ github.ref_name }} ([link](${{ github.event.repository.html_url }}/tree/${{ github.ref_name }})) + ### Latest changeset: + ${{ github.event.head_commit.id }} ([link](${{ github.event.head_commit.url }})) + ### Changes: + ${{ github.event.head_commit.message }} From c997403b8322f788316986b1a8acc58bced78f72 Mon Sep 17 00:00:00 2001 From: druckgott Date: Mon, 5 Dec 2022 21:38:40 +0100 Subject: [PATCH 16/18] Add Page for Position OSD Elements (Betaflight 4.4 MSP), small Fix Add Page for Position OSD Elements (Betaflight 4.4 MSP) Add osd pos Page Update pos_osd.lua Update pages.lua Update pos_osd.lua --- src/SCRIPTS/BF/PAGES/pos_osd.lua | 161 +++++++++++++++++++++++++++++++ src/SCRIPTS/BF/pages.lua | 4 + 2 files changed, 165 insertions(+) create mode 100644 src/SCRIPTS/BF/PAGES/pos_osd.lua diff --git a/src/SCRIPTS/BF/PAGES/pos_osd.lua b/src/SCRIPTS/BF/PAGES/pos_osd.lua new file mode 100644 index 0000000..3417ac2 --- /dev/null +++ b/src/SCRIPTS/BF/PAGES/pos_osd.lua @@ -0,0 +1,161 @@ +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 = {} + +local items = { + {["address"] = 0, ["firstVal"] = 11, ["secondVal"] = 12, ["nameCli"] = "rssi_pos"}, + {["address"] = 1, ["firstVal"] = 13, ["secondVal"] = 14, ["nameCli"] = "vbat_pos"}, + {["address"] = 2, ["firstVal"] = 15, ["secondVal"] = 16, ["nameCli"] = "crosshairs_pos"}, + {["address"] = 3, ["firstVal"] = 17, ["secondVal"] = 18, ["nameCli"] = "ah_pos"}, + {["address"] = 4, ["firstVal"] = 19, ["secondVal"] = 20, ["nameCli"] = "ah_sbar_pos"}, + {["address"] = 5, ["firstVal"] = 21, ["secondVal"] = 22, ["nameCli"] = "tim_1_pos"}, + {["address"] = 6, ["firstVal"] = 23, ["secondVal"] = 24, ["nameCli"] = "tim_2_pos"}, + {["address"] = 7, ["firstVal"] = 25, ["secondVal"] = 26, ["nameCli"] = "flymode_pos"}, + {["address"] = 8, ["firstVal"] = 27, ["secondVal"] = 28, ["nameCli"] = "craft_name_pos"}, + {["address"] = 9, ["firstVal"] = 29, ["secondVal"] = 30, ["nameCli"] = "throttle_pos"}, + {["address"] = 10, ["firstVal"] = 31, ["secondVal"] = 32, ["nameCli"] = "vtx_channel_pos"}, + {["address"] = 11, ["firstVal"] = 33, ["secondVal"] = 34, ["nameCli"] = "current_pos"}, + {["address"] = 12, ["firstVal"] = 35, ["secondVal"] = 36, ["nameCli"] = "mah_drawn_pos"}, + {["address"] = 13, ["firstVal"] = 37, ["secondVal"] = 38, ["nameCli"] = "gps_speed_pos"}, + {["address"] = 14, ["firstVal"] = 39, ["secondVal"] = 40, ["nameCli"] = "gps_sats_pos"}, + {["address"] = 15, ["firstVal"] = 41, ["secondVal"] = 42, ["nameCli"] = "altitude_pos"}, + {["address"] = 16, ["firstVal"] = 43, ["secondVal"] = 44, ["nameCli"] = "pid_roll_pos"}, + {["address"] = 17, ["firstVal"] = 45, ["secondVal"] = 46, ["nameCli"] = "pid_pitch_pos"}, + {["address"] = 18, ["firstVal"] = 47, ["secondVal"] = 48, ["nameCli"] = "pid_yaw_pos"}, + {["address"] = 19, ["firstVal"] = 49, ["secondVal"] = 50, ["nameCli"] = "power_pos"}, + {["address"] = 20, ["firstVal"] = 51, ["secondVal"] = 52, ["nameCli"] = "pidrate_profile_pos"}, + {["address"] = 21, ["firstVal"] = 53, ["secondVal"] = 54, ["nameCli"] = "warnings_pos"}, + {["address"] = 22, ["firstVal"] = 55, ["secondVal"] = 56, ["nameCli"] = "avg_cell_voltage_pos"}, + {["address"] = 23, ["firstVal"] = 57, ["secondVal"] = 58, ["nameCli"] = "gps_lon_pos"}, + {["address"] = 24, ["firstVal"] = 59, ["secondVal"] = 60, ["nameCli"] = "gps_lat_pos"}, + {["address"] = 25, ["firstVal"] = 61, ["secondVal"] = 62, ["nameCli"] = "debug_pos"}, + {["address"] = 26, ["firstVal"] = 63, ["secondVal"] = 64, ["nameCli"] = "pit_ang_pos"}, + {["address"] = 27, ["firstVal"] = 65, ["secondVal"] = 66, ["nameCli"] = "rol_ang_pos"}, + {["address"] = 28, ["firstVal"] = 67, ["secondVal"] = 68, ["nameCli"] = "battery_usage_pos"}, + {["address"] = 29, ["firstVal"] = 69, ["secondVal"] = 70, ["nameCli"] = "disarmed_pos"}, + {["address"] = 30, ["firstVal"] = 71, ["secondVal"] = 72, ["nameCli"] = "home_dir_pos"}, + {["address"] = 31, ["firstVal"] = 73, ["secondVal"] = 74, ["nameCli"] = "home_dist_pos"}, + {["address"] = 32, ["firstVal"] = 75, ["secondVal"] = 76, ["nameCli"] = "nheading_pos"}, + {["address"] = 33, ["firstVal"] = 77, ["secondVal"] = 78, ["nameCli"] = "nvario_pos"}, + {["address"] = 34, ["firstVal"] = 79, ["secondVal"] = 80, ["nameCli"] = "compass_bar_pos"}, + {["address"] = 35, ["firstVal"] = 81, ["secondVal"] = 82, ["nameCli"] = "esc_tmp_pos"}, + {["address"] = 36, ["firstVal"] = 83, ["secondVal"] = 84, ["nameCli"] = "esc_rpm_pos"}, + {["address"] = 37, ["firstVal"] = 85, ["secondVal"] = 86, ["nameCli"] = "remaining_time_estimate_pos"}, + {["address"] = 38, ["firstVal"] = 87, ["secondVal"] = 88, ["nameCli"] = "rtc_date_time_pos"}, + {["address"] = 39, ["firstVal"] = 89, ["secondVal"] = 90, ["nameCli"] = "adjustment_range_pos"}, + {["address"] = 40, ["firstVal"] = 91, ["secondVal"] = 92, ["nameCli"] = "core_temp_pos"}, + {["address"] = 41, ["firstVal"] = 93, ["secondVal"] = 94, ["nameCli"] = "anti_gravity_pos"}, + {["address"] = 42, ["firstVal"] = 95, ["secondVal"] = 96, ["nameCli"] = "g_force_pos"}, + {["address"] = 43, ["firstVal"] = 97, ["secondVal"] = 98, ["nameCli"] = "motor_diag_pos"}, + {["address"] = 44, ["firstVal"] = 99, ["secondVal"] = 100, ["nameCli"] = "log_status_pos"}, + {["address"] = 45, ["firstVal"] = 101, ["secondVal"] = 102, ["nameCli"] = "flip_arrow_pos"}, + {["address"] = 46, ["firstVal"] = 103, ["secondVal"] = 104, ["nameCli"] = "link_quality_pos"}, + {["address"] = 47, ["firstVal"] = 105, ["secondVal"] = 106, ["nameCli"] = "flight_dist_pos"}, + {["address"] = 48, ["firstVal"] = 107, ["secondVal"] = 108, ["nameCli"] = "stick_overlay_left_pos"}, + {["address"] = 49, ["firstVal"] = 109, ["secondVal"] = 110, ["nameCli"] = "stick_overlay_right_pos"}, + {["address"] = 50, ["firstVal"] = 111, ["secondVal"] = 112, ["nameCli"] = "display_name_pos"}, + {["address"] = 51, ["firstVal"] = 113, ["secondVal"] = 114, ["nameCli"] = "esc_rpm_freq_pos"}, + {["address"] = 52, ["firstVal"] = 115, ["secondVal"] = 116, ["nameCli"] = "rate_profile_name_pos"}, + {["address"] = 53, ["firstVal"] = 117, ["secondVal"] = 118, ["nameCli"] = "pid_profile_name_pos"}, + {["address"] = 54, ["firstVal"] = 119, ["secondVal"] = 120, ["nameCli"] = "profile_name_pos"}, + {["address"] = 55, ["firstVal"] = 121, ["secondVal"] = 122, ["nameCli"] = "rssi_dbm_pos"}, + {["address"] = 56, ["firstVal"] = 123, ["secondVal"] = 124, ["nameCli"] = "rcchannels_pos"}, + {["address"] = 57, ["firstVal"] = 125, ["secondVal"] = 126, ["nameCli"] = "camera_frame_pos"}, + {["address"] = 58, ["firstVal"] = 127, ["secondVal"] = 128, ["nameCli"] = "efficiency_pos"}, + {["address"] = 59, ["firstVal"] = 129, ["secondVal"] = 130, ["nameCli"] = "total_flights_pos"}, + {["address"] = 60, ["firstVal"] = 131, ["secondVal"] = 132, ["nameCli"] = "up_down_reference_pos"}, + {["address"] = 61, ["firstVal"] = 133, ["secondVal"] = 134, ["nameCli"] = "link_tx_power_pos"}, + {["address"] = 62, ["firstVal"] = 135, ["secondVal"] = 136, ["nameCli"] = "wh_drawn_pos"}, + {["address"] = 63, ["firstVal"] = 137, ["secondVal"] = 138, ["nameCli"] = "aux_pos"}, + {["address"] = 64, ["firstVal"] = 139, ["secondVal"] = 140, ["nameCli"] = "ready_mode_pos"}, + {["address"] = 65, ["firstVal"] = 141, ["secondVal"] = 142, ["nameCli"] = "rsnr_pos"}, + {["address"] = 66, ["firstVal"] = 143, ["secondVal"] = 144, ["nameCli"] = "sys_goggle_voltage_pos"}, + {["address"] = 67, ["firstVal"] = 145, ["secondVal"] = 146, ["nameCli"] = "sys_vtx_voltage_pos"}, + {["address"] = 68, ["firstVal"] = 147, ["secondVal"] = 148, ["nameCli"] = "sys_bitrate_pos"}, + {["address"] = 69, ["firstVal"] = 149, ["secondVal"] = 150, ["nameCli"] = "sys_delay_pos"}, + {["address"] = 70, ["firstVal"] = 151, ["secondVal"] = 152, ["nameCli"] = "sys_distance_pos"}, + {["address"] = 71, ["firstVal"] = 153, ["secondVal"] = 154, ["nameCli"] = "sys_lq_pos"}, + {["address"] = 72, ["firstVal"] = 155, ["secondVal"] = 156, ["nameCli"] = "sys_goggle_dvr_pos"}, + {["address"] = 73, ["firstVal"] = 157, ["secondVal"] = 158, ["nameCli"] = "sys_vtx_dvr_pos"}, + {["address"] = 74, ["firstVal"] = 159, ["secondVal"] = 160, ["nameCli"] = "sys_warnings_pos"}, + {["address"] = 75, ["firstVal"] = 161, ["secondVal"] = 162, ["nameCli"] = "sys_vtx_temp_pos"}, + {["address"] = 76, ["firstVal"] = 163, ["secondVal"] = 164, ["nameCli"] = "sys_fan_speed_pos"}, +} + +address = address or 0 +local firstVal = items[address + 1]["firstVal"] +local secondVal = items[address + 1]["secondVal"] +local nameCli = items[address + 1]["nameCli"] + +x = margin +y = yMinLim - tableSpacing.header + +fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.header), min = 0, max = (#items - 1), vals = { 1 }, upd = function(self) self.updateItems(self) end } +labels[#labels + 1] = { t = nameCli, x = x + tableSpacing.col * 1, y = y } + +labels[#labels + 1] = { t = "POS", x = x, y = inc.y(tableSpacing.header) } +labels[#labels + 1] = { t = "OP1", x = x + tableSpacing.col, y = y } +labels[#labels + 1] = { t = "OP2", x = x + tableSpacing.col * 2, y = y } +labels[#labels + 1] = { t = "OP3", x = x + tableSpacing.col * 3, y = y } + +fields[#fields + 1] = { x = x, y = inc.y(tableSpacing.row), min = 0, max = 2047, vals = { 2, 3 } } +fields[#fields + 1] = { x = x + tableSpacing.col, y = y, min = 0, max = 1, vals = { 1, 2 }, table = { [0] = "OFF", "ON" } } +fields[#fields + 1] = { x = x + tableSpacing.col * 2, y = y, min = 0, max = 1, vals = { 1, 2 }, table = { [0] = "OFF", "ON" } } +fields[#fields + 1] = { x = x + tableSpacing.col * 3, y = y, min = 0, max = 1, vals = { 1, 2 }, table = { [0] = "OFF", "ON" } } + +return { + read = 84, -- MSP_OSD_CONFIG + write = 85, -- MSP_SET_OSD_CONFIG + title = "OSD Elements", + reboot = false, + eepromWrite = true, + minBytes = 3, + labels = labels, + fields = fields, + postLoad = function(self) + self.fields[1].value = address + self.fields[2].value, self.fields[3].value, self.fields[4].value, self.fields[5].value = self.splitVal(self, self.values[firstVal], self.values[secondVal]) + end, + preSave = function(self) + self.values = {} + self.values[1] = self.fields[1].value + local combineValue = self.checkProfile(self, self.fields[2].value, self.fields[3].value, self.fields[4].value, self.fields[5].value) + self.values[2] = bit32.band(combineValue, 0xFF) + self.values[3] = bit32.rshift(combineValue, 8) + return self.values + end, + checkProfile = function(self, 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) + local inputVal = inputFirstVal + bit32.lshift(inputSecondVal, 8) + local profiles = bit32.extract(inputVal, 11, 3) + local fieldPos = bit32.extract(inputVal, 0, 11) + local fieldFirstProfile = bit32.band(bit32.rshift(profiles, 0), 1) + local FieldSecondProfile = bit32.band(bit32.rshift(profiles, 1), 1) + local FieldThirdProfile = bit32.band(bit32.rshift(profiles, 2), 1) + return fieldPos, fieldFirstProfile, FieldSecondProfile, FieldThirdProfile + end, + updateItems = function(self) + if self.fields[1].value ~= items[address + 1]["address"] then + address = self.fields[1].value + firstVal = items[address + 1]["firstVal"] + secondVal = items[address + 1]["secondVal"] + address = items[address + 1]["address"] + nameCli = items[address + 1]["nameCli"] + self.labels[1].t = nameCli + self.fields[2].value, self.fields[3].value, self.fields[4].value, self.fields[5].value = self.splitVal(self, self.values[firstVal], self.values[secondVal]) + end + end +} diff --git a/src/SCRIPTS/BF/pages.lua b/src/SCRIPTS/BF/pages.lua index db0d078..d1f1e01 100644 --- a/src/SCRIPTS/BF/pages.lua +++ b/src/SCRIPTS/BF/pages.lua @@ -60,4 +60,8 @@ if apiVersion >= 1.16 then PageFiles[#PageFiles + 1] = { title = "Trim Accelerometer", script = "acc_trim.lua" } end +if apiVersion >= 1.45 then + PageFiles[#PageFiles + 1] = { title = "OSD Elements", script = "pos_osd.lua" } +end + return PageFiles From 9f07432ebc105b370ddaba21f919525021703b5e Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Sat, 14 Jan 2023 21:12:25 +0100 Subject: [PATCH 17/18] Add scale to ground speed for >= API 1.45 --- src/SCRIPTS/BF/PAGES/rescue.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SCRIPTS/BF/PAGES/rescue.lua b/src/SCRIPTS/BF/PAGES/rescue.lua index 448de7b..cdbd21a 100644 --- a/src/SCRIPTS/BF/PAGES/rescue.lua +++ b/src/SCRIPTS/BF/PAGES/rescue.lua @@ -16,7 +16,12 @@ if apiVersion >= 1.41 then fields[#fields + 1] = { t = "Angle", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 200, vals = { 1, 2 } } fields[#fields + 1] = { t = "Initial Altitude", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 20, max = 100, vals = { 3, 4 } } fields[#fields + 1] = { t = "Descent Distance", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 30, max = 500, vals = { 5, 6 } } - fields[#fields + 1] = { t = "Ground Speed", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 30, max = 3000, vals = { 7, 8 } } + + if apiVersion >= 1.45 then + fields[#fields + 1] = { t = "Ground Speed", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 0, max = 3000, vals = { 7, 8 }, scale = 100 } + else + fields[#fields + 1] = { t = "Ground Speed", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 30, max = 3000, vals = { 7, 8 } } + end if apiVersion >= 1.43 then fields[#fields + 1] = { t = "Ascend Rate", x = x, y = inc.y(lineSpacing), sp = x + sp, min = 100, max = 2500, vals = { 17, 18 }, scale = 100 } From 633d3ba5a1f588193c0aa82dded1b7a0319a6ad0 Mon Sep 17 00:00:00 2001 From: Hans Christian Olaussen <41271048+klutvott123@users.noreply.github.com> Date: Mon, 30 Jan 2023 20:24:56 +0100 Subject: [PATCH 18/18] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e7dd41..2464a14 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![BF lua logo light mode](docs/assets/images/bf_lua_logo_light_mode.png#gh-light-mode-only) ![BF lua logo dark mode](docs/assets/images/bf_lua_logo_dark_mode.png#gh-dark-mode-only) - [![Latest version](https://img.shields.io/github/v/release/betaflight/betaflight-tx-lua-scripts)](https://github.com/betaflight/betaflight-tx-lua-scripts/releases) [![Build Status](https://api.travis-ci.com/betaflight/betaflight-tx-lua-scripts.svg?branch=master)](https://travis-ci.com/betaflight/betaflight-tx-lua-scripts) [![Build Status](https://dev.azure.com/Betaflight/Betaflight%20Nightlies/_apis/build/status/betaflight.betaflight-tx-lua-scripts?branchName=master)](https://dev.azure.com/Betaflight/Betaflight%20Nightlies/_build/latest?definitionId=1&branchName=master) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) + [![Latest version](https://img.shields.io/github/v/release/betaflight/betaflight-tx-lua-scripts)](https://github.com/betaflight/betaflight-tx-lua-scripts/releases) [![Build](https://img.shields.io/github/actions/workflow/status/betaflight/betaflight-tx-lua-scripts/nightly.yml?branch=master)](https://github.com/betaflight/betaflight-tx-lua-scripts/actions/workflows/nightly.yml) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) ## Requirements @@ -10,8 +10,9 @@ - OpenTX - 2.3.12 or newer; - EdgeTX - 2.4.0 or newer; - ExpressLRS - 2.0.1 or newer; -- Crossfire TX / RX - v2.11 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. ## Installing