Merge against latest 2.3

This commit is contained in:
Bertrand Songis
2019-09-17 13:28:42 +02:00
247 changed files with 35085 additions and 42445 deletions
@@ -320,7 +320,7 @@ local function fieldCommandLoad(field, data, offset)
field.status = data[offset]
field.timeout = data[offset+1]
field.info, offset = fieldGetString(data, offset+2)
if field.status < 2 or field.status > 3 then
if field.status == 0 then
fieldPopup = nil
end
end
@@ -406,8 +406,7 @@ local function refreshNext()
local time = getTime()
if fieldPopup then
if time > fieldTimeout then
local frame = { deviceId, 0xEA, fieldPopup.id }
crossfireTelemetryPush(0x2D, frame)
crossfireTelemetryPush(0x2D, { deviceId, 0xEA, fieldPopup.id, 6 })
fieldTimeout = time + fieldPopup.timeout
end
elseif time > fieldTimeout and not edit then
@@ -435,7 +434,7 @@ local function runDevicePage(event)
else
return "crossfire.lua"
end
elseif event == EVT_VIRTUAL_EXIT then -- toggle editing/selecting current field
elseif event == EVT_VIRTUAL_ENTER then -- toggle editing/selecting current field
local field = getField(lineIndex)
if field.name then
if field.type == 10 then
+515
View File
@@ -0,0 +1,515 @@
---- #########################################################################
---- # #
---- # Copyright (C) OpenTX #
-----# #
---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html #
---- # #
---- # This program is free software; you can redistribute it and/or modify #
---- # it under the terms of the GNU General Public License version 2 as #
---- # published by the Free Software Foundation. #
---- # #
---- # This program is distributed in the hope that it will be useful #
---- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
---- # GNU General Public License for more details. #
---- # #
---- #########################################################################
local version = "v1.1"
local VALUE = 0
local COMBO = 1
local FLPOI = 2
local edit = false
local page = 1
local current = 1 --row
local refreshState = 0
local refreshIndex = 0
local refreshIndex3 = 0
local pageOffset = 0
local pages = {}
local fields = {}
local modifications = {}
local thistime = getTime()
local lastTime = thistime
local margin = 1
local spacing = 8
local configFields = {}
local counter = 0
local appId = 0
local function drawScreenTitle(title,page, pages)
if math.fmod(math.floor(getTime()/100),10) == 0 then
title = version
end
if LCD_W == 480 then
lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR)
lcd.drawText(1, 5, title, MENU_TITLE_COLOR)
lcd.drawText(LCD_W-40, 5, page.."/"..pages, MENU_TITLE_COLOR)
else
lcd.drawScreenTitle(title, page, pages)
end
end
local interfaceconfig = {
{"Sensor group select", VALUE, appId, nil, 0, 15},
}
local settingsFields = {
{"Software version", FLPOT, 0x0c, nil, 1, 100 },
{"Physical ID", VALUE, 0x01, nil, 0, 26 },
{"Application IDgroup", VALUE, 0x0D, nil, 0, 15 },
{"Data rate(*100ms)", VALUE, 0x22, nil, 1, 255 },
}
local telemetryFields = {
{"TEMP1(C/F)", VALUE, 0x90, nil, -30, 600},
{"TEMP2(C/F)", VALUE, 0x91, nil, -30, 600},
{"SPEED(r/min)", VALUE, 0x92, nil, 0, 100000},
{"Residual Volume(mL)", VALUE, 0x93, nil, 0, 60000},
{"Residual Percent(%)", VALUE, 0x94, nil, 0, 100},
{"FLOW(mL/min)", VALUE, 0x95, nil, 0, 2000},
{"Max Flow(mL/min)", VALUE, 0x96, nil, 0, 2000},
{"Avg Flow(mL/min)", VALUE, 0x97, nil, 0, 2000},
}
-- Change display attribute to current field
local function addField(step)
local field = fields[current]
local min, max
if field[2] == VALUE then
min = field[5]
max = field[6]
elseif field[2] == COMBO then
min = 0
max = #(field[5]) - 1
end
if field[2] ~= FLPOT then --only read ?
if field[2] == VALUE and field[6] > 256 then
if field[4] > 1000 then
step = step * 50
field[4] = math.floor(field[4]/50)
field[4] = field[4] *50
elseif field[4] > 500 then
step = step * 20
field[4] = math.floor(field[4]/20)
field[4] = field[4] *20
elseif field[4] > 200 then
step = step * 10
field[4] = math.floor(field[4]/10)
field[4] = field[4] *10
else
step = step * 1
field[4] = math.floor(field[4]/1)
field[4] = field[4] *1
end
end
if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then
field[4] = field[4] + step
end
else
field[4] = field[4]
end
end
-- Select the next or previous page
local function selectPage(step)
page = 1 + ((page + step - 1 + #pages) % #pages)
refreshIndex = 0
pageOffset = 0
end
-- Select the next or previous editable field
local function selectField(step)
current = current + step
if current > #fields then
current = #fields
elseif current < 1 then
current = 1
end
if current > 7 + pageOffset then
pageOffset = current - 7
elseif current <= pageOffset then
pageOffset = current - 1
end
end
local function drawProgressBar()
if LCD_W == 480 then
local width = (300 * refreshIndex) / #fields
lcd.drawRectangle(100, 10, 300, 6)
lcd.drawFilledRectangle(102, 13, width, 2);
else
local width = (60 * refreshIndex) / #fields
lcd.drawRectangle(45, 1, 60, 6)
lcd.drawFilledRectangle(47, 3, width, 2);
end
end
-- Redraw the current page
local function redrawFieldsPage()
lcd.clear()
drawScreenTitle("GasSuit", 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(1, margin+ spacing * index, field[1])
if field[4] == nil then
lcd.drawText(LCD_W, margin+ spacing * index, "---", attr + RIGHT)
else
if field[2] == VALUE then
if (field[3] == 0x90 or field[3] == 0x91) and field[4] == 500 then
lcd.drawText(LCD_W, margin+ spacing * index, "---", attr + RIGHT)
else
lcd.drawNumber(LCD_W, margin+ spacing * index, field[4] , attr + RIGHT)
end
elseif field[2] == COMBO then
if field[4] >= 0 and field[4] < #(field[5]) then
lcd.drawText(LCD_W, margin+ spacing * index, field[5][1+field[4]], attr + RIGHT)
end
elseif field[2] == FLPOT then
lcd.drawText(LCD_W, margin+ spacing * index, field[4], attr + RIGHT)
end
end
end
end
local function telemetryRead(fieldx)
return sportTelemetryPush(0x1b, 0x30, appId, fieldx)
end
local function telemetryListen(fieldx)
return sportTelemetryPush(0x1b, 0, 0, 0)
end
local function telemetryWrite(fieldx, valuex)
return sportTelemetryPush(0x1b, 0x31, appId, fieldx + valuex*256)
end
local telemetryPopTimeout = 0
local function refreshNext()
if refreshState == 0 and page ~= 3 then --
if #modifications > 0 then --
if modifications[1][1] ~= 0x0c then
if modifications[1][1] == 0x22 then
modifications[1][2] = modifications[1][2] + 0xf00
end
local modificationstmp = modifications[1][2]
if modifications[1][1] == 0x8a or modifications[1][1] == 0x8b then
if configFields[11][4]== 1 then
modificationstmp = (modifications[1][2] - 32)*10
modificationstmp = math.floor(modificationstmp/18)
end
end
telemetryWrite(modifications[1][1], modificationstmp)
refreshIndex = 0
end
modifications[1] = nil
elseif refreshIndex < #fields then
local field = fields[refreshIndex + 1]
if telemetryRead(field[3]) == true then
refreshState = 1
telemetryPopTimeout = getTime() + 80
end
end
elseif refreshState == 0 and page == 3 then
if #modifications > 0 then
if modifications[1][1] == 0x96 or modifications[1][1] == 0x97 or modifications[1][1] == 0x93 then
telemetryWrite(modifications[1][1], 0)
end
modifications[1] = nil
elseif refreshIndex < #fields then
local field = fields[refreshIndex + 1]
if telemetryRead(field[3]) == true then
refreshState = 1
telemetryPopTimeout = getTime() + 20
end
elseif refreshIndex >= #fields then
refreshIndex = 0
refreshState = 0
end
elseif refreshState == 1 and page ~= 3 then
local physicalId, primId, dataId, value = sportTelemetryPop()
if primId == 0x32 and dataId >= 0x0d00 and dataId <= 0x0d7f then
local fieldId = value % 256
local field = fields[refreshIndex + 1]
if fieldId == field[3] then
local value = math.floor(value / 256)
if field[2] == COMBO then
for index = 1, #(field[6]), 1 do
if value == field[6][index] then
value = index - 1
break
end
end
elseif field[2] == VALUE then
value = value -- - field[8] + field[5]
end
if field[1] == "Software version" then
local flo_string = string.char(value/16%16 + 48).."."..string.char(value%16 + 48)
fields[refreshIndex + 1][4] = flo_string
else
fields[refreshIndex + 1][4] = value
end
refreshIndex = refreshIndex + 1
refreshState = 0
end
elseif getTime() > telemetryPopTimeout then
refreshState = 0
end
elseif refreshState == 1 and page == 3 then
local pageID3 = 0
local physicalId3, primId3, dataId3, value3 = sportTelemetryPop()
if value3 ~= nil then
pageID3 = value3 % 256
value3 = math.floor(value3 / 0x100)
end
if primId3 == 0x32 and value3 ~= nil then
if pageID3 == fields[refreshIndex + 1][3] then
local field = fields[refreshIndex + 1]
if field[2] == COMBO and #field == 6 then
for index = 1, #(field[6]), 1 do
if value3 == field[6][index] then
value3 = index - 1
break
end
end
elseif field[2] == VALUE then
if field[3] == 0x90 or field[3] == 0x91 then
value3 = math.floor(value3 % 0x10000)
if value3 > 0xf000 then
value3 = value3 - 0x10000
end
if configFields[11][4]== 1 and (field[3] == 0x90 or field[3] == 0x91) then
value3 =(value3*18)
value3 = math.floor(value3/10)+32
end
else
value3 = value3
end
end
fields[refreshIndex + 1][4] = value3
refreshIndex = refreshIndex + 1
refreshState = 0
end
elseif getTime() > telemetryPopTimeout then
refreshState = 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 == 6 then
value = value -- + field[8] - field[5]
elseif field[2] == FLPOT then
value = 0
end
modifications[#modifications+1] = {field[3], value}
end
-- Main1
local function runFieldsPage(event)
if event == EVT_VIRTUAL_EXIT then
return 2
elseif event == EVT_VIRTUAL_ENTER then
if fields[current][4] ~= nil then
edit = not edit
if edit == false then
updateField(fields[current])
end
end
elseif edit then
if event == EVT_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REPT then
addField(1)
elseif event == EVT_VIRTUAL_PREVIOUS or event == EVT_VIRTUAL_PREVIOUS_REPT then
addField(-1)
end
else
if event == EVT_VIRTUAL_NEXT then
selectField(1)
elseif event == EVT_VIRTUAL_PREVIOUS then
selectField(-1)
end
end
redrawFieldsPage()
return 0
end
local function runConfigPage(event)
fields = configFields
local result = runFieldsPage(event)
return result
end
local function runSettingsPage(event)
fields = settingsFields
return runFieldsPage(event)
end
local function runTelemetryPage(event)
fields = telemetryFields
return runFieldsPage(event)
end
-- Init
local function init()
current, edit, refreshState, refreshIndex = 1, false, 0, 0
if LCD_W == 480 then
margin = 10
spacing = 20
end
if LCD_W == 128 then
configFields = {
{"CDI off speed limit", VALUE, 0x81, nil, 10,10000}, -- 1
{"Milliliter per pulse", VALUE, 0x80, nil, 1, 2000}, -- 2
{"Volume", VALUE, 0x83, nil, 10,60000}, -- 3
-- {"Flow trigger", VALUE, 0x84, nil, 5, 50 },
-- {"Flow Reset", COMBO, 0x85, nil, { "ON", "OFF" }, {1 , 0}},
{"Auto Reset", COMBO, 0x8d, nil, { "ON", "OFF" }, {0 , 1}}, -- 4
{"Reset settings", COMBO, 0x86, nil,{ "YES", "NO" }, {1 , 0} }, -- 5
{"Volume alarm(%)", VALUE, 0x87, nil, 0, 90 }, -- 6
{"Max.Flow alarm", VALUE, 0x88, nil, 0, 2000 }, -- 7
{"Over speed alarm", VALUE, 0x89, nil, 0, 10000 }, -- 8
{"Over temp1 alarm", VALUE, 0x8a, nil, 0, 600 }, -- 9
{"Over temp2 alarm", VALUE, 0x8b, nil, 0, 600 }, -- 10
{"Temperature C/F", COMBO, 0x8c, nil,{ "C", "F" }, {0 , 1} }, -- 11
}
else
configFields = {
{"CDI off speed limit(*100RPM)", VALUE, 0x81, nil, 10,10000},
{"Milliliter per pulse(*0.001mL/pul)", VALUE, 0x80, nil, 1, 2000},
{"Volume(mL)", VALUE, 0x83, nil, 10,60000},
-- {"Flow trigger(mL/min)", VALUE, 0x84, nil, 5, 50 },
-- {"Flow Reset", COMBO, 0x85, nil, { "ON", "OFF" }, {1 , 0}},
{"Auto Reset", COMBO, 0x8d, nil, { "ON", "OFF" }, {0 , 1}},
{"Reset to factory settings", COMBO, 0x86, nil,{ "YES", "NO" }, {1 , 0} },
{"Volume alarm(%)", VALUE, 0x87, nil, 0, 90 },
{"Max.Flow alarm(mL/min)", VALUE, 0x88, nil, 0, 2000 },
{"Over speed alarm(*100RPM)", VALUE, 0x89, nil, 0, 10000 },
{"Over temperature1 alarm(C/F)", VALUE, 0x8a, nil, 0, 600 },
{"Over temperature2 alarm(C/F)", VALUE, 0x8b, nil, 0, 600 },
{"Temperature Celsius/Fahrenheit", COMBO, 0x8c, nil,{ "C", "F" }, {0 , 1} },
}
end
pages = {
runConfigPage,
runSettingsPage,
runTelemetryPage,
}
-- Warning : GaSuite tool requires Temp2 to be connected and discovered for script to work
for index = 1, 40, 1 do
local sensor = model.getSensor(index)
if sensor ~= nil and sensor.id >= 0x0d10 and sensor.id <= 0x0d1f then
appId = sensor.id
break
end
end
if appId == 0 then
error("No GasSuit sensor in this model!")
end
end
local function background()
local tonefrq,tonelength,tonepause
thistime = getTime()
lastTime = thistime
refreshNext()
if page == 3 then --alarm
local alarmnum = 0
if fields[3][4] ~= nil and configFields[9][4] ~= nil then
local speedtest = fields[3][4]
local speedover = configFields[9][4]*100
if speedtest >= speedover then
tonefrq = 800 + math.max(0,math.floor((speedtest - speedover)/10))
tonelength = 50 + math.max(0,(150 - math.floor((speedtest - speedover)/10)))
tonepause = tonelength
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if fields[5][4] ~= nil and configFields[7][4] ~= nil then
local Residualtest = fields[5][4]
local Residualline = configFields[6][4]
if Residualtest < Residualline then
tonefrq = 400
tonelength = 100
tonepause = 1000 + math.floor( Residualline - Residualtest )*30
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if fields[6][4] ~= nil and configFields[8][4] ~= nil then
local Flowtest = fields[6][4]
local Flowover = configFields[7][4]
if Flowtest > Flowover then
tonefrq = 400
tonelength = 100
tonepause = 200
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if fields[1][4] ~= nil and configFields[10][4] ~= nil then
local temp1test = fields[1][4] --
local temp1over = configFields[9][4]
if temp1test > temp1over and (temp1test ~= 500 and temp1test ~= 932) then
tonefrq = 2000
tonelength = 100
tonepause = 900
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if fields[2][4] ~= nil and configFields[11][4] ~= nil then
local temp2test = fields[2][4]
local temp2over = configFields[10][4]
if temp2test > temp2over and (temp2test ~= 500 and temp2test ~= 932) then
tonefrq = 2000
tonelength = 300
tonepause = 700
playTone(tonefrq, tonelength, tonepause, PLAY_BACKGROUND,10)
alarmnum = alarmnum + 1
end
end
if alarmnum > 1 then
playTone(2000, 100, 100, PLAY_BACKGROUND,10)
end
alarmnum = 0
end
end
local function run(event)
if event == nil then
error("Cannot be run as a sensor script!")
return 2
elseif event == EVT_VIRTUAL_NEXT_PAGE then
selectPage(1)
elseif event == EVT_VIRTUAL_PREVIOUS_PAGE then
killEvents(event);
selectPage(-1)
end
local result = pages[page](event)
if page ~= 3 then
refreshNext()
end
background()
return result
end
return { init=init, background=background, run=run }
@@ -0,0 +1,289 @@
---- #########################################################################
---- # #
---- # Copyright (C) OpenTX #
-----# #
---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html #
---- # #
---- # This program is free software; you can redistribute it and/or modify #
---- # it under the terms of the GNU General Public License version 2 as #
---- # published by the Free Software Foundation. #
---- # #
---- # This program is distributed in the hope that it will be useful #
---- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
---- # GNU General Public License for more details. #
---- # #
---- #########################################################################
local version = "v1.2"
local VALUE = 0
local COMBO = 1
local edit = false
local page = 1
local current = 1 --row
local refreshState = 0
local refreshIndex = 0
local pageOffset = 0
local pages = {}
local fields = {}
local modifications = {}
local margin = 1
local spacing = 8
local appId = 0
local function drawScreenTitle(title,page, pages)
if math.fmod(math.floor(getTime()/100),10) == 0 then
title = version
end
if LCD_W == 480 then
lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR)
lcd.drawText(1, 5, title, MENU_TITLE_COLOR)
lcd.drawText(LCD_W-40, 5, page.."/"..pages, MENU_TITLE_COLOR)
else
lcd.drawScreenTitle(title, page, pages)
end
end
local settingsFields = {
{"SBEC OUTPUT (V)", VALUE, 0x80, nil, 50, 84 },
{"Physical ID", VALUE, 0x01, nil, 0, 26 },
{"Application IDgroup", VALUE, 0x0D, nil, 0, 15 },
{"Data rate(*100ms)", VALUE, 0x22, nil, 1, 255 },
}
-- Change display attribute to current field
local function addField(step)
local field = fields[current]
local min, max
if field[2] == VALUE then
min = field[5]
max = field[6]
elseif field[2] == COMBO then
min = 0
max = #(field[5]) - 1
end
if field[2] ~= FLPOT then --only read ?
if field[2] == VALUE and field[6] > 256 then
if field[4] > 1000 then
step = step * 50
field[4] = math.floor(field[4]/50)
field[4] = field[4] *50
elseif field[4] > 500 then
step = step * 20
field[4] = math.floor(field[4]/20)
field[4] = field[4] *20
elseif field[4] > 200 then
step = step * 10
field[4] = math.floor(field[4]/10)
field[4] = field[4] *10
else
step = step * 1
field[4] = math.floor(field[4]/1)
field[4] = field[4] *1
end
end
if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then
field[4] = field[4] + step
end
else
field[4] = field[4]
end
end
-- Select the next or previous editable field
local function selectField(step)
current = current + step
if current > #fields then
current = #fields
elseif current < 1 then
current = 1
end
if current > 7 + pageOffset then
pageOffset = current - 7
elseif current <= pageOffset then
pageOffset = current - 1
end
end
local function drawProgressBar()
if LCD_W == 480 then
local width = (300 * refreshIndex) / #fields
lcd.drawRectangle(100, 10, 300, 6)
lcd.drawFilledRectangle(102, 13, width, 2);
else
local width = (60 * refreshIndex) / #fields
lcd.drawRectangle(45, 1, 60, 6)
lcd.drawFilledRectangle(47, 3, width, 2);
end
end
-- Redraw the current page
local function redrawFieldsPage()
lcd.clear()
drawScreenTitle("SBEC", 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(1, margin+ spacing * index, field[1])
if field[4] == nil then
lcd.drawText(LCD_W, margin+ spacing * index, "---", attr + RIGHT)
else
if field[2] == VALUE then
if field[3] == 0x80 then
lcd.drawNumber(LCD_W, margin+ spacing * index, field[4] , attr + RIGHT + PREC1)
else
lcd.drawNumber(LCD_W, margin+ spacing * index, field[4] , attr + RIGHT)
end
end
end
end
end
local function telemetryRead(fieldx)
return sportTelemetryPush(0x17, 0x30, appId, fieldx)
end
local function telemetryIdle(field)
return sportTelemetryPush(0x17, 0x21, appId, field)
end
local function telemetryUnIdle(field)
return sportTelemetryPush(0x17, 0x20, appId, field)
end
local function telemetryWrite(fieldx, valuex)
return sportTelemetryPush(0x17, 0x31, appId, fieldx + valuex*256)
end
local telemetryPopTimeout = 0
local function refreshNext()
if refreshState == 0 then
if #modifications > 0 then
local modificationstmp = modifications[1][2]
telemetryWrite(modifications[1][1], modificationstmp)
refreshIndex = 0
modifications[1] = nil
elseif refreshIndex < #fields then
local field = fields[refreshIndex + 1]
if telemetryRead(field[3]) == true then
refreshState = 1
telemetryPopTimeout = getTime() + 80
end
end
elseif refreshState == 1 then
local physicalId, primId, dataId, value = sportTelemetryPop()
if primId == 0x32 and dataId == appId then
local fieldId = value % 256
local field = fields[refreshIndex + 1]
if fieldId == field[3] then
local value = math.floor(value / 256)
if field[2] == VALUE then
value = value
end
fields[refreshIndex + 1][4] = value
refreshIndex = refreshIndex + 1
refreshState = 0
end
elseif getTime() > telemetryPopTimeout then
refreshState = 0
end
end
end
local function updateField(field)
local value = field[4]
if field[2] == VALUE and #field == 6 then
value = value
end
modifications[#modifications+1] = {field[3], value}
end
-- Main1
local function runFieldsPage(event)
if event == EVT_VIRTUAL_EXIT then
telemetryUnIdle(0x80)
return 2
elseif event == EVT_VIRTUAL_ENTER then
if fields[current][4] ~= nil then
edit = not edit
if edit == false then
updateField(fields[current])
end
end
elseif edit then
if event == EVT_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REPT then
addField(1)
elseif event == EVT_VIRTUAL_PREVIOUS or event == EVT_VIRTUAL_PREVIOUS_REPT then
addField(-1)
end
else
if event == EVT_VIRTUAL_NEXT then
selectField(1)
elseif event == EVT_VIRTUAL_PREVIOUS then
selectField(-1)
end
end
redrawFieldsPage()
return 0
end
local function runSettingsPage(event)
fields = settingsFields
return runFieldsPage(event)
end
-- Init
local function init()
current, edit, refreshState, refreshIndex = 1, false, 0, 0
if LCD_W == 480 then
margin = 10
spacing = 20
end
pages = {
runSettingsPage,
}
for index = 1, 40, 1 do
local sensor = model.getSensor(index)
if sensor ~= nil and sensor.id >= 0x0e50 and sensor.id <= 0x0e5f then
appId = sensor.id
break
end
end
if appId == 0 then
error("No SBEC sensor in this model!")
end
telemetryIdle(0x80)
end
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)
refreshNext()
return result
end
return { init=init, background=background, run=run }
+363
View File
@@ -0,0 +1,363 @@
--- - #########################################################################
---- # #
---- # Copyright (C) OpenTX #
----- # #
---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html #
---- # #
---- # This program is free software; you can redistribute it and/or modify #
---- # it under the terms of the GNU General Public License version 2 as #
---- # published by the Free Software Foundation. #
---- # #
---- # This program is distributed in the hope that it will be useful #
---- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
---- # GNU General Public License for more details. #
---- # #
---- #########################################################################
local version = "v2.00"
local VALUE = 0
local COMBO = 1
local COLUMN_2 = 300
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 wingBitmaps = {}
local mountBitmaps = {}
local margin = 1
local spacing = 8
local counter = 0
local configFields = {
{ "Wing type", COMBO, 0x80, nil, { "Normal", "Delta", "VTail" } },
{ "Mounting type", COMBO, 0x81, nil, { "Horz", "Horz rev.", "Vert", "Vert rev." } },
}
local wingBitmapsFile = { "bmp/plane.bmp", "bmp/delta.bmp", "bmp/vtail.bmp" }
local mountBitmapsFile = { "bmp/horz.bmp", "bmp/horz-r.bmp", "bmp/vert.bmp", "bmp/vert-r.bmp" }
local settingsFields = {
{"SxR functions", COMBO, 0x9C, nil, { "Disable", "Enable" } },
{"Quick Mode:", COMBO, 0xAA, nil, { "Disable", "Enable" } },
{"CH5 mode", COMBO, 0xA8, nil, { "AIL2", "AUX1" } },
{"CH6 mode", COMBO, 0xA9, nil, { "ELE2", "AUX2" } },
{"AIL direction", COMBO, 0x82, nil, { "Normal", "Invers" }, { 255, 0 } },
{"ELE direction", COMBO, 0x83, nil, { "Normal", "Invers" }, { 255, 0 } },
{"RUD direction", COMBO, 0x84, nil, { "Normal", "Invers" }, { 255, 0 } },
{"AIL2 direction", COMBO, 0x9A, nil, { "Normal", "Invers" }, { 255, 0 } },
{"ELE2 direction", COMBO, 0x9B, nil, { "Normal", "Invers" }, { 255, 0 } },
{"AIL stab gain", VALUE, 0x85, nil, 0, 200, "%"},
{"ELE stab gain", VALUE, 0x86, nil, 0, 200, "%"},
{"RUD stab gain", VALUE, 0x87, nil, 0, 200, "%"},
{"AIL autolvl gain", VALUE, 0x88, nil, 0, 200, "%"},
{"ELE autolvl gain", VALUE, 0x89, nil, 0, 200, "%"},
{"ELE hover gain", VALUE, 0x8C, nil, 0, 200, "%"},
{"RUD hover gain", VALUE, 0x8D, nil, 0, 200, "%"},
{"AIL knife gain", VALUE, 0x8E, nil, 0, 200, "%"},
{"RUD knife gain", VALUE, 0x90, nil, 0, 200, "%"},
{"AIL autolvl offset", VALUE, 0x91, nil, -20, 20, "%", 0x6C},
{"ELE autolvl offset", VALUE, 0x92, nil, -20, 20, "%", 0x6C},
{"ELE hover offset", VALUE, 0x95, nil, -20, 20, "%", 0x6C},
{"RUD hover offset", VALUE, 0x96, nil, -20, 20, "%", 0x6C},
{"AIL knife offset", VALUE, 0x97, nil, -20, 20, "%", 0x6C},
{"RUD knife offset", VALUE, 0x99, nil, -20, 20, "%", 0x6C},
}
local calibrationFields = {
{ "X:", VALUE, 0x9E, 0, -100, 100, "%" },
{ "Y:", VALUE, 0x9F, 0, -100, 100, "%" },
{ "Z:", VALUE, 0xA0, 0, -100, 100, "%" }
}
local function drawScreenTitle(title, page, pages)
if math.fmod(math.floor(getTime() / 100), 10) == 0 then
title = version
end
if LCD_W == 480 then
lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR)
lcd.drawText(1, 5, title, MENU_TITLE_COLOR)
lcd.drawText(LCD_W - 40, 5, page .. "/" .. pages, MENU_TITLE_COLOR)
else
lcd.drawScreenTitle(title, page, pages)
end
end
-- Change display attribute to current field
local function addField(step)
local field = fields[current]
local min, max
if field[2] == VALUE then
min = field[5]
max = field[6]
elseif field[2] == COMBO then
min = 0
max = #(field[5]) - 1
end
if (step < 0 and field[4] > min) or (step > 0 and field[4] < max) then
field[4] = field[4] + step
end
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
-- Select the next or previous editable field
local function selectField(step)
current = 1 + ((current + step - 1 + #fields) % #fields)
if current > 7 + pageOffset then
pageOffset = current - 7
elseif current <= pageOffset then
pageOffset = current - 1
end
end
local function drawProgressBar()
if LCD_W == 480 then
local width = (300 * refreshIndex) / #fields
lcd.drawRectangle(100, 10, 300, 6)
lcd.drawFilledRectangle(102, 13, width, 2);
else
local width = (60 * refreshIndex) / #fields
lcd.drawRectangle(45, 1, 60, 6)
lcd.drawFilledRectangle(47, 3, width, 2);
end
end
-- Redraw the current page
local function redrawFieldsPage(event)
lcd.clear()
drawScreenTitle("SxR", page, #pages)
if refreshIndex < #fields then
drawProgressBar()
end
for index = 1, 10, 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(1, margin + spacing * index, field[1], attr)
if field[4] == nil then
lcd.drawText(LCD_W, margin + spacing * index, "---", RIGHT + attr)
else
if field[2] == VALUE then
lcd.drawNumber(LCD_W, margin + spacing * index, field[4], RIGHT + attr)
elseif field[2] == COMBO then
if field[4] >= 0 and field[4] < #(field[5]) then
lcd.drawText(LCD_W, margin + spacing * index, field[5][1 + field[4]], RIGHT + attr)
end
end
end
end
end
local function telemetryRead(field)
return sportTelemetryPush(0x17, 0x30, 0x0C30, field)
end
local function telemetryWrite(field, value)
return sportTelemetryPush(0x17, 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() + 120 -- 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] == 0xAA then
value = bit32.band(value, 0x0001)
end
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
fields[refreshIndex + 1][4] = nil
refreshIndex = refreshIndex + 1
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_VIRTUAL_EXIT then -- exit script
return 2
elseif event == EVT_VIRTUAL_ENTER 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_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REPT then
addField(1)
elseif event == EVT_VIRTUAL_PREVIOUS or event == EVT_VIRTUAL_PREVIOUS_REPT then
addField(-1)
end
else
if event == EVT_VIRTUAL_NEXT then
selectField(1)
elseif event == EVT_VIRTUAL_PREVIOUS then
selectField(-1)
end
end
redrawFieldsPage(event)
return 0
end
local function runConfigPage(event)
fields = configFields
local result = runFieldsPage(event)
if LCD_W == 128 then
local mountText = { "Label is facing the sky", "Label is facing ground", "Label is left when", "Label is right when" }
if fields[2][4] ~= nil then
lcd.drawText(1, 30, "Pins toward tail")
lcd.drawText(1, 40, mountText[1 + fields[2][4]])
if fields[2][4] > 1 then
lcd.drawText(1, 50, "looking from the tail")
end
end
else
if fields[1][4] ~= nil then
if LCD_W == 480 then
if wingBitmaps[1 + fields[1][4]] == nil then
wingBitmaps[1 + fields[1][4]] = Bitmap.open(wingBitmapsFile[1 + fields[1][4]])
end
lcd.drawBitmap(wingBitmaps[1 + fields[1][4]], 10, 90)
else
lcd.drawPixmap(20, 28, wingBitmapsFile[1 + fields[1][4]])
end
end
if fields[2][4] ~= nil then
if LCD_W == 480 then
if mountBitmaps[1 + fields[2][4]] == nil then
mountBitmaps[1 + fields[2][4]] = Bitmap.open(mountBitmapsFile[1 + fields[2][4]])
end
lcd.drawBitmap(mountBitmaps[1 + fields[2][4]], 190, 110)
else
lcd.drawPixmap(128, 28, mountBitmapsFile[1 + fields[2][4]])
end
end
end
return result
end
local function runSettingsPage(event)
fields = settingsFields
return runFieldsPage(event)
end
-- Init
local function init()
current, edit, refreshState, refreshIndex = 1, false, 0, 0
if LCD_W == 480 then
margin = 10
spacing = 20
wingBitmapsFile = { "img/plane_b.png", "img/delta_b.png", "img/planev_b.png" }
mountBitmapsFile = { "img/up.png", "img/down.png", "img/vert.png", "img/vert-r.png" }
end
pages = {
runConfigPage,
runSettingsPage,
}
end
-- Main
local function run(event)
if event == nil then
error("Cannot be run as a model script!")
return 2
elseif event == EVT_VIRTUAL_NEXT_PAGE then
selectPage(1)
elseif event == EVT_VIRTUAL_PREVIOUS_PAGE then
killEvents(event);
selectPage(-1)
end
local result = pages[page](event)
refreshNext()
return result
end
return { init = init, run = run }
@@ -0,0 +1,37 @@
local toolName = "TNS|Crossfire configure|TNE"
---- #########################################################################
---- # #
---- # Copyright (C) OpenTX #
-----# #
---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html #
---- # #
---- # This program is free software; you can redistribute it and/or modify #
---- # it under the terms of the GNU General Public License version 2 as #
---- # published by the Free Software Foundation. #
---- # #
---- # This program is distributed in the hope that it will be useful #
---- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
---- # GNU General Public License for more details. #
---- # #
---- #########################################################################
-- Init
local function init()
end
-- Run
local function run(event)
if event == nil then
error("Cannot run as a model script!")
return 2
end
chdir("CROSSFIRE")
return "crossfire.lua"
end
return { init=init, run=run }
@@ -0,0 +1 @@
Scripts that need to be available in TOOLS menu should be in this directory
@@ -258,7 +258,7 @@ local function runFlapsConfig(event)
end
local TailFields = {
{50, 50, COMBO, 1, 1, { "1 channel for Elevator, no Rudder", "One chan for Elevator, one for Rudder", "Two chans for Elevator, one for Rudder", "V Tail"} },
{50, 50, COMBO, 1, 1, { "1 channel for Elevator, no Rudder", "One channel for Elevator, one for Rudder", "Two channels for Elevator, one for Rudder", "V Tail"} },
{50, 127, COMBO, 1, 1, { "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8" } }, --ele
{50, 167, COMBO, 1, 3, { "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8" } }, --rud
{50, 207, COMBO, 0, 5, { "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8" } }, --ele2
@@ -302,8 +302,8 @@ local function runTailConfig(event)
if fields[1][5] == 2 then
lcd.drawBitmap(ImgTail, 252, 100)
lcd.drawBitmap(ImgTailRud, 340, 100)
drawMark(415, 150, "A")
drawMark(380, 120, "C")
drawMark(415, 150, "C")
drawMark(380, 120, "A")
drawMark(390, 185, "B")
lcd.drawFilledRectangle(40, 122, 100, 30, CUSTOM_COLOR)
drawMark(152, 124, "A")
@@ -332,7 +332,7 @@ end
local lineIndex
local function drawNextLine(text, text2)
lcd.drawText(40, lineIndex, text, TEXT_COLOR)
lcd.drawText(250, lineIndex, text2 + 1, TEXT_COLOR)
lcd.drawText(242, lineIndex, ": CH" .. text2 + 1, TEXT_COLOR)
lineIndex = lineIndex + 20
end
@@ -354,38 +354,35 @@ local function runConfigSummary(event)
lineIndex = 40
-- motors
if(MotorFields[1][5] == 1) then
drawNextLine("Motor chan :", MotorFields[2][5])
elseif (MotorFields[1][5] == 2) then
drawNextLine("Motor 1 chan :", MotorFields[2][5])
drawNextLine("Motor 2 chan :", MotorFields[3][5])
drawNextLine("Motor channel", MotorFields[2][5])
end
-- ail
if(AilFields[1][5] == 1) then
drawNextLine("Aileron chan :",AilFields[2][5])
drawNextLine("Aileron channel",AilFields[2][5])
elseif (AilFields[1][5] == 2) then
drawNextLine("Aileron 1 chan :",AilFields[2][5])
drawNextLine("Aileron 2 chan :",AilFields[3][5])
drawNextLine("Aileron Right channel",AilFields[2][5])
drawNextLine("Aileron Left channel",AilFields[3][5])
end
-- flaps
if(FlapsFields[1][5] == 1) then
drawNextLine("Flaps chan :",FlapsFields[2][5])
drawNextLine("Flaps channel",FlapsFields[2][5])
elseif (FlapsFields[1][5] == 2) then
drawNextLine("Flaps 1 chan :",FlapsFields[2][5])
drawNextLine("Flaps 2 chan :",FlapsFields[3][5])
drawNextLine("Flaps Right channel",FlapsFields[2][5])
drawNextLine("Flaps Left channel",FlapsFields[3][5])
end
-- tail
if(TailFields[1][5] == 0) then
drawNextLine("Elevator chan :",TailFields[2][5])
drawNextLine("Elevator channel",TailFields[2][5])
elseif (TailFields[1][5] == 1) then
drawNextLine("Elevator chan :",TailFields[2][5])
drawNextLine("Rudder chan :",TailFields[3][5])
drawNextLine("Elevator channel",TailFields[2][5])
drawNextLine("Rudder channel",TailFields[3][5])
elseif (TailFields[1][5] == 2) then
drawNextLine("Elevator 1 chan :",TailFields[2][5])
drawNextLine("Rudder chan :",TailFields[3][5])
drawNextLine("Elevator 2 chan :",TailFields[4][5])
drawNextLine("Elevator Right channel",TailFields[2][5])
drawNextLine("Rudder channel",TailFields[3][5])
drawNextLine("Elevator Left channel",TailFields[4][5])
elseif (TailFields[1][5] == 3) then
drawNextLine("V-Tail elevator :", TailFields[2][5])
drawNextLine("V-Tail rudder :", TailFields[3][5])
drawNextLine("V-Tail Right", TailFields[2][5])
drawNextLine("V-Tail Left", TailFields[3][5])
end
local result = runFieldsPage(event)
if(fields[1][5] == 1 and edit == false) then
@@ -414,23 +411,20 @@ local function createModel(event)
-- motor
if(MotorFields[1][5] == 1) then
addMix(MotorFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(2), "Motor")
elseif (MotorFields[1][5] == 2) then
addMix(MotorFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(2), "Motor1")
addMix(MotorFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(2), "Motor2")
end
-- Ailerons
if(AilFields[1][5] == 1) then
addMix(AilFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "Ail")
elseif (AilFields[1][5] == 2) then
addMix(AilFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "AilL")
addMix(AilFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "AilR", -100)
addMix(AilFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "AilR")
addMix(AilFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "AilL", -100)
end
-- Flaps
if(FlapsFields[1][5] == 1) then
addMix(FlapsFields[2][5], MIXSRC_SA, "Flaps")
elseif (FlapsFields[1][5] == 2) then
addMix(FlapsFields[2][5], MIXSRC_SA, "FlapsL")
addMix(FlapsFields[3][5], MIXSRC_SA, "FlapsR")
addMix(FlapsFields[2][5], MIXSRC_SA, "FlapsR")
addMix(FlapsFields[3][5], MIXSRC_SA, "FlapsL")
end
-- Tail
if(TailFields[1][5] == 0) then
@@ -439,14 +433,14 @@ local function createModel(event)
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "Elev")
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "Rudder")
elseif (TailFields[1][5] == 2) then
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "ElevL")
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "ElevR")
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "Rudder")
addMix(TailFields[4][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "ElevR")
addMix(TailFields[4][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "ElevL")
elseif (TailFields[1][5] == 3) then
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleL", 50)
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudL", 50, 1)
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleR", 50)
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudR", -50, 1)
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleR", 50)
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudR", 50, 1)
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleL", 50)
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudL", -50, 1)
end
lcd.drawText(70, 90, "Model successfully created !", TEXT_COLOR)
lcd.drawText(100, 130, "Press RTN to exit", TEXT_COLOR)
@@ -258,7 +258,7 @@ local function runFlapsConfig(event)
end
local TailFields = {
{50, 50, COMBO, 1, 1, { "1 channel for Elevator, no Rudder", "One chan for Elevator, one for Rudder", "Two chans for Elevator, one for Rudder", "V Tail"} },
{50, 50, COMBO, 1, 1, { "1 channel for Elevator, no Rudder", "One channel for Elevator, one for Rudder", "Two channels for Elevator, one for Rudder", "V Tail"} },
{50, 127, COMBO, 1, 1, { "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8" } }, --ele
{50, 167, COMBO, 1, 3, { "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8" } }, --rud
{50, 207, COMBO, 0, 5, { "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8" } }, --ele2
@@ -332,7 +332,7 @@ end
local lineIndex
local function drawNextLine(text, text2)
lcd.drawText(40, lineIndex, text, TEXT_COLOR)
lcd.drawText(250, lineIndex, text2 + 1, TEXT_COLOR)
lcd.drawText(242, lineIndex, ": CH" .. text2 + 1, TEXT_COLOR)
lineIndex = lineIndex + 20
end
@@ -354,38 +354,35 @@ local function runConfigSummary(event)
lineIndex = 40
-- motors
if(MotorFields[1][5] == 1) then
drawNextLine("Motor chan :", MotorFields[2][5])
elseif (MotorFields[1][5] == 2) then
drawNextLine("Motor 1 chan :", MotorFields[2][5])
drawNextLine("Motor 2 chan :", MotorFields[3][5])
drawNextLine("Motor channel", MotorFields[2][5])
end
-- ail
if(AilFields[1][5] == 1) then
drawNextLine("Aileron chan :",AilFields[2][5])
drawNextLine("Aileron channel",AilFields[2][5])
elseif (AilFields[1][5] == 2) then
drawNextLine("Aileron 1 chan :",AilFields[2][5])
drawNextLine("Aileron 2 chan :",AilFields[3][5])
drawNextLine("Aileron Right channel",AilFields[2][5])
drawNextLine("Aileron Left channel",AilFields[3][5])
end
-- flaps
if(FlapsFields[1][5] == 1) then
drawNextLine("Flaps chan :",FlapsFields[2][5])
drawNextLine("Flaps channel",FlapsFields[2][5])
elseif (FlapsFields[1][5] == 2) then
drawNextLine("Flaps 1 chan :",FlapsFields[2][5])
drawNextLine("Flaps 2 chan :",FlapsFields[3][5])
drawNextLine("Flaps Right channel",FlapsFields[2][5])
drawNextLine("Flaps Left channel",FlapsFields[3][5])
end
-- tail
if(TailFields[1][5] == 0) then
drawNextLine("Elevator chan :",TailFields[2][5])
drawNextLine("Elevator channel",TailFields[2][5])
elseif (TailFields[1][5] == 1) then
drawNextLine("Elevator chan :",TailFields[2][5])
drawNextLine("Rudder chan :",TailFields[3][5])
drawNextLine("Elevator channel",TailFields[2][5])
drawNextLine("Rudder channel",TailFields[3][5])
elseif (TailFields[1][5] == 2) then
drawNextLine("Elevator 1 chan :",TailFields[2][5])
drawNextLine("Rudder chan :",TailFields[3][5])
drawNextLine("Elevator 2 chan :",TailFields[4][5])
drawNextLine("Elevator Right channel",TailFields[2][5])
drawNextLine("Rudder channel",TailFields[3][5])
drawNextLine("Elevator Left channel",TailFields[4][5])
elseif (TailFields[1][5] == 3) then
drawNextLine("V-Tail elevator :", TailFields[2][5])
drawNextLine("V-Tail rudder :", TailFields[3][5])
drawNextLine("V-Tail Right", TailFields[2][5])
drawNextLine("V-Tail Left", TailFields[3][5])
end
local result = runFieldsPage(event)
if(fields[1][5] == 1 and edit == false) then
@@ -414,23 +411,20 @@ local function createModel(event)
-- motor
if(MotorFields[1][5] == 1) then
addMix(MotorFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(2), "Motor")
elseif (MotorFields[1][5] == 2) then
addMix(MotorFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(2), "Motor1")
addMix(MotorFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(2), "Motor2")
end
-- Ailerons
if(AilFields[1][5] == 1) then
addMix(AilFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "Ail")
elseif (AilFields[1][5] == 2) then
addMix(AilFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "AilL")
addMix(AilFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "AilR", -100)
addMix(AilFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "AilR")
addMix(AilFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(3), "AilL", -100)
end
-- Flaps
if(FlapsFields[1][5] == 1) then
addMix(FlapsFields[2][5], MIXSRC_SA, "Flaps")
elseif (FlapsFields[1][5] == 2) then
addMix(FlapsFields[2][5], MIXSRC_SA, "FlapsL")
addMix(FlapsFields[3][5], MIXSRC_SA, "FlapsR")
addMix(FlapsFields[2][5], MIXSRC_SA, "FlapsR")
addMix(FlapsFields[3][5], MIXSRC_SA, "FlapsL")
end
-- Tail
if(TailFields[1][5] == 0) then
@@ -439,14 +433,14 @@ local function createModel(event)
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "Elev")
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "Rudder")
elseif (TailFields[1][5] == 2) then
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "ElevL")
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "ElevR")
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "Rudder")
addMix(TailFields[4][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "ElevR")
addMix(TailFields[4][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "ElevL")
elseif (TailFields[1][5] == 3) then
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleL", 50)
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudL", 50, 1)
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleR", 50)
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudR", -50, 1)
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleR", 50)
addMix(TailFields[2][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudR", 50, 1)
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleL", 50)
addMix(TailFields[3][5], MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudL", -50, 1)
end
lcd.drawText(70, 90, "Model successfully created !", TEXT_COLOR)
lcd.drawText(100, 130, "Press RTN to exit", TEXT_COLOR)
@@ -315,7 +315,7 @@ local function fieldCommandLoad(field, data, offset)
field.status = data[offset]
field.timeout = data[offset+1]
field.info, offset = fieldGetString(data, offset+2)
if field.status < 2 or field.status > 3 then
if field.status == 0 then
fieldPopup = nil
end
end
@@ -401,8 +401,7 @@ local function refreshNext()
local time = getTime()
if fieldPopup then
if time > fieldTimeout then
local frame = { deviceId, 0xEA, fieldPopup.id }
crossfireTelemetryPush(0x2D, frame)
crossfireTelemetryPush(0x2D, { deviceId, 0xEA, fieldPopup.id, 6 })
fieldTimeout = time + fieldPopup.timeout
end
elseif time > fieldTimeout and not edit then
@@ -0,0 +1,37 @@
local toolName = "TNS|Crossfire config|TNE"
---- #########################################################################
---- # #
---- # Copyright (C) OpenTX #
-----# #
---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html #
---- # #
---- # This program is free software; you can redistribute it and/or modify #
---- # it under the terms of the GNU General Public License version 2 as #
---- # published by the Free Software Foundation. #
---- # #
---- # This program is distributed in the hope that it will be useful #
---- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
---- # GNU General Public License for more details. #
---- # #
---- #########################################################################
-- Init
local function init()
end
-- Run
local function run(event)
if event == nil then
error("Cannot run as a model script!")
return 2
end
chdir("CROSSFIRE")
return "crossfire.lua"
end
return { init=init, run=run }
@@ -311,6 +311,7 @@ end
local function drawNextLine(x, y, label, channel)
lcd.drawText(x, y, label, 0);
lcd.drawText(x+48, y, ":", 0);
lcd.drawSource(x+52, y, MIXSRC_CH1+channel, 0)
y = y + 8
if y > 50 then
@@ -327,12 +328,12 @@ local function drawConfirmationMenu()
lcd.drawText(48, 1, "Ready to go?", 0);
lcd.drawFilledRectangle(0, 0, LCD_W, 9, 0)
if engineMode == 1 then
x, y = drawNextLine(x, y, "Thr:", thrCH1)
x, y = drawNextLine(x, y, "Throttle", thrCH1)
end
x, y = drawNextLine(x, y, "Ele L:", elevCH1)
x, y = drawNextLine(x, y, "Ele R:", elevCH2)
x, y = drawNextLine(x, y, "Elevon L", elevCH1)
x, y = drawNextLine(x, y, "Elevon R", elevCH2)
if rudderMode == 1 then
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)
@@ -165,8 +165,8 @@ end
-- Init function
local function init()
thrCH1 = defaultChannel(2)
rollCH1 = defaultChannel(3)
yawCH1 = defaultChannel(0)
rollCH1 = defaultChannel(0)
yawCH1 = defaultChannel(3)
pitchCH1 = defaultChannel(1)
local ver, radio, maj, minor, rev = getVersion()
if string.match(radio, "x7") then
@@ -326,6 +326,7 @@ end
-- Confirmation Menu
local function drawNextLine(x, y, label, channel)
lcd.drawText(x, y, label, 0);
lcd.drawText(x+46, y, ":", 0);
lcd.drawSource(x+50, y, MIXSRC_CH1+channel, 0)
y = y + 8
if y > 50 then
@@ -337,6 +338,7 @@ end
local function drawNextSWLine(x, y, label, switch)
lcd.drawText(x, y, label, 0);
lcd.drawText(x+38, y, ":", 0);
lcd.drawText(x+42, y, switches[switch], 0)
y = y + 8
if y > 50 then
@@ -352,15 +354,15 @@ local function drawConfirmationMenu()
lcd.clear()
lcd.drawText(0, 1, "Ready to go?", 0);
lcd.drawFilledRectangle(0, 0, LCD_W, 9, 0)
x, y = drawNextLine(x, y, "Throttle:", thrCH1)
x, y = drawNextLine(x, y, "Roll:", rollCH1)
x, y = drawNextLine(x, y, "Pitch:", pitchCH1)
x, y = drawNextLine(x, y, "Yaw:", yawCH1)
x, y = drawNextLine(x, y, "Throttle", thrCH1)
x, y = drawNextLine(x, y, "Roll", rollCH1)
x, y = drawNextLine(x, y, "Pitch", pitchCH1)
x, y = drawNextLine(x, y, "Yaw", yawCH1)
local x = 72
local y = 12
x, y = drawNextSWLine(x, y, "Arm:", armSW1)
x, y = drawNextSWLine(x, y, "Mode:", modeSW1)
x, y = drawNextSWLine(x, y, "Beeper:", beeperSW1)
x, y = drawNextSWLine(x, y, "Arm", armSW1)
x, y = drawNextSWLine(x, y, "Mode", modeSW1)
x, y = drawNextSWLine(x, y, "Beeper", beeperSW1)
lcd.drawText(0, LCD_H-8, "[Enter Long] to confirm", 0);
lcd.drawFilledRectangle(0, LCD_H-9, LCD_W, 9, 0)
fieldsMax = 0
@@ -429,6 +429,7 @@ end
-- Confirmation Menu
local function drawNextLine(x, y, label, channel)
lcd.drawText(x, y, label, 0);
lcd.drawText(x+26, y, ":", 0);
lcd.drawSource(x+30, y, MIXSRC_CH1+channel, 0)
y = y + 8
if y > 50 then
@@ -502,8 +503,8 @@ local function applySettings()
if aileronsMode == 1 then
addMix(ailCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "Ail")
elseif aileronsMode == 2 then
addMix(ailCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "AilL")
addMix(ailCH2, MIXSRC_FIRST_INPUT+defaultChannel(3), "AilR", -100)
addMix(ailCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "AilL", -100)
addMix(ailCH2, MIXSRC_FIRST_INPUT+defaultChannel(3), "AilR")
end
if flapsMode == 1 then
addMix(flapsCH1, MIXSRC_SA, "Flap")
@@ -519,9 +520,9 @@ local function applySettings()
end
if tailMode == 3 then
addMix(eleCH1, MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleL", 50)
addMix(eleCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudL", 50, 1)
addMix(eleCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudL", -50, 1)
addMix(eleCH2, MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleR", 50)
addMix(eleCH2, MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudR", -50, 1)
addMix(eleCH2, MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudR", 50, 1)
else
if tailMode > 0 then
addMix(rudCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "Rudder")
@@ -315,7 +315,7 @@ local function fieldCommandLoad(field, data, offset)
field.status = data[offset]
field.timeout = data[offset+1]
field.info, offset = fieldGetString(data, offset+2)
if field.status < 2 or field.status > 3 then
if field.status == 0 then
fieldPopup = nil
end
end
@@ -401,8 +401,7 @@ local function refreshNext()
local time = getTime()
if fieldPopup then
if time > fieldTimeout then
local frame = { deviceId, 0xEA, fieldPopup.id }
crossfireTelemetryPush(0x2D, frame)
crossfireTelemetryPush(0x2D, { deviceId, 0xEA, fieldPopup.id, 6 })
fieldTimeout = time + fieldPopup.timeout
end
elseif time > fieldTimeout and not edit then
@@ -0,0 +1,37 @@
local toolName = "TNS|Crossfire configure|TNE"
---- #########################################################################
---- # #
---- # Copyright (C) OpenTX #
-----# #
---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html #
---- # #
---- # This program is free software; you can redistribute it and/or modify #
---- # it under the terms of the GNU General Public License version 2 as #
---- # published by the Free Software Foundation. #
---- # #
---- # This program is distributed in the hope that it will be useful #
---- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
---- # GNU General Public License for more details. #
---- # #
---- #########################################################################
-- Init
local function init()
end
-- Run
local function run(event)
if event == nil then
error("Cannot run as a model script!")
return 2
end
chdir("CROSSFIRE")
return "crossfire.lua"
end
return { init=init, run=run }
@@ -338,10 +338,10 @@ local function drawConfirmationMenu()
if engineMode == 1 then
x, y = drawNextLine(x, y, "Throttle", thrCH1)
end
x, y = drawNextLine(x, y, "Elev L", elevCH1)
x, y = drawNextLine(x, y, "Elev R", elevCH2)
x, y = drawNextLine(x, y, "Elevon L", elevCH1)
x, y = drawNextLine(x, y, "Elevon R", elevCH2)
if rudderMode == 1 then
drawNextLine(x, y, "Rudder:", rudCH1)
drawNextLine(x, y, "Rudder", rudCH1)
end
lcd.drawText(48, LCD_H-8, "Long [ENT] to confirm", 0);
lcd.drawFilledRectangle(0, LCD_H-9, LCD_W, 9, 0)
@@ -20,8 +20,8 @@ local ROLL_PAGE = 1
local PITCH_PAGE = 2
local YAW_PAGE = 3
local ARM_PAGE = 4
local MODE_PAGE = 5
local BEEPER_PAGE = 6
local BEEPER_PAGE = 5
local MODE_PAGE = 6
local CONFIRMATION_PAGE = 7
-- Navigation variables
@@ -340,6 +340,7 @@ end
-- Confirmation Menu
local function drawNextCHLine(x, y, label, channel)
lcd.drawText(x, y, label, 0);
lcd.drawText(x+48, y, ":", 0);
lcd.drawSource(x+52, y, MIXSRC_CH1+channel, 0)
y = y + 8
if y > 50 then
@@ -351,6 +352,7 @@ end
local function drawNextSWLine(x, y, label, switch)
lcd.drawText(x, y, label, 0);
lcd.drawText(x+76, y, ":", 0);
lcd.drawText(x+80, y, switches[switch], 0)
y = y + 8
if y > 50 then
@@ -366,15 +368,15 @@ local function drawConfirmationMenu()
lcd.clear()
lcd.drawText(48, 1, "Ready to go?", 0);
lcd.drawFilledRectangle(0, 0, LCD_W, 9, 0)
x, y = drawNextCHLine(x, y, "Throttle:", thrCH1)
x, y = drawNextCHLine(x, y, "Roll:", rollCH1)
x, y = drawNextCHLine(x, y, "Pitch:", pitchCH1)
x, y = drawNextCHLine(x, y, "Yaw:", yawCH1)
x, y = drawNextCHLine(x, y, "Throttle", thrCH1)
x, y = drawNextCHLine(x, y, "Roll", rollCH1)
x, y = drawNextCHLine(x, y, "Pitch", pitchCH1)
x, y = drawNextCHLine(x, y, "Yaw", yawCH1)
x = 95
y = 12
x, y = drawNextSWLine(x, y, "Arm switch:", armSW1)
x, y = drawNextSWLine(x, y, "Mode switch:", modeSW1)
x, y = drawNextSWLine(x, y, "Beeper switch:", beeperSW1)
x, y = drawNextSWLine(x, y, "Arm switch", armSW1)
x, y = drawNextSWLine(x, y, "Beeper switch", beeperSW1)
x, y = drawNextSWLine(x, y, "Mode switch", modeSW1)
lcd.drawText(48, LCD_H-8, "[Enter Long] to confirm", 0);
lcd.drawFilledRectangle(0, LCD_H-9, LCD_W, 9, 0)
lcd.drawPixmap(LCD_W-18, 0, "confirm-tick.bmp")
@@ -396,7 +398,7 @@ end
local function applySettings()
model.defaultInputs()
model.deleteMixes()
addMix(thrCH1, MIXSRC_FIRST_INPUT+defaultChannel(2), "Throttle")
addMix(thrCH1, MIXSRC_FIRST_INPUT+defaultChannel(2), "Engine")
addMix(rollCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "Roll")
addMix(yawCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "Yaw")
addMix(pitchCH1, MIXSRC_FIRST_INPUT+defaultChannel(1), "Pitch")
@@ -509,8 +509,8 @@ local function applySettings()
if aileronsMode == 1 then
addMix(ailCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "Ail")
elseif aileronsMode == 2 then
addMix(ailCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "AilL")
addMix(ailCH2, MIXSRC_FIRST_INPUT+defaultChannel(3), "AilR", -100)
addMix(ailCH1, MIXSRC_FIRST_INPUT+defaultChannel(3), "AilL", -100)
addMix(ailCH2, MIXSRC_FIRST_INPUT+defaultChannel(3), "AilR")
end
if flapsMode == 1 then
addMix(flapsCH1, MIXSRC_SA, "Flaps")
@@ -526,9 +526,9 @@ local function applySettings()
end
if tailMode == 3 then
addMix(eleCH1, MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleL", 50)
addMix(eleCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudL", 50, 1)
addMix(eleCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudL", -50, 1)
addMix(eleCH2, MIXSRC_FIRST_INPUT+defaultChannel(1), "V-EleR", 50)
addMix(eleCH2, MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudR", -50, 1)
addMix(eleCH2, MIXSRC_FIRST_INPUT+defaultChannel(0), "V-RudR", 50, 1)
else
if tailMode > 0 then
addMix(rudCH1, MIXSRC_FIRST_INPUT+defaultChannel(0), "Rudder")
+3 -3
View File
@@ -32,7 +32,7 @@ option(AUTOSOURCE "Automatic source detection in menus" ON)
option(AUTOSWITCH "Automatic switch detection in menus" ON)
option(SEMIHOSTING "Enable debugger semihosting" OFF)
option(JITTER_MEASURE "Enable ADC jitter measurement" OFF)
option(WATCHDOG_DISABLED "Disable hardware Watchdog" OFF)
option(WATCHDOG "Enable hardware Watchdog" ON)
if(SDL_FOUND)
option(SIMU_AUDIO "Enable simulator audio." ON)
endif()
@@ -232,8 +232,8 @@ if(JITTER_MEASURE)
add_definitions(-DJITTER_MEASURE)
endif()
if(WATCHDOG_DISABLED)
add_definitions(-DWATCHDOG_DISABLED)
if(WATCHDOG)
add_definitions(-DWATCHDOG)
endif()
if(SIMU_AUDIO)
+1 -1
View File
@@ -529,7 +529,7 @@ void audioTask(void * pdata)
RTOS_WAIT_MS(1000); // 1s
#endif
if (!unexpectedShutdown) {
if (!globalData.unexpectedShutdown) {
AUDIO_HELLO();
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

+1 -1
View File
@@ -54,6 +54,7 @@ class Bluetooth
public:
void writeString(const char * str);
char * readline(bool error_reset = true);
void write(const uint8_t * data, uint8_t length);
void forwardTelemetry(const uint8_t * packet);
void wakeup();
@@ -66,7 +67,6 @@ class Bluetooth
protected:
void pushByte(uint8_t byte);
uint8_t read(uint8_t * data, uint8_t size, uint32_t timeout=1000/*ms*/);
void write(const uint8_t * data, uint8_t length);
void appendTrainerByte(uint8_t data);
void processTrainerFrame(const uint8_t * buffer);
void processTrainerByte(uint8_t data);
+2 -3
View File
@@ -191,8 +191,8 @@ enum TrainerMode {
#if defined(PCBTARANIS)
TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE,
TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE,
#endif
TRAINER_MODE_MASTER_BATTERY_COMPARTMENT,
#endif
#if defined(BLUETOOTH)
TRAINER_MODE_MASTER_BLUETOOTH,
TRAINER_MODE_SLAVE_BLUETOOTH,
@@ -482,7 +482,6 @@ enum SwitchSources {
SWSRC_SR2,
#endif
#if defined(PCBSKY9X)
SWSRC_ID0 = SWSRC_FIRST_SWITCH,
SWSRC_ID1,
@@ -501,7 +500,7 @@ enum SwitchSources {
#if NUM_XPOTS > 0
SWSRC_FIRST_MULTIPOS_SWITCH,
SWSRC_LAST_MULTIPOS_SWITCH = SWSRC_FIRST_MULTIPOS_SWITCH + (NUM_POTS * XPOTS_MULTIPOS_COUNT) - 1,
SWSRC_LAST_MULTIPOS_SWITCH = SWSRC_FIRST_MULTIPOS_SWITCH + (NUM_XPOTS * XPOTS_MULTIPOS_COUNT) - 1,
#endif
SWSRC_FIRST_TRIM,
+27 -27
View File
@@ -323,6 +323,9 @@ PACK(struct VarioData {
* Telemetry Sensor structure
*/
#define TELEMETRY_ENDPOINT_NONE 0xFF
#define TELEMETRY_ENDPOINT_SPORT 0x07
PACK(struct TelemetrySensor {
union {
uint16_t id; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type.
@@ -383,18 +386,17 @@ PACK(struct TelemetrySensor {
int32_t getPrecDivisor() const;
bool isSameInstance(TelemetryProtocol protocol, uint8_t instance)
{
if (this->instance == instance)
return true;
if (protocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) {
if (((this->instance ^ instance) & 0x9F) == 0) {
if (((this->instance ^ instance) & 0x9F) == 0 && (this->instance >> 5) != TELEMETRY_ENDPOINT_SPORT && (instance >> 5) != TELEMETRY_ENDPOINT_SPORT) {
this->instance = instance; // update the instance in case we had telemetry switching
return true;
}
else {
return false;
}
}
else {
return this->instance == instance;
}
return false;
}
);
});
@@ -422,16 +424,13 @@ PACK(struct TrainerModuleData {
#define MM_RF_CUSTOM_SELECTED 0xff
PACK(struct ModuleData {
uint8_t type:4;
// TODO some refactoring is needed, rfProtocol is only used by DSM2 and MULTI, it could be merged with subType
int8_t rfProtocol:4;
uint8_t channelsStart;
int8_t channelsCount; // 0=8 channels
union {
struct {
uint8_t failsafeMode:4; // only 3 bits used
uint8_t subType:3;
uint8_t invertedSerial:1; // telemetry serial inverted from standard
};
};
uint8_t failsafeMode:4; // only 3 bits used
uint8_t subType:3;
uint8_t invertedSerial:1; // telemetry serial inverted from standard
union {
uint8_t raw[PXX2_MAX_RECEIVERS_PER_MODULE * PXX2_LEN_RX_NAME + 1];
@@ -452,10 +451,9 @@ PACK(struct ModuleData {
NOBACKUP(struct {
uint8_t power:2; // 0=10 mW, 1=100 mW, 2=500 mW, 3=1W
uint8_t spare1:2;
uint8_t receiver_telem_off:1; // false = receiver telem enabled
uint8_t receiver_channel_9_16:1; // false = pwm out 1-8, true 9-16
uint8_t external_antenna:1; // false = internal antenna, true = external antenna
uint8_t fast:1; // TODO: to be used later by external module (fast means serial @ high speed)
uint8_t receiverTelemetryOff:1; // false = receiver telem enabled
uint8_t receiverHigherChannels:1; // false = pwm out 1-8, true 9-16
int8_t antennaMode:2;
uint8_t spare2;
} pxx);
NOBACKUP(struct {
@@ -668,7 +666,7 @@ PACK(struct TrainerData {
#define SPLASH_MODE uint8_t splashMode:1; uint8_t splashSpare:2
#endif
#if defined(PCBXLITES) || defined(PCBHORUS)
#if defined(PCBXLITES)
#define GYRO_FIELDS \
int8_t gyroMax; \
int8_t gyroOffset;
@@ -685,13 +683,13 @@ PACK(struct TrainerData {
NOBACKUP(char switchNames[STORAGE_NUM_SWITCHES][LEN_SWITCH_NAME]); \
NOBACKUP(char anaNames[NUM_STICKS + STORAGE_NUM_POTS + STORAGE_NUM_SLIDERS][LEN_ANA_NAME]); \
NOBACKUP(char currModelFilename[LEN_MODEL_FILENAME+1]); \
NOBACKUP(uint8_t spare4:1); \
NOBACKUP(uint8_t spare5:1); \
NOBACKUP(uint8_t blOffBright:7); \
NOBACKUP(char bluetoothName[LEN_BLUETOOTH_NAME]);
#elif defined(PCBTARANIS) || defined(PCBNV14)
#if defined(STORAGE_BLUETOOTH)
#define BLUETOOTH_FIELDS \
uint8_t spare4; \
uint8_t spare5; \
char bluetoothName[LEN_BLUETOOTH_NAME];
#else
#define BLUETOOTH_FIELDS
@@ -709,7 +707,7 @@ PACK(struct TrainerData {
#elif defined(PCBSKY9X)
#define EXTRA_GENERAL_FIELDS \
int8_t txCurrentCalibration; \
int8_t spare4; \
int8_t spare5; \
uint8_t mAhWarn; \
uint16_t mAhUsed; \
int8_t temperatureCalib; \
@@ -735,7 +733,7 @@ PACK(struct TrainerData {
#if defined(BUZZER)
#define BUZZER_FIELD int8_t buzzerMode:2 // -2=quiet, -1=only alarms, 0=no keys, 1=all (only used on AVR radios without audio hardware)
#else
#define BUZZER_FIELD int8_t spare3:2
#define BUZZER_FIELD int8_t spare4:2
#endif
PACK(struct RadioData {
@@ -747,7 +745,9 @@ PACK(struct RadioData {
N_HORUS_FIELD(uint8_t contrast);
NOBACKUP(uint8_t vBatWarn);
NOBACKUP(int8_t txVoltageCalibration);
NOBACKUP(int8_t backlightMode);
uint8_t backlightMode:3;
int8_t antennaMode:2;
int8_t spare1:3;
NOBACKUP(TrainerData trainer);
NOBACKUP(uint8_t view); // index of view in main screen
NOBACKUP(BUZZER_FIELD); /* 2bits */
@@ -768,7 +768,7 @@ PACK(struct RadioData {
NOBACKUP(uint8_t templateSetup); // RETA order for receiver channels
NOBACKUP(int8_t PPM_Multiplier);
NOBACKUP(int8_t hapticLength);
N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t spare1));
N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t spare2));
N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t stickReverse));
NOBACKUP(int8_t beepLength:3);
NOBACKUP(int8_t hapticStrength:3);
@@ -791,7 +791,7 @@ PACK(struct RadioData {
NOBACKUP(uint8_t disableRssiPoweroffAlarm:1);
NOBACKUP(uint8_t USBMode:2);
NOBACKUP(uint8_t jackMode:2);
NOBACKUP(uint8_t spare2:1);
NOBACKUP(uint8_t spare3:1);
NOBACKUP(char ttsLanguage[2]);
NOBACKUP(int8_t beepVolume:4);
NOBACKUP(int8_t wavVolume:4);
@@ -945,7 +945,7 @@ static inline void check_struct()
CHKSIZE(RadioData, 735);
CHKSIZE(ModelData, 5301);
#elif defined(PCBHORUS)
CHKSIZE(RadioData, 883);
CHKSIZE(RadioData, 881);
CHKSIZE(ModelData, 9736);
#endif
+1 -1
View File
@@ -41,7 +41,7 @@ void loadFonts();
extern const unsigned char font_5x7[];
extern const unsigned char font_10x14[];
#if defined(BOLD_FONT) && !defined(BOOT)
#if defined(BOLD_FONT) && !defined(BOOT)
#define BOLD_SPECIFIC_FONT
extern const unsigned char font_5x7_B[];
#endif
+2 -1
View File
@@ -129,10 +129,11 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint8_t width, uin
memset(dest, 0, BITMAP_BUFFER_SIZE(w, h) - 2);
uint8_t rowSize = (w + 7) / 8;
uint8_t rowSize;
switch (depth) {
case 1:
rowSize = ((w + 31) / 32) * 4;
for (int8_t i=h-1; i>=0; i--) {
result = f_read(&bmpFile, buf, rowSize, &read);
if (result != FR_OK || read != rowSize) {
+1 -6
View File
@@ -183,8 +183,7 @@ void title(const char * s);
title(name)
typedef int choice_t;
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event);
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable = nullptr);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char * label, LcdFlags attr, event_t event);
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event);
@@ -231,15 +230,11 @@ void drawStatusLine();
#define drawStatusLine()
#endif
#define TEXT_FILENAME_MAXLEN 40
extern char s_text_file[TEXT_FILENAME_MAXLEN];
void menuTextView(event_t event);
void pushMenuTextView(const char *filename);
void pushModelNotes();
void readModelNotes();
#define LABEL(...) (uint8_t)-1
#define CURSOR_MOVED_LEFT(event) (IS_ROTARY_LEFT(event) || EVT_KEY_MASK(event) == KEY_LEFT)
#define CURSOR_MOVED_RIGHT(event) (IS_ROTARY_RIGHT(event) || EVT_KEY_MASK(event) == KEY_RIGHT)
+21 -2
View File
@@ -922,15 +922,34 @@ void lcdDraw1bitBitmap(coord_t x, coord_t y, const uint8_t * img, uint8_t idx, L
const uint8_t * q = img;
uint8_t w = *q++;
uint8_t hb = ((*q++) + 7) / 8;
uint8_t yShift = y % 8;
bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false);
q += idx*w*hb;
for (uint8_t yb = 0; yb < hb; yb++) {
uint8_t *p = &displayBuf[(y / 8 + yb) * LCD_W + x];
for (coord_t i=0; i<w; i++){
uint8_t b = *q++;
uint8_t b = inv ? ~(*q++) : *q++;
if (p < DISPLAY_END) {
*p++ = inv ? ~b : b;
if (!yShift) {
*p = b;
}
else {
*p = (*p & ((1 << yShift) - 1)) | (b << yShift);
if (p + LCD_W < DISPLAY_END) {
p[LCD_W] = (p[LCD_W] & (0xFF >> yShift)) | (b >> (8 - yShift));
}
}
}
p++;
}
}
}
+1 -1
View File
@@ -23,7 +23,7 @@
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint8_t delay)
{
lcdDrawTextAlignedLeft(y, str);
lcdDrawNumber(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
lcdDrawNumber(MIXES_2ND_COLUMN, y, delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX);
return delay;
}
+2 -2
View File
@@ -22,7 +22,7 @@
void menuRadioSpecialFunctions(event_t event)
{
#if defined(PCBTARANIS)
#if defined(NAVIGATION_X7)
const CustomFunctionData * cfn = &g_eeGeneral.customFn[menuVerticalPosition];
if (!CFN_SWITCH(cfn) && menuHorizontalPosition < 0 && event==EVT_KEY_BREAK(KEY_ENTER)) {
menuHorizontalPosition = 0;
@@ -33,7 +33,7 @@ void menuRadioSpecialFunctions(event_t event)
menuSpecialFunctions(event, g_eeGeneral.customFn, &globalFunctionsContext);
#if defined(PCBX7)
#if defined(NAVIGATION_X7)
if (!CFN_SWITCH(cfn) && menuHorizontalPosition == 0 && s_editMode <= 0) {
menuHorizontalPosition = -1;
}
+13 -11
View File
@@ -22,6 +22,15 @@
#define MODELSEL_W LCD_W
void onDeleteModelConfirm(const char * result)
{
if (result == STR_OK) {
storageCheck(true);
eeDeleteModel(menuVerticalPosition); // delete file
s_copyMode = 0;
}
}
void onModelSelectMenu(const char * result)
{
int8_t sub = menuVerticalPosition;
@@ -45,13 +54,14 @@ void onModelSelectMenu(const char * result)
POPUP_WARNING(eeBackupModel(sub));
}
else if (result == STR_RESTORE_MODEL || result == STR_UPDATE_LIST) {
if (!sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, NULL)) {
if (sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, nullptr))
POPUP_MENU_START(onModelSelectMenu);
else
POPUP_WARNING(STR_NO_MODELS_ON_SD);
}
}
#endif
else if (result == STR_DELETE_MODEL) {
POPUP_CONFIRMATION(STR_DELETEMODEL, nullptr);
POPUP_CONFIRMATION(STR_DELETEMODEL, onDeleteModelConfirm);
SET_WARNING_INFO(modelHeaders[sub].name, sizeof(g_model.header.name), ZCHAR);
}
#if defined(SDCARD)
@@ -68,14 +78,6 @@ void onModelSelectMenu(const char * result)
void menuModelSelect(event_t event)
{
if (warningResult) {
warningResult = 0;
storageCheck(true);
eeDeleteModel(menuVerticalPosition); // delete file
s_copyMode = 0;
event = EVT_ENTRY_UP;
}
event_t _event_ = event;
if ((s_copyMode && EVT_KEY_MASK(event) == KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT) || IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event)) {
_event_ = 0;
+42 -31
View File
@@ -90,7 +90,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_INTERNAL_MODULE_CHANNELS,
ITEM_MODEL_SETUP_INTERNAL_MODULE_NOT_ACCESS_BIND,
ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_MODEL_NUM,
#if defined(EXTERNAL_ANTENNA)
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
ITEM_MODEL_SETUP_INTERNAL_MODULE_ANTENNA,
#endif
ITEM_MODEL_SETUP_INTERNAL_MODULE_FAILSAFE,
@@ -224,8 +224,25 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
#define TRAINER_BLUETOOTH_S_ROW (bluetooth.distantAddr[0] == '\0' ? HIDDEN_ROW : LABEL())
#define IF_BT_TRAINER_ON(x) (g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER ? (uint8_t)(x) : HIDDEN_ROW)
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
#define EXTERNAL_ANTENNA_ROW ((isModuleXJT(INTERNAL_MODULE) && g_eeGeneral.antennaMode == ANTENNA_MODE_PER_MODEL) ? (uint8_t)0 : HIDDEN_ROW),
void onModelAntennaSwitchConfirm(const char * result)
{
if (result == STR_OK) {
// Switch to external antenna confirmation
g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode = ANTENNA_MODE_EXTERNAL;
globalData.externalAntennaEnabled = true;
storageDirty(EE_MODEL);
}
else {
reusableBuffer.moduleSetup.antennaMode = g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode;
}
}
#else
#define EXTERNAL_ANTENNA_ROW
#endif
#if defined(PCBX7) || defined(PCBX9LITE)
#define ANTENNA_ROW
#if defined(BLUETOOTH)
#define TRAINER_BLUETOOTH_ROW (g_model.trainerData.mode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_BLUETOOTH_M_ROW : (g_model.trainerData.mode == TRAINER_MODE_SLAVE_BLUETOOTH ? TRAINER_BLUETOOTH_S_ROW : HIDDEN_ROW)),
#else
@@ -234,12 +251,10 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
#define TRAINER_PPM_PARAMS_ROW (g_model.trainerData.mode == TRAINER_MODE_SLAVE ? (uint8_t)2 : HIDDEN_ROW)
#define TRAINER_ROWS LABEL(Trainer), 0, TRAINER_BLUETOOTH_ROW TRAINER_CHANNELS_ROW, TRAINER_PPM_PARAMS_ROW
#elif defined(PCBXLITES)
#define ANTENNA_ROW IF_NOT_PXX2_MODULE(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(0)),
#define TRAINER_BLUETOOTH_ROW (g_model.trainerData.mode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_BLUETOOTH_M_ROW : (g_model.trainerData.mode == TRAINER_MODE_SLAVE_BLUETOOTH ? TRAINER_BLUETOOTH_S_ROW : HIDDEN_ROW))
#define TRAINER_PPM_PARAMS_ROW (g_model.trainerData.mode == TRAINER_MODE_SLAVE ? (uint8_t)2 : HIDDEN_ROW)
#define TRAINER_ROWS LABEL(Trainer), 0, IF_BT_TRAINER_ON(TRAINER_BLUETOOTH_ROW), TRAINER_CHANNELS_ROW, TRAINER_PPM_PARAMS_ROW
#elif defined(PCBXLITE)
#define ANTENNA_ROW IF_NOT_PXX2_MODULE(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(0)),
#define TRAINER_BLUETOOTH_ROW (g_model.trainerData.mode == TRAINER_MODE_MASTER_BLUETOOTH ? TRAINER_BLUETOOTH_M_ROW : (g_model.trainerData.mode == TRAINER_MODE_SLAVE_BLUETOOTH ? TRAINER_BLUETOOTH_S_ROW : HIDDEN_ROW))
#define TRAINER_ROWS IF_BT_TRAINER_ON(LABEL(Trainer)), IF_BT_TRAINER_ON(0), IF_BT_TRAINER_ON(TRAINER_BLUETOOTH_ROW), IF_BT_TRAINER_ON(TRAINER_CHANNELS_ROW), HIDDEN_ROW /* xlite has only BT trainer, so never PPM */
#else
@@ -274,7 +289,7 @@ void onBluetoothConnectMenu(const char * result)
INTERNAL_MODULE_CHANNELS_ROWS, \
IF_NOT_ACCESS_MODULE_RF(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(isModuleRxNumAvailable(INTERNAL_MODULE) ? (uint8_t)2 : (uint8_t)1)), \
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* RxNum */ \
ANTENNA_ROW \
EXTERNAL_ANTENNA_ROW \
IF_INTERNAL_MODULE_ON(FAILSAFE_ROWS(INTERNAL_MODULE)), /* Failsafe */ \
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 1), /* Range check and Register buttons */ \
IF_PXX2_MODULE(INTERNAL_MODULE, 0), /* Module options */ \
@@ -285,16 +300,6 @@ void onBluetoothConnectMenu(const char * result)
#define INTERNAL_MODULE_ROWS
#endif
#if defined(EXTERNAL_ANTENNA)
void onAntennaSwitchConfirm(const char * result)
{
if (result == STR_OK) {
// Switch to external antenna confirmation
g_model.moduleData[INTERNAL_MODULE].pxx.external_antenna = XJT_EXTERNAL_ANTENNA;
}
}
#endif
void menuModelSetup(event_t event)
{
int8_t old_editMode = s_editMode;
@@ -372,6 +377,9 @@ void menuModelSetup(event_t event)
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) {
memclear(&reusableBuffer.moduleSetup, sizeof(reusableBuffer.moduleSetup));
reusableBuffer.moduleSetup.r9mPower = g_model.moduleData[EXTERNAL_MODULE].pxx.power;
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
reusableBuffer.moduleSetup.antennaMode = g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode;
#endif
}
#if (defined(DSM2) || defined(PXX))
@@ -910,16 +918,16 @@ void menuModelSetup(event_t event)
if (isModuleR9MNonAccess(EXTERNAL_MODULE)) {
if (g_model.moduleData[EXTERNAL_MODULE].subType > MODULE_SUBTYPE_R9M_EU) {
POPUP_WARNING(STR_MODULE_PROTOCOL_FLEX_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
#if POPUP_LEVEL >= 3
else if (g_model.moduleData[EXTERNAL_MODULE].subType == MODULE_SUBTYPE_R9M_EU) {
POPUP_WARNING(STR_R9M_PROTO_EU_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
POPUP_WARNING(STR_MODULE_PROTOCOL_EU_WARN_LINE1);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
else {
POPUP_WARNING(STR_R9M_PROTO_FCC_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
POPUP_WARNING(STR_MODULE_PROTOCOL_FCC_WARN_LINE1);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
#endif
}
@@ -1379,20 +1387,23 @@ void menuModelSetup(event_t event)
}
break;
#if defined(EXTERNAL_ANTENNA)
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
case ITEM_MODEL_SETUP_INTERNAL_MODULE_ANTENNA:
{
uint8_t newAntennaSel = editChoice(MODEL_SETUP_2ND_COLUMN, y, STR_ANTENNASELECTION, STR_VANTENNATYPES, g_model.moduleData[INTERNAL_MODULE].pxx.external_antenna, 0, 1, attr, event);
if (newAntennaSel != g_model.moduleData[INTERNAL_MODULE].pxx.external_antenna && newAntennaSel == XJT_EXTERNAL_ANTENNA) {
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onAntennaSwitchConfirm);
const char * w = STR_ANTENNACONFIRM2;
SET_WARNING_INFO(w, strlen(w), 0);
}
else {
g_model.moduleData[INTERNAL_MODULE].pxx.external_antenna = newAntennaSel;
reusableBuffer.moduleSetup.antennaMode = editChoice(MODEL_SETUP_2ND_COLUMN, y, INDENT TR_ANTENNA, STR_ANTENNA_MODES,
reusableBuffer.moduleSetup.antennaMode == ANTENNA_MODE_PER_MODEL ? ANTENNA_MODE_INTERNAL : reusableBuffer.moduleSetup.antennaMode,
ANTENNA_MODE_INTERNAL, ANTENNA_MODE_EXTERNAL, attr, event,
[](int value) { return value != ANTENNA_MODE_PER_MODEL; });
if (event && !s_editMode && reusableBuffer.moduleSetup.antennaMode != g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode) {
if (reusableBuffer.moduleSetup.antennaMode == ANTENNA_MODE_EXTERNAL && !isExternalAntennaEnabled()) {
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onModelAntennaSwitchConfirm);
SET_WARNING_INFO(STR_ANTENNACONFIRM2, sizeof(TR_ANTENNACONFIRM2), 0);
}
else {
g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode = reusableBuffer.moduleSetup.antennaMode;
checkExternalAntenna();
}
}
break;
}
#endif
case ITEM_MODEL_SETUP_EXTERNAL_MODULE_OPTIONS:
@@ -70,7 +70,6 @@ void onCustomFunctionsFileSelectionMenu(const char * result)
#endif // SDCARD
#if defined(PCBTARANIS)
void onAdjustGvarSourceLongEnterPress(const char * result)
{
CustomFunctionData * cfn = &g_model.customFn[menuVerticalPosition];
@@ -148,9 +147,8 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
#if defined(PCBTARANIS)
#if defined(PCBXLITE)
if (menuHorizontalPosition==0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
killEvents(KEY_ENTER);
if (IS_SHIFT_PRESSED()) { // ENT LONG on xlite brings up switch type menu, so this menu is activated with SHIT + ENT LONG
// ENT LONG on xlite brings up switch type menu, so this menu is activated with SHIT + ENT LONG
if (menuHorizontalPosition==0 && event==EVT_KEY_LONG(KEY_ENTER) && IS_SHIFT_PRESSED() && !READ_ONLY()) {
#else
if (menuHorizontalPosition<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
#endif
@@ -172,9 +170,6 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
}
POPUP_MENU_START(onCustomFunctionsMenu);
}
#if defined(PCBXLITE)
}
#endif
#endif // PCBTARANIS
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
@@ -389,7 +384,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
}
#if defined(PCBX7) || defined(PCBX9LITE)
#if defined(NAVIGATION_X7)
if (active || event==EVT_KEY_LONG(KEY_ENTER)) {
CFN_PARAM(cfn) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max);
if (func == FUNC_ADJUST_GVAR && attr && event==EVT_KEY_LONG(KEY_ENTER)) {
@@ -436,7 +431,7 @@ void menuSpecialFunctions(event_t event, CustomFunctionData * functions, CustomF
break;
}
}
#if defined(PCBX7) || defined(PCBX9LITE)
#if defined(NAVIGATION_X7)
if (sub==k && menuHorizontalPosition<0 && CFN_SWITCH(cfn)) {
lcdInvertLine(i+1);
}
+4 -1
View File
@@ -247,12 +247,15 @@ void menuModelTelemetry(event_t event)
case ITEM_TELEMETRY_RSSI_SOURCE: {
lcdDrawTextAlignedLeft(y, INDENT TR_SOURCE);
drawSource(TELEM_COL2, y, g_model.rssiSource ? MIXSRC_FIRST_TELEM + 3 * (g_model.rssiSource - 1) : 0, attr);
if (g_model.rssiSource) {
drawSource(TELEM_COL2, y, MIXSRC_FIRST_TELEM + 3 * (g_model.rssiSource - 1), attr);
TelemetrySensor * sensor = &g_model.telemetrySensors[g_model.rssiSource - 1];
lcdDrawText(lcdNextPos, y, " ", attr);
drawReceiverName(lcdNextPos, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, attr);
}
else {
lcdDrawText(TELEM_COL2, y, STR_DEFAULT, attr);
}
if (attr) {
g_model.rssiSource = checkIncDec(event, g_model.rssiSource, 0, MAX_TELEMETRY_SENSORS, EE_MODEL | NO_INCDEC_MARKS, isRssiSensorAvailable);
}
@@ -51,7 +51,7 @@ void menuModelSensor(event_t event)
0, // Name
0, // Type
sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, // ID / Formula
sensor->type == TELEM_TYPE_CALCULATED ? HIDDEN_ROW : LABEL(Receiver), // Receiver name
sensor->type == TELEM_TYPE_CALCULATED ? HIDDEN_ROW : READONLY_ROW, // Receiver name
((sensor->type == TELEM_TYPE_CALCULATED && (sensor->formula == TELEM_FORMULA_DIST)) || sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW), // Unit
(sensor->isPrecConfigurable() && sensor->unit != UNIT_FAHRENHEIT ? (uint8_t)0 : HIDDEN_ROW), // Precision
(sensor->unit >= UNIT_FIRST_VIRTUAL ? HIDDEN_ROW : (uint8_t)0), // Param1
@@ -84,7 +84,6 @@ void menuModelSensor(event_t event)
LcdFlags attr = (sub==k ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
switch (k) {
case SENSOR_FIELD_NAME:
editSingleName(SENSOR_2ND_COLUMN, y, STR_NAME, sensor->label, TELEM_LABEL_LEN, event, attr);
break;
@@ -106,7 +105,7 @@ void menuModelSensor(event_t event)
lcdDrawTextAlignedLeft(y, STR_ID);
lcdDrawHexNumber(SENSOR_2ND_COLUMN, y, sensor->id, LEFT|(menuHorizontalPosition==0 ? attr : 0));
lcdDrawHexChar(SENSOR_3RD_COLUMN, y, sensor->instance & 0x1f, LEFT|(menuHorizontalPosition==1 ? attr : 0));
if (attr) {
if (attr && s_editMode > 0) {
switch (menuHorizontalPosition) {
case 0:
CHECK_INCDEC_MODELVAR_ZERO(event, sensor->id, 0xffff);
@@ -143,8 +142,19 @@ void menuModelSensor(event_t event)
break;
case SENSOR_FILED_RECEIVER_NAME:
lcdDrawTextAlignedLeft(y, STR_RECEIVER);
drawReceiverName(SENSOR_2ND_COLUMN, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, 0);
lcdDrawTextAlignedLeft(y, STR_SOURCE);
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT && sensor->frskyInstance.rxIndex != TELEMETRY_ENDPOINT_SPORT) {
drawReceiverName(SENSOR_2ND_COLUMN, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, 0);
}
#if defined(HARDWARE_INTERNAL_MODULE)
else if (isModuleUsingSport(INTERNAL_MODULE, g_model.moduleData[INTERNAL_MODULE].type)) {
// far from perfect
lcdDrawText(SENSOR_2ND_COLUMN, y, STR_INTERNAL_MODULE);
}
#endif
else {
lcdDrawText(SENSOR_2ND_COLUMN, y, STR_EXTERNAL_MODULE);
}
break;
case SENSOR_FIELD_UNIT:
+6 -4
View File
@@ -511,14 +511,16 @@ void menuRadioSetup(event_t event)
#if defined(PWR_BUTTON_PRESS)
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, LCD_W - 2 - RADIO_SETUP_2ND_COLUMN, g_eeGeneral.pwrOnSpeed +1, 3, attr);
lcdDrawTextAlignedLeft(y, STR_PWR_ON_DELAY);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOnSpeed, attr|LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2);
break;
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, LCD_W - 2 - RADIO_SETUP_2ND_COLUMN, g_eeGeneral.pwrOffSpeed +1, 3, attr);
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_DELAY);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOffSpeed, attr|LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2);
break;
#endif
+17 -15
View File
@@ -22,33 +22,35 @@
void menuChannelsView(event_t event)
{
static bool longNames = false;
bool newLongNames = false;
static bool secondPage = false;
static bool mixersView = false;
uint8_t ch;
switch(event)
{
switch (event) {
case EVT_ENTRY:
memclear(&reusableBuffer.viewChannels, sizeof(reusableBuffer.viewChannels));
break;
case EVT_KEY_BREAK(KEY_EXIT):
popMenu();
break;
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_LEFT):
secondPage = !secondPage;
reusableBuffer.viewChannels.secondPage = !reusableBuffer.viewChannels.secondPage;
break;
case EVT_KEY_FIRST(KEY_ENTER):
mixersView = !mixersView;
reusableBuffer.viewChannels.mixersView = !reusableBuffer.viewChannels.mixersView;
break;
}
if (secondPage)
if (reusableBuffer.viewChannels.secondPage)
ch = 16;
else
ch = 0;
if (mixersView) {
if (reusableBuffer.viewChannels.mixersView) {
lcdDrawTextAlignedCenter(0, TR_MIXERS_MONITOR);
}
else {
@@ -67,13 +69,13 @@ void menuChannelsView(event_t event)
// Channels
for (uint8_t line=0; line<8; line++) {
uint8_t y = 9+line*7;
int32_t val = (mixersView) ? ex_chans[ch] : channelOutputs[ch];
int32_t val = (reusableBuffer.viewChannels.mixersView) ? ex_chans[ch] : channelOutputs[ch];
uint8_t ofs = (col ? 0 : 1);
// Channel name if present, number if not
uint8_t lenLabel = ZLEN(g_model.limitData[ch].name);
if (lenLabel > 4) {
newLongNames = longNames = true;
newLongNames = reusableBuffer.viewChannels.longNames = true;
}
if (lenLabel > 0)
@@ -83,13 +85,13 @@ void menuChannelsView(event_t event)
// Value
#if defined(PPM_UNIT_US)
uint8_t wbar = (longNames ? 54 : 64);
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE|RIGHT);
#elif defined(PPM_UNIT_PERCENT_PREC1)
uint8_t wbar = (longNames ? 48 : 58);
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 48 : 58);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE|RIGHT);
#else
uint8_t wbar = (longNames ? 54 : 64);
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE|RIGHT);
#endif
@@ -105,5 +107,5 @@ void menuChannelsView(event_t event)
}
}
longNames = newLongNames;
reusableBuffer.viewChannels.longNames = newLongNames;
}
+17 -10
View File
@@ -50,16 +50,24 @@
#define RSSSI_X (30)
#define RSSSI_Y (31)
#define RSSI_MAX 105
#define TRIM_LEN 23
void drawRSSIGauge()
void drawExternalAntennaAndRSSI()
{
uint8_t bar = (RSSI_MAX - g_model.rssiAlarms.getWarningRssi()) / 4;
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
if (isModuleXJT(INTERNAL_MODULE) && isExternalAntennaEnabled()) {
lcdDrawText(VBATT_X-1, VBATT_Y+8, "E", TINSIZE);
}
#endif
for(uint8_t i=1; i<5; i++) {
if((TELEMETRY_RSSI() - g_model.rssiAlarms.getWarningRssi()) > bar*(i-1)) {
lcdDrawFilledRect(RSSSI_X + i*4, RSSSI_Y - 2*i, 3, 2*i, SOLID, 0);
if (TELEMETRY_RSSI() > 0) {
auto warningRSSI = g_model.rssiAlarms.getWarningRssi();
int8_t value = TELEMETRY_RSSI() - warningRSSI;
uint8_t step = (RSSI_MAX - warningRSSI) / 4;
for (uint8_t i = 1; i < 5; i++) {
if (value > step * (i - 1)) {
lcdDrawFilledRect(RSSSI_X + i * 4, RSSSI_Y - 2 * i + 1, 3, 2 * i - 1, SOLID, 0);
}
}
}
}
@@ -271,6 +279,7 @@ void onMainViewMenu(const char *result)
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER2);
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER3);
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
POPUP_MENU_START(onMainViewMenu);
}
else if (result == STR_RESET_TELEMETRY) {
telemetryReset();
@@ -405,10 +414,8 @@ void menuMainView(event_t event)
// Trims sliders
displayTrims(mode);
// RSSI gauge
if (TELEMETRY_RSSI() > 0) {
drawRSSIGauge();
}
// RSSI gauge / external antenna
drawExternalAntennaAndRSSI();
}
if (view_base < VIEW_INPUTS) {
+1 -2
View File
@@ -111,7 +111,6 @@ void menuStatisticsDebug(event_t event)
switch (event) {
case EVT_ENTRY:
case EVT_ENTRY_UP:
enableVBatBridge();
break;
case EVT_KEY_LONG(KEY_ENTER):
@@ -160,7 +159,7 @@ void menuStatisticsDebug(event_t event)
if (IS_RESET_REASON_WATCHDOG()) {
lcdDrawText(LCD_W-8*FW, 0, "WATCHDOG");
}
else if (unexpectedShutdown) {
else if (globalData.unexpectedShutdown) {
lcdDrawText(LCD_W-13*FW, 0, "UNEXP.SHTDOWN");
}
#endif
+2 -2
View File
@@ -70,11 +70,11 @@ void title(const char * s)
lcdDrawText(0, 0, s, INVERS);
}
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event)
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable)
{
drawFieldLabel(x, y, label);
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
if (attr & (~RIGHT)) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
if (attr & (~RIGHT)) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL, isValueAvailable);
return value;
}
+1 -5
View File
@@ -209,7 +209,7 @@ void title(const char * s);
typedef int choice_t;
choice_t editChoice(coord_t x, coord_t y, const char *label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event);
choice_t editChoice(coord_t x, coord_t y, const char *label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable = nullptr);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label, LcdFlags attr, event_t event);
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event);
@@ -264,8 +264,6 @@ extern char statusLineMsg[STATUS_LINE_LENGTH];
void showStatusLine();
void drawStatusLine();
#define TEXT_FILENAME_MAXLEN 40
extern char s_text_file[TEXT_FILENAME_MAXLEN];
void menuTextView(event_t event);
void pushMenuTextView(const char *filename);
void pushModelNotes();
@@ -273,8 +271,6 @@ void readModelNotes();
void menuChannelsView(event_t event);
#define LABEL(...) (uint8_t)-1
#if defined(ROTARY_ENCODER_NAVIGATION)
#define CURSOR_MOVED_LEFT(event) (event==EVT_ROTARY_LEFT)
#define CURSOR_MOVED_RIGHT(event) (event==EVT_ROTARY_RIGHT)
+1 -1
View File
@@ -44,7 +44,7 @@ const MenuHandlerFunc menuTabModel[] = {
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint8_t delay)
{
lcdDrawTextAlignedLeft(y, str);
lcdDrawNumber(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
lcdDrawNumber(MIXES_2ND_COLUMN, y, delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX);
return delay;
}
+30 -31
View File
@@ -24,46 +24,45 @@ extern uint8_t g_moduleIdx;
void menuModelFailsafe(event_t event)
{
static uint8_t maxNameLen = 4;
static int8_t lastModel = g_eeGeneral.currModel;
const coord_t barH = (LCD_H - FH) / 8 - 1;
const int lim = (g_model.extendedLimits ? (512 * LIMIT_EXT_PERCENT / 100) : 512) * 2;
const uint8_t channelStart = g_model.moduleData[g_moduleIdx].channelsStart;
uint8_t cols = 1;
uint8_t colW = LCD_W;
if (lastModel != g_eeGeneral.currModel) {
lastModel = g_eeGeneral.currModel;
maxNameLen = 4;
}
switch(event) {
case EVT_ENTRY:
reusableBuffer.modelFailsafe.maxNameLen = 4;
break;
if (event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
event = 0;
case EVT_KEY_LONG(KEY_ENTER):
killEvents(event);
event = 0;
if (menuVerticalPosition < sentModuleChannels(g_moduleIdx)) {
if (s_editMode) {
g_model.failsafeChannels[menuVerticalPosition] = channelOutputs[menuVerticalPosition+channelStart];
s_editMode = 0;
if (menuVerticalPosition < sentModuleChannels(g_moduleIdx)) {
if (s_editMode) {
g_model.failsafeChannels[menuVerticalPosition] = channelOutputs[menuVerticalPosition+channelStart];
s_editMode = 0;
}
else {
int16_t * failsafe = &g_model.failsafeChannels[menuVerticalPosition];
if (*failsafe < FAILSAFE_CHANNEL_HOLD)
*failsafe = FAILSAFE_CHANNEL_HOLD;
else if (*failsafe == FAILSAFE_CHANNEL_HOLD)
*failsafe = FAILSAFE_CHANNEL_NOPULSE;
else
*failsafe = 0;
}
}
else {
int16_t * failsafe = &g_model.failsafeChannels[menuVerticalPosition];
if (*failsafe < FAILSAFE_CHANNEL_HOLD)
*failsafe = FAILSAFE_CHANNEL_HOLD;
else if (*failsafe == FAILSAFE_CHANNEL_HOLD)
*failsafe = FAILSAFE_CHANNEL_NOPULSE;
else
*failsafe = 0;
// "Outputs => Failsafe" menu item
setCustomFailsafe(g_moduleIdx);
}
}
else {
// "Outputs => Failsafe" menu item
setCustomFailsafe(g_moduleIdx);
}
storageDirty(EE_MODEL);
AUDIO_WARNING1();
SEND_FAILSAFE_NOW(g_moduleIdx);
storageDirty(EE_MODEL);
AUDIO_WARNING1();
SEND_FAILSAFE_NOW(g_moduleIdx);
break;
}
SIMPLE_SUBMENU_NOTITLE(sentModuleChannels(g_moduleIdx) + 1);
@@ -95,7 +94,7 @@ void menuModelFailsafe(event_t event)
const int32_t channelValue = channelOutputs[ch+channelStart];
int32_t failsafeValue = g_model.failsafeChannels[8*col+line];
uint8_t lenLabel = ZLEN(g_model.limitData[ch+channelStart].name);
uint8_t barW = colW - FW * maxNameLen - FWNUM * 3; // default bar width
uint8_t barW = colW - FW * reusableBuffer.modelFailsafe.maxNameLen - FWNUM * 3; // default bar width
#if defined(PPM_UNIT_PERCENT_PREC1)
barW -= FWNUM + 1;
@@ -104,8 +103,8 @@ void menuModelFailsafe(event_t event)
// Channel name if present, number if not
if (lenLabel > 0) {
if (lenLabel > maxNameLen)
maxNameLen = lenLabel;
if (lenLabel > reusableBuffer.modelFailsafe.maxNameLen)
reusableBuffer.modelFailsafe.maxNameLen = lenLabel;
lcdDrawSizedText(x - colW, y, g_model.limitData[ch+channelStart].name, sizeof(g_model.limitData[ch+channelStart].name), ZCHAR | SMLSIZE);
}
else {
+2 -2
View File
@@ -126,12 +126,12 @@ void menuModelFlightModesAll(event_t event)
}
case ITEM_FLIGHT_MODES_FADE_IN:
lcdDrawNumber(32*FW-2, y, (10/DELAY_STEP)*p->fadeIn, attr|PREC1|RIGHT);
lcdDrawNumber(32*FW-2, y, p->fadeIn, attr|PREC1|RIGHT);
if (active) p->fadeIn = checkIncDec(event, p->fadeIn, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS);
break;
case ITEM_FLIGHT_MODES_FADE_OUT:
lcdDrawNumber(35*FW, y, (10/DELAY_STEP)*p->fadeOut, attr|PREC1|RIGHT);
lcdDrawNumber(35*FW, y, p->fadeOut, attr|PREC1|RIGHT);
if (active) p->fadeOut = checkIncDec(event, p->fadeOut, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS);
break;
+3 -2
View File
@@ -45,9 +45,10 @@ void onModelSelectMenu(const char * result)
POPUP_WARNING(eeBackupModel(sub));
}
else if (result == STR_RESTORE_MODEL || result == STR_UPDATE_LIST) {
if (!sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, NULL)) {
if (sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, nullptr))
POPUP_MENU_START(onModelSelectMenu);
else
POPUP_WARNING(STR_NO_MODELS_ON_SD);
}
}
else if (result == STR_DELETE_MODEL) {
char * nametmp = reusableBuffer.modelsel.mainname;
+33 -31
View File
@@ -252,7 +252,7 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
return 1;
#if defined(MULTIMODULE)
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
return 2 + MULTIMODULE_RFPROTO_COLUMNS(EXTERNAL_MODULE);
return 1 + MULTIMODULE_RFPROTO_COLUMNS(EXTERNAL_MODULE);
}
#endif
else
@@ -384,7 +384,8 @@ void menuModelSetup(event_t event)
MENU_CHECK(menuTabModel, MENU_MODEL_SETUP, ITEM_MODEL_SETUP_LINES_COUNT);
title(STR_MENUSETUP);
if (event == EVT_ENTRY) {
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) {
memclear(&reusableBuffer.moduleSetup, sizeof(reusableBuffer.moduleSetup));
reusableBuffer.moduleSetup.r9mPower = g_model.moduleData[EXTERNAL_MODULE].pxx.power;
}
@@ -397,10 +398,10 @@ void menuModelSetup(event_t event)
int sub = menuVerticalPosition;
for (int i=0; i<NUM_BODY_LINES; ++i) {
for (int i = 0; i < NUM_BODY_LINES; ++i) {
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
uint8_t k = i+menuVerticalOffset;
for (int j=0; j<=k; j++) {
uint8_t k = i + menuVerticalOffset;
for (int j = 0; j <= k; j++) {
if (mstate_tab[j] == HIDDEN_ROW)
k++;
}
@@ -408,7 +409,7 @@ void menuModelSetup(event_t event)
LcdFlags blink = ((s_editMode>0) ? BLINK|INVERS : INVERS);
LcdFlags attr = (sub == k ? blink : 0);
switch(k) {
switch (k) {
case ITEM_MODEL_SETUP_NAME:
editSingleName(MODEL_SETUP_2ND_COLUMN, y, STR_MODELNAME, g_model.header.name, sizeof(g_model.header.name), event, attr);
memcpy(modelHeaders[g_eeGeneral.currModel].name, g_model.header.name, sizeof(g_model.header.name));
@@ -756,7 +757,7 @@ void menuModelSetup(event_t event)
#if defined(INTERNAL_MODULE_PXX1)
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_INTERNAL_MODULE_PROTOCOLS, g_model.moduleData[INTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0);
if (isModuleXJT(INTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_XJT_ACCST_RF_PROTOCOLS, 1 + g_model.moduleData[INTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_XJT_ACCST_RF_PROTOCOLS, 1 + g_model.moduleData[INTERNAL_MODULE].subType, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleISRM(INTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_ISRM_RF_PROTOCOLS, 1 + g_model.moduleData[INTERNAL_MODULE].subType, menuHorizontalPosition==1 ? attr : 0);
if (attr) {
@@ -807,7 +808,7 @@ void menuModelSetup(event_t event)
lcdDrawTextAlignedLeft(y, INDENT TR_MODE);
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_EXTERNAL_MODULE_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, menuHorizontalPosition==0 ? attr : 0);
if (isModuleXJT(EXTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_XJT_ACCST_RF_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_XJT_ACCST_RF_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].subType, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleDSM2(EXTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleR9MNonAccess(EXTERNAL_MODULE))
@@ -844,27 +845,28 @@ void menuModelSetup(event_t event)
}
case 1:
if (isModuleDSM2(EXTERNAL_MODULE))
if (isModuleDSM2(EXTERNAL_MODULE)) {
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, DSM2_PROTO_LP45, DSM2_PROTO_DSMX);
}
#if defined(MULTIMODULE)
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
int multiRfProto = g_model.moduleData[EXTERNAL_MODULE].multi.customProto == 1 ? MODULE_SUBTYPE_MULTI_CUSTOM : g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(false);
CHECK_INCDEC_MODELVAR(event, multiRfProto, MODULE_SUBTYPE_MULTI_FIRST, MODULE_SUBTYPE_MULTI_LAST);
if (checkIncDec_Ret) {
g_model.moduleData[EXTERNAL_MODULE].multi.customProto = (multiRfProto == MODULE_SUBTYPE_MULTI_CUSTOM);
if (!g_model.moduleData[EXTERNAL_MODULE].multi.customProto)
g_model.moduleData[EXTERNAL_MODULE].setMultiProtocol(multiRfProto);
g_model.moduleData[EXTERNAL_MODULE].subType = 0;
// Sensible default for DSM2 (same as for ppm): 7ch@22ms + Autodetect settings enabled
if (g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) == MODULE_SUBTYPE_MULTI_DSM2) {
g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode = 1;
}
else {
g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode = 0;
}
g_model.moduleData[EXTERNAL_MODULE].multi.optionValue = 0;
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
int multiRfProto = g_model.moduleData[EXTERNAL_MODULE].multi.customProto == 1 ? MODULE_SUBTYPE_MULTI_CUSTOM : g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(false);
CHECK_INCDEC_MODELVAR(event, multiRfProto, MODULE_SUBTYPE_MULTI_FIRST, MODULE_SUBTYPE_MULTI_LAST);
if (checkIncDec_Ret) {
g_model.moduleData[EXTERNAL_MODULE].multi.customProto = (multiRfProto == MODULE_SUBTYPE_MULTI_CUSTOM);
if (!g_model.moduleData[EXTERNAL_MODULE].multi.customProto)
g_model.moduleData[EXTERNAL_MODULE].setMultiProtocol(multiRfProto);
g_model.moduleData[EXTERNAL_MODULE].subType = 0;
// Sensible default for DSM2 (same as for ppm): 7ch@22ms + Autodetect settings enabled
if (g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol(true) == MODULE_SUBTYPE_MULTI_DSM2) {
g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode = 1;
}
else {
g_model.moduleData[EXTERNAL_MODULE].multi.autoBindMode = 0;
}
g_model.moduleData[EXTERNAL_MODULE].multi.optionValue = 0;
}
}
#endif
else if (isModuleR9MNonAccess(EXTERNAL_MODULE)) {
g_model.moduleData[EXTERNAL_MODULE].subType = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].subType,
@@ -872,7 +874,7 @@ void menuModelSetup(event_t event)
isR9MModeAvailable);
}
else {
g_model.moduleData[EXTERNAL_MODULE].rfProtocol = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol,
g_model.moduleData[EXTERNAL_MODULE].subType = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].subType,
MODULE_SUBTYPE_PXX1_ACCST_D16, MODULE_SUBTYPE_PXX1_LAST, EE_MODEL,
isRfProtocolAvailable);
}
@@ -907,16 +909,16 @@ void menuModelSetup(event_t event)
if (isModuleR9MNonAccess(EXTERNAL_MODULE)) {
if (g_model.moduleData[EXTERNAL_MODULE].subType > MODULE_SUBTYPE_R9M_EU) {
POPUP_WARNING(STR_MODULE_PROTOCOL_FLEX_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
#if POPUP_LEVEL >= 3
else if (g_model.moduleData[EXTERNAL_MODULE].subType == MODULE_SUBTYPE_R9M_EU) {
POPUP_WARNING(STR_R9M_PROTO_EU_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
POPUP_WARNING(STR_MODULE_PROTOCOL_EU_WARN_LINE1);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
else {
POPUP_WARNING(STR_R9M_PROTO_FCC_WARN_LINE1);
SET_WARNING_INFO(STR_R9M_PROTO_WARN_LINE2, sizeof(TR_R9M_PROTO_WARN_LINE2) - 1, 0);
POPUP_WARNING(STR_MODULE_PROTOCOL_FCC_WARN_LINE1);
SET_WARNING_INFO(STR_MODULE_PROTOCOL_WARN_LINE2, sizeof(TR_MODULE_PROTOCOL_WARN_LINE2) - 1, 0);
}
#endif
}
+4 -1
View File
@@ -238,12 +238,15 @@ void menuModelTelemetry(event_t event)
case ITEM_TELEMETRY_RSSI_SOURCE: {
lcdDrawTextAlignedLeft(y, INDENT TR_SOURCE);
drawSource(TELEM_COL2, y, g_model.rssiSource ? MIXSRC_FIRST_TELEM + 3 * (g_model.rssiSource - 1) : 0, attr);
if (g_model.rssiSource) {
drawSource(TELEM_COL2, y, MIXSRC_FIRST_TELEM + 3 * (g_model.rssiSource - 1), attr);
TelemetrySensor * sensor = &g_model.telemetrySensors[g_model.rssiSource - 1];
lcdDrawText(lcdNextPos, y, " ", attr);
drawReceiverName(lcdNextPos, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, attr);
}
else {
lcdDrawText(TELEM_COL2, y, STR_DEFAULT, attr);
}
if (attr) {
g_model.rssiSource = checkIncDec(event, g_model.rssiSource, 0, MAX_TELEMETRY_SENSORS, EE_MODEL | NO_INCDEC_MARKS, isRssiSensorAvailable);
}
@@ -25,6 +25,7 @@ enum SensorFields {
SENSOR_FIELD_TYPE,
SENSOR_FIELD_ID,
SENSOR_FIELD_FORMULA=SENSOR_FIELD_ID,
SENSOR_FILED_RECEIVER_NAME,
SENSOR_FIELD_UNIT,
SENSOR_FIELD_PRECISION,
SENSOR_FIELD_PARAM1,
@@ -61,7 +62,23 @@ void menuModelSensor(event_t event)
drawSensorCustomValue(25*FW, 0, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx));
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, { 0, 0, sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, SENSOR_UNIT_ROWS, SENSOR_PREC_ROWS, SENSOR_PARAM1_ROWS, SENSOR_PARAM2_ROWS, SENSOR_PARAM3_ROWS, SENSOR_PARAM4_ROWS, SENSOR_AUTOOFFSET_ROWS, SENSOR_ONLYPOS_ROWS, SENSOR_FILTER_ROWS, SENSOR_PERSISTENT_ROWS, 0 });
SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, {
0, //Name
0, // Type
sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, // ID / Formula
sensor->type == TELEM_TYPE_CALCULATED ? HIDDEN_ROW : READONLY_ROW, // Receiver name
SENSOR_UNIT_ROWS,
SENSOR_PREC_ROWS,
SENSOR_PARAM1_ROWS,
SENSOR_PARAM2_ROWS,
SENSOR_PARAM3_ROWS,
SENSOR_PARAM4_ROWS,
SENSOR_AUTOOFFSET_ROWS,
SENSOR_ONLYPOS_ROWS,
SENSOR_FILTER_ROWS,
SENSOR_PERSISTENT_ROWS,
0 // Logs
});
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
coord_t y = MENU_HEADER_HEIGHT + 1 + i*FH;
@@ -130,6 +147,20 @@ void menuModelSensor(event_t event)
}
break;
case SENSOR_FILED_RECEIVER_NAME:
lcdDrawTextAlignedLeft(y, STR_SOURCE);
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT && sensor->frskyInstance.rxIndex != TELEMETRY_ENDPOINT_SPORT) {
drawReceiverName(SENSOR_2ND_COLUMN, y, sensor->frskyInstance.rxIndex >> 2, sensor->frskyInstance.rxIndex & 0x03, 0);
}
else if (isModuleUsingSport(INTERNAL_MODULE, g_model.moduleData[INTERNAL_MODULE].type)) {
// far from perfect
lcdDrawText(SENSOR_2ND_COLUMN, y, STR_INTERNAL_MODULE);
}
else {
lcdDrawText(SENSOR_2ND_COLUMN, y, STR_EXTERNAL_MODULE);
}
break;
case SENSOR_FIELD_UNIT:
lcdDrawTextAlignedLeft(y, STR_UNIT);
lcdDrawTextAtIndex(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr);
+7 -5
View File
@@ -472,14 +472,16 @@ void menuRadioSetup(event_t event)
#if defined(PWR_BUTTON_PRESS)
case ITEM_RADIO_SETUP_PWR_ON_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed +1, 3, attr);
lcdDrawTextAlignedLeft(y, STR_PWR_ON_DELAY);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOnSpeed, attr|LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2);
break;
case ITEM_RADIO_SETUP_PWR_OFF_SPEED:
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED);
drawSlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed +1, 3, attr);
lcdDrawTextAlignedLeft(y, STR_PWR_OFF_DELAY);
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 2 - g_eeGeneral.pwrOffSpeed, attr|LEFT);
lcdDrawChar(lcdLastRightPos, y, 's');
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2);
break;
#endif
@@ -528,7 +530,7 @@ void menuRadioSetup(event_t event)
#if defined(FAI_CHOICE)
case ITEM_RADIO_SETUP_FAI:
editCheckBox(g_eeGeneral.fai, RADIO_SETUP_2ND_COLUMN, y, "FAI Mode"), attr, event;
editCheckBox(g_eeGeneral.fai, RADIO_SETUP_2ND_COLUMN, y, "FAI Mode", attr, event);
if (attr && checkIncDec_Ret) {
if (g_eeGeneral.fai)
POPUP_WARNING("FAI\001mode blocked!");
+15 -13
View File
@@ -22,44 +22,46 @@
void menuChannelsView(event_t event)
{
static bool longNames = false;
static bool secondPage = false;
static bool mixersView = false;
uint8_t ch = 0;
uint8_t wbar = (longNames ? 54 : 64);
uint8_t wbar = (reusableBuffer.viewChannels.longNames ? 54 : 64);
int16_t limits = 512 * 2;
#if defined(PPM_UNIT_PERCENT_PREC1)
wbar -= 6;
#endif
switch(event)
{
switch(event) {
case EVT_ENTRY:
memclear(&reusableBuffer.viewChannels, sizeof(reusableBuffer.viewChannels));
break;
case EVT_KEY_BREAK(KEY_EXIT):
popMenu();
break;
case EVT_KEY_FIRST(KEY_RIGHT):
case EVT_KEY_FIRST(KEY_LEFT):
#if defined(ROTARY_ENCODER_NAVIGATION)
case EVT_ROTARY_LEFT:
case EVT_ROTARY_RIGHT:
#endif
secondPage = !secondPage;
reusableBuffer.viewChannels.secondPage = !reusableBuffer.viewChannels.secondPage;
break;
case EVT_KEY_FIRST(KEY_ENTER):
mixersView = !mixersView;
reusableBuffer.viewChannels.mixersView = !reusableBuffer.viewChannels.mixersView;
break;
}
if (secondPage)
if (reusableBuffer.viewChannels.secondPage)
ch = 16;
if (mixersView)
if (reusableBuffer.viewChannels.mixersView)
limits *= 2; // this could be handled nicer, but slower, by checking actual range for this mixer
else if (g_model.extendedLimits)
limits *= LIMIT_EXT_PERCENT / 100;
if (mixersView)
if (reusableBuffer.viewChannels.mixersView)
lcdDrawTextAlignedCenter(0, TR_MIXERS_MONITOR);
else
lcdDrawTextAlignedCenter(0, TR_CHANNELS_MONITOR);
@@ -76,13 +78,13 @@ void menuChannelsView(event_t event)
// Channels
for (uint8_t line=0; line < 8; line++) {
const uint8_t y = 9 + line * 7;
const int32_t val = mixersView ? ex_chans[ch] : channelOutputs[ch];
const int32_t val = reusableBuffer.viewChannels.mixersView ? ex_chans[ch] : channelOutputs[ch];
const uint8_t lenLabel = ZLEN(g_model.limitData[ch].name);
// Channel name if present, number if not
if (lenLabel > 0) {
if (lenLabel > 4)
longNames = true;
reusableBuffer.viewChannels.longNames = true;
lcdDrawSizedText(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE);
}
else {
+2 -12
View File
@@ -342,7 +342,7 @@ void menuMainViewChannelsMonitor(event_t event)
return menuChannelsView(event);
}
void onMainViewMenu(const char *result)
void onMainViewMenu(const char * result)
{
if (result == STR_RESET_TIMER1) {
timerReset(0);
@@ -364,6 +364,7 @@ void onMainViewMenu(const char *result)
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER2);
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER3);
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
POPUP_MENU_START(onMainViewMenu);
}
else if (result == STR_RESET_TELEMETRY) {
telemetryReset();
@@ -409,16 +410,6 @@ void displaySwitch(coord_t x, coord_t y, int width, unsigned int index)
}
}
bool isMenuAvailable(int index)
{
if (index == 4) {
return modelHasNotes();
}
else {
return true;
}
}
int getSwitchCount()
{
int count = 0;
@@ -435,7 +426,6 @@ void menuMainView(event_t event)
static bool secondPage = false;
switch(event) {
case EVT_ENTRY:
killEvents(KEY_EXIT);
killEvents(KEY_UP);
+1 -6
View File
@@ -115,12 +115,7 @@ void menuStatisticsDebug(event_t event)
}
#endif
switch(event) {
case EVT_ENTRY:
case EVT_ENTRY_UP:
enableVBatBridge();
break;
switch (event) {
case EVT_KEY_LONG(KEY_ENTER):
g_eeGeneral.globalTimer = 0;
sessionTimer = 0;
+2 -2
View File
@@ -81,11 +81,11 @@ void title(const char * s)
lcdDrawText(0, 0, s, INVERS);
}
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event)
choice_t editChoice(coord_t x, coord_t y, const char * label, const char *values, choice_t value, choice_t min, choice_t max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable)
{
drawFieldLabel(x, y, label);
if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr);
if (attr & (~RIGHT)) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL);
if (attr & (~RIGHT)) value = checkIncDec(event, value, min, max, (isModelMenuDisplayed()) ? EE_MODEL : EE_GENERAL, isValueAvailable);
return value;
}
+4
View File
@@ -64,6 +64,10 @@ const uint8_t LBM_TOPMENU_TXBATT[] = {
#include "mask_txbat.lbm"
};
const uint8_t LBM_TOPMENU_ANTENNA[] = {
#include "mask_antenna.lbm"
};
const uint8_t LBM_HTRIM_FRAME[] = {
#include "mask_htrim_frame.lbm"
};
+1
View File
@@ -26,6 +26,7 @@ extern const uint8_t LBM_DOT[];
// Main view icons
extern const uint8_t LBM_TOPMENU_USB[];
extern const uint8_t LBM_TOPMENU_ANTENNA[];
extern const uint8_t LBM_TOPMENU_VOLUME_0[];
extern const uint8_t LBM_TOPMENU_VOLUME_1[];
extern const uint8_t LBM_TOPMENU_VOLUME_2[];
-3
View File
@@ -342,9 +342,6 @@ extern uint8_t popupMenuOffsetType;
extern uint8_t popupMenuSelectedItem;
const char * runPopupMenu(event_t event);
extern void (*popupMenuHandler)(const char * result);
#define TEXT_FILENAME_MAXLEN 40
extern char s_text_file[TEXT_FILENAME_MAXLEN];
void pushMenuTextView(const char * filename);
void pushModelNotes();
void readModelNotes();
+4 -6
View File
@@ -133,15 +133,13 @@ void ModelFlightModesPage::build(FormWindow * window)
// Flight mode fade in / out
new StaticText(group, grid.getLabelSlot(true), "Fade in/out");
auto edit = new NumberEdit(group, grid.getFieldSlot(2, 0), 0, DELAY_MAX,
GET_DEFAULT(g_model.flightModeData[i].fadeIn * (10 / DELAY_STEP)),
SET_VALUE(g_model.flightModeData[i].fadeIn, newValue / (10 / DELAY_STEP)),
GET_DEFAULT(g_model.flightModeData[i].fadeIn),
SET_VALUE(g_model.flightModeData[i].fadeIn, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit = new NumberEdit(group, grid.getFieldSlot(2, 1), 0, DELAY_MAX,
GET_DEFAULT(g_model.flightModeData[i].fadeOut * (10 / DELAY_STEP)),
SET_VALUE(g_model.flightModeData[i].fadeOut, newValue / (10 / DELAY_STEP)),
GET_DEFAULT(g_model.flightModeData[i].fadeOut),
SET_VALUE(g_model.flightModeData[i].fadeOut, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
grid.nextLine();
group->setLastField(FormField::getCurrentField());
+3 -2
View File
@@ -158,14 +158,15 @@ bool menuModelGVars(event_t event)
gvar_t v = fm->gvars[i];
LcdFlags attr = RIGHT | ((sub == i && menuHorizontalPosition == j) ? (s_editMode > 0 ? BLINK | INVERS : INVERS) : 0);
if (j == curfm)
attr |= BOLD;
coord_t x = GVARS_FM_COLUMN(j);
coord_t yval = y;
if (v <= GVAR_MAX && (g_model.gvars[i].prec > 0 || abs(v) >= 1000 || ( abs(v) >= 100 && g_model.gvars[i].unit > 0))) {
attr |= SMLSIZE;
yval += 3;
}
else if (j == curfm) {
attr |= BOLD;
}
if (v <= GVAR_MAX && g_model.gvars[i].unit > 0) {
x -= 9;
lcdDrawText(GVARS_FM_COLUMN(j) - 9, y+5, "%", TINSIZE);
-4
View File
@@ -190,7 +190,6 @@ class MixEditWindow : public Page {
GET_DEFAULT(mix->delayUp),
SET_VALUE(mix->delayUp, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit->setSuffix("s");
grid.nextLine();
@@ -200,7 +199,6 @@ class MixEditWindow : public Page {
GET_DEFAULT(mix->delayDown),
SET_VALUE(mix->delayDown, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit->setSuffix("s");
grid.nextLine();
@@ -210,7 +208,6 @@ class MixEditWindow : public Page {
GET_DEFAULT(mix->speedUp),
SET_VALUE(mix->speedUp, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit->setSuffix("s");
grid.nextLine();
@@ -220,7 +217,6 @@ class MixEditWindow : public Page {
GET_DEFAULT(mix->speedDown),
SET_VALUE(mix->speedDown, newValue),
PREC1);
edit->setStep(10 / DELAY_STEP);
edit->setSuffix("s");
grid.nextLine();
+23 -22
View File
@@ -219,6 +219,27 @@ bool menuModelWizard(event_t event)
}
#endif
void onDeleteModelConfirm(const char * result)
{
if (result == STR_OK) {
if (deleteMode == MODE_DELETE_CATEGORY) {
modelslist.removeCategory(currentCategory);
modelslist.save();
setCurrentCategory(currentCategoryIndex > 0 ? currentCategoryIndex-1 : currentCategoryIndex);
}
else if (deleteMode == MODE_DELETE_MODEL){
int modelIndex = MODEL_INDEX();
modelslist.removeModel(currentCategory, currentModel);
s_copyMode = 0;
putEvent(EVT_REFRESH);
if (modelIndex > 0) {
modelIndex--;
}
setCurrentModel(modelIndex);
}
}
}
void onModelSelectMenu(const char * result)
{
if (result == STR_SELECT_MODEL) {
@@ -233,7 +254,7 @@ void onModelSelectMenu(const char * result)
chainMenu(menuMainView);
}
else if (result == STR_DELETE_MODEL) {
POPUP_CONFIRMATION(STR_DELETEMODEL);
POPUP_CONFIRMATION(STR_DELETEMODEL, onDeleteModelConfirm);
SET_WARNING_INFO(currentModel->modelName, LEN_MODEL_NAME, 0);
deleteMode = MODE_DELETE_MODEL;
}
@@ -279,7 +300,7 @@ void onModelSelectMenu(const char * result)
SET_WARNING_INFO(STR_CAT_NOT_EMPTY, sizeof(TR_CAT_NOT_EMPTY), 0);
}
else {
POPUP_CONFIRMATION(STR_DELETEMODEL);
POPUP_CONFIRMATION(STR_DELETEMODEL, onDeleteModelConfirm);
SET_WARNING_INFO(currentCategory->name, LEN_MODEL_FILENAME, 0);
deleteMode = MODE_DELETE_CATEGORY;
}
@@ -322,26 +343,6 @@ void initModelsList()
bool menuModelSelect(event_t event)
{
if (warningResult) {
warningResult = 0;
if (deleteMode == MODE_DELETE_CATEGORY) {
TRACE("DELETE CATEGORY");
modelslist.removeCategory(currentCategory);
modelslist.save();
setCurrentCategory(currentCategoryIndex > 0 ? currentCategoryIndex-1 : currentCategoryIndex);
}
else if (deleteMode == MODE_DELETE_MODEL){
int modelIndex = MODEL_INDEX();
modelslist.removeModel(currentCategory, currentModel);
s_copyMode = 0;
event = EVT_REFRESH;
if (modelIndex > 0) {
modelIndex--;
}
setCurrentModel(modelIndex);
}
}
const std::list<ModelsCategory*>& cats = modelslist.getCategories();
switch(event) {
case 0:
+8 -8
View File
@@ -831,20 +831,20 @@ void onBindMenu(const char * result)
uint8_t moduleIdx = 0; // TODO (menuVerticalPosition >= ITEM_MODEL_EXTERNAL_MODULE_LABEL ? EXTERNAL_MODULE : INTERNAL_MODULE);
if (result == STR_BINDING_1_8_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
}
else if (result == STR_BINDING_1_8_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
}
else if (result == STR_BINDING_9_16_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else if (result == STR_BINDING_9_16_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else {
return;
+1 -1
View File
@@ -118,7 +118,7 @@ void RadioToolsPage::checkEvents()
void RadioToolsPage::rebuild(FormWindow * window)
{
FormGridLayout grid;
grid.spacer(8);
grid.spacer(PAGE_PADDING);
grid.setLabelWidth(100);
window->clear();
+1 -1
View File
@@ -36,8 +36,8 @@ void RadioTrainerPage::build(FormWindow * window)
#define TRAINER_LABEL_WIDTH 100
#endif
FormGridLayout grid;
grid.spacer(PAGE_PADDING);
grid.setLabelWidth(TRAINER_LABEL_WIDTH);
grid.nextLine();
for (uint8_t i=0; i<NUM_STICKS; i++) {
uint8_t chan = channelOrder(i+1);
+1 -1
View File
@@ -96,7 +96,7 @@ class FrskyTheme: public Theme
void loadIcons() const
{
#if defined(LOG_TELEMETRY) || defined(WATCHDOG_DISABLED)
#if defined(LOG_TELEMETRY) || !defined(WATCHDOG)
loadMenuIcon(ICON_OPENTX, "mask_opentx_testmode.png", TEXT_COLOR);
#else
loadMenuIcon(ICON_OPENTX, "mask_opentx.png");
+6
View File
@@ -55,6 +55,12 @@ void drawTopBar()
lcdDrawSolidFilledRect(LCD_W-90 + i * 6, 38 - height, 4, height, TELEMETRY_RSSI() >= rssiBarsValue[i] ? MENU_TITLE_COLOR : MENU_TITLE_DISABLE_COLOR);
}
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
if (isModuleXJT(INTERNAL_MODULE) && isExternalAntennaEnabled()) {
lcdDrawBitmapPattern(LCD_W-94, 4, LBM_TOPMENU_ANTENNA, MENU_TITLE_COLOR);
}
#endif
/* Audio volume */
lcdDrawBitmapPattern(LCD_W-130, 4, LBM_TOPMENU_VOLUME_SCALE, MENU_TITLE_DISABLE_COLOR);
if (requiredSpeakerVolume == 0 || g_eeGeneral.beepMode == e_mode_quiet)
@@ -98,7 +98,6 @@ bool menuStatsDebug(event_t event)
switch(event) {
case EVT_ENTRY:
case EVT_ENTRY_UP:
enableVBatBridge();
break;
case EVT_KEY_FIRST(KEY_ENTER):
+8 -81
View File
@@ -20,91 +20,17 @@
#include "opentx.h"
#define TEXT_FILE_MAXSIZE 2048
char s_text_file[TEXT_FILENAME_MAXLEN];
char s_text_screen[NUM_BODY_LINES][LCD_COLS+1];
void readTextFile(int & lines_count)
{
FIL file;
int result;
char c;
unsigned int sz;
int line_length = 0;
int escape = 0;
char escape_chars[2];
int current_line = 0;
memset(s_text_screen, 0, sizeof(s_text_screen));
result = f_open(&file, s_text_file, FA_OPEN_EXISTING | FA_READ);
if (result == FR_OK) {
for (int i=0; i<TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz)==FR_OK && sz==1 && (lines_count==0 || current_line-menuVerticalOffset<NUM_BODY_LINES); i++) {
if (c == '\n') {
++current_line;
line_length = 0;
escape = 0;
}
else if (c!='\r' && current_line>=menuVerticalOffset && current_line-menuVerticalOffset<NUM_BODY_LINES && line_length<LCD_COLS) {
if (c=='\\' && escape==0) {
escape = 1;
continue;
}
else if (c!='\\' && escape>0 && escape<4) {
escape_chars[escape-1] = c;
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
c = '\300';
escape = 0;
}
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
c = '\301';
escape = 0;
}
else if (escape == 3) {
int val = atoi(escape_chars);
if (val >= 200 && val < 225) {
c = '\200' + val-200;
}
escape = 0;
}
else {
escape++;
continue;
}
}
else if (c=='~') {
c = 'z'+1;
}
else if (c=='\t') {
c = 0x1D; //tab
}
escape = 0;
s_text_screen[current_line-menuVerticalOffset][line_length++] = c;
}
}
if (c != '\n') {
current_line += 1;
}
f_close(&file);
}
if (lines_count == 0) {
lines_count = current_line;
}
}
bool menuTextView(event_t event)
{
static int lines_count;
drawMenuTemplate(STR_TEXT_VIEWER, ICON_OPENTX);
drawMenuTemplate(STR_TEXT_VIEWER, ICON_OPENTX, nullptr, OPTION_MENU_NO_SCROLLBAR);
switch (event) {
case EVT_ENTRY:
menuVerticalOffset = 0;
lines_count = 0;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_ROTARY_LEFT:
@@ -112,24 +38,25 @@ bool menuTextView(event_t event)
break;
else
menuVerticalOffset--;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_ROTARY_RIGHT:
if (menuVerticalOffset+NUM_BODY_LINES >= lines_count)
if (menuVerticalOffset + NUM_BODY_LINES >= lines_count)
break;
else
++menuVerticalOffset;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, lines_count);
break;
case EVT_KEY_FIRST(KEY_EXIT):
menuVerticalOffset = 0;
popMenu();
break;
}
for (int i=0; i<NUM_BODY_LINES; i++) {
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + i*FH, s_text_screen[i]);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + i*FH, reusableBuffer.viewText.lines[i]);
}
#if 0
@@ -148,7 +75,7 @@ bool menuTextView(event_t event)
void pushMenuTextView(const char *filename)
{
if (strlen(filename) < TEXT_FILENAME_MAXLEN) {
strcpy(s_text_file, filename);
strcpy(reusableBuffer.viewText.filename, filename);
pushMenu(menuTextView);
}
}
+3 -2
View File
@@ -22,6 +22,7 @@
#define _WIDGET_H_
#include <list>
#include <string.h>
#include "zone.h"
#define MAX_WIDGET_OPTIONS 5
@@ -58,7 +59,7 @@ class Widget
virtual const char * getErrorMessage() const
{
return NULL;
return nullptr;
}
inline ZoneOptionValue * getOptionValue(unsigned int index) const
@@ -83,7 +84,7 @@ void registerWidget(const WidgetFactory * factory);
class WidgetFactory
{
public:
WidgetFactory(const char * name, const ZoneOption * options=NULL):
WidgetFactory(const char * name, const ZoneOption * options=nullptr):
name(name),
options(options)
{
@@ -25,7 +25,7 @@
void drawStringWithIndex(coord_t x, coord_t y, const char * str, int idx, LcdFlags flags, const char * prefix, const char * suffix);
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att);
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event);
int editChoice(coord_t x, coord_t y, const char * values, int value, int min, int max, LcdFlags attr, event_t event, IsValueAvailable isValueAvailable=nullptr);
uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, LcdFlags attr, event_t event);
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t event);
void drawFatalErrorScreen(const char * message);
+2 -2
View File
@@ -23,8 +23,8 @@
void menuModelNotes(event_t event)
{
if (event == EVT_ENTRY) {
strcpy(s_text_file, MODELS_PATH "/");
char *buf = strcat_modelname(&s_text_file[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(reusableBuffer.viewText.filename, MODELS_PATH "/");
char *buf = strcat_modelname(&reusableBuffer.viewText.filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(buf, TEXT_EXT);
}
@@ -24,26 +24,26 @@ void onBindMenu(const char * result)
uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition - HEADER_LINE);
if (result == STR_BINDING_1_8_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
if (isModuleR9MLiteNonPro(moduleIdx) && isModuleR9M_LBT(moduleIdx)) {
g_model.moduleData[moduleIdx].pxx.power = R9M_LITE_LBT_POWER_25_8CH;
}
}
else if (result == STR_BINDING_1_8_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = false;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = false;
if (isModuleR9MLiteNonPro(moduleIdx) && isModuleR9M_LBT(moduleIdx)) {
g_model.moduleData[moduleIdx].pxx.power = R9M_LITE_LBT_POWER_100_16CH_NOTELEM;
}
}
else if (result == STR_BINDING_9_16_TELEM_ON) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = false;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = false;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else if (result == STR_BINDING_9_16_TELEM_OFF) {
g_model.moduleData[moduleIdx].pxx.receiver_telem_off = true;
g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16 = true;
g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff = true;
g_model.moduleData[moduleIdx].pxx.receiverHigherChannels = true;
}
else {
return;
@@ -66,13 +66,13 @@ void startBindMenu(uint8_t moduleIdx)
POPUP_MENU_ADD_ITEM(STR_BINDING_9_16_TELEM_OFF);
}
if (isBindCh9To16Allowed(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiver_channel_9_16) {
if (isBindCh9To16Allowed(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiverHigherChannels) {
selection += 1;
if (isTelemAllowedOnBind(moduleIdx))
selection += 1;
}
if (isTelemAllowedOnBind(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiver_telem_off)
if (isTelemAllowedOnBind(moduleIdx) && g_model.moduleData[moduleIdx].pxx.receiverTelemetryOff)
selection += 1;
POPUP_MENU_SELECT_ITEM(selection);
@@ -298,13 +298,15 @@ void modelSetupModulePxx2ReceiverLine(uint8_t moduleIdx, uint8_t receiverIdx, co
if (moduleState[moduleIdx].mode == MODULE_MODE_BIND) {
if (reusableBuffer.moduleSetup.bindInformation.step == BIND_INIT) {
if (reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount > 0) {
popupMenuItemsCount = min<uint8_t>(reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE);
for (auto rx = 0; rx < popupMenuItemsCount; rx++) {
popupMenuItems[rx] = reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[rx];
if (reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount != popupMenuItemsCount) {
CLEAR_POPUP();
popupMenuItemsCount = reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount;
for (auto rx = 0; rx < popupMenuItemsCount; rx++) {
popupMenuItems[rx] = reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[rx];
}
popupMenuTitle = STR_PXX2_SELECT_RX;
POPUP_MENU_START(onPXX2BindMenu);
}
popupMenuTitle = STR_PXX2_SELECT_RX;
CLEAR_POPUP();
POPUP_MENU_START(onPXX2BindMenu);
}
else {
POPUP_WAIT(STR_WAITING_FOR_RX);
+18 -8
View File
@@ -81,6 +81,9 @@ enum
inline void CLEAR_POPUP()
{
warningText = nullptr;
warningInfoText = nullptr;
popupMenuHandler = nullptr;
popupMenuItemsCount = 0;
}
inline void POPUP_WAIT(const char * s)
@@ -109,11 +112,14 @@ enum
inline void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler)
{
warningText = s;
warningInfoText = nullptr;
warningType = WARNING_TYPE_CONFIRM;
popupFunc = runPopupWarning;
popupMenuHandler = handler;
if (s != warningText) {
killAllEvents();
warningText = s;
warningInfoText = nullptr;
warningType = WARNING_TYPE_CONFIRM;
popupFunc = runPopupWarning;
popupMenuHandler = handler;
}
}
inline void POPUP_INPUT(const char * s, PopupFunc func)
@@ -146,8 +152,9 @@ enum
inline void POPUP_MENU_ADD_ITEM(const char * s)
{
popupMenuOffsetType = MENU_OFFSET_INTERNAL;
if (popupMenuItemsCount < POPUP_MENU_MAX_LINES)
if (popupMenuItemsCount < POPUP_MENU_MAX_LINES) {
popupMenuItems[popupMenuItemsCount++] = s;
}
}
#if defined(SDCARD)
@@ -163,8 +170,11 @@ inline void POPUP_MENU_SELECT_ITEM(uint8_t index)
inline void POPUP_MENU_START(PopupMenuHandler handler)
{
popupMenuHandler = handler;
AUDIO_KEY_PRESS();
if (handler != popupMenuHandler) {
killAllEvents();
AUDIO_KEY_PRESS();
popupMenuHandler = handler;
}
}
#endif // _STDLCD_POPUPS_H_
+43 -1
View File
@@ -18,7 +18,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include <opentx.h>
#if defined(PCBSKY9X)
#define HW_SETTINGS_COLUMN (2+(15*FW))
@@ -169,6 +169,10 @@ enum {
ITEM_RADIO_HARDWARE_BLUETOOTH_NAME,
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
ITEM_RADIO_HARDWARE_EXTERNAL_ANTENNA,
#endif
#if defined(AUX_SERIAL)
ITEM_RADIO_HARDWARE_AUX_SERIAL_MODE,
#endif
@@ -221,6 +225,23 @@ enum {
#define BLUETOOTH_ROWS uint8_t(IS_BLUETOOTH_CHIP_PRESENT() ? 0 : HIDDEN_ROW), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY ? -1 : HIDDEN_ROW), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : -1), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : -1), uint8_t(g_eeGeneral.bluetoothMode == BLUETOOTH_OFF ? HIDDEN_ROW : 0),
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
#define EXTERNAL_ANTENNA_ROW 0,
void onHardwareAntennaSwitchConfirm(const char * result)
{
if (result == STR_OK) {
// Switch to external antenna confirmation
g_eeGeneral.antennaMode = reusableBuffer.radioHardware.antennaMode;
storageDirty(EE_GENERAL);
}
else {
reusableBuffer.radioHardware.antennaMode = g_eeGeneral.antennaMode;
}
}
#else
#define EXTERNAL_ANTENNA_ROW
#endif
#if defined(PCBX9LITE)
#define SWITCH_TYPE_MAX(sw) (sw == MIXSRC_SD-MIXSRC_FIRST_SWITCH ? SWITCH_2POS : SWITCH_3POS)
#elif defined(PCBXLITES)
@@ -298,6 +319,8 @@ void menuRadioHardware(event_t event)
BLUETOOTH_ROWS
EXTERNAL_ANTENNA_ROW
AUX_SERIAL_ROWS
0 /* ADC filter */,
@@ -324,6 +347,9 @@ void menuRadioHardware(event_t event)
}
else if (event == EVT_ENTRY) {
enableVBatBridge();
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
reusableBuffer.radioHardware.antennaMode = g_eeGeneral.antennaMode;
#endif
}
for (uint8_t i=0; i<NUM_BODY_LINES; i++) {
@@ -546,6 +572,22 @@ void menuRadioHardware(event_t event)
break;
#endif
#if defined(INTERNAL_MODULE_PXX1) && defined(EXTERNAL_ANTENNA)
case ITEM_RADIO_HARDWARE_EXTERNAL_ANTENNA:
reusableBuffer.radioHardware.antennaMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_ANTENNA, STR_ANTENNA_MODES, reusableBuffer.radioHardware.antennaMode, ANTENNA_MODE_INTERNAL, ANTENNA_MODE_EXTERNAL, attr, event);
if (!s_editMode && reusableBuffer.radioHardware.antennaMode != g_eeGeneral.antennaMode) {
if (!isExternalAntennaEnabled() && (reusableBuffer.radioHardware.antennaMode == ANTENNA_MODE_EXTERNAL || (reusableBuffer.radioHardware.antennaMode == ANTENNA_MODE_PER_MODEL && g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode == ANTENNA_MODE_EXTERNAL))) {
POPUP_CONFIRMATION(STR_ANTENNACONFIRM1, onHardwareAntennaSwitchConfirm);
SET_WARNING_INFO(STR_ANTENNACONFIRM2, sizeof(TR_ANTENNACONFIRM2), 0);
}
else {
g_eeGeneral.antennaMode = reusableBuffer.radioHardware.antennaMode;
checkExternalAntenna();
}
}
break;
#endif
#if defined(AUX_SERIAL)
case ITEM_RADIO_HARDWARE_AUX_SERIAL_MODE:
g_eeGeneral.auxSerialMode = editChoice(HW_SETTINGS_COLUMN2, y, STR_AUX_SERIAL_MODE, STR_AUX_SERIAL_MODES, g_eeGeneral.auxSerialMode, 0, UART_MODE_MAX, attr, event);
+12 -12
View File
@@ -21,11 +21,15 @@
#include "opentx.h"
#include "io/frsky_firmware_update.h"
#define REFRESH_FILES() do { reusableBuffer.sdManager.offset = 65535; menuVerticalPosition = 0; } while(0)
#define NODE_TYPE(fname) fname[SD_SCREEN_FILE_LENGTH+1]
#define IS_DIRECTORY(fname) ((bool)(!NODE_TYPE(fname)))
#define IS_FILE(fname) ((bool)(NODE_TYPE(fname)))
inline void REFRESH_FILES()
{
reusableBuffer.sdManager.offset = 65535;
}
void menuRadioSdManagerInfo(event_t event)
{
SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1);
@@ -288,7 +292,7 @@ void menuRadioSdManager(event_t _event)
break;
case EVT_ENTRY_UP:
menuVerticalOffset = reusableBuffer.sdManager.offset;
REFRESH_FILES();
break;
#if defined(PCBX9) || defined(RADIO_X7) // TODO NO_MENU_KEY
@@ -421,23 +425,19 @@ void menuRadioSdManager(event_t _event)
FILINFO fno;
DIR dir;
if (menuVerticalOffset == 0) {
reusableBuffer.sdManager.offset = 0;
memset(reusableBuffer.sdManager.lines, 0, sizeof(reusableBuffer.sdManager.lines));
}
else if (menuVerticalOffset == reusableBuffer.sdManager.count-NUM_BODY_LINES) {
reusableBuffer.sdManager.offset = menuVerticalOffset;
memset(reusableBuffer.sdManager.lines, 0, sizeof(reusableBuffer.sdManager.lines));
}
else if (menuVerticalOffset > reusableBuffer.sdManager.offset) {
if (menuVerticalOffset == reusableBuffer.sdManager.offset + 1) {
memmove(reusableBuffer.sdManager.lines[0], reusableBuffer.sdManager.lines[1], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdManager.lines[0]));
memset(reusableBuffer.sdManager.lines[NUM_BODY_LINES-1], 0xff, SD_SCREEN_FILE_LENGTH);
NODE_TYPE(reusableBuffer.sdManager.lines[NUM_BODY_LINES-1]) = 1;
}
else {
else if (menuVerticalOffset == reusableBuffer.sdManager.offset - 1) {
memmove(reusableBuffer.sdManager.lines[1], reusableBuffer.sdManager.lines[0], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdManager.lines[0]));
memset(reusableBuffer.sdManager.lines[0], 0, sizeof(reusableBuffer.sdManager.lines[0]));
}
else {
reusableBuffer.sdManager.offset = menuVerticalOffset;
memset(reusableBuffer.sdManager.lines, 0, sizeof(reusableBuffer.sdManager.lines));
}
reusableBuffer.sdManager.count = 0;
+6 -10
View File
@@ -85,16 +85,16 @@ void menuRadioTools(event_t event)
uint8_t index = 0;
#if defined(PXX2)
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_INT, menuRadioSpectrumAnalyser, INTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
addRadioModuleTool(index++, STR_POWER_METER_INT, menuRadioPowerMeter, INTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER))
addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_EXT, menuRadioSpectrumAnalyser, EXTERNAL_MODULE);
if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
if (isPXX2ModuleOptionAvailable(reusableBuffer.radioTools.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER))
addRadioModuleTool(index++, STR_POWER_METER_EXT, menuRadioPowerMeter, EXTERNAL_MODULE);
#endif
@@ -102,11 +102,6 @@ void menuRadioTools(event_t event)
FILINFO fno;
DIR dir;
#if defined(CROSSFIRE)
if(isFileAvailable(SCRIPTS_TOOLS_PATH "/CROSSFIRE/crossfire.lua"))
addRadioScriptTool(index++, SCRIPTS_TOOLS_PATH "/CROSSFIRE/crossfire.lua");
#endif
FRESULT res = f_opendir(&dir, SCRIPTS_TOOLS_PATH);
if (res == FR_OK) {
for (;;) {
@@ -121,6 +116,7 @@ void menuRadioTools(event_t event)
if (isRadioScriptTool(fno.fname))
addRadioScriptTool(index++, path);
}
f_closedir(&dir);
}
#endif
@@ -129,4 +125,4 @@ void menuRadioTools(event_t event)
}
reusableBuffer.radioTools.linesCount = index;
}
}
+12 -88
View File
@@ -20,80 +20,6 @@
#include "opentx.h"
#define TEXT_FILE_MAXSIZE 2048
char s_text_file[TEXT_FILENAME_MAXLEN];
char s_text_screen[LCD_LINES-1][LCD_COLS+1];
void readTextFile(int & lines_count)
{
FIL file;
int result;
char c;
unsigned int sz;
int line_length = 0;
int escape = 0;
char escape_chars[4] = {0};
int current_line = 0;
memset(s_text_screen, 0, sizeof(s_text_screen));
result = f_open(&file, s_text_file, FA_OPEN_EXISTING | FA_READ);
if (result == FR_OK) {
for (int i=0; i<TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz)==FR_OK && sz==1 && (lines_count==0 || current_line-menuVerticalOffset<LCD_LINES-1); i++) {
if (c == '\n') {
++current_line;
line_length = 0;
escape = 0;
}
else if (c!='\r' && current_line>=menuVerticalOffset && current_line-menuVerticalOffset<LCD_LINES-1 && line_length<LCD_COLS) {
if (c=='\\' && escape==0) {
escape = 1;
continue;
}
else if (c!='\\' && escape>0 && escape<4) {
escape_chars[escape-1] = c;
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
c = '\300';
escape = 0;
}
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
c = '\301';
escape = 0;
}
else if (escape == 3) {
int val = atoi(escape_chars);
if (val >= 200 && val < 225) {
c = '\200' + val-200;
}
escape = 0;
}
else {
escape++;
continue;
}
}
else if (c=='~') {
c = 'z'+1;
}
else if (c=='\t') {
c = 0x1D; //tab
}
escape = 0;
s_text_screen[current_line-menuVerticalOffset][line_length++] = c;
}
}
if (c != '\n') {
current_line += 1;
}
f_close(&file);
}
if (lines_count == 0) {
lines_count = current_line;
}
}
#if defined(ROTARY_ENCODER_NAVIGATION)
#define EVT_KEY_NEXT_LINE EVT_ROTARY_RIGHT
#define EVT_KEY_PREVIOUS_LINE EVT_ROTARY_LEFT
@@ -106,8 +32,8 @@ void readModelNotes()
{
LED_ERROR_BEGIN();
strcpy(s_text_file, MODELS_PATH "/");
char *buf = strcat_modelname(&s_text_file[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(reusableBuffer.viewText.filename, MODELS_PATH "/");
char *buf = strcat_modelname(&reusableBuffer.viewText.filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel);
strcpy(buf, TEXT_EXT);
waitKeysReleased();
@@ -126,13 +52,11 @@ void readModelNotes()
void menuTextView(event_t event)
{
static int lines_count;
switch (event) {
case EVT_ENTRY:
menuVerticalOffset = 0;
lines_count = 0;
readTextFile(lines_count);
reusableBuffer.viewText.linesCount = 0;
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount);
break;
case EVT_KEY_PREVIOUS_LINE:
@@ -140,15 +64,15 @@ void menuTextView(event_t event)
break;
else
menuVerticalOffset--;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount);
break;
case EVT_KEY_NEXT_LINE:
if (menuVerticalOffset+LCD_LINES-1 >= lines_count)
if (menuVerticalOffset+LCD_LINES-1 >= reusableBuffer.viewText.linesCount)
break;
else
++menuVerticalOffset;
readTextFile(lines_count);
sdReadTextFile(reusableBuffer.viewText.filename, reusableBuffer.viewText.lines, reusableBuffer.viewText.linesCount);
break;
case EVT_KEY_BREAK(KEY_EXIT):
@@ -157,10 +81,10 @@ void menuTextView(event_t event)
}
for (int i=0; i<LCD_LINES-1; i++) {
lcdDrawText(0, i*FH+FH+1, s_text_screen[i], FIXEDWIDTH);
lcdDrawText(0, i*FH+FH+1, reusableBuffer.viewText.lines[i], FIXEDWIDTH);
}
char * title = s_text_file;
char * title = reusableBuffer.viewText.filename;
#if defined(SIMU)
if (!strncmp(title, "./", 2)) title += 2;
#else
@@ -169,15 +93,15 @@ void menuTextView(event_t event)
lcdDrawText(LCD_W/2, 0, getBasename(title), CENTERED);
lcdInvertLine(0);
if (lines_count > LCD_LINES-1) {
drawVerticalScrollbar(LCD_W-1, FH, LCD_H-FH, menuVerticalOffset, lines_count, LCD_LINES-1);
if (reusableBuffer.viewText.linesCount > LCD_LINES-1) {
drawVerticalScrollbar(LCD_W-1, FH, LCD_H-FH, menuVerticalOffset, reusableBuffer.viewText.linesCount, LCD_LINES-1);
}
}
void pushMenuTextView(const char *filename)
{
if (strlen(filename) < TEXT_FILENAME_MAXLEN) {
strcpy(s_text_file, filename);
strcpy(reusableBuffer.viewText.filename, filename);
pushMenu(menuTextView);
}
}
+12 -4
View File
@@ -539,7 +539,7 @@ bool isPxx2IsrmChannelsCountAllowed(int channels)
bool isModuleUsingSport(uint8_t moduleBay, uint8_t moduleType)
{
switch(moduleType) {
switch (moduleType) {
case MODULE_TYPE_NONE:
case MODULE_TYPE_SBUS:
case MODULE_TYPE_PPM:
@@ -717,7 +717,7 @@ bool isTrainerModeAvailable(int mode)
return false;
#endif
#if !defined(PCBSKY9X) && !defined(TRAINER_BATTERY_COMPARTMENT)
#if defined(PCBTARANIS) && !defined(TRAINER_BATTERY_COMPARTMENT)
if (mode == TRAINER_MODE_MASTER_BATTERY_COMPARTMENT)
return false;
#endif
@@ -787,6 +787,7 @@ const char STR_SUBTYPE_FRSKY[] = "\007""D16\0 ""D8\0 ""D16 8ch""V8\0
const char STR_SUBTYPE_HISKY[] = "\005""Std\0 ""HK310";
const char STR_SUBTYPE_V2X2[] = "\006""Std\0 ""JXD506";
const char STR_SUBTYPE_DSM[] = "\006""2 22ms""2 11ms""X 22ms""X 11ms";
const char STR_SUBTYPE_DEVO[] = "\004""8ch\0""10ch""12ch""6ch\0""7ch\0";
const char STR_SUBTYPE_YD717[] = "\007""Std\0 ""SkyWlkr""Syma X4""XINXUN\0""NIHUI\0 ";
const char STR_SUBTYPE_KN[] = "\006""WLtoys""FeiLun";
const char STR_SUBTYPE_SYMAX[] = "\003""Std""X5C";
@@ -807,10 +808,13 @@ const char STR_SUBTYPE_H83D[] = "\007""Std\0 ""H20H\0 ""H20Mini""H30Min
const char STR_SUBTYPE_CORONA[] = "\005""V1\0 ""V2\0 ""FD V3";
const char STR_SUBTYPE_HITEC[] = "\007""Optima\0""Opt Hub""Minima\0";
const char STR_SUBTYPE_BUGS_MINI[] = "\006""Std\0 ""Bugs3H";
const char STR_SUBTYPE_TRAXXAS[] = "\004""6519";
const char STR_SUBTYPE_E01X[] = "\005""E012\0""E015\0""E016H";
const char STR_SUBTYPE_GD00X[] = "\005""GD_V1""GD_V2";
const char STR_SUBTYPE_REDPINE[] = "\004""Fast""Slow";
const char STR_SUBTYPE_POTENSIC[] = "\003""A20""---";
const char STR_SUBTYPE_POTENSIC[] = "\003""A20";
const char STR_SUBTYPE_ZSX[] = "\007""280JJRC";
const char STR_SUBTYPE_FLYZONE[] = "\005""FZ410";
const mm_protocol_definition multi_protocols[] = {
@@ -820,6 +824,7 @@ const mm_protocol_definition multi_protocols[] = {
{MODULE_SUBTYPE_MULTI_HISKY, 1, false, STR_SUBTYPE_HISKY, nullptr},
{MODULE_SUBTYPE_MULTI_V2X2, 1, false, STR_SUBTYPE_V2X2, nullptr},
{MODULE_SUBTYPE_MULTI_DSM2, 3, false, STR_SUBTYPE_DSM, nullptr},
{MODULE_SUBTYPE_MULTI_DEVO, 4, false, STR_SUBTYPE_DEVO, STR_MULTI_FIXEDID},
{MODULE_SUBTYPE_MULTI_YD717, 4, false, STR_SUBTYPE_YD717, nullptr},
{MODULE_SUBTYPE_MULTI_KN, 1, false, STR_SUBTYPE_KN, nullptr},
{MODULE_SUBTYPE_MULTI_SYMAX, 1, false, STR_SUBTYPE_SYMAX, nullptr},
@@ -842,12 +847,15 @@ const mm_protocol_definition multi_protocols[] = {
{MODULE_SUBTYPE_MULTI_CORONA, 2, false, STR_SUBTYPE_CORONA, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_HITEC, 2, false, STR_SUBTYPE_HITEC, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_BUGS_MINI, 1, false, STR_SUBTYPE_BUGS_MINI, nullptr},
{MODULE_SUBTYPE_MULTI_TRAXXAS, 0, false, STR_SUBTYPE_TRAXXAS, nullptr},
{MODULE_SUBTYPE_MULTI_E01X, 2, false, STR_SUBTYPE_E01X, nullptr},
{MODULE_SUBTYPE_MULTI_V911S, 0, false, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_GD00X, 1, false, STR_SUBTYPE_GD00X, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_KF606, 0, false, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_REDPINE, 1, false, STR_SUBTYPE_REDPINE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_POTENSIC, 1, false, STR_SUBTYPE_POTENSIC, nullptr},
{MODULE_SUBTYPE_MULTI_POTENSIC, 0, false, STR_SUBTYPE_POTENSIC, nullptr},
{MODULE_SUBTYPE_MULTI_ZSX, 0, false, STR_SUBTYPE_ZSX, nullptr},
{MODULE_SUBTYPE_MULTI_FLYZONE, 0, false, STR_SUBTYPE_FLYZONE, nullptr},
{MM_RF_CUSTOM_SELECTED, 7, true, NO_SUBTYPE, STR_MULTI_OPTION},
// Sentinel and default for protocols not listed above (MM_RF_CUSTOM is 0xff)
+6
View File
@@ -28,6 +28,7 @@
#define READONLY_ROW ((uint8_t)-1)
#define TITLE_ROW READONLY_ROW
#define LABEL(...) READONLY_ROW
#define HIDDEN_ROW ((uint8_t)-2)
#if defined(ROTARY_ENCODER_NAVIGATION)
@@ -75,6 +76,7 @@ bool isSwitchAvailableInMixes(int swtch);
bool isSwitchAvailableInTimers(int swtch);
bool isR9MModeAvailable(int mode);
bool isPxx2IsrmChannelsCountAllowed(int channels);
bool isModuleUsingSport(uint8_t moduleBay, uint8_t moduleType);
bool isExternalModuleAvailable(int moduleType);
bool isInternalModuleAvailable(int moduleType);
bool isRfProtocolAvailable(int protocol);
@@ -156,7 +158,11 @@ inline bool MULTIMODULE_HAS_SUBTYPE(uint8_t moduleIdx)
}
inline uint8_t MULTIMODULE_RFPROTO_COLUMNS(uint8_t moduleIdx)
{
#if LCD_W < 212
return (g_model.moduleData[moduleIdx].multi.customProto ? (uint8_t) 1 : MULTIMODULE_HAS_SUBTYPE(g_model.moduleData[moduleIdx].getMultiProtocol(true)) ? (uint8_t) 0 : HIDDEN_ROW);
#else
return (g_model.moduleData[moduleIdx].multi.customProto ? (uint8_t) 2 : MULTIMODULE_HAS_SUBTYPE(g_model.moduleData[moduleIdx].getMultiProtocol(true)) ? (uint8_t) 1 : 0);
#endif
}
#define MULTIMODULE_SUBTYPE_ROWS(x) isModuleMultimodule(x) ? MULTIMODULE_RFPROTO_COLUMNS(x) : HIDDEN_ROW,
#define MULTIMODULE_HASOPTIONS(x) (getMultiProtocolDefinition(x)->optionsstr != nullptr)
+16 -6
View File
@@ -96,12 +96,12 @@ void FrskyDeviceFirmwareUpdate::processFrame(const uint8_t * frame)
}
}
#if defined(PCBHORUS)
bool FrskyDeviceFirmwareUpdate::readBuffer(uint8_t * buffer, uint8_t count, uint32_t timeout)
{
watchdogSuspend(timeout);
switch(module) {
#if defined(INTMODULE_USART)
case INTERNAL_MODULE:
{
uint32_t elapsed = 0;
@@ -118,7 +118,6 @@ bool FrskyDeviceFirmwareUpdate::readBuffer(uint8_t * buffer, uint8_t count, uint
}
break;
}
#endif
default:
break;
@@ -126,6 +125,7 @@ bool FrskyDeviceFirmwareUpdate::readBuffer(uint8_t * buffer, uint8_t count, uint
return true;
}
#endif
const uint8_t * FrskyDeviceFirmwareUpdate::readFullDuplexFrame(ModuleFifo & fifo, uint32_t timeout)
{
@@ -177,7 +177,7 @@ const uint8_t * FrskyDeviceFirmwareUpdate::readFrame(uint32_t timeout)
RTOS_WAIT_MS(1);
switch(module) {
#if defined(INTMODULE_USART)
#if defined(INTMODULE_USART) && !(defined(PCBXLITE) && !defined(PCBXLITES))
case INTERNAL_MODULE:
return readFullDuplexFrame(intmoduleFifo, timeout);
#endif
@@ -236,7 +236,7 @@ void FrskyDeviceFirmwareUpdate::sendFrame()
}
switch(module) {
#if defined(INTMODULE_USART)
#if defined(INTMODULE_USART) && !(defined(PCBXLITE) && !defined(PCBXLITES))
case INTERNAL_MODULE:
return intmoduleSendBuffer(outputTelemetryBuffer.data, ptr - outputTelemetryBuffer.data);
#endif
@@ -288,6 +288,11 @@ const char * FrskyDeviceFirmwareUpdate::sendReqVersion()
return "Version request failed";
}
// X12S / X10 IXJT = use TX + RX @ 38400 bauds with BOOTCMD pin inverted
// X10 / X10 ISRM = use TX + RX @ 57600 bauds (no BOOTCMD)
// X9D / X9D+ / X9E / XLite IXJT = use S.PORT @ 57600 bauds
// XLite PRO / X9Lite / X9D+ 2019 ISRM = use TX + RX @ 57600 bauds
const char * FrskyDeviceFirmwareUpdate::doFlashFirmware(const char * filename, ProgressHandler progressHandler)
{
FIL file;
@@ -305,7 +310,8 @@ const char * FrskyDeviceFirmwareUpdate::doFlashFirmware(const char * filename, P
f_close(&file);
return "Format error";
}
} else {
}
else {
#if defined(PCBHORUS)
information.productId = FIRMWARE_ID_XJT;
#endif
@@ -314,6 +320,7 @@ const char * FrskyDeviceFirmwareUpdate::doFlashFirmware(const char * filename, P
#if defined(PCBHORUS)
if (module == INTERNAL_MODULE && information.productId == FIRMWARE_ID_XJT) {
INTERNAL_MODULE_ON();
RTOS_WAIT_MS(1);
intmoduleSerialStart(38400, true);
GPIO_SetBits(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_GPIO_PIN);
result = uploadFileToHorusXJT(filename, &file, progressHandler);
@@ -324,7 +331,10 @@ const char * FrskyDeviceFirmwareUpdate::doFlashFirmware(const char * filename, P
#endif
switch (module) {
#if defined(INTMODULE_USART)
#if defined(INTMODULE_USART) && !(defined(PCBXLITE) && !defined(PCBXLITES))
// on XLite we don't use TX + RX but the S.PORT line
// this ifdef can be removed if we use .frsk instead of .frk
// theorically it should be possible to use an ISRM module in an XLite
case INTERNAL_MODULE:
intmoduleSerialStart(57600, true);
break;
+1 -1
View File
@@ -39,7 +39,7 @@
event_t s_evt;
struct t_inactivity inactivity = {0};
struct InactivityData inactivity = {0};
Key keys[NUM_KEYS];
event_t getEvent(bool trim)
+27 -2
View File
@@ -120,7 +120,7 @@ Return the time since the radio was started in multiple of 10ms
@retval number Number of 10ms ticks since the radio was started Example:
run time: 12.54 seconds, return value: 1254
The timer internally uses a 32-bit counter which is enough for 30 years so
The timer internally uses a 32-bit counter which is enough for 497 days so
overflows will not happen.
@status current Introduced in 2.0.0
@@ -203,11 +203,17 @@ static int luaGetRtcTime(lua_State * L)
static void luaPushLatLon(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
/* result is lua table containing members ["lat"] and ["lon"] as lua_Number (doubles) in decimal degrees */
{
lua_createtable(L, 0, 4);
lua_createtable(L, 0, 5);
lua_pushtablenumber(L, "lat", telemetryItem.gps.latitude * 0.000001); // floating point multiplication is faster than division
lua_pushtablenumber(L, "pilot-lat", telemetryItem.pilotLatitude * 0.000001);
lua_pushtablenumber(L, "lon", telemetryItem.gps.longitude * 0.000001);
lua_pushtablenumber(L, "pilot-lon", telemetryItem.pilotLongitude * 0.000001);
int8_t delay = telemetryItem.getDelaySinceLastValue();
if (delay >= 0)
lua_pushtableinteger(L, "delay", delay);
else
lua_pushtablenil(L, "delay");
}
static void luaPushTelemetryDateTime(lua_State* L, TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem)
@@ -1351,6 +1357,24 @@ static int luaGetRSSI(lua_State * L)
return 3;
}
/*luadoc
@function chdir(directory)
Change the working directory
@param directory (string) New working directory
@status current Introduced in 2.3.0
*/
static int luaChdir(lua_State * L)
{
const char * directory = luaL_optstring(L, 1, nullptr);
f_chdir(directory);
return 0;
}
/*luadoc
@function loadScript(file [, mode], [,env])
@@ -1548,6 +1572,7 @@ const luaL_Reg opentxLib[] = {
{ "defaultChannel", luaDefaultChannel },
{ "getRSSI", luaGetRSSI },
{ "killEvents", luaKillEvents },
{ "chdir", luaChdir },
{ "loadScript", luaLoadScript },
{ "getUsage", luaGetUsage },
{ "resetGlobalTimer", luaResetGlobalTimer },
+1 -1
View File
@@ -541,7 +541,7 @@ Draw a bitmap at (x,y)
@param name (string) full path to the bitmap on SD card (i.e. “/IMAGES/test.bmp”)
@notice Only available on Taranis X9 series. Maximum image size if 106 x 64 pixels (width x height).
@notice Maximum image size is [display width / 2] x [display height] pixels.
@status current Introduced in 2.0.0
*/
+5 -5
View File
@@ -86,7 +86,7 @@ static int luaModelSetInfo(lua_State *L)
Get RF module parameters
`rfProtocol` values:
`subType` values:
* -1 OFF
* 0 D16
* 1 D8
@@ -97,7 +97,7 @@ Get RF module parameters
@retval nil requested module does not exist
@retval table module parameters:
* `rfProtocol` (number) protocol index
* `subType` (number) protocol index
* `modelId` (number) receiver number
* `firstChannel` (number) start channel (0 is CH1)
* `channelsCount` (number) number of channels sent to module
@@ -110,7 +110,7 @@ static int luaModelGetModule(lua_State *L)
if (idx < NUM_MODULES) {
ModuleData & module = g_model.moduleData[idx];
lua_newtable(L);
lua_pushtableinteger(L, "rfProtocol", module.rfProtocol);
lua_pushtableinteger(L, "subType", module.subType);
lua_pushtableinteger(L, "modelId", g_model.header.modelId[idx]);
lua_pushtableinteger(L, "firstChannel", module.channelsStart);
lua_pushtableinteger(L, "channelsCount", module.channelsCount + 8);
@@ -145,8 +145,8 @@ static int luaModelSetModule(lua_State *L)
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
luaL_checktype(L, -2, LUA_TSTRING); // key is string
const char * key = luaL_checkstring(L, -2);
if (!strcmp(key, "rfProtocol")) {
module.rfProtocol = luaL_checkinteger(L, -1);
if (!strcmp(key, "subType")) {
module.subType = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "modelId")) {
g_model.header.modelId[idx] = luaL_checkinteger(L, -1);
+13 -8
View File
@@ -636,18 +636,22 @@ bool luaLoadMixScript(uint8_t index)
bool luaLoadFunctionScript(uint8_t index, uint8_t ref)
{
if ((ref >= SCRIPT_GFUNC_FIRST) && g_model.noGlobalFunctions)
return false;
CustomFunctionData * fn;
CustomFunctionData & fn = (ref < SCRIPT_GFUNC_FIRST ? g_model.customFn[index] : g_eeGeneral.customFn[index]);
if (ref < SCRIPT_GFUNC_FIRST)
fn = &g_model.customFn[index];
else if (!g_model.noGlobalFunctions)
fn = &g_eeGeneral.customFn[index];
else
return true;
if (fn.func == FUNC_PLAY_SCRIPT && ZEXIST(fn.play.name)) {
if (fn->func == FUNC_PLAY_SCRIPT && ZEXIST(fn->play.name)) {
if (luaScriptsCount < MAX_SCRIPTS) {
ScriptInternalData & sid = scriptInternalData[luaScriptsCount++];
sid.reference = ref + index;
sid.state = SCRIPT_NOFILE;
char filename[sizeof(SCRIPTS_FUNCS_PATH) + LEN_FUNCTION_NAME + sizeof(SCRIPT_EXT)] = SCRIPTS_FUNCS_PATH "/";
strncpy(filename + sizeof(SCRIPTS_FUNCS_PATH), fn.play.name, LEN_FUNCTION_NAME);
strncpy(filename + sizeof(SCRIPTS_FUNCS_PATH), fn->play.name, LEN_FUNCTION_NAME);
filename[sizeof(SCRIPTS_FUNCS_PATH) + LEN_FUNCTION_NAME] = '\0';
strcat(filename + sizeof(SCRIPTS_FUNCS_PATH), SCRIPT_EXT);
if (luaLoad(lsScripts, filename, sid) == SCRIPT_PANIC) {
@@ -1127,10 +1131,11 @@ bool readToolName(char * toolName, const char * filename)
return "Error opening file";
}
if (f_read(&file, &buffer, sizeof(buffer), &count) != FR_OK) {
f_close(&file);
FRESULT res = f_read(&file, &buffer, sizeof(buffer), &count);
f_close(&file);
if (res != FR_OK)
return false;
}
const char * tns = "TNS|";
auto * start = std::search(buffer, buffer + sizeof(buffer), tns, tns + 4);
+14 -10
View File
@@ -301,7 +301,7 @@ void guiMain(event_t evt)
#else
if (!refreshNeeded) {
DEBUG_TIMER_START(debugTimerMenus);
while (1) {
while (true) {
// normal GUI from menus
const char * warn = warningText;
uint8_t menu = popupMenuItemsCount;
@@ -324,7 +324,10 @@ void guiMain(event_t evt)
const char * result = runPopupMenu(evt);
if (result) {
TRACE("popupMenuHandler(%s)", result);
popupMenuHandler(result);
auto handler = popupMenuHandler;
if (result != STR_UPDATE_LIST)
CLEAR_POPUP();
handler(result);
if (menuEvent == 0) {
evt = EVT_REFRESH;
continue;
@@ -400,7 +403,6 @@ void handleGui(event_t event) {
}
}
menuHandlers[menuLevel](event);
// todo drawStatusLine(); here???
}
else
#endif
@@ -464,7 +466,10 @@ void guiMain(event_t evt)
const char * result = runPopupMenu(evt);
if (result) {
TRACE("popupMenuHandler(%s)", result);
popupMenuHandler(result);
auto handler = popupMenuHandler;
if (result != STR_UPDATE_LIST)
CLEAR_POPUP();
handler(result);
}
}
@@ -503,24 +508,23 @@ void perMain()
#endif
#if defined(RAMBACKUP)
if (unexpectedShutdown) {
if (globalData.unexpectedShutdown) {
drawFatalErrorScreen(STR_EMERGENCY_MODE);
return;
}
#endif
#if defined(STM32)
static bool sdcard_present_before = SD_CARD_PRESENT();
bool sdcard_present_now = SD_CARD_PRESENT();
if (sdcard_present_now && !sdcard_present_before) {
bool sdcardPresent = SD_CARD_PRESENT();
if (sdcardPresent && !globalData.sdcardPresent) {
sdMount();
}
sdcard_present_before = sdcard_present_now;
globalData.sdcardPresent = sdcardPresent;
#endif
#if !defined(EEPROM)
// In case the SD card is removed during the session
if (!SD_CARD_PRESENT() && !unexpectedShutdown) {
if (!SD_CARD_PRESENT() && !globalData.unexpectedShutdown) {
drawFatalErrorScreen(STR_NO_SDCARD);
return;
}
+31 -32
View File
@@ -547,8 +547,8 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
{
evalInputs(mode);
if (tick10ms) evalLogicalSwitches(mode==e_perout_mode_normal);
if (tick10ms)
evalLogicalSwitches(mode==e_perout_mode_normal);
#if defined(HELI)
int heliEleValue = getValue(g_model.swashR.elevatorSource);
@@ -614,7 +614,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
}
#endif
memclear(chans, sizeof(chans)); // All outputs to 0
memclear(chans, sizeof(chans)); // all outputs to 0
//========== MIXER LOOP ===============
uint8_t lv_mixWarning = 0;
@@ -624,27 +624,27 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
bitfield_channels_t dirtyChannels = (bitfield_channels_t)-1; // all dirty when mixer starts
do {
bitfield_channels_t passDirtyChannels = 0;
for (uint8_t i=0; i<MAX_MIXERS; i++) {
#if defined(BOLD_FONT)
if (mode==e_perout_mode_normal && pass==0) swOn[i].activeMix = 0;
if (mode == e_perout_mode_normal && pass == 0)
swOn[i].activeMix = 0;
#endif
MixData *md = mixAddress(i);
MixData * md = mixAddress(i);
if (md->srcRaw == 0) break;
if (md->srcRaw == 0)
break;
mixsrc_t stickIndex = md->srcRaw - MIXSRC_Rud;
if (!(dirtyChannels & ((bitfield_channels_t)1 << md->destCh))) continue;
if (!(dirtyChannels & ((bitfield_channels_t)1 << md->destCh)))
continue;
// if this is the first calculation for the destination channel, initialize it with 0 (otherwise would be random)
if (i == 0 || md->destCh != (md-1)->destCh) {
if (i == 0 || md->destCh != (md-1)->destCh)
chans[md->destCh] = 0;
}
//========== FLIGHT MODE && SWITCH =====
bool mixCondition = (md->flightModes != 0 || md->swtch);
@@ -669,44 +669,43 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
//========== VALUE ===============
getvalue_t v = 0;
if (mode > e_perout_mode_inactive_flight_mode) {
if (!mixEnabled) {
continue;
}
else {
if (mixEnabled)
v = getValue(md->srcRaw);
}
else
continue;
}
else {
mixsrc_t srcRaw = MIXSRC_Rud + stickIndex;
v = getValue(srcRaw);
srcRaw -= MIXSRC_CH1;
if (srcRaw<=MIXSRC_LAST_CH-MIXSRC_CH1 && md->destCh != srcRaw) {
if (srcRaw <= MIXSRC_LAST_CH-MIXSRC_CH1 && md->destCh != srcRaw) {
if (dirtyChannels & ((bitfield_channels_t)1 << srcRaw) & (passDirtyChannels|~(((bitfield_channels_t) 1 << md->destCh)-1)))
passDirtyChannels |= (bitfield_channels_t) 1 << md->destCh;
if (srcRaw < md->destCh || pass > 0)
v = chans[srcRaw] >> 8;
}
if (!mixCondition) {
mixEnabled = v >> DELAY_POS_SHIFT;
mixEnabled = v;
}
}
bool apply_offset_and_curve = true;
bool applyOffsetAndCurve = true;
//========== DELAYS ===============
delayval_t _swOn = swOn[i].now;
delayval_t _swPrev = swOn[i].prev;
bool swTog = (mixEnabled > _swOn+DELAY_POS_MARGIN || mixEnabled < _swOn-DELAY_POS_MARGIN);
if (mode==e_perout_mode_normal && swTog) {
if (!swOn[i].delay) _swPrev = _swOn;
swOn[i].delay = (mixEnabled > _swOn ? md->delayUp : md->delayDown) * (100/DELAY_STEP);
if (mode == e_perout_mode_normal && swTog) {
if (!swOn[i].delay)
_swPrev = _swOn;
swOn[i].delay = (mixEnabled > _swOn ? md->delayUp : md->delayDown) * 10;
swOn[i].now = mixEnabled;
swOn[i].prev = _swPrev;
}
if (mode==e_perout_mode_normal && swOn[i].delay > 0) {
if (mode == e_perout_mode_normal && swOn[i].delay > 0) {
swOn[i].delay = max<int16_t>(0, (int16_t)swOn[i].delay - tick10ms);
if (!mixCondition)
v = _swPrev << DELAY_POS_SHIFT;
v = _swPrev;
else if (mixEnabled)
continue;
}
@@ -718,7 +717,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
if ((md->speedDown || md->speedUp) && md->mltpx!=MLTPX_REP) {
if (mixCondition) {
v = (md->mltpx == MLTPX_ADD ? 0 : RESX);
apply_offset_and_curve = false;
applyOffsetAndCurve = false;
}
}
else if (mixCondition) {
@@ -734,7 +733,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
#endif
}
if (apply_offset_and_curve) {
if (applyOffsetAndCurve) {
//========== TRIMS ================
if (!(mode & e_perout_mode_notrims)) {
@@ -757,7 +756,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
int16_t diff = v - (tact>>DEL_MULT_SHIFT);
if (diff) {
// open.20.fsguruh: speed is defined in % movement per second; In menu we specify the full movement (-100% to 100%) = 200% in total
// the unit of the stored value is the value from md->speedUp or md->speedDown divide SLOW_STEP seconds; e.g. value 4 means 4/SLOW_STEP = 2 seconds for CPU64
// the unit of the stored value is the value from md->speedUp or md->speedDown * 0.1s; e.g. value 4 means 0.4 seconds
// because we get a tick each 10msec, we need 100 ticks for one second
// the value in md->speedXXX gives the time it should take to do a full movement from -100 to 100 therefore 200%. This equals 2048 in recalculated internal range
if (tick10ms || !s_mixer_first_run_done) {
@@ -769,14 +768,14 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
if (diff > 0) {
if (s_mixer_first_run_done && md->speedUp > 0) {
// if a speed upwards is defined recalculate the new value according configured speed; the higher the speed the smaller the add value is
int32_t newValue = tact+rate/((int16_t)(100/SLOW_STEP)*md->speedUp);
int32_t newValue = tact+rate/((int16_t)10*md->speedUp);
if (newValue<currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
}
}
else { // if is <0 because ==0 is not possible
if (s_mixer_first_run_done && md->speedDown > 0) {
// see explanation in speedUp
int32_t newValue = tact-rate/((int16_t)(100/SLOW_STEP)*md->speedDown);
int32_t newValue = tact-rate/((int16_t)10*md->speedDown);
if (newValue>currentValue) currentValue = newValue; // Endposition; prevent toggling around the destination
}
}
@@ -788,7 +787,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
}
//========== CURVES ===============
if (apply_offset_and_curve && md->curve.type != CURVE_REF_DIFF && md->curve.value) {
if (applyOffsetAndCurve && md->curve.type != CURVE_REF_DIFF && md->curve.value) {
v = applyCurve(v, md->curve);
}
@@ -797,7 +796,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
dv = div_and_round(dv, 10);
//========== OFFSET / AFTER ===============
if (apply_offset_and_curve) {
if (applyOffsetAndCurve) {
int32_t offset = GET_GVAR_PREC1(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
if (offset) dv += div_and_round(calc100toRESX_16Bits(offset), 10) << 8;
}
@@ -912,7 +911,7 @@ void evalMixes(uint8_t tick10ms)
ACTIVE_PHASES_TYPE transitionMask = ((ACTIVE_PHASES_TYPE)1 << lastFlightMode) + ((ACTIVE_PHASES_TYPE)1 << fm);
if (fadeTime) {
flightModesFade |= transitionMask;
delta = (MAX_ACT / (100/SLOW_STEP)) / fadeTime;
delta = (MAX_ACT / 10) / fadeTime;
}
else {
flightModesFade &= ~transitionMask;
+2 -4
View File
@@ -147,10 +147,8 @@ enum CurveRefType {
#define GV1_LARGE 1024
#define GV_RANGE_WEIGHT 500
#define GV_RANGE_OFFSET 500
#define DELAY_STEP 10
#define SLOW_STEP 10
#define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */
#define SLOW_MAX (25*SLOW_STEP) /* 25 seconds */
#define DELAY_MAX 250 /* 25 seconds */
#define SLOW_MAX 250 /* 25 seconds */
#define MD_WEIGHT(md) (md->weight)
#define MD_WEIGHT_TO_UNION(md, var) var.word = md->weight
+18 -32
View File
@@ -34,13 +34,9 @@ ModelData g_model;
Clipboard clipboard;
#endif
uint8_t unexpectedShutdown = 0;
uint16_t vbattRTC;
/* ARM: mixer duration in 0.5us */
uint16_t maxMixerDuration;
GlobalData globalData;
uint16_t maxMixerDuration; // step = 0.01ms
uint8_t heartbeat;
#if defined(OVERRIDE_CHANNEL_FUNCTION)
@@ -206,9 +202,7 @@ void per10ms()
}
#endif
if (!IS_DSM2_SERIAL_PROTOCOL(s_current_protocol[0])) {
telemetryInterrupt10ms();
}
telemetryInterrupt10ms();
// These moved here from evalFlightModeMixes() to improve beep trigger reliability.
#if defined(PWM_BACKLIGHT)
@@ -505,14 +499,9 @@ void modelDefault(uint8_t id)
}
#endif
#if defined(HARDWARE_INTERNAL_MODULE)
#if defined(FRSKY_RELEASE)
g_model.moduleData[INTERNAL_MODULE].type = IS_PXX2_INTERNAL_ENABLED() ? MODULE_TYPE_ISRM_PXX2 : MODULE_TYPE_XJT_PXX1;
g_model.moduleData[INTERNAL_MODULE].channelsCount = defaultModuleChannels_M8(INTERNAL_MODULE);
#elif defined(PCBSKY9X)
g_model.moduleData[EXTERNAL_MODULE].type = MODULE_TYPE_PPM;
#elif defined(RADIO_T12)
g_model.moduleData[EXTERNAL_MODULE].type = MODULE_TYPE_NONE;
g_model.moduleData[EXTERNAL_MODULE].type = MODULE_TYPE_MULTIMODULE;
#endif
#if defined(PCBXLITE)
@@ -683,11 +672,6 @@ getvalue_t convert16bitsTelemValue(source_t channel, ls_telemetry_value_t value)
return value;
}
ls_telemetry_value_t minTelemValue(source_t channel)
{
return 0;
}
ls_telemetry_value_t maxTelemValue(source_t channel)
{
return 30000;
@@ -942,6 +926,10 @@ void checkAll()
}
}
#if defined(EXTERNAL_ANTENNA) && defined(INTERNAL_MODULE_PXX1)
checkExternalAntenna();
#endif
START_SILENCE_PERIOD();
}
#endif // GUI
@@ -1866,8 +1854,7 @@ void opentxInit()
#endif
#if defined(EEPROM)
storageClearRadioSetting();
storageReadRadioSettings(false);
bool radioSettingsValid = storageReadRadioSettings(false);
#endif
BACKLIGHT_ENABLE(); // we start the backlight during the startup animation
@@ -1891,12 +1878,14 @@ void opentxInit()
// * radios without CPU controlled power can only use Reset status register (if available)
if (UNEXPECTED_SHUTDOWN()) {
TRACE("Unexpected Shutdown detected");
unexpectedShutdown = 1;
globalData.unexpectedShutdown = 1;
}
#if defined(SDCARD)
globalData.sdcardPresent = SD_CARD_PRESENT();
// SDCARD related stuff, only done if not unexpectedShutdown
if (!unexpectedShutdown) {
if (!globalData.unexpectedShutdown) {
sdInit();
#if defined(AUTOUPDATE)
@@ -1926,12 +1915,13 @@ void opentxInit()
#endif
#if defined(EEPROM)
storageReadRadioSettings(true);
if (!radioSettingsValid)
storageReadRadioSettings();
storageReadCurrentModel();
#endif
#if defined(COLORLCD)
if (!unexpectedShutdown) {
if (!globalData.unexpectedShutdown) {
// g_model.topbarData is still zero here (because it was not yet read from SDCARD),
// but we only remember the pointer to in in constructor.
// The storageReadAll() needs topbar object, so it must be created here
@@ -1947,7 +1937,7 @@ void opentxInit()
// handling of storage for radios that have no EEPROM
#if !defined(EEPROM)
#if defined(RAMBACKUP)
if (unexpectedShutdown) {
if (globalData.unexpectedShutdown) {
// SDCARD not available, try to restore last model from RAM
TRACE("rambackupRestore");
rambackupRestore();
@@ -1964,10 +1954,6 @@ void opentxInit()
auxSerialInit(g_eeGeneral.auxSerialMode, modelTelemetryProtocol());
#endif
#if defined(PCBTARANIS)
BACKLIGHT_ENABLE();
#endif
#if MENUS_LOCK == 1
getMovedSwitch();
if (TRIMS_PRESSED() && g_eeGeneral.switchUnlockStates==switches_states) {
@@ -2002,7 +1988,7 @@ void opentxInit()
backlightOn();
}
if (!unexpectedShutdown) {
if (!globalData.unexpectedShutdown) {
opentxStart();
}
+48 -30
View File
@@ -420,13 +420,13 @@ void watchdogSuspend(uint32_t timeout);
#define MAX_ALERT_TIME 60
struct t_inactivity
struct InactivityData
{
uint16_t counter;
uint8_t sum;
};
extern struct t_inactivity inactivity;
extern InactivityData inactivity;
#define LEN_STD_CHARS 40
@@ -583,9 +583,14 @@ extern uint8_t trimsDisplayMask;
void flightReset(uint8_t check=true);
extern uint8_t unexpectedShutdown;
PACK(struct GlobalData {
uint8_t unexpectedShutdown:1;
uint8_t sdcardPresent:1;
uint8_t externalAntennaEnabled: 1;
uint8_t spare:5;
});
extern uint16_t vbattRTC;
extern GlobalData globalData;
extern uint16_t maxMixerDuration;
@@ -875,16 +880,15 @@ void copySticksToOffset(uint8_t ch);
void moveTrimsToOffsets();
typedef uint16_t ACTIVE_PHASES_TYPE;
#define DELAY_POS_SHIFT 0
#define DELAY_POS_MARGIN 3
typedef int16_t delayval_t;
PACK(typedef struct {
uint16_t delay;
PACK(struct SwOn {
uint16_t delay:14; // max = 2550
uint8_t activeMix:1;
uint8_t activeExpo:1;
int16_t now; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
int16_t prev;
uint8_t activeMix;
uint8_t activeExpo;
}) SwOn;
});
extern SwOn swOn[MAX_MIXERS];
extern int32_t act[MAX_MIXERS];
@@ -1089,15 +1093,17 @@ constexpr uint8_t OPENTX_START_NO_CHECKS = 0x04;
// Re-useable byte array to save having multiple buffers
#if LCD_W <= 212
#define SD_SCREEN_FILE_LENGTH 32
constexpr uint8_t SD_SCREEN_FILE_LENGTH = 32;
#else
#define SD_SCREEN_FILE_LENGTH 64
constexpr uint8_t SD_SCREEN_FILE_LENGTH = 64;
#endif
#if defined(BLUETOOTH)
#include "bluetooth.h"
#endif
constexpr uint8_t TEXT_FILENAME_MAXLEN = 40;
union ReusableBuffer
{
struct {
@@ -1115,6 +1121,7 @@ union ReusableBuffer
struct {
char msg[64];
uint8_t r9mPower;
int8_t antennaMode;
BindInformation bindInformation;
struct {
union {
@@ -1181,7 +1188,7 @@ union ReusableBuffer
uint32_t updateTime;
ModuleSettings moduleSettings;
ReceiverSettings receiverSettings; // when dealing with receiver settings, we also need module settings
} hardwareAndSettings;
} hardwareAndSettings; // moduleOptions, receiverOptions, radioVersion
struct {
ModuleInformation modules[NUM_MODULES];
@@ -1189,6 +1196,10 @@ union ReusableBuffer
char msg[64];
} radioTools;
struct {
int8_t antennaMode;
} radioHardware;
struct {
uint8_t stickMode;
} generalSettings;
@@ -1221,13 +1232,29 @@ union ReusableBuffer
int8_t preset;
} curveEdit;
struct {
char filename[TEXT_FILENAME_MAXLEN];
char lines[NUM_BODY_LINES][LCD_COLS + 1];
int linesCount;
} viewText;
struct {
bool longNames;
bool secondPage;
bool mixersView;
} viewChannels;
struct {
uint8_t maxNameLen;
} modelFailsafe;
#if defined(STM32)
// Data for the USB mass storage driver. If USB mass storage runs no menu is not allowed to be displayed
uint8_t MSC_BOT_Data[MSC_MEDIA_PACKET];
#endif
};
extern union ReusableBuffer reusableBuffer;
extern ReusableBuffer reusableBuffer;
uint8_t zlen(const char *str, uint8_t size);
bool zexist(const char *str, uint8_t size);
@@ -1246,13 +1273,15 @@ char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defa
// Stick tolerance varies between transmitters, Higher is better
#define STICK_TOLERANCE 64
ls_telemetry_value_t minTelemValue(source_t channel);
ls_telemetry_value_t maxTelemValue(source_t channel);
ls_telemetry_value_t maxTelemValue(source_t channel);
getvalue_t convert16bitsTelemValue(source_t channel, ls_telemetry_value_t value);
getvalue_t convertLswTelemValue(LogicalSwitchData * cs);
#define convertTelemValue(channel, value) convert16bitsTelemValue(channel, value)
inline getvalue_t convertTelemValue(source_t channel, ls_telemetry_value_t value)
{
return convert16bitsTelemValue(channel, value);
}
inline int div_and_round(int num, int den)
{
@@ -1292,8 +1321,6 @@ extern uint8_t s_frsky_view;
constexpr uint32_t EARTH_RADIUS = 6371009;
void getGpsPilotPosition();
void getGpsDistance();
void varioWakeup();
#if defined(AUDIO) && defined(BUZZER)
@@ -1378,26 +1405,17 @@ enum JackMode {
#include "gyro.h"
#endif
inline bool isSimu()
{
#if defined(SIMU)
return true;
#else
return false;
#endif
}
#if defined(DEBUG_LATENCY)
extern uint8_t latencyToggleSwitch;
#endif
inline bool isAsteriskDisplayed()
{
#if defined(LOG_TELEMETRY) || defined(WATCHDOG_DISABLED) || defined(DEBUG_LATENCY)
#if defined(LOG_TELEMETRY) || !defined(WATCHDOG) || defined(DEBUG_LATENCY)
return true;
#endif
return unexpectedShutdown;
return globalData.unexpectedShutdown;
}
#include "module.h"
+34
View File
@@ -1,3 +1,26 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _MODULES_CONSTANTS_H_
#define _MODULES_CONSTANTS_H_
enum ModuleType {
MODULE_TYPE_NONE = 0,
MODULE_TYPE_PPM,
@@ -165,3 +188,14 @@ enum FailsafeModes {
FAILSAFE_RECEIVER,
FAILSAFE_LAST = FAILSAFE_RECEIVER
};
enum AntennaModes {
ANTENNA_MODE_INTERNAL = -2,
ANTENNA_MODE_ASK = -1,
ANTENNA_MODE_PER_MODEL = 0,
ANTENNA_MODE_EXTERNAL = 1,
ANTENNA_MODE_FIRST = ANTENNA_MODE_INTERNAL,
ANTENNA_MODE_LAST = ANTENNA_MODE_EXTERNAL
};
#endif // _MODULES_CONSTANTS_H_
+43
View File
@@ -0,0 +1,43 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "opentx.h"
#if defined(EXTERNAL_ANTENNA)
bool isExternalAntennaEnabled()
{
switch (g_eeGeneral.antennaMode) {
case ANTENNA_MODE_INTERNAL:
return false;
case ANTENNA_MODE_EXTERNAL:
return true;
case ANTENNA_MODE_PER_MODEL:
switch (g_model.moduleData[INTERNAL_MODULE].pxx.antennaMode) {
case ANTENNA_MODE_EXTERNAL:
case ANTENNA_MODE_ASK:
return globalData.externalAntennaEnabled;
default:
return false;
}
default:
return globalData.externalAntennaEnabled;
}
}
#endif
+2
View File
@@ -529,4 +529,6 @@ inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType)
setDefaultPpmFrameLength(moduleIdx);
}
extern bool isExternalAntennaEnabled();
#endif // _MODULES_HELPERS_H_
+1 -7
View File
@@ -46,12 +46,6 @@
#define IS_DSM2_PROTOCOL(protocol) (0)
#endif
#if defined(DSM2_SERIAL)
#define IS_DSM2_SERIAL_PROTOCOL(protocol) (IS_DSM2_PROTOCOL(protocol))
#else
#define IS_DSM2_SERIAL_PROTOCOL(protocol) (0)
#endif
#if defined(MULTIMODULE)
#define IS_MULTIMODULE_PROTOCOL(protocol) (protocol==PROTOCOL_CHANNELS_MULTIMODULE)
#if !defined(DSM2)
@@ -146,7 +140,7 @@ class BindInformation {
class OtaUpdateInformation: public BindInformation {
public:
char filename[_MAX_LFN+1];
char filename[32+1];
uint32_t address;
};
+10 -10
View File
@@ -52,27 +52,27 @@ template <class PxxTransport>
void Pxx1Pulses<PxxTransport>::addExtraFlags(uint8_t module)
{
// Ext. flag (holds antenna selection on Horus internal module, 0x00 otherwise)
uint8_t extra_flags = 0;
uint8_t extraFlags = 0;
#if defined(PCBHORUS) || defined(PCBXLITE)
if (module == INTERNAL_MODULE) {
extra_flags |= (g_model.moduleData[module].pxx.external_antenna << 0);
#if defined(EXTERNAL_ANTENNA)
if (module == INTERNAL_MODULE && isExternalAntennaEnabled()) {
extraFlags |= (1 << 0);
}
#endif
extra_flags |= (g_model.moduleData[module].pxx.receiver_telem_off << 1);
extra_flags |= (g_model.moduleData[module].pxx.receiver_channel_9_16 << 2);
extraFlags |= (g_model.moduleData[module].pxx.receiverTelemetryOff << 1);
extraFlags |= (g_model.moduleData[module].pxx.receiverHigherChannels << 2);
if (isModuleR9MNonAccess(module)) {
extra_flags |= (min<uint8_t>(g_model.moduleData[module].pxx.power, isModuleR9M_FCC_VARIANT(module) ? (uint8_t)R9M_FCC_POWER_MAX : (uint8_t)R9M_LBT_POWER_MAX) << 3);
extraFlags |= (min<uint8_t>(g_model.moduleData[module].pxx.power, isModuleR9M_FCC_VARIANT(module) ? (uint8_t)R9M_FCC_POWER_MAX : (uint8_t)R9M_LBT_POWER_MAX) << 3);
if (isModuleR9M_EUPLUS(module))
extra_flags |= (1 << 6);
extraFlags |= (1 << 6);
}
// Disable S.PORT if internal module is active
if (module == EXTERNAL_MODULE && isSportLineUsedByInternalModule()) {
extra_flags |= (1 << 5);
extraFlags |= (1 << 5);
}
PxxTransport::addByte(extra_flags);
PxxTransport::addByte(extraFlags);
}
template <class PxxTransport>
+1 -1
View File
@@ -243,7 +243,7 @@ void Pxx2Pulses::setupAccstBindFrame(uint8_t module)
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
Pxx2Transport::addByte(0x00);
}
Pxx2Transport::addByte((g_model.moduleData[module].pxx.receiver_channel_9_16 << 7) + (g_model.moduleData[module].pxx.receiver_telem_off << 6));
Pxx2Transport::addByte((g_model.moduleData[module].pxx.receiverHigherChannels << 7) + (g_model.moduleData[module].pxx.receiverTelemetryOff << 6));
Pxx2Transport::addByte(g_model.header.modelId[module]);
}
+68
View File
@@ -410,6 +410,74 @@ bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen
return popupMenuItemsCount;
}
constexpr uint32_t TEXT_FILE_MAXSIZE = 2048;
void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS + 1], int & lines_count)
{
FIL file;
int result;
char c;
unsigned int sz;
int line_length = 0;
uint8_t escape = 0;
char escape_chars[4] = {0};
int current_line = 0;
memclear(lines, NUM_BODY_LINES * (LCD_COLS + 1));
result = f_open(&file, filename, FA_OPEN_EXISTING | FA_READ);
if (result == FR_OK) {
for (unsigned i = 0; i < TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz) == FR_OK && sz == 1 && (lines_count == 0 || current_line - menuVerticalOffset < NUM_BODY_LINES); i++) {
if (c == '\n') {
++current_line;
line_length = 0;
escape = 0;
}
else if (c!='\r' && current_line>=menuVerticalOffset && current_line-menuVerticalOffset<NUM_BODY_LINES && line_length<LCD_COLS) {
if (c == '\\' && escape == 0) {
escape = 1;
continue;
}
else if (c != '\\' && escape > 0 && escape < sizeof(escape_chars)) {
escape_chars[escape - 1] = c;
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
c = '\300';
}
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
c = '\301';
}
else if (escape == 3) {
int val = atoi(escape_chars);
if (val >= 200 && val < 225) {
c = '\200' + val-200;
}
}
else {
escape++;
continue;
}
}
else if (c=='~') {
c = 'z'+1;
}
else if (c=='\t') {
c = 0x1D; //tab
}
escape = 0;
lines[current_line-menuVerticalOffset][line_length++] = c;
}
}
if (c != '\n') {
current_line += 1;
}
f_close(&file);
}
if (lines_count == 0) {
lines_count = current_line;
}
}
// returns true if current working dir is at the root level
bool isCwdAtRoot()
{
+2
View File
@@ -158,6 +158,8 @@ const char * sdCopyFile(const char * srcFilename, const char * srcDir, const cha
#define LIST_SD_FILE_EXT 2
bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen, const char * selection, uint8_t flags=0);
void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS + 1], int & lines_count);
bool isCwdAtRoot();
FRESULT sdReadDir(DIR * dir, FILINFO * fno, bool & firstTime);
@@ -524,14 +524,14 @@ PACK(typedef struct {
ScriptData_v216 scriptsData[MAX_SCRIPTS]; \
char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; \
uint8_t nPotsToWarn; \
int8_t potPosition[NUM_POTS+NUM_SLIDERS]; \
int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; \
uint8_t spare[2];
#elif defined(PCBSKY9X)
#define MODELDATA_EXTRA_216 \
uint8_t externalModule; \
ModuleData_v216 moduleData[NUM_MODULES+1]; \
uint8_t nPotsToWarn; \
int8_t potPosition[NUM_POTS+NUM_SLIDERS]; \
int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; \
uint8_t rxBattAlarms[2];
#endif
@@ -1070,7 +1070,7 @@ void convertModelData_216_to_217(ModelData &model)
#endif
newModel.potsWarnMode = oldModel.nPotsToWarn >> 6;
newModel.potsWarnEnabled = oldModel.nPotsToWarn & 0x1f;
memcpy(newModel.potsWarnPosition, oldModel.potPosition, sizeof(newModel.potsWarnPosition));
memcpy(newModel.potsWarnPosition, oldModel.potsWarnPosition, sizeof(newModel.potsWarnPosition));
}
void convertModelData_217_to_218(ModelData &model)

Some files were not shown because too many files have changed in this diff Show More