-
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.
- Loading branch information
Showing
6 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
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,11 @@ | ||
#!/bin/bash | ||
|
||
ETHOS='/mnt/c/Program Files (x86)/FrSky/Ethos' | ||
|
||
# These scripts only needed for this macro | ||
cp -r 'macro_support/scripts/lua task example' scripts | ||
cp -r 'macro_support/scripts/source example' scripts | ||
"${ETHOS}/X20S/simulator.exe" --read-only --no-audio --documents-directory ./sd/documents --radio-settings ./x20s-en.bin --sd-directory ./sd --flash-directory ./flash --exec ./macros/model-lua.lua | ||
# Remove the scripts again so the LUA icon only appears in this macro | ||
rm -r 'scripts/lua task example' | ||
rm -r 'scripts/source example' |
43 changes: 43 additions & 0 deletions
43
english/dev-environment/manual/macro_support/scripts/lua task example/main.lua
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,43 @@ | ||
-- Lua Task Example | ||
|
||
local taskMin = -100 | ||
local taskMax = 100 | ||
|
||
local function taskInit() | ||
print("Task init") | ||
end | ||
|
||
local function taskWakeup(task) | ||
-- print("Task wakeup") | ||
end | ||
|
||
local function taskEvent(task) | ||
print("Task event") | ||
end | ||
|
||
local function taskConfigure(task) | ||
print("Task configure") | ||
local line = form.addLine("Range") | ||
local slots = form.getFieldSlots(line, {0, "-", 0}) | ||
form.addNumberField(line, slots[1], -1024, 1024, function() return taskMin end, function(value) taskMin = value end) | ||
form.addStaticText(line, slots[2], "-") | ||
form.addNumberField(line, slots[3], -1024, 1024, function() return taskMax end, function(value) taskMax = value end) | ||
end | ||
|
||
local function taskRead(task) | ||
print("Task read") | ||
taskMin = storage.read("min") | ||
taskMax = storage.read("max") | ||
end | ||
|
||
local function taskWrite(task) | ||
print("Task write") | ||
storage.write("min", taskMin) | ||
storage.write("max", taskMax) | ||
end | ||
|
||
local function init() | ||
system.registerTask({key="LuaTask", name="Task Example", init=taskInit, wakeup=taskWakeup, event=taskEvent, configure=taskConfigure, read=taskRead, write=taskWrite}) | ||
end | ||
|
||
return {init=init} |
44 changes: 44 additions & 0 deletions
44
english/dev-environment/manual/macro_support/scripts/source example/main.lua
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,44 @@ | ||
-- Lua Source Example | ||
|
||
local translations = {en="Lua Source", fr="Source Lua"} | ||
|
||
local function sourceName(source) | ||
local locale = system.getLocale() | ||
return translations[locale] or translations["en"] | ||
end | ||
|
||
local function sourceInit(source) | ||
print("Source init") | ||
source:decimals(2) | ||
source:unit(UNIT_VOLT) | ||
source:value(0.0) | ||
end | ||
|
||
local function sourceReset(source) | ||
print("Source reset") | ||
source:value(0.0) | ||
end | ||
|
||
local function sourceRead(source) | ||
print("Source read") | ||
source:value(storage.read("Some Key")) | ||
end | ||
|
||
local function sourceWrite(source) | ||
print("Source write") | ||
storage.write("Some Key", source:value()) | ||
end | ||
|
||
local function sourceWakeup(source) | ||
-- print("Source wakeup") | ||
source:value(source:value() + 0.1) | ||
end | ||
|
||
local function sourceConfigure(source) | ||
end | ||
|
||
local function init() | ||
system.registerSource({key="Example", name=sourceName, init=sourceInit, reset=sourceReset, wakeup=sourceWakeup, configure=sourceConfigure, read=sourceRead, write=sourceWrite}) | ||
end | ||
|
||
return {init=init} |
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