XLite support (#5806)
This commit is contained in:
@@ -52,10 +52,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_ROT_RIGHT then
|
||||
if event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -66,12 +66,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_ROT_RIGHT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_ROT_RIGHT or event == EVT_RIGHT_BREAK then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_LEFT_BREAK then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -88,16 +88,16 @@ local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
edit = false
|
||||
dirty = true
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
dirty = blinkChanged()
|
||||
end
|
||||
else
|
||||
if event == EVT_PAGE_BREAK then
|
||||
if event == EVT_PAGE_BREAK or event==EVT_SHIFT_BREAK then
|
||||
page = nextPage
|
||||
field = 0
|
||||
dirty = true
|
||||
elseif event == EVT_PAGE_LONG then
|
||||
elseif event == EVT_PAGE_LONG or event==EVT_SHIFT_LONG then
|
||||
page = prevPage
|
||||
field = 0
|
||||
killEvents(event);
|
||||
@@ -140,7 +140,7 @@ end
|
||||
-- Engine Menu
|
||||
local engineModeItems = {"No", "Yes"}
|
||||
local function drawEngineMenu()
|
||||
lcd.clear()
|
||||
lcd.clear()
|
||||
if engineMode == 0 then
|
||||
-- No engine
|
||||
fieldsMax = 0
|
||||
@@ -177,7 +177,7 @@ local function drawElevonsMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Select elevon channnels", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, elevonsModeItems, elevonsMode, 0)
|
||||
lcd.drawCombobox(0, 8, LCD_W, elevonsModeItems, elevonsMode, 0)
|
||||
lcd.drawText(5, 30, "Assign channels", 0);
|
||||
lcd.drawText(30, 40, "L", 0);
|
||||
lcd.drawText(65, 40, "R", 0);
|
||||
@@ -219,7 +219,7 @@ local function drawRudderMenu()
|
||||
end
|
||||
lcd.drawText(1, 0, "Got a rudder?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, rudderModeItems, rudderMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W, rudderModeItems, rudderMode, getFieldFlags(0))
|
||||
end
|
||||
|
||||
local function rudderMenu(event)
|
||||
@@ -227,7 +227,7 @@ local function rudderMenu(event)
|
||||
dirty = false
|
||||
drawRudderMenu()
|
||||
end
|
||||
|
||||
|
||||
navigate(event, fieldsMax, page-1, page+1)
|
||||
|
||||
if field==0 then
|
||||
@@ -252,7 +252,7 @@ local function drawServoMenu(limits)
|
||||
else
|
||||
lcd.drawText(129, 50, "\127", getFieldFlags(3));
|
||||
end
|
||||
fieldsMax = 3
|
||||
fieldsMax = 3
|
||||
end
|
||||
|
||||
local function servoMenu(event)
|
||||
@@ -288,7 +288,7 @@ local function addMix(channel, input, name, weight, index)
|
||||
if weight ~= nil then
|
||||
mix.weight = weight
|
||||
end
|
||||
if index == nil then
|
||||
if index == nil then
|
||||
index = 0
|
||||
end
|
||||
model.insertMix(channel, index, mix)
|
||||
@@ -296,7 +296,7 @@ end
|
||||
|
||||
local function applySettings()
|
||||
model.defaultInputs()
|
||||
model.deleteMixes()
|
||||
model.deleteMixes()
|
||||
if engineMode == 1 then
|
||||
addMix(thrCH1, MIXSRC_FIRST_INPUT+defaultChannel(2), "Engine")
|
||||
end
|
||||
@@ -346,7 +346,7 @@ local function confirmationMenu(event)
|
||||
end
|
||||
|
||||
navigate(event, fieldsMax, RUDDER_PAGE, page)
|
||||
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
@@ -366,7 +366,7 @@ local function run(event)
|
||||
end
|
||||
|
||||
if servoPage ~= nil then
|
||||
servoMenu(event)
|
||||
servoMenu(event)
|
||||
elseif page == ENGINE_PAGE then
|
||||
engineMenu(event)
|
||||
elseif page == ELEVONS_PAGE then
|
||||
|
||||
@@ -50,10 +50,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_ROT_RIGHT then
|
||||
if event == EVT_ROT_RIGHT or event == EVT_UP_BREAK then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_DOWN_BREAK then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -64,12 +64,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_ROT_RIGHT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_ROT_RIGHT or event == EVT_RIGHT_BREAK then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_LEFT_BREAK then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -86,16 +86,16 @@ local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
edit = false
|
||||
dirty = true
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
dirty = blinkChanged()
|
||||
end
|
||||
else
|
||||
if event == EVT_PAGE_BREAK then
|
||||
if event == EVT_PAGE_BREAK or event==EVT_SHIFT_BREAK then
|
||||
page = nextPage
|
||||
field = 0
|
||||
dirty = true
|
||||
elseif event == EVT_PAGE_LONG then
|
||||
elseif event == EVT_PAGE_LONG or event==EVT_SHIFT_LONG then
|
||||
page = prevPage
|
||||
field = 0
|
||||
killEvents(event);
|
||||
@@ -140,7 +140,7 @@ local function drawThrottleMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Multicopter", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, {"Throttle"}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawCombobox(0, 8, LCD_W, {"Throttle"}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawText(5, 30, "Assign channel", 0);
|
||||
lcd.drawText(5, 40, ">>>", 0);
|
||||
lcd.drawSource(25, 40, MIXSRC_CH1+thrCH1, getFieldFlags(0))
|
||||
@@ -161,7 +161,7 @@ local function drawRollMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Multicopter", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, {"Roll"}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawCombobox(0, 8, LCD_W, {"Roll"}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawText(5, 30, "Assign channel", 0);
|
||||
lcd.drawText(5, 40, ">>>", 0);
|
||||
lcd.drawSource(25, 40, MIXSRC_CH1+rollCH1, getFieldFlags(0))
|
||||
@@ -182,7 +182,7 @@ local function drawPitchMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Multicopter", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, {"Pitch"}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawCombobox(0, 8, LCD_W, {"Pitch"}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawText(5, 30, "Assign channel", 0);
|
||||
lcd.drawText(5, 40, ">>>", 0);
|
||||
lcd.drawSource(25, 40, MIXSRC_CH1+pitchCH1, getFieldFlags(0))
|
||||
@@ -203,7 +203,7 @@ local function drawYawMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Multicopter", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, {"Yaw"}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawCombobox(0, 8, LCD_W, {"Yaw"}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawText(5, 30, "Assign channel", 0);
|
||||
lcd.drawText(5, 40, ">>>", 0);
|
||||
lcd.drawSource(25, 40, MIXSRC_CH1+yawCH1, getFieldFlags(0))
|
||||
@@ -251,7 +251,7 @@ local function addMix(channel, input, name, weight, index)
|
||||
if weight ~= nil then
|
||||
mix.weight = weight
|
||||
end
|
||||
if index == nil then
|
||||
if index == nil then
|
||||
index = 0
|
||||
end
|
||||
model.insertMix(channel, index, mix)
|
||||
@@ -259,7 +259,7 @@ end
|
||||
|
||||
local function applySettings()
|
||||
model.defaultInputs()
|
||||
model.deleteMixes()
|
||||
model.deleteMixes()
|
||||
addMix(thrCH1, MIXSRC_FIRST_INPUT+defaultChannel(2), "Engine")
|
||||
addMix(rollCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "Roll")
|
||||
addMix(yawCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "Yaw")
|
||||
|
||||
@@ -62,10 +62,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_ROT_LEFT then
|
||||
if event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -76,12 +76,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_ROT_LEFT or event == EVT_ROT_LEFT then
|
||||
if event == EVT_ROT_RIGHT or event == EVT_RIGHT_BREAK then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_ROT_RIGHT or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_LEFT_BREAK then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -98,16 +98,16 @@ local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
edit = false
|
||||
dirty = true
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
dirty = blinkChanged()
|
||||
end
|
||||
else
|
||||
if event == EVT_PAGE_BREAK then
|
||||
if event == EVT_PAGE_BREAK or event==EVT_SHIFT_BREAK then
|
||||
page = nextPage
|
||||
field = 0
|
||||
dirty = true
|
||||
elseif event == EVT_PAGE_LONG then
|
||||
elseif event == EVT_PAGE_LONG or event==EVT_SHIFT_LONG then
|
||||
page = prevPage
|
||||
field = 0
|
||||
killEvents(event);
|
||||
@@ -163,7 +163,7 @@ local function drawEngineMenu()
|
||||
end
|
||||
lcd.drawText(1, 0, "Got an engine?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, engineModeItems, engineMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W, engineModeItems, engineMode, getFieldFlags(0))
|
||||
end
|
||||
|
||||
local function engineMenu(event)
|
||||
@@ -206,7 +206,7 @@ local function drawAileronsMenu()
|
||||
end
|
||||
lcd.drawText(1, 0, "Got ailerons?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, aileronsModeItems, aileronsMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W, aileronsModeItems, aileronsMode, getFieldFlags(0))
|
||||
end
|
||||
|
||||
local function aileronsMenu(event)
|
||||
@@ -251,7 +251,7 @@ local function drawFlapsMenu()
|
||||
end
|
||||
lcd.drawText(1, 0, "Got flaps?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, flapsModeItems, flapsMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W, flapsModeItems, flapsMode, getFieldFlags(0))
|
||||
end
|
||||
|
||||
local function flapsMenu(event)
|
||||
@@ -296,7 +296,7 @@ local function drawBrakesMenu()
|
||||
end
|
||||
lcd.drawText(1, 0, "Got air brakes?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, brakesModeItems, brakesMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W, brakesModeItems, brakesMode, getFieldFlags(0))
|
||||
end
|
||||
|
||||
local function brakesMenu(event)
|
||||
@@ -313,7 +313,7 @@ local function brakesMenu(event)
|
||||
brakesCH1 = channelIncDec(event, brakesCH1)
|
||||
elseif field==2 then
|
||||
brakesCH2 = channelIncDec(event, brakesCH2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Tail Menu
|
||||
@@ -358,7 +358,7 @@ local function drawTailMenu()
|
||||
end
|
||||
lcd.drawText(1, 0, "Tail config", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W, tailModeItems, tailMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W, tailModeItems, tailMode, getFieldFlags(0))
|
||||
end
|
||||
|
||||
local function tailMenu(event)
|
||||
@@ -377,7 +377,7 @@ local function tailMenu(event)
|
||||
rudCH1 = channelIncDec(event, rudCH1)
|
||||
elseif field==2 then
|
||||
eleCH2 = channelIncDec(event, eleCH2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Servo (limits) Menu
|
||||
@@ -396,7 +396,7 @@ local function drawServoMenu(limits)
|
||||
else
|
||||
lcd.drawText(129, 50, "\127", getFieldFlags(3));
|
||||
end
|
||||
fieldsMax = 3
|
||||
fieldsMax = 3
|
||||
end
|
||||
|
||||
local function servoMenu(event)
|
||||
@@ -487,7 +487,7 @@ local function addMix(channel, input, name, weight, index)
|
||||
if weight ~= nil then
|
||||
mix.weight = weight
|
||||
end
|
||||
if index == nil then
|
||||
if index == nil then
|
||||
index = 0
|
||||
end
|
||||
model.insertMix(channel, index, mix)
|
||||
@@ -495,7 +495,7 @@ end
|
||||
|
||||
local function applySettings()
|
||||
model.defaultInputs()
|
||||
model.deleteMixes()
|
||||
model.deleteMixes()
|
||||
if engineMode > 0 then
|
||||
addMix(thrCH1, MIXSRC_FIRST_INPUT+defaultChannel(2), "Engine")
|
||||
end
|
||||
@@ -561,7 +561,7 @@ local function run(event)
|
||||
end
|
||||
|
||||
if servoPage ~= nil then
|
||||
servoMenu(event)
|
||||
servoMenu(event)
|
||||
elseif page == ENGINE_PAGE then
|
||||
engineMenu(event)
|
||||
elseif page == AILERONS_PAGE then
|
||||
|
||||
@@ -25,10 +25,10 @@ local MODELTYPE_QUAD = 2
|
||||
|
||||
-- Common functions
|
||||
local function fieldIncDec(event, value, max)
|
||||
if event == EVT_ROT_LEFT then
|
||||
if event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -80,13 +80,13 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot be run as a model script!")
|
||||
end
|
||||
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
return 2
|
||||
end
|
||||
|
||||
|
||||
return modelTypeMenu(event)
|
||||
|
||||
return modelTypeMenu(event)
|
||||
end
|
||||
|
||||
return { run=run }
|
||||
|
||||
@@ -212,15 +212,15 @@ local function runFieldsPage(event)
|
||||
end
|
||||
end
|
||||
elseif edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT or event == EVT_RIGHT_BREAK then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT or event == EVT_LEFT_BREAK then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -262,9 +262,9 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot be run as a model script!")
|
||||
return 2
|
||||
elseif event == EVT_PAGE_BREAK then
|
||||
elseif event == EVT_PAGE_BREAK or event==EVT_SHIFT_BREAK then
|
||||
selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG then
|
||||
elseif event == EVT_PAGE_LONG or event==EVT_SHIFT_LONG then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
@@ -196,15 +196,15 @@ local function runFieldsPage(event)
|
||||
end
|
||||
end
|
||||
elseif edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT or event == EVT_DOWN_BREAK then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT or event == EVT_UP_BREAK then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT then
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -284,9 +284,9 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot be run as a model script!")
|
||||
return 2
|
||||
elseif event == EVT_PAGE_BREAK then
|
||||
elseif event == EVT_PAGE_BREAK or event==EVT_SHIFT_BREAK then
|
||||
selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG then
|
||||
elseif event == EVT_PAGE_LONG or event==EVT_SHIFT_LONG then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user