3djc/taranis improve s6 r (#3825)

* Step 1 : calibration

* Step 2 : remove calib for main LUA

* Clean BMP
This commit is contained in:
3djc
2016-09-18 15:59:55 +02:00
committed by Bertrand Songis
parent 3107bbb88b
commit f675506bc6
8 changed files with 516 additions and 318 deletions
+256 -318
View File
@@ -1,318 +1,256 @@
local VALUE = 0 local VALUE = 0
local COMBO = 1 local COMBO = 1
local COLUMN_2 = 150 local COLUMN_2 = 150
local edit = false local edit = false
local page = 1 local page = 1
local current = 1 local current = 1
local refreshState = 0 local refreshState = 0
local refreshIndex = 0 local refreshIndex = 0
local calibrationState = 0 local pageOffset = 0
local pageOffset = 0 local pages = {}
local calibrationStep = 0 local fields = {}
local pages = {} local modifications = {}
local fields = {}
local modifications = {} local configFields = {
{"Wing type:", COMBO, 0x80, nil, { "Normal", "Delta", "VTail" } },
local configFields = { {"Mounting type:", COMBO, 0x81, nil, { "Horz", "Horz rev.", "Vert", "Vert rev." } },
{"Wing type:", COMBO, 0x80, nil, { "Normal", "Delta", "VTail" } }, }
{"Mounting type:", COMBO, 0x81, nil, { "Horz", "Horz rev.", "Vert", "Vert rev." } },
} local settingsFields = {
{"S6R functions:", COMBO, 0x9C, nil, { "Disable", "Enable" } },
local settingsFields = { {"AIL direction:", COMBO, 0x82, nil, { "Normal", "Invers" }, { 255, 0 } },
{"S6R functions:", COMBO, 0x9C, nil, { "Disable", "Enable" } }, {"ELE direction:", COMBO, 0x83, nil, { "Normal", "Invers" }, { 255, 0 } },
{"AIL direction:", COMBO, 0x82, nil, { "Normal", "Invers" }, { 255, 0 } }, {"RUD direction:", COMBO, 0x84, nil, { "Normal", "Invers" }, { 255, 0 } },
{"ELE direction:", COMBO, 0x83, nil, { "Normal", "Invers" }, { 255, 0 } }, {"AIL2 direction:", COMBO, 0x9A, nil, { "Normal", "Invers" }, { 255, 0 } },
{"RUD direction:", COMBO, 0x84, nil, { "Normal", "Invers" }, { 255, 0 } }, {"ELE2 direction:", COMBO, 0x9B, nil, { "Normal", "Invers" }, { 255, 0 } },
{"AIL2 direction:", COMBO, 0x9A, nil, { "Normal", "Invers" }, { 255, 0 } }, {"AIL stabilize gain:", VALUE, 0x85, nil, 0, 200, "%"},
{"ELE2 direction:", COMBO, 0x9B, nil, { "Normal", "Invers" }, { 255, 0 } }, {"ELE stabilize gain:", VALUE, 0x86, nil, 0, 200, "%"},
{"AIL stabilize gain:", VALUE, 0x85, nil, 0, 200, "%"}, {"RUD stabilize gain:", VALUE, 0x87, nil, 0, 200, "%"},
{"ELE stabilize gain:", VALUE, 0x86, nil, 0, 200, "%"}, {"AIL auto level gain:", VALUE, 0x88, nil, 0, 200, "%"},
{"RUD stabilize gain:", VALUE, 0x87, nil, 0, 200, "%"}, {"ELE auto level gain:", VALUE, 0x89, nil, 0, 200, "%"},
{"AIL auto level gain:", VALUE, 0x88, nil, 0, 200, "%"}, {"ELE upright gain:", VALUE, 0x8C, nil, 0, 200, "%"},
{"ELE auto level gain:", VALUE, 0x89, nil, 0, 200, "%"}, {"RUD upright gain:", VALUE, 0x8D, nil, 0, 200, "%"},
{"ELE upright gain:", VALUE, 0x8C, nil, 0, 200, "%"}, {"AIL crab gain:", VALUE, 0x8E, nil, 0, 200, "%"},
{"RUD upright gain:", VALUE, 0x8D, nil, 0, 200, "%"}, {"RUD crab gain:", VALUE, 0x90, nil, 0, 200, "%"},
{"AIL crab gain:", VALUE, 0x8E, nil, 0, 200, "%"}, {"AIL auto angle offset:", VALUE, 0x91, nil, -20, 20, "%", 0x6C},
{"RUD crab gain:", VALUE, 0x90, nil, 0, 200, "%"}, {"ELE auto angle offset:", VALUE, 0x92, nil, -20, 20, "%", 0x6C},
{"AIL auto angle offset:", VALUE, 0x91, nil, -20, 20, "%", 0x6C}, {"ELE upright angle offset:", VALUE, 0x95, nil, -20, 20, "%", 0x6C},
{"ELE auto angle offset:", VALUE, 0x92, nil, -20, 20, "%", 0x6C}, {"RUD upright angle offset:", VALUE, 0x96, nil, -20, 20, "%", 0x6C},
{"ELE upright angle offset:", VALUE, 0x95, nil, -20, 20, "%", 0x6C}, {"AIL crab angle offset:", VALUE, 0x97, nil, -20, 20, "%", 0x6C},
{"RUD upright angle offset:", VALUE, 0x96, nil, -20, 20, "%", 0x6C}, {"RUD crab angle offset:", VALUE, 0x99, nil, -20, 20, "%", 0x6C},
{"AIL crab angle offset:", VALUE, 0x97, nil, -20, 20, "%", 0x6C}, }
{"RUD crab angle offset:", VALUE, 0x99, nil, -20, 20, "%", 0x6C},
} -- Change display attribute to current field
local function addField(step)
local calibrationFields = { local field = fields[current]
{"X:", VALUE, 0x9E, 0, -100, 100, "%"}, local min, max
{"Y:", VALUE, 0x9F, 0, -100, 100, "%"}, if field[2] == VALUE then
{"Z:", VALUE, 0xA0, 0, -100, 100, "%"} min = field[5]
} max = field[6]
elseif field[2] == COMBO then
-- Change display attribute to current field min = 0
local function addField(step) max = #(field[5]) - 1
local field = fields[current] end
local min, max if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then
if field[2] == VALUE then field[4] = field[4] + step
min = field[5] end
max = field[6] end
elseif field[2] == COMBO then
min = 0 -- Select the next or previous page
max = #(field[5]) - 1 local function selectPage(step)
end page = 1 + ((page + step - 1 + #pages) % #pages)
if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then refreshIndex = 0
field[4] = field[4] + step pageOffset = 0
end end
end
-- Select the next or previous editable field
-- Select the next or previous page local function selectField(step)
local function selectPage(step) current = 1 + ((current + step - 1 + #fields) % #fields)
page = 1 + ((page + step - 1 + #pages) % #pages) if current > 7 + pageOffset then
refreshIndex = 0 pageOffset = current - 7
calibrationStep = 0 elseif current <= pageOffset then
pageOffset = 0 pageOffset = current - 1
end end
end
-- Select the next or previous editable field
local function selectField(step) local function drawProgressBar()
current = 1 + ((current + step - 1 + #fields) % #fields) local width = (140 * refreshIndex) / #fields
if current > 7 + pageOffset then lcd.drawRectangle(30, 1, 144, 6)
pageOffset = current - 7 lcd.drawFilledRectangle(32, 3, width, 2);
elseif current <= pageOffset then end
pageOffset = current - 1
end -- Redraw the current page
end local function redrawFieldsPage()
lcd.clear()
local function drawProgressBar() lcd.drawScreenTitle("S6R", page, #pages)
local width = (140 * refreshIndex) / #fields
lcd.drawRectangle(30, 1, 144, 6) if refreshIndex < #fields then
lcd.drawFilledRectangle(32, 3, width, 2); drawProgressBar()
end end
-- Redraw the current page for index = 1, 7, 1 do
local function redrawFieldsPage() local field = fields[pageOffset+index]
lcd.clear() if field == nil then
lcd.drawScreenTitle("S6R", page, #pages) break
end
if refreshIndex < #fields then
drawProgressBar() local attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0
end
lcd.drawText(0, 1+8*index, field[1])
for index = 1, 7, 1 do
local field = fields[pageOffset+index] if field[4] == nil then
if field == nil then lcd.drawText(COLUMN_2, 1+8*index, "---", attr)
break else
end if field[2] == VALUE then
lcd.drawNumber(COLUMN_2, 1+8*index, field[4], LEFT + attr)
local attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0 elseif field[2] == COMBO then
if field[4] >= 0 and field[4] < #(field[5]) then
lcd.drawText(0, 1+8*index, field[1]) lcd.drawText(COLUMN_2, 1+8*index, field[5][1+field[4]], attr)
end
if field[4] == nil then end
lcd.drawText(COLUMN_2, 1+8*index, "---", attr) end
else end
if field[2] == VALUE then end
lcd.drawNumber(COLUMN_2, 1+8*index, field[4], LEFT + attr)
elseif field[2] == COMBO then local function telemetryRead(field)
if field[4] >= 0 and field[4] < #(field[5]) then return sportTelemetryPush(0x1B, 0x30, 0x0C30, field)
lcd.drawText(COLUMN_2, 1+8*index, field[5][1+field[4]], attr) end
end
end local function telemetryWrite(field, value)
end return sportTelemetryPush(0x1B, 0x31, 0x0C30, field + value*256)
end end
end
local telemetryPopTimeout = 0
local function telemetryRead(field) local function refreshNext()
return sportTelemetryPush(0x1B, 0x30, 0x0C30, field) if refreshState == 0 then
end if #modifications > 0 then
telemetryWrite(modifications[1][1], modifications[1][2])
local function telemetryWrite(field, value) modifications[1] = nil
return sportTelemetryPush(0x1B, 0x31, 0x0C30, field + value*256) elseif refreshIndex < #fields then
end local field = fields[refreshIndex + 1]
if telemetryRead(field[3]) == true then
local telemetryPopTimeout = 0 refreshState = 1
local function refreshNext() telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms
if refreshState == 0 then end
if calibrationState == 1 then end
if telemetryWrite(0x9D, calibrationStep) == true then elseif refreshState == 1 then
refreshState = 1 local physicalId, primId, dataId, value = sportTelemetryPop()
calibrationState = 2 if physicalId == 0x1A and primId == 0x32 and dataId == 0x0C30 then
telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms local fieldId = value % 256
end local field = fields[refreshIndex + 1]
elseif #modifications > 0 then if fieldId == field[3] then
telemetryWrite(modifications[1][1], modifications[1][2]) local value = math.floor(value / 256)
modifications[1] = nil if field[3] >= 0x9E and field[3] <= 0xA0 then
elseif refreshIndex < #fields then local b1 = value % 256
local field = fields[refreshIndex + 1] local b2 = math.floor(value / 256)
if telemetryRead(field[3]) == true then value = b1*256 + b2
refreshState = 1 value = value - bit32.band(value, 0x8000) * 2
telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms end
end if field[2] == COMBO and #field == 6 then
end for index = 1, #(field[6]), 1 do
elseif refreshState == 1 then if value == field[6][index] then
local physicalId, primId, dataId, value = sportTelemetryPop() value = index - 1
if physicalId == 0x1A and primId == 0x32 and dataId == 0x0C30 then break
local fieldId = value % 256 end
if calibrationState == 2 then end
if fieldId == 0x9D then elseif field[2] == VALUE and #field == 8 then
refreshState = 0 value = value - field[8] + field[5]
calibrationState = 0 end
calibrationStep = (calibrationStep + 1) % 7 fields[refreshIndex + 1][4] = value
end refreshIndex = refreshIndex + 1
else refreshState = 0
local field = fields[refreshIndex + 1] end
if fieldId == field[3] then elseif getTime() > telemetryPopTimeout then
local value = math.floor(value / 256) refreshState = 0
if field[3] >= 0x9E and field[3] <= 0xA0 then end
local b1 = value % 256 end
local b2 = math.floor(value / 256) end
value = b1*256 + b2
value = value - bit32.band(value, 0x8000) * 2 local function updateField(field)
end local value = field[4]
if field[2] == COMBO and #field == 6 then if field[2] == COMBO and #field == 6 then
for index = 1, #(field[6]), 1 do value = field[6][1+value]
if value == field[6][index] then elseif field[2] == VALUE and #field == 8 then
value = index - 1 value = value + field[8] - field[5]
break end
end modifications[#modifications+1] = { field[3], value }
end end
elseif field[2] == VALUE and #field == 8 then
value = value - field[8] + field[5] -- Main
end local function runFieldsPage(event)
fields[refreshIndex + 1][4] = value if event == EVT_EXIT_BREAK then -- exit script
refreshIndex = refreshIndex + 1 return 2
refreshState = 0 elseif event == EVT_ENTER_BREAK then -- toggle editing/selecting current field
end if fields[current][4] ~= nil then
end edit = not edit
elseif getTime() > telemetryPopTimeout then if edit == false then
refreshState = 0 updateField(fields[current])
calibrationState = 0 end
end end
end elseif edit then
end if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then
addField(1)
local function updateField(field) elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
local value = field[4] addField(-1)
if field[2] == COMBO and #field == 6 then end
value = field[6][1+value] else
elseif field[2] == VALUE and #field == 8 then if event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT then
value = value + field[8] - field[5] selectField(1)
end elseif event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT then
modifications[#modifications+1] = { field[3], value } selectField(-1)
end end
end
-- Main redrawFieldsPage()
local function runFieldsPage(event) return 0
if event == EVT_EXIT_BREAK then -- exit script end
return 2
elseif event == EVT_ENTER_BREAK then -- toggle editing/selecting current field local wingBitmaps = { "bmp/plane.bmp", "bmp/delta.bmp", "bmp/vtail.bmp" }
if fields[current][4] ~= nil then local mountBitmaps = { "bmp/horz.bmp", "bmp/horz-r.bmp", "bmp/vert.bmp", "bmp/vert-r.bmp" }
edit = not edit
if edit == false then local function runConfigPage(event)
updateField(fields[current]) fields = configFields
end local result = runFieldsPage(event)
end if fields[1][4] ~= nil then
elseif edit then lcd.drawPixmap(20, 28, wingBitmaps[1 + fields[1][4]])
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then end
addField(1) if fields[2][4] ~= nil then
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then lcd.drawPixmap(128, 28, mountBitmaps[1 + fields[2][4]])
addField(-1) end
end return result
else end
if event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT then
selectField(1) local function runSettingsPage(event)
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT then fields = settingsFields
selectField(-1) return runFieldsPage(event)
end end
end
redrawFieldsPage() -- Init
return 0 local function init()
end current, edit, refreshState, refreshIndex = 1, false, 0, 0
pages = {
local wingBitmaps = { "bmp/plane.bmp", "bmp/delta.bmp", "bmp/vtail.bmp" } runConfigPage,
local mountBitmaps = { "bmp/horz.bmp", "bmp/horz-r.bmp", "bmp/vert.bmp", "bmp/vert-r.bmp" } runSettingsPage,
}
local function runConfigPage(event) end
fields = configFields
local result = runFieldsPage(event) -- Main
if fields[1][4] ~= nil then local function run(event)
lcd.drawPixmap(20, 28, wingBitmaps[1 + fields[1][4]]) if event == nil then
end error("Cannot be run as a model script!")
if fields[2][4] ~= nil then return 2
lcd.drawPixmap(128, 28, mountBitmaps[1 + fields[2][4]]) elseif event == EVT_PAGE_BREAK then
end selectPage(1)
return result elseif event == EVT_PAGE_LONG then
end killEvents(event);
selectPage(-1)
local function runSettingsPage(event) end
fields = settingsFields
return runFieldsPage(event) local result = pages[page](event)
end refreshNext()
local calibrationPositions = { "up", "down", "left", "right", "forward", "back" } return result
end
local function runCalibrationPage(event)
fields = calibrationFields return { init=init, run=run }
if refreshIndex == #fields then
refreshIndex = 0
end
lcd.clear()
lcd.drawScreenTitle("S6R", page, #pages)
if(calibrationStep < 6) then
local position = calibrationPositions[1 + calibrationStep]
lcd.drawText(0, 9, "Turn the S6R " .. position, 0)
lcd.drawPixmap(10, 19, "bmp/"..position .. ".bmp")
for index = 1, 3, 1 do
local field = fields[index]
lcd.drawText(80, 12+10*index, field[1], 0)
lcd.drawNumber(90, 12+10*index, field[4]/10, LEFT+PREC2)
end
local attr = calibrationState == 0 and INVERS or 0
lcd.drawText(0, 56, "Press [Enter] when ready", attr)
else
lcd.drawText(0, 9, "Calibration completed", 0)
lcd.drawText(0, 56, "Press [Enter] when ready", attr)
end
if event == EVT_ENTER_BREAK then
calibrationState = 1
elseif event == EVT_EXIT_BREAK then
if calibrationStep > 0 then
calibrationStep = 0
else
return 2
end
end
return 0
end
-- Init
local function init()
current, edit, refreshState, refreshIndex = 1, false, 0, 0
pages = {
runConfigPage,
runSettingsPage,
runCalibrationPage
}
end
-- Main
local function run(event)
if event == nil then
error("Cannot be run as a model script!")
return 2
elseif event == EVT_PAGE_BREAK then
selectPage(1)
elseif event == EVT_PAGE_LONG then
killEvents(event);
selectPage(-1)
end
local result = pages[page](event)
refreshNext()
return result
end
return { init=init, run=run }
@@ -0,0 +1,260 @@
local VALUE = 0
local COMBO = 1
local COLUMN_2 = 150
local edit = false
local page = 1
local current = 1
local refreshState = 0
local refreshIndex = 0
local calibrationState = 0
local pageOffset = 0
local calibrationStep = 0
local pages = {}
local fields = {}
local modifications = {}
local calibrationFields = {
{"X:", VALUE, 0x9E, 0, -100, 100, "%"},
{"Y:", VALUE, 0x9F, 0, -100, 100, "%"},
{"Z:", VALUE, 0xA0, 0, -100, 100, "%"}
}
local function drawProgressBar()
local width = (140 * refreshIndex) / #fields
lcd.drawRectangle(30, 1, 144, 6)
lcd.drawFilledRectangle(32, 3, width, 2);
end
-- Select the next or previous page
local function selectPage(step)
page = 1 + ((page + step - 1 + #pages) % #pages)
refreshIndex = 0
calibrationStep = 0
pageOffset = 0
end
-- Draw initial warning page
local function runWarningPage(event)
lcd.clear()
lcd.drawScreenTitle("S6R", page, #pages)
lcd.drawText(0, 10, "Warning: this will start S6R calibration", SMLSIZE)
lcd.drawText(0, 20, "This need to be run only once. You need a S6R,", SMLSIZE)
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
selectPage(1)
return 0
elseif event == EVT_EXIT_BREAK then
return 2
end
return 0
end
-- Redraw the current page
local function redrawFieldsPage()
lcd.clear()
lcd.drawScreenTitle("S6R", page, #pages)
if refreshIndex < #fields then
drawProgressBar()
end
for index = 1, 7, 1 do
local field = fields[pageOffset+index]
if field == nil then
break
end
local attr = current == (pageOffset+index) and ((edit == true and BLINK or 0) + INVERS) or 0
lcd.drawText(0, 1+8*index, field[1])
if field[4] == nil then
lcd.drawText(COLUMN_2, 1+8*index, "---", attr)
else
if field[2] == VALUE then
lcd.drawNumber(COLUMN_2, 1+8*index, field[4], LEFT + attr)
elseif field[2] == COMBO then
if field[4] >= 0 and field[4] < #(field[5]) then
lcd.drawText(COLUMN_2, 1+8*index, field[5][1+field[4]], attr)
end
end
end
end
end
local function telemetryRead(field)
return sportTelemetryPush(0x1B, 0x30, 0x0C30, field)
end
local function telemetryWrite(field, value)
return sportTelemetryPush(0x1B, 0x31, 0x0C30, field + value*256)
end
local telemetryPopTimeout = 0
local function refreshNext()
if refreshState == 0 then
if calibrationState == 1 then
if telemetryWrite(0x9D, calibrationStep) == true then
refreshState = 1
calibrationState = 2
telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms
end
elseif #modifications > 0 then
telemetryWrite(modifications[1][1], modifications[1][2])
modifications[1] = nil
elseif refreshIndex < #fields then
local field = fields[refreshIndex + 1]
if telemetryRead(field[3]) == true then
refreshState = 1
telemetryPopTimeout = getTime() + 80 -- normal delay is 500ms
end
end
elseif refreshState == 1 then
local physicalId, primId, dataId, value = sportTelemetryPop()
if physicalId == 0x1A and primId == 0x32 and dataId == 0x0C30 then
local fieldId = value % 256
if calibrationState == 2 then
if fieldId == 0x9D then
refreshState = 0
calibrationState = 0
calibrationStep = (calibrationStep + 1) % 7
end
else
local field = fields[refreshIndex + 1]
if fieldId == field[3] then
local value = math.floor(value / 256)
if field[3] >= 0x9E and field[3] <= 0xA0 then
local b1 = value % 256
local b2 = math.floor(value / 256)
value = b1*256 + b2
value = value - bit32.band(value, 0x8000) * 2
end
if field[2] == COMBO and #field == 6 then
for index = 1, #(field[6]), 1 do
if value == field[6][index] then
value = index - 1
break
end
end
elseif field[2] == VALUE and #field == 8 then
value = value - field[8] + field[5]
end
fields[refreshIndex + 1][4] = value
refreshIndex = refreshIndex + 1
refreshState = 0
end
end
elseif getTime() > telemetryPopTimeout then
refreshState = 0
calibrationState = 0
end
end
end
local function updateField(field)
local value = field[4]
if field[2] == COMBO and #field == 6 then
value = field[6][1+value]
elseif field[2] == VALUE and #field == 8 then
value = value + field[8] - field[5]
end
modifications[#modifications+1] = { field[3], value }
end
-- Main
local function runFieldsPage(event)
if event == EVT_EXIT_BREAK then -- exit script
return 2
elseif event == EVT_ENTER_BREAK then -- toggle editing/selecting current field
if fields[current][4] ~= nil then
edit = not edit
if edit == false then
updateField(fields[current])
end
end
elseif edit then
if event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT or event == EVT_PLUS_REPT then
addField(1)
elseif event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT or event == EVT_MINUS_REPT then
addField(-1)
end
else
if event == EVT_MINUS_FIRST or event == EVT_ROT_LEFT then
selectField(1)
elseif event == EVT_PLUS_FIRST or event == EVT_ROT_RIGHT then
selectField(-1)
end
end
redrawFieldsPage()
return 0
end
local calibrationPositions = { "up", "down", "left", "right", "forward", "back" }
local function runCalibrationPage(event)
fields = calibrationFields
if refreshIndex == #fields then
refreshIndex = 0
end
lcd.clear()
lcd.drawScreenTitle("S6R", page, #pages)
if(calibrationStep < 6) then
local position = calibrationPositions[1 + calibrationStep]
lcd.drawText(0, 9, "Turn the S6R " .. position, 0)
lcd.drawPixmap(10, 19, "bmp/"..position .. ".bmp")
for index = 1, 3, 1 do
local field = fields[index]
lcd.drawText(80, 12+10*index, field[1], 0)
lcd.drawNumber(90, 12+10*index, field[4]/10, LEFT+PREC2)
end
local attr = calibrationState == 0 and INVERS or 0
lcd.drawText(0, 56, "Press [Enter] when ready", attr)
else
lcd.drawText(0, 9, "Calibration completed", 0)
lcd.drawText(0, 56, "Press [Enter] when ready", attr)
end
if event == EVT_ENTER_BREAK then
calibrationState = 1
elseif event == EVT_EXIT_BREAK then
if calibrationStep > 0 then
calibrationStep = 0
else
return 2
end
end
return 0
end
-- Init
local function init()
current, edit, refreshState, refreshIndex = 1, false, 0, 0
pages = {
runWarningPage,
runCalibrationPage
}
end
-- Main
local function run(event)
if event == nil then
error("Cannot be run as a model script!")
return 2
elseif event == EVT_PAGE_BREAK then
selectPage(1)
elseif event == EVT_PAGE_LONG then
killEvents(event);
selectPage(-1)
end
local result = pages[page](event)
refreshNext()
return result
end
return { init=init, run=run }

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB