Skip to content

Commit

Permalink
display error info when no signal found
Browse files Browse the repository at this point in the history
  • Loading branch information
offer-shmuely committed Nov 18, 2024
1 parent 5bc0fe5 commit 67d6e32
Showing 1 changed file with 20 additions and 33 deletions.
53 changes: 20 additions & 33 deletions sdcard/c480x272/SCRIPTS/TOOLS/Model Locator (by RSSI).lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,32 @@ end

local function getSignalValues()

-- try regular RSSI
-- try regular Frsky RSSI
local fieldinfo = getFieldInfo("RSSI")
if fieldinfo then
local v = getValue("RSSI")
log("RSSI: " .. v)
lcd.drawText(3, 30, "Signal: RSSI", 0)
return v, 0, 100
return v, 0, 100, "Using signal: Frsky RSSI", nil
end

-- try expressLRS
-- try expressLRS antenna 1
local fieldinfo = getFieldInfo("1RSS")
if fieldinfo then
local v = getValue("1RSS")
lcd.drawText(3, 30, "Signal: 1RSS", 0)
if v == 0 then
v = -115
end
return v, -115, 20
return v, -115, 20, "Using signal: elrs 1RSS", "Set tx power to 25mW non dynamic"
end

-- try expressLRS
-- try expressLRS antenna 2
local fieldinfo = getFieldInfo("2RSS")
if fieldinfo then
local v = getValue("2RSS")
lcd.drawText(3, 30, "Signal: 2RSS", 0)
if v == 0 then
v = -115
end
return v, -115, 20
return v, -115, 20, "Using signal: elrs 2RSS", "Set tx power to 25mW non dynamic"
end

---- try UNI-ACSST firmware VFR
Expand All @@ -144,43 +141,36 @@ end

local function main(event, touchState)
lcd.clear()

-- background
--lcd.drawBitmap(img, 0, 20, 30)
lcd.drawBitmap(img, 250, 50, 40)
lcd.drawBitmap(img, LCD_W-120, 30, 20)

-- Title
lcd.drawText(3, 3, "RSSI Model Locator", 0)
lcd.drawText(LCD_W - 50, 3, "ver: " .. app_ver .. "", SMLSIZE)
lcd.drawFilledRectangle(0,0, LCD_W, 30, BLACK)
lcd.drawFilledRectangle(0,LCD_H-25, LCD_W, 25, GREY)
lcd.drawText(10, 3, "RSSI Model Locator", WHITE)
lcd.drawText(LCD_W - 50, 3, "ver: " .. app_ver .. "", SMLSIZE + GREEN)

local signalValue, signalMin, signalMax = getSignalValues()
local signalValue, signalMin, signalMax, line1, line2 = getSignalValues()
-- log(signalValue)
if signalValue == nil then
lcd.drawText(30, 50, "No signal found (expected: RSSI/1RSS/2RSS)", 0 + BLINK)
return 0
end
lcd.drawText(3, 60, line2 or "", RED)
lcd.drawText(10, LCD_H-22, line1, WHITE)

log("signalValue:" .. signalValue .. ", signalMin: " .. signalMin .. ", signalMax: " .. signalMax)

--if (rssi > 42) then
-- lcd.setColor(CUSTOM_COLOR, YELLOW) -- RED / YELLOW
--else
-- lcd.setColor(CUSTOM_COLOR, RED) -- RED / YELLOW
--end
local signalPercent = 100 * ((signalValue - signalMin) / (signalMax - signalMin))
--myColor = getRangeColor(signalPercent, 0, 100)
--lcd.setColor(CUSTOM_COLOR, myColor)
lcd.setColor(CUSTOM_COLOR, getRangeColor(signalPercent, 0, 100))

-- draw current value
lcd.drawNumber(180, 30, signalValue, XXLSIZE + CUSTOM_COLOR)
lcd.drawText(260, 70, "db", 0 + CUSTOM_COLOR)
lcd.drawNumber(40, 100, signalValue, XXLSIZE + CUSTOM_COLOR)
lcd.drawText(130, 140, "db", 0 + CUSTOM_COLOR)

-- draw main bar
--lcd.setColor(CUSTOM_COLOR, YELLOW) -- RED / YELLOW
local xMin = 0
local yMin = 270
local xMax = 480
local yMax = 200
local xMin = 10
local yMin = LCD_H - 30
local xMax = LCD_W
local h = 0
local rssiAsX = (signalPercent * xMax) / 100
log("signalPercent:" .. signalPercent .. ", signalValue: " .. signalValue .. ", rssiAsX: " .. rssiAsX)
Expand All @@ -190,9 +180,6 @@ local function main(event, touchState)
lcd.drawFilledRectangle(xx, yMin - h, 15, h, CUSTOM_COLOR)
end

-- draw rectangle
--lcd.drawFilledRectangle(0, 250, signalPercent * 4.8, 20, GREY_DEFAULT)

-- beep
if getTime() >= nextPlayTime then
playFile("/SCRIPTS/TOOLS/Model Locator (by RSSI).wav")
Expand Down

0 comments on commit 67d6e32

Please sign in to comment.