mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-10 14:18:12 +00:00
Update DSM FwdPrg.lua
This commit is contained in:
parent
15a254879c
commit
5639def6fb
@ -35,25 +35,15 @@ local RX_VERSION, WAIT_CMD, MENU_TITLE, MENU_LINES, MENU_VALUES, VALUE_CHANGING,
|
|||||||
local MENU, LIST_MENU_NOCHANGING, LIST_MENU2, PERCENTAGE_VALUE = 0x1C, 0x6C, 0x4C, 0xC0
|
local MENU, LIST_MENU_NOCHANGING, LIST_MENU2, PERCENTAGE_VALUE = 0x1C, 0x6C, 0x4C, 0xC0
|
||||||
local Phase = RX_VERSION
|
local Phase = RX_VERSION
|
||||||
local Waiting_RX = 0
|
local Waiting_RX = 0
|
||||||
local Prev_Menu = 0
|
|
||||||
local Cur_Menu = -1
|
|
||||||
local Next_line = -1
|
|
||||||
local RX_Version = ""
|
|
||||||
local Menu_Title = ""
|
|
||||||
local Menu_Line = {}
|
|
||||||
local Next_Menu = {}
|
|
||||||
local Menu_Value = {}
|
|
||||||
local Menu_Type = {}
|
|
||||||
local Menu_Value_Max = {}
|
|
||||||
local Menu_Value_Min = {}
|
|
||||||
local Menu_Value_Def = {}
|
|
||||||
local Text = {}
|
local Text = {}
|
||||||
local Retry=100
|
local Retry=100
|
||||||
local Selected_Line=-1
|
|
||||||
local Menu_Edit = nil
|
|
||||||
local Blink = 0
|
local Blink = 0
|
||||||
local Value_Changed=0
|
local Value_Changed=0
|
||||||
|
|
||||||
|
local Menu = { Cur=nil, Id=nil, Title="", Prev=nil, PrevId=nil, Next=nil, NextId=nil, Back=nil, BackId=nil, CurLine=nil, SelLine=nil, EditLine=nil }
|
||||||
|
local Line = {}
|
||||||
|
local RX = { Name="", Version="" }
|
||||||
|
|
||||||
local function conv_int16(number)
|
local function conv_int16(number)
|
||||||
if number >= 0x8000 then
|
if number >= 0x8000 then
|
||||||
return number - 0x10000
|
return number - 0x10000
|
||||||
@ -61,6 +51,14 @@ local function conv_int16(number)
|
|||||||
return number
|
return number
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function Get_Text(index)
|
||||||
|
out = Text[index]
|
||||||
|
if out == nil then -- unknown...
|
||||||
|
out = "Unknown_"..string.format("%X",index)
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
local function DSM_Release()
|
local function DSM_Release()
|
||||||
multiBuffer( 0, 0 )
|
multiBuffer( 0, 0 )
|
||||||
end
|
end
|
||||||
@ -73,96 +71,118 @@ local function DSM_Send(...)
|
|||||||
multiBuffer( 3, 0x70+#arg)
|
multiBuffer( 3, 0x70+#arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function Value_Add(dir)
|
||||||
|
local line=Line[Menu.SelLine]
|
||||||
|
Speed = getRotEncSpeed()
|
||||||
|
if Speed == ROTENC_MIDSPEED then
|
||||||
|
line.Val = line.Val + (5 * dir)
|
||||||
|
elseif Speed == ROTENC_HIGHSPEED then
|
||||||
|
line.Val = line.Val + (15 * dir)
|
||||||
|
else
|
||||||
|
line.Val = line.Val + dir
|
||||||
|
end
|
||||||
|
if line.Val > line.Max then
|
||||||
|
line.Val = line.Max
|
||||||
|
elseif line.Val < line.Min then
|
||||||
|
line.Val = line.Min
|
||||||
|
end
|
||||||
|
if Line[Menu.SelLine].Type ~= LIST_MENU_NOCHANGING then
|
||||||
|
Phase = VALUE_CHANGING
|
||||||
|
Waiting_RX = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function DSM_Menu(event)
|
local function DSM_Menu(event)
|
||||||
local Speed = 0
|
local Speed = 0
|
||||||
if event == EVT_VIRTUAL_NEXT then
|
if event == EVT_VIRTUAL_NEXT then
|
||||||
if Menu_Edit == nil then
|
if Menu.EditLine == nil then
|
||||||
-- not changing a value
|
-- not changing a value
|
||||||
if Selected_Line ~= -1 and Selected_Line < 6 then
|
if Menu.SelLine ~= nil then
|
||||||
for line = Selected_Line + 1, 6, 1 do
|
if Menu.SelLine < 7 then
|
||||||
if Menu_Line[line] ~= "" and Next_Menu[line] ~= Cur_Menu then
|
local num = Menu.SelLine
|
||||||
Selected_Line=line
|
for i = Menu.SelLine + 1, 6, 1 do
|
||||||
break
|
if Line[i].Type ~= nil and Line[i].Next ~= nil then
|
||||||
|
Menu.SelLine=i
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
if num == Menu.SelLine then
|
||||||
|
if Menu.Next ~= 0 then -- Next
|
||||||
|
Menu.SelLine = 7
|
||||||
|
elseif Menu.Prev ~= 0 then -- Prev
|
||||||
|
Menu.SelLine = 8
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Menu.Prev ~= 0 then -- Prev
|
||||||
|
Menu.SelLine = 8
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else -- need to inc the value
|
||||||
-- need to inc the value
|
Value_Add(1)
|
||||||
if Menu_Value[Selected_Line] < Menu_Value_Max[Selected_Line] then
|
|
||||||
Speed = getRotEncSpeed()
|
|
||||||
if Speed == ROTENC_MIDSPEED then
|
|
||||||
Menu_Value[Selected_Line] = Menu_Value[Selected_Line] + 5
|
|
||||||
elseif Speed == ROTENC_HIGHSPEED then
|
|
||||||
Menu_Value[Selected_Line] = Menu_Value[Selected_Line] + 15
|
|
||||||
else
|
|
||||||
Menu_Value[Selected_Line] = Menu_Value[Selected_Line] + 1
|
|
||||||
end
|
|
||||||
if Menu_Value[Selected_Line] > Menu_Value_Max[Selected_Line] then
|
|
||||||
Menu_Value[Selected_Line] = Menu_Value_Max[Selected_Line]
|
|
||||||
end
|
|
||||||
if Menu_Type[Selected_Line] ~= LIST_MENU_NOCHANGING then
|
|
||||||
Phase = VALUE_CHANGING
|
|
||||||
Waiting_RX = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elseif event == EVT_VIRTUAL_PREV then
|
elseif event == EVT_VIRTUAL_PREV then
|
||||||
if Menu_Edit == nil then
|
if Menu.EditLine == nil then
|
||||||
if Selected_Line > 0 then
|
if Menu.SelLine ~= nil then
|
||||||
for line = Selected_Line-1, 0, -1 do
|
if Menu.SelLine == 8 and Menu.Next ~= 0 then
|
||||||
if Menu_Line[line] ~= "" and Next_Menu[line] ~= Cur_Menu then
|
Menu.SelLine = 7
|
||||||
Selected_Line=line
|
elseif Menu.SelLine > 0 then
|
||||||
break
|
if Menu.SelLine > 6 then
|
||||||
|
Menu.SelLine = 7
|
||||||
|
end
|
||||||
|
local num = Menu.SelLine
|
||||||
|
for i = Menu.SelLine-1, 0, -1 do
|
||||||
|
if Line[i].Type ~= nil and Line[i].Next ~= nil then
|
||||||
|
Menu.SelLine=i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if num == Menu.SelLine then -- Back
|
||||||
|
Menu.SelLine = -1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- need to dec the value
|
|
||||||
if Menu_Value[Selected_Line] > Menu_Value_Min[Selected_Line] then
|
|
||||||
Speed = getRotEncSpeed()
|
|
||||||
if Speed == ROTENC_MIDSPEED then
|
|
||||||
Menu_Value[Selected_Line] = Menu_Value[Selected_Line] - 5
|
|
||||||
elseif Speed == ROTENC_HIGHSPEED then
|
|
||||||
Menu_Value[Selected_Line] = Menu_Value[Selected_Line] - 15
|
|
||||||
else
|
else
|
||||||
Menu_Value[Selected_Line] = Menu_Value[Selected_Line] - 1
|
Menu.SelLine = -1 -- Back
|
||||||
end
|
|
||||||
if Menu_Value[Selected_Line] < Menu_Value_Min[Selected_Line] then
|
|
||||||
Menu_Value[Selected_Line] = Menu_Value_Min[Selected_Line]
|
|
||||||
end
|
|
||||||
if Menu_Type[Selected_Line] ~= LIST_MENU_NOCHANGING then
|
|
||||||
Phase = VALUE_CHANGING
|
|
||||||
Waiting_RX = 0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else -- need to dec the value
|
||||||
|
Value_Add(-1)
|
||||||
end
|
end
|
||||||
elseif event == EVT_VIRTUAL_ENTER then
|
elseif event == EVT_VIRTUAL_ENTER then
|
||||||
if Selected_Line ~= -1 then
|
if Menu.SelLine == -1 then -- Back
|
||||||
if Menu_Type[Selected_Line] == MENU then -- Menu entry
|
Menu.Cur = Menu.Back
|
||||||
if Next_Menu[Selected_Line] ~= nil then -- Next menu exist
|
Menu.Id = Menu.BackId
|
||||||
Cur_Menu = Next_Menu[Selected_Line]
|
Menu.SelLine = 0
|
||||||
Phase = MENU_TITLE
|
Phase = MENU_TITLE
|
||||||
Waiting_RX = 0
|
Waiting_RX = 0
|
||||||
end
|
elseif Menu.SelLine == 7 then -- Next
|
||||||
|
Menu.Cur = Menu.Next
|
||||||
|
Menu.Id = Menu.NextId
|
||||||
|
Menu.SelLine = 0
|
||||||
|
Phase = MENU_TITLE
|
||||||
|
Waiting_RX = 0
|
||||||
|
elseif Menu.SelLine == 8 then -- Prev
|
||||||
|
Menu.Cur = Menu.Prev
|
||||||
|
Menu.Id = Menu.PrevId
|
||||||
|
Menu.SelLine = 0
|
||||||
|
Phase = MENU_TITLE
|
||||||
|
Waiting_RX = 0
|
||||||
|
elseif Menu.SelLine ~= nil and Line[Menu.SelLine].Next ~= nil then
|
||||||
|
if Line[Menu.SelLine].Type == MENU then -- Next menu exist
|
||||||
|
Menu.Cur = Line[Menu.SelLine].Next
|
||||||
|
Menu.Id = Line[Menu.SelLine].NextId
|
||||||
|
Phase = MENU_TITLE
|
||||||
|
Waiting_RX = 0
|
||||||
else
|
else
|
||||||
-- value entry
|
-- value entry
|
||||||
if Menu_Edit == Selected_Line then
|
if Menu.EditLine == Menu.SelLine then
|
||||||
Menu_Edit = nil
|
Menu.EditLine = nil
|
||||||
Value_Changed=0
|
Value_Changed = 0
|
||||||
Phase = VALUE_CHANGED
|
Phase = VALUE_CHANGED
|
||||||
Waiting_RX = 0
|
Waiting_RX = 0
|
||||||
else
|
else
|
||||||
Menu_Edit = Selected_Line
|
Menu.EditLine = Menu.SelLine
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif event == EVT_VIRTUAL_PREV_PAGE then
|
|
||||||
killEvents(event)
|
|
||||||
if Cur_Menu ~= 0 then
|
|
||||||
Cur_Menu = Prev_Menu
|
|
||||||
Phase = MENU_TITLE
|
|
||||||
Waiting_RX = 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -175,49 +195,49 @@ local function DSM_Send_Receive()
|
|||||||
elseif Phase == WAIT_CMD then -- keep connection open
|
elseif Phase == WAIT_CMD then -- keep connection open
|
||||||
DSM_Send(0x00,0x04,0x00,0x00)
|
DSM_Send(0x00,0x04,0x00,0x00)
|
||||||
elseif Phase == MENU_TITLE then -- request menu title
|
elseif Phase == MENU_TITLE then -- request menu title
|
||||||
if Cur_Menu == -1 then
|
if Menu.Cur == nil then
|
||||||
DSM_Send(0x12,0x06,0x00,0x14,0x00,0x00)
|
DSM_Send(0x12,0x06,0x00,0x14,0x00,0x00) -- first menu only
|
||||||
Cur_Menu = 0
|
Menu.Cur = 0
|
||||||
else
|
else
|
||||||
DSM_Send(0x16,0x06,0x10,Cur_Menu,0x00,0x01) -- last byte is 0 or 1=unknown...
|
DSM_Send(0x16,0x06,Menu.Id,Menu.Cur,0x00,Menu.SelLine)
|
||||||
end
|
end
|
||||||
elseif Phase == MENU_LINES then -- request menu lines
|
elseif Phase == MENU_LINES then -- request menu lines
|
||||||
if Cur_Line == -1 then
|
if Menu.CurLine == nil then
|
||||||
DSM_Send(0x13,0x04,0x10,Cur_Menu) -- line 0
|
DSM_Send(0x13,0x04,Menu.Id,Menu.Cur) -- line 0
|
||||||
elseif Cur_Line >= 0x80 then
|
elseif Menu.CurLine >= 0x80 then
|
||||||
local last_byte={0x40,0x01,0x02,0x04,0x00,0x00} -- unknown...
|
local last_byte={0x40,0x01,0x02,0x04,0x00,0x00} -- unknown...
|
||||||
DSM_Send(0x20,0x06,Cur_Line-0x80,Cur_Line-0x80,0x00,last_byte[Cur_Line-0x80+1]) -- line X
|
DSM_Send(0x20,0x06,Menu.CurLine-0x80,Menu.CurLine-0x80,0x00,last_byte[Menu.CurLine-0x80+1]) -- line X
|
||||||
else
|
else
|
||||||
DSM_Send(0x14,0x06,0x10,Cur_Menu,0x00,Cur_Line) -- line X
|
DSM_Send(0x14,0x06,Menu.Id,Menu.Cur,0x00,Menu.CurLine) -- line X
|
||||||
end
|
end
|
||||||
elseif Phase == MENU_VALUES then -- request menu values
|
elseif Phase == MENU_VALUES then -- request menu values
|
||||||
DSM_Send(0x15,0x06,0x10,Cur_Menu,0x10,Cur_Line) -- line X
|
DSM_Send(0x15,0x06,Menu.Id,Menu.Cur,Line[Menu.CurLine].ValId,Menu.CurLine) -- line X
|
||||||
elseif Phase == VALUE_CHANGING then -- send value
|
elseif Phase == VALUE_CHANGING then -- send value
|
||||||
local value=Menu_Value[Selected_Line]
|
local value=Line[Menu.SelLine].Val
|
||||||
if value < 0 then
|
if value < 0 then
|
||||||
value = 0x10000 + value
|
value = 0x10000 + value
|
||||||
end
|
end
|
||||||
DSM_Send(0x18,0x06,0x10,Selected_Line,bit32.rshift(value,8),bit32.band(value,0xFF)) -- send current value
|
DSM_Send(0x18,0x06,Line[Menu.SelLine].ValId,Menu.SelLine,bit32.rshift(value,8),bit32.band(value,0xFF)) -- send current value
|
||||||
Phase = VALUE_CHANGING_WAIT
|
Phase = VALUE_CHANGING_WAIT
|
||||||
elseif Phase == VALUE_CHANGED then -- send value
|
elseif Phase == VALUE_CHANGED then -- send value
|
||||||
if Value_Changed == 0 then
|
if Value_Changed == 0 then
|
||||||
local value=Menu_Value[Selected_Line]
|
local value=Line[Menu.SelLine].Val
|
||||||
if value < 0 then
|
if value < 0 then
|
||||||
value = 0x10000 + value
|
value = 0x10000 + value
|
||||||
end
|
end
|
||||||
DSM_Send(0x18,0x06,0x10,Selected_Line,bit32.rshift(value,8),bit32.band(value,0xFF)) -- send current value
|
DSM_Send(0x18,0x06,Line[Menu.SelLine].ValId,Menu.SelLine,bit32.rshift(value,8),bit32.band(value,0xFF)) -- send current value
|
||||||
Value_Changed = Value_Changed + 1
|
Value_Changed = Value_Changed + 1
|
||||||
Waiting_RX = 0
|
Waiting_RX = 0
|
||||||
elseif Value_Changed == 1 then
|
elseif Value_Changed == 1 then
|
||||||
DSM_Send(0x19,0x06,0x10,Selected_Line) -- validate
|
DSM_Send(0x19,0x06,Line[Menu.SelLine].ValId,Menu.SelLine) -- validate
|
||||||
-- Value_Changed = Value_Changed + 1
|
-- Value_Changed = Value_Changed + 1
|
||||||
-- Waiting_RX = 0
|
-- Waiting_RX = 0
|
||||||
--elseif Value_Changed == 2 then
|
--elseif Value_Changed == 2 then
|
||||||
-- DSM_Send(0x1B,0x06,0x10,Selected_Line) -- validate again?
|
-- DSM_Send(0x1B,0x06,0x10,Menu.SelLine) -- validate again?
|
||||||
-- Value_Changed = Value_Changed + 1
|
-- Value_Changed = Value_Changed + 1
|
||||||
end
|
end
|
||||||
elseif Phase == VALUE_CHANGING_WAIT then
|
elseif Phase == VALUE_CHANGING_WAIT then
|
||||||
DSM_Send(0x1A,0x06,0x10,Selected_Line)
|
DSM_Send(0x1A,0x06,Line[Menu.SelLine].ValId,Menu.SelLine)
|
||||||
end
|
end
|
||||||
multiBuffer(10,0x00);
|
multiBuffer(10,0x00);
|
||||||
Retry = 50
|
Retry = 50
|
||||||
@ -225,58 +245,79 @@ local function DSM_Send_Receive()
|
|||||||
-- Answer received
|
-- Answer received
|
||||||
--if multiBuffer(11) == 0x00 then -- waiting for commands?
|
--if multiBuffer(11) == 0x00 then -- waiting for commands?
|
||||||
if multiBuffer(11) == 0x01 then -- read version
|
if multiBuffer(11) == 0x01 then -- read version
|
||||||
RX_Version = multiBuffer(14).."."..multiBuffer(15).."."..multiBuffer(16)
|
--ex: 0x09 0x01 0x00 0x15 0x02 0x22 0x01 0x00 0x14 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
|
RX.Name = Get_Text(multiBuffer(13))
|
||||||
|
RX.Version = multiBuffer(14).."."..multiBuffer(15).."."..multiBuffer(16)
|
||||||
Phase = MENU_TITLE
|
Phase = MENU_TITLE
|
||||||
elseif multiBuffer(11) == 0x02 then -- read menu title
|
elseif multiBuffer(11) == 0x02 then -- read menu title
|
||||||
Menu_Title = Text[multiBuffer(14)+multiBuffer(15)*256]
|
--ex: 0x09 0x02 0x4F 0x10 0xA5 0x00 0x00 0x00 0x50 0x10 0x10 0x10 0x00 0x00 0x00 0x00
|
||||||
if Menu_Title == nil then -- missing text...
|
Menu.Cur = multiBuffer(12)
|
||||||
Menu_Title = "Unknown_"..string.format("%X",multiBuffer(14)+multiBuffer(15)*256)
|
Menu.Id = multiBuffer(13)
|
||||||
|
Menu.Title = Get_Text(multiBuffer(14)+multiBuffer(15)*256)
|
||||||
|
Menu.Prev = multiBuffer(16)
|
||||||
|
Menu.PrevId = multiBuffer(17)
|
||||||
|
Menu.Next = multiBuffer(18)
|
||||||
|
Menu.NextId = multiBuffer(19)
|
||||||
|
Menu.Back = multiBuffer(20)
|
||||||
|
Menu.BackId = multiBuffer(21)
|
||||||
|
for i = 0, 6 do -- clear menu
|
||||||
|
Line[i] = { Menu = nil, Id = nil, Type = nil, Text="", Next = nil, NextId = nil, ValLine = nil, ValId = nil, Min, Max, Def, Val, Unit, Step }
|
||||||
end
|
end
|
||||||
for line = 0, 6 do -- clear menu
|
Menu.CurLine = nil
|
||||||
Menu_Line[line] = ""
|
if Menu.Next ~= 0 then
|
||||||
Next_Menu[line] = nil
|
Menu.SelLine = 7 -- highlight Next
|
||||||
Menu_Type[line] = nil
|
else
|
||||||
|
Menu.SelLine = -1 -- highlight Back
|
||||||
end
|
end
|
||||||
Menu_Edit = nil
|
|
||||||
Blink = 0
|
Blink = 0
|
||||||
Prev_Menu = multiBuffer(20)
|
|
||||||
Cur_Line = -1
|
|
||||||
Selected_Line = -1
|
|
||||||
Phase = MENU_LINES
|
Phase = MENU_LINES
|
||||||
elseif multiBuffer(11) == 0x03 then -- read menu lines
|
elseif multiBuffer(11) == 0x03 then -- read menu lines
|
||||||
Cur_Line = multiBuffer(14)
|
--ex: 0x09 0x03 0x00 0x10 0x00 0x1C 0xF9 0x00 0x10 0x10 0x00 0x00 0x00 0x00 0x03 0x00
|
||||||
Menu_Type[Cur_Line] = multiBuffer(15) -- not quite sure yet: 1C is text menu only, 4C/6C is text menu followed by text list, C0 is text menu followed by percentage value
|
-- Menu Id line Type Text_idx Next V_Id Val_Min Val_Max Val_Def
|
||||||
Menu_Line[Cur_Line] = Text[multiBuffer(16)+multiBuffer(17)*256]
|
--ex: 0x09 0x03 0x61 0x10 0x00 0x6C 0x50 0x00 0x00 0x10 0x36 0x00 0x49 0x00 0x36 0x00
|
||||||
if Menu_Line[Cur_Line] == nil then -- missing text...
|
Menu.CurLine = multiBuffer(14)
|
||||||
Menu_Line[Cur_Line] = "Unknown_"..string.format("%X",multiBuffer(16)+multiBuffer(17)*256)
|
local line = Line[Menu.CurLine]
|
||||||
|
line.Menu = multiBuffer(12)
|
||||||
|
line.Id = multiBuffer(13) -- not quite sure yet
|
||||||
|
line.Type = multiBuffer(15) -- not quite sure yet: 1C is text menu only, 4C/6C is text followed by text list, C0 is text followed by percentage value
|
||||||
|
line.Text = Get_Text(multiBuffer(16)+multiBuffer(17)*256)
|
||||||
|
if multiBuffer(18) == Menu.Cur then
|
||||||
|
line.Next = nil
|
||||||
|
else
|
||||||
|
line.Next = multiBuffer(18) -- not quite sure yet: 1C=text menu=>next menu, others=>line number of the value
|
||||||
end
|
end
|
||||||
Next_Menu[Cur_Line] = multiBuffer(18)
|
if Menu.SelLine == -1 and line.Next ~= nil then -- Auto select first line of the menu
|
||||||
if Selected_Line == -1 and Next_Menu[Cur_Line] ~= Cur_Menu then -- Auto select first line of the menu
|
Menu.SelLine = Menu.CurLine
|
||||||
Selected_Line = multiBuffer(14)
|
|
||||||
end
|
end
|
||||||
Menu_Value_Min[Cur_Line] = conv_int16(multiBuffer(20)+multiBuffer(21)*256)
|
line.NextId = multiBuffer(19) -- not quite sure yet
|
||||||
Menu_Value_Max[Cur_Line] = conv_int16(multiBuffer(22)+multiBuffer(23)*256)
|
line.ValLine = multiBuffer(18) -- not quite sure yet
|
||||||
Menu_Value_Def[Cur_Line] = conv_int16(multiBuffer(24)+multiBuffer(25)*256)
|
line.ValId = multiBuffer(19) -- not quite sure yet
|
||||||
if Menu_Type[Cur_Line] == 0x1C then
|
line.Min = conv_int16(multiBuffer(20)+multiBuffer(21)*256)
|
||||||
|
line.Max = conv_int16(multiBuffer(22)+multiBuffer(23)*256)
|
||||||
|
line.Def = conv_int16(multiBuffer(24)+multiBuffer(25)*256)
|
||||||
|
if line.Type == MENU then
|
||||||
-- nothing to do on menu entries
|
-- nothing to do on menu entries
|
||||||
elseif Menu_Type[Cur_Line] == LIST_MENU_NOCHANGING or Menu_Type[Cur_Line] == LIST_MENU2 then
|
elseif line.Type == LIST_MENU_NOCHANGING or line.Type == LIST_MENU2 then
|
||||||
Menu_Value[Cur_Line] = Menu_Value_Def[Cur_Line] - Menu_Value_Min[Cur_Line] -- use default value not sure if needed
|
line.Val = nil --line.Def - line.Min -- use default value not sure if needed
|
||||||
Menu_Value_Def[Cur_Line] = Menu_Value_Min[Cur_Line] -- pointer to the start of the list in Text
|
line.Def = line.Min -- pointer to the start of the list in Text
|
||||||
Menu_Value_Max[Cur_Line] = Menu_Value_Max[Cur_Line] - Menu_Value_Min[Cur_Line] -- max index
|
line.Max = line.Max - line.Min -- max index
|
||||||
Menu_Value_Min[Cur_Line] = 0 -- min index
|
line.Min = 0 -- min index
|
||||||
else -- default to numerical value
|
else -- default to numerical value
|
||||||
Menu_Value[Cur_Line] = Menu_Value_Def[Cur_Line] -- use default value not sure if needed
|
line.Val = nil --line.Def -- use default value not sure if needed
|
||||||
end
|
end
|
||||||
if Menu_Type[Cur_Line] ~= 0x1C then -- value to follow
|
if line.Type ~= 0x1C then -- value to follow
|
||||||
Menu_Line[Cur_Line] = Menu_Line[Cur_Line]..":"
|
line.Text = line.Text..":"
|
||||||
end
|
end
|
||||||
Phase = MENU_LINES
|
Phase = MENU_LINES
|
||||||
elseif multiBuffer(11) == 0x04 then -- read menu values
|
elseif multiBuffer(11) == 0x04 then -- read menu values
|
||||||
Cur_Line = multiBuffer(14)
|
--ex: 0x09 0x04 0x53 0x10 0x00 0x10 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
Menu_Value[Cur_Line] = conv_int16(multiBuffer(16)+multiBuffer(17)*256)
|
-- Menu MeId line VaId Value
|
||||||
|
--ex: 0x09 0x04 0x61 0x10 0x02 0x10 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||||
|
Menu.CurLine = multiBuffer(14)
|
||||||
|
Line[Menu.CurLine].Val = conv_int16(multiBuffer(16)+multiBuffer(17)*256)
|
||||||
Phase = MENU_VALUES
|
Phase = MENU_VALUES
|
||||||
elseif multiBuffer(11) == 0x05 then -- unknown... need to get through the lines...
|
elseif multiBuffer(11) == 0x05 then -- unknown... need to get through the lines...
|
||||||
Cur_Line = 0x80 + multiBuffer(12)
|
Menu.CurLine = 0x80 + multiBuffer(12)
|
||||||
Phase = MENU_LINES
|
Phase = MENU_LINES
|
||||||
elseif multiBuffer(11) == 0x00 and Phase == VALUE_CHANGING then
|
elseif multiBuffer(11) == 0x00 and Phase == VALUE_CHANGING then
|
||||||
Phase = VALUE_CHANGING_WAIT
|
Phase = VALUE_CHANGING_WAIT
|
||||||
@ -299,8 +340,6 @@ local function DSM_Send_Receive()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function DSM_Display()
|
local function DSM_Display()
|
||||||
local line
|
|
||||||
|
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
if LCD_W == 480 then
|
if LCD_W == 480 then
|
||||||
--Draw title
|
--Draw title
|
||||||
@ -310,41 +349,66 @@ local function DSM_Display()
|
|||||||
if Phase == RX_VERSION then
|
if Phase == RX_VERSION then
|
||||||
lcd.drawText(10,50,"No compatible DSM RX...", BLINK)
|
lcd.drawText(10,50,"No compatible DSM RX...", BLINK)
|
||||||
else
|
else
|
||||||
local attrib=0;
|
if Menu.Title ~= nil then
|
||||||
lcd.drawText(50,32,Menu_Title)
|
local attrib=0;
|
||||||
for line = 0, 6 do
|
lcd.drawText(80,32,Menu.Title,MIDSIZE)
|
||||||
if line == Selected_Line then
|
for i = 0, 6 do
|
||||||
attrib = INVERS
|
if i == Menu.SelLine then
|
||||||
else
|
attrib = INVERS
|
||||||
attrib = 0
|
|
||||||
end
|
|
||||||
if Menu_Type[line] ~= nil and Menu_Type[line] ~= MENU then
|
|
||||||
local text=""
|
|
||||||
if Menu_Type[line] == LIST_MENU_NOCHANGING or Menu_Type[line] == LIST_MENU2 then
|
|
||||||
text = Text[Menu_Value[line]+Menu_Value_Def[line]]
|
|
||||||
if text == nil then
|
|
||||||
text = "Unknown_"..Menu_Value[line]+Menu_Value_Def[line]
|
|
||||||
end
|
|
||||||
elseif Menu_Type[line] == PERCENTAGE_VALUE then
|
|
||||||
text = Menu_Value[line].." %"
|
|
||||||
else
|
else
|
||||||
text = Menu_Value[line]
|
attrib = 0
|
||||||
end
|
end
|
||||||
if Menu_Edit == Selected_Line then
|
if Line[i] ~= nil and Line[i].Type ~= nil then
|
||||||
Blink = Blink + 1
|
if Line[i].Type ~= MENU then-- list/value
|
||||||
if Blink > 25 then
|
if Line[i].Val ~= nil then
|
||||||
attrib = 0
|
local text=""
|
||||||
if Blink > 50 then
|
if Line[i].Type == LIST_MENU_NOCHANGING or Line[i].Type == LIST_MENU2 then
|
||||||
Blink = 0
|
text = Get_Text(Line[i].Val+Line[i].Def)
|
||||||
|
elseif Line[i].Type == PERCENTAGE_VALUE then
|
||||||
|
text = Line[i].Val.." %"
|
||||||
|
else
|
||||||
|
text = Line[i].Val
|
||||||
|
end
|
||||||
|
if Menu.EditLine == Menu.SelLine then -- blink edited entry
|
||||||
|
Blink = Blink + 1
|
||||||
|
if Blink > 25 then
|
||||||
|
attrib = 0
|
||||||
|
if Blink > 50 then
|
||||||
|
Blink = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
lcd.drawText(240,32+20*(i+2), text, attrib) -- display value
|
||||||
end
|
end
|
||||||
|
attrib = 0
|
||||||
end
|
end
|
||||||
|
lcd.drawText(10,32+20*(i+2), Line[i].Text, attrib) -- display text
|
||||||
end
|
end
|
||||||
lcd.drawText(240,32+20*(line+2),text,attrib)
|
|
||||||
attrib = 0
|
|
||||||
end
|
end
|
||||||
lcd.drawText(10,32+20*(line+2),Menu_Line[line], attrib)
|
if Menu.SelLine == -1 then
|
||||||
|
lcd.drawText(437,32, "Back", INVERS)
|
||||||
|
else
|
||||||
|
lcd.drawText(437,32, "Back", 0)
|
||||||
|
end
|
||||||
|
lcd.drawRectangle(437-5, 32-2, 48, 25)
|
||||||
|
if Menu.Next ~= 0 then
|
||||||
|
if Menu.SelLine == 7 then
|
||||||
|
lcd.drawText(437,220, "Next",INVERS)
|
||||||
|
else
|
||||||
|
lcd.drawText(437,220, "Next")
|
||||||
|
end
|
||||||
|
lcd.drawRectangle(437-5, 220-2, 48, 25)
|
||||||
|
end
|
||||||
|
if Menu.Prev ~= 0 then
|
||||||
|
if Menu.SelLine == 8 then
|
||||||
|
lcd.drawText(5,220, "Prev",INVERS)
|
||||||
|
else
|
||||||
|
lcd.drawText(5,220, "Prev")
|
||||||
|
end
|
||||||
|
lcd.drawRectangle(5-5, 220-2, 48, 25)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
lcd.drawText(10,252,"RX v"..RX_Version)
|
lcd.drawText(170,252, "RX "..RX.Name.." v"..RX.Version) -- display RX info
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- --Draw RX Menu on LCD_W=128
|
-- --Draw RX Menu on LCD_W=128
|
||||||
@ -391,7 +455,12 @@ local function DSM_Init()
|
|||||||
multiBuffer( 0, string.byte('D') )
|
multiBuffer( 0, string.byte('D') )
|
||||||
multiBuffer( 1, string.byte('S') )
|
multiBuffer( 1, string.byte('S') )
|
||||||
multiBuffer( 2, string.byte('M') )
|
multiBuffer( 2, string.byte('M') )
|
||||||
|
|
||||||
--Text to be displayed -> need to use a file instead?
|
--Text to be displayed -> need to use a file instead?
|
||||||
|
--RX names--
|
||||||
|
Text[0x0014]="SPM4651T"
|
||||||
|
Text[0x0015]="AR637T"
|
||||||
|
--Lists--
|
||||||
Text[0x0036]="Throttle"
|
Text[0x0036]="Throttle"
|
||||||
Text[0x0037]="Aileron"
|
Text[0x0037]="Aileron"
|
||||||
Text[0x0038]="Elevator"
|
Text[0x0038]="Elevator"
|
||||||
@ -407,8 +476,11 @@ local function DSM_Init()
|
|||||||
Text[0x004B]="Main Menu"
|
Text[0x004B]="Main Menu"
|
||||||
Text[0x004E]="Position"
|
Text[0x004E]="Position"
|
||||||
Text[0x0050]="Outputs"
|
Text[0x0050]="Outputs"
|
||||||
|
--Text[0x005E]="Inhibit"
|
||||||
Text[0x005F]="Hold Last"
|
Text[0x005F]="Hold Last"
|
||||||
Text[0x0060]="Preset"
|
Text[0x0060]="Preset"
|
||||||
|
--Text[0x0061]="Custom"
|
||||||
|
--Messages--
|
||||||
Text[0x0090]="Apply"
|
Text[0x0090]="Apply"
|
||||||
Text[0x0093]="Complete"
|
Text[0x0093]="Complete"
|
||||||
Text[0x0094]="Done"
|
Text[0x0094]="Done"
|
||||||
@ -423,10 +495,30 @@ local function DSM_Init()
|
|||||||
Text[0x0103]="before continuing setup."
|
Text[0x0103]="before continuing setup."
|
||||||
Text[0x0104]=""
|
Text[0x0104]=""
|
||||||
Text[0x0105]=""
|
Text[0x0105]=""
|
||||||
|
Text[0x0106]="Any wing type, channel assignment,"
|
||||||
|
Text[0x0107]="subtrim, or servo reversing changes"
|
||||||
|
Text[0x0108]="require running through initial"
|
||||||
|
Text[0x0109]="setup again."
|
||||||
|
Text[0x010A]=""
|
||||||
|
Text[0x010B]=""
|
||||||
|
|
||||||
Text[0x019C]="Enter Receiver Bind Mode"
|
Text[0x019C]="Enter Receiver Bind Mode"
|
||||||
Text[0x020A]="Restore from Backup"
|
Text[0x020A]="Restore from Backup"
|
||||||
Text[0x0209]="Save to Backup"
|
Text[0x0209]="Save to Backup"
|
||||||
|
|
||||||
|
Text[0x021A]="Set the model level,"
|
||||||
|
Text[0x021B]="and press Continue."
|
||||||
|
Text[0x021C]=""
|
||||||
|
Text[0x021D]=""
|
||||||
|
|
||||||
|
Text[0x021F]="Set the model on its nose,"
|
||||||
|
Text[0x0220]="and press Continue. If the"
|
||||||
|
Text[0x0221]="orientation on the next"
|
||||||
|
Text[0x0222]="screen is wrong go back"
|
||||||
|
Text[0x0223]="and try again."
|
||||||
|
Text[0x0224]="Continue"
|
||||||
|
Text[0x0229]="Set Orientation Manually"
|
||||||
|
|
||||||
Text[0x0227]="Other settings"
|
Text[0x0227]="Other settings"
|
||||||
Text[0x022B]="WARNING!"
|
Text[0x022B]="WARNING!"
|
||||||
Text[0x022C]="This will reset the"
|
Text[0x022C]="This will reset the"
|
||||||
@ -444,11 +536,6 @@ local function DSM_Init()
|
|||||||
Text[0x0238]="that which is in"
|
Text[0x0238]="that which is in"
|
||||||
Text[0x0239]="the backup memory."
|
Text[0x0239]="the backup memory."
|
||||||
Text[0x023A]=""
|
Text[0x023A]=""
|
||||||
|
|
||||||
--Lines to be displayed
|
|
||||||
for line = 0, 6 do -- clear lines
|
|
||||||
Menu_Line[line]=""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Main
|
-- Main
|
||||||
|
Loading…
x
Reference in New Issue
Block a user