-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
widget(color): Add RotaryGauge widget (#63)
* new Rotary Gauge widget * Rotary Gauge widget: less ticks on small size * new Rotary Gauge widget * new Rotary Gauge widget * Rotary Gauge widget: fix error if no telemetry sensor exists * Rotary Gauge widget: show last values when battery disconnected from plane (with disconnected indication) * Rotary Gauge widget: perf improve (do not call getValue() with string) * Rotary Gauge widget: cosmetics * Rotary Gauge widget: show gauge data when telemetry disconnected add indication of "no telemetry data" * Rotary Gauge widget: fix typo * Rotary Gauge widget: fix error if no telemetry sensor exists * Rotary Gauge widget: show last values when battery disconnected from plane (with disconnected indication) * Rotary Gauge widget: perf improve (do not call getValue() with string) * Rotary Gauge widget: cosmetics * Rotary Gauge widget: show gauge data when telemetry disconnected add indication of "no telemetry data" * Rotary Gauge widget: fix typo * Rotary Gauge widget: additional telemetry sources Co-authored-by: Shmuely <offer.shmuely@cognyte.com>
- Loading branch information
1 parent
31446b2
commit ac15b88
Showing
3 changed files
with
162 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
local wgt_options_xx = ... | ||
|
||
local self = {} | ||
self.wgt_options_xx = wgt_options_xx | ||
self.tele_src_name = nil | ||
self.tele_src_id = nil | ||
|
||
self.periodic1 = {startTime = getTime(), sampleIntervalMili = sampleIntervalMili} | ||
|
||
-------------------------------------------------------------- | ||
local function log(s) | ||
--return; | ||
print("appValue2: " .. s) | ||
end | ||
-------------------------------------------------------------- | ||
|
||
----------------------------------------------------------------- | ||
local function periodicReset(t) | ||
t.startTime = getTime(); | ||
end | ||
|
||
local function periodicHasPassed(t) | ||
local elapsed = getTime() - t.startTime; | ||
local elapsedMili = elapsed * 10; | ||
if (elapsedMili < t.sampleIntervalMili) then | ||
return false; | ||
end | ||
return true; | ||
end | ||
|
||
local function periodicGetElapsedTime(t) | ||
local elapsed = getTime() - t.startTime; | ||
--log(string.format("elapsed: %d",elapsed)); | ||
local elapsedMili = elapsed * 10; | ||
--log(string.format("elapsedMili: %d",elapsedMili)); | ||
return elapsedMili; | ||
end | ||
|
||
-------------------------------------------------------------------------------------------------------- | ||
|
||
function self.isTelemetryAvailable() | ||
-- select telemetry source | ||
if not self.tele_src_id then | ||
log("select telemetry source") | ||
tele_src = getFieldInfo("RSSI") | ||
if not tele_src then tele_src = getFieldInfo("RxBt") end | ||
if not tele_src then tele_src = getFieldInfo("A1") end | ||
if not tele_src then tele_src = getFieldInfo("A2") end | ||
if not tele_src then tele_src = getFieldInfo("1RSS") end | ||
if not tele_src then tele_src = getFieldInfo("2RSS") end | ||
if not tele_src then tele_src = getFieldInfo("RQly") end | ||
|
||
if tele_src == nil then | ||
log("no telemetry sensor found") | ||
self.tele_src_id = nil | ||
self.tele_src_name = "---" | ||
tele_is_available = false | ||
return | ||
end | ||
end | ||
self.tele_src_id = tele_src.id | ||
self.tele_src_name = tele_src.name | ||
|
||
if self.tele_src_id == nil then | ||
return false | ||
end | ||
|
||
local rx_val = getValue(self.tele_src_id) | ||
if rx_val ~= 0 then | ||
return true | ||
end | ||
return false | ||
end | ||
-------------------------------------------------------------------------------------------------------- | ||
|
||
return self |