Merge with latest 2.3

This commit is contained in:
Bertrand Songis
2020-05-30 11:57:03 +02:00
240 changed files with 16050 additions and 14404 deletions
@@ -489,7 +489,7 @@ end
local function runPopupPage(event)
local result
if fieldPopup.status == 3 then
result = popupConfirmation(fieldPopup.info, event)
result = popupConfirmation("Confirmation", fieldPopup.info, event)
else
result = popupWarning(fieldPopup.info, event)
end
@@ -0,0 +1,157 @@
1,0,Flysky,Flysky,0,CH5,CH6,CH7,CH8
1,1,Flysky,V9x9,1,Flip,Light,Pict,Video
1,2,Flysky,V6x6,1,Flip,Light,Pict,Video,HLess,RTH,XCAL,YCAL
1,3,Flysky,V912,1,BtmBtn,TopBtn
1,4,Flysky,CX20,0,CH5,CH6,CH7
28,0,Flysky_AFHDS2A,PWM_IBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,1,Flysky_AFHDS2A,PPM_IBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,2,Flysky_AFHDS2A,PWM_SBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,3,Flysky_AFHDS2A,PPM_SBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
53,0,Flyzone,FZ-410,0
2,0,Hubsan,H107,1,Flip,Light,Pict,Video,HLess
2,1,Hubsan,H301,0,RTH,Light,Stab,Video
2,2,Hubsan,H501,0,RTH,Light,Pict,Video,HLess,GPS_H,ALT_H,Flip,FModes
41,0,Bugs,3-6-8,0,Arm,Angle,Flip,Pict,Video,LED
60,0,Pelikan,PRO_V4,0,CH5,CH6,CH7,CH8
37,0,Corona,COR_V1,0,CH5,CH6,CH7,CH8
37,1,Corona,COR_V2,0,CH5,CH6,CH7,CH8
37,2,Corona,FD_V3,0,CH5,CH6,CH7,CH8
25,0,FrSkyV,V8,0,CH5,CH6,CH7,CH8
3,0,FrSkyD,D8,0,CH5,CH6,CH7,CH8
3,0,FrSkyD,D8Cloned,0,CH5,CH6,CH7,CH8
67,0,FrSkyL,LR12,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
67,1,FrSkyL,LR12_6CH,0,CH5,CH6
15,0,FrSkyX,D16_FCC,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
15,1,FrSkyX,D16_8CH_FCC,0,CH5,CH6,CH7,CH8
15,2,FrSkyX,D16_LBT,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
15,3,FrSkyX,D16_8CH_LBT,0,CH5,CH6,CH7,CH8
15,4,FrSkyX,D16Cloned,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,0,FrSkyX2,D16_FCC,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,1,FrSkyX2,D16_8CH_FCC,0,CH5,CH6,CH7,CH8
64,2,FrSkyX2,D16_LBT,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,3,FrSkyX2,D16_8CH_LBT,1,CH5,CH6,CH7,CH8
64,4,FrSkyX2,D16Cloned,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
55,0,FrSkyRX,RX,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
55,1,FrSkyRX,CloneTX,0
39,0,Hitec,Opt_Fw,0,CH5,CH6,CH7,CH8,CH9
39,1,Hitec,Opt_Hub,0,CH5,CH6,CH7,CH8,CH9
39,2,Hitec,Minima,0,CH5,CH6,CH7,CH8,CH9
57,0,HoTT,Std,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
21,0,SFHSS,Std,0,CH5,CH6,CH7,CH8
68,0,Skyartec,Std,0,CH5,CH6,CH7
7,0,Devo,8CH,0,CH5,CH6,CH7,CH8
7,1,Devo,10CH,0,CH5,CH6,CH7,CH8,CH9,CH10
7,2,Devo,12CH,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
7,3,Devo,6CH,0,CH5,CH6
7,4,Devo,7CH,0,CH5,CH6,CH7
30,0,WK2x01,WK2801,0,CH5,CH6,CH7,CH8
30,1,WK2x01,WK2401,0
30,2,WK2x01,W6_5_1,0,Gear,Dis,Gyro
30,3,WK2x01,W6_6_1,0,Gear,Col,Gyro
30,4,WK2x01,W6HEL,0,Gear,Col,Gyro
30,5,WK2x01,W6HEL_I,0,Gear,Col,Gyro
6,0,DSM,2_22,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,1,DSM,2_11,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,2,DSM,X_22,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,3,DSM,X_11,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
22,0,J6Pro,Std,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
22,0,WFLY,WFR0xS,0,CH5,CH6,CH7,CH8,CH9
24,0,Assan,Std,0,CH5,CH6,CH7,CH8
14,0,Bayang,Std,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,n-a,n-a,AnAux1,AnAux2
14,1,Bayang,H8S3D,1,Flip,RTH,Pict,Video,HLess,Invert,Rates
14,2,Bayang,X16_AH,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf
14,3,Bayang,IRDRONE,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf,EmStop
14,4,Bayang,DHD_D4,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf,EmStop
59,0,BayangRX,RX,1,AnAux1,AnAux2,Flip,RTH,Pict,Video
42,0,BugsMini,Mini,0,Arm,Angle,Flip,Pict,Video,LED
42,1,BugsMini,3H,0,Arm,Angle,Flip,Pict,Video,LED,AltHol
34,0,Cabell,V3,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
34,1,Cabell,V3Telem,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
13,0,CG023,Std,1,Flip,Light,Pict,Video,HLess
13,1,CG023,YD829,1,Flip,n-a,Pict,Video,HLess
12,0,CX10,Green,1,Flip,Rate
12,1,CX10,Blue,1,Flip,Rate,Pict,Video
12,2,CX10,DM007,1,Flip,Mode,Pict,Video,HLess
12,4,CX10,JC3015_1,1,Flip,Mode,Pict,Video
12,5,CX10,JC3015_2,1,Flip,Mode,LED,DFlip
12,6,CX10,MK33041,1,Flip,Mode,Pict,Video,HLess,RTH
33,0,DM022,Std,1,Flip,LED,Cam1,Cam2,HLess,RTH,RLow
45,0,E01X,E012,1,n-a,Flip,n-a,HLess,RTH
45,1,E01X,E015,1,Arm,Flip,LED,HLess,RTH
45,2,E01X,E016H,1,Stop,Flip,n-a,HLess,RTH
16,0,ESKY,Std,0,Gyro,Pitch
16,1,ESKY,ET4,0,Gyro,Pitch
35,0,ESKY150,4CH,0
35,1,ESKY150,7CH,0,FMode,Aux6,Aux7
20,0,FY326,FY326,1,Flip,RTH,HLess,Expert,Calib
20,1,FY326,FY319,1,Flip,RTH,HLess,Expert,Calib
23,0,FY326,FY326,1,Flip,RTH,HLess,Expert
32,0,GW008,FY326,1,Flip
36,0,H8_3D,Std,1,Flip,Light,Pict,Video,RTH,FlMode,Cal1
36,1,H8_3D,H20H,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
36,2,H8_3D,H20,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
36,3,H8_3D,H30,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
4,0,Hisky,Std,0,Gear,Pitch,Gyro,CH8
9,0,KN,WLToys,0,DRate,THold,IdleUp,Gyro,Ttrim,Atrim,Etrim
9,1,KN,Feilun,0,DRate,THold,IdleUp,Gyro,Ttrim,Atrim,Etrim
26,0,Hontai,Std,1,Flip,LED,Pict,Video,HLess,RTH,Calib
26,1,Hontai,JJRCX1,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
26,2,Hontai,X5C1,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
26,3,Hontai,FQ777_951,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
18,0,MJXQ,WHL08,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,1,MJXQ,X600,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,2,MJXQ,X800,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,3,MJXQ,H26D,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,4,MJXQ,E010,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,5,MJXQ,H26WH,1,Flip,Arm,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,6,MJXQ,Phoenix,1,Flip,Arm,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
17,0,MT99XX,Std,1,Flip,LED,Pict,Video,HLess
17,1,MT99XX,H7,1,Flip,LED,Pict,Video,HLess
17,2,MT99XX,YZ,1,Flip,LED,Pict,Video,HLess
17,3,MT99XX,LS,1,Flip,Invert,Pict,Video,HLess
17,4,MT99XX,FY805,1,Flip,n-a,n-a,n-a,HLess
44,0,NCC1701,Std,1,Warp
51,0,Potensic,A20,1,TakLan,Emerg,Mode,HLess
66,0,Propel,74-Z,1,LEDs,RollCW,RolCCW,Fire,Weapon,Calib,AltHol,TakeOf,Land,Train
29,0,Q2x2,Q222,1,Flip,LED,Mod2,Mod1,HLess,RTH,XCal,YCal
29,1,Q2x2,Q242,1,Flip,LED,Pict,Video,HLess,RTH,XCal,YCal
29,2,Q2x2,Q282,1,Flip,LED,Pict,Video,HLess,RTH,XCal,YCal
31,0,Q303,Q303,1,AltHol,Flip,Pict,Video,HLess,RTH,Gimbal
31,1,Q303,C35,1,Arm,VTX,Pict,Video,n-a,RTH,Gimbal
31,2,Q303,CX10D,1,Arm,Flip
31,3,Q303,CX10WD,1,Arm,Flip
50,0,Redpine,Fast,0,sCH5,sCH6,sCH7,sCH8,sCH9,sCH10,sCH11,sCH12,sCH13,sCH14,sCH15,sCH16
50,1,Redpine,Slow,0,sCH5,sCH6,sCH7,sCH8,sCH9,sCH10,sCH11,sCH12,sCH13,sCH14,sCH15,sCH16
11,0,SLT,V1,0,Gear,Pitch
11,1,SLT,V2,0,CH5,CH6,CH7,CH8
11,2,SLT,Q100,0,Rates,n-a,CH7,CH8,Mode,Flip,n-a,n-a,Calib
11,3,SLT,Q200,0,Rates,n-a,CH7,CH8,Mode,VidOn,VidOff,Calib
11,4,SLT,MR100,0,Rates,n-a,CH7,CH8,Mode,Flip,Video,Pict
10,0,Symax,Std,1,Flip,Rates,Pict,Video,HLess
10,1,Symax,X5C,1,Flip,Rates,Pict,Video,HLess
5,0,V2x2,Std,1,Flip,Light,Pict,Video,HLess,CalX,CalY
5,1,V2x2,JXD506,1,Flip,Light,Pict,Video,HLess,StaSto,Emerg,Cam_UD
61,0,Tiger,Std,1,Flip,Light
46,0,V911s,Std,1,Calib
46,1,E119,Std,1,Calib
62,0,XK,X450,1,FMode,TakeOf,Emerg,3D_6G,Pict,Video
62,1,XK,X420,1,FMode,TakeOf,Emerg,3D_6G,Pict,Video
8,0,YD717,Std,1,Flip,Light,Pict,Video,HLess
8,1,YD717,SkyWlkr,1,Flip,Light,Pict,Video,HLess
8,2,YD717,Simax4,1,Flip,Light,Pict,Video,HLess
8,3,YD717,XinXun,1,Flip,Light,Pict,Video,HLess
8,4,YD717,NiHui,1,Flip,Light,Pict,Video,HLess
65,0,FrSkyR9,R9_915,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
65,1,FrSkyR9,R9_868,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
65,2,FrSkyR9,R9_915_8CH,0,CH5,CH6,CH7,CH8
65,3,FrSkyR9,R9_968_8CH,0,CH5,CH6,CH7,CH8
56,0,Flysky2A_RX,RX,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
19,0,Shenqi,Cycle,1
4,1,Hisky,HK310,0,Aux
43,0,Traxxas,6519,0
52,0,ZSX,280,1,Light
48,0,V761,Std,1,Gyro
49,0,KF606,Std,1,Trim
47,0,GD00x,V1,1,Trim,LED,Rate
47,1,GD00x,V2,1,Trim,LED,Rate
58,0,FX816,P38,1
@@ -0,0 +1,302 @@
local toolName = "TNS|Multi chan namer|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. #
---- # #
---- #########################################################################
local protocol_name = ""
local sub_protocol_name = ""
local bind_ch = 0
local module_conf = {}
local module_pos = "Internal"
local file_ok = 0
local done = 0
local protocol = 0
local sub_protocol = 0
local f_seek = 0
local channel_names={}
local num_search = "Searching"
local function drawScreenTitle(title)
if LCD_W == 480 then
lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR)
lcd.drawText(1, 5, title, MENU_TITLE_COLOR)
else
lcd.drawScreenTitle(title, 0, 0)
end
end
function bitand(a, b)
local result = 0
local bitval = 1
while a > 0 and b > 0 do
if a % 2 == 1 and b % 2 == 1 then -- test the rightmost bits
result = result + bitval -- set the current bit
end
bitval = bitval * 2 -- shift left
a = math.floor(a/2) -- shift right
b = math.floor(b/2)
end
return result
end
local function Multi_Draw_LCD(event)
local line = 0
lcd.clear()
drawScreenTitle("Multi channels namer")
--Display settings
local lcd_opt = 0
if LCD_W == 480 then
x_pos = 10
y_pos = 32
y_inc = 20
else
x_pos = 0
y_pos = 9
y_inc = 8
lcd_opt = SMLSIZE
end
--Multi Module detection
if module_conf["Type"] ~= 6 then
if LCD_W == 480 then
lcd.drawText(10,50,"No Multi module configured...", BLINK)
else
--Draw on LCD_W=128
lcd.drawText(2,17,"No Multi module configured...",SMLSIZE)
end
return
else
lcd.drawText(x_pos, y_pos+y_inc*line,module_pos .. " Multi detected.", lcd_opt)
line = line + 1
end
--Channel order
if (ch_order == -1) then
lcd.drawText(x_pos, y_pos+y_inc*line,"Channels order can't be read from Multi...", lcd_opt)
line = line + 1
end
--Can't open file MultiChan.txt
if file_ok == 0 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Can't read MultiChan.txt file...", lcd_opt)
return
end
if ( protocol_name == "" or sub_protocol_name == "" ) and f_seek ~=-1 then
local f = io.open("/SCRIPTS/TOOLS/MultiChan.txt", "r")
if f == nil then return end
lcd.drawText(x_pos, y_pos+y_inc*line,num_search, lcd_opt)
num_search = num_search .. "."
if #num_search > 15 then
num_search = string.sub(num_search,1,9)
end
local proto = 0
local sub_proto = 0
local proto_name = ""
local sub_proto_name = ""
local channels = ""
local nbr_try = 0
local nbr_car = 0
repeat
io.seek(f, f_seek)
local data = io.read(f, 100) -- read 100 characters
if #data ==0 then
f_seek = -1 -- end of file
break
end
proto, sub_proto, proto_name, sub_proto_name, bind_ch, channels = string.match(data,'(%d+),(%d),([%w-_ ]+),([%w-_ ]+),(%d)(.+)')
if proto ~= nil and sub_proto ~= nil and protocol_name ~= nil and sub_protocol_name ~= nil and bind_ch ~= nil then
if tonumber(proto) == protocol and tonumber(sub_proto) == sub_protocol then
protocol_name = proto_name
sub_protocol_name = sub_proto_name
bind_ch = tonumber(bind_ch)
if channels ~= nil then
--extract channel names
nbr_car = string.find(channels, "\r")
if nbr_car == nil then nbr_car = string.find(channels, "\n") end
if nbr_car ~= nil then
channels = string.sub(channels,1,nbr_car-1)
end
local i = 5
for k in string.gmatch(channels, ",([%w-_ ]+)") do
channel_names[i] = k
i = i + 1
end
end
f_seek = -1 -- protocol found
break
end
end
if f_seek ~= -1 then
nbr_car = string.find(data, "\n")
if nbr_car == nil then nbr_car = string.find(data, "\r") end
if nbr_car == nil then
f_seek = -1 -- end of file
break
end
f_seek = f_seek + nbr_car -- seek to next line
nbr_try = nbr_try + 1
end
until nbr_try > 20 or f_seek == -1
io.close(f)
end
if f_seek ~= -1 then
return -- continue searching...
end
--Protocol & Sub_protocol
if protocol_name == "" or sub_protocol_name == "" then
lcd.drawText(x_pos, y_pos+y_inc*line,"Unknown protocol "..tostring(protocol).."/"..tostring(sub_protocol).." ...", lcd_opt)
return
elseif LCD_W > 128 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Protocol: " .. protocol_name .. " / SubProtocol: " .. sub_protocol_name, lcd_opt)
line = line + 1
else
lcd.drawText(x_pos, y_pos+y_inc*line,"Protocol: " .. protocol_name, lcd_opt)
line = line + 1
lcd.drawText(x_pos, y_pos+y_inc*line,"SubProtocol: " .. sub_protocol_name, lcd_opt)
line = line + 1
end
text1=""
text2=""
for i,v in ipairs(channel_names) do
if i<=8 then
if i==1 then
text1 = v
else
text1=text1 .. "," .. v
end
else
if i==9 then
text2 = v
else
text2=text2 .. "," .. v
end
end
end
if LCD_W > 128 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Channels: " .. text1, lcd_opt)
line = line + 1
if text2 ~= "" then
lcd.drawText(x_pos*9, y_pos+y_inc*line,text2, lcd_opt)
line = line + 1
end
end
if event ~= EVT_VIRTUAL_ENTER and done == 0 then
lcd.drawText(x_pos, y_pos+y_inc*line,"<ENT> Save", lcd_opt + INVERS + BLINK)
return
end
lcd.drawText(x_pos, y_pos+y_inc*line,"Setting channel names.", lcd_opt)
line = line + 1
local output, nbr
if done == 0 then
for i,v in ipairs(channel_names) do
output = model.getOutput(i-1)
output["name"] = v
model.setOutput(i-1,output)
nbr = i
end
for i = nbr, 15 do
output = model.getOutput(i)
output["name"] = "n-a"
model.setOutput(i,output)
end
if bind_ch == 1 then
output = model.getOutput(15)
output["name"] = "BindCH"
model.setOutput(15,output)
end
done = 1
end
lcd.drawText(x_pos, y_pos+y_inc*line,"Done!", lcd_opt)
line = line + 1
end
-- Init
local function Multi_Init()
module_conf = model.getModule(0)
if module_conf["Type"] ~= 6 then
module_pos = "External"
module_conf = model.getModule(1)
if module_conf["Type"] ~= 6 then
return
end
end
protocol = module_conf["protocol"]
sub_protocol = module_conf["subProtocol"]
--Exceptions on first 4 channels...
local stick_names = { "Rud", "Ele", "Thr", "Ail" }
if ( protocol == 4 and sub_protocol ==1 ) or protocol == 19 or protocol == 52 then -- Hisky/HK310, Shenqi, ZSX
stick_names[2] = "n-a"
stick_names[4] = "n-a"
elseif protocol == 43 then -- Traxxas
stick_names[2] = "Aux4"
stick_names[4] = "Aux3"
elseif protocol == 48 then -- V761
stick_names[4] = "n-a"
elseif protocol == 47 or protocol == 49 or protocol == 58 then -- GD00x, KF606, FX816
stick_names[1] = "n-a"
stick_names[2] = "n-a"
end
--Determine fist 4 channels order
local ch_order=module_conf["channelsOrder"]
if (ch_order == -1) then
channel_names[1] = stick_names[defaultChannel(0)+1]
channel_names[2] = stick_names[defaultChannel(1)+1]
channel_names[3] = stick_names[defaultChannel(2)+1]
channel_names[4] = stick_names[defaultChannel(3)+1]
else
channel_names[bitand(ch_order,3)+1] = stick_names[4]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[2]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[3]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[1]
end
--Check MultiChan.txt
local f = io.open("/SCRIPTS/TOOLS/MultiChan.txt", "r")
if f == nil then return end
file_ok = 1
io.close(f)
end
-- Main
local function Multi_Run(event)
if event == nil then
error("Cannot be run as a model script!")
return 2
else
Multi_Draw_LCD(event)
if event == EVT_VIRTUAL_EXIT then
return 2
end
end
return 0
end
return { init=Multi_Init, run=Multi_Run }
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 161 KiB

