Fix ROT encoder nav for wizards (#4105)
This commit is contained in:
@@ -36,10 +36,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK then
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -50,12 +50,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -72,12 +72,12 @@ 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 then
|
||||
page = nextPage
|
||||
field = 0
|
||||
dirty = true
|
||||
@@ -127,7 +127,7 @@ local function drawEngineMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Has your model got an engine?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, engineModeItems, engineMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, engineModeItems, engineMode, getFieldFlags(0))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
if engineMode == 0 then
|
||||
-- No engine
|
||||
@@ -164,8 +164,8 @@ local function drawElevonsMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Select elevon channnels", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, elevonsModeItems, elevonsMode, 0)
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, elevonsModeItems, elevonsMode, 0)
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
lcd.drawPixmap(110, 9, "elevons.bmp")
|
||||
lcd.drawText(20, LCD_H-16, "Assign channels", 0);
|
||||
lcd.drawText(LCD_W/2-19, LCD_H-8, ">>>", 0);
|
||||
@@ -196,7 +196,7 @@ local function drawRudderMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Has your model got a rudder?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, rudderModeItems, rudderMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, rudderModeItems, rudderMode, getFieldFlags(0))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
if rudderMode == 0 then
|
||||
-- No rudder
|
||||
@@ -217,7 +217,7 @@ local function rudderMenu(event)
|
||||
dirty = false
|
||||
drawRudderMenu()
|
||||
end
|
||||
|
||||
|
||||
navigate(event, fieldsMax, page-1, page+1)
|
||||
|
||||
if field==0 then
|
||||
@@ -244,7 +244,7 @@ local function drawServoMenu(limits)
|
||||
else
|
||||
lcd.drawText(129, 50, "\127", getFieldFlags(3));
|
||||
end
|
||||
fieldsMax = 3
|
||||
fieldsMax = 3
|
||||
end
|
||||
|
||||
local function servoMenu(event)
|
||||
@@ -280,7 +280,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)
|
||||
@@ -288,7 +288,7 @@ end
|
||||
|
||||
local function applySettings()
|
||||
model.defaultInputs()
|
||||
model.deleteMixes()
|
||||
model.deleteMixes()
|
||||
if engineMode == 1 then
|
||||
addMix(thrCH1, MIXSRC_FIRST_INPUT+defaultChannel(2), "Engine")
|
||||
end
|
||||
@@ -340,7 +340,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
|
||||
@@ -359,7 +359,7 @@ local function run(event)
|
||||
error("Cannot be run as a model script!")
|
||||
end
|
||||
if servoPage ~= nil then
|
||||
servoMenu(event)
|
||||
servoMenu(event)
|
||||
elseif page == ENGINE_PAGE then
|
||||
engineMenu(event)
|
||||
elseif page == ELEVONS_PAGE then
|
||||
|
||||
@@ -34,10 +34,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK then
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -48,12 +48,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -70,12 +70,12 @@ 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 then
|
||||
page = nextPage
|
||||
field = 0
|
||||
dirty = true
|
||||
@@ -124,7 +124,7 @@ local function drawThrottleMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Select multicopter throttle channel", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, {"..."}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, {"..."}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
lcd.drawPixmap(120, 8, "multi-thr.bmp")
|
||||
lcd.drawText(20, LCD_H-16, "Assign Throttle", 0);
|
||||
@@ -148,7 +148,7 @@ local function drawRollMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Select multicopter roll channel", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, {"..."}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, {"..."}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
lcd.drawPixmap(120, 8, "multi-roll.bmp")
|
||||
lcd.drawText(20, LCD_H-16, "Assign Roll", 0);
|
||||
@@ -172,7 +172,7 @@ local function drawPitchMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Select multicopter pitch channel", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, {"..."}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, {"..."}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
lcd.drawPixmap(120, 8, "multi-pitch.bmp")
|
||||
lcd.drawText(20, LCD_H-16, "Assign Pitch", 0);
|
||||
@@ -196,7 +196,7 @@ local function drawYawMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Select multicopter yaw channel", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, {"..."}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, {"..."}, comboBoxMode, getFieldFlags(1))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
lcd.drawPixmap(120, 8, "multi-yaw.bmp")
|
||||
lcd.drawText(20, LCD_H-16, "Assign Yaw", 0);
|
||||
@@ -249,7 +249,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)
|
||||
@@ -257,7 +257,7 @@ end
|
||||
|
||||
local function applySettings()
|
||||
model.defaultInputs()
|
||||
model.deleteMixes()
|
||||
model.deleteMixes()
|
||||
addMix(thrCH1, MIXSRC_FIRST_INPUT+defaultChannel(2), "Throttle")
|
||||
addMix(rollCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "Roll")
|
||||
addMix(yawCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "Yaw")
|
||||
|
||||
@@ -46,10 +46,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK then
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -60,12 +60,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -82,12 +82,12 @@ 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 then
|
||||
page = nextPage
|
||||
field = 0
|
||||
dirty = true
|
||||
@@ -137,7 +137,7 @@ local function drawEngineMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Has your model got an engine?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, engineModeItems, engineMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, engineModeItems, engineMode, getFieldFlags(0))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
if engineMode == 1 then
|
||||
-- 1 channel
|
||||
@@ -174,7 +174,7 @@ local function drawAileronsMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Has your model got ailerons?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, aileronsModeItems, aileronsMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, aileronsModeItems, aileronsMode, getFieldFlags(0))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
if aileronsMode == 2 then
|
||||
-- 2 channels
|
||||
@@ -221,7 +221,7 @@ local function drawFlapsMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Has your model got flaps?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, flapsModeItems, flapsMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, flapsModeItems, flapsMode, getFieldFlags(0))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
if flapsMode == 0 then
|
||||
-- no flaps
|
||||
@@ -268,7 +268,7 @@ local function drawBrakesMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Has your model got air brakes?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, brakesModeItems, brakesMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, brakesModeItems, brakesMode, getFieldFlags(0))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
if brakesMode == 0 then
|
||||
-- no brakes
|
||||
@@ -306,7 +306,7 @@ local function brakesMenu(event)
|
||||
brakesCH1 = channelIncDec(event, brakesCH1)
|
||||
elseif field==2 then
|
||||
brakesCH2 = channelIncDec(event, brakesCH2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Tail Menu
|
||||
@@ -315,7 +315,7 @@ local function drawTailMenu()
|
||||
lcd.clear()
|
||||
lcd.drawText(1, 0, "Which is the tail config on your model?", 0)
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 8, GREY_DEFAULT+FILL_WHITE)
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, tailModeItems, tailMode, getFieldFlags(0))
|
||||
lcd.drawCombobox(0, 8, LCD_W/2, tailModeItems, tailMode, getFieldFlags(0))
|
||||
lcd.drawLine(LCD_W/2-1, 18, LCD_W/2-1, LCD_H-1, DOTTED, 0)
|
||||
lcd.drawText(LCD_W/2-19, LCD_H-8, ">>>", 0);
|
||||
if tailMode == 0 then
|
||||
@@ -365,7 +365,7 @@ local function tailMenu(event)
|
||||
rudCH1 = channelIncDec(event, rudCH1)
|
||||
elseif field==2 then
|
||||
eleCH2 = channelIncDec(event, eleCH2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Servo (limits) Menu
|
||||
@@ -385,7 +385,7 @@ local function drawServoMenu(limits)
|
||||
else
|
||||
lcd.drawText(129, 50, "\127", getFieldFlags(3));
|
||||
end
|
||||
fieldsMax = 3
|
||||
fieldsMax = 3
|
||||
end
|
||||
|
||||
local function servoMenu(event)
|
||||
@@ -462,7 +462,7 @@ local function drawConfirmationMenu()
|
||||
if tailMode == 2 then
|
||||
x, y = drawNextLine(x, y, "Elevator:", eleCH2)
|
||||
end
|
||||
drawNextLine(x, y, "Rudder:", rudCH1)
|
||||
drawNextLine(x, y, "Rudder:", rudCH1)
|
||||
end
|
||||
lcd.drawText(48, LCD_H-8, "[Enter Long] to confirm", 0);
|
||||
lcd.drawFilledRectangle(0, LCD_H-9, LCD_W, 9, 0)
|
||||
@@ -476,7 +476,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)
|
||||
@@ -484,7 +484,7 @@ end
|
||||
|
||||
local function applySettings()
|
||||
model.defaultInputs()
|
||||
model.deleteMixes()
|
||||
model.deleteMixes()
|
||||
if engineMode > 0 then
|
||||
addMix(thrCH1, MIXSRC_FIRST_INPUT+defaultChannel(2), "Engine")
|
||||
end
|
||||
@@ -547,7 +547,7 @@ local function run(event)
|
||||
error("Cannot be run as a model script!")
|
||||
end
|
||||
if servoPage ~= nil then
|
||||
servoMenu(event)
|
||||
servoMenu(event)
|
||||
elseif page == ENGINE_PAGE then
|
||||
engineMenu(event)
|
||||
elseif page == AILERONS_PAGE then
|
||||
|
||||
@@ -10,10 +10,10 @@ local MODELTYPE_QUAD = 3
|
||||
|
||||
-- Common functions
|
||||
local function fieldIncDec(event, value, max)
|
||||
if event == EVT_PLUS_BREAK then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK then
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -64,12 +64,12 @@ 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 }
|
||||
|
||||
Reference in New Issue
Block a user