diff --git a/.DS_Store b/.DS_Store index 8005be6..5c8f5ac 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/english/dev-environment/.DS_Store b/english/dev-environment/.DS_Store index f8031de..6947c54 100644 Binary files a/english/dev-environment/.DS_Store and b/english/dev-environment/.DS_Store differ diff --git a/english/dev-environment/manual/macro_support/modellua.sh b/english/dev-environment/manual/macro_support/modellua.sh new file mode 100644 index 0000000..bd6cbdd --- /dev/null +++ b/english/dev-environment/manual/macro_support/modellua.sh @@ -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' diff --git a/english/dev-environment/manual/macro_support/scripts/lua task example/main.lua b/english/dev-environment/manual/macro_support/scripts/lua task example/main.lua new file mode 100644 index 0000000..c730dc3 --- /dev/null +++ b/english/dev-environment/manual/macro_support/scripts/lua task example/main.lua @@ -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} diff --git a/english/dev-environment/manual/macro_support/scripts/source example/main.lua b/english/dev-environment/manual/macro_support/scripts/source example/main.lua new file mode 100644 index 0000000..1131b1b --- /dev/null +++ b/english/dev-environment/manual/macro_support/scripts/source example/main.lua @@ -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} diff --git a/english/dev-environment/manual/modellua.sh b/english/dev-environment/manual/modellua.sh index a219f08..bd6cbdd 100644 --- a/english/dev-environment/manual/modellua.sh +++ b/english/dev-environment/manual/modellua.sh @@ -2,5 +2,10 @@ 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'