+147 -85
View File
@@ -19,15 +19,50 @@
-- Horus Widget to display the levels of lipo battery with per cell indication
-- 3djc & Offer Shmuely
-- Date: 2020
-- ver: 0.4
-- ver: 0.5
local version = "v0.5"
local _options = {
{ "Sensor", SOURCE, 0 }, -- default to 'Cels'
{ "Color", COLOR, WHITE },
{ "Shadow", BOOL, 0 },
{ "LowestCell", BOOL, 1 } -- 0=main voltage display shows all-cell-voltage, 1=main voltage display shows lowest-cell
{ "Sensor", SOURCE, 0 }, -- default to 'Cels'
{ "Color", COLOR, WHITE },
{ "Shadow", BOOL, 0 },
{ "LowestCell", BOOL, 1 } -- 0=main voltage display shows all-cell-voltage, 1=main voltage display shows lowest-cell
}
-- Data gathered from commercial lipo sensors
local _lipoPercentListSplit = {
{ { 3, 0 }, { 3.093, 1 }, { 3.196, 2 }, { 3.301, 3 }, { 3.401, 4 }, { 3.477, 5 }, { 3.544, 6 }, { 3.601, 7 }, { 3.637, 8 }, { 3.664, 9 }, { 3.679, 10 }, { 3.683, 11 }, { 3.689, 12 }, { 3.692, 13 } },
{ { 3.705, 14 }, { 3.71, 15 }, { 3.713, 16 }, { 3.715, 17 }, { 3.72, 18 }, { 3.731, 19 }, { 3.735, 20 }, { 3.744, 21 }, { 3.753, 22 }, { 3.756, 23 }, { 3.758, 24 }, { 3.762, 25 }, { 3.767, 26 } },
{ { 3.774, 27 }, { 3.78, 28 }, { 3.783, 29 }, { 3.786, 30 }, { 3.789, 31 }, { 3.794, 32 }, { 3.797, 33 }, { 3.8, 34 }, { 3.802, 35 }, { 3.805, 36 }, { 3.808, 37 }, { 3.811, 38 }, { 3.815, 39 } },
{ { 3.818, 40 }, { 3.822, 41 }, { 3.825, 42 }, { 3.829, 43 }, { 3.833, 44 }, { 3.836, 45 }, { 3.84, 46 }, { 3.843, 47 }, { 3.847, 48 }, { 3.85, 49 }, { 3.854, 50 }, { 3.857, 51 }, { 3.86, 52 } },
{ { 3.863, 53 }, { 3.866, 54 }, { 3.87, 55 }, { 3.874, 56 }, { 3.879, 57 }, { 3.888, 58 }, { 3.893, 59 }, { 3.897, 60 }, { 3.902, 61 }, { 3.906, 62 }, { 3.911, 63 }, { 3.918, 64 } },
{ { 3.923, 65 }, { 3.928, 66 }, { 3.939, 67 }, { 3.943, 68 }, { 3.949, 69 }, { 3.955, 70 }, { 3.961, 71 }, { 3.968, 72 }, { 3.974, 73 }, { 3.981, 74 }, { 3.987, 75 }, { 3.994, 76 } },
{ { 4.001, 77 }, { 4.007, 78 }, { 4.014, 79 }, { 4.021, 80 }, { 4.029, 81 }, { 4.036, 82 }, { 4.044, 83 }, { 4.052, 84 }, { 4.062, 85 }, { 4.074, 86 }, { 4.085, 87 }, { 4.095, 88 } },
{ { 4.105, 89 }, { 4.111, 90 }, { 4.116, 91 }, { 4.12, 92 }, { 4.125, 93 }, { 4.129, 94 }, { 4.135, 95 }, { 4.145, 96 }, { 4.176, 97 }, { 4.179, 98 }, { 4.193, 99 }, { 4.2, 100 } },
}
local function periodicInit(t, durationMili)
t.startTime = getTime();
t.durationMili = durationMili;
end
local function periodicReset(t)
t.startTime = getTime();
end
local function periodicHasPassed(t)
local elapsed = getTime() - t.startTime;
local elapsedMili = elapsed * 10;
if (elapsedMili < t.durationMili) then
return false;
end
return true;
end
local function periodicGetElapsedTime(t)
local elapsed = getTime() - t.startTime;
local elapsedMili = elapsed * 10;
return elapsedMili;
end
-- This function is run once at the creation of the widget
local function create(zone, options)
local wgt = {
@@ -40,8 +75,8 @@ local function create(zone, options)
telemResetLowestMinRSSI = 101,
no_telem_blink = 0,
isDataAvailable = 0,
cellDataLive = {0,0,0,0,0,0},
cellDataHistoryLowest = {5,5,5,5,5,5},
cellDataLive = { 0, 0, 0, 0, 0, 0 },
cellDataHistoryLowest = { 5, 5, 5, 5, 5, 5 },
cellDataHistoryCellLowest = 5,
cellMax = 0,
cellMin = 0,
@@ -50,7 +85,10 @@ local function create(zone, options)
cellCount = 0,
cellSum = 0,
mainValue = 0,
secondaryValue = 0
secondaryValue = 0,
periodic1 = { startTime = getTime(), durationMili = 1000 },
periodicProfiler = { startTime = getTime(), durationMili = 5000 },
profTimes = {},
}
-- use default if user did not set, So widget is operational on "select widget"
@@ -65,7 +103,9 @@ end
-- This function allow updates when you change widgets settings
local function update(wgt, options)
if (wgt == nil) then return end
if (wgt == nil) then
return
end
wgt.options = options
@@ -83,8 +123,8 @@ end
local function onTelemetryResetEvent(wgt)
wgt.telemResetCount = wgt.telemResetCount + 1
wgt.cellDataLive = {0,0,0,0,0,0}
wgt.cellDataHistoryLowest = {5,5,5,5,5,5}
wgt.cellDataLive = { 0, 0, 0, 0, 0, 0 }
wgt.cellDataHistoryLowest = { 5, 5, 5, 5, 5, 5 }
wgt.cellDataHistoryCellLowest = 5
end
@@ -99,9 +139,12 @@ end
local function detectResetEvent(wgt)
local currMinRSSI = getValue('RSSI-')
if (currMinRSSI == nil) then return
if (currMinRSSI == nil) then
return
end
if (currMinRSSI == wgt.telemResetLowestMinRSSI) then
return
end
if (currMinRSSI == wgt.telemResetLowestMinRSSI) then return end
if (currMinRSSI < wgt.telemResetLowestMinRSSI) then
-- rssi just got lower, record it
@@ -118,28 +161,28 @@ local function detectResetEvent(wgt)
end
--- This function return the percentage remaining in a single Lipo cel
local function getCellPercent(cellValue)
--- since running on long array found to be very intensive to hrous cpu, we are splitting the list to small lists
local function getCellPercent(wgt, cellValue)
if cellValue == nil then
return 0
end
local result = 0;
-- in case somehow voltage is higher, don't return nil
if (cellValue > 4.2) then
return 100
end
-- Data gathered from commercial lipo sensors
local myArrayPercentList = { {3,0},{3.093,1},{3.196,2},{3.301,3},{3.401,4},{3.477,5},{3.544,6},{3.601,7},{3.637,8},{3.664,9},{3.679,10},{3.683,11},{3.689,12},{3.692,13},{3.705,14},{3.71,15},{3.713,16},{3.715,17},{3.72,18},{3.731,19},{3.735,20},{3.744,21},{3.753,22},{3.756,23},{3.758,24},{3.762,25},{3.767,26},{3.774,27},{3.78,28},{3.783,29},{3.786,30},{3.789,31},{3.794,32},{3.797,33},{3.8,34},{3.802,35},{3.805,36},{3.808,37},{3.811,38},{3.815,39},{3.818,40},{3.822,41},{3.825,42},{3.829,43},{3.833,44},{3.836,45},{3.84,46},{3.843,47},{3.847,48},{3.85,49},{3.854,50},{3.857,51},{3.86,52},{3.863,53},{3.866,54},{3.87,55},{3.874,56},{3.879,57},{3.888,58},{3.893,59},{3.897,60},{3.902,61},{3.906,62},{3.911,63},{3.918,64},{3.923,65},{3.928,66},{3.939,67},{3.943,68},{3.949,69},{3.955,70},{3.961,71},{3.968,72},{3.974,73},{3.981,74},{3.987,75},{3.994,76},{4.001,77},{4.007,78},{4.014,79},{4.021,80},{4.029,81},{4.036,82},{4.044,83},{4.052,84},{4.062,85},{4.074,86},{4.085,87},{4.095,88},{4.105,89},{4.111,90},{4.116,91},{4.12,92},{4.125,93},{4.129,94},{4.135,95},{4.145,96},{4.176,97},{4.179,98},{4.193,99},{4.2,100} }
for i, v in ipairs(myArrayPercentList) do
if v[1] >= cellValue then
result = v[2]
break
for i1, v1 in ipairs(_lipoPercentListSplit) do
--is the cellVal < last-value-on-sub-list? (first-val:v1[1], last-val:v1[#v1])
if (cellValue <= v1[#v1][1]) then
-- cellVal is in this sub-list, find the exact value
for i2, v2 in ipairs(v1) do
if v2[1] >= cellValue then
result = v2[2]
return result
end
end
end
end
return result
-- in case somehow voltage is too high (>4.2), don't return nil
return 100
end
--- This function returns a table with cels values
@@ -152,20 +195,13 @@ local function calculateBatteryData(wgt)
return
end
-- this is necessary for simu where cell-count can change
if #wgt.cellDataHistoryLowest ~= #newCellData then
wgt.cellDataHistoryLowest = {}
for k, v in pairs(newCellData) do
wgt.cellDataHistoryLowest[k] = 5 -- invalid reading, set high value so the min() will update it soon
end
end
local cellMax = 0
local cellMin = 5
local cellSum = 0
for k, v in pairs(newCellData) do
-- stores the lowest cell values in historical table
if v > 1 and v < wgt.cellDataHistoryLowest[k] then -- min 1v to consider a valid reading
if v > 1 and v < wgt.cellDataHistoryLowest[k] then
-- min 1v to consider a valid reading
wgt.cellDataHistoryLowest[k] = v
--- calc history lowest of all cells
@@ -181,7 +217,8 @@ local function calculateBatteryData(wgt)
end
--- calc lowest of all cells
if v < cellMin and v > 1 then -- min 1v to consider a valid reading
if v < cellMin and v > 1 then
-- min 1v to consider a valid reading
cellMin = v
end
--- sum of all cells
@@ -197,7 +234,6 @@ local function calculateBatteryData(wgt)
--- average of all cells
wgt.cellAvg = wgt.cellSum / wgt.cellCount
wgt.cellPercent = getCellPercent(wgt.cellMin)
wgt.cellDataLive = newCellData
@@ -219,13 +255,19 @@ local function calculateBatteryData(wgt)
wgt.secondaryValue = "-2"
end
wgt.isDataAvailable = true
-- calculate intensive CPU data
if (periodicHasPassed(wgt.periodic1) or wgt.cellPercent == 0) then
--wgt.cellPercent = getCellPercent(wgt, wgt.cellMin) -- use batt percentage by lowest cell voltage
wgt.cellPercent = getCellPercent(wgt, wgt.cellAvg) -- use batt percentage by average cell voltage
periodicReset(wgt.periodic1)
end
end
-- color for battery
-- This function returns green at 100%, red bellow 30% and graduate in between
local function getPercentColor(percent)
@@ -242,34 +284,46 @@ end
-- This function returns green at gvalue, red at rvalue and graduate in between
local function getRangeColor(value, green_value, red_value)
local range = math.abs(green_value - red_value)
if range==0 then return lcd.RGB(0, 0xdf, 0) end
if range == 0 then
return lcd.RGB(0, 0xdf, 0)
end
if value == nil then
return lcd.RGB(0, 0xdf, 0)
end
if green_value > red_value then
if value > green_value then return lcd.RGB(0, 0xdf, 0) end
if value < red_value then return lcd.RGB(0xdf, 0, 0) end
if value > green_value then
return lcd.RGB(0, 0xdf, 0)
end
if value < red_value then
return lcd.RGB(0xdf, 0, 0)
end
g = math.floor(0xdf * (value - red_value) / range)
r = 0xdf - g
return lcd.RGB(r, g, 0)
else
if value > green_value then return lcd.RGB(0, 0xdf, 0) end
if value < red_value then return lcd.RGB(0xdf, 0, 0) end
if value > green_value then
return lcd.RGB(0, 0xdf, 0)
end
if value < red_value then
return lcd.RGB(0xdf, 0, 0)
end
r = math.floor(0xdf * (value - green_value) / range)
g = 0xdf - r
return lcd.RGB(r, g, 0)
end
end
--- Zone size: 70x39 1/8th top bar
local function refreshZoneTiny(wgt)
local myString = string.format("%2.1fV", wgt.mainValue)
lcd.drawText(wgt.zone.x + wgt.zone.w -25, wgt.zone.y + 5, wgt.cellPercent .. "%", RIGHT + SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
lcd.drawText(wgt.zone.x + wgt.zone.w -25, wgt.zone.y + 20, myString, RIGHT + SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
lcd.drawText(wgt.zone.x + wgt.zone.w - 25, wgt.zone.y + 5, wgt.cellPercent .. "%", RIGHT + SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
lcd.drawText(wgt.zone.x + wgt.zone.w - 25, wgt.zone.y + 20, myString, RIGHT + SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
-- draw batt
lcd.drawRectangle(wgt.zone.x + 50, wgt.zone.y + 9, 16, 25, CUSTOM_COLOR, 2)
lcd.drawFilledRectangle(wgt.zone.x +50 + 4, wgt.zone.y + 7, 6, 3, CUSTOM_COLOR)
lcd.drawFilledRectangle(wgt.zone.x + 50 + 4, wgt.zone.y + 7, 6, 3, CUSTOM_COLOR)
local rect_h = math.floor(25 * wgt.cellPercent / 100)
lcd.drawFilledRectangle(wgt.zone.x +50, wgt.zone.y + 9 + 25 - rect_h, 16, rect_h, CUSTOM_COLOR + wgt.no_telem_blink)
lcd.drawFilledRectangle(wgt.zone.x + 50, wgt.zone.y + 9 + 25 - rect_h, 16, rect_h, CUSTOM_COLOR + wgt.no_telem_blink)
end
--- Zone size: 160x32 1/8th
@@ -307,13 +361,13 @@ local function refreshZoneMedium(wgt)
end
-- draw values
lcd.drawText(wgt.zone.x, wgt.zone.y + 35, string.format("%2.1fV", wgt.mainValue), DBLSIZE + CUSTOM_COLOR + wgt.shadowed + wgt.no_telem_blink)
lcd.drawText(wgt.zone.x + wgt.zone.w, wgt.zone.y, string.format("%2.1fV", wgt.mainValue), DBLSIZE + CUSTOM_COLOR + RIGHT + wgt.shadowed + wgt.no_telem_blink)
-- more info if 1/4 is high enough (without trim & slider)
if wgt.zone.h > 80 then
lcd.drawText(wgt.zone.x , wgt.zone.y + 70, string.format("%2.2fV" , wgt.secondaryValue), SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
lcd.drawText(wgt.zone.x + 50, wgt.zone.y + 70, string.format("dV %2.2fV", wgt.cellMax - wgt.cellMin), SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
lcd.drawText(wgt.zone.x , wgt.zone.y + 84, string.format("Min %2.2fV", wgt.cellDataHistoryCellLowest), SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
--lcd.drawText(wgt.zone.x + 50 , wgt.zone.y + 70, string.format("%2.2fV" , wgt.secondaryValue), SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
lcd.drawText(wgt.zone.x, wgt.zone.y + 70, string.format("dV %2.2fV", wgt.cellMax - wgt.cellMin), SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
lcd.drawText(wgt.zone.x, wgt.zone.y + 84, string.format("Min %2.2fV", wgt.cellDataHistoryCellLowest), SMLSIZE + CUSTOM_COLOR + wgt.no_telem_blink)
end
-- fill batt
@@ -321,28 +375,21 @@ local function refreshZoneMedium(wgt)
lcd.drawGauge(wgt.zone.x + myBatt.x, wgt.zone.y + myBatt.y, myBatt.w, myBatt.h, wgt.cellPercent, 100, CUSTOM_COLOR)
-- draw cells
local cellH = wgt.zone.h / wgt.cellCount
if cellH > 20 then cellH =20 end
local cellH = 19
local cellX = 118
local cellW = 58
local cellW = wgt.zone.w / 3
local pos = { { x = 0, y = 38 }, { x = cellW, y = 38 }, { x = 2 * cellW, y = 38 }, { x = 0, y = 57 }, { x = cellW, y = 57 }, { x = 2 * cellW, y = 57 } }
for i = 1, wgt.cellCount, 1 do
local cellY = wgt.zone.y + (i-1)* (cellH -1)
local cellY = wgt.zone.y + (i - 1) * (cellH - 1)
-- fill current cell
lcd.setColor(CUSTOM_COLOR, getRangeColor(wgt.cellDataLive[i], wgt.cellMax, wgt.cellMax - 0.2))
--lcd.drawFilledRectangle(wgt.zone.x + cellX , cellY, 58, cellH, CUSTOM_COLOR)
local percentCurrent = getCellPercent(wgt.cellDataLive[i])
local percentMin = getCellPercent(wgt.cellDataHistoryLowest[i])
lcd.drawFilledRectangle(wgt.zone.x + cellX , cellY, cellW * percentCurrent / 100, cellH, CUSTOM_COLOR)
-- fill min
lcd.setColor(CUSTOM_COLOR, getRangeColor(wgt.cellDataHistoryLowest[i], wgt.cellMax, wgt.cellMax - 0.2))
lcd.drawFilledRectangle(wgt.zone.x + cellX + ((percentCurrent - percentMin) / 100) , cellY, cellW - (cellW * (percentCurrent - percentMin) / 100), cellH, CUSTOM_COLOR)
lcd.setColor(CUSTOM_COLOR, getRangeColor(wgt.cellDataLive[i], wgt.cellMax, wgt.cellMax - 0.2))
lcd.drawFilledRectangle(wgt.zone.x + pos[i].x, wgt.zone.y + pos[i].y, cellW - 1, 20, CUSTOM_COLOR)
lcd.setColor(CUSTOM_COLOR, WHITE)
lcd.drawText (wgt.zone.x + cellX + 10, cellY, string.format("%.2f", wgt.cellDataLive[i]), SMLSIZE + CUSTOM_COLOR + wgt.shadowed + wgt.no_telem_blink)
lcd.drawRectangle (wgt.zone.x + cellX , cellY, 59, cellH, CUSTOM_COLOR , 1)
lcd.drawText(wgt.zone.x + pos[i].x + 10, wgt.zone.y + pos[i].y, string.format("%.2f", wgt.cellDataLive[i]), CUSTOM_COLOR + wgt.shadowed)
lcd.drawRectangle(wgt.zone.x + pos[i].x, wgt.zone.y + pos[i].y, cellW, 20, CUSTOM_COLOR, 1)
end
-- draws bat
@@ -447,7 +494,9 @@ end
-- This function allow recording of lowest cells when widget is in background
local function background(wgt)
if (wgt == nil) then return end
if (wgt == nil) then
return
end
detectResetEvent(wgt)
@@ -456,11 +505,21 @@ local function background(wgt)
end
local function refresh(wgt)
if (wgt == nil) then return end
if (wgt.options == nil) then return end
if (wgt.zone == nil) then return end
if (wgt.options.LowestCell == nil) then return end
if (wgt == nil) then
return
end
if type(wgt) ~= "table" then
return
end
if (wgt.options == nil) then
return
end
if (wgt.zone == nil) then
return
end
if (wgt.options.LowestCell == nil) then
return
end
if wgt.options.Shadow == 1 then
wgt.shadowed = SHADOWED
@@ -478,14 +537,17 @@ local function refresh(wgt)
wgt.no_telem_blink = INVERS + BLINK
end
if wgt.zone.w > 380 and wgt.zone.h > 165 then refreshZoneXLarge(wgt)
elseif wgt.zone.w > 180 and wgt.zone.h > 145 then refreshZoneLarge(wgt)
elseif wgt.zone.w > 170 and wgt.zone.h > 65 then refreshZoneMedium(wgt)
elseif wgt.zone.w > 150 and wgt.zone.h > 28 then refreshZoneSmall(wgt)
elseif wgt.zone.w > 65 and wgt.zone.h > 35 then refreshZoneTiny(wgt)
if wgt.zone.w > 380 and wgt.zone.h > 165 then
refreshZoneXLarge(wgt)
elseif wgt.zone.w > 180 and wgt.zone.h > 145 then
refreshZoneLarge(wgt)
elseif wgt.zone.w > 170 and wgt.zone.h > 65 then
refreshZoneMedium(wgt)
elseif wgt.zone.w > 150 and wgt.zone.h > 28 then
refreshZoneSmall(wgt)
elseif wgt.zone.w > 65 and wgt.zone.h > 35 then
refreshZoneTiny(wgt)
end
end
return { name="BattCheck", options=_options, create=create, update=update, background=background, refresh=refresh }
return { name = "BattCheck", options = _options, create = create, update = update, background = background, refresh = refresh }
@@ -0,0 +1,157 @@
1,0,Flysky,Flysky,0,CH5,CH6,CH7,CH8
1,1,Flysky,V9x9,1,Flip,Light,Pict,Video
1,2,Flysky,V6x6,1,Flip,Light,Pict,Video,HLess,RTH,XCAL,YCAL
1,3,Flysky,V912,1,BtmBtn,TopBtn
1,4,Flysky,CX20,0,CH5,CH6,CH7
28,0,Flysky_AFHDS2A,PWM_IBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,1,Flysky_AFHDS2A,PPM_IBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,2,Flysky_AFHDS2A,PWM_SBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,3,Flysky_AFHDS2A,PPM_SBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
53,0,Flyzone,FZ-410,0
2,0,Hubsan,H107,1,Flip,Light,Pict,Video,HLess
2,1,Hubsan,H301,0,RTH,Light,Stab,Video
2,2,Hubsan,H501,0,RTH,Light,Pict,Video,HLess,GPS_H,ALT_H,Flip,FModes
41,0,Bugs,3-6-8,0,Arm,Angle,Flip,Pict,Video,LED
60,0,Pelikan,PRO_V4,0,CH5,CH6,CH7,CH8
37,0,Corona,COR_V1,0,CH5,CH6,CH7,CH8
37,1,Corona,COR_V2,0,CH5,CH6,CH7,CH8
37,2,Corona,FD_V3,0,CH5,CH6,CH7,CH8
25,0,FrSkyV,V8,0,CH5,CH6,CH7,CH8
3,0,FrSkyD,D8,0,CH5,CH6,CH7,CH8
3,0,FrSkyD,D8Cloned,0,CH5,CH6,CH7,CH8
67,0,FrSkyL,LR12,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
67,1,FrSkyL,LR12_6CH,0,CH5,CH6
15,0,FrSkyX,D16_FCC,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
15,1,FrSkyX,D16_8CH_FCC,0,CH5,CH6,CH7,CH8
15,2,FrSkyX,D16_LBT,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
15,3,FrSkyX,D16_8CH_LBT,0,CH5,CH6,CH7,CH8
15,4,FrSkyX,D16Cloned,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,0,FrSkyX2,D16_FCC,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,1,FrSkyX2,D16_8CH_FCC,0,CH5,CH6,CH7,CH8
64,2,FrSkyX2,D16_LBT,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,3,FrSkyX2,D16_8CH_LBT,1,CH5,CH6,CH7,CH8
64,4,FrSkyX2,D16Cloned,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
55,0,FrSkyRX,RX,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
55,1,FrSkyRX,CloneTX,0
39,0,Hitec,Opt_Fw,0,CH5,CH6,CH7,CH8,CH9
39,1,Hitec,Opt_Hub,0,CH5,CH6,CH7,CH8,CH9
39,2,Hitec,Minima,0,CH5,CH6,CH7,CH8,CH9
57,0,HoTT,Std,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
21,0,SFHSS,Std,0,CH5,CH6,CH7,CH8
68,0,Skyartec,Std,0,CH5,CH6,CH7
7,0,Devo,8CH,0,CH5,CH6,CH7,CH8
7,1,Devo,10CH,0,CH5,CH6,CH7,CH8,CH9,CH10
7,2,Devo,12CH,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
7,3,Devo,6CH,0,CH5,CH6
7,4,Devo,7CH,0,CH5,CH6,CH7
30,0,WK2x01,WK2801,0,CH5,CH6,CH7,CH8
30,1,WK2x01,WK2401,0
30,2,WK2x01,W6_5_1,0,Gear,Dis,Gyro
30,3,WK2x01,W6_6_1,0,Gear,Col,Gyro
30,4,WK2x01,W6HEL,0,Gear,Col,Gyro
30,5,WK2x01,W6HEL_I,0,Gear,Col,Gyro
6,0,DSM,2_22,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,1,DSM,2_11,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,2,DSM,X_22,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,3,DSM,X_11,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
22,0,J6Pro,Std,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
22,0,WFLY,WFR0xS,0,CH5,CH6,CH7,CH8,CH9
24,0,Assan,Std,0,CH5,CH6,CH7,CH8
14,0,Bayang,Std,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,n-a,n-a,AnAux1,AnAux2
14,1,Bayang,H8S3D,1,Flip,RTH,Pict,Video,HLess,Invert,Rates
14,2,Bayang,X16_AH,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf
14,3,Bayang,IRDRONE,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf,EmStop
14,4,Bayang,DHD_D4,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf,EmStop
59,0,BayangRX,RX,1,AnAux1,AnAux2,Flip,RTH,Pict,Video
42,0,BugsMini,Mini,0,Arm,Angle,Flip,Pict,Video,LED
42,1,BugsMini,3H,0,Arm,Angle,Flip,Pict,Video,LED,AltHol
34,0,Cabell,V3,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
34,1,Cabell,V3Telem,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
13,0,CG023,Std,1,Flip,Light,Pict,Video,HLess
13,1,CG023,YD829,1,Flip,n-a,Pict,Video,HLess
12,0,CX10,Green,1,Flip,Rate
12,1,CX10,Blue,1,Flip,Rate,Pict,Video
12,2,CX10,DM007,1,Flip,Mode,Pict,Video,HLess
12,4,CX10,JC3015_1,1,Flip,Mode,Pict,Video
12,5,CX10,JC3015_2,1,Flip,Mode,LED,DFlip
12,6,CX10,MK33041,1,Flip,Mode,Pict,Video,HLess,RTH
33,0,DM022,Std,1,Flip,LED,Cam1,Cam2,HLess,RTH,RLow
45,0,E01X,E012,1,n-a,Flip,n-a,HLess,RTH
45,1,E01X,E015,1,Arm,Flip,LED,HLess,RTH
45,2,E01X,E016H,1,Stop,Flip,n-a,HLess,RTH
16,0,ESKY,Std,0,Gyro,Pitch
16,1,ESKY,ET4,0,Gyro,Pitch
35,0,ESKY150,4CH,0
35,1,ESKY150,7CH,0,FMode,Aux6,Aux7
20,0,FY326,FY326,1,Flip,RTH,HLess,Expert,Calib
20,1,FY326,FY319,1,Flip,RTH,HLess,Expert,Calib
23,0,FY326,FY326,1,Flip,RTH,HLess,Expert
32,0,GW008,FY326,1,Flip
36,0,H8_3D,Std,1,Flip,Light,Pict,Video,RTH,FlMode,Cal1
36,1,H8_3D,H20H,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
36,2,H8_3D,H20,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
36,3,H8_3D,H30,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
4,0,Hisky,Std,0,Gear,Pitch,Gyro,CH8
9,0,KN,WLToys,0,DRate,THold,IdleUp,Gyro,Ttrim,Atrim,Etrim
9,1,KN,Feilun,0,DRate,THold,IdleUp,Gyro,Ttrim,Atrim,Etrim
26,0,Hontai,Std,1,Flip,LED,Pict,Video,HLess,RTH,Calib
26,1,Hontai,JJRCX1,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
26,2,Hontai,X5C1,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
26,3,Hontai,FQ777_951,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
18,0,MJXQ,WHL08,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,1,MJXQ,X600,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,2,MJXQ,X800,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,3,MJXQ,H26D,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,4,MJXQ,E010,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,5,MJXQ,H26WH,1,Flip,Arm,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,6,MJXQ,Phoenix,1,Flip,Arm,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
17,0,MT99XX,Std,1,Flip,LED,Pict,Video,HLess
17,1,MT99XX,H7,1,Flip,LED,Pict,Video,HLess
17,2,MT99XX,YZ,1,Flip,LED,Pict,Video,HLess
17,3,MT99XX,LS,1,Flip,Invert,Pict,Video,HLess
17,4,MT99XX,FY805,1,Flip,n-a,n-a,n-a,HLess
44,0,NCC1701,Std,1,Warp
51,0,Potensic,A20,1,TakLan,Emerg,Mode,HLess
66,0,Propel,74-Z,1,LEDs,RollCW,RolCCW,Fire,Weapon,Calib,AltHol,TakeOf,Land,Train
29,0,Q2x2,Q222,1,Flip,LED,Mod2,Mod1,HLess,RTH,XCal,YCal
29,1,Q2x2,Q242,1,Flip,LED,Pict,Video,HLess,RTH,XCal,YCal
29,2,Q2x2,Q282,1,Flip,LED,Pict,Video,HLess,RTH,XCal,YCal
31,0,Q303,Q303,1,AltHol,Flip,Pict,Video,HLess,RTH,Gimbal
31,1,Q303,C35,1,Arm,VTX,Pict,Video,n-a,RTH,Gimbal
31,2,Q303,CX10D,1,Arm,Flip
31,3,Q303,CX10WD,1,Arm,Flip
50,0,Redpine,Fast,0,sCH5,sCH6,sCH7,sCH8,sCH9,sCH10,sCH11,sCH12,sCH13,sCH14,sCH15,sCH16
50,1,Redpine,Slow,0,sCH5,sCH6,sCH7,sCH8,sCH9,sCH10,sCH11,sCH12,sCH13,sCH14,sCH15,sCH16
11,0,SLT,V1,0,Gear,Pitch
11,1,SLT,V2,0,CH5,CH6,CH7,CH8
11,2,SLT,Q100,0,Rates,n-a,CH7,CH8,Mode,Flip,n-a,n-a,Calib
11,3,SLT,Q200,0,Rates,n-a,CH7,CH8,Mode,VidOn,VidOff,Calib
11,4,SLT,MR100,0,Rates,n-a,CH7,CH8,Mode,Flip,Video,Pict
10,0,Symax,Std,1,Flip,Rates,Pict,Video,HLess
10,1,Symax,X5C,1,Flip,Rates,Pict,Video,HLess
5,0,V2x2,Std,1,Flip,Light,Pict,Video,HLess,CalX,CalY
5,1,V2x2,JXD506,1,Flip,Light,Pict,Video,HLess,StaSto,Emerg,Cam_UD
61,0,Tiger,Std,1,Flip,Light
46,0,V911s,Std,1,Calib
46,1,E119,Std,1,Calib
62,0,XK,X450,1,FMode,TakeOf,Emerg,3D_6G,Pict,Video
62,1,XK,X420,1,FMode,TakeOf,Emerg,3D_6G,Pict,Video
8,0,YD717,Std,1,Flip,Light,Pict,Video,HLess
8,1,YD717,SkyWlkr,1,Flip,Light,Pict,Video,HLess
8,2,YD717,Simax4,1,Flip,Light,Pict,Video,HLess
8,3,YD717,XinXun,1,Flip,Light,Pict,Video,HLess
8,4,YD717,NiHui,1,Flip,Light,Pict,Video,HLess
65,0,FrSkyR9,R9_915,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
65,1,FrSkyR9,R9_868,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
65,2,FrSkyR9,R9_915_8CH,0,CH5,CH6,CH7,CH8
65,3,FrSkyR9,R9_968_8CH,0,CH5,CH6,CH7,CH8
56,0,Flysky2A_RX,RX,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
19,0,Shenqi,Cycle,1
4,1,Hisky,HK310,0,Aux
43,0,Traxxas,6519,0
52,0,ZSX,280,1,Light
48,0,V761,Std,1,Gyro
49,0,KF606,Std,1,Trim
47,0,GD00x,V1,1,Trim,LED,Rate
47,1,GD00x,V2,1,Trim,LED,Rate
58,0,FX816,P38,1
@@ -0,0 +1,302 @@
local toolName = "TNS|Multi chan namer|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. #
---- # #
---- #########################################################################
local protocol_name = ""
local sub_protocol_name = ""
local bind_ch = 0
local module_conf = {}
local module_pos = "Internal"
local file_ok = 0
local done = 0
local protocol = 0
local sub_protocol = 0
local f_seek = 0
local channel_names={}
local num_search = "Searching"
local function drawScreenTitle(title)
if LCD_W == 480 then
lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR)
lcd.drawText(1, 5, title, MENU_TITLE_COLOR)
else
lcd.drawScreenTitle(title, 0, 0)
end
end
function bitand(a, b)
local result = 0
local bitval = 1
while a > 0 and b > 0 do
if a % 2 == 1 and b % 2 == 1 then -- test the rightmost bits
result = result + bitval -- set the current bit
end
bitval = bitval * 2 -- shift left
a = math.floor(a/2) -- shift right
b = math.floor(b/2)
end
return result
end
local function Multi_Draw_LCD(event)
local line = 0
lcd.clear()
drawScreenTitle("Multi channels namer")
--Display settings
local lcd_opt = 0
if LCD_W == 480 then
x_pos = 10
y_pos = 32
y_inc = 20
else
x_pos = 0
y_pos = 9
y_inc = 8
lcd_opt = SMLSIZE
end
--Multi Module detection
if module_conf["Type"] ~= 6 then
if LCD_W == 480 then
lcd.drawText(10,50,"No Multi module configured...", BLINK)
else
--Draw on LCD_W=128
lcd.drawText(2,17,"No Multi module configured...",SMLSIZE)
end
return
else
lcd.drawText(x_pos, y_pos+y_inc*line,module_pos .. " Multi detected.", lcd_opt)
line = line + 1
end
--Channel order
if (ch_order == -1) then
lcd.drawText(x_pos, y_pos+y_inc*line,"Channels order can't be read from Multi...", lcd_opt)
line = line + 1
end
--Can't open file MultiChan.txt
if file_ok == 0 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Can't read MultiChan.txt file...", lcd_opt)
return
end
if ( protocol_name == "" or sub_protocol_name == "" ) and f_seek ~=-1 then
local f = io.open("/SCRIPTS/TOOLS/MultiChan.txt", "r")
if f == nil then return end
lcd.drawText(x_pos, y_pos+y_inc*line,num_search, lcd_opt)
num_search = num_search .. "."
if #num_search > 15 then
num_search = string.sub(num_search,1,9)
end
local proto = 0
local sub_proto = 0
local proto_name = ""
local sub_proto_name = ""
local channels = ""
local nbr_try = 0
local nbr_car = 0
repeat
io.seek(f, f_seek)
local data = io.read(f, 100) -- read 100 characters
if #data ==0 then
f_seek = -1 -- end of file
break
end
proto, sub_proto, proto_name, sub_proto_name, bind_ch, channels = string.match(data,'(%d+),(%d),([%w-_ ]+),([%w-_ ]+),(%d)(.+)')
if proto ~= nil and sub_proto ~= nil and protocol_name ~= nil and sub_protocol_name ~= nil and bind_ch ~= nil then
if tonumber(proto) == protocol and tonumber(sub_proto) == sub_protocol then
protocol_name = proto_name
sub_protocol_name = sub_proto_name
bind_ch = tonumber(bind_ch)
if channels ~= nil then
--extract channel names
nbr_car = string.find(channels, "\r")
if nbr_car == nil then nbr_car = string.find(channels, "\n") end
if nbr_car ~= nil then
channels = string.sub(channels,1,nbr_car-1)
end
local i = 5
for k in string.gmatch(channels, ",([%w-_ ]+)") do
channel_names[i] = k
i = i + 1
end
end
f_seek = -1 -- protocol found
break
end
end
if f_seek ~= -1 then
nbr_car = string.find(data, "\n")
if nbr_car == nil then nbr_car = string.find(data, "\r") end
if nbr_car == nil then
f_seek = -1 -- end of file
break
end
f_seek = f_seek + nbr_car -- seek to next line
nbr_try = nbr_try + 1
end
until nbr_try > 20 or f_seek == -1
io.close(f)
end
if f_seek ~= -1 then
return -- continue searching...
end
--Protocol & Sub_protocol
if protocol_name == "" or sub_protocol_name == "" then
lcd.drawText(x_pos, y_pos+y_inc*line,"Unknown protocol "..tostring(protocol).."/"..tostring(sub_protocol).." ...", lcd_opt)
return
elseif LCD_W > 128 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Protocol: " .. protocol_name .. " / SubProtocol: " .. sub_protocol_name, lcd_opt)
line = line + 1
else
lcd.drawText(x_pos, y_pos+y_inc*line,"Protocol: " .. protocol_name, lcd_opt)
line = line + 1
lcd.drawText(x_pos, y_pos+y_inc*line,"SubProtocol: " .. sub_protocol_name, lcd_opt)
line = line + 1
end
text1=""
text2=""
for i,v in ipairs(channel_names) do
if i<=8 then
if i==1 then
text1 = v
else
text1=text1 .. "," .. v
end
else
if i==9 then
text2 = v
else
text2=text2 .. "," .. v
end
end
end
if LCD_W > 128 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Channels: " .. text1, lcd_opt)
line = line + 1
if text2 ~= "" then
lcd.drawText(x_pos*9, y_pos+y_inc*line,text2, lcd_opt)
line = line + 1
end
end
if event ~= EVT_VIRTUAL_ENTER and done == 0 then
lcd.drawText(x_pos, y_pos+y_inc*line,"<ENT> Save", lcd_opt + INVERS + BLINK)
return
end
lcd.drawText(x_pos, y_pos+y_inc*line,"Setting channel names.", lcd_opt)
line = line + 1
local output, nbr
if done == 0 then
for i,v in ipairs(channel_names) do
output = model.getOutput(i-1)
output["name"] = v
model.setOutput(i-1,output)
nbr = i
end
for i = nbr, 15 do
output = model.getOutput(i)
output["name"] = "n-a"
model.setOutput(i,output)
end
if bind_ch == 1 then
output = model.getOutput(15)
output["name"] = "BindCH"
model.setOutput(15,output)
end
done = 1
end
lcd.drawText(x_pos, y_pos+y_inc*line,"Done!", lcd_opt)
line = line + 1
end
-- Init
local function Multi_Init()
module_conf = model.getModule(0)
if module_conf["Type"] ~= 6 then
module_pos = "External"
module_conf = model.getModule(1)
if module_conf["Type"] ~= 6 then
return
end
end
protocol = module_conf["protocol"]
sub_protocol = module_conf["subProtocol"]
--Exceptions on first 4 channels...
local stick_names = { "Rud", "Ele", "Thr", "Ail" }
if ( protocol == 4 and sub_protocol ==1 ) or protocol == 19 or protocol == 52 then -- Hisky/HK310, Shenqi, ZSX
stick_names[2] = "n-a"
stick_names[4] = "n-a"
elseif protocol == 43 then -- Traxxas
stick_names[2] = "Aux4"
stick_names[4] = "Aux3"
elseif protocol == 48 then -- V761
stick_names[4] = "n-a"
elseif protocol == 47 or protocol == 49 or protocol == 58 then -- GD00x, KF606, FX816
stick_names[1] = "n-a"
stick_names[2] = "n-a"
end
--Determine fist 4 channels order
local ch_order=module_conf["channelsOrder"]
if (ch_order == -1) then
channel_names[1] = stick_names[defaultChannel(0)+1]
channel_names[2] = stick_names[defaultChannel(1)+1]
channel_names[3] = stick_names[defaultChannel(2)+1]
channel_names[4] = stick_names[defaultChannel(3)+1]
else
channel_names[bitand(ch_order,3)+1] = stick_names[4]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[2]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[3]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[1]
end
--Check MultiChan.txt
local f = io.open("/SCRIPTS/TOOLS/MultiChan.txt", "r")
if f == nil then return end
file_ok = 1
io.close(f)
end
-- Main
local function Multi_Run(event)
if event == nil then
error("Cannot be run as a model script!")
return 2
else
Multi_Draw_LCD(event)
if event == EVT_VIRTUAL_EXIT then
return 2
end
end
return 0
end
return { init=Multi_Init, run=Multi_Run }
@@ -0,0 +1,157 @@
1,0,Flysky,Flysky,0,CH5,CH6,CH7,CH8
1,1,Flysky,V9x9,1,Flip,Light,Pict,Video
1,2,Flysky,V6x6,1,Flip,Light,Pict,Video,HLess,RTH,XCAL,YCAL
1,3,Flysky,V912,1,BtmBtn,TopBtn
1,4,Flysky,CX20,0,CH5,CH6,CH7
28,0,Flysky_AFHDS2A,PWM_IBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,1,Flysky_AFHDS2A,PPM_IBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,2,Flysky_AFHDS2A,PWM_SBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
28,3,Flysky_AFHDS2A,PPM_SBUS,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
53,0,Flyzone,FZ-410,0
2,0,Hubsan,H107,1,Flip,Light,Pict,Video,HLess
2,1,Hubsan,H301,0,RTH,Light,Stab,Video
2,2,Hubsan,H501,0,RTH,Light,Pict,Video,HLess,GPS_H,ALT_H,Flip,FModes
41,0,Bugs,3-6-8,0,Arm,Angle,Flip,Pict,Video,LED
60,0,Pelikan,PRO_V4,0,CH5,CH6,CH7,CH8
37,0,Corona,COR_V1,0,CH5,CH6,CH7,CH8
37,1,Corona,COR_V2,0,CH5,CH6,CH7,CH8
37,2,Corona,FD_V3,0,CH5,CH6,CH7,CH8
25,0,FrSkyV,V8,0,CH5,CH6,CH7,CH8
3,0,FrSkyD,D8,0,CH5,CH6,CH7,CH8
3,0,FrSkyD,D8Cloned,0,CH5,CH6,CH7,CH8
67,0,FrSkyL,LR12,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
67,1,FrSkyL,LR12_6CH,0,CH5,CH6
15,0,FrSkyX,D16_FCC,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
15,1,FrSkyX,D16_8CH_FCC,0,CH5,CH6,CH7,CH8
15,2,FrSkyX,D16_LBT,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
15,3,FrSkyX,D16_8CH_LBT,0,CH5,CH6,CH7,CH8
15,4,FrSkyX,D16Cloned,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,0,FrSkyX2,D16_FCC,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,1,FrSkyX2,D16_8CH_FCC,0,CH5,CH6,CH7,CH8
64,2,FrSkyX2,D16_LBT,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
64,3,FrSkyX2,D16_8CH_LBT,1,CH5,CH6,CH7,CH8
64,4,FrSkyX2,D16Cloned,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
55,0,FrSkyRX,RX,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
55,1,FrSkyRX,CloneTX,0
39,0,Hitec,Opt_Fw,0,CH5,CH6,CH7,CH8,CH9
39,1,Hitec,Opt_Hub,0,CH5,CH6,CH7,CH8,CH9
39,2,Hitec,Minima,0,CH5,CH6,CH7,CH8,CH9
57,0,HoTT,Std,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
21,0,SFHSS,Std,0,CH5,CH6,CH7,CH8
68,0,Skyartec,Std,0,CH5,CH6,CH7
7,0,Devo,8CH,0,CH5,CH6,CH7,CH8
7,1,Devo,10CH,0,CH5,CH6,CH7,CH8,CH9,CH10
7,2,Devo,12CH,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
7,3,Devo,6CH,0,CH5,CH6
7,4,Devo,7CH,0,CH5,CH6,CH7
30,0,WK2x01,WK2801,0,CH5,CH6,CH7,CH8
30,1,WK2x01,WK2401,0
30,2,WK2x01,W6_5_1,0,Gear,Dis,Gyro
30,3,WK2x01,W6_6_1,0,Gear,Col,Gyro
30,4,WK2x01,W6HEL,0,Gear,Col,Gyro
30,5,WK2x01,W6HEL_I,0,Gear,Col,Gyro
6,0,DSM,2_22,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,1,DSM,2_11,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,2,DSM,X_22,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
6,3,DSM,X_11,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,n-a,ThKill
22,0,J6Pro,Std,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12
22,0,WFLY,WFR0xS,0,CH5,CH6,CH7,CH8,CH9
24,0,Assan,Std,0,CH5,CH6,CH7,CH8
14,0,Bayang,Std,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,n-a,n-a,AnAux1,AnAux2
14,1,Bayang,H8S3D,1,Flip,RTH,Pict,Video,HLess,Invert,Rates
14,2,Bayang,X16_AH,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf
14,3,Bayang,IRDRONE,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf,EmStop
14,4,Bayang,DHD_D4,1,Flip,RTH,Pict,Video,HLess,Invert,Rates,TakeOf,EmStop
59,0,BayangRX,RX,1,AnAux1,AnAux2,Flip,RTH,Pict,Video
42,0,BugsMini,Mini,0,Arm,Angle,Flip,Pict,Video,LED
42,1,BugsMini,3H,0,Arm,Angle,Flip,Pict,Video,LED,AltHol
34,0,Cabell,V3,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
34,1,Cabell,V3Telem,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
13,0,CG023,Std,1,Flip,Light,Pict,Video,HLess
13,1,CG023,YD829,1,Flip,n-a,Pict,Video,HLess
12,0,CX10,Green,1,Flip,Rate
12,1,CX10,Blue,1,Flip,Rate,Pict,Video
12,2,CX10,DM007,1,Flip,Mode,Pict,Video,HLess
12,4,CX10,JC3015_1,1,Flip,Mode,Pict,Video
12,5,CX10,JC3015_2,1,Flip,Mode,LED,DFlip
12,6,CX10,MK33041,1,Flip,Mode,Pict,Video,HLess,RTH
33,0,DM022,Std,1,Flip,LED,Cam1,Cam2,HLess,RTH,RLow
45,0,E01X,E012,1,n-a,Flip,n-a,HLess,RTH
45,1,E01X,E015,1,Arm,Flip,LED,HLess,RTH
45,2,E01X,E016H,1,Stop,Flip,n-a,HLess,RTH
16,0,ESKY,Std,0,Gyro,Pitch
16,1,ESKY,ET4,0,Gyro,Pitch
35,0,ESKY150,4CH,0
35,1,ESKY150,7CH,0,FMode,Aux6,Aux7
20,0,FY326,FY326,1,Flip,RTH,HLess,Expert,Calib
20,1,FY326,FY319,1,Flip,RTH,HLess,Expert,Calib
23,0,FY326,FY326,1,Flip,RTH,HLess,Expert
32,0,GW008,FY326,1,Flip
36,0,H8_3D,Std,1,Flip,Light,Pict,Video,RTH,FlMode,Cal1
36,1,H8_3D,H20H,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
36,2,H8_3D,H20,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
36,3,H8_3D,H30,1,Flip,Light,Pict,Video,Opt1,Opt2,Cal1,Cal2,Gimbal
4,0,Hisky,Std,0,Gear,Pitch,Gyro,CH8
9,0,KN,WLToys,0,DRate,THold,IdleUp,Gyro,Ttrim,Atrim,Etrim
9,1,KN,Feilun,0,DRate,THold,IdleUp,Gyro,Ttrim,Atrim,Etrim
26,0,Hontai,Std,1,Flip,LED,Pict,Video,HLess,RTH,Calib
26,1,Hontai,JJRCX1,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
26,2,Hontai,X5C1,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
26,3,Hontai,FQ777_951,1,Flip,Arm,Pict,Video,HLess,RTH,Calib
18,0,MJXQ,WHL08,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,1,MJXQ,X600,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,2,MJXQ,X800,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,3,MJXQ,H26D,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,4,MJXQ,E010,1,Flip,LED,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,5,MJXQ,H26WH,1,Flip,Arm,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
18,6,MJXQ,Phoenix,1,Flip,Arm,Pict,Video,HLess,RTH,AuFlip,Pan,Tilt,Rate
17,0,MT99XX,Std,1,Flip,LED,Pict,Video,HLess
17,1,MT99XX,H7,1,Flip,LED,Pict,Video,HLess
17,2,MT99XX,YZ,1,Flip,LED,Pict,Video,HLess
17,3,MT99XX,LS,1,Flip,Invert,Pict,Video,HLess
17,4,MT99XX,FY805,1,Flip,n-a,n-a,n-a,HLess
44,0,NCC1701,Std,1,Warp
51,0,Potensic,A20,1,TakLan,Emerg,Mode,HLess
66,0,Propel,74-Z,1,LEDs,RollCW,RolCCW,Fire,Weapon,Calib,AltHol,TakeOf,Land,Train
29,0,Q2x2,Q222,1,Flip,LED,Mod2,Mod1,HLess,RTH,XCal,YCal
29,1,Q2x2,Q242,1,Flip,LED,Pict,Video,HLess,RTH,XCal,YCal
29,2,Q2x2,Q282,1,Flip,LED,Pict,Video,HLess,RTH,XCal,YCal
31,0,Q303,Q303,1,AltHol,Flip,Pict,Video,HLess,RTH,Gimbal
31,1,Q303,C35,1,Arm,VTX,Pict,Video,n-a,RTH,Gimbal
31,2,Q303,CX10D,1,Arm,Flip
31,3,Q303,CX10WD,1,Arm,Flip
50,0,Redpine,Fast,0,sCH5,sCH6,sCH7,sCH8,sCH9,sCH10,sCH11,sCH12,sCH13,sCH14,sCH15,sCH16
50,1,Redpine,Slow,0,sCH5,sCH6,sCH7,sCH8,sCH9,sCH10,sCH11,sCH12,sCH13,sCH14,sCH15,sCH16
11,0,SLT,V1,0,Gear,Pitch
11,1,SLT,V2,0,CH5,CH6,CH7,CH8
11,2,SLT,Q100,0,Rates,n-a,CH7,CH8,Mode,Flip,n-a,n-a,Calib
11,3,SLT,Q200,0,Rates,n-a,CH7,CH8,Mode,VidOn,VidOff,Calib
11,4,SLT,MR100,0,Rates,n-a,CH7,CH8,Mode,Flip,Video,Pict
10,0,Symax,Std,1,Flip,Rates,Pict,Video,HLess
10,1,Symax,X5C,1,Flip,Rates,Pict,Video,HLess
5,0,V2x2,Std,1,Flip,Light,Pict,Video,HLess,CalX,CalY
5,1,V2x2,JXD506,1,Flip,Light,Pict,Video,HLess,StaSto,Emerg,Cam_UD
61,0,Tiger,Std,1,Flip,Light
46,0,V911s,Std,1,Calib
46,1,E119,Std,1,Calib
62,0,XK,X450,1,FMode,TakeOf,Emerg,3D_6G,Pict,Video
62,1,XK,X420,1,FMode,TakeOf,Emerg,3D_6G,Pict,Video
8,0,YD717,Std,1,Flip,Light,Pict,Video,HLess
8,1,YD717,SkyWlkr,1,Flip,Light,Pict,Video,HLess
8,2,YD717,Simax4,1,Flip,Light,Pict,Video,HLess
8,3,YD717,XinXun,1,Flip,Light,Pict,Video,HLess
8,4,YD717,NiHui,1,Flip,Light,Pict,Video,HLess
65,0,FrSkyR9,R9_915,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
65,1,FrSkyR9,R9_868,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14,CH15,CH16
65,2,FrSkyR9,R9_915_8CH,0,CH5,CH6,CH7,CH8
65,3,FrSkyR9,R9_968_8CH,0,CH5,CH6,CH7,CH8
56,0,Flysky2A_RX,RX,0,CH5,CH6,CH7,CH8,CH9,CH10,CH11,CH12,CH13,CH14
19,0,Shenqi,Cycle,1
4,1,Hisky,HK310,0,Aux
43,0,Traxxas,6519,0
52,0,ZSX,280,1,Light
48,0,V761,Std,1,Gyro
49,0,KF606,Std,1,Trim
47,0,GD00x,V1,1,Trim,LED,Rate
47,1,GD00x,V2,1,Trim,LED,Rate
58,0,FX816,P38,1
@@ -0,0 +1,302 @@
local toolName = "TNS|Multi chan namer|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. #
---- # #
---- #########################################################################
local protocol_name = ""
local sub_protocol_name = ""
local bind_ch = 0
local module_conf = {}
local module_pos = "Internal"
local file_ok = 0
local done = 0
local protocol = 0
local sub_protocol = 0
local f_seek = 0
local channel_names={}
local num_search = "Searching"
local function drawScreenTitle(title)
if LCD_W == 480 then
lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR)
lcd.drawText(1, 5, title, MENU_TITLE_COLOR)
else
lcd.drawScreenTitle(title, 0, 0)
end
end
function bitand(a, b)
local result = 0
local bitval = 1
while a > 0 and b > 0 do
if a % 2 == 1 and b % 2 == 1 then -- test the rightmost bits
result = result + bitval -- set the current bit
end
bitval = bitval * 2 -- shift left
a = math.floor(a/2) -- shift right
b = math.floor(b/2)
end
return result
end
local function Multi_Draw_LCD(event)
local line = 0
lcd.clear()
drawScreenTitle("Multi channels namer")
--Display settings
local lcd_opt = 0
if LCD_W == 480 then
x_pos = 10
y_pos = 32
y_inc = 20
else
x_pos = 0
y_pos = 9
y_inc = 8
lcd_opt = SMLSIZE
end
--Multi Module detection
if module_conf["Type"] ~= 6 then
if LCD_W == 480 then
lcd.drawText(10,50,"No Multi module configured...", BLINK)
else
--Draw on LCD_W=128
lcd.drawText(2,17,"No Multi module configured...",SMLSIZE)
end
return
else
lcd.drawText(x_pos, y_pos+y_inc*line,module_pos .. " Multi detected.", lcd_opt)
line = line + 1
end
--Channel order
if (ch_order == -1) then
lcd.drawText(x_pos, y_pos+y_inc*line,"Channels order can't be read from Multi...", lcd_opt)
line = line + 1
end
--Can't open file MultiChan.txt
if file_ok == 0 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Can't read MultiChan.txt file...", lcd_opt)
return
end
if ( protocol_name == "" or sub_protocol_name == "" ) and f_seek ~=-1 then
local f = io.open("/SCRIPTS/TOOLS/MultiChan.txt", "r")
if f == nil then return end
lcd.drawText(x_pos, y_pos+y_inc*line,num_search, lcd_opt)
num_search = num_search .. "."
if #num_search > 15 then
num_search = string.sub(num_search,1,9)
end
local proto = 0
local sub_proto = 0
local proto_name = ""
local sub_proto_name = ""
local channels = ""
local nbr_try = 0
local nbr_car = 0
repeat
io.seek(f, f_seek)
local data = io.read(f, 100) -- read 100 characters
if #data ==0 then
f_seek = -1 -- end of file
break
end
proto, sub_proto, proto_name, sub_proto_name, bind_ch, channels = string.match(data,'(%d+),(%d),([%w-_ ]+),([%w-_ ]+),(%d)(.+)')
if proto ~= nil and sub_proto ~= nil and protocol_name ~= nil and sub_protocol_name ~= nil and bind_ch ~= nil then
if tonumber(proto) == protocol and tonumber(sub_proto) == sub_protocol then
protocol_name = proto_name
sub_protocol_name = sub_proto_name
bind_ch = tonumber(bind_ch)
if channels ~= nil then
--extract channel names
nbr_car = string.find(channels, "\r")
if nbr_car == nil then nbr_car = string.find(channels, "\n") end
if nbr_car ~= nil then
channels = string.sub(channels,1,nbr_car-1)
end
local i = 5
for k in string.gmatch(channels, ",([%w-_ ]+)") do
channel_names[i] = k
i = i + 1
end
end
f_seek = -1 -- protocol found
break
end
end
if f_seek ~= -1 then
nbr_car = string.find(data, "\n")
if nbr_car == nil then nbr_car = string.find(data, "\r") end
if nbr_car == nil then
f_seek = -1 -- end of file
break
end
f_seek = f_seek + nbr_car -- seek to next line
nbr_try = nbr_try + 1
end
until nbr_try > 20 or f_seek == -1
io.close(f)
end
if f_seek ~= -1 then
return -- continue searching...
end
--Protocol & Sub_protocol
if protocol_name == "" or sub_protocol_name == "" then
lcd.drawText(x_pos, y_pos+y_inc*line,"Unknown protocol "..tostring(protocol).."/"..tostring(sub_protocol).." ...", lcd_opt)
return
elseif LCD_W > 128 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Protocol: " .. protocol_name .. " / SubProtocol: " .. sub_protocol_name, lcd_opt)
line = line + 1
else
lcd.drawText(x_pos, y_pos+y_inc*line,"Protocol: " .. protocol_name, lcd_opt)
line = line + 1
lcd.drawText(x_pos, y_pos+y_inc*line,"SubProtocol: " .. sub_protocol_name, lcd_opt)
line = line + 1
end
text1=""
text2=""
for i,v in ipairs(channel_names) do
if i<=8 then
if i==1 then
text1 = v
else
text1=text1 .. "," .. v
end
else
if i==9 then
text2 = v
else
text2=text2 .. "," .. v
end
end
end
if LCD_W > 128 then
lcd.drawText(x_pos, y_pos+y_inc*line,"Channels: " .. text1, lcd_opt)
line = line + 1
if text2 ~= "" then
lcd.drawText(x_pos*9, y_pos+y_inc*line,text2, lcd_opt)
line = line + 1
end
end
if event ~= EVT_VIRTUAL_ENTER and done == 0 then
lcd.drawText(x_pos, y_pos+y_inc*line,"<ENT> Save", lcd_opt + INVERS + BLINK)
return
end
lcd.drawText(x_pos, y_pos+y_inc*line,"Setting channel names.", lcd_opt)
line = line + 1
local output, nbr
if done == 0 then
for i,v in ipairs(channel_names) do
output = model.getOutput(i-1)
output["name"] = v
model.setOutput(i-1,output)
nbr = i
end
for i = nbr, 15 do
output = model.getOutput(i)
output["name"] = "n-a"
model.setOutput(i,output)
end
if bind_ch == 1 then
output = model.getOutput(15)
output["name"] = "BindCH"
model.setOutput(15,output)
end
done = 1
end
lcd.drawText(x_pos, y_pos+y_inc*line,"Done!", lcd_opt)
line = line + 1
end
-- Init
local function Multi_Init()
module_conf = model.getModule(0)
if module_conf["Type"] ~= 6 then
module_pos = "External"
module_conf = model.getModule(1)
if module_conf["Type"] ~= 6 then
return
end
end
protocol = module_conf["protocol"]
sub_protocol = module_conf["subProtocol"]
--Exceptions on first 4 channels...
local stick_names = { "Rud", "Ele", "Thr", "Ail" }
if ( protocol == 4 and sub_protocol ==1 ) or protocol == 19 or protocol == 52 then -- Hisky/HK310, Shenqi, ZSX
stick_names[2] = "n-a"
stick_names[4] = "n-a"
elseif protocol == 43 then -- Traxxas
stick_names[2] = "Aux4"
stick_names[4] = "Aux3"
elseif protocol == 48 then -- V761
stick_names[4] = "n-a"
elseif protocol == 47 or protocol == 49 or protocol == 58 then -- GD00x, KF606, FX816
stick_names[1] = "n-a"
stick_names[2] = "n-a"
end
--Determine fist 4 channels order
local ch_order=module_conf["channelsOrder"]
if (ch_order == -1) then
channel_names[1] = stick_names[defaultChannel(0)+1]
channel_names[2] = stick_names[defaultChannel(1)+1]
channel_names[3] = stick_names[defaultChannel(2)+1]
channel_names[4] = stick_names[defaultChannel(3)+1]
else
channel_names[bitand(ch_order,3)+1] = stick_names[4]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[2]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[3]
ch_order = math.floor(ch_order/4)
channel_names[bitand(ch_order,3)+1] = stick_names[1]
end
--Check MultiChan.txt
local f = io.open("/SCRIPTS/TOOLS/MultiChan.txt", "r")
if f == nil then return end
file_ok = 1
io.close(f)
end
-- Main
local function Multi_Run(event)
if event == nil then
error("Cannot be run as a model script!")
return 2
else
Multi_Draw_LCD(event)
if event == EVT_VIRTUAL_EXIT then
return 2
end
end
return 0
end
return { init=Multi_Init, run=Multi_Run }
+6 -4
View File
@@ -381,9 +381,12 @@ endif()
add_definitions(-DPOPUP_LEVEL=${POPUP_LEVEL})
if(BOOTLOADER)
add_definitions(-DBOOTLOADER)
endif(BOOTLOADER)
if(INTERNAL_MODULE_MULTI)
set(DEFAULT_TEMPLATE_SETUP 21 CACHE STRING "")
else()
set(DEFAULT_TEMPLATE_SETUP 0 CACHE STRING "")
endif()
add_definitions(-DDEFAULT_TEMPLATE_SETUP=${DEFAULT_TEMPLATE_SETUP})
set(SRC
${SRC}
@@ -444,7 +447,6 @@ endif()
set(SRC ${SRC} ${FIRMWARE_SRC})
##### firmware target #####
option(FIRMWARE_TARGET "Configure Firmware target (can be turned of for compiling Companion only)" ON)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 601 B

After

Width:  |  Height:  |  Size: 310 B

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 553 B

+2 -2
View File
@@ -315,7 +315,7 @@ void Bluetooth::wakeup(void)
uint8_t len = ZLEN(g_eeGeneral.bluetoothName);
if (len > 0) {
for (int i = 0; i < len; i++) {
*cur++ = char2lower(zchar2char(g_eeGeneral.bluetoothName[i]));
*cur++ = char2lower(g_eeGeneral.bluetoothName[i]);
}
*cur = '\0';
}
@@ -418,7 +418,7 @@ void Bluetooth::wakeup()
uint8_t len = ZLEN(g_eeGeneral.bluetoothName);
if (len > 0) {
for (int i = 0; i < len; i++) {
*cur++ = char2lower(zchar2char(g_eeGeneral.bluetoothName[i]));
*cur++ = char2lower(g_eeGeneral.bluetoothName[i]);
}
*cur = '\0';
}
-2
View File
@@ -22,8 +22,6 @@
#define _BUZZER_H_
#if defined(BUZZER)
extern uint8_t g_beepCnt;
extern uint8_t beepAgain;
extern uint8_t beepAgainOrig;
extern uint8_t beepOn;
extern bool warble;
+10 -9
View File
@@ -20,7 +20,6 @@
#include "opentx.h"
uint8_t s_curveChan;
int8_t * curveEnd[MAX_CURVES];
void loadCurves()
@@ -120,7 +119,7 @@ bool isCurveUsed(uint8_t index)
}
#define CUSTOM_POINT_X(points, count, idx) ((idx)==0 ? -100 : (((idx)==(count)-1) ? 100 : points[(count)+(idx)-1]))
int32_t compute_tangent(CurveHeader * crv, int8_t * points, int i)
int32_t compute_tangent(CurveHeader * crv, const int8_t * points, int i)
{
int32_t m=0;
uint8_t num_points = crv->points + 5;
@@ -240,7 +239,7 @@ int intpol(int x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100
int8_t * points = curveAddress(idx);
uint8_t count = crv.points+5;
bool custom = (crv.type == CURVE_TYPE_CUSTOM);
int16_t erg = 0;
int16_t erg;
x += RESXu;
@@ -339,11 +338,6 @@ int applyCustomCurve(int x, uint8_t idx)
return intpol(x, idx);
}
point_t getPoint(uint8_t index)
{
return getPoint(s_curveChan, index);
}
point_t getPoint(uint8_t curveIndex, uint8_t index)
{
point_t result = {0, 0};
@@ -363,7 +357,14 @@ point_t getPoint(uint8_t curveIndex, uint8_t index)
return result;
}
#if !defined(COLORLCD)
point_t getPoint(uint8_t index)
{
return getPoint(s_currIdxSubMenu, index);
}
int applyCurrentCurve(int x)
{
return applyCustomCurve(x, s_curveChan);
return applyCustomCurve(x, s_currIdxSubMenu);
}
#endif
+10
View File
@@ -208,6 +208,16 @@ enum TrainerMode {
};
#endif
#if defined(RADIO_FAMILY_T16) || (defined(RADIO_T12) && defined(INTERNAL_MODULE_MULTI)) || defined(ALLOW_TRAINER_MULTI)
#define TRAINER_MODE_MAX() TRAINER_MODE_MULTI
#elif defined(BLUETOOTH)
#define TRAINER_MODE_MAX() TRAINER_MODE_SLAVE_BLUETOOTH
#elif defined(PCBX7) || defined(PCBXLITE)
#define TRAINER_MODE_MAX() TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE
#else
#define TRAINER_MODE_MAX() HAS_WIRELESS_TRAINER_HARDWARE() ? TRAINER_MODE_MASTER_BATTERY_COMPARTMENT : TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE
#endif
#if defined(HARDWARE_INTERNAL_MODULE)
#define IS_INTERNAL_MODULE_ENABLED() (g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_NONE)
#else
+5 -5
View File
@@ -26,6 +26,7 @@
#include "dataconstants.h"
#include "definitions.h"
#include "opentx_types.h"
#include "globals.h"
#if defined(PCBTARANIS)
#define N_TARANIS_FIELD(x)
@@ -331,10 +332,10 @@ PACK(struct TelemetrySensor {
NOBACKUP(uint16_t persistentValue);
} NAME(id1) FUNC(select_id1);
union {
PACK(struct {
NOBACKUP(PACK(struct {
uint8_t physID:5;
uint8_t rxIndex:3; // 1 bit for module index, 2 bits for receiver index
}) frskyInstance;
}) frskyInstance);
uint8_t instance;
NOBACKUP(uint8_t formula);
} NAME(id2) FUNC(select_id2);
@@ -513,8 +514,6 @@ PACK(struct ModuleData {
* Model structure
*/
typedef uint16_t BeepANACenter;
#if LEN_BITMAP_NAME > 0
#define MODEL_HEADER_BITMAP_FIELD NOBACKUP(char bitmap[LEN_BITMAP_NAME]);
#else
@@ -697,7 +696,8 @@ PACK(struct TrainerData {
#if defined(PCBHORUS) || defined(PCBNV14)
#define EXTRA_GENERAL_FIELDS \
NOBACKUP(uint8_t auxSerialMode); \
NOBACKUP(uint8_t auxSerialMode:4); \
NOBACKUP(uint8_t aux2SerialMode:4); \
swconfig_t switchConfig ARRAY(2,struct_switchConfig,nullptr); \
uint16_t potsConfig ARRAY(2,struct_potConfig,nullptr); /* two bits per pot */ \
uint8_t slidersConfig ARRAY(1,struct_sliderConfig,nullptr); /* 1 bit per slider */ \
+1
View File
@@ -37,6 +37,7 @@
extern volatile uint32_t g_tmr10ms;
uint8_t auxSerialTracesEnabled();
uint8_t aux2SerialTracesEnabled();
#if defined(SIMU)
typedef void (*traceCallbackFunc)(const char * text);
+2 -2
View File
@@ -19,10 +19,10 @@ add_truetype_font_target(9 9 ${subset} none)
add_truetype_font_target(13 13 ${subset} none)
add_truetype_font_target(15 15 ${subset} none)
add_truetype_font_target(16 16 ${subset} none)
add_truetype_font_target(16en 16 en none)
add_truetype_font_target(16en 16 en none)
add_truetype_font_target(bold16 16 ${subset} bold)
add_truetype_font_target(17 17 ${subset} none)
add_truetype_font_target(17en 17 en none)
add_truetype_font_target(17en 17 en none)
add_truetype_font_target(bold17 17 ${subset} bold)
add_truetype_font_target(24 24 ${subset} none)
add_truetype_font_target(32 32 ${subset} bold)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 B

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 B

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 355 B

+97
View File
@@ -0,0 +1,97 @@
/*
* 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 _GLOBALS_H_
#define _GLOBALS_H_
#include "definitions.h"
#include "dataconstants.h"
PACK(struct GlobalData {
uint8_t unexpectedShutdown:1;
uint8_t externalAntennaEnabled:1;
uint8_t authenticationCount:2;
uint8_t upgradeModulePopup:1;
uint8_t internalModuleVersionChecked:1;
uint8_t spare:2;
});
extern GlobalData globalData;
extern uint16_t sessionTimer;
extern uint16_t s_timeCumThr;
extern uint16_t s_timeCum16ThrP;
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define OVERRIDE_CHANNEL_UNDEFINED -4096
extern safetych_t safetyCh[MAX_OUTPUT_CHANNELS];
#endif
extern uint8_t trimsCheckTimer;
extern uint8_t trimsDisplayTimer;
extern uint8_t trimsDisplayMask;
extern uint16_t maxMixerDuration;
extern uint8_t requiredSpeakerVolume;
enum MainRequest {
REQUEST_SCREENSHOT,
REQUEST_FLIGHT_RESET,
};
extern uint8_t mainRequestFlags;
#define DELAY_POS_MARGIN 3
typedef int16_t delayval_t;
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;
});
extern SwOn swOn[MAX_MIXERS];
extern int32_t act[MAX_MIXERS];
// static variables used in evalFlightModeMixes - moved here so they don't interfere with the stack
// It's also easier to initialize them here.
extern int8_t virtualInputsTrims[MAX_INPUTS];
extern int16_t anas [MAX_INPUTS];
extern int16_t trims[NUM_TRIMS];
extern int32_t chans[MAX_OUTPUT_CHANNELS];
extern int16_t ex_chans[MAX_OUTPUT_CHANNELS]; // Outputs (before LIMITS) of the last perMain
extern int16_t channelOutputs[MAX_OUTPUT_CHANNELS];
typedef uint16_t BeepANACenter;
extern BeepANACenter bpanaCenter;
extern uint8_t s_mixer_first_run_done;
extern int16_t calibratedAnalogs[NUM_CALIBRATED_ANALOGS];
extern uint8_t g_beepCnt;
extern uint8_t beepAgain;
extern uint16_t lightOffCounter;
extern uint8_t flashCounter;
extern uint8_t mixWarning;
#endif
+2 -1
View File
@@ -40,6 +40,7 @@
#define drawFieldLabel(x, y, str) lcdDrawTextAlignedLeft(y, str)
#define NUM_BODY_LINES (LCD_LINES-1)
#define TEXT_VIEWER_LINES NUM_BODY_LINES
#define MENU_HEADER_HEIGHT FH
#define CURVE_SIDE_WIDTH (LCD_H/2)
@@ -213,7 +214,7 @@ extern uint8_t s_copyMode;
extern int8_t s_copySrcRow;
extern int8_t s_copyTgtOfs;
extern uint8_t s_currIdx;
extern uint8_t s_curveChan;
extern uint8_t s_currIdxSubMenu;
extern uint8_t s_copySrcIdx;
extern uint8_t s_copySrcCh;
extern int8_t s_currCh;
+17 -4
View File
@@ -18,6 +18,7 @@
* GNU General Public License for more details.
*/
#include <limits.h>
#include "opentx.h"
#include "gui/common/stdlcd/fonts.h"
@@ -213,7 +214,7 @@ uint8_t getCharWidth(char c, LcdFlags flags)
}
#endif
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
void lcdDrawChar(coord_t x, coord_t y, char c, LcdFlags flags)
{
const unsigned char * q;
@@ -281,7 +282,7 @@ void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
}
}
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c)
void lcdDrawChar(coord_t x, coord_t y, char c)
{
lcdDrawChar(x, y, c, 0);
}
@@ -441,12 +442,12 @@ void lcdDraw8bitsNumber(coord_t x, coord_t y, int8_t val)
lcdDrawNumber(x, y, val);
}
void lcdDrawNumber(coord_t x, coord_t y, int val, LcdFlags flags)
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags)
{
lcdDrawNumber(x, y, val, flags, 0);
}
void lcdDrawNumber(coord_t x, coord_t y, int val, LcdFlags flags, uint8_t len)
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t len)
{
char str[16+1];
char *s = str+16;
@@ -454,7 +455,19 @@ void lcdDrawNumber(coord_t x, coord_t y, int val, LcdFlags flags, uint8_t len)
int idx = 0;
int mode = MODE(flags);
bool neg = false;
if (val == INT_MAX) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MAX", flags);
return;
}
if (val < 0) {
if (val == INT_MIN) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MIN", flags);
return;
}
val = -val;
neg = true;
}
+4 -4
View File
@@ -98,8 +98,8 @@ extern coord_t lcdNextPos;
extern volatile uint32_t lcdInputs ;
#endif
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c);
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags);
void lcdDrawChar(coord_t x, coord_t y, char c);
void lcdDrawChar(coord_t x, coord_t y, char c, LcdFlags flags);
void lcdDrawCenteredText(coord_t y, const char * s, LcdFlags flags = 0);
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags flags);
void lcdDrawTextAtIndex(coord_t x, coord_t y, const char * s, uint8_t idx, LcdFlags flags);
@@ -112,8 +112,8 @@ void drawTimerWithMode(coord_t x, coord_t y, uint8_t index, LcdFlags att);
void lcdDrawHexNumber(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0);
void lcdDrawHexChar(coord_t x, coord_t y, uint8_t val, LcdFlags flags=0);
void lcdDrawNumber(coord_t x, coord_t y, int val, LcdFlags mode, uint8_t len);
void lcdDrawNumber(coord_t x, coord_t y, int val, LcdFlags mode=0);
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode, uint8_t len);
void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode=0);
void lcdDraw8bitsNumber(coord_t x, coord_t y, int8_t val);
void drawModelName(coord_t x, coord_t y, char * name, uint8_t id, LcdFlags att);
+1
View File
@@ -45,3 +45,4 @@ void editSingleName(coord_t x, coord_t y, const char * label, char * name, uint8
}
uint8_t s_currIdx;
uint8_t s_currIdxSubMenu;
+13 -13
View File
@@ -50,8 +50,8 @@ void runPopupCurvePreset(event_t event)
if (warningResult) {
warningResult = 0;
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
int k = 25 * reusableBuffer.curveEdit.preset;
int dx = 2000 / (5+crv.points-1);
for (uint8_t i=0; i<5+crv.points; i++) {
@@ -71,14 +71,14 @@ void onCurveOneMenu(const char * result)
POPUP_INPUT(STR_PRESET, runPopupCurvePreset);
}
else if (result == STR_MIRROR) {
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
for (int i=0; i<5+crv.points; i++)
points[i] = -points[i];
}
else if (result == STR_CLEAR) {
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
for (int i=0; i<5+crv.points; i++)
points[i] = 0;
if (crv.type == CURVE_TYPE_CUSTOM) {
@@ -89,10 +89,10 @@ void onCurveOneMenu(const char * result)
void menuModelCurveOne(event_t event)
{
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
drawStringWithIndex(PSIZE(TR_MENUCURVES)*FW+FW, 0, STR_CV, s_curveChan+1);
drawStringWithIndex(PSIZE(TR_MENUCURVES)*FW+FW, 0, STR_CV, s_currIdxSubMenu+1);
SIMPLE_SUBMENU(STR_MENUCURVES, 4 + 5+crv.points + (crv.type==CURVE_TYPE_CUSTOM ? 5+crv.points-2 : 0));
@@ -108,9 +108,9 @@ void menuModelCurveOne(event_t event)
uint8_t newType = checkIncDecModelZero(event, crv.type, CURVE_TYPE_LAST);
if (newType != crv.type) {
for (int i = 1; i < 4 + crv.points; i++) {
points[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + crv.points, i)), s_curveChan));
points[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + crv.points, i)), s_currIdxSubMenu));
}
if (moveCurve(s_curveChan, checkIncDec_Ret > 0 ? 3 + crv.points : -3 - crv.points)) {
if (moveCurve(s_currIdxSubMenu, checkIncDec_Ret > 0 ? 3 + crv.points : -3 - crv.points)) {
if (newType == CURVE_TYPE_CUSTOM) {
resetCustomCurveX(points, 5 + crv.points);
}
@@ -131,8 +131,8 @@ void menuModelCurveOne(event_t event)
newPoints[0] = points[0];
newPoints[4 + count] = points[4 + crv.points];
for (int i = 1; i < 4 + count; i++)
newPoints[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + count, i)), s_curveChan));
if (moveCurve(s_curveChan, checkIncDec_Ret * (crv.type == CURVE_TYPE_CUSTOM ? 2 : 1))) {
newPoints[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + count, i)), s_currIdxSubMenu));
if (moveCurve(s_currIdxSubMenu, checkIncDec_Ret * (crv.type == CURVE_TYPE_CUSTOM ? 2 : 1))) {
for (int i = 0; i < 5 + count; i++) {
points[i] = newPoints[i];
if (crv.type == CURVE_TYPE_CUSTOM && i != 0 && i != 4 + count)
+3 -2
View File
@@ -87,7 +87,8 @@ void menuModelFlightModeOne(event_t event)
int8_t editMode = s_editMode;
#if defined(GVARS)
if (s_currIdx == 0 && sub>=ITEM_MODEL_FLIGHT_MODE_SWITCH) sub += VERTICAL_SHIFT;
if (s_currIdx == 0 && sub>=ITEM_MODEL_FLIGHT_MODE_SWITCH)
sub += VERTICAL_SHIFT;
for (uint8_t k=0; k<LCD_LINES-1; k++) {
coord_t y = MENU_HEADER_HEIGHT + 1 + k*FH;
@@ -147,7 +148,7 @@ void menuModelFlightModeOne(event_t event)
drawStringWithIndex(INDENT_WIDTH, y, STR_GV, idx+1, posHorz==0 ? attr : 0);
lcdDrawSizedText(4*FW, y,g_model.gvars[idx].name, LEN_GVAR_NAME, ZCHAR);
if (attr && editMode>0 && posHorz==0) {
s_currIdx = sub - ITEM_MODEL_FLIGHT_MODE_GV1;
s_currIdxSubMenu = sub - ITEM_MODEL_FLIGHT_MODE_GV1;
editMode = 0;
pushMenu(menuModelGVarOne);
}
+6 -6
View File
@@ -64,10 +64,10 @@ enum GVarFields {
void menuModelGVarOne(event_t event)
{
GVarData * gvar = &g_model.gvars[s_currIdx];
GVarData * gvar = &g_model.gvars[s_currIdxSubMenu];
drawStringWithIndex(PSIZE(TR_GVARS)*FW+FW, 0, STR_GV, s_currIdx+1, 0);
drawGVarValue(32*FW, 0, s_currIdx, getGVarValue(s_currIdx, getFlightMode()));
drawStringWithIndex(PSIZE(TR_GVARS)*FW+FW, 0, STR_GV, s_currIdxSubMenu+1, 0);
drawGVarValue(32*FW, 0, s_currIdxSubMenu, getGVarValue(s_currIdxSubMenu, getFlightMode()));
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID);
SIMPLE_SUBMENU(STR_GVARS, GVAR_FIELD_LAST);
@@ -92,13 +92,13 @@ void menuModelGVarOne(event_t event)
case GVAR_FIELD_MIN:
lcdDrawText(0, y, STR_MIN);
drawGVarValue(GVAR_2ND_COLUMN, y, s_currIdx, GVAR_MIN+gvar->min, LEFT|attr);
drawGVarValue(GVAR_2ND_COLUMN, y, s_currIdxSubMenu, GVAR_MIN+gvar->min, LEFT|attr);
if (attr) gvar->min = checkIncDec(event, GVAR_MIN+gvar->min, GVAR_MIN, GVAR_MAX-gvar->max, EE_MODEL) - GVAR_MIN;
break;
case GVAR_FIELD_MAX:
lcdDrawText(0, y, STR_MAX);
drawGVarValue(GVAR_2ND_COLUMN, y, s_currIdx, GVAR_MAX-gvar->max, LEFT|attr);
drawGVarValue(GVAR_2ND_COLUMN, y, s_currIdxSubMenu, GVAR_MAX-gvar->max, LEFT|attr);
if (attr) gvar->max = GVAR_MAX - checkIncDec(event, GVAR_MAX-gvar->max, GVAR_MIN+gvar->min, GVAR_MAX, EE_MODEL);
break;
@@ -108,7 +108,7 @@ void menuModelGVarOne(event_t event)
default:
drawStringWithIndex(0, y, STR_FM, k-GVAR_FIELD_FM0);
editGVarValue(GVAR_2ND_COLUMN, y, event, s_currIdx, k-GVAR_FIELD_FM0, LEFT|attr);
editGVarValue(GVAR_2ND_COLUMN, y, event, s_currIdxSubMenu, k-GVAR_FIELD_FM0, LEFT|attr);
break;
}
}
+2 -2
View File
@@ -271,7 +271,7 @@ void menuModelExpoOne(event_t event)
CHECK_INCDEC_MODELVAR_ZERO(event, ed->curveParam, CURVE_BASE+MAX_CURVES-1);
if (ed->curveParam) ed->curveMode = MODE_CURVE;
if (ed->curveParam>=CURVE_BASE && event==EVT_KEY_LONG(KEY_ENTER)) {
s_curveChan = ed->curveParam - CURVE_BASE;
s_currIdxSubMenu = ed->curveParam - CURVE_BASE;
pushMenu(menuModelCurveOne);
}
}
@@ -442,7 +442,7 @@ void menuModelMixOne(event_t event)
drawCurveName(COLUMN_X+MIXES_2ND_COLUMN, y, curveParam, attr);
if (attr) {
if (event==EVT_KEY_LONG(KEY_ENTER) && (curveParam<0 || curveParam>=CURVE_BASE)){
s_curveChan = (curveParam<0 ? -curveParam-1 : curveParam-CURVE_BASE);
s_currIdxSubMenu = (curveParam<0 ? -curveParam-1 : curveParam-CURVE_BASE);
pushMenu(menuModelCurveOne);
}
else {
+1 -1
View File
@@ -150,7 +150,7 @@ void menuModelMixOne(event_t event)
case MIX_FIELD_CURVE:
lcdDrawTextAlignedLeft(y, STR_CURVE);
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr);
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, s_editMode > 0 ? event : 0, attr);
break;
#if defined(FLIGHT_MODES)
+56 -30
View File
@@ -88,6 +88,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_INTERNAL_MODULE_LABEL,
ITEM_MODEL_SETUP_INTERNAL_MODULE_TYPE,
#if defined(MULTIMODULE)
ITEM_MODEL_SETUP_INTERNAL_MODULE_PROTOCOL,
ITEM_MODEL_SETUP_INTERNAL_MODULE_SUBTYPE,
ITEM_MODEL_SETUP_INTERNAL_MODULE_STATUS,
ITEM_MODEL_SETUP_INTERNAL_MODULE_SYNCSTATUS,
@@ -116,6 +117,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_EXTERNAL_MODULE_LABEL,
ITEM_MODEL_SETUP_EXTERNAL_MODULE_TYPE,
#if defined(MULTIMODULE)
ITEM_MODEL_SETUP_EXTERNAL_MODULE_PROTOCOL,
ITEM_MODEL_SETUP_EXTERNAL_MODULE_SUBTYPE,
#endif
#if defined(MULTIMODULE)
@@ -211,7 +213,7 @@ inline uint8_t MODULE_TYPE_ROWS(int moduleIdx)
return 1;
#if defined(MULTIMODULE)
else if (isModuleMultimodule(moduleIdx)) {
return 1;
return 0;
}
#endif
else
@@ -309,19 +311,20 @@ void onBluetoothConnectMenu(const char * result)
#if defined(HARDWARE_INTERNAL_MODULE)
#define INTERNAL_MODULE_ROWS \
LABEL(InternalModule), \
MODULE_TYPE_ROWS(INTERNAL_MODULE), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_TYPE*/ \
MULTIMODULE_SUBTYPE_ROWS(INTERNAL_MODULE) /* ITEM_MODEL_SETUP_INTERNAL_MODULE_SUBTYPE*/ \
MODULE_TYPE_ROWS(INTERNAL_MODULE), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_TYPE */ \
MULTIMODULE_TYPE_ROWS(INTERNAL_MODULE) /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PROTOCOL */ \
MULTIMODULE_SUBTYPE_ROWS(INTERNAL_MODULE) /* ITEM_MODEL_SETUP_INTERNAL_MODULE_SUBTYPE */ \
MULTIMODULE_STATUS_ROWS(INTERNAL_MODULE) /* ITEM_MODEL_SETUP_INTERNAL_MODULE_STATUS, ITEM_MODEL_SETUP_INTERNAL_MODULE_SYNCSTATUS */ \
MODULE_CHANNELS_ROWS(INTERNAL_MODULE), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_CHANNELS*/ \
IF_NOT_ACCESS_MODULE_RF(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(IF_INTERNAL_MODULE_ON(isModuleRxNumAvailable(INTERNAL_MODULE) ? (uint8_t)2 : (uint8_t)1))), /* *ITEM_MODEL_SETUP_INTERNAL_MODULE_NOT_ACCESS_RXNUM_BIND_RANGE */\
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_MODEL_NUM*/ \
MODULE_CHANNELS_ROWS(INTERNAL_MODULE), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_CHANNELS */ \
IF_NOT_ACCESS_MODULE_RF(INTERNAL_MODULE, IF_INTERNAL_MODULE_ON(IF_INTERNAL_MODULE_ON(MODULE_BIND_ROWS(INTERNAL_MODULE)))), /* *ITEM_MODEL_SETUP_INTERNAL_MODULE_NOT_ACCESS_RXNUM_BIND_RANGE */\
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_MODEL_NUM */ \
MODULE_OPTION_ROW(INTERNAL_MODULE), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_OPTIONS */ \
MULTIMODULE_MODULE_ROWS(INTERNAL_MODULE) /* ITEM_MODEL_SETUP_INTERNAL_MODULE_AUTOBIND */ \
EXTERNAL_ANTENNA_ROW /* ITEM_MODEL_SETUP_INTERNAL_MODULE_ANTENNA */ \
MODULE_POWER_ROW(INTERNAL_MODULE), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_POWER */ \
IF_INTERNAL_MODULE_ON(FAILSAFE_ROWS(INTERNAL_MODULE)), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_FAILSAFE */ \
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 1), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_REGISTER_RANGE */ \
IF_PXX2_MODULE(INTERNAL_MODULE, 0), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_OPTIONS*/ \
IF_PXX2_MODULE(INTERNAL_MODULE, 0), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_OPTIONS */ \
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_RECEIVER_1 */ \
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_RECEIVER_2 */ \
IF_ACCESS_MODULE_RF(INTERNAL_MODULE, 0), /* ITEM_MODEL_SETUP_INTERNAL_MODULE_PXX2_RECEIVER_3 */
@@ -365,7 +368,8 @@ void menuModelSetup(event_t event)
LABEL(ExternalModule),
MODULE_TYPE_ROWS(EXTERNAL_MODULE),
MULTIMODULE_SUBTYPE_ROWS(EXTERNAL_MODULE)
MULTIMODULE_TYPE_ROWS(EXTERNAL_MODULE) // PROTOCOL
MULTIMODULE_SUBTYPE_ROWS(EXTERNAL_MODULE) // SUBTYPE
MULTIMODULE_STATUS_ROWS(EXTERNAL_MODULE)
MODULE_CHANNELS_ROWS(EXTERNAL_MODULE),
IF_NOT_ACCESS_MODULE_RF(EXTERNAL_MODULE, MODULE_BIND_ROWS(EXTERNAL_MODULE)), // line reused for PPM: PPM settings
@@ -373,8 +377,8 @@ void menuModelSetup(event_t event)
MODULE_POWER_ROW(EXTERNAL_MODULE),
IF_NOT_PXX2_MODULE(EXTERNAL_MODULE, MODULE_OPTION_ROW(EXTERNAL_MODULE)),
MULTIMODULE_MODULE_ROWS(EXTERNAL_MODULE)
FAILSAFE_ROWS(EXTERNAL_MODULE),
IF_ACCESS_MODULE_RF(EXTERNAL_MODULE, 1), // Range check and Register buttons
FAILSAFE_ROWS(EXTERNAL_MODULE), //ITEM_MODEL_SETUP_EXTERNAL_MODULE_FAILSAFE
IF_ACCESS_MODULE_RF(EXTERNAL_MODULE, 1), // Range check and Register buttons
IF_PXX2_MODULE(EXTERNAL_MODULE, 0), // Module options
IF_ACCESS_MODULE_RF(EXTERNAL_MODULE, 0), // Receiver 1
IF_ACCESS_MODULE_RF(EXTERNAL_MODULE, 0), // Receiver 2
@@ -908,12 +912,6 @@ void menuModelSetup(event_t event)
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_DSM_PROTOCOLS, g_model.moduleData[moduleIdx].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleR9MNonAccess(moduleIdx))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_R9M_REGION, g_model.moduleData[moduleIdx].subType, (menuHorizontalPosition==1 ? attr : 0));
#if defined(MULTIMODULE)
else if (isModuleMultimodule(moduleIdx)) {
int multi_rfProto = g_model.moduleData[moduleIdx].getMultiProtocol();
lcdDrawMultiProtocolString(lcdNextPos + 3, y, moduleIdx, multi_rfProto, menuHorizontalPosition == 1 ? attr : 0);
}
#endif
if (attr && menuHorizontalPosition == 0 && moduleIdx == EXTERNAL_MODULE) {
if (s_editMode > 0) {
g_model.moduleData[moduleIdx].type = MODULE_TYPE_NONE;
@@ -962,18 +960,6 @@ void menuModelSetup(event_t event)
g_model.moduleData[moduleIdx].channelsCount = defaultModuleChannels_M8(moduleIdx);
}
}
#if defined(MULTIMODULE)
else if (isModuleMultimodule(moduleIdx)) {
int multiRfProto = g_model.moduleData[moduleIdx].getMultiProtocol();
CHECK_INCDEC_MODELVAR_CHECK(event, multiRfProto, MODULE_SUBTYPE_MULTI_FIRST, MULTI_MAX_PROTOCOLS, isMultiProtocolSelectable);
if (checkIncDec_Ret) {
g_model.moduleData[moduleIdx].setMultiProtocol(multiRfProto);
g_model.moduleData[moduleIdx].subType = 0;
resetMultiProtocolsOptions(moduleIdx);
}
}
#endif
else {
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[moduleIdx].subType, 0, MODULE_SUBTYPE_PXX1_LAST);
}
@@ -1008,6 +994,45 @@ void menuModelSetup(event_t event)
break;
#if defined(MULTIMODULE)
#if defined(HARDWARE_INTERNAL_MODULE)
case ITEM_MODEL_SETUP_INTERNAL_MODULE_PROTOCOL:
#endif
case ITEM_MODEL_SETUP_EXTERNAL_MODULE_PROTOCOL:
{
lcdDrawTextAlignedLeft(y, TR_TYPE);
int multi_rfProto = g_model.moduleData[moduleIdx].getMultiProtocol();
lcdDrawMultiProtocolString(MODEL_SETUP_2ND_COLUMN, y, moduleIdx, multi_rfProto, attr);
if (attr) {
int multiRfProto = g_model.moduleData[moduleIdx].getMultiProtocol();
MultiModuleStatus &status = getMultiModuleStatus(moduleIdx);
if (status.isValid()) {
int8_t direction = checkIncDec(event, 0, -1, 1);
if (direction == -1) {
if (multiRfProto == MODULE_SUBTYPE_MULTI_FRSKY)
multiRfProto = MODULE_SUBTYPE_MULTI_FRSKYX_RX;
else
multiRfProto = convertMultiToOtx(status.protocolPrev);
}
if (direction == 1) {
if (multiRfProto == MODULE_SUBTYPE_MULTI_FRSKY)
multiRfProto = MODULE_SUBTYPE_MULTI_FRSKYX2;
else
multiRfProto = convertMultiToOtx(status.protocolNext);
}
}
else {
CHECK_INCDEC_MODELVAR_CHECK(event, multiRfProto, MODULE_SUBTYPE_MULTI_FIRST, MULTI_MAX_PROTOCOLS, isMultiProtocolSelectable);
}
if (checkIncDec_Ret) {
g_model.moduleData[moduleIdx].setMultiProtocol(multiRfProto);
g_model.moduleData[moduleIdx].subType = 0;
resetMultiProtocolsOptions(moduleIdx);
storageDirty(EE_MODEL);
}
}
}
break;
#if defined(HARDWARE_INTERNAL_MODULE)
case ITEM_MODEL_SETUP_INTERNAL_MODULE_SUBTYPE:
#endif
@@ -1324,7 +1349,8 @@ void menuModelSetup(event_t event)
}
}
lcdDrawText(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0);
lcdDrawText(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0);
if (!IS_RX_MULTI(moduleIdx))
lcdDrawText(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0);
uint8_t newFlag = 0;
#if defined(MULTIMODULE)
if (getMultiBindStatus(moduleIdx) == MULTI_BIND_FINISHED) {
@@ -1584,7 +1610,7 @@ void menuModelSetup(event_t event)
}
#if defined(MULTIMODULE)
else if (isModuleMultimodule(moduleIdx)) {
module.multi.lowPowerMode = editCheckBox(module.multi.lowPowerMode, MODEL_SETUP_2ND_COLUMN, y, STR_MULTI_LOWPOWER, attr, event);
module.multi.lowPowerMode = editCheckBox(module.multi.lowPowerMode, MODEL_SETUP_2ND_COLUMN, y, IS_RX_MULTI(moduleIdx) ? STR_MULTI_LNA_DISABLE : STR_MULTI_LOWPOWER, attr, event);
}
#endif
-4
View File
@@ -128,10 +128,6 @@ void menuChannelsView(event_t event)
case EVT_KEY_PREVIOUS_PAGE:
g_eeGeneral.view = (g_eeGeneral.view + (4 * ALTERNATE_VIEW) - ALTERNATE_VIEW) % (4 * ALTERNATE_VIEW);
break;
case EVT_KEY_FIRST(KEY_ENTER):
reusableBuffer.viewChannels.mixersView = !reusableBuffer.viewChannels.mixersView;
break;
}
menuChannelsViewCommon(event);
+2 -1
View File
@@ -32,6 +32,7 @@
#define DEFAULT_SCROLLBAR_X (LCD_W-1)
#define NUM_BODY_LINES (LCD_LINES-1)
#define TEXT_VIEWER_LINES NUM_BODY_LINES
#define MENU_HEADER_HEIGHT FH
#define MODEL_BITMAP_WIDTH 64
@@ -226,7 +227,6 @@ swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t e
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
extern uint8_t s_curveChan;
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
extern uint8_t editNameCursorPos;
@@ -244,6 +244,7 @@ extern uint8_t s_copyMode;
extern int8_t s_copySrcRow;
extern int8_t s_copyTgtOfs;
extern uint8_t s_currIdx;
extern uint8_t s_currIdxSubMenu;
extern uint8_t s_maxLines;
extern uint8_t s_copySrcIdx;
extern uint8_t s_copySrcCh;
+36 -19
View File
@@ -18,6 +18,7 @@
* GNU General Public License for more details.
*/
#include <limits.h>
#include "opentx.h"
#include "common/stdlcd/fonts.h"
@@ -87,11 +88,11 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
uint8_t lines = (height+7)/8;
assert(lines <= 5);
for (int8_t i=0; i<(int8_t)(width+2); i++) {
if (x<LCD_W) {
for (int8_t i = 0; i < int8_t(width + 2); i++) {
if (x < LCD_W) {
uint8_t b[5] = { 0 };
if (i==0) {
if (x==0 || !inv) {
if (i == 0) {
if (x == 0 || !inv) {
lcdNextPos++;
continue;
}
@@ -100,11 +101,11 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
x--;
}
}
else if (i<=width) {
else if (i <= width) {
uint8_t skip = true;
for (uint8_t j=0; j<lines; j++) {
b[j] = *(pattern++); /*top byte*/
if (b[j] != 0xff) {
if (b[j] != 0xFF) {
skip = false;
}
}
@@ -120,20 +121,24 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
}
}
for (int8_t j=-1; j<=(int8_t)(height); j++) {
for (int8_t j = -1; j <= int8_t(height); j++) {
bool plot;
if (j < 0 || ((j == height) && !(FONTSIZE(flags) == SMLSIZE))) {
if (j < 0 || (j == height && FONTSIZE(flags) != SMLSIZE)) {
plot = false;
if (height >= 12) continue;
if (j<0 && !inv) continue;
if (y+j < 0) continue;
if (height >= 12)
continue;
if (j < 0 && !inv)
continue;
if (y + j < 0)
continue;
}
else {
uint8_t line = (j / 8);
uint8_t pixel = (j % 8);
plot = b[line] & (1 << pixel);
}
if (inv) plot = !plot;
if (inv)
plot = !plot;
if (!blink) {
if (flags & VERTICAL)
lcdDrawPoint(y+j, LCD_H-x, plot ? FORCE : ERASE);
@@ -154,10 +159,10 @@ void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
uint32_t fontsize = FONTSIZE(flags);
unsigned char c_remapped = 0;
if (fontsize == DBLSIZE || (flags&BOLD)) {
if (fontsize == DBLSIZE || (flags & BOLD)) {
// To save space only some DBLSIZE and BOLD chars are available
// c has to be remapped. All non existing chars mapped to 0 (space)
if (c>=',' && c<=':')
if (c >= ',' && c <= ':')
c_remapped = c - ',' + 1;
else if (c>='A' && c<='Z')
c_remapped = c - 'A' + 16;
@@ -221,7 +226,7 @@ uint8_t getCharWidth(char c, LcdFlags flags)
}
#endif
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
void lcdDrawChar(coord_t x, coord_t y, char c, LcdFlags flags)
{
lcdNextPos = x-1;
#if defined(BOOT)
@@ -234,7 +239,7 @@ void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
#endif
}
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c)
void lcdDrawChar(coord_t x, coord_t y, char c)
{
lcdDrawChar(x, y, c, 0);
}
@@ -285,7 +290,7 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
break;
}
else if (c >= 0x20) {
if ( ( c == 46) && ((FONTSIZE(flags) == TINSIZE))) { // '.' handling
if (c == 46 && FONTSIZE(flags) == TINSIZE) { // '.' handling
if (((flags & BLINK) && BLINK_ON_PHASE) || ((!(flags & BLINK) && (flags & INVERS)))) {
lcdDrawSolidVerticalLine(x, y-1, 5);
lcdDrawPoint(x, y + 5);
@@ -293,7 +298,7 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
else {
lcdDrawPoint(x, y + 5 -1 , flags);
}
x+=2;
x += 2;
}
else {
lcdDrawChar(x, y, c, flags);
@@ -320,7 +325,7 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
x += 1;
}
else {
x += (c*FW/2); // EXTENDED SPACE
x += (c * FW/2); // EXTENDED SPACE
}
s++;
}
@@ -398,7 +403,19 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t le
int idx = 0;
int mode = MODE(flags);
bool neg = false;
if (val == INT_MAX) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MAX", flags);
return;
}
if (val < 0) {
if (val == INT_MIN) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MIN", flags);
return;
}
val = -val;
neg = true;
}
+3 -3
View File
@@ -100,12 +100,12 @@ extern coord_t lcdNextPos;
#define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE)
#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END)
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c);
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags mode);
void lcdDrawChar(coord_t x, coord_t y, char c);
void lcdDrawChar(coord_t x, coord_t y, char c, LcdFlags mode);
void lcdDrawCenteredText(coord_t y, const char * s, LcdFlags flags = 0);
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags mode);
void lcdDrawTextAtIndex(coord_t x, coord_t y, const char * s,uint8_t idx, LcdFlags mode);
void lcdDrawSizedText(coord_t x, coord_t y, const char * s,unsigned char len, LcdFlags mode);
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len, LcdFlags mode);
void lcdDrawText(coord_t x, coord_t y, const char * s);
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len);
void lcdDrawTextAlignedLeft(coord_t y, const char * s);
+2
View File
@@ -63,7 +63,9 @@ uint8_t editNameCursorPos = 0;
void editSingleName(coord_t x, coord_t y, const char * label, char *name, uint8_t size, event_t event, uint8_t active)
{
lcdDrawTextAlignedLeft(y, label);
TRACE("EDIT SINGLE NAME %s", name);
editName(x, y, name, size, event, active);
}
uint8_t s_currIdx;
uint8_t s_currIdxSubMenu;
+13 -13
View File
@@ -52,8 +52,8 @@ void runPopupCurvePreset(event_t event)
if (warningResult) {
warningResult = 0;
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
int k = 25 * reusableBuffer.curveEdit.preset;
int dx = 2000 / (5+crv.points-1);
for (uint8_t i=0; i<5+crv.points; i++) {
@@ -73,14 +73,14 @@ void onCurveOneMenu(const char * result)
POPUP_INPUT(STR_PRESET, runPopupCurvePreset);
}
else if (result == STR_MIRROR) {
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
for (int i=0; i<5+crv.points; i++)
points[i] = -points[i];
}
else if (result == STR_CLEAR) {
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
for (int i=0; i<5+crv.points; i++)
points[i] = 0;
if (crv.type == CURVE_TYPE_CUSTOM) {
@@ -92,10 +92,10 @@ void onCurveOneMenu(const char * result)
void menuModelCurveOne(event_t event)
{
static uint8_t pointsOfs = 0;
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
drawStringWithIndex(PSIZE(TR_MENUCURVES)*FW+FW, 0, "CV", s_curveChan+1);
drawStringWithIndex(PSIZE(TR_MENUCURVES)*FW+FW, 0, "CV", s_currIdxSubMenu+1);
lcdDrawText(11*FW+FW/2, 0, TR_PT "\002X\006Y");
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
@@ -114,9 +114,9 @@ void menuModelCurveOne(event_t event)
uint8_t newType = checkIncDecModelZero(event, crv.type, CURVE_TYPE_LAST);
if (newType != crv.type) {
for (int i = 1; i < 4 + crv.points; i++) {
points[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + crv.points, i)), s_curveChan));
points[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + crv.points, i)), s_currIdxSubMenu));
}
if (moveCurve(s_curveChan, checkIncDec_Ret > 0 ? 3 + crv.points : -3 - crv.points)) {
if (moveCurve(s_currIdxSubMenu, checkIncDec_Ret > 0 ? 3 + crv.points : -3 - crv.points)) {
if (newType == CURVE_TYPE_CUSTOM) {
resetCustomCurveX(points, 5 + crv.points);
}
@@ -137,8 +137,8 @@ void menuModelCurveOne(event_t event)
newPoints[0] = points[0];
newPoints[4 + count] = points[4 + crv.points];
for (int i = 1; i < 4 + count; i++)
newPoints[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + count, i)), s_curveChan));
if (moveCurve(s_curveChan, checkIncDec_Ret * (crv.type == CURVE_TYPE_CUSTOM ? 2 : 1))) {
newPoints[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + count, i)), s_currIdxSubMenu));
if (moveCurve(s_currIdxSubMenu, checkIncDec_Ret * (crv.type == CURVE_TYPE_CUSTOM ? 2 : 1))) {
for (int i = 0; i < 5 + count; i++) {
points[i] = newPoints[i];
if (crv.type == CURVE_TYPE_CUSTOM && i != 0 && i != 4 + count)
+1 -1
View File
@@ -212,7 +212,7 @@ void menuModelLimits(event_t event)
case ITEM_LIMITS_CURVE:
drawCurveName(LIMITS_CURVE_POS, y, ld->curve, attr);
if (attr && event==EVT_KEY_LONG(KEY_ENTER) && ld->curve>0) {
s_curveChan = (ld->curve<0 ? -ld->curve-1 : ld->curve-1);
s_currIdxSubMenu = (ld->curve<0 ? -ld->curve-1 : ld->curve-1);
pushMenu(menuModelCurveOne);
}
if (active) {
-1
View File
@@ -20,7 +20,6 @@
#include "opentx.h"
#define MODELSIZE_POS_X 170
#define MODELSEL_W 133
void onModelSelectMenu(const char * result)
+65 -18
View File
@@ -98,6 +98,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_EXTERNAL_MODULE_LABEL,
ITEM_MODEL_SETUP_EXTERNAL_MODULE_TYPE,
#if defined (MULTIMODULE)
ITEM_MODEL_SETUP_EXTERNAL_MODULE_PROTOCOL,
ITEM_MODEL_SETUP_EXTERNAL_MODULE_STATUS,
ITEM_MODEL_SETUP_EXTERNAL_MODULE_SYNCSTATUS,
#endif
@@ -248,11 +249,6 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
{
if (isModuleXJT(EXTERNAL_MODULE) || isModuleR9MNonAccess(EXTERNAL_MODULE) || isModuleDSM2(EXTERNAL_MODULE))
return 1;
#if defined(MULTIMODULE)
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
return 1 + MULTIMODULE_RFPROTO_COLUMNS(EXTERNAL_MODULE);
}
#endif
else
return 0;
}
@@ -362,6 +358,7 @@ void menuModelSetup(event_t event)
LABEL(ExternalModule),
EXTERNAL_MODULE_TYPE_ROW(),
MULTIMODULE_TYPE_ROW(EXTERNAL_MODULE)
MULTIMODULE_STATUS_ROWS(EXTERNAL_MODULE)
MODULE_CHANNELS_ROWS(EXTERNAL_MODULE),
IF_NOT_ACCESS_MODULE_RF(EXTERNAL_MODULE, MODULE_BIND_ROWS(EXTERNAL_MODULE)),
@@ -813,15 +810,6 @@ void menuModelSetup(event_t event)
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleR9MNonAccess(EXTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_R9M_REGION, g_model.moduleData[EXTERNAL_MODULE].subType, (menuHorizontalPosition==1 ? attr : 0));
#if defined(MULTIMODULE)
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
uint8_t multi_rfProto = g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol();
// Do not use MODEL_SETUP_3RD_COLUMN here since some the protocol string are so long that we cannot afford the 2 spaces (+6) here
lcdDrawMultiProtocolString(lcdNextPos + 3, y, EXTERNAL_MODULE, multi_rfProto, menuHorizontalPosition == 1 ? attr : 0);
if (MULTIMODULE_HAS_SUBTYPE(EXTERNAL_MODULE))
lcdDrawMultiSubProtocolString(lcdNextPos + 3, y, EXTERNAL_MODULE, g_model.moduleData[EXTERNAL_MODULE].subType, menuHorizontalPosition==2 ? attr : 0);
}
#endif
if (attr && menuHorizontalPosition == 0) {
if (s_editMode > 0) {
g_model.moduleData[EXTERNAL_MODULE].type = MODULE_TYPE_NONE;
@@ -906,6 +894,59 @@ void menuModelSetup(event_t event)
}
break;
#if defined(MULTIMODULE)
case ITEM_MODEL_SETUP_EXTERNAL_MODULE_PROTOCOL:
{
lcdDrawTextAlignedLeft(y, TR_TYPE);
uint8_t multi_rfProto = g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol();
lcdDrawMultiProtocolString(MODEL_SETUP_2ND_COLUMN, y, EXTERNAL_MODULE, multi_rfProto, menuHorizontalPosition == 0 ? attr : 0);
if (MULTIMODULE_HAS_SUBTYPE(EXTERNAL_MODULE))
lcdDrawMultiSubProtocolString(MODEL_SETUP_3RD_COLUMN + 15, y, EXTERNAL_MODULE, g_model.moduleData[EXTERNAL_MODULE].subType,
menuHorizontalPosition == 1 ? attr : 0);
if (attr) {
switch (menuHorizontalPosition) {
case 0: {
int multiRfProto = g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol();
MultiModuleStatus &status = getMultiModuleStatus(EXTERNAL_MODULE);
if (status.isValid()) {
int8_t direction = checkIncDec(event, 0, -1, 1);
if (direction == -1) {
if (multiRfProto == MODULE_SUBTYPE_MULTI_FRSKY)
multiRfProto = MODULE_SUBTYPE_MULTI_FRSKYX_RX;
else
multiRfProto = convertMultiToOtx(status.protocolPrev);
}
if (direction == 1) {
if (multiRfProto == MODULE_SUBTYPE_MULTI_FRSKY)
multiRfProto = MODULE_SUBTYPE_MULTI_FRSKYX2;
else
multiRfProto = convertMultiToOtx(status.protocolNext);
}
}
else {
CHECK_INCDEC_MODELVAR_CHECK(event, multiRfProto, MODULE_SUBTYPE_MULTI_FIRST, MULTI_MAX_PROTOCOLS, isMultiProtocolSelectable);
}
if (checkIncDec_Ret) {
g_model.moduleData[EXTERNAL_MODULE].setMultiProtocol(multiRfProto);
g_model.moduleData[EXTERNAL_MODULE].subType = 0;
resetMultiProtocolsOptions(EXTERNAL_MODULE);
storageDirty(EE_MODEL);
}
}
break;
case 1:
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].subType, 0, getMaxMultiSubtype(EXTERNAL_MODULE));
if (checkIncDec_Ret) {
resetMultiProtocolsOptions(EXTERNAL_MODULE);
}
break;
}
}
}
break;
#endif
case ITEM_MODEL_SETUP_TRAINER_LABEL:
lcdDrawTextAlignedLeft(y, STR_TRAINER);
break;
@@ -1100,8 +1141,13 @@ void menuModelSetup(event_t event)
lcdDrawText(INDENT_WIDTH, y, STR_RECEIVER_NUM);
}
if (isModuleBindRangeAvailable(moduleIdx)) {
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2);
bindButtonPos = lcdNextPos + FW;
if (!IS_RX_MULTI(moduleIdx)) {
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz == 0 ? attr : 0) | LEADING0 | LEFT, 2);
bindButtonPos = lcdNextPos + FW;
}
else {
bindButtonPos = MODEL_SETUP_2ND_COLUMN;
}
if (attr && l_posHorz==0) {
if (s_editMode>0) {
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], getMaxRxNum(moduleIdx));
@@ -1119,7 +1165,8 @@ void menuModelSetup(event_t event)
}
}
lcdDrawText(bindButtonPos, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0);
lcdDrawText(lcdNextPos + FW, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0);
if (!IS_RX_MULTI(moduleIdx))
lcdDrawText(lcdNextPos + FW, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0);
uint8_t newFlag = 0;
#if defined(MULTIMODULE)
if (getMultiBindStatus(moduleIdx) == MULTI_BIND_FINISHED) {
@@ -1284,7 +1331,7 @@ void menuModelSetup(event_t event)
}
#if defined (MULTIMODULE)
else if (isModuleMultimodule(moduleIdx)) {
g_model.moduleData[EXTERNAL_MODULE].multi.lowPowerMode = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].multi.lowPowerMode, MODEL_SETUP_2ND_COLUMN, y, STR_MULTI_LOWPOWER, attr, event);
g_model.moduleData[EXTERNAL_MODULE].multi.lowPowerMode = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].multi.lowPowerMode, MODEL_SETUP_2ND_COLUMN, y, IS_RX_MULTI(moduleIdx) ? STR_MULTI_LNA_DISABLE : STR_MULTI_LOWPOWER, attr, event);
}
#endif
break;
-8
View File
@@ -38,12 +38,4 @@ void menuRadioDiagAnalogs(event_t event)
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
#endif
}
// RAS
if ((isModuleXJT(INTERNAL_MODULE) && IS_INTERNAL_MODULE_ON()) || (isModulePXX1(EXTERNAL_MODULE) && !IS_INTERNAL_MODULE_ON())) {
lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+6*FH, "RAS");
lcdDrawNumber(10*FW-1, MENU_HEADER_HEIGHT+6*FH, telemetryData.swrInternal.value(), RIGHT);
lcdDrawText(LCD_W/2, MENU_HEADER_HEIGHT+6*FH, "XJTVER");
lcdDrawNumber(LCD_W/2 + 10*FW-1, MENU_HEADER_HEIGHT+6*FH, telemetryData.xjtVersion, RIGHT);
}
}
+2 -2
View File
@@ -25,8 +25,8 @@ const uint8_t LBM_LAYOUT_1x1[] = {
};
const ZoneOption OPTIONS_LAYOUT_1x1[] = {
{ "Top bar", ZoneOption::Bool },
{ "Sliders+Trims", ZoneOption::Bool },
{ STR_TOP_BAR, ZoneOption::Bool },
{ STR_SLIDERS_TRIMS, ZoneOption::Bool },
{ nullptr, ZoneOption::Bool }
};
+2 -2
View File
@@ -25,7 +25,7 @@ const uint8_t LBM_LAYOUT_2x1[] = {
};
const ZoneOption OPTIONS_LAYOUT_2x1[] = {
{ "Top bar", ZoneOption::Bool },
{ STR_TOP_BAR, ZoneOption::Bool },
{ nullptr, ZoneOption::Bool }
};
@@ -45,7 +45,7 @@ class Layout2x1: public Layout
unsigned int getZonesCount() const override
{
return 4;
return 2;
}
Zone getZone(unsigned int index) const override
+1 -1
View File
@@ -25,7 +25,7 @@ const uint8_t LBM_LAYOUT_2x2[] = {
};
const ZoneOption OPTIONS_LAYOUT_2x2[] = {
{ "Top bar", ZoneOption::Bool },
{ STR_TOP_BAR, ZoneOption::Bool },
{ nullptr, ZoneOption::Bool }
};
+3 -41
View File
@@ -28,50 +28,12 @@ uint8_t getMappedChar(uint8_t c)
{
uint8_t result;
#if defined(TRANSLATIONS_FR)
if (c >= 0x80 && c <= 0x84) {
result = 115 + c - 0x80;
}
#elif defined(TRANSLATIONS_DE)
if (c >= 0x80 && c <= 0x86) {
result = 120 + c - 0x80;
}
#elif defined(TRANSLATIONS_CZ)
if (c >= 0x80 && c <= 0x80+29) {
result = 127 + c - 0x80;
}
#elif defined(TRANSLATIONS_ES)
if (c >= 0x80 && c <= 0x81) {
result = 157 + c - 0x80;
}
#elif defined(TRANSLATIONS_FI)
if (c >= 0x80 && c <= 0x85) {
result = 159 + c - 0x80;
}
#elif defined(TRANSLATIONS_IT)
if (c >= 0x80 && c <= 0x81) {
result = 165 + c - 0x80;
}
#elif defined(TRANSLATIONS_PL)
if (c >= 0x80 && c <= 0x80+17) {
result = 167 + c - 0x80;
}
#elif defined(TRANSLATIONS_PT)
if (c >= 0x80 && c <= 0x80+21) {
result = 185 + c - 0x80;
}
#elif defined(TRANSLATIONS_SE)
if (c >= 0x80 && c <= 0x85) {
result = 207 + c - 0x80;
}
#endif
if (c < 0xC0)
if (c < 0x80)
result = c - 0x20;
else
result = c - 0xC0 + 96;
result = c - 0x80 + 32 + 26 + 6 + 26 + 5; // 96;
// TRACE("getMappedChar '%c' (%x) = %d", c, c, result);
// TRACE("getMappedChar '%c' (0x%x) = %d", c, c, result);
return result;
}
+1 -1
View File
@@ -278,7 +278,7 @@ extern int8_t s_editMode; // global editmode
//#define NAVIGATION_LINE_BY_LINE 0x40
//#define CURSOR_ON_LINE() (menuHorizontalPosition<0)
extern uint8_t s_curveChan;
extern uint8_t s_currIdxSubMenu;
extern const char * warningText;
extern const char * warningInfoText;
+2 -2
View File
@@ -62,7 +62,7 @@ void drawModel(coord_t x, coord_t y, ModelCell * model, bool current, bool selec
if (selected) {
lcdDrawSolidRect(x, y, MODELCELL_WIDTH+2, MODELCELL_HEIGHT+2, 1, TITLE_BGCOLOR);
drawShadow(x, y, MODELCELL_WIDTH+2, MODELCELL_HEIGHT+2);
if (selectMode == MODE_MOVE_MODEL) {
if (selectMode == MODE_MOVE_MODEL && modelselModelMoveBackground) {
lcd->drawMask(x+MODELCELL_WIDTH+2-modelselModelMoveBackground->width(), y, modelselModelMoveBackground, TITLE_BGCOLOR);
lcd->drawMask(x+MODELCELL_WIDTH+2-modelselModelMoveBackground->width()+12, y+5, modelselModelMoveIcon, DEFAULT_BGCOLOR);
}
@@ -279,7 +279,7 @@ void onModelSelectMenu(const char * result)
setCurrentModel(currentCategory->size() - 1);
}
else {
POPUP_WARNING("Invalid File");
POPUP_WARNING(STR_INVALID_FILE);
}
}
else if (result == STR_MOVE_MODEL) {
+3 -3
View File
@@ -121,7 +121,7 @@ bool editZoneOption(coord_t y, const ZoneOption * option, ZoneOptionValue * valu
}
}
else if (option->type == ZoneOption::TextSize) {
lcdDrawTextAtIndex(SCREENS_SETUP_2ND_COLUMN, y, "\010StandardTiny\0 Small\0 Mid\0 Double", value->unsignedValue, attr);
lcdDrawTextAtIndex(SCREENS_SETUP_2ND_COLUMN, y, STR_TEXT_SIZE, value->unsignedValue, attr);
if (attr) {
value->unsignedValue = checkIncDec(event, value->unsignedValue, 0, 4, i_flags);
}
@@ -346,7 +346,7 @@ bool menuWidgetsSetup(event_t event)
currentScreen->refresh();
for (int i=currentContainer->getZonesCount()-1; i>=0; i--) {
for (int i = currentContainer->getZonesCount() - 1; i >= 0; i--) {
Zone zone = currentContainer->getZone(i);
LcdFlags color;
int padding, thickness;
@@ -558,7 +558,7 @@ bool menuScreenSetup(int index, event_t event)
currentContainer = currentScreen;
bool needsOffsetCheck = (menuVerticalPosition != 0 || menuHorizontalPosition < 0);
char title[] = "Main view X";
char title[] = TR_MAIN_VIEW_X;
title[sizeof(title)-2] = '1' + index;
menuPageCount = updateMainviewsMenu();
+13 -12
View File
@@ -26,30 +26,31 @@
#include "lcd.h"
#include "strhelpers.h"
#include "draw_functions.h"
#include "opentx.h"
class SourceChoiceMenuToolbar : public MenuToolbar<SourceChoice> {
public:
SourceChoiceMenuToolbar(SourceChoice * choice, Menu * menu):
MenuToolbar<SourceChoice>(choice, menu)
{
addButton(char('\314'), MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT);
addButton(CHAR_INPUT, MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT);
#if defined(LUA_MODEL_SCRIPTS)
addButton(char('\322'), MIXSRC_LAST_LUA, MIXSRC_FIRST_LUA);
addButton(CHAR_LUA, MIXSRC_LAST_LUA, MIXSRC_FIRST_LUA);
#endif
addButton(char('\307'), MIXSRC_FIRST_STICK, MIXSRC_LAST_STICK);
addButton(char('\310'), MIXSRC_FIRST_POT, MIXSRC_LAST_POT);
addButton(char('\315'), MIXSRC_MAX, MIXSRC_MAX);
addButton(char(CHAR_STICK), MIXSRC_FIRST_STICK, MIXSRC_LAST_STICK);
addButton(CHAR_POT, MIXSRC_FIRST_POT, MIXSRC_LAST_POT);
addButton(CHAR_FUNCTION, MIXSRC_MAX, MIXSRC_MAX);
#if defined(HELI)
addButton(char('\316'), MIXSRC_FIRST_HELI, MIXSRC_LAST_HELI);
addButton(CHAR_CYC, MIXSRC_FIRST_HELI, MIXSRC_LAST_HELI);
#endif
addButton(char('\313'), MIXSRC_FIRST_TRIM, MIXSRC_LAST_TRIM);
addButton(char('\312'), MIXSRC_FIRST_SWITCH, MIXSRC_LAST_SWITCH);
addButton(char('\317'), MIXSRC_FIRST_TRAINER, MIXSRC_LAST_TRAINER);
addButton(char('\320'), MIXSRC_FIRST_CH, MIXSRC_LAST_CH);
addButton(CHAR_TRIM, MIXSRC_FIRST_TRIM, MIXSRC_LAST_TRIM);
addButton(CHAR_SWITCH, MIXSRC_FIRST_SWITCH, MIXSRC_LAST_SWITCH);
addButton(CHAR_TRAINER, MIXSRC_FIRST_TRAINER, MIXSRC_LAST_TRAINER);
addButton(CHAR_CHANNEL, MIXSRC_FIRST_CH, MIXSRC_LAST_CH);
#if defined(GVARS)
addButton(char('\311'), MIXSRC_LAST_GVAR, MIXSRC_FIRST_GVAR);
addButton(CHAR_GVAR, MIXSRC_LAST_GVAR, MIXSRC_FIRST_GVAR);
#endif
addButton(char('\321'), MIXSRC_FIRST_TELEM, MIXSRC_LAST_TELEM);
addButton(CHAR_TELEMETRY, MIXSRC_FIRST_TELEM, MIXSRC_LAST_TELEM);
}
};
+1 -1
View File
@@ -83,7 +83,7 @@ bool TabsCarousel::onTouchEnd(coord_t x, coord_t y)
TabsGroup::TabsGroup(uint8_t icon):
Window(&mainWindow, { 0, 0, LCD_W, LCD_H }, OPAQUE),
header(this, icon),
body(this, { 0, MENU_BODY_TOP, LCD_W, MENU_BODY_HEIGHT })
body(this, { 0, MENU_BODY_TOP, LCD_W, MENU_BODY_HEIGHT }, FORM_FORWARD_FOCUS)
{
}
+11 -3
View File
@@ -76,11 +76,19 @@ void drawTopBar()
/* Tx battery */
uint8_t bars = GET_TXBATT_BARS(5);
lcdDrawBitmapPattern(LCD_W-130, 24, LBM_TOPMENU_TXBATT, MENU_COLOR);
#if defined(USB_CHARGER)
if (usbChargerLed()) {
lcdDrawBitmapPattern(LCD_W - 130, 25, LBM_TOPMENU_TXBATT_CHARGING, MENU_TITLE_COLOR);
}
else {
lcdDrawBitmapPattern(LCD_W - 130, 25, LBM_TOPMENU_TXBATT, MENU_TITLE_COLOR);
}
#else
lcdDrawBitmapPattern(LCD_W - 130, 25, LBM_TOPMENU_TXBATT, MENU_TITLE_COLOR);
#endif
for (unsigned int i = 0; i < 5; i++) {
lcdDrawSolidFilledRect(LCD_W-122+4*i, 30, 2, 8, i >= bars ? MENU_TITLE_DISABLE_COLOR : MENU_COLOR);
lcdDrawSolidFilledRect(LCD_W - 128 + 4 * i, 30, 2, 8, i >= bars ? MENU_TITLE_DISABLE_COLOR : MENU_COLOR);
}
topbar->refresh();
#if 0
+4 -4
View File
@@ -42,7 +42,7 @@ bool menuTextView(event_t event)
break;
case EVT_ROTARY_RIGHT:
if (menuVerticalOffset + NUM_BODY_LINES >= lines_count)
if (menuVerticalOffset + TEXT_VIEWER_LINES >= lines_count)
break;
else
++menuVerticalOffset;
@@ -55,11 +55,11 @@ bool menuTextView(event_t event)
break;
}
for (int i=0; i<NUM_BODY_LINES; i++) {
lcd->drawTextMaxWidth(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + i * FH, reusableBuffer.viewText.lines[i], 0, LCD_W - 2 * MENUS_MARGIN_LEFT);
for (int i = 0; i < TEXT_VIEWER_LINES; i++) {
lcd->drawTextMaxWidth(MENUS_MARGIN_LEFT, MENU_HEADER_HEIGHT + i * FH, reusableBuffer.viewText.lines[i], 0, LCD_W - 2 * MENUS_MARGIN_LEFT);
}
drawVerticalScrollbar(LCD_W-5, 50, 195, menuVerticalOffset, lines_count, NUM_BODY_LINES);
drawVerticalScrollbar(LCD_W-5, 50, 195, menuVerticalOffset, lines_count, TEXT_VIEWER_LINES);
return true;
}
+4 -4
View File
@@ -34,10 +34,10 @@ class GaugeWidget: public Widget
};
const ZoneOption GaugeWidget::options[] = {
{ "Source", ZoneOption::Source, OPTION_VALUE_UNSIGNED(1) },
{ "Min", ZoneOption::Integer, OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(RESX) },
{ "Max", ZoneOption::Integer, OPTION_VALUE_SIGNED(RESX), OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(RESX) },
{ "Color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(RED) },
{ STR_SOURCE, ZoneOption::Source, OPTION_VALUE_UNSIGNED(1) },
{ STR_MIN, ZoneOption::Integer, OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(RESX) },
{ STR_MAX, ZoneOption::Integer, OPTION_VALUE_SIGNED(RESX), OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(RESX) },
{ STR_COLOR, ZoneOption::Color, OPTION_VALUE_UNSIGNED(RED) },
{ nullptr, ZoneOption::Bool }
};
+3 -3
View File
@@ -95,9 +95,9 @@ class OutputsWidget: public Widget
};
const ZoneOption OutputsWidget::options[] = {
{ "First channel", ZoneOption::Integer, OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(32) },
{ "Fill Background?", ZoneOption::Bool, OPTION_VALUE_BOOL(false) },
{ "BG Color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(LIGHTGREY) },
{ STR_FIRST_CHANNEL, ZoneOption::Integer, OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(32) },
{ STR_FILL_BACKGROUND, ZoneOption::Bool, OPTION_VALUE_BOOL(false) },
{ STR_BG_COLOR, ZoneOption::Color, OPTION_VALUE_UNSIGNED(LIGHTGREY) },
{ nullptr, ZoneOption::Bool }
};
+4 -4
View File
@@ -36,10 +36,10 @@ class TextWidget: public Widget
};
const ZoneOption TextWidget::options[] = {
{ "Text", ZoneOption::String, OPTION_VALUE_STRING(TEXT_WIDGET_DEFAULT_LABEL) },
{ "Color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(RED) },
{ "Size", ZoneOption::TextSize, OPTION_VALUE_UNSIGNED(0) },
{ "Shadow", ZoneOption::Bool, OPTION_VALUE_BOOL(false) },
{ STR_TEXT, ZoneOption::String, OPTION_VALUE_STRING(TEXT_WIDGET_DEFAULT_LABEL) },
{ STR_COLOR, ZoneOption::Color, OPTION_VALUE_UNSIGNED(RED) },
{ STR_SIZE, ZoneOption::TextSize, OPTION_VALUE_UNSIGNED(0) },
{ STR_SHADOW, ZoneOption::Bool, OPTION_VALUE_BOOL(false) },
{ nullptr, ZoneOption::Bool }
};
+1 -1
View File
@@ -34,7 +34,7 @@ class TimerWidget: public Widget
};
const ZoneOption TimerWidget::options[] = {
{ "Timer source", ZoneOption::Timer, OPTION_VALUE_UNSIGNED(0) },
{ STR_TIMER_SOURCE, ZoneOption::Timer, OPTION_VALUE_UNSIGNED(0) },
{ nullptr, ZoneOption::Bool }
};
+3 -3
View File
@@ -34,9 +34,9 @@ class ValueWidget: public Widget
};
const ZoneOption ValueWidget::options[] = {
{ "Source", ZoneOption::Source, OPTION_VALUE_UNSIGNED(MIXSRC_Rud) },
{ "Color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(WHITE) },
{ "Shadow", ZoneOption::Bool, OPTION_VALUE_BOOL(false) },
{ STR_SOURCE, ZoneOption::Source, OPTION_VALUE_UNSIGNED(MIXSRC_Rud) },
{ STR_COLOR, ZoneOption::Color, OPTION_VALUE_UNSIGNED(WHITE) },
{ STR_SHADOW, ZoneOption::Bool, OPTION_VALUE_BOOL(false) },
{ nullptr, ZoneOption::Bool }
};
+65 -45
View File
@@ -84,7 +84,7 @@ void drawTrimMode(coord_t x, coord_t y, uint8_t flightMode, uint8_t idx, LcdFlag
}
}
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att)
void drawValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att)
{
// convertUnit(val, unit);
lcdDrawNumber(x, y, val, att & (~NO_UNIT));
@@ -121,6 +121,40 @@ FlightModesType editFlightModes(coord_t x, coord_t y, event_t event, FlightModes
return value;
}
char getNextChar(char c, uint8_t position)
{
if (c == ' ')
return (position == 0 ? 'A' : 'a');
if (c == 'Z' || c == 'z')
return '0';
static const char * specialChars = "9_-., ";
for (uint8_t i = 0; specialChars[i] != 0; i++) {
if (c == specialChars[i])
return specialChars[i + 1];
}
return c + 1;
}
char getPreviousChar(char c, uint8_t position)
{
if (c == 'A' || c == 'a')
return ' ';
if (c == '0')
return (position == 0 ? 'Z' : 'z');
static const char * specialChars = "9_-., ";
for (uint8_t i = 1; specialChars[i] != 0; i++) {
if (c == specialChars[i])
return specialChars[i - 1];
}
return c - 1;
}
void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, uint8_t active, LcdFlags attr)
{
uint8_t mode = 0;
@@ -131,23 +165,24 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui
mode = FIXEDWIDTH;
}
lcdDrawSizedText(x, y, name, size, attr | mode);
lcdDrawSizedText(x, y, name[0] == '\0' ? "---" : name, size, attr | mode);
coord_t backupNextPos = lcdNextPos;
if (active) {
uint8_t cur = editNameCursorPos;
if (s_editMode > 0) {
int8_t c = name[cur];
int8_t v = c;
if (IS_NEXT_EVENT(event) || IS_PREVIOUS_EVENT(event)) {
if (attr == ZCHAR) {
v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0);
if (c <= 0) v = -v;
}
else {
v = checkIncDec(event, abs(v), '0', 'z', 0);
}
if (c == '\0')
c = ' ';
char v;
if (IS_NEXT_EVENT(event)) {
v = getNextChar(c, cur);
}
else if (IS_PREVIOUS_EVENT(event)) {
v = getPreviousChar(c, cur);
}
else {
v = c;
}
switch (event) {
@@ -164,11 +199,13 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui
#if defined(NAVIGATION_XLITE) || defined(NAVIGATION_9X)
case EVT_KEY_BREAK(KEY_LEFT):
if (cur>0) cur--;
if (cur > 0)
cur--;
break;
case EVT_KEY_BREAK(KEY_RIGHT):
if (cur<size-1) cur++;
if (cur < size - 1)
cur++;
break;
#endif
@@ -181,33 +218,21 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui
case EVT_KEY_LONG(KEY_ENTER):
#endif
if (attr & ZCHAR) {
#if defined(PCBTARANIS) && !defined(PCBXLITE)
if (v == 0) {
s_editMode = 0;
killEvents(event);
}
#endif
if (v >= -26 && v <= 26) {
v = -v; // toggle case
}
}
else {
#if !defined(NAVIGATION_XLITE)
if (v == ' ') {
s_editMode = 0;
killEvents(event);
break;
}
else
#endif
if (v >= 'A' && v <= 'Z') {
v = 'a' + v - 'A'; // toggle case
}
else if (v >= 'a' && v <= 'z') {
v = 'A' + v - 'a'; // toggle case
}
if (v == ' ') {
s_editMode = 0;
killEvents(event);
break;
}
else
#endif
if (v >= 'A' && v <= 'Z') {
v = 'a' + v - 'A'; // toggle case
}
else if (v >= 'a' && v <= 'z') {
v = 'A' + v - 'a'; // toggle case
}
#if defined(NAVIGATION_9X)
if (event==EVT_KEY_LONG(KEY_LEFT))
killEvents(KEY_LEFT);
@@ -220,12 +245,7 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui
storageDirty(isModelMenuDisplayed() ? EE_MODEL : EE_GENERAL);
}
if (attr == ZCHAR) {
lcdDrawChar(x+editNameCursorPos*FW, y, zchar2char(v), ERASEBG|INVERS|FIXEDWIDTH);
}
else {
lcdDrawChar(x+editNameCursorPos*FW, y, v, ERASEBG|INVERS|FIXEDWIDTH);
}
lcdDrawChar(x+editNameCursorPos*FW, y, v, ERASEBG|INVERS|FIXEDWIDTH);
}
else {
cur = 0;
+1 -1
View File
@@ -25,7 +25,7 @@
void lcdDrawMultiProtocolString(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t protocol, LcdFlags flags = 0);
void lcdDrawMultiSubProtocolString(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t subType, LcdFlags flags = 0);
void drawStringWithIndex(coord_t x, coord_t y, const char * str, uint8_t idx, LcdFlags att=0);
void drawValueWithUnit(coord_t x, coord_t y, int val, uint8_t unit, LcdFlags att=0);
void drawValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att=0);
void drawPower(coord_t x, coord_t y, int8_t dBm, LcdFlags att = 0);
void drawGVarName(coord_t x, coord_t y, int8_t index, LcdFlags flags=0);
+3 -3
View File
@@ -61,7 +61,7 @@ void menuModelCurvesAll(event_t event)
#endif
case EVT_KEY_FIRST(KEY_ENTER):
if (CURVE_SELECTED() && !READ_ONLY()) {
s_curveChan = sub;
s_currIdxSubMenu = sub;
pushMenu(menuModelCurveOne);
}
break;
@@ -94,7 +94,7 @@ void menuModelCurvesAll(event_t event)
}
if (CURVE_SELECTED()) {
s_curveChan = sub;
s_currIdxSubMenu = sub;
#if LCD_W >= 212
drawCurve(23);
#else
@@ -143,7 +143,7 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlag
drawCurveName(x, y, curve.value, flags);
if (active && menuHorizontalPosition==1) {
if (event==EVT_KEY_LONG(KEY_ENTER) && curve.value!=0) {
s_curveChan = (curve.value<0 ? -curve.value-1 : curve.value-1);
s_currIdxSubMenu = (curve.value<0 ? -curve.value-1 : curve.value-1);
pushMenu(menuModelCurveOne);
}
else {
+1 -1
View File
@@ -227,7 +227,7 @@ void showAlertBox(const char * title, const char * text, const char * action , u
lcdRefresh();
lcdSetContrast();
waitKeysReleased();
backlightOn();
resetBacklightTimeout();
checkBacklight();
}
+1 -1
View File
@@ -107,7 +107,7 @@ enum
{
warningText = message;
warningInfoText = info;
warningInfoLength = strlen(info);
warningInfoLength = info ? strlen(info) : 0;
warningInfoFlags = 0;
warningType = WARNING_TYPE_ASTERISK;
popupFunc = runPopupWarning;
@@ -624,22 +624,23 @@ void menuRadioHardware(event_t event)
break;
case ITEM_RADIO_HARDWARE_RAS:
#if defined(PCBX9LITE) && !defined(PCBX9LITES)
lcdDrawTextAlignedLeft(y, "Ext. RAS");
lcdNextPos = HW_SETTINGS_COLUMN2;
#else
#if defined(HARDWARE_INTERNAL_RAS)
lcdDrawTextAlignedLeft(y, "RAS");
if (telemetryData.swrInternal.isFresh())
lcdDrawNumber(HW_SETTINGS_COLUMN2, y, telemetryData.swrInternal.value());
else
lcdDrawText(HW_SETTINGS_COLUMN2, y, "---");
lcdDrawText(lcdNextPos, y, "/");
#else
lcdDrawTextAlignedLeft(y, "Ext. RAS");
lcdNextPos = HW_SETTINGS_COLUMN2;
#endif
if (telemetryData.swrExternal.isFresh())
lcdDrawNumber(lcdNextPos, y, telemetryData.swrExternal.value());
else
lcdDrawText(lcdNextPos, y, "---");
break;
#if defined(SPORT_UPDATE_PWR_GPIO)
case ITEM_RADIO_HARDWARE_SPORT_UPDATE_POWER:
g_eeGeneral.sportUpdatePower = editChoice(HW_SETTINGS_COLUMN2, y, STR_SPORT_UPDATE_POWER_MODE, STR_SPORT_UPDATE_POWER_MODES, g_eeGeneral.sportUpdatePower, 0, 1, attr, event);
@@ -291,12 +291,14 @@ void menuRadioSdManager(event_t _event)
int lastPos = menuVerticalPosition;
#endif
if (moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode == MODULE_MODE_BIND && EVT_KEY_MASK(_event) == KEY_EXIT) {
#if defined(PXX2)
if (EVT_KEY_MASK(_event) == KEY_EXIT && moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode == MODULE_MODE_BIND) {
moduleState[reusableBuffer.sdManager.otaUpdateInformation.module].mode = MODULE_MODE_NORMAL;
CLEAR_POPUP();
killEvents(KEY_EXIT);
_event = 0;
}
#endif
event_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event);
SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabGeneral, MENU_RADIO_SD_MANAGER, HEADER_LINE + reusableBuffer.sdManager.count);
@@ -304,13 +306,13 @@ void menuRadioSdManager(event_t _event)
switch (_event) {
case EVT_ENTRY:
f_chdir(ROOT_PATH);
REFRESH_FILES();
#if LCD_DEPTH > 1
lastPos = -1;
#endif
break;
// no break
case EVT_ENTRY_UP:
memclear(&reusableBuffer.sdManager, sizeof(reusableBuffer.sdManager));
REFRESH_FILES();
break;
@@ -579,7 +581,7 @@ void menuRadioSdManager(event_t _event)
if (reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversCount > 0) {
if (reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversCount != popupMenuItemsCount) {
CLEAR_POPUP();
popupMenuItemsCount = min<uint8_t>(reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversCount,PXX2_MAX_RECEIVERS_PER_MODULE);
popupMenuItemsCount = min<uint8_t>(reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE);
for (auto rx = 0; rx < popupMenuItemsCount; rx++) {
popupMenuItems[rx] = reusableBuffer.sdManager.otaUpdateInformation.candidateReceiversNames[rx];
}
@@ -92,7 +92,7 @@ void menuViewTelemetry(event_t event)
}
drawTelemetryTopBar();
lcdDrawText(LCD_W / 2, 3 * FH, "No Telemetry Screens", CENTERED);
lcdDrawText(LCD_W / 2, 3 * FH, STR_NO_TELEMETRY_SCREENS, CENTERED);
displayRssiLine();
}
+59 -21
View File
@@ -752,16 +752,12 @@ bool isTrainerModeAvailable(int mode)
return g_eeGeneral.auxSerialMode == UART_MODE_SBUS_TRAINER;
#endif
#if defined(HARDWARE_TRAINER_BLUETOOTH)
case TRAINER_MODE_MASTER_BLUETOOTH:
case TRAINER_MODE_SLAVE_BLUETOOTH:
return g_eeGeneral.bluetoothMode == BLUETOOTH_TRAINER;
#endif
#if defined(HARDWARE_TRAINER_JACK)
case TRAINER_MODE_MASTER_TRAINER_JACK:
case TRAINER_MODE_SLAVE:
return true;
#if defined(BLUETOOTH) && !defined(PCBX9E)
if (g_eeGeneral.bluetoothMode != BLUETOOTH_TRAINER && (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_SLAVE_BLUETOOTH))
return false;
#elif !defined(PCBSKY9X)
if (mode == TRAINER_MODE_MASTER_BLUETOOTH || mode == TRAINER_MODE_SLAVE_BLUETOOTH)
return false;
#endif
#if defined(HARDWARE_TRAINER_MULTI)
@@ -813,7 +809,7 @@ int getFirstAvailable(int min, int max, IsValueAvailable isValueAvailable)
#if defined(MULTIMODULE)
// This maps OpenTX multi type with Pascal's Multi type
uint8_t convertMultiProtocol(uint8_t moduleIdx, uint8_t type)
uint8_t multiConvertOtxToMulti(uint8_t moduleIdx, uint8_t type)
{
// 15 for Multimodule is FrskyX or D16 which we map as a subprotocol of 3 (FrSky)
@@ -827,7 +823,7 @@ uint8_t convertMultiProtocol(uint8_t moduleIdx, uint8_t type)
if (type == MODULE_SUBTYPE_MULTI_FRSKY) {
int subtype = g_model.moduleData[moduleIdx].subType;
if (subtype == MM_RF_FRSKY_SUBTYPE_D8) {
if (subtype == MM_RF_FRSKY_SUBTYPE_D8 || subtype == MM_RF_FRSKY_SUBTYPE_D8_CLONED) {
//D8
type = 3;
}
@@ -842,6 +838,27 @@ uint8_t convertMultiProtocol(uint8_t moduleIdx, uint8_t type)
return type;
}
// This maps multi type to OpenTX number, type ONLY (no subtype)
int convertMultiToOtx(int type)
{
if (type == 3) //FrSkyD
return MODULE_SUBTYPE_MULTI_FRSKY;
if (type == 15) //FrSkyX
return MODULE_SUBTYPE_MULTI_FRSKY;
if (type == 25) //FrSkyV
return MODULE_SUBTYPE_MULTI_FRSKY;
if (type > 25)
type = type - 1;
if (type > 15)
type = type - 1;
return type - 1; //Multi list starts at 1
}
// Third row is number of subtypes -1 (max valid subtype)
#define NO_SUBTYPE nullptr
@@ -855,7 +872,7 @@ uint8_t convertMultiProtocol(uint8_t moduleIdx, uint8_t type)
const char STR_SUBTYPE_FLYSKY[] = "\004""Std\0""V9x9""V6x6""V912""CX20";
const char STR_SUBTYPE_HUBSAN[] = "\004""H107""H301""H501";
const char STR_SUBTYPE_FRSKY[] = "\007""D16\0 ""D8\0 ""D16 8ch""V8\0 ""LBT(EU)""LBT 8ch";
const char STR_SUBTYPE_FRSKY[] = "\011""D16\0 ""D8\0 ""D16 8ch\0 ""V8\0 ""LBT(EU)\0 ""LBT 8ch\0 ""D8Cloned\0""D16Cloned";
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";
@@ -867,6 +884,7 @@ const char STR_SUBTYPE_SLT[] = "\006""V1_6ch""V2_8ch""Q100\0 ""Q200\0 ""M
const char STR_SUBTYPE_CX10[] = "\007""Green\0 ""Blue\0 ""DM007\0 ""-\0 ""JC3015a""JC3015b""MK33041";
const char STR_SUBTYPE_CG023[] = "\005""Std\0 ""YD829";
const char STR_SUBTYPE_BAYANG[] = "\007""Std\0 ""H8S3D\0 ""X16 AH\0""IRDrone""DHD D4";
const char STR_SUBTYPE_ESky[] = "\003""Std""ET4";
const char STR_SUBTYPE_MT99[] = "\006""MT99\0 ""H7\0 ""YZ\0 ""LS\0 ""FY805";
const char STR_SUBTYPE_MJXQ[] = "\007""WLH08\0 ""X600\0 ""X800\0 ""H26D\0 ""E010\0 ""H26WH\0 ""Phoenix";
const char STR_SUBTYPE_FY326[] = "\005""Std\0 ""FY319";
@@ -876,19 +894,29 @@ const char STR_SUBTYPE_Q2X2[] = "\004""Q222""Q242""Q282";
const char STR_SUBTYPE_WK2x01[] = "\006""WK2801""WK2401""W6_5_1""W6_6_1""W6_HeL""W6_HeI";
const char STR_SUBTYPE_Q303[] = "\006""Std\0 ""CX35\0 ""CX10D\0""CX10WD";
const char STR_SUBTYPE_CABELL[] = "\007""V3\0 ""V3 Telm""-\0 ""-\0 ""-\0 ""-\0 ""F-Safe\0""Unbind\0";
const char STR_SUBTYPE_ESKY150[] = "\003""4ch""7ch";
const char STR_SUBTYPE_H83D[] = "\007""Std\0 ""H20H\0 ""H20Mini""H30Mini";
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_WFLY[] = "\006""WFR0xS";
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_V911S[] = "\004""Std\0""E119";
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_ZSX[] = "\007""280JJRC";
const char STR_SUBTYPE_FLYZONE[] = "\005""FZ410";
const char STR_SUBTYPE_FRSKYX_RX[] = "\007""RX\0 ""CloneTX";
const char STR_SUBTYPE_FX816[] = "\003""P38";
const char STR_SUBTYPE_ESKY150[] = "\003""4CH""7CH";
const char STR_SUBTYPE_XK[] = "\004""X450""X420";
const char STR_SUBTYPE_XN297DUMP[] = "\004""250K""1M\0 ""2M\0 ""AUTO";
const char STR_SUBTYPE_FRSKYX2[] = "\011""D16\0 ""D16 8ch\0 ""LBT(EU)\0 ""LBT 8ch\0 ""D16Cloned";
const char STR_SUBTYPE_FRSKYR9[] = "\007""915MHz\0""868MHz\0""915 8ch""868 8ch";
const char STR_SUBTYPE_PROPEL[] = "\004""74-Z";
const char STR_SUBTYPE_FRSKYL[] = "\010""LR12\0 ""LR12 6ch";
const char STR_SUBTYPE_ESKY150V2[] = "\006""150 V2";
const char* mm_options_strings::options[] = {
nullptr,
@@ -906,7 +934,7 @@ const mm_protocol_definition multi_protocols[] = {
// Protocol as defined in pulses\modules_constants.h, number of sub_protocols - 1, Failsafe supported, Disable channel mapping supported, Subtype string, Option type
{MODULE_SUBTYPE_MULTI_FLYSKY, 4, false, true, STR_SUBTYPE_FLYSKY, nullptr},
{MODULE_SUBTYPE_MULTI_HUBSAN, 2, false, false, STR_SUBTYPE_HUBSAN, STR_MULTI_VIDFREQ},
{MODULE_SUBTYPE_MULTI_FRSKY, 5, false, false, STR_SUBTYPE_FRSKY, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_FRSKY, 7, false, false, STR_SUBTYPE_FRSKY, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_HISKY, 1, false, true, STR_SUBTYPE_HISKY, nullptr},
{MODULE_SUBTYPE_MULTI_V2X2, 1, false, false, STR_SUBTYPE_V2X2, nullptr},
{MODULE_SUBTYPE_MULTI_DSM2, 3, false, true, STR_SUBTYPE_DSM, STR_MULTI_MAX_THROW},
@@ -914,14 +942,16 @@ const mm_protocol_definition multi_protocols[] = {
{MODULE_SUBTYPE_MULTI_YD717, 4, false, false, STR_SUBTYPE_YD717, nullptr},
{MODULE_SUBTYPE_MULTI_KN, 1, false, false, STR_SUBTYPE_KN, nullptr},
{MODULE_SUBTYPE_MULTI_SYMAX, 1, false, false, STR_SUBTYPE_SYMAX, nullptr},
{MODULE_SUBTYPE_MULTI_SLT, 4, false, true, STR_SUBTYPE_SLT, nullptr},
{MODULE_SUBTYPE_MULTI_SLT, 4, false, true, STR_SUBTYPE_SLT, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_CX10, 6, false, false, STR_SUBTYPE_CX10, nullptr},
{MODULE_SUBTYPE_MULTI_CG023, 1, false, false, STR_SUBTYPE_CG023, nullptr},
{MODULE_SUBTYPE_MULTI_BAYANG, 4, false, false, STR_SUBTYPE_BAYANG, STR_MULTI_TELEMETRY},
{MODULE_SUBTYPE_MULTI_ESky, 1, false, true, STR_SUBTYPE_ESky, nullptr},
{MODULE_SUBTYPE_MULTI_MT99XX, 4, false, false, STR_SUBTYPE_MT99, nullptr},
{MODULE_SUBTYPE_MULTI_MJXQ, 6, false, false, STR_SUBTYPE_MJXQ, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_FY326, 1, false, false, STR_SUBTYPE_FY326, nullptr},
{MODULE_SUBTYPE_MULTI_SFHSS, 0, true, true, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_J6PRO, 0, false, true, NO_SUBTYPE, nullptr},
{MODULE_SUBTYPE_MULTI_HONTAI, 3, false, false, STR_SUBTYPE_HONTAI, nullptr},
{MODULE_SUBTYPE_MULTI_OLRS, 0, false, false, NO_SUBTYPE, STR_RF_POWER},
{MODULE_SUBTYPE_MULTI_FS_AFHDS2A, 3, true, true, STR_SUBTYPE_AFHDS2A, STR_MULTI_SERVOFREQ},
@@ -929,24 +959,32 @@ const mm_protocol_definition multi_protocols[] = {
{MODULE_SUBTYPE_MULTI_WK_2X01, 5, false, true, STR_SUBTYPE_WK2x01, nullptr},
{MODULE_SUBTYPE_MULTI_Q303, 3, false, false, STR_SUBTYPE_Q303, nullptr},
{MODULE_SUBTYPE_MULTI_CABELL, 7, false, false, STR_SUBTYPE_CABELL, STR_MULTI_OPTION},
{MODULE_SUBTYPE_MULTI_ESKY150, 1, false, false, STR_SUBTYPE_ESKY150, nullptr},
{MODULE_SUBTYPE_MULTI_H83D, 3, false, false, STR_SUBTYPE_H83D, nullptr},
{MODULE_SUBTYPE_MULTI_CORONA, 2, false, false, STR_SUBTYPE_CORONA, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_HITEC, 2, false, false, STR_SUBTYPE_HITEC, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_WFLY, 0, false, false, STR_SUBTYPE_WFLY, nullptr},
{MODULE_SUBTYPE_MULTI_BUGS_MINI, 1, false, false, STR_SUBTYPE_BUGS_MINI, nullptr},
{MODULE_SUBTYPE_MULTI_TRAXXAS, 0, false, false, STR_SUBTYPE_TRAXXAS, nullptr},
{MODULE_SUBTYPE_MULTI_E01X, 2, false, false, STR_SUBTYPE_E01X, STR_MULTI_OPTION},
{MODULE_SUBTYPE_MULTI_V911S, 1, false, false, STR_SUBTYPE_V911S, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_GD00X, 1, false, false, STR_SUBTYPE_GD00X, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_KF606, 0, false, false, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_REDPINE, 1, false, false, STR_SUBTYPE_REDPINE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_POTENSIC, 0, false, false, STR_SUBTYPE_POTENSIC, nullptr},
{MODULE_SUBTYPE_MULTI_ZSX, 0, false, false, STR_SUBTYPE_ZSX, nullptr},
{MODULE_SUBTYPE_MULTI_FLYZONE, 0, false, false, STR_SUBTYPE_FLYZONE, nullptr},
{MODULE_SUBTYPE_MULTI_FRSKYX_RX, 0, false, false, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_ESky, 0, false, true, NO_SUBTYPE, nullptr},
{MODULE_SUBTYPE_MULTI_J6PRO, 0, false, true, NO_SUBTYPE, nullptr},
{MODULE_SUBTYPE_MULTI_ESKY150, 1, false, false, STR_SUBTYPE_ESKY150, nullptr},
{MODULE_SUBTYPE_MULTI_FX816, 0, false, false, STR_SUBTYPE_FX816, nullptr},
{MODULE_SUBTYPE_MULTI_FRSKYX_RX, 1, false, false, STR_SUBTYPE_FRSKYX_RX, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_HOTT, 0, true, false, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_FX816, 0, false, false, STR_SUBTYPE_FX816, nullptr},
{MODULE_SUBTYPE_MULTI_XK, 1, false, false, STR_SUBTYPE_XK, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_XN297DUMP, 3, false, false, STR_SUBTYPE_XN297DUMP, STR_MULTI_RFCHAN},
{MODULE_SUBTYPE_MULTI_FRSKYX2, 4, true, false, STR_SUBTYPE_FRSKYX2, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_FRSKY_R9, 3, true, false, STR_SUBTYPE_FRSKYR9, nullptr},
{MODULE_SUBTYPE_MULTI_PROPEL, 0, false, false, STR_SUBTYPE_PROPEL, nullptr},
{MODULE_SUBTYPE_MULTI_FRSKYL, 1, false, false, STR_SUBTYPE_FRSKYL, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_SKYARTEC, 0, false, false, NO_SUBTYPE, STR_MULTI_RFTUNE},
{MODULE_SUBTYPE_MULTI_ESKY150V2, 0, false, true, STR_SUBTYPE_ESKY150V2, STR_MULTI_RFTUNE},
{MM_RF_CUSTOM_SELECTED, 7, true, true, NO_SUBTYPE, STR_MULTI_OPTION},
// Sentinel and default for protocols not listed above (MM_RF_CUSTOM is 0xff)
+8 -4
View File
@@ -137,6 +137,8 @@ void drawSensorCustomValue(coord_t x, coord_t y, uint8_t sensor, int32_t value,
void drawSourceCustomValue(coord_t x, coord_t y, source_t channel, int32_t val, LcdFlags flags=0);
void drawSourceValue(coord_t x, coord_t y, source_t channel, LcdFlags flags=0);
int convertMultiToOtx(int type);
void drawCurve(coord_t offset=0);
// model_setup Defines that are used in all uis in the same way
@@ -145,7 +147,7 @@ void drawCurve(coord_t offset=0);
inline uint8_t MODULE_BIND_ROWS(int moduleIdx)
{
if (isModuleXJTD8(moduleIdx) || isModuleSBUS(moduleIdx))
if (isModuleXJTD8(moduleIdx) || isModuleSBUS(moduleIdx) || IS_RX_MULTI(moduleIdx))
return 1;
if (isModulePPM(moduleIdx) || isModulePXX1(moduleIdx) || isModulePXX2(moduleIdx) || isModuleDSM2(moduleIdx) || isModuleMultimodule(moduleIdx))
@@ -156,7 +158,7 @@ inline uint8_t MODULE_BIND_ROWS(int moduleIdx)
inline uint8_t MODULE_CHANNELS_ROWS(int moduleIdx)
{
if (!IS_MODULE_ENABLED(moduleIdx))
if (!IS_MODULE_ENABLED(moduleIdx) || IS_RX_MULTI(moduleIdx))
return HIDDEN_ROW;
if (isModuleDSM2(moduleIdx) || isModuleCrossfire(moduleIdx) || isModuleSBUS(moduleIdx) || (isModuleMultimodule(moduleIdx) && g_model.moduleData[moduleIdx].getMultiProtocol() != MODULE_SUBTYPE_MULTI_DSM2))
@@ -256,12 +258,14 @@ inline uint8_t MULTIMODULE_HASOPTIONS(uint8_t moduleIdx)
return false;
}
#define MULTIMODULE_MODULE_ROWS(moduleIdx) MULTIMODULE_PROTOCOL_KNOWN(moduleIdx) ? (uint8_t) 0 : HIDDEN_ROW, MULTIMODULE_PROTOCOL_KNOWN(moduleIdx) ? (uint8_t) 0 : HIDDEN_ROW, MULTI_DISABLE_CHAN_MAP_ROW(moduleIdx), // AUTOBIND, DISABLE TELEM, DISABLE CN.MAP
#define MULTIMODULE_MODULE_ROWS(moduleIdx) (MULTIMODULE_PROTOCOL_KNOWN(moduleIdx) && !IS_RX_MULTI(moduleIdx)) ? (uint8_t) 0 : HIDDEN_ROW, (MULTIMODULE_PROTOCOL_KNOWN(moduleIdx) && !IS_RX_MULTI(moduleIdx)) ? (uint8_t) 0 : HIDDEN_ROW, MULTI_DISABLE_CHAN_MAP_ROW(moduleIdx), // AUTOBIND, DISABLE TELEM, DISABLE CN.MAP
#define MULTIMODULE_TYPE_ROW(moduleIdx) isModuleMultimodule(moduleIdx) ? MULTIMODULE_RFPROTO_COLUMNS(moduleIdx) : HIDDEN_ROW,
#define MULTIMODULE_STATUS_ROWS(moduleIdx) isModuleMultimodule(moduleIdx) ? TITLE_ROW : HIDDEN_ROW, (isModuleMultimodule(moduleIdx) && getMultiSyncStatus(moduleIdx).isValid()) ? TITLE_ROW : HIDDEN_ROW,
#define MULTIMODULE_MODE_ROWS(moduleIdx) (g_model.moduleData[moduleIdx].multi.customProto) ? (uint8_t) 3 : MULTIMODULE_HAS_SUBTYPE(moduleIdx) ? (uint8_t)2 : (uint8_t)1
#define MULTIMODULE_TYPE_ROWS(moduleIdx) isModuleMultimodule(moduleIdx) ? (uint8_t) 0 : HIDDEN_ROW,
#define MULTIMODULE_SUBTYPE_ROWS(moduleIdx) isModuleMultimodule(moduleIdx) ? MULTIMODULE_RFPROTO_COLUMNS(moduleIdx) : HIDDEN_ROW,
#define MULTIMODULE_OPTIONS_ROW(moduleIdx) (isModuleMultimodule(moduleIdx) && MULTIMODULE_HASOPTIONS(moduleIdx)) ? (uint8_t) 0: HIDDEN_ROW
#define MODULE_POWER_ROW(moduleIdx) (MULTIMODULE_PROTOCOL_KNOWN(moduleIdx) || isModuleR9MNonAccess(moduleIdx)) ? (isModuleR9MLiteNonPro(moduleIdx) ? (isModuleR9M_FCC_VARIANT(moduleIdx) ? READONLY_ROW : (uint8_t)0) : (uint8_t)0) : HIDDEN_ROW
#define MODULE_POWER_ROW(moduleIdx) (MULTIMODULE_PROTOCOL_KNOWN(moduleIdx) || isModuleR9MNonAccess(moduleIdx)) ? (isModuleR9MLiteNonPro(moduleIdx) ? (isModuleR9M_FCC_VARIANT(moduleIdx) ? READONLY_ROW : (uint8_t)0) : (uint8_t)0) : HIDDEN_ROW
#else
#define MULTIMODULE_STATUS_ROWS(moduleIdx)
@@ -316,9 +316,9 @@ bool check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
if (menuTab && !menuCalibrationState) {
int cc = curr;
switch (event) {
#if defined(PCBX12S)
#if defined(KEYS_GPIO_REG_PGUP)
case EVT_KEY_FIRST(KEY_PGDN):
#elif defined(PCBX10)
#else
case EVT_KEY_BREAK(KEY_PGDN):
#endif
if (s_editMode>0)
@@ -328,8 +328,9 @@ bool check(event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t
cc = 0;
break;
#if defined(KEYS_GPIO_REG_PGUP)
case EVT_KEY_FIRST(KEY_PGUP):
#if defined(PCBX10)
#else
case EVT_KEY_LONG(KEY_PGDN):
#endif
if (s_editMode>0)
+36 -14
View File
@@ -45,30 +45,52 @@ enum FrskyFirmwareModuleProductId {
enum FrskyFirmwareReceiverProductId {
FIRMWARE_ID_RECEIVER_NONE,
FIRMWARE_ID_RECEIVER_ARCHER = 0xC0, // TODO use the right constant
FIRMWARE_ID_RECEIVER_R9MX = 0xF0, // TODO use the right constant
// TODO fill the table
FIRMWARE_ID_RECEIVER_X8R = 0x01,
FIRMWARE_ID_RECEIVER_RX8R = 0x02,
FIRMWARE_ID_RECEIVER_RX8R_PRO = 0x03,
FIRMWARE_ID_RECEIVER_RX6R = 0x04,
FIRMWARE_ID_RECEIVER_RX4R = 0x05,
FIRMWARE_ID_RECEIVER_G_RX8 = 0x06,
FIRMWARE_ID_RECEIVER_G_RX6 = 0x07,
FIRMWARE_ID_RECEIVER_X6R = 0x08,
FIRMWARE_ID_RECEIVER_X4R = 0x09,
FIRMWARE_ID_RECEIVER_X4R_SB = 0x0A,
FIRMWARE_ID_RECEIVER_XSR = 0x0B,
FIRMWARE_ID_RECEIVER_XSR_M = 0x0C,
FIRMWARE_ID_RECEIVER_RXSR = 0x0D,
FIRMWARE_ID_RECEIVER_S6R = 0x0E,
FIRMWARE_ID_RECEIVER_S8R = 0x0F,
FIRMWARE_ID_RECEIVER_XM = 0x10,
FIRMWARE_ID_RECEIVER_XMP = 0x11,
FIRMWARE_ID_RECEIVER_XMR = 0x12,
FIRMWARE_ID_RECEIVER_R9 = 0x13,
FIRMWARE_ID_RECEIVER_R9_SLIM = 0x14,
FIRMWARE_ID_RECEIVER_R9_SLIMP = 0x15,
FIRMWARE_ID_RECEIVER_R9_MINI = 0x16,
FIRMWARE_ID_RECEIVER_R9_MM = 0x17,
FIRMWARE_ID_RECEIVER_R9_STAB = 0x18, // R9_STAB has OTA
FIRMWARE_ID_RECEIVER_R9_MINI_OTA = 0x19, // this one has OTA (different bootloader)
FIRMWARE_ID_RECEIVER_R9_MM_OTA = 0x1A, // this one has OTA (different bootloader)
FIRMWARE_ID_RECEIVER_R9_SLIMP_OTA = 0x1B, // this one has OTA (different bootloader)
FIRMWARE_ID_RECEIVER_ARCHER_X = 0x1C, // this one has OTA (internal module)
FIRMWARE_ID_RECEIVER_R9MX = 0x1D, // this one has OTA
FIRMWARE_ID_RECEIVER_R9SX = 0x1E, // this one has OTA
};
inline bool isReceiverOTAEnabledFromModule(uint8_t moduleIdx, uint8_t productId)
{
switch (productId) {
case FIRMWARE_ID_RECEIVER_ARCHER:
case FIRMWARE_ID_RECEIVER_ARCHER_X:
return isModuleISRM(moduleIdx);
case FIRMWARE_ID_RECEIVER_R9_STAB:
case FIRMWARE_ID_RECEIVER_R9_MINI_OTA:
case FIRMWARE_ID_RECEIVER_R9_MM_OTA:
case FIRMWARE_ID_RECEIVER_R9_SLIMP_OTA:
case FIRMWARE_ID_RECEIVER_R9MX:
case FIRMWARE_ID_RECEIVER_R9SX:
return isModuleR9M(moduleIdx);
// TODO add all those OTA receivers here
/*
"R9-MINI-OTA", // this one has OTA (different bootloader)
"R9-MM-OTA", // this one has OTA (different bootloader)
"R9-SLIM+-OTA", // this one has OTA (different bootloader)
"R9SX", // this one has OTA
*/
default:
return false;
}
+1 -1
View File
@@ -71,7 +71,7 @@ class MultiFirmwareInformation {
bool isMultiInternalFirmware() const
{
return (boardType == FIRMWARE_MULTI_STM && telemetryInversion == false && optibootSupport == true && bootloaderCheck == true && telemetryType == FIRMWARE_MULTI_TELEM_MULTI_TELEMETRY);
return (boardType == FIRMWARE_MULTI_STM && optibootSupport == true && bootloaderCheck == true && telemetryType == FIRMWARE_MULTI_TELEM_MULTI_TELEMETRY);
}
bool isMultiExternalFirmware() const
+1 -3
View File
@@ -71,9 +71,7 @@ const char * logsOpen()
if (!len && filename[i])
len = i+1;
if (len) {
if (filename[i])
filename[i] = zchar2char(filename[i]);
else
if (!filename[i])
filename[i] = '_';
}
i--;
+91 -13
View File
@@ -66,6 +66,10 @@
{ "EVT_"#xxx"_LONG", EVT_KEY_LONG(yyy) }, \
{ "EVT_"#xxx"_REPT", EVT_KEY_REPT(yyy) }
#if defined(LUA) && !defined(CLI)
Fifo<uint8_t, LUA_FIFO_SIZE> * luaRxFifo = nullptr;
#endif
/*luadoc
@function getVersion()
@@ -694,7 +698,8 @@ The list of valid sources is available:
|----------------|-------|
| 2.0 | [all](http://downloads-20.open-tx.org/firmware/lua_fields.txt) |
| 2.1 | [X9D and X9D+](http://downloads-21.open-tx.org/firmware/lua_fields_taranis.txt), [X9E](http://downloads-21.open-tx.org/firmware/lua_fields_taranis_x9e.txt) |
| 2.2 | [X9D and X9D+](http://downloads.open-tx.org/2.2/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.2/firmware/lua_fields_x9e.txt), [Horus](http://downloads.open-tx.org/2.2/firmware/lua_fields_x12s.txt) |
| 2.2 | [X9D and X9D+](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x9e.txt), [Horus](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x12s.txt) |
| 2.3 | [X9D and X9D+](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x9e.txt), [X7](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x7.txt), [Horus](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x12s.txt) |
@param name (string) name of the field
@@ -741,8 +746,8 @@ The list of fixed sources:
|----------------|-------|
| 2.0 | [all](http://downloads-20.open-tx.org/firmware/lua_fields.txt) |
| 2.1 | [X9D and X9D+](http://downloads-21.open-tx.org/firmware/lua_fields_taranis.txt), [X9E](http://downloads-21.open-tx.org/firmware/lua_fields_taranis_x9e.txt) |
| 2.2 | [X9D and X9D+](http://downloads.open-tx.org/2.2/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.2/firmware/lua_fields_x9e.txt), [Horus](http://downloads.open-tx.org/2.2/firmware/lua_fields_x12s.txt) |
| 2.2 | [X9D and X9D+](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x9e.txt), [Horus](http://downloads.open-tx.org/2.2/release/firmware/lua_fields_x12s.txt) |
| 2.3 | [X9D and X9D+](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x9d.txt), [X9E](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x9e.txt), [X7](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x7.txt), [Horus](http://downloads.open-tx.org/2.3/release/firmware/lua_fields_x12s.txt) |
In OpenTX 2.1.x the telemetry sources no longer have a predefined name.
To get a telemetry value simply use it's sensor name. For example:
@@ -1206,11 +1211,14 @@ static int luaPopupWarning(lua_State * L)
}
/*luadoc
@function popupConfirmation(title, event)
@function popupConfirmation(title, event) deprecated, please replace by
@function popupConfirmation(title, message, event)
Raises a pop-up on screen that asks for confirmation
@param title (string) text to display
@param title (string) title to display
@param message (string) text to display
@param event (number) the event variable that is passed in from the
Run function (key pressed)
@@ -1219,13 +1227,24 @@ Run function (key pressed)
@notice Use only from stand-alone and telemetry scripts.
@status current Introduced in 2.2.0
@status current Introduced in 2.2.0, changed to (title, message, event) in 2.3.8
*/
static int luaPopupConfirmation(lua_State * L)
{
event_t event = luaL_checkinteger(L, 2);
warningText = luaL_checkstring(L, 1);
warningType = WARNING_TYPE_CONFIRM;
event_t event;
if (lua_isnone(L, 3)) {
// only two args: deprecated mode
warningText = luaL_checkstring(L, 1);
event = luaL_checkinteger(L, 2);
}
else {
warningText = luaL_checkstring(L, 1);
warningInfoText = luaL_checkstring(L, 2);
event = luaL_optinteger(L, 3, 0);
}
runPopupWarning(event);
if (!warningText) {
lua_pushstring(L, warningResult ? "OK" : "CANCEL");
@@ -1586,6 +1605,13 @@ static int luaSerialWrite(lua_State * L)
while(wr_len--) auxSerialPutc(*p++);
}
#endif
#if defined(AUX2_SERIAL)
if (aux2SerialMode == UART_MODE_LUA) {
size_t wr_len = len;
const char* p = str;
while(wr_len--) aux2SerialPutc(*p++);
}
#endif
#else
debugPrintf("luaSerialWrite: %.*s",len,str);
#endif
@@ -1593,6 +1619,58 @@ static int luaSerialWrite(lua_State * L)
return 0;
}
/*luadoc
@function serialRead([num])
@param num (optional): maximum number of bytes to read.
If non-zero, serialRead will read up to num characters from the buffer.
If 0 or left out, serialRead will read up to and including the first newline character or the end of the buffer.
Note that the returned string may not end in a newline if this character is not present in the buffer.
@retval str string. Empty if no new characters were available.
Reads characters from the serial port. The string is allowed to contain any character, including 0.
@status current Introduced in 2.3.8
*/
static int luaSerialRead(lua_State * L)
{
#if defined(LUA) && !defined(CLI)
int num = luaL_optunsigned(L, 1, 0);
if (!luaRxFifo) {
luaRxFifo = new Fifo<uint8_t, LUA_FIFO_SIZE>();
if (!luaRxFifo) {
lua_pushlstring(L, "", 0);
return 1;
}
}
uint8_t str[LUA_FIFO_SIZE];
uint8_t *p = str;
while (luaRxFifo->pop(*p)) {
p++; // increment only when pop was successful
if (p - str >= LUA_FIFO_SIZE) {
// buffer full
break;
}
if (num == 0) {
if (*(p - 1) == '\n' || *(p - 1) == '\r') {
// found newline
break;
}
}
else if (p - str >= num) {
// requested number of characters reached
break;
}
}
lua_pushlstring(L, (const char*)str, p - str);
#else
lua_pushlstring(L, "", 0);
#endif
return 1;
}
const luaL_Reg opentxLib[] = {
{ "getTime", luaGetTime },
{ "getDateTime", luaGetDateTime },
@@ -1640,6 +1718,7 @@ const luaL_Reg opentxLib[] = {
{ "multiBuffer", luaMultiBuffer },
#endif
{ "serialWrite", luaSerialWrite },
{ "serialRead", luaSerialRead },
{ nullptr, nullptr } /* sentinel */
};
@@ -1649,6 +1728,9 @@ const luaR_value_entry opentxConstants[] = {
{ "DBLSIZE", DBLSIZE },
{ "MIDSIZE", MIDSIZE },
{ "SMLSIZE", SMLSIZE },
#if defined(COLORLCD)
{ "TINSIZE", TINSIZE },
#endif
{ "INVERS", INVERS },
{ "BOLD", BOLD },
{ "BLINK", BLINK },
@@ -1790,9 +1872,7 @@ const luaR_value_entry opentxConstants[] = {
{ "EVT_VIRTUAL_EXIT", EVT_KEY_BREAK(KEY_EXIT) },
#endif
#if defined(KEYS_GPIO_REG_EXIT)
{ "EVT_EXIT_BREAK", EVT_KEY_BREAK(KEY_EXIT) },
#endif
#if defined(KEYS_GPIO_REG_ENTER)
KEY_EVENTS(ENTER, KEY_ENTER),
@@ -1875,8 +1955,6 @@ const luaR_value_entry opentxConstants[] = {
{ "PLAY_BACKGROUND", PLAY_BACKGROUND },
{ "TIMEHOUR", TIMEHOUR },
#if defined(PCBHORUS)
// Adding the unit consts for the set Telemetry function adds about 1k of flash usage
{"UNIT_RAW", UNIT_RAW },
{"UNIT_VOLTS", UNIT_VOLTS },
{"UNIT_AMPS", UNIT_AMPS },
@@ -1910,6 +1988,6 @@ const luaR_value_entry opentxConstants[] = {
{"UNIT_GPS", UNIT_GPS},
{"UNIT_BITFIELD", UNIT_BITFIELD},
{"UNIT_TEXT", UNIT_TEXT},
#endif
{ nullptr, 0 } /* sentinel */
};
+15
View File
@@ -62,6 +62,20 @@ static int luaLcdClear(lua_State *L)
return 0;
}
/*luadoc
@function lcd.resetBacklightTimeout()
Reset the backlight timeout
@status current Introduced in 2.3.6
*/
static int luaLcdResetBacklightTimeout(lua_State * L)
{
if (!luaLcdAllowed) return 0;
resetBacklightTimeout();
return 0;
}
/*luadoc
@function lcd.drawPoint(x, y)
@@ -861,6 +875,7 @@ static int luaRGB(lua_State *L)
const luaL_Reg lcdLib[] = {
{ "refresh", luaLcdRefresh },
{ "clear", luaLcdClear },
{ "resetBacklightTimeout", luaLcdResetBacklightTimeout },
{ "drawPoint", luaLcdDrawPoint },
{ "drawLine", luaLcdDrawLine },
{ "drawRectangle", luaLcdDrawRectangle },
+42 -1
View File
@@ -86,7 +86,24 @@ static int luaModelSetInfo(lua_State *L)
Get RF module parameters
`subType` values:
`Type` values:
* 0 NONE
* 1 PPM
* 2 XJT_PXX1
* 3 ISRM_PXX2
* 4 DSM2
* 5 CROSSFIRE
* 6 MULTIMODULE
* 7 R9M_PXX1
* 8 R9M_PXX2
* 9 R9M_LITE_PXX1
* 10 R9M_LITE_PXX2
* 11 R9M_LITE_PRO_PXX1
* 12 R9M_LITE_PRO_PXX2
* 13 SBUS
* 14 XJT_LITE_PXX2
`subType` values for XJT_PXX1:
* -1 OFF
* 0 D16
* 1 D8
@@ -101,6 +118,11 @@ Get RF module parameters
* `modelId` (number) receiver number
* `firstChannel` (number) start channel (0 is CH1)
* `channelsCount` (number) number of channels sent to module
* `Type` (number) module type
* if the module type is Multi additional information are available
* `protocol` (number) protocol number
* `subProtocol` (number) sub-protocol number
* `channelsOrder` (number) first 4 channels expected order
@status current Introduced in TODO
*/
@@ -114,6 +136,25 @@ static int luaModelGetModule(lua_State *L)
lua_pushtableinteger(L, "modelId", g_model.header.modelId[idx]);
lua_pushtableinteger(L, "firstChannel", module.channelsStart);
lua_pushtableinteger(L, "channelsCount", module.channelsCount + 8);
lua_pushtableinteger(L, "Type", module.type);
#if defined(MULTIMODULE)
if (module.type == MODULE_TYPE_MULTIMODULE) {
int protocol = g_model.moduleData[idx].getMultiProtocol() + 1;
int subprotocol = g_model.moduleData[idx].subType;
convertOtxProtocolToMulti(&protocol, &subprotocol); // Special treatment for the FrSky entry...
lua_pushtableinteger(L, "protocol", protocol);
lua_pushtableinteger(L, "subProtocol", subprotocol);
if (getMultiModuleStatus(idx).isValid()) {
if (getMultiModuleStatus(idx).ch_order == 0xFF)
lua_pushtableinteger(L, "channelsOrder", -1);
else
lua_pushtableinteger(L, "channelsOrder", getMultiModuleStatus(idx).ch_order);
}
else {
lua_pushtableinteger(L, "channelsOrder", -1);
}
}
#endif
}
else {
lua_pushnil(L);
+5
View File
@@ -41,6 +41,11 @@ extern "C" {
#endif
#endif
#if !defined(CLI) || defined(AUX2_SERIAL)
#define LUA_FIFO_SIZE 256
extern Fifo<uint8_t, LUA_FIFO_SIZE> * luaRxFifo;
#endif
extern lua_State * lsScripts;
extern lua_State * lsWidgets;
extern bool luaLcdAllowed;
+5 -9
View File
@@ -457,7 +457,7 @@ void evalInputs(uint8_t mode)
if (mode == e_perout_mode_normal) {
if (tmp==0 || (tmp==1 && (bpanaCenter & mask))) {
anaCenter |= mask;
if ((g_model.beepANACenter & mask) && !(bpanaCenter & mask) && !menuCalibrationState) {
if ((g_model.beepANACenter & mask) && !(bpanaCenter & mask) && s_mixer_first_run_done && !menuCalibrationState) {
if (!IS_POT(i) || IS_POT_SLIDER_AVAILABLE(i)) {
AUDIO_POT_MIDDLE(i);
}
@@ -893,9 +893,7 @@ void evalMixes(uint8_t tick10ms)
static uint16_t fp_act[MAX_FLIGHT_MODES] = {0};
static uint16_t delta = 0;
static ACTIVE_PHASES_TYPE flightModesFade = 0;
LS_RECURSIVE_EVALUATION_RESET();
static uint16_t flightModesFade = 0;
uint8_t fm = getFlightMode();
@@ -907,7 +905,7 @@ void evalMixes(uint8_t tick10ms)
}
else {
uint8_t fadeTime = max(g_model.flightModeData[lastFlightMode].fadeOut, g_model.flightModeData[fm].fadeIn);
ACTIVE_PHASES_TYPE transitionMask = ((ACTIVE_PHASES_TYPE)1 << lastFlightMode) + ((ACTIVE_PHASES_TYPE)1 << fm);
uint16_t transitionMask = (0x01u << lastFlightMode) + (0x01u << fm);
if (fadeTime) {
flightModesFade |= transitionMask;
delta = (MAX_ACT / 10) / fadeTime;
@@ -937,15 +935,13 @@ void evalMixes(uint8_t tick10ms)
if (flightModesFade) {
memclear(sum_chans512, sizeof(sum_chans512));
for (uint8_t p=0; p<MAX_FLIGHT_MODES; p++) {
LS_RECURSIVE_EVALUATION_RESET();
if (flightModesFade & ((ACTIVE_PHASES_TYPE)1 << p)) {
if (flightModesFade & (0x01 << p)) {
mixerCurrentFlightMode = p;
evalFlightModeMixes(p==fm ? e_perout_mode_normal : e_perout_mode_inactive_flight_mode, p==fm ? tick10ms : 0);
for (uint8_t i=0; i<MAX_OUTPUT_CHANNELS; i++)
sum_chans512[i] += (chans[i] >> 4) * fp_act[p];
weight += fp_act[p];
}
LS_RECURSIVE_EVALUATION_RESET();
}
assert(weight);
mixerCurrentFlightMode = fm;
@@ -986,7 +982,7 @@ void evalMixes(uint8_t tick10ms)
if (tick10ms && flightModesFade) {
uint16_t tick_delta = delta * tick10ms;
for (uint8_t p=0; p<MAX_FLIGHT_MODES; p++) {
ACTIVE_PHASES_TYPE flightModeMask = ((ACTIVE_PHASES_TYPE)1 << p);
uint16_t flightModeMask = (0x01 << p);
if (flightModesFade & flightModeMask) {
if (p == fm) {
if (MAX_ACT - fp_act[p] > tick_delta)
+11 -13
View File
@@ -303,9 +303,7 @@ void generalDefault()
g_eeGeneral.stickMode = DEFAULT_MODE - 1;
#endif
#if defined(FRSKY_RELEASE)
g_eeGeneral.templateSetup = 17; /* TAER */
#endif
g_eeGeneral.templateSetup = DEFAULT_TEMPLATE_SETUP;
g_eeGeneral.backlightMode = e_backlight_mode_all;
g_eeGeneral.lightAutoOff = 2;
@@ -510,11 +508,7 @@ void modelDefault(uint8_t id)
}
#endif
#if !defined(EEPROM)
strcpy(g_model.header.name, "Model");
g_model.header.name[5] = '0' + id / 10;
g_model.header.name[6] = '0' + id % 10;
#endif
strAppendUnsigned(strAppend(g_model.header.name, STR_MODEL), id + 1, 2);
#if defined(COLORLCD)
extern const LayoutFactory * defaultLayout;
@@ -696,7 +690,7 @@ void checkBacklight()
if (inputsMoved()) {
inactivity.counter = 0;
if (g_eeGeneral.backlightMode & e_backlight_mode_sticks) {
backlightOn();
resetBacklightTimeout();
}
}
@@ -709,7 +703,7 @@ void checkBacklight()
}
}
void backlightOn()
void resetBacklightTimeout()
{
lightOffCounter = ((uint16_t)g_eeGeneral.lightAutoOff*250) << 1;
}
@@ -736,7 +730,7 @@ void doSplash()
#endif
if (SPLASH_NEEDED()) {
backlightOn();
resetBacklightTimeout();
drawSplash();
#if defined(PCBSKY9X)
@@ -1999,6 +1993,10 @@ void opentxInit()
auxSerialInit(g_eeGeneral.auxSerialMode, modelTelemetryProtocol());
#endif
#if defined(AUX2_SERIAL)
aux2SerialInit(g_eeGeneral.aux2SerialMode, modelTelemetryProtocol());
#endif
#if MENUS_LOCK == 1
getMovedSwitch();
if (TRIMS_PRESSED() && g_eeGeneral.switchUnlockStates==switches_states) {
@@ -2034,7 +2032,7 @@ void opentxInit()
if (g_eeGeneral.backlightMode != e_backlight_mode_off) {
// on Tx start turn the light on
backlightOn();
resetBacklightTimeout();
}
if (!globalData.unexpectedShutdown) {
@@ -2052,7 +2050,7 @@ void opentxInit()
lcdSetContrast();
#endif
backlightOn();
resetBacklightTimeout();
startPulses();
+1 -79
View File
@@ -21,11 +21,7 @@
#ifndef _OPENTX_H_
#define _OPENTX_H_
#include <inttypes.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <math.h>
#include "definitions.h"
#include "opentx_types.h"
#include "debounce.h"
@@ -434,7 +430,6 @@ char char2lower(char c);
int8_t char2zchar(char c);
void str2zchar(char *dest, const char *src, int size);
int zchar2str(char *dest, const char *src, int size);
bool cmpStrWithZchar(const char * charString, const char * zcharString, int size);
#include "keys.h"
#include "pwr.h"
@@ -519,7 +514,6 @@ void logicalSwitchesReset();
void evalLogicalSwitches(bool isCurrentFlightmode=true);
void logicalSwitchesCopyState(uint8_t src, uint8_t dst);
#define LS_RECURSIVE_EVALUATION_RESET()
#if defined(PCBFRSKY) || defined(PCBFLYSKY)
void getSwitchesPosition(bool startup);
@@ -564,34 +558,8 @@ bool setTrimValue(uint8_t phase, uint8_t idx, int trim);
#include "gvars.h"
extern uint16_t sessionTimer;
extern uint16_t s_timeCumThr;
extern uint16_t s_timeCum16ThrP;
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define OVERRIDE_CHANNEL_UNDEFINED -4096
extern safetych_t safetyCh[MAX_OUTPUT_CHANNELS];
#endif
extern uint8_t trimsCheckTimer;
extern uint8_t trimsDisplayTimer;
extern uint8_t trimsDisplayMask;
void flightReset(uint8_t check=true);
PACK(struct GlobalData {
uint8_t unexpectedShutdown:1;
uint8_t externalAntennaEnabled:1;
uint8_t authenticationCount:2;
uint8_t upgradeModulePopup:1;
uint8_t internalModuleVersionChecked:1;
uint8_t spare:2;
});
extern GlobalData globalData;
extern uint16_t maxMixerDuration;
#define DURATION_MS_PREC2(x) ((x)/20)
#if defined(THRTRACE)
@@ -652,7 +620,7 @@ static inline void GET_ADC_IF_MIXER_NOT_RUNNING()
#include "sbus.h"
void backlightOn();
void resetBacklightTimeout();
void checkBacklight();
uint16_t isqrt32(uint32_t n);
@@ -733,14 +701,9 @@ extern const char vers_stamp[];
const char * getOtherVersion(char * buffer);
#define g_blinkTmr10ms (*(uint8_t*)&g_tmr10ms)
extern uint8_t g_beepCnt;
#include "trainer.h"
extern int32_t chans[MAX_OUTPUT_CHANNELS];
extern int16_t ex_chans[MAX_OUTPUT_CHANNELS]; // Outputs (before LIMITS) of the last perMain
extern int16_t channelOutputs[MAX_OUTPUT_CHANNELS];
int expo(int x, int k);
inline void getMixSrcRange(const int source, int16_t & valMin, int16_t & valMax, LcdFlags * flags = 0)
@@ -813,33 +776,15 @@ int16_t applyLimits(uint8_t channel, int32_t value);
void evalInputs(uint8_t mode);
uint16_t anaIn(uint8_t chan);
extern int16_t calibratedAnalogs[NUM_CALIBRATED_ANALOGS];
#define FLASH_DURATION 20 /*200ms*/
extern uint8_t beepAgain;
extern uint16_t lightOffCounter;
extern uint8_t flashCounter;
extern uint8_t mixWarning;
FlightModeData * flightModeAddress(uint8_t idx);
ExpoData * expoAddress(uint8_t idx);
MixData * mixAddress(uint8_t idx);
LimitData * limitAddress(uint8_t idx);
LogicalSwitchData * lswAddress(uint8_t idx);
// static variables used in evalFlightModeMixes - moved here so they don't interfere with the stack
// It's also easier to initialize them here.
extern int8_t virtualInputsTrims[MAX_INPUTS];
extern int16_t anas [MAX_INPUTS];
extern int16_t trims[NUM_TRIMS];
extern BeepANACenter bpanaCenter;
extern uint8_t s_mixer_first_run_done;
void applyDefaultTemplate();
void instantTrim();
void evalTrims();
void copyTrimsToOffset(uint8_t ch);
@@ -847,20 +792,6 @@ void copySticksToOffset(uint8_t ch);
void copyMinMaxToOutputs(uint8_t ch);
void moveTrimsToOffsets();
typedef uint16_t ACTIVE_PHASES_TYPE;
#define DELAY_POS_MARGIN 3
typedef int16_t delayval_t;
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;
});
extern SwOn swOn[MAX_MIXERS];
extern int32_t act[MAX_MIXERS];
inline bool isExpoActive(uint8_t expo)
{
return swOn[expo].activeExpo;
@@ -1028,15 +959,6 @@ void setMFP();
void clearMFP();
#endif
extern uint8_t requiredSpeakerVolume;
enum MainRequest {
REQUEST_SCREENSHOT,
REQUEST_FLIGHT_RESET,
};
extern uint8_t mainRequestFlags;
void checkBattery();
void opentxClose(uint8_t shutdown=true);
void opentxInit();
+3
View File
@@ -53,6 +53,9 @@ static const char * options[] = {
#if defined(HORUS_STICKS)
"horussticks",
#endif
#if defined(INTERNAL_GPS)
"internalgps",
#endif
#if defined(INTERNAL_MODULE_PPM)
"internalppm",
#endif
+32 -17
View File
@@ -103,62 +103,75 @@ enum ModuleSubtypeR9M {
enum ModuleSubtypeMulti {
MODULE_SUBTYPE_MULTI_FIRST = 0,
MODULE_SUBTYPE_MULTI_FLYSKY = MODULE_SUBTYPE_MULTI_FIRST,
MODULE_SUBTYPE_MULTI_HUBSAN,
MODULE_SUBTYPE_MULTI_FRSKY,
MODULE_SUBTYPE_MULTI_HISKY,
MODULE_SUBTYPE_MULTI_V2X2,
MODULE_SUBTYPE_MULTI_DSM2,
MODULE_SUBTYPE_MULTI_HUBSAN, //1
MODULE_SUBTYPE_MULTI_FRSKY, //2
MODULE_SUBTYPE_MULTI_HISKY, //3
MODULE_SUBTYPE_MULTI_V2X2, //4
MODULE_SUBTYPE_MULTI_DSM2, //5
MODULE_SUBTYPE_MULTI_DEVO,
MODULE_SUBTYPE_MULTI_YD717,
MODULE_SUBTYPE_MULTI_KN,
MODULE_SUBTYPE_MULTI_SYMAX,
MODULE_SUBTYPE_MULTI_SLT,
MODULE_SUBTYPE_MULTI_SLT, //10
MODULE_SUBTYPE_MULTI_CX10,
MODULE_SUBTYPE_MULTI_CG023,
MODULE_SUBTYPE_MULTI_BAYANG,
MODULE_SUBTYPE_MULTI_ESky,
MODULE_SUBTYPE_MULTI_MT99XX,
MODULE_SUBTYPE_MULTI_MT99XX, //15
MODULE_SUBTYPE_MULTI_MJXQ,
MODULE_SUBTYPE_MULTI_SHENQI,
MODULE_SUBTYPE_MULTI_FY326,
MODULE_SUBTYPE_MULTI_SFHSS,
MODULE_SUBTYPE_MULTI_J6PRO,
MODULE_SUBTYPE_MULTI_J6PRO, //20
MODULE_SUBTYPE_MULTI_FQ777,
MODULE_SUBTYPE_MULTI_ASSAN,
MODULE_SUBTYPE_MULTI_HONTAI,
MODULE_SUBTYPE_MULTI_OLRS,
MODULE_SUBTYPE_MULTI_FS_AFHDS2A,
MODULE_SUBTYPE_MULTI_FS_AFHDS2A, //25
MODULE_SUBTYPE_MULTI_Q2X2,
MODULE_SUBTYPE_MULTI_WK_2X01,
MODULE_SUBTYPE_MULTI_Q303,
MODULE_SUBTYPE_MULTI_GW008,
MODULE_SUBTYPE_MULTI_DM002,
MODULE_SUBTYPE_MULTI_DM002, //30
MODULE_SUBTYPE_MULTI_CABELL,
MODULE_SUBTYPE_MULTI_ESKY150,
MODULE_SUBTYPE_MULTI_H83D,
MODULE_SUBTYPE_MULTI_CORONA,
MODULE_SUBTYPE_MULTI_CFLIE,
MODULE_SUBTYPE_MULTI_CFLIE, //35
MODULE_SUBTYPE_MULTI_HITEC,
MODULE_SUBTYPE_MULTI_WFLY,
MODULE_SUBTYPE_MULTI_BUGS,
MODULE_SUBTYPE_MULTI_BUGS_MINI,
MODULE_SUBTYPE_MULTI_TRAXXAS,
MODULE_SUBTYPE_MULTI_TRAXXAS, //40
MODULE_SUBTYPE_MULTI_NCC1701,
MODULE_SUBTYPE_MULTI_E01X,
MODULE_SUBTYPE_MULTI_V911S,
MODULE_SUBTYPE_MULTI_GD00X,
MODULE_SUBTYPE_MULTI_V761,
MODULE_SUBTYPE_MULTI_V761, //45
MODULE_SUBTYPE_MULTI_KF606,
MODULE_SUBTYPE_MULTI_REDPINE,
MODULE_SUBTYPE_MULTI_POTENSIC,
MODULE_SUBTYPE_MULTI_ZSX,
MODULE_SUBTYPE_MULTI_FLYZONE,
MODULE_SUBTYPE_MULTI_FLYZONE, //50
MODULE_SUBTYPE_MULTI_SCANNER,
MODULE_SUBTYPE_MULTI_FRSKYX_RX,
MODULE_SUBTYPE_MULTI_AFHDS2A_RX,
MODULE_SUBTYPE_MULTI_HOTT,
MODULE_SUBTYPE_MULTI_FX816,
MODULE_SUBTYPE_MULTI_LAST = MODULE_SUBTYPE_MULTI_FX816
MODULE_SUBTYPE_MULTI_FX816, //55
MODULE_SUBTYPE_MULTI_BAYANG_RX,
MODULE_SUBTYPE_MULTI_PELIKAN,
MODULE_SUBTYPE_MULTI_TIGER,
MODULE_SUBTYPE_MULTI_XK,
MODULE_SUBTYPE_MULTI_XN297DUMP, //60
MODULE_SUBTYPE_MULTI_FRSKYX2,
MODULE_SUBTYPE_MULTI_FRSKY_R9,
MODULE_SUBTYPE_MULTI_PROPEL,
MODULE_SUBTYPE_MULTI_FRSKYL,
MODULE_SUBTYPE_MULTI_SKYARTEC,
MODULE_SUBTYPE_MULTI_ESKY150V2,
MODULE_SUBTYPE_MULTI_DSM_RX,
MODULE_SUBTYPE_MULTI_JJRC345,
MODULE_SUBTYPE_MULTI_LAST = MODULE_SUBTYPE_MULTI_JJRC345
};
#define MODULE_SUBTYPE_MULTI_XN297DP 63-3
@@ -176,7 +189,9 @@ enum MMRFrskySubtypes {
MM_RF_FRSKY_SUBTYPE_D16_8CH,
MM_RF_FRSKY_SUBTYPE_V8,
MM_RF_FRSKY_SUBTYPE_D16_LBT,
MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH
MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH,
MM_RF_FRSKY_SUBTYPE_D8_CLONED,
MM_RF_FRSKY_SUBTYPE_D16_CLONED
};
enum ModuleSubtypeDSM2 {
+12 -1
View File
@@ -26,6 +26,7 @@
#include "opentx_helpers.h"
#include "telemetry/telemetry.h"
#include "storage/storage.h"
#include "globals.h"
#if defined(MULTIMODULE)
#include "telemetry/multi.h"
@@ -57,7 +58,7 @@ inline uint8_t getMaxMultiSubtype(uint8_t moduleIdx)
const mm_protocol_definition *pdef = getMultiProtocolDefinition(g_model.moduleData[moduleIdx].getMultiProtocol());
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKY) {
return 5;
return 7;
}
if (g_model.moduleData[moduleIdx].getMultiProtocol() > MODULE_SUBTYPE_MULTI_LAST) {
@@ -584,6 +585,14 @@ inline void setDefaultPpmFrameLength(uint8_t moduleIdx)
g_model.moduleData[moduleIdx].ppm.frameLength = 4 * max<int>(0, g_model.moduleData[moduleIdx].channelsCount);
}
inline void resetAccessAuthenticationCount()
{
#if defined(ACCESS_LIB)
// the module will reset on mode switch, we need to reset the authentication counter
globalData.authenticationCount = 0;
#endif
}
inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType)
{
ModuleData & moduleData = g_model.moduleData[moduleIdx];
@@ -594,6 +603,8 @@ inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType)
moduleData.sbus.refreshRate = -31;
else if (moduleData.type == MODULE_TYPE_PPM)
setDefaultPpmFrameLength(moduleIdx);
else
resetAccessAuthenticationCount();
}
extern bool isExternalAntennaEnabled();
+48 -33
View File
@@ -244,6 +244,50 @@ void sendChannels(uint8_t moduleIdx)
}
}
void convertOtxProtocolToMulti(int *protocol, int *subprotocol)
{
// Special treatment for the FrSky entry...
if (*protocol == MODULE_SUBTYPE_MULTI_FRSKY +1) {
if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D8) {
//D8
*protocol = 3;
*subprotocol = 0;
}
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D8_CLONED) {
//D8
*protocol = 3;
*subprotocol = 1;
}
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_V8) {
//V8
*protocol = 25;
*subprotocol = 0;
}
else {
*protocol = 15;
if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D16_8CH)
*subprotocol = 1;
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D16)
*subprotocol = 0; // D16
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D16_LBT)
*subprotocol = 2;
else if (*subprotocol == MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH)
*subprotocol = 3;
else
*subprotocol = 4; // D16_CLONED
}
}
else {
// 15 for Multimodule is FrskyX or D16 which we map as a protocol of 3 (FrSky)
// all protos > frskyx are therefore also off by one
if (*protocol >= 15)
*protocol = *protocol + 1;
// 25 is again a FrSky *protocol (FrskyV) so shift again
if (*protocol >= 25)
*protocol = *protocol + 1;
}
}
void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
{// byte 1+2, protocol information
@@ -268,8 +312,7 @@ void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
protoByte |= MULTI_SEND_RANGECHECK;
// rfProtocol
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_DSM2) {
if (type == MODULE_SUBTYPE_MULTI_DSM2 +1 ) {
// Autobinding should always be done in DSMX 11ms
if (g_model.moduleData[moduleIdx].multi.autoBindMode && moduleState[moduleIdx].mode == MODULE_MODE_BIND)
subtype = MM_RF_DSM2_SUBTYPE_AUTO;
@@ -279,39 +322,11 @@ void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
optionValue = 0x80 | sentModuleChannels(moduleIdx); // Max throw
else
optionValue = sentModuleChannels(moduleIdx);
}
// 15 for Multimodule is FrskyX or D16 which we map as a subprotocol of 3 (FrSky)
// all protos > frskyx are therefore also off by one
if (type >= 15)
type = type + 1;
// 25 is again a FrSky protocol (FrskyV) so shift again
if (type >= 25)
type = type + 1;
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FRSKY) {
if (subtype == MM_RF_FRSKY_SUBTYPE_D8) {
//D8
type = 3;
subtype = 0;
} else if (subtype == MM_RF_FRSKY_SUBTYPE_V8) {
//V8
type = 25;
subtype = 0;
} else {
type = 15;
if (subtype == MM_RF_FRSKY_SUBTYPE_D16_8CH) // D16 8ch
subtype = 1;
else if (subtype == MM_RF_FRSKY_SUBTYPE_D16)
subtype = 0; // D16
else if (subtype == MM_RF_FRSKY_SUBTYPE_D16_LBT)
subtype = 2;
else
subtype = 3; // MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH
}
}
// Special treatment for the FrSky entry...
convertOtxProtocolToMulti(&type, &subtype);
// Set the highest bit of option byte in AFHDS2A protocol to instruct MULTI to passthrough telemetry bytes instead
// of sending Frsky D telemetry
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FS_AFHDS2A)
+1
View File
@@ -24,6 +24,7 @@
#include "pulses_common.h"
void multiPatchCustom(uint8_t moduleIdx);
void convertOtxProtocolToMulti(int *protocol, int *subprotocol);
class UartMultiPulses: public DataBuffer<uint8_t, 64>
{
+1 -3
View File
@@ -308,9 +308,7 @@ static void enablePulsesInternalModule(uint8_t protocol)
#if defined(PXX2)
case PROTOCOL_CHANNELS_PXX2_HIGHSPEED:
intmoduleSerialStart(PXX2_HIGHSPEED_BAUDRATE, true, USART_Parity_No, USART_StopBits_1, USART_WordLength_8b);
#if defined(HARDWARE_INTERNAL_MODULE) && defined(INTERNAL_MODULE_PXX2) && defined(ACCESS_LIB)
globalData.authenticationCount = 0;
#endif
resetAccessAuthenticationCount();
break;
#endif
+3 -3
View File
@@ -172,10 +172,10 @@ void Pxx2Pulses::setupRegisterFrame(uint8_t module)
if (reusableBuffer.moduleSetup.pxx2.registerStep == REGISTER_RX_NAME_SELECTED) {
Pxx2Transport::addByte(0x01);
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
Pxx2Transport::addByte(zchar2char(reusableBuffer.moduleSetup.pxx2.registerRxName[i]));
Pxx2Transport::addByte(reusableBuffer.moduleSetup.pxx2.registerRxName[i]);
}
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
Pxx2Transport::addByte(zchar2char(g_model.modelRegistrationID[i]));
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
}
Pxx2Transport::addByte(reusableBuffer.moduleSetup.pxx2.registerLoopIndex);
}
@@ -291,7 +291,7 @@ void Pxx2Pulses::setupAccessBindFrame(uint8_t module)
else {
Pxx2Transport::addByte(0x00); // DATA0
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
Pxx2Transport::addByte(zchar2char(g_model.modelRegistrationID[i]));
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
}
}
}
+7 -7
View File
@@ -357,7 +357,7 @@ bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen
constexpr uint32_t TEXT_FILE_MAXSIZE = 2048;
void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS + 1], int & lines_count)
void sdReadTextFile(const char * filename, char lines[TEXT_VIEWER_LINES][LCD_COLS + 1], int & lines_count)
{
FIL file;
int result;
@@ -368,17 +368,17 @@ void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS +
char escape_chars[4] = {0};
int current_line = 0;
memclear(lines, NUM_BODY_LINES * (LCD_COLS + 1));
memclear(lines, TEXT_VIEWER_LINES * (LCD_COLS + 1));
result = f_open(&file, filename, FA_OPEN_EXISTING | FA_READ);
if (result == FR_OK) {
for (uint32_t i = 0; i < TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz) == FR_OK && sz == 1 && (lines_count == 0 || current_line - menuVerticalOffset < int(NUM_BODY_LINES)); i++) {
for (uint32_t i = 0; i < TEXT_FILE_MAXSIZE && f_read(&file, &c, 1, &sz) == FR_OK && sz == 1 && (lines_count == 0 || current_line - menuVerticalOffset < int(TEXT_VIEWER_LINES)); i++) {
if (c == '\n') {
++current_line;
line_length = 0;
escape = 0;
}
else if (c != '\r' && current_line >= menuVerticalOffset && current_line - menuVerticalOffset < int(NUM_BODY_LINES) && line_length < LCD_COLS) {
else if (c != '\r' && current_line >= menuVerticalOffset && current_line - menuVerticalOffset < int(TEXT_VIEWER_LINES) && line_length < LCD_COLS) {
if (c == '\\' && escape == 0) {
escape = 1;
continue;
@@ -386,15 +386,15 @@ void sdReadTextFile(const char * filename, char lines[NUM_BODY_LINES][LCD_COLS +
else if (c != '\\' && escape > 0 && escape < sizeof(escape_chars)) {
escape_chars[escape - 1] = c;
if (escape == 2 && !strncmp(escape_chars, "up", 2)) {
c = '\300';
c = CHAR_UP;
}
else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) {
c = '\301';
c = CHAR_DOWN;
}
else if (escape == 3) {
int val = atoi(escape_chars);
if (val >= 200 && val < 225) {
c = '\200' + val-200;
c = '\200' + val - 200;
}
}
else {
+4
View File
@@ -34,6 +34,10 @@ void serialPutc(char c) {
if (auxSerialTracesEnabled())
auxSerialPutc(c);
#endif
#if defined(AUX2_SERIAL)
if (aux2SerialTracesEnabled())
aux2SerialPutc(c);
#endif
}
void serialPrintf(const char * format, ...)
@@ -401,7 +401,7 @@ void convertRadioData_218_to_219(RadioData & settings)
#if defined(PCBHORUS)
// 2 new pots from X10:
// - copy btw. 'chkSum' and 'auxSerialMode' (excl.)
memcpy(&settings.chkSum, &oldSettings.chkSum, offsetof(RadioData, auxSerialMode) - offsetof(RadioData, chkSum));
memcpy(&settings.chkSum, &oldSettings.chkSum, offsetof(RadioData, switchConfig) - sizeof(uint8_t) - offsetof(RadioData, chkSum));
// - move calibration data
memcpy(&settings.calib[NUM_STICKS + 5], &oldSettings.calib[NUM_STICKS + 3], sizeof(CalibData) * (STORAGE_NUM_SLIDERS + STORAGE_NUM_MOUSE_ANALOGS));
memclear(&settings.calib[NUM_STICKS + 3], sizeof(CalibData) * 2);
+2 -4
View File
@@ -465,13 +465,11 @@ const char * eeBackupModel(uint8_t i_fileSrc)
uint8_t i = sizeof(MODELS_PATH)+sizeof(g_model.header.name)-1;
uint8_t len = 0;
while (i>sizeof(MODELS_PATH)-1) {
while (i > sizeof(MODELS_PATH)-1) {
if (!len && buf[i])
len = i+1;
if (len) {
if (buf[i])
buf[i] = zchar2char(buf[i]);
else
if (!buf[i])
buf[i] = '_';
}
i--;
+4 -16
View File
@@ -84,20 +84,10 @@ int zchar2str(char * dest, const char * src, int size)
return size+1;
}
bool cmpStrWithZchar(const char * charString, const char * zcharString, int size)
{
for (int i=0; i<size; i++) {
if (charString[i] != zchar2char(zcharString[i])) {
return false;
}
}
return true;
}
unsigned int effectiveLen(const char * str, unsigned int size)
{
while (size > 0) {
if (str[size-1] != ' ')
if (str[size-1] != ' ' && str[size-1] != '\0')
return size;
size--;
}
@@ -137,9 +127,7 @@ char * strcat_zchar(char * dest, const char * name, uint8_t size, const char * d
if (!len && dest[i])
len = i+1;
if (len) {
if (dest[i])
dest[i] = zchar2char(dest[i]);
else
if (!dest[i])
dest[i] = '_';
}
i--;
@@ -392,7 +380,7 @@ char * getSourceString(char * dest, mixsrc_t idx)
}
else if (idx <= MIXSRC_LAST_INPUT) {
idx -= MIXSRC_FIRST_INPUT;
*dest = '\314';
*dest = CHAR_INPUT;
if (strlen(g_model.inputNames[idx])) {
memset(dest + 1, 0, LEN_INPUT_NAME);
strncpy(dest + 1, g_model.inputNames[idx], LEN_INPUT_NAME);
@@ -406,7 +394,7 @@ char * getSourceString(char * dest, mixsrc_t idx)
#if defined(LUA_MODEL_SCRIPTS)
div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
*dest++ = '\322';
*dest++ = CHAR_LUA;
// *dest++ = '1'+qr.quot;
strcpy(dest, scriptInputsOutputs[qr.quot].outputs[qr.rem].name);
}
+1 -1
View File
@@ -648,7 +648,7 @@ void checkSwitches()
}
LED_ERROR_BEGIN();
backlightOn();
resetBacklightTimeout();
// first - display warning
#if defined(PCBSKY9X)
@@ -25,7 +25,7 @@
#elif defined(RADIO_T16)
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,1, -1,1, -1,1};
#elif defined(RADIO_TX16S)
const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1,1, -1,1, -1,1};
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,1, -1,1, -1,1};
#elif defined(PCBX10)
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, 1,1, 1, -1};
#elif defined(PCBX9E)

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