[S6R] Fixes
This commit is contained in:
@@ -11,7 +11,8 @@ local refreshIndex = 0
|
|||||||
local calibrationState = 0
|
local calibrationState = 0
|
||||||
local pageOffset = 0
|
local pageOffset = 0
|
||||||
local calibrationStep = 0
|
local calibrationStep = 0
|
||||||
local pages = { }
|
local pages = {}
|
||||||
|
local fields = {}
|
||||||
|
|
||||||
local configFields = {
|
local configFields = {
|
||||||
{"Wing type:", COMBO, 0x80, nil, { "Normal", "Delta", "VTail" } },
|
{"Wing type:", COMBO, 0x80, nil, { "Normal", "Delta", "VTail" } },
|
||||||
@@ -50,7 +51,8 @@ local calibrationFields = {
|
|||||||
|
|
||||||
-- Change display attribute to current field
|
-- Change display attribute to current field
|
||||||
local function addField(step)
|
local function addField(step)
|
||||||
field = fields[current]
|
local field = fields[current]
|
||||||
|
local min, max
|
||||||
if field[2] == VALUE then
|
if field[2] == VALUE then
|
||||||
min = field[5]
|
min = field[5]
|
||||||
max = field[6]
|
max = field[6]
|
||||||
@@ -68,6 +70,7 @@ local function selectPage(step)
|
|||||||
page = 1 + ((page + step - 1 + #pages) % #pages)
|
page = 1 + ((page + step - 1 + #pages) % #pages)
|
||||||
refreshIndex = 0
|
refreshIndex = 0
|
||||||
calibrationStep = 0
|
calibrationStep = 0
|
||||||
|
pageOffset = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Select the next or previous editable field
|
-- Select the next or previous editable field
|
||||||
@@ -96,12 +99,12 @@ local function redrawFieldsPage()
|
|||||||
end
|
end
|
||||||
|
|
||||||
for index = 1, 7, 1 do
|
for index = 1, 7, 1 do
|
||||||
field = fields[pageOffset+index]
|
local field = fields[pageOffset+index]
|
||||||
if field == nil then
|
if field == nil then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0
|
local attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0
|
||||||
|
|
||||||
lcd.drawText(0, 1+8*index, field[1])
|
lcd.drawText(0, 1+8*index, field[1])
|
||||||
|
|
||||||
@@ -137,16 +140,16 @@ local function refreshNext()
|
|||||||
telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms
|
telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms
|
||||||
end
|
end
|
||||||
elseif refreshIndex < #fields then
|
elseif refreshIndex < #fields then
|
||||||
field = fields[refreshIndex + 1]
|
local field = fields[refreshIndex + 1]
|
||||||
if telemetryRead(field[3]) == true then
|
if telemetryRead(field[3]) == true then
|
||||||
refreshState = 1
|
refreshState = 1
|
||||||
telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms
|
telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif refreshState == 1 then
|
elseif refreshState == 1 then
|
||||||
physicalId, primId, dataId, value = sportTelemetryPop()
|
local physicalId, primId, dataId, value = sportTelemetryPop()
|
||||||
if physicalId == 0x1A and primId == 0x32 and dataId == 0x0C30 then
|
if physicalId == 0x1A and primId == 0x32 and dataId == 0x0C30 then
|
||||||
fieldId = value % 256
|
local fieldId = value % 256
|
||||||
if calibrationState == 2 then
|
if calibrationState == 2 then
|
||||||
if fieldId == 0x9D then
|
if fieldId == 0x9D then
|
||||||
refreshState = 0
|
refreshState = 0
|
||||||
@@ -154,12 +157,12 @@ local function refreshNext()
|
|||||||
calibrationStep = (calibrationStep + 1) % 6
|
calibrationStep = (calibrationStep + 1) % 6
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
field = fields[refreshIndex + 1]
|
local field = fields[refreshIndex + 1]
|
||||||
if fieldId == field[3] then
|
if fieldId == field[3] then
|
||||||
value = math.floor(value / 256)
|
local value = math.floor(value / 256)
|
||||||
if field[3] >= 0x9E and field[3] <= 0xA0 then
|
if field[3] >= 0x9E and field[3] <= 0xA0 then
|
||||||
b1 = value % 256
|
local b1 = value % 256
|
||||||
b2 = math.floor(value / 256)
|
local b2 = math.floor(value / 256)
|
||||||
value = b1*256 + b2
|
value = b1*256 + b2
|
||||||
value = value - bit32.band(value, 0x8000) * 2
|
value = value - bit32.band(value, 0x8000) * 2
|
||||||
end
|
end
|
||||||
@@ -186,7 +189,7 @@ local function refreshNext()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function updateField(field)
|
local function updateField(field)
|
||||||
value = field[4]
|
local value = field[4]
|
||||||
if field[2] == COMBO and #field == 6 then
|
if field[2] == COMBO and #field == 6 then
|
||||||
value = field[6][1+value]
|
value = field[6][1+value]
|
||||||
elseif field[2] == VALUE and #field == 8 then
|
elseif field[2] == VALUE and #field == 8 then
|
||||||
@@ -228,7 +231,7 @@ local mountBitmaps = { "horz.bmp", "horz-r.bmp", "vert.bmp", "vert-r.bmp" }
|
|||||||
|
|
||||||
local function runConfigPage(event)
|
local function runConfigPage(event)
|
||||||
fields = configFields
|
fields = configFields
|
||||||
result = runFieldsPage(event)
|
local result = runFieldsPage(event)
|
||||||
if fields[1][4] ~= nil then
|
if fields[1][4] ~= nil then
|
||||||
lcd.drawPixmap(20, 28, wingBitmaps[1 + fields[1][4]])
|
lcd.drawPixmap(20, 28, wingBitmaps[1 + fields[1][4]])
|
||||||
end
|
end
|
||||||
@@ -256,12 +259,12 @@ local function runCalibrationPage(event)
|
|||||||
lcd.drawText(0, 9, "Turn the receiver " .. position, 0)
|
lcd.drawText(0, 9, "Turn the receiver " .. position, 0)
|
||||||
lcd.drawPixmap(10, 19, position .. ".bmp")
|
lcd.drawPixmap(10, 19, position .. ".bmp")
|
||||||
for index = 1, 3, 1 do
|
for index = 1, 3, 1 do
|
||||||
field = fields[pageOffset+index]
|
local field = fields[index]
|
||||||
lcd.drawText(80, 12+10*index, field[1], 0)
|
lcd.drawText(80, 12+10*index, field[1], 0)
|
||||||
lcd.drawNumber(90, 12+10*index, field[4]/10, LEFT+PREC2)
|
lcd.drawNumber(90, 12+10*index, field[4]/10, LEFT+PREC2)
|
||||||
end
|
end
|
||||||
|
|
||||||
attr = calibrationState == 0 and INVERS or 0
|
local attr = calibrationState == 0 and INVERS or 0
|
||||||
lcd.drawText(0, 56, "Press [Enter] when ready", attr)
|
lcd.drawText(0, 56, "Press [Enter] when ready", attr)
|
||||||
if event == EVT_ENTER_BREAK then
|
if event == EVT_ENTER_BREAK then
|
||||||
calibrationState = 1
|
calibrationState = 1
|
||||||
@@ -297,7 +300,7 @@ local function run(event)
|
|||||||
selectPage(-1)
|
selectPage(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
result = pages[page](event)
|
local result = pages[page](event)
|
||||||
refreshNext()
|
refreshNext()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user