From 9bf773982a533a8f078dbb27d00f6d6494d6fa32 Mon Sep 17 00:00:00 2001 From: AegisCrusader <18148657+AegisCrusader@users.noreply.github.com> Date: Tue, 24 Dec 2024 17:01:32 -0500 Subject: [PATCH] Adding support for b&w 212x64 --- .../SCRIPTS/TOOLS/Model Locator (by RSSI).wav | Bin 0 -> 2772 bytes .../SCRIPTS/TOOLS/RSSI Model Locator.lua | 156 ++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 sdcard/bw212x64/SCRIPTS/TOOLS/Model Locator (by RSSI).wav create mode 100644 sdcard/bw212x64/SCRIPTS/TOOLS/RSSI Model Locator.lua diff --git a/sdcard/bw212x64/SCRIPTS/TOOLS/Model Locator (by RSSI).wav b/sdcard/bw212x64/SCRIPTS/TOOLS/Model Locator (by RSSI).wav new file mode 100644 index 0000000000000000000000000000000000000000..bbd078e88feb733e93d3cfe86fbbd75c62022e0a GIT binary patch literal 2772 zcmWNRXQ>kAWP6EH44EJv07Rc>w?<$xm6wy6m4IN zidvtDt)e~=t;MCd6+vrJGL%dNLP(&6Ndhw=feaF|k&uv($M1eQAMTfP?){%kacXLF zFaUg{Kl&|46}i{xx0Z?KttToZ*3D08f0PADICMeCI0HrH9kONc$j>dcoFIBzHG(;x5;bUZ*yx)?qH zc@-Qx*n|%b@O-zKS)h9uP&7A3adRc_C$IJ{Rcyk>`U=1rBo#;_XX(#aR|BQcyL67> ztn4TK{>X#U)X0^_e3aGplWhvO9x`t>{haXutJHf@1EPCfoRpEY&v-Q&Mq_sO z9$z~$%nqVjaEZCy_W>9WrVdwNH(QqSJdziQv7UWcEY@i}1sxP@2-J{Qb(@DT0fo>N zdX+&cOVRETmSkRt-r8S<^4mmK+vF%7-=)!BA-{GF(E--!vFwhgGNr?s$cB0G~% zqU+FD9I_=iXYeSVW=``}F;9c8;oXWm%`3Up>7~gI@7Id|$=@-42A&j*13!>Yb%=EU z5JT~F75P~9P}dZ(UOFlAo^eLwp0;;weVk<8q>(=D7vu$35MvTc=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|GHwZX zzvDw~n;~O#>qKAUqm$I(=vG&B%98XQJdUOZecB!H;mEq+P)db+%zG&`tQNaVJv5I$+l0TdA3TF}Mc|wR|ea zTN4DYGZrPpyHl`!>=)A$=(6DCcnq;ozub0^b{$$tyWA_1%_O2?Zf35UCnndSa+TE{ z4o`wtI4ZQ?8=ku<2Esb+F}3G5?(){IoVC_5`Eom>ai%tBoF;e$JsFs)MFwa3!$A<7 zH&oJuDsNBOx9-#B%8^+4QN@vd3Y;sr6L1g~U8?OGa1y#oD{VV&g$i)k@781t+il!2}PF$2TMWtTO}u)OMPm U`?r8H=9QskP1o8Yk&5;I2fCWSyZ`_I literal 0 HcmV?d00001 diff --git a/sdcard/bw212x64/SCRIPTS/TOOLS/RSSI Model Locator.lua b/sdcard/bw212x64/SCRIPTS/TOOLS/RSSI Model Locator.lua new file mode 100644 index 00000000..a6fd948b --- /dev/null +++ b/sdcard/bw212x64/SCRIPTS/TOOLS/RSSI Model Locator.lua @@ -0,0 +1,156 @@ +---- ######################################################################### +---- # # +---- # Telemetry Widget script for b&w 212x64 radios # +---- # Copyright (C) EdgeTX # +-----# # +---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html # +---- # # +---- # This program is free software; you can redistribute it and/or modify # +---- # it under the terms of the GNU General Public License version 2 as # +---- # published by the Free Software Foundation. # +---- # # +---- # This program is distributed in the hope that it will be useful # +---- # but WITHOUT ANY WARRANTY; without even the implied warranty of # +---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +---- # GNU General Public License for more details. # +---- # # +---- ######################################################################### + +-- Model Locator by RSSI +-- AegisCrusader & Offer Shmuely (based on code from Scott Bauer 6/21/2015) +-- Date: 2022-2024 +-- ver: 0.6 +local app_ver = "0.6" + +-- This widget help to find a lost/crashed model based on the RSSI (if still available) +-- The widget produce audio representation (vario-meter style) of the RSSI from the lost model +-- The widget also displays the RSSI in a visible bar + +-- There are two way to use it +-- 1. The simple way: +-- walk toward the quad/plane that crashed, +-- as you get closer to your model the beeps will become more frequent with higher pitch (and a visual bar graph as well) +-- until you get close enough to find it visually + +-- 2. the more accurate way: +-- turn the antenna straight away (i.e. to point from you, straight away) +-- try to find the weakest signal! (not the highest), i.e. the lowest RSSI you can find, this is the direction to the model. +-- now walk to the side (not toward the model), find again the weakest signal, this is also the direction to your model +-- triangulate the two lines, and it will be :-) + +local delayMillis = 100 +local targetTXPower = 25 +local nextPlayTime = getTime() +local useHaptic = false + +local function getSignalValues() + -- try to get transmitter power + local txPowerField = getFieldInfo("TPWR") + local txPowerValue = nil + if txPowerField then + txPowerValue = getValue("TPWR") + end + + -- try regular Frsky RSSI + local fieldinfo = getFieldInfo("RSSI") + if fieldinfo then + local v = getValue("RSSI") + return v, 0, 100, txPowerValue, "Using signal: Frsky RSSI", nil + end + + -- try expressLRS antenna 1 + local fieldinfo = getFieldInfo("1RSS") + if fieldinfo then + local v = getValue("1RSS") + if v == 0 then + v = -115 + end + return v, -115, 20, txPowerValue, "Using signal: ELRS 1RSS", "Set TX PWR 25mW No Dyn" + end + + -- try expressLRS antenna 2 + local fieldinfo = getFieldInfo("2RSS") + if fieldinfo then + local v = getValue("2RSS") + if v == 0 then + v = -115 + end + return v, -115, 20, txPowerValue, "Using signal: ELRS 2RSS", "Set TX PWR 25mW No Dyn" + end + + return nil, 0, 0 +end + +local function init() + lcd.clear() +end + +local function run(event) + -- exit script + if event == EVT_VIRTUAL_EXIT then + return 2 + end + + lcd.clear() + + local signalValue, signalMin, signalMax, txPower, line1, line2 = getSignalValues() + + lcd.drawText(0, 0, "Model Locator by RSSI", BOLD) + + if signalValue == nil then + lcd.drawText(0, 24, "No signal, expected:", 0 + BLINK) + lcd.drawText(0, 32, "RSSI/1RSS/2RSS", 0 + BLINK) + return 0 + end + + if txPower then + lcd.drawText(0, 16, "Current TX PWR: " .. tostring(txPower) .. "mW") + + if txPower ~= targetTXPower then + lcd.drawText(0, 8, line2 or "", BLINK) + else + lcd.drawText(0, 8, "[ENTER] to toggle haptic") + end + else + lcd.drawText(0, 8, "[ENTER] to toggle haptic") + end + + local signalPercent = 100 * ((signalValue - signalMin) / (signalMax - signalMin)) + + lcd.drawText(0, 24, tostring(signalValue) .. "db", DBLSIZE) + + -- draw main bar + local xMin = 10 + local yMin = LCD_H - 10 + local xMax = LCD_W + local h = 0 + local rssiAsX = (signalPercent * xMax) / 100 + + for xx = xMin, rssiAsX, 8 do + h = h + 2 + lcd.drawFilledRectangle(xx, yMin - h, 5, h) + end + + lcd.drawFilledRectangle(0, LCD_H - 10, LCD_W, 1) + + -- current signal type + lcd.drawText(0, LCD_H - 8, line1) + + -- toggle haptic + if event == EVT_VIRTUAL_ENTER then + useHaptic = not useHaptic + end + + -- beep + if getTime() >= nextPlayTime then + playFile("/SCRIPTS/TOOLS/Model Locator (by RSSI).wav") + if useHaptic then + playHaptic(7, 0, 1) + end + nextPlayTime = getTime() + delayMillis - signalPercent + end + + return 0 +end + +return {init = init, run = run}