From aaebe2443ca314eca38818788be9c17d0fc02c7e Mon Sep 17 00:00:00 2001 From: JLP Date: Wed, 7 Jan 2026 21:37:41 -0500 Subject: [PATCH] ethos nil check --- .gitignore | 2 ++ .../SD/scripts/yaaputelemetry/lib/drawlib.lua | 3 ++- .../SD/scripts/yaaputelemetry/lib/utils.lua | 14 +++++++++++--- ETHOS/c480x272/SD/scripts/yaaputelemetry/main.lua | 8 ++++++-- .../SD/scripts/yaaputelemetry/lib/drawlib.lua | 3 ++- .../SD/scripts/yaaputelemetry/lib/utils.lua | 14 +++++++++++--- ETHOS/c480x320/SD/scripts/yaaputelemetry/main.lua | 8 ++++++-- .../SD/scripts/yaaputelemetry/lib/drawlib.lua | 3 ++- .../SD/scripts/yaaputelemetry/lib/utils.lua | 14 +++++++++++--- ETHOS/c800x480/SD/scripts/yaaputelemetry/main.lua | 8 ++++++-- 10 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3177d691 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# macos +.DS_Store diff --git a/ETHOS/c480x272/SD/scripts/yaaputelemetry/lib/drawlib.lua b/ETHOS/c480x272/SD/scripts/yaaputelemetry/lib/drawlib.lua index 0c585414..57dcd3cb 100644 --- a/ETHOS/c480x272/SD/scripts/yaaputelemetry/lib/drawlib.lua +++ b/ETHOS/c480x272/SD/scripts/yaaputelemetry/lib/drawlib.lua @@ -134,7 +134,8 @@ function drawLib.drawStatusBar(widget, y, maxRows) lcd.drawFilledRectangle(0,y,480,27) -- flight time - local seconds = model.getTimer("Yaapu"):value() + local timer = model.getTimer("Yaapu") + local seconds = timer ~= nil and timer:value() or 0 local ss = (seconds%3600)%60 local mm = math.floor(seconds/60) drawLib.drawText(480, y-4, string.format("%02.0f:%02.0f",mm,ss), FONT_XXL, status.colors.barText, RIGHT) diff --git a/ETHOS/c480x272/SD/scripts/yaaputelemetry/lib/utils.lua b/ETHOS/c480x272/SD/scripts/yaaputelemetry/lib/utils.lua index 7d95dcc4..8d05d558 100644 --- a/ETHOS/c480x272/SD/scripts/yaaputelemetry/lib/utils.lua +++ b/ETHOS/c480x272/SD/scripts/yaaputelemetry/lib/utils.lua @@ -668,8 +668,13 @@ function utils.calcFLVSSBatt(battIdx) return 0,0,0 end - local cellMin = system.getSource({name=batterySource:name(),options=OPTION_CELL_LOWEST}):value() - local cellCount = system.getSource({name=batterySource:name(),options=OPTION_CELL_COUNT}):value() + local cellMinSrc = system.getSource({name=batterySource:name(),options=OPTION_CELL_LOWEST}) + local cellCountSrc = system.getSource({name=batterySource:name(),options=OPTION_CELL_COUNT}) + if cellMinSrc == nil or cellCountSrc == nil then + return 0,0,0 + end + local cellMin = cellMinSrc:value() + local cellCount = cellCountSrc:value() local cellSum = batterySource:value() statusBattSources.vs = true @@ -972,7 +977,10 @@ function utils.pushMessage(severity, msg) end function utils.updateFlightTime() - status.flightTime = tonumber(model.getTimer("Yaapu"):value()) + local timer = model.getTimer("Yaapu") + if timer ~= nil then + status.flightTime = tonumber(timer:value()) + end end --------------------------------- diff --git a/ETHOS/c480x272/SD/scripts/yaaputelemetry/main.lua b/ETHOS/c480x272/SD/scripts/yaaputelemetry/main.lua index 028736d9..912b9f26 100644 --- a/ETHOS/c480x272/SD/scripts/yaaputelemetry/main.lua +++ b/ETHOS/c480x272/SD/scripts/yaaputelemetry/main.lua @@ -803,8 +803,12 @@ local function task1(now) local gpsData = {} if status.conf.gpsSource ~= nil then - gpsData.lat = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LATITUDE}):value() - gpsData.lon = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LONGITUDE}):value() + local latSrc = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LATITUDE}) + local lonSrc = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LONGITUDE}) + if latSrc ~= nil and lonSrc ~= nil then + gpsData.lat = latSrc:value() + gpsData.lon = lonSrc:value() + end end if gpsData.lat ~= nil and gpsData.lon ~= nil then diff --git a/ETHOS/c480x320/SD/scripts/yaaputelemetry/lib/drawlib.lua b/ETHOS/c480x320/SD/scripts/yaaputelemetry/lib/drawlib.lua index 53c8b7dc..9bb0fc23 100644 --- a/ETHOS/c480x320/SD/scripts/yaaputelemetry/lib/drawlib.lua +++ b/ETHOS/c480x320/SD/scripts/yaaputelemetry/lib/drawlib.lua @@ -134,7 +134,8 @@ function drawLib.drawStatusBar(widget, y, maxRows) lcd.drawFilledRectangle(0,y,480,27) -- flight time - local seconds = model.getTimer("Yaapu"):value() + local timer = model.getTimer("Yaapu") + local seconds = timer ~= nil and timer:value() or 0 local ss = (seconds%3600)%60 local mm = math.floor(seconds/60) drawLib.drawText(480, y-4, string.format("%02.0f:%02.0f",mm,ss), FONT_XXL, status.colors.barText, RIGHT) diff --git a/ETHOS/c480x320/SD/scripts/yaaputelemetry/lib/utils.lua b/ETHOS/c480x320/SD/scripts/yaaputelemetry/lib/utils.lua index 41f4ef49..f57c8742 100644 --- a/ETHOS/c480x320/SD/scripts/yaaputelemetry/lib/utils.lua +++ b/ETHOS/c480x320/SD/scripts/yaaputelemetry/lib/utils.lua @@ -668,8 +668,13 @@ function utils.calcFLVSSBatt(battIdx) return 0,0,0 end - local cellMin = system.getSource({name=batterySource:name(),options=OPTION_CELL_LOWEST}):value() - local cellCount = system.getSource({name=batterySource:name(),options=OPTION_CELL_COUNT}):value() + local cellMinSrc = system.getSource({name=batterySource:name(),options=OPTION_CELL_LOWEST}) + local cellCountSrc = system.getSource({name=batterySource:name(),options=OPTION_CELL_COUNT}) + if cellMinSrc == nil or cellCountSrc == nil then + return 0,0,0 + end + local cellMin = cellMinSrc:value() + local cellCount = cellCountSrc:value() local cellSum = batterySource:value() statusBattSources.vs = true @@ -972,7 +977,10 @@ function utils.pushMessage(severity, msg) end function utils.updateFlightTime() - status.flightTime = tonumber(model.getTimer("Yaapu"):value()) + local timer = model.getTimer("Yaapu") + if timer ~= nil then + status.flightTime = tonumber(timer:value()) + end end --------------------------------- diff --git a/ETHOS/c480x320/SD/scripts/yaaputelemetry/main.lua b/ETHOS/c480x320/SD/scripts/yaaputelemetry/main.lua index 2dfa6d32..183fb269 100644 --- a/ETHOS/c480x320/SD/scripts/yaaputelemetry/main.lua +++ b/ETHOS/c480x320/SD/scripts/yaaputelemetry/main.lua @@ -802,8 +802,12 @@ local function task1(now) local gpsData = {} if status.conf.gpsSource ~= nil then - gpsData.lat = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LATITUDE}):value() - gpsData.lon = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LONGITUDE}):value() + local latSrc = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LATITUDE}) + local lonSrc = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LONGITUDE}) + if latSrc ~= nil and lonSrc ~= nil then + gpsData.lat = latSrc:value() + gpsData.lon = lonSrc:value() + end end if gpsData.lat ~= nil and gpsData.lon ~= nil then diff --git a/ETHOS/c800x480/SD/scripts/yaaputelemetry/lib/drawlib.lua b/ETHOS/c800x480/SD/scripts/yaaputelemetry/lib/drawlib.lua index 03f39f90..feb5f933 100644 --- a/ETHOS/c800x480/SD/scripts/yaaputelemetry/lib/drawlib.lua +++ b/ETHOS/c800x480/SD/scripts/yaaputelemetry/lib/drawlib.lua @@ -134,7 +134,8 @@ function drawLib.drawStatusBar(widget, y, maxRows) lcd.drawFilledRectangle(0,y,800,48) -- flight time - local seconds = model.getTimer("Yaapu"):value() + local timer = model.getTimer("Yaapu") + local seconds = timer ~= nil and timer:value() or 0 local ss = (seconds%3600)%60 local hh = math.floor(seconds/3600) local mm = math.floor((seconds%3600)/60) diff --git a/ETHOS/c800x480/SD/scripts/yaaputelemetry/lib/utils.lua b/ETHOS/c800x480/SD/scripts/yaaputelemetry/lib/utils.lua index 9553bce7..52e0a325 100644 --- a/ETHOS/c800x480/SD/scripts/yaaputelemetry/lib/utils.lua +++ b/ETHOS/c800x480/SD/scripts/yaaputelemetry/lib/utils.lua @@ -668,8 +668,13 @@ function utils.calcFLVSSBatt(battIdx) return 0,0,0 end - local cellMin = system.getSource({name=batterySource:name(),options=OPTION_CELL_LOWEST}):value() - local cellCount = system.getSource({name=batterySource:name(),options=OPTION_CELL_COUNT}):value() + local cellMinSrc = system.getSource({name=batterySource:name(),options=OPTION_CELL_LOWEST}) + local cellCountSrc = system.getSource({name=batterySource:name(),options=OPTION_CELL_COUNT}) + if cellMinSrc == nil or cellCountSrc == nil then + return 0,0,0 + end + local cellMin = cellMinSrc:value() + local cellCount = cellCountSrc:value() local cellSum = batterySource:value() statusBattSources.vs = true @@ -972,7 +977,10 @@ function utils.pushMessage(severity, msg) end function utils.updateFlightTime() - status.flightTime = tonumber(model.getTimer("Yaapu"):value()) + local timer = model.getTimer("Yaapu") + if timer ~= nil then + status.flightTime = tonumber(timer:value()) + end end --------------------------------- diff --git a/ETHOS/c800x480/SD/scripts/yaaputelemetry/main.lua b/ETHOS/c800x480/SD/scripts/yaaputelemetry/main.lua index dda71188..867e6de4 100644 --- a/ETHOS/c800x480/SD/scripts/yaaputelemetry/main.lua +++ b/ETHOS/c800x480/SD/scripts/yaaputelemetry/main.lua @@ -802,8 +802,12 @@ local function task1(now) local gpsData = {} if status.conf.gpsSource ~= nil then - gpsData.lat = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LATITUDE}):value() - gpsData.lon = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LONGITUDE}):value() + local latSrc = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LATITUDE}) + local lonSrc = system.getSource({name=status.conf.gpsSource:name(),options=OPTION_LONGITUDE}) + if latSrc ~= nil and lonSrc ~= nil then + gpsData.lat = latSrc:value() + gpsData.lon = lonSrc:value() + end end if gpsData.lat ~= nil and gpsData.lon ~= nil then