-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Outputs a string representing the actual flight mode
- Loading branch information
1 parent
60d8a5f
commit 34a29cd
Showing
1 changed file
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--[[ ** TELEMETRY SCREEN WIDGET ** | ||
Outputs a string representing the actual flight mode. | ||
NOTE: This is a wrapper function using valueWidget() [WIDGETS/value.lua]. | ||
Define source and flightmodes below. | ||
PLATFORM | ||
X7, X9 and relatives | ||
SCALING | ||
vert: scalable | ||
horiz: scalable | ||
PARAMETER | ||
zone: table [x, y, w, h] | ||
- Location on display in px | ||
(x-pos, y-pos, width, height) | ||
event: int | ||
- User event | ||
opts: table | ||
- Configurations | ||
src: function or sensor-ID string/number | ||
- Data source | ||
lbl: string (optional) | ||
- Label text | ||
style: int (optional, default 0) | ||
- Text Attributes: 0, DBLSIZE, MIDSIZE, SMLSIZE, INVERS, BLINK, XXLSIZE, LEFT | ||
All att values can be combined together using the + character. ie BLINK + DBLSIZE | ||
p: table (optional, default [t=0, r=2, b=0, l=0]) | ||
- Padding between content and widget boundaries in px | ||
(top, right, bottom, left) | ||
--]] | ||
|
||
local valueWidget = assert(loadScript("/SCRIPTS/WIDGETS/value.lua"))() | ||
|
||
local function flightModeWidget(zone, event, opts) | ||
local _opts = {} | ||
|
||
for i, opt in pairs(opts) do | ||
_opts[i] = opt | ||
end | ||
|
||
local val = getValue("ch5") -- switchname, global variable or other source | ||
|
||
_opts.src = function() -- returns the string | ||
if val < -512 then | ||
return "Turtle" | ||
elseif val > -100 and val < 100 then | ||
return "Acro" | ||
elseif val > 512 then | ||
return "Horizon" | ||
end | ||
return "?" | ||
end | ||
|
||
valueWidget.run(zone, event, _opts) | ||
end | ||
|
||
return { run=flightModeWidget } |