Taranis Wizard: Ailerons configuration page added
This commit is contained in:
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
+143
-47
@@ -1,18 +1,42 @@
|
||||
|
||||
-- Wizard states
|
||||
local TEMPLATE_CHOICE_INIT = 0
|
||||
local TEMPLATE_CHOICE_RUN = 1
|
||||
local TEMPLATE_NEXT = 2
|
||||
-- Wizard pages
|
||||
local MODELTYPE_MENU = 0
|
||||
local PLANE_MENU = MODELTYPE_MENU+1
|
||||
local HELI_MENU = PLANE_MENU+10
|
||||
local DELTA_MENU = HELI_MENU+10
|
||||
local QUADRI_MENU = DELTA_MENU+10
|
||||
|
||||
local state = TEMPLATE_CHOICE_INIT
|
||||
local AILERONS_MENU = PLANE_MENU
|
||||
|
||||
local page = MODELTYPE_MENU
|
||||
local dirty = true
|
||||
local choice = 0
|
||||
|
||||
local edit = false
|
||||
local field = 0
|
||||
local fieldsMax = 0
|
||||
local aileronsMode = 0
|
||||
local aileronsCH1 = 0
|
||||
local aileronsCH2 = 4
|
||||
|
||||
local function init()
|
||||
for stick = 0, 4, 1 do
|
||||
local index = channelOrder(stick);
|
||||
if index == 0 then
|
||||
elseif index == 1 then
|
||||
elseif index == 2 then
|
||||
else
|
||||
aileronsCH1 = stick
|
||||
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 drawTemplateChoice()
|
||||
local function drawModelChoiceMenu()
|
||||
lcd.clear()
|
||||
lcd.drawScreenTitle("", 0, 0)
|
||||
-- lcd.drawText(58, 13, "Select model type", 0)
|
||||
@@ -23,60 +47,132 @@ local function drawTemplateChoice()
|
||||
choiceSurround(choice)
|
||||
end
|
||||
|
||||
local function templateChoiceRun(event)
|
||||
nextchoice = choice
|
||||
local function keyIncDec(event, value, max, isvalue)
|
||||
if isvalue then
|
||||
if event == EVT_PLUS_BREAK then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_BREAK then
|
||||
if value > 0 then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
end
|
||||
end
|
||||
else
|
||||
if event == EVT_PLUS_BREAK then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
value = (value % (max+1))
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
local function modelTypeMenu(event)
|
||||
if dirty == true then
|
||||
drawModelChoiceMenu()
|
||||
dirty = false
|
||||
end
|
||||
if event == EVT_ENTER_BREAK then
|
||||
state = 2
|
||||
elseif event == EVT_PLUS_BREAK then
|
||||
nextchoice = (nextchoice + 1)
|
||||
elseif event == EVT_MINUS_BREAK then
|
||||
nextchoice = (nextchoice + 3)
|
||||
end
|
||||
nextchoice = nextchoice % 4
|
||||
if nextchoice ~= choice then
|
||||
choice = nextchoice
|
||||
drawTemplateChoice()
|
||||
page = PLANE_MENU+(10*choice)
|
||||
dirty = true
|
||||
else
|
||||
choice = keyIncDec(event, choice, 3)
|
||||
end
|
||||
end
|
||||
|
||||
local function drawWing(x, y)
|
||||
lcd.drawLine(x+1, y+1, x+54, y)
|
||||
lcd.drawLine(x+1, y, x+1, y+16)
|
||||
lcd.drawLine(x, y+17, x+54, y+27)
|
||||
lcd.drawLine(x+1, y+11, x+33, y+17)
|
||||
lcd.drawLine(x+34, y+16, x+34, y+22)
|
||||
MIRROR = 128
|
||||
lcd.drawRectangle(x+55, y-8, 15, 39)
|
||||
lcd.drawLine(x+MIRROR-5, y+1, x+MIRROR-58, y)
|
||||
lcd.drawLine(x+MIRROR-5, y, x+MIRROR-5, y+16)
|
||||
lcd.drawLine(x+MIRROR-4, y+17, x+MIRROR-58, y+27)
|
||||
lcd.drawLine(x+MIRROR-5, y+11, x+MIRROR-37, y+17)
|
||||
lcd.drawLine(x+MIRROR-38, y+16, x+MIRROR-38, y+22)
|
||||
local function getFieldFlags(position)
|
||||
flags = 0
|
||||
if field == position then
|
||||
flags = INVERS
|
||||
if edit then
|
||||
flags = INVERS + BLINK
|
||||
end
|
||||
end
|
||||
return flags
|
||||
end
|
||||
|
||||
local lastBlink = 0
|
||||
local function blinkChanged()
|
||||
local time = getTime() % 128
|
||||
local blink = (time - time % 64) / 64
|
||||
if blink ~= lastBlink then
|
||||
lastBlink = blink
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local aileronsModeItems = {"Yes...", "No...", "Yes, 2 channels..."}
|
||||
|
||||
local function drawAileronsMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Has your model got ailerons?", 0)
|
||||
lcd.drawRect(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, aileronsModeItems, aileronsMode, getFieldFlags(0))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H, DOTTED, 0)
|
||||
if aileronsMode == 2 then
|
||||
-- 2 channels
|
||||
lcd.drawPixmap(112, 8, "/TEMPLATES/ailerons-2.bmp")
|
||||
lcd.drawText(20, LCD_H-16, "Assign channels", 0);
|
||||
lcd.drawText(LCD_W/2-19, LCD_H-8, ">>>", 0);
|
||||
lcd.drawText(116, LCD_H-8, "CH" .. (aileronsCH1+1), getFieldFlags(1))
|
||||
lcd.drawText(175, LCD_H-8, "CH" .. (aileronsCH2+1), getFieldFlags(2))
|
||||
fieldsMax = 2
|
||||
elseif aileronsMode == 1 then
|
||||
-- No ailerons
|
||||
lcd.drawPixmap(112, 8, "/TEMPLATES/ailerons-0.bmp")
|
||||
fieldsMax = 0
|
||||
else
|
||||
-- 1 channel
|
||||
lcd.drawPixmap(112, 8, "/TEMPLATES/ailerons-1.bmp")
|
||||
lcd.drawText(25, LCD_H-16, "Assign channel", 0);
|
||||
lcd.drawText(LCD_W/2-19, LCD_H-8, ">>>", 0);
|
||||
lcd.drawText(151, LCD_H-8, "CH" .. (aileronsCH1+1), getFieldFlags(1))
|
||||
fieldsMax = 1
|
||||
end
|
||||
end
|
||||
|
||||
local function aileronsMenu(event)
|
||||
if not dirty then
|
||||
dirty = blinkChanged()
|
||||
end
|
||||
if dirty then
|
||||
dirty = false
|
||||
drawAileronsMenu()
|
||||
end
|
||||
if event == EVT_ENTER_BREAK then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
end
|
||||
if edit == false then
|
||||
field = keyIncDec(event, field, fieldsMax)
|
||||
elseif field == 0 then
|
||||
aileronsMode = keyIncDec(event, aileronsMode, 2)
|
||||
elseif field == 1 then
|
||||
aileronsCH1 = keyIncDec(event, aileronsCH1, 7, true)
|
||||
elseif field == 2 then
|
||||
aileronsCH2 = keyIncDec(event, aileronsCH2, 7, true)
|
||||
end
|
||||
end
|
||||
|
||||
local function run(event)
|
||||
if event == EVT_EXIT_BREAK then
|
||||
return 2
|
||||
end
|
||||
lcd.lock()
|
||||
if state == TEMPLATE_CHOICE_INIT then
|
||||
drawTemplateChoice()
|
||||
state = TEMPLATE_CHOICE_RUN
|
||||
elseif state == TEMPLATE_CHOICE_RUN then
|
||||
templateChoiceRun(event)
|
||||
elseif state == 2 then
|
||||
state = 3
|
||||
lcd.clear()
|
||||
lcd.drawText(68, 13, "Wing config", 0)
|
||||
lcd.drawScreenTitle("MODEL SETUP WIZARD", 2, 3)
|
||||
drawWing(2, 33)
|
||||
lcd.drawText(140, 30, "Ail", 0)
|
||||
lcd.drawText(175, 30, "50%", INVERS)
|
||||
lcd.drawText(140, 42, "Flp", 0)
|
||||
lcd.drawText(175, 42, "30%", 0)
|
||||
if page == MODELTYPE_MENU then
|
||||
modelTypeMenu(event)
|
||||
elseif page == AILERONS_MENU then
|
||||
aileronsMenu(event)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
return { run=run }
|
||||
return { init=init, run=run }
|
||||
|
||||
Reference in New Issue
Block a user