Merge with latest 2.3
This commit is contained in:
@@ -72,7 +72,7 @@ local function incrField(step)
|
||||
end
|
||||
else
|
||||
local min, max = 0, 0
|
||||
if field.type <= 5 then
|
||||
if ((field.type <= 5) or (field.type == 8)) then
|
||||
min = field.min
|
||||
max = field.max
|
||||
step = field.step * step
|
||||
@@ -239,25 +239,21 @@ local function fieldFloatLoad(field, data, offset)
|
||||
field.default = fieldGetValue(data, offset+12, 4)
|
||||
fieldUnsignedToSigned(field, 4)
|
||||
field.prec = data[offset+16]
|
||||
if field.prec > 2 then
|
||||
field.prec = 2
|
||||
if field.prec > 3 then
|
||||
field.prec = 3
|
||||
end
|
||||
field.step = fieldGetValue(data, offset+17, 4)
|
||||
field.unit, offset = fieldGetString(data, offset+21)
|
||||
end
|
||||
|
||||
local function formatFloat(num, decimals)
|
||||
local mult = 10^(decimals or 0)
|
||||
local val = num / mult
|
||||
return string.format("%." .. decimals .. "f", val)
|
||||
end
|
||||
|
||||
local function fieldFloatDisplay(field, y, attr)
|
||||
local attrnum
|
||||
if field.prec == 1 then
|
||||
attrnum = LEFT + attr + PREC1
|
||||
elseif field.prec == 2 then
|
||||
attrnum = LEFT + attr + PREC2
|
||||
else
|
||||
attrnum = LEFT + attr
|
||||
end
|
||||
-- lcd.drawNumber(140, y, field.value, attrnum) -- NOTE: original code getLastPos not available in Horus
|
||||
-- lcd.drawText(lcd.getLastPos(), y, field.unit, attr) -- NOTE: original code getLastPos not available in Horus
|
||||
lcd.drawText(140, y, field.value .. field.unit, attr) -- NOTE: Concenated fields instead of get lastPos
|
||||
lcd.drawText(140, y, formatFloat(field.value, field.prec) .. field.unit, attr)
|
||||
end
|
||||
|
||||
local function fieldFloatSave(field)
|
||||
@@ -423,7 +419,7 @@ end
|
||||
|
||||
-- Main
|
||||
local function runDevicePage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
if edit == true then
|
||||
edit = false
|
||||
local field = getField(lineIndex)
|
||||
@@ -455,9 +451,9 @@ local function runDevicePage(event)
|
||||
end
|
||||
end
|
||||
elseif edit then
|
||||
if event == EVT_VIRTUAL_INC then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
incrField(1)
|
||||
elseif event == EVT_VIRTUAL_DEC then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
incrField(-1)
|
||||
end
|
||||
else
|
||||
|
||||
@@ -273,11 +273,6 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot run as a model script!")
|
||||
return 2
|
||||
elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST or event == EVT_SHIFT_BREAK then
|
||||
--selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST or event == EVT_SHIFT_LONG then
|
||||
--killEvents(event);
|
||||
--selectPage(-1)
|
||||
end
|
||||
local result = pages[page](event)
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ end
|
||||
|
||||
-- Main
|
||||
local function runFieldsPage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK or event == EVT_ROT_BREAK then -- toggle editing/selecting current field
|
||||
elseif event == EVT_VIRTUAL_ENTER then -- toggle editing/selecting current field
|
||||
if fields[current][5] ~= nil then
|
||||
edit = not edit
|
||||
if edit == false then
|
||||
@@ -101,15 +101,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_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_NEXT then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_PREV then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -465,9 +465,9 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot be run as a model script!")
|
||||
return 2
|
||||
elseif (event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST) and page < #pages-1 then
|
||||
elseif event == EVT_VIRTUAL_NEXT_PAGE and page < #pages-1 then
|
||||
selectPage(1)
|
||||
elseif (event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST) and page > 1 then
|
||||
elseif event == EVT_VIRTUAL_PREV_PAGE and page > 1 then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
@@ -91,9 +91,9 @@ end
|
||||
|
||||
-- Main
|
||||
local function runFieldsPage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK or event == EVT_ROT_BREAK then -- toggle editing/selecting current field
|
||||
elseif event == EVT_VIRTUAL_ENTER then -- toggle editing/selecting current field
|
||||
if fields[current][5] ~= nil then
|
||||
edit = not edit
|
||||
if edit == false then
|
||||
@@ -101,15 +101,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_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_NEXT then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_PREV then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -465,9 +465,9 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot be run as a model script!")
|
||||
return 2
|
||||
elseif (event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST) and page < #pages-1 then
|
||||
elseif event == EVT_VIRTUAL_NEXT_PAGE and page < #pages-1 then
|
||||
selectPage(1)
|
||||
elseif (event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST) and page > 1 then
|
||||
elseif event == EVT_VIRTUAL_PREV_PAGE and page > 1 then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
@@ -237,9 +237,9 @@ end
|
||||
|
||||
-- Main
|
||||
local function runFieldsPage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK or event == EVT_ROT_BREAK then -- toggle editing/selecting current field
|
||||
elseif event == EVT_VIRTUAL_ENTER then -- toggle editing/selecting current field
|
||||
if fields[current][4] ~= nil then
|
||||
edit = not edit
|
||||
if edit == false then
|
||||
@@ -247,15 +247,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_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_NEXT then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_PREV then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -313,11 +313,11 @@ local function runCalibrationPage(event)
|
||||
lcd.drawBitmap(Bitmap.open("img/done.bmp"),200, 100)
|
||||
lcd.drawText(160, 220, "Press [RTN] when ready", attr)
|
||||
end
|
||||
if calibrationStep > 6 and (event == EVT_ENTER_BREAK or event == EVT_EXIT_BREAK) then
|
||||
if calibrationStep > 6 and (event == EVT_VIRTUAL_ENTER or event == EVT_VIRTUAL_EXIT) then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK then
|
||||
elseif event == EVT_VIRTUAL_ENTER then
|
||||
calibrationState = 1
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
if calibrationStep > 0 then
|
||||
calibrationStep = 0
|
||||
end
|
||||
@@ -341,9 +341,9 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot be run as a model script!")
|
||||
return 2
|
||||
elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST then
|
||||
elseif event == EVT_VIRTUAL_NEXT_PAGE then
|
||||
selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST then
|
||||
elseif event == EVT_VIRTUAL_PREV_PAGE then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 161 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 121 KiB |
@@ -16,11 +16,16 @@
|
||||
---- # #
|
||||
---- #########################################################################
|
||||
|
||||
-- Horus Widget to display the levels of lipo battery with per cell indication
|
||||
-- 3djc & Offer Shmuely
|
||||
-- Date: 2020
|
||||
-- ver: 0.4
|
||||
|
||||
local _options = {
|
||||
{ "Sensor", SOURCE, 0 },
|
||||
{ "Sensor", SOURCE, 0 }, -- default to 'Cels'
|
||||
{ "Color", COLOR, WHITE },
|
||||
{ "Shadow", BOOL, 0 },
|
||||
{ "LowestCell", BOOL, 1 }
|
||||
{ "LowestCell", BOOL, 1 } -- 0=main voltage display shows all-cell-voltage, 1=main voltage display shows lowest-cell
|
||||
}
|
||||
|
||||
-- This function is run once at the creation of the widget
|
||||
@@ -29,12 +34,12 @@ local function create(zone, options)
|
||||
zone = zone,
|
||||
options = options,
|
||||
counter = 0,
|
||||
|
||||
shadowed = 0,
|
||||
|
||||
no_telem_blink = 0,
|
||||
isDataAvailable = 0,
|
||||
cellDataLive = {0,0,0,0,0,0},
|
||||
cellDataHistoryLowest = {0,0,0,0,0,0},
|
||||
cellDataHistoryLowest = {5,5,5,5,5,5},
|
||||
cellDataHistoryCellLowest = 5,
|
||||
cellMax = 0,
|
||||
cellMin = 0,
|
||||
@@ -112,51 +117,47 @@ local function calculateBatteryData(wgt)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
-- this is necessary for simu where cell-count can change
|
||||
if #wgt.cellDataHistoryLowest ~= #newCellData then
|
||||
wgt.cellDataHistoryLowest = {}
|
||||
for k, v in pairs(newCellData) do
|
||||
wgt.cellDataHistoryLowest[k] = v
|
||||
end
|
||||
end
|
||||
-- stores the lowest cell values in historical table
|
||||
for k, v in pairs(newCellData) do
|
||||
if v < wgt.cellDataHistoryLowest[k] then
|
||||
wgt.cellDataHistoryLowest[k] = v
|
||||
wgt.cellDataHistoryLowest[k] = 5 -- invalid reading, set high value so the min() will update it soon
|
||||
end
|
||||
end
|
||||
|
||||
--- calc highest of all cels
|
||||
local cellMax = 0
|
||||
local cellMin = 5
|
||||
local cellSum = 0
|
||||
for k, v in pairs(newCellData) do
|
||||
-- stores the lowest cell values in historical table
|
||||
if v > 1 and v < wgt.cellDataHistoryLowest[k] then -- min 1v to consider a valid reading
|
||||
wgt.cellDataHistoryLowest[k] = v
|
||||
|
||||
--- calc history lowest of all cells
|
||||
if v < wgt.cellDataHistoryCellLowest then
|
||||
wgt.cellDataHistoryCellLowest = v
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- calc highest of all cells
|
||||
if v > cellMax then
|
||||
cellMax = v
|
||||
end
|
||||
end
|
||||
wgt.cellMax = cellMax
|
||||
|
||||
--- calc lowest of all cels
|
||||
local cellMin = 5
|
||||
for k, v in pairs(newCellData) do
|
||||
if v < cellMin and v > 1 then -- >1 to ignore invalid values
|
||||
--- calc lowest of all cells
|
||||
if v < cellMin and v > 1 then -- min 1v to consider a valid reading
|
||||
cellMin = v
|
||||
end
|
||||
end
|
||||
wgt.cellMin = cellMin
|
||||
|
||||
--- calc history lowest of all cells
|
||||
if cellMin < wgt.cellDataHistoryCellLowest and cellMin > 1 then -- >1 to ignore invalid values
|
||||
wgt.cellDataHistoryCellLowest = cellMin
|
||||
end
|
||||
|
||||
wgt.cellCount = #newCellData
|
||||
|
||||
--- sum of all cells
|
||||
local cellSum = 0
|
||||
for k, v in pairs(newCellData) do
|
||||
--- sum of all cells
|
||||
cellSum = cellSum + v
|
||||
|
||||
|
||||
end
|
||||
|
||||
wgt.cellMin = cellMin
|
||||
wgt.cellMax = cellMax
|
||||
wgt.cellCount = #newCellData
|
||||
wgt.cellSum = cellSum
|
||||
|
||||
--- average of all cells
|
||||
@@ -328,7 +329,7 @@ local function refreshZoneLarge(wgt)
|
||||
|
||||
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y, wgt.cellPercent .. "%", RIGHT + DBLSIZE + CUSTOM_COLOR + wgt.shadowed)
|
||||
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y + 30, string.format("%2.1fV", wgt.mainValue), RIGHT + DBLSIZE + CUSTOM_COLOR + wgt.shadowed)
|
||||
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y + 70, string.format("%2.1fV %2.1fS", wgt.secondaryValue, wgt.cellCount), RIGHT + SMLSIZE + CUSTOM_COLOR + wgt.shadowed)
|
||||
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y + 70, string.format("%2.1fV %dS", wgt.secondaryValue, wgt.cellCount), RIGHT + SMLSIZE + CUSTOM_COLOR + wgt.shadowed)
|
||||
-- fill batt
|
||||
lcd.setColor(CUSTOM_COLOR, getPercentColor(wgt.cellPercent))
|
||||
lcd.drawFilledRectangle(wgt.zone.x + myBatt.x, wgt.zone.y + myBatt.y + myBatt.h + myBatt.cath_h - math.floor(wgt.cellPercent / 100 * myBatt.h), myBatt.w, math.floor(wgt.cellPercent / 100 * myBatt.h), CUSTOM_COLOR)
|
||||
@@ -372,7 +373,7 @@ local function refreshZoneXLarge(wgt)
|
||||
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y + myBatt.y, wgt.cellPercent .. "%", RIGHT + DBLSIZE + CUSTOM_COLOR + wgt.shadowed + wgt.no_telem_blink)
|
||||
|
||||
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y + myBatt.y + 30, string.format("%2.1fV", wgt.mainValue), RIGHT + DBLSIZE + CUSTOM_COLOR + wgt.shadowed + wgt.no_telem_blink)
|
||||
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y + myBatt.y + 105, string.format("%2.1fV %2.1fS", wgt.secondaryValue, wgt.cellCount), RIGHT + SMLSIZE + CUSTOM_COLOR + wgt.shadowed + wgt.no_telem_blink)
|
||||
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y + myBatt.y + 105, string.format("%2.1fV %dS", wgt.secondaryValue, wgt.cellCount), RIGHT + SMLSIZE + CUSTOM_COLOR + wgt.shadowed + wgt.no_telem_blink)
|
||||
|
||||
-- draw cells
|
||||
local pos = { { x = 111, y = 38 }, { x = 164, y = 38 }, { x = 217, y = 38 }, { x = 111, y = 57 }, { x = 164, y = 57 }, { x = 217, y = 57 } }
|
||||
|
||||
@@ -72,7 +72,7 @@ local function incrField(step)
|
||||
end
|
||||
else
|
||||
local min, max = 0, 0
|
||||
if field.type <= 5 then
|
||||
if ((field.type <= 5) or (field.type == 8)) then
|
||||
min = field.min
|
||||
max = field.max
|
||||
step = field.step * step
|
||||
@@ -238,23 +238,21 @@ local function fieldFloatLoad(field, data, offset)
|
||||
field.default = fieldGetValue(data, offset+12, 4)
|
||||
fieldUnsignedToSigned(field, 4)
|
||||
field.prec = data[offset+16]
|
||||
if field.prec > 2 then
|
||||
field.prec = 2
|
||||
if field.prec > 3 then
|
||||
field.prec = 3
|
||||
end
|
||||
field.step = fieldGetValue(data, offset+17, 4)
|
||||
field.unit, offset = fieldGetString(data, offset+21)
|
||||
end
|
||||
|
||||
local function formatFloat(num, decimals)
|
||||
local mult = 10^(decimals or 0)
|
||||
local val = num / mult
|
||||
return string.format("%." .. decimals .. "f", val)
|
||||
end
|
||||
|
||||
local function fieldFloatDisplay(field, y, attr)
|
||||
local attrnum
|
||||
if field.prec == 1 then
|
||||
attrnum = LEFT + attr + PREC1
|
||||
elseif field.prec == 2 then
|
||||
attrnum = LEFT + attr + PREC2
|
||||
else
|
||||
attrnum = LEFT + attr
|
||||
end
|
||||
lcd.drawNumber(89, y, field.value, attrnum)
|
||||
lcd.drawText(89, y, formatFloat(field.value, field.prec), LEFT + attr)
|
||||
lcd.drawText(lcd.getLastPos(), y, field.unit, attr)
|
||||
end
|
||||
|
||||
|
||||
@@ -273,11 +273,6 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot run as a model script!")
|
||||
return 2
|
||||
elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST or event == EVT_SHIFT_BREAK then
|
||||
--selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST or event == EVT_SHIFT_LONG then
|
||||
--killEvents(event);
|
||||
--selectPage(-1)
|
||||
end
|
||||
local result = pages[page](event)
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
if event == EVT_VIRTUAL_PREV or event == EVT_VIRTUAL_PREV_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
elseif event == EVT_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REPT 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_RIGHT_BREAK then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_LEFT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -82,22 +82,22 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
dirty = blinkChanged()
|
||||
end
|
||||
else
|
||||
if event == EVT_PAGE_BREAK or event==EVT_RIGHT_BREAK then
|
||||
if event == EVT_VIRTUAL_NEXT then
|
||||
page = nextPage
|
||||
field = 0
|
||||
dirty = true
|
||||
elseif event == EVT_PAGE_LONG or event==EVT_LEFT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_PREV then
|
||||
page = prevPage
|
||||
field = 0
|
||||
killEvents(event);
|
||||
@@ -120,7 +120,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event==EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -276,7 +276,7 @@ local function servoMenu(event)
|
||||
limits.revert = fieldIncDec(event, limits.revert, 1)
|
||||
end
|
||||
model.setOutput(servoPage, limits)
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
servoPage = nil
|
||||
dirty = true
|
||||
end
|
||||
@@ -348,9 +348,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, RUDDER_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -58,10 +58,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -72,12 +72,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_ROT_RIGHT or event == EVT_RIGHT_FIRST then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_LEFT_FIRST then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -88,11 +88,11 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
@@ -126,7 +126,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event==EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -137,12 +137,12 @@ end
|
||||
|
||||
local function switchValueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_ROT_RIGHT or event == EVT_RIGHT_FIRST then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_LEFT_FIRST then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -153,7 +153,7 @@ local function switchValueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function switchIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event== EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -399,9 +399,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, BEEPER_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -62,10 +62,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT 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_RIGHT or event == EVT_RIGHT_BREAK then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_ROT_LEFT or event == EVT_LEFT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -92,11 +92,11 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
@@ -130,7 +130,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event==EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -420,7 +420,7 @@ local function servoMenu(event)
|
||||
limits.revert = fieldIncDec(event, limits.revert, 1)
|
||||
end
|
||||
model.setOutput(servoPage, limits)
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
servoPage = nil
|
||||
dirty = true
|
||||
end
|
||||
@@ -544,9 +544,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, TAIL_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -23,9 +23,9 @@ local MODELTYPE_QUAD = 2
|
||||
|
||||
-- Common functions
|
||||
local function fieldIncDec(event, value, max)
|
||||
if event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
elseif event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
value = (value + max + 2)
|
||||
end
|
||||
value = (value % (max+1))
|
||||
@@ -53,7 +53,7 @@ end
|
||||
|
||||
local function modelTypeMenu(event)
|
||||
drawModelChoiceMenu()
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
if modelType == MODELTYPE_PLANE then
|
||||
return "plane.lua"
|
||||
elseif modelType == MODELTYPE_DELTA then
|
||||
@@ -73,7 +73,7 @@ local function run(event)
|
||||
error("Cannot be run as a model script!")
|
||||
end
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
end
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ local function run(event)
|
||||
raise("Cannot be run as a model script!")
|
||||
end
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
end
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ local function runWarningPage(event)
|
||||
lcd.drawText(0, 30, "power, and a level surface.", SMLSIZE)
|
||||
lcd.drawText(0, 40, "Press [Enter] when ready", SMLSIZE)
|
||||
lcd.drawText(0, 50, "Press [Exit] to cancel", SMLSIZE)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
selectPage(1)
|
||||
return 0
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
end
|
||||
return 0
|
||||
@@ -186,9 +186,9 @@ end
|
||||
|
||||
-- Main
|
||||
local function runFieldsPage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK then -- toggle editing/selecting current field
|
||||
elseif event == EVT_VIRTUAL_ENTER then -- toggle editing/selecting current field
|
||||
if fields[current][4] ~= nil then
|
||||
edit = not edit
|
||||
if edit == false then
|
||||
@@ -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 or event == EVT_DOWN_BREAK then
|
||||
if event == EVT_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REP then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT or event == EVT_UP_BREAK then
|
||||
elseif event == EVT_VIRTUAL_PREV or event == EVT_VIRTUAL_PREV_REP then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_UP_BREAK then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REP then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_DOWN_BREAK then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REP then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -260,9 +260,9 @@ local function runCalibrationPage(event)
|
||||
-- lcd.drawText(10, 19, "Done",0)
|
||||
lcd.drawText(0, 56, "Press [Exit] when ready", attr)
|
||||
end
|
||||
if calibrationStep > 6 and (event == EVT_ENTER_BREAK or event == EVT_EXIT_BREAK) then
|
||||
if calibrationStep > 6 and (event == EVT_VIRTUAL_ENTER or event == EVT_VIRTUAL_EXIT) then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK and positionConfirmed then
|
||||
elseif event == EVT_VIRTUAL_ENTER and positionConfirmed then
|
||||
calibrationState = 1
|
||||
positionConfirmed = 0
|
||||
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 or event==EVT_RIGHT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_NEXT_PAGE then
|
||||
selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG or event==EVT_LEFT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_PREV_PAGE then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
@@ -72,7 +72,7 @@ local function incrField(step)
|
||||
end
|
||||
else
|
||||
local min, max = 0, 0
|
||||
if field.type <= 5 then
|
||||
if ((field.type <= 5) or (field.type == 8)) then
|
||||
min = field.min
|
||||
max = field.max
|
||||
step = field.step * step
|
||||
@@ -238,23 +238,21 @@ local function fieldFloatLoad(field, data, offset)
|
||||
field.default = fieldGetValue(data, offset+12, 4)
|
||||
fieldUnsignedToSigned(field, 4)
|
||||
field.prec = data[offset+16]
|
||||
if field.prec > 2 then
|
||||
field.prec = 2
|
||||
if field.prec > 3 then
|
||||
field.prec = 3
|
||||
end
|
||||
field.step = fieldGetValue(data, offset+17, 4)
|
||||
field.unit, offset = fieldGetString(data, offset+21)
|
||||
end
|
||||
|
||||
local function formatFloat(num, decimals)
|
||||
local mult = 10^(decimals or 0)
|
||||
local val = num / mult
|
||||
return string.format("%." .. decimals .. "f", val)
|
||||
end
|
||||
|
||||
local function fieldFloatDisplay(field, y, attr)
|
||||
local attrnum
|
||||
if field.prec == 1 then
|
||||
attrnum = LEFT + attr + PREC1
|
||||
elseif field.prec == 2 then
|
||||
attrnum = LEFT + attr + PREC2
|
||||
else
|
||||
attrnum = LEFT + attr
|
||||
end
|
||||
lcd.drawNumber(140, y, field.value, attrnum)
|
||||
lcd.drawText(140, y, formatFloat(field.value, field.prec), LEFT + attr)
|
||||
lcd.drawText(lcd.getLastPos(), y, field.unit, attr)
|
||||
end
|
||||
|
||||
|
||||
@@ -273,11 +273,6 @@ local function run(event)
|
||||
if event == nil then
|
||||
error("Cannot run as a model script!")
|
||||
return 2
|
||||
elseif event == EVT_PAGE_BREAK or event == EVT_PAGEDN_FIRST or event == EVT_SHIFT_BREAK then
|
||||
--selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG or event == EVT_PAGEUP_FIRST or event == EVT_SHIFT_LONG then
|
||||
--killEvents(event);
|
||||
--selectPage(-1)
|
||||
end
|
||||
local result = pages[page](event)
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT 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_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -82,11 +82,11 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
@@ -120,7 +120,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event == EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -284,7 +284,7 @@ local function servoMenu(event)
|
||||
limits.revert = fieldIncDec(event, limits.revert, 1)
|
||||
end
|
||||
model.setOutput(servoPage, limits)
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
servoPage = nil
|
||||
dirty = true
|
||||
end
|
||||
@@ -357,9 +357,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, RUDDER_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -57,10 +57,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -71,12 +71,12 @@ end
|
||||
|
||||
local function valueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -87,11 +87,11 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
@@ -125,7 +125,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event == EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -136,12 +136,12 @@ end
|
||||
|
||||
local function switchValueIncDec(event, value, min, max)
|
||||
if edit then
|
||||
if event == EVT_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -152,7 +152,7 @@ local function switchValueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function switchIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event == EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -415,9 +415,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, BEEPER_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -62,10 +62,10 @@ end
|
||||
|
||||
local function fieldIncDec(event, value, max, force)
|
||||
if edit or force==true then
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT 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_PLUS_FIRST or event == EVT_PLUS_REPT or event == EVT_ROT_RIGHT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
if value < max then
|
||||
value = (value + 1)
|
||||
dirty = true
|
||||
end
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_MINUS_REPT or event == EVT_ROT_LEFT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
if value > min then
|
||||
value = (value - 1)
|
||||
dirty = true
|
||||
@@ -92,11 +92,11 @@ local function valueIncDec(event, value, min, max)
|
||||
end
|
||||
|
||||
local function navigate(event, fieldMax, prevPage, nextPage)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
edit = not edit
|
||||
dirty = true
|
||||
elseif edit then
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
edit = false
|
||||
dirty = true
|
||||
elseif not dirty then
|
||||
@@ -130,7 +130,7 @@ local function getFieldFlags(position)
|
||||
end
|
||||
|
||||
local function channelIncDec(event, value)
|
||||
if not edit and event==EVT_MENU_BREAK then
|
||||
if not edit and event == EVT_VIRTUAL_MENU then
|
||||
servoPage = value
|
||||
dirty = true
|
||||
else
|
||||
@@ -425,7 +425,7 @@ local function servoMenu(event)
|
||||
limits.revert = fieldIncDec(event, limits.revert, 1)
|
||||
end
|
||||
model.setOutput(servoPage, limits)
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
servoPage = nil
|
||||
dirty = true
|
||||
end
|
||||
@@ -550,9 +550,9 @@ local function confirmationMenu(event)
|
||||
|
||||
navigate(event, fieldsMax, TAIL_PAGE, page)
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_LONG then
|
||||
elseif event == EVT_VIRTUAL_ENTER_LONG then
|
||||
killEvents(event)
|
||||
applySettings()
|
||||
return 2
|
||||
|
||||
@@ -25,10 +25,10 @@ local MODELTYPE_QUAD = 2
|
||||
|
||||
-- Common functions
|
||||
local function fieldIncDec(event, value, max)
|
||||
if event == EVT_PLUS_BREAK or event == EVT_ROT_LEFT or event == EVT_PLUS_REPT then
|
||||
if event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REPT then
|
||||
value = (value + max)
|
||||
dirty = true
|
||||
elseif event == EVT_MINUS_BREAK or event == EVT_ROT_RIGHT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REPT then
|
||||
value = (value + max + 2)
|
||||
dirty = true
|
||||
end
|
||||
@@ -56,7 +56,7 @@ local function modelTypeMenu(event)
|
||||
drawModelChoiceMenu()
|
||||
dirty = false
|
||||
end
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
if modelType == MODELTYPE_PLANE then
|
||||
return "plane.lua"
|
||||
elseif modelType == MODELTYPE_DELTA then
|
||||
@@ -77,7 +77,7 @@ local function run(event)
|
||||
error("Cannot be run as a model script!")
|
||||
end
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
end
|
||||
return modelTypeMenu(event)
|
||||
|
||||
@@ -127,7 +127,7 @@ local function run(event)
|
||||
raise("Cannot be run as a model script!")
|
||||
end
|
||||
|
||||
if event == EVT_EXIT_BREAK then
|
||||
if event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
end
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ local function runWarningPage(event)
|
||||
lcd.drawText(0, 30, "power supply and a flat level surface (desk,...)", SMLSIZE)
|
||||
lcd.drawText(0, 40, "Press [Enter] when ready", SMLSIZE)
|
||||
lcd.drawText(0, 50, "Press [Exit] when cancel", SMLSIZE)
|
||||
if event == EVT_ENTER_BREAK then
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
selectPage(1)
|
||||
return 0
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
return 2
|
||||
end
|
||||
return 0
|
||||
@@ -184,9 +184,9 @@ end
|
||||
|
||||
-- Main
|
||||
local function runFieldsPage(event)
|
||||
if event == EVT_EXIT_BREAK then -- exit script
|
||||
if event == EVT_VIRTUAL_EXIT then -- exit script
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK then -- toggle editing/selecting current field
|
||||
elseif event == EVT_VIRTUAL_ENTER then -- toggle editing/selecting current field
|
||||
if fields[current][4] ~= nil then
|
||||
edit = not edit
|
||||
if edit == false then
|
||||
@@ -194,15 +194,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_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REP then
|
||||
addField(1)
|
||||
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
|
||||
elseif event == EVT_VIRTUAL_PREV or event == EVT_VIRTUAL_PREV_REP then
|
||||
addField(-1)
|
||||
end
|
||||
else
|
||||
if event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT then
|
||||
if event == EVT_VIRTUAL_INC or event == EVT_VIRTUAL_INC_REP then
|
||||
selectField(1)
|
||||
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT then
|
||||
elseif event == EVT_VIRTUAL_DEC or event == EVT_VIRTUAL_DEC_REP then
|
||||
selectField(-1)
|
||||
end
|
||||
end
|
||||
@@ -235,11 +235,11 @@ local function runCalibrationPage(event)
|
||||
lcd.drawPixmap(10, 19, "bmp/done.bmp")
|
||||
lcd.drawText(0, 56, "Press [Exit] when ready", attr)
|
||||
end
|
||||
if calibrationStep > 6 and (event == EVT_ENTER_BREAK or event == EVT_EXIT_BREAK) then
|
||||
if calibrationStep > 6 and (event == EVT_VIRTUAL_ENTER or event == EVT_VIRTUAL_EXIT) then
|
||||
return 2
|
||||
elseif event == EVT_ENTER_BREAK then
|
||||
elseif event == EVT_VIRTUAL_ENTER then
|
||||
calibrationState = 1
|
||||
elseif event == EVT_EXIT_BREAK then
|
||||
elseif event == EVT_VIRTUAL_EXIT then
|
||||
if calibrationStep > 0 then
|
||||
calibrationStep = 0
|
||||
end
|
||||
@@ -261,9 +261,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_VIRTUAL_NEXT_PAGE then
|
||||
selectPage(1)
|
||||
elseif event == EVT_PAGE_LONG then
|
||||
elseif event == EVT_VIRTUAL_PREV_PAGE then
|
||||
killEvents(event);
|
||||
selectPage(-1)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user