Lua Wizard simplification. Engine paged added.
This commit is contained in:
+9
-1
@@ -63,7 +63,7 @@ ScriptInternalData standaloneScript = { SCRIPT_NOFILE, 0 };
|
|||||||
|
|
||||||
#define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (1000/100)
|
#define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (1000/100)
|
||||||
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (10000/100)
|
#define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (10000/100)
|
||||||
#define SCRIPTS_MAX_HEAP 50
|
#define SCRIPTS_MAX_HEAP 100
|
||||||
#define SET_LUA_INSTRUCTIONS_COUNT(x) (instructionsPercent=0, lua_sethook(L, hook, LUA_MASKCOUNT, x))
|
#define SET_LUA_INSTRUCTIONS_COUNT(x) (instructionsPercent=0, lua_sethook(L, hook, LUA_MASKCOUNT, x))
|
||||||
|
|
||||||
static int instructionsPercent = 0;
|
static int instructionsPercent = 0;
|
||||||
@@ -193,6 +193,12 @@ static int luaPlayNumber(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int luaKillEvents(lua_State *L)
|
||||||
|
{
|
||||||
|
int event = luaL_checkinteger(L, 1);
|
||||||
|
killEvents(event);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int luaLcdLock(lua_State *L)
|
static int luaLcdLock(lua_State *L)
|
||||||
{
|
{
|
||||||
@@ -993,6 +999,7 @@ void luaInit()
|
|||||||
lua_register(L, "playNumber", luaPlayNumber);
|
lua_register(L, "playNumber", luaPlayNumber);
|
||||||
lua_register(L, "popupInput", luaPopupInput);
|
lua_register(L, "popupInput", luaPopupInput);
|
||||||
lua_register(L, "channelOrder", luaChannelOrder);
|
lua_register(L, "channelOrder", luaChannelOrder);
|
||||||
|
lua_register(L, "killEvents", luaKillEvents);
|
||||||
|
|
||||||
// Push OpenTX constants
|
// Push OpenTX constants
|
||||||
lua_registerint(L, "FULLSCALE", RESX);
|
lua_registerint(L, "FULLSCALE", RESX);
|
||||||
@@ -1012,6 +1019,7 @@ void luaInit()
|
|||||||
lua_registerint(L, "SOURCE_FIRST_CH", MIXSRC_FIRST_CH);
|
lua_registerint(L, "SOURCE_FIRST_CH", MIXSRC_FIRST_CH);
|
||||||
lua_registerint(L, "EVT_MENU_BREAK", EVT_KEY_BREAK(KEY_MENU));
|
lua_registerint(L, "EVT_MENU_BREAK", EVT_KEY_BREAK(KEY_MENU));
|
||||||
lua_registerint(L, "EVT_PAGE_BREAK", EVT_KEY_BREAK(KEY_PAGE));
|
lua_registerint(L, "EVT_PAGE_BREAK", EVT_KEY_BREAK(KEY_PAGE));
|
||||||
|
lua_registerint(L, "EVT_PAGE_LONG", EVT_KEY_LONG(KEY_PAGE));
|
||||||
lua_registerint(L, "EVT_ENTER_BREAK", EVT_KEY_BREAK(KEY_ENTER));
|
lua_registerint(L, "EVT_ENTER_BREAK", EVT_KEY_BREAK(KEY_ENTER));
|
||||||
lua_registerint(L, "EVT_EXIT_BREAK", EVT_KEY_BREAK(KEY_EXIT));
|
lua_registerint(L, "EVT_EXIT_BREAK", EVT_KEY_BREAK(KEY_EXIT));
|
||||||
lua_registerint(L, "EVT_PLUS_BREAK", EVT_KEY_BREAK(KEY_PLUS));
|
lua_registerint(L, "EVT_PLUS_BREAK", EVT_KEY_BREAK(KEY_PLUS));
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
+134
-58
@@ -6,7 +6,8 @@ local HELI_MENU = PLANE_MENU+10
|
|||||||
local DELTA_MENU = HELI_MENU+10
|
local DELTA_MENU = HELI_MENU+10
|
||||||
local QUADRI_MENU = DELTA_MENU+10
|
local QUADRI_MENU = DELTA_MENU+10
|
||||||
|
|
||||||
local AILERONS_MENU = PLANE_MENU
|
local ENGINE_MENU = PLANE_MENU
|
||||||
|
local AILERONS_MENU = PLANE_MENU+1
|
||||||
|
|
||||||
local page = MODELTYPE_MENU
|
local page = MODELTYPE_MENU
|
||||||
local dirty = true
|
local dirty = true
|
||||||
@@ -15,38 +16,26 @@ local choice = 0
|
|||||||
local edit = false
|
local edit = false
|
||||||
local field = 0
|
local field = 0
|
||||||
local fieldsMax = 0
|
local fieldsMax = 0
|
||||||
|
local engineMode = 0
|
||||||
|
local engineCH1 = 0
|
||||||
local aileronsMode = 0
|
local aileronsMode = 0
|
||||||
local aileronsCH1 = 0
|
local aileronsCH1 = 0
|
||||||
local aileronsCH2 = 4
|
local aileronsCH2 = 4
|
||||||
|
|
||||||
local function init()
|
-- Common functions
|
||||||
for stick = 0, 4, 1 do
|
|
||||||
local index = channelOrder(stick);
|
local lastBlink = 0
|
||||||
if index == 0 then
|
local function blinkChanged()
|
||||||
elseif index == 1 then
|
local time = getTime() % 128
|
||||||
elseif index == 2 then
|
local blink = (time - time % 64) / 64
|
||||||
else
|
if blink ~= lastBlink then
|
||||||
aileronsCH1 = stick
|
lastBlink = blink
|
||||||
end
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function choiceSurround(index)
|
|
||||||
lcd.drawRectangle(12+47*index, 13, 48, 48)
|
|
||||||
lcd.drawPixmap(17+47*index, 8, "/TEMPLATES/mark.bmp")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function drawModelChoiceMenu()
|
|
||||||
lcd.clear()
|
|
||||||
lcd.drawScreenTitle("", 0, 0)
|
|
||||||
-- lcd.drawText(58, 13, "Select model type", 0)
|
|
||||||
lcd.drawPixmap( 16, 17, "/TEMPLATES/plane.bmp")
|
|
||||||
lcd.drawPixmap( 63, 17, "/TEMPLATES/heli.bmp")
|
|
||||||
lcd.drawPixmap(110, 17, "/TEMPLATES/delta.bmp")
|
|
||||||
lcd.drawPixmap(157, 17, "/TEMPLATES/quadri.bmp")
|
|
||||||
choiceSurround(choice)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function keyIncDec(event, value, max, isvalue)
|
local function keyIncDec(event, value, max, isvalue)
|
||||||
if isvalue then
|
if isvalue then
|
||||||
if event == EVT_PLUS_BREAK then
|
if event == EVT_PLUS_BREAK then
|
||||||
@@ -73,16 +62,26 @@ local function keyIncDec(event, value, max, isvalue)
|
|||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
local function modelTypeMenu(event)
|
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||||
if dirty == true then
|
|
||||||
drawModelChoiceMenu()
|
|
||||||
dirty = false
|
|
||||||
end
|
|
||||||
if event == EVT_ENTER_BREAK then
|
if event == EVT_ENTER_BREAK then
|
||||||
page = PLANE_MENU+(10*choice)
|
edit = not edit
|
||||||
dirty = true
|
dirty = true
|
||||||
|
end
|
||||||
|
if edit then
|
||||||
|
if not dirty then
|
||||||
|
dirty = blinkChanged()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
choice = keyIncDec(event, choice, 3)
|
if event == EVT_PAGE_BREAK then
|
||||||
|
page = nextPage
|
||||||
|
dirty = true
|
||||||
|
elseif event == EVT_PAGE_LONG then
|
||||||
|
page = prevPage
|
||||||
|
killEvents(event);
|
||||||
|
dirty = true
|
||||||
|
else
|
||||||
|
field = keyIncDec(event, field, fieldMax)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -97,19 +96,96 @@ local function getFieldFlags(position)
|
|||||||
return flags
|
return flags
|
||||||
end
|
end
|
||||||
|
|
||||||
local lastBlink = 0
|
-- Init function
|
||||||
local function blinkChanged()
|
|
||||||
local time = getTime() % 128
|
local function init()
|
||||||
local blink = (time - time % 64) / 64
|
for stick = 0, 4, 1 do
|
||||||
if blink ~= lastBlink then
|
local index = channelOrder(stick);
|
||||||
lastBlink = blink
|
if index == 0 then
|
||||||
return true
|
elseif index == 1 then
|
||||||
else
|
elseif index == 2 then
|
||||||
return false
|
engineCH1 = stick
|
||||||
|
else
|
||||||
|
aileronsCH1 = stick
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local aileronsModeItems = {"Yes...", "No...", "Yes, 2 channels..."}
|
-- Model Type Menu
|
||||||
|
|
||||||
|
local function choiceSurround(index)
|
||||||
|
lcd.drawRectangle(12+47*index, 13, 48, 48)
|
||||||
|
lcd.drawPixmap(17+47*index, 8, "/TEMPLATES/mark.bmp")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function drawModelChoiceMenu()
|
||||||
|
lcd.clear()
|
||||||
|
lcd.drawScreenTitle("", 0, 0)
|
||||||
|
-- lcd.drawText(58, 13, "Select model type", 0)
|
||||||
|
lcd.drawPixmap( 16, 17, "/TEMPLATES/plane.bmp")
|
||||||
|
lcd.drawPixmap( 63, 17, "/TEMPLATES/heli.bmp")
|
||||||
|
lcd.drawPixmap(110, 17, "/TEMPLATES/delta.bmp")
|
||||||
|
lcd.drawPixmap(157, 17, "/TEMPLATES/quadri.bmp")
|
||||||
|
choiceSurround(choice)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function modelTypeMenu(event)
|
||||||
|
if dirty == true then
|
||||||
|
drawModelChoiceMenu()
|
||||||
|
dirty = false
|
||||||
|
end
|
||||||
|
if event == EVT_ENTER_BREAK then
|
||||||
|
page = PLANE_MENU+(10*choice)
|
||||||
|
dirty = true
|
||||||
|
else
|
||||||
|
choice = keyIncDec(event, choice, 3)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Engine Menu
|
||||||
|
|
||||||
|
local engineModeItems = {"Yes...", "No"}
|
||||||
|
|
||||||
|
local function drawEngineMenu()
|
||||||
|
lcd.clear()
|
||||||
|
lcd.drawText(1, 0, "Has your model got an engine?", 0)
|
||||||
|
lcd.drawRect(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||||
|
lcd.drawCombobox(0, 8, LCD_W/2, engineModeItems, engineMode, getFieldFlags(0))
|
||||||
|
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H, DOTTED, 0)
|
||||||
|
if engineMode == 1 then
|
||||||
|
-- No engine
|
||||||
|
lcd.drawPixmap(132, 8, "/TEMPLATES/engine-0.bmp")
|
||||||
|
fieldsMax = 0
|
||||||
|
else
|
||||||
|
-- 1 channel
|
||||||
|
lcd.drawPixmap(132, 8, "/TEMPLATES/engine-1.bmp")
|
||||||
|
lcd.drawText(25, LCD_H-16, "Assign channel", 0);
|
||||||
|
lcd.drawText(LCD_W/2-19, LCD_H-8, ">>>", 0);
|
||||||
|
lcd.drawSource(151, LCD_H-8, SOURCE_FIRST_CH+engineCH1, getFieldFlags(1))
|
||||||
|
fieldsMax = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function engineMenu(event)
|
||||||
|
if dirty then
|
||||||
|
dirty = false
|
||||||
|
drawEngineMenu()
|
||||||
|
end
|
||||||
|
|
||||||
|
navigate(event, fieldsMax, MODELTYPE_MENU, page+1)
|
||||||
|
|
||||||
|
if edit then
|
||||||
|
if field==0 then
|
||||||
|
engineMode = keyIncDec(event, engineMode, 1)
|
||||||
|
elseif field==1 then
|
||||||
|
engineCH1 = keyIncDec(event, engineCH1, 7, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Ailerons Menu
|
||||||
|
|
||||||
|
local aileronsModeItems = {"Yes...", "No", "Yes, 2 channels..."}
|
||||||
|
|
||||||
local function drawAileronsMenu()
|
local function drawAileronsMenu()
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
@@ -140,28 +216,26 @@ local function drawAileronsMenu()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function aileronsMenu(event)
|
local function aileronsMenu(event)
|
||||||
if not dirty then
|
|
||||||
dirty = blinkChanged()
|
|
||||||
end
|
|
||||||
if dirty then
|
if dirty then
|
||||||
dirty = false
|
dirty = false
|
||||||
drawAileronsMenu()
|
drawAileronsMenu()
|
||||||
end
|
end
|
||||||
if event == EVT_ENTER_BREAK then
|
|
||||||
edit = not edit
|
navigate(event, fieldsMax, page-1, page+1)
|
||||||
dirty = true
|
|
||||||
end
|
if edit then
|
||||||
if edit == false then
|
if field==0 then
|
||||||
field = keyIncDec(event, field, fieldsMax)
|
aileronsMode = keyIncDec(event, aileronsMode, 2)
|
||||||
elseif field == 0 then
|
elseif field==1 then
|
||||||
aileronsMode = keyIncDec(event, aileronsMode, 2)
|
aileronsCH1 = keyIncDec(event, aileronsCH1, 7, true)
|
||||||
elseif field == 1 then
|
elseif field==2 then
|
||||||
aileronsCH1 = keyIncDec(event, aileronsCH1, 7, true)
|
aileronsCH2 = keyIncDec(event, aileronsCH2, 7, true)
|
||||||
elseif field == 2 then
|
end
|
||||||
aileronsCH2 = keyIncDec(event, aileronsCH2, 7, true)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Main
|
||||||
|
|
||||||
local function run(event)
|
local function run(event)
|
||||||
if event == EVT_EXIT_BREAK then
|
if event == EVT_EXIT_BREAK then
|
||||||
return 2
|
return 2
|
||||||
@@ -169,6 +243,8 @@ local function run(event)
|
|||||||
lcd.lock()
|
lcd.lock()
|
||||||
if page == MODELTYPE_MENU then
|
if page == MODELTYPE_MENU then
|
||||||
modelTypeMenu(event)
|
modelTypeMenu(event)
|
||||||
|
elseif page == ENGINE_MENU then
|
||||||
|
engineMenu(event)
|
||||||
elseif page == AILERONS_MENU then
|
elseif page == AILERONS_MENU then
|
||||||
aileronsMenu(event)
|
aileronsMenu(event)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user