mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 18:48:11 +00:00
Multi config: enabled by default, LUA script update
This commit is contained in:
parent
58ed8ca60f
commit
d0db7829e5
@ -27,77 +27,406 @@
|
||||
-- Write
|
||||
-- Write at address 5..11 the command
|
||||
-- Write 0x01 at address 4 will send the command to the module
|
||||
-- !! Before exiting the script must write 0 at address 0 for normal operation !!
|
||||
--###############################################################################
|
||||
|
||||
local Version = "v0.2"
|
||||
local Focus = -1
|
||||
local Page = 0
|
||||
local Edit = -1
|
||||
local Edit_pos = 1
|
||||
local Menu = { {text = "", field_type = 0, field_len = 0, field_value = {}, field_text = ""},
|
||||
{text = "", field_type = 0, field_len = 0, field_value = {}, field_text = ""},
|
||||
{text = "", field_type = 0, field_len = 0, field_value = {}, field_text = ""},
|
||||
{text = "", field_type = 0, field_len = 0, field_value = {}, field_text = ""},
|
||||
{text = "", field_type = 0, field_len = 0, field_value = {}, field_text = ""},
|
||||
{text = "", field_type = 0, field_len = 0, field_value = {}, field_text = ""},
|
||||
{text = "", field_type = 0, field_len = 0, field_value = {}, field_text = ""} }
|
||||
local Menu_value = {}
|
||||
local Blink = 0
|
||||
local ModuleNumber = 0
|
||||
local ModuleType = ""
|
||||
local Module = {}
|
||||
local InitialProtocol = 0
|
||||
|
||||
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 Config_Send(page, line, value)
|
||||
local i
|
||||
i = (page*16) + line
|
||||
multiBuffer( 5, i )
|
||||
for i = 1 , 6 , 1 do
|
||||
multiBuffer( 5+i, value[i] )
|
||||
end
|
||||
multiBuffer( 4, 1 )
|
||||
end
|
||||
|
||||
local function Config_Release()
|
||||
--Set the protocol back to what it was
|
||||
Module.protocol = InitialProtocol
|
||||
model.setModule(ModuleNumber, Module)
|
||||
|
||||
--Stop requesting updates
|
||||
local i
|
||||
for i = 3 , 0 , -1 do
|
||||
multiBuffer( i, 0 )
|
||||
end
|
||||
end
|
||||
|
||||
local function Config_Page( event )
|
||||
local function Config_Page( )
|
||||
Config_Send(Page, 0, { 0, 0, 0, 0, 0, 0 })
|
||||
end
|
||||
|
||||
local function Config_Menu( event )
|
||||
local function Config_Draw_Edit( event )
|
||||
local i
|
||||
local text
|
||||
|
||||
if Menu[Focus].field_type == 0xD0 then
|
||||
-- Editable Hex value
|
||||
if Edit == -1 then
|
||||
-- Init
|
||||
Edit = 0
|
||||
Edit_pos = 1
|
||||
Blink = 0
|
||||
for i = 1, Menu[Focus].field_len, 1 do
|
||||
Menu_value[i] = Menu[Focus].field_value[i]
|
||||
end
|
||||
end
|
||||
if Edit == 0 then
|
||||
-- Not editing value
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
if Edit_pos > Menu[Focus].field_len then
|
||||
-- Save or Cancel
|
||||
Edit = -1
|
||||
if Edit_pos == Menu[Focus].field_len + 1 then
|
||||
-- Save
|
||||
Config_Send(Page, Focus, Menu_value)
|
||||
end
|
||||
return
|
||||
else
|
||||
-- Switch to edit mode
|
||||
Edit = 1
|
||||
end
|
||||
elseif event == EVT_VIRTUAL_PREV and Edit_pos > 1 then
|
||||
-- Move cursor
|
||||
Edit_pos = Edit_pos - 1
|
||||
elseif event == EVT_VIRTUAL_NEXT and Edit_pos < Menu[Focus].field_len + 2 then
|
||||
-- Move cursor
|
||||
Edit_pos = Edit_pos + 1
|
||||
end
|
||||
else
|
||||
-- Editing value
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
-- End edit
|
||||
Edit = 0
|
||||
elseif event == EVT_VIRTUAL_PREV then
|
||||
-- Change value
|
||||
Menu_value[Edit_pos] = Menu_value[Edit_pos] - 1
|
||||
elseif event == EVT_VIRTUAL_NEXT then
|
||||
-- Change value
|
||||
Menu_value[Edit_pos] = Menu_value[Edit_pos] + 1
|
||||
end
|
||||
--Blink
|
||||
Blink = Blink + 1
|
||||
if Blink > 30 then
|
||||
Blink = 0
|
||||
end
|
||||
end
|
||||
--Display
|
||||
if LCD_W == 480 then
|
||||
lcd.drawRectangle(160-1, 100-1, 160+2, 55+2, TEXT_COLOR)
|
||||
lcd.drawFilledRectangle(160, 100, 160, 55, TEXT_BGCOLOR)
|
||||
else
|
||||
lcd.clear()
|
||||
end
|
||||
for i = 1, Menu[Focus].field_len, 1 do
|
||||
if i==Edit_pos and (Edit ~= 1 or Blink > 15) then
|
||||
attrib = INVERS
|
||||
else
|
||||
attrib = 0
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(170+12*2*(i-1), 110, string.format('%02X', Menu_value[i]), attrib)
|
||||
else
|
||||
lcd.drawText(17+6*2*(i-1), 10, string.format('%02X', Menu_value[i]), attrib + SMLSIZE)
|
||||
end
|
||||
end
|
||||
if Edit_pos == Menu[Focus].field_len + 1 then
|
||||
attrib = INVERS
|
||||
else
|
||||
attrib = 0
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(170, 130, "Save", attrib)
|
||||
else
|
||||
lcd.drawText(17, 30, "Save", attrib + SMLSIZE)
|
||||
end
|
||||
if Edit_pos == Menu[Focus].field_len + 2 then
|
||||
attrib = INVERS
|
||||
else
|
||||
attrib = 0
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(260, 130, "Cancel", attrib)
|
||||
else
|
||||
lcd.drawText(77, 30, "Cancel", attrib + SMLSIZE)
|
||||
end
|
||||
|
||||
elseif Menu[Focus].field_type == 0x90 then
|
||||
-- Action text
|
||||
if Edit == -1 then
|
||||
-- Init
|
||||
Edit = 0
|
||||
Edit_pos = 2
|
||||
end
|
||||
if event == EVT_VIRTUAL_ENTER then
|
||||
-- Exit
|
||||
Edit = -1
|
||||
if Edit_pos == 1 then
|
||||
-- Yes
|
||||
Config_Send(Page, Focus, { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA } )
|
||||
end
|
||||
return
|
||||
elseif event == EVT_VIRTUAL_PREV and Edit_pos > 1 then
|
||||
-- Switch to Yes
|
||||
Edit_pos = Edit_pos - 1
|
||||
elseif event == EVT_VIRTUAL_NEXT and Edit_pos < 2 then
|
||||
-- Switch to No
|
||||
Edit_pos = Edit_pos + 1
|
||||
end
|
||||
-- Display
|
||||
if LCD_W == 480 then
|
||||
lcd.drawRectangle(160-1, 100-1, 160+2, 55+2, TEXT_COLOR)
|
||||
lcd.drawFilledRectangle(160, 100, 160, 55, TEXT_BGCOLOR)
|
||||
else
|
||||
lcd.clear()
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(170, 110, Menu[Focus].field_text .. "?")
|
||||
else
|
||||
lcd.drawText(17, 10, Menu[Focus].field_text .. "?", SMLSIZE)
|
||||
end
|
||||
if Edit_pos == 1 then
|
||||
attrib = INVERS
|
||||
else
|
||||
attrib = 0
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(170, 130, "Yes", attrib)
|
||||
else
|
||||
lcd.drawText(17, 30, "Yes", attrib + SMLSIZE)
|
||||
end
|
||||
if Edit_pos == 2 then
|
||||
attrib = INVERS
|
||||
else
|
||||
attrib = 0
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(260, 130, "No", attrib)
|
||||
else
|
||||
lcd.drawText(77, 30, "No", attrib)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function Config_Draw_LCD()
|
||||
local function Config_Next_Prev( event )
|
||||
-- Next Prev on main menu
|
||||
local line
|
||||
if event == EVT_VIRTUAL_PREV then
|
||||
for line = Focus - 1, 1, -1 do
|
||||
if Menu[line].field_type >= 0x80 and Menu[line].field_type ~= 0xA0 and Menu[line].field_type ~= 0xC0 then
|
||||
Focus = line
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif event == EVT_VIRTUAL_NEXT then
|
||||
for line = Focus + 1, 7, 1 do
|
||||
if Menu[line].field_type >= 0x80 and Menu[line].field_type ~= 0xA0 and Menu[line].field_type ~= 0xC0 then
|
||||
Focus = line
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function Config_Draw_Menu()
|
||||
-- Main menu
|
||||
local i
|
||||
local value
|
||||
local line
|
||||
local result
|
||||
local offset=0
|
||||
local length
|
||||
local text
|
||||
|
||||
lcd.clear()
|
||||
|
||||
if LCD_W == 480 then
|
||||
--Draw title
|
||||
lcd.drawFilledRectangle(0, 0, LCD_W, 30, TITLE_BGCOLOR)
|
||||
lcd.drawText(1, 5, "Multi Config " .. Version, MENU_TITLE_COLOR)
|
||||
if multiBuffer(13) == 0x00 then
|
||||
lcd.drawText(1, 5, "Multi Config", MENU_TITLE_COLOR)
|
||||
lcd.drawText(10,50,"No Config telemetry...", BLINK)
|
||||
end
|
||||
else
|
||||
--Draw on LCD_W=128
|
||||
lcd.drawText(1, 0, "Multi Config " .. Version, SMLSIZE)
|
||||
if multiBuffer(13) == 0x00 then
|
||||
lcd.drawText(2,17,"No Config telemetry...",SMLSIZE)
|
||||
end
|
||||
end
|
||||
|
||||
if multiBuffer(13) ~= 0x00 then
|
||||
if LCD_W == 480 then
|
||||
--Draw firmware version and channels order
|
||||
local ch_order = multiBuffer(17)
|
||||
local channel_names = {}
|
||||
channel_names[bitand(ch_order,3)+1] = "A"
|
||||
ch_order = math.floor(ch_order/4)
|
||||
channel_names[bitand(ch_order,3)+1] = "E"
|
||||
ch_order = math.floor(ch_order/4)
|
||||
channel_names[bitand(ch_order,3)+1] = "T"
|
||||
ch_order = math.floor(ch_order/4)
|
||||
channel_names[bitand(ch_order,3)+1] = "R"
|
||||
lcd.drawText(150, 5, ModuleType.." v" .. multiBuffer(13) .. "." .. multiBuffer(14) .. "." .. multiBuffer(15) .. "." .. multiBuffer(16) .. " " .. channel_names[1] .. channel_names[2] .. channel_names[3] .. channel_names[4], MENU_TITLE_COLOR)
|
||||
else
|
||||
lcd.drawText(1, 5, "Multi Config v" .. string.char(multiBuffer(13)) .. "." .. string.char(multiBuffer(14)) .. "." .. string.char(multiBuffer(15)) .. "." .. string.char(multiBuffer(16)), MENU_TITLE_COLOR)
|
||||
--Draw RX Menu
|
||||
for line = 1, 7, 1 do
|
||||
for i = 0, 20-1, 1 do
|
||||
value=multiBuffer( line*20+13+i )
|
||||
if value > 0x00 and value < 0x80 then
|
||||
lcd.drawText(10+i*16,32+20*line,string.char(value))
|
||||
--lcd.drawText(10+i*16,32+20*line,string.char(value).." ",INVERS)
|
||||
lcd.drawText(76, 0, "/Fw" .. multiBuffer(13) .. "." .. multiBuffer(14) .. "." .. multiBuffer(15) .. "." .. multiBuffer(16),SMLSIZE) -- .. " " .. channel_names[1] .. channel_names[2] .. channel_names[3] .. channel_names[4])
|
||||
end
|
||||
|
||||
--Draw Menu
|
||||
for line = 1, 7, 1 do
|
||||
--Clear line info
|
||||
Menu[line].text = ""
|
||||
Menu[line].field_type = 0
|
||||
Menu[line].field_len = 0
|
||||
for i = 1, 7, 1 do
|
||||
Menu[line].field_value[i] = 0
|
||||
end
|
||||
Menu[line].field_text = ""
|
||||
length = 0
|
||||
--Read line from buffer
|
||||
for i = 0, 20-1, 1 do
|
||||
value=multiBuffer( line*20+13+i )
|
||||
if value == 0 then
|
||||
break -- end of line
|
||||
end
|
||||
if value > 0x80 and Menu[line].field_type == 0 then
|
||||
-- Read field type
|
||||
Menu[line].field_type = bitand(value, 0xF0)
|
||||
Menu[line].field_len = bitand(value, 0x0F)
|
||||
length = Menu[line].field_len
|
||||
if Menu[line].field_type ~= 0xA0 and Menu[line].field_type ~= 0xC0 and Focus == -1 then
|
||||
-- First actionnable field if nothing was selected
|
||||
Focus = line;
|
||||
end
|
||||
else
|
||||
if Menu[line].field_type == 0 then
|
||||
-- Text
|
||||
Menu[line].text = Menu[line].text .. string.char(value)
|
||||
else
|
||||
-- Menu specific fields
|
||||
length = length - 1
|
||||
if Menu[line].field_type == 0x80 or Menu[line].field_type == 0x90 then
|
||||
Menu[line].field_text = Menu[line].field_text .. string.char(value)
|
||||
else
|
||||
Menu[line].field_value[Menu[line].field_len-length] = value
|
||||
end
|
||||
if length == 0 then
|
||||
-- End of fields
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Display menu text
|
||||
if Menu[line].text ~= "" then
|
||||
if Menu[line].field_type == 0xA0 or Menu[line].field_type == 0xB0 or Menu[line].field_type == 0xC0 or Menu[line].field_type == 0xD0 then
|
||||
Menu[line].text = Menu[line].text .. ":"
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(10,32+20*line,Menu[line].text )
|
||||
else
|
||||
lcd.drawText(2,1+8*line,Menu[line].text,SMLSIZE)
|
||||
end
|
||||
end
|
||||
-- Display specific fields
|
||||
if line == Focus then
|
||||
attrib = INVERS
|
||||
else
|
||||
attrib = 0
|
||||
end
|
||||
if Menu[line].field_type == 0x80 or Menu[line].field_type == 0x90 then
|
||||
-- Text
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(10+9*#Menu[line].text, 32+20*line, Menu[line].field_text, attrib)
|
||||
else
|
||||
lcd.drawText(2+5*#Menu[line].text, 1+8*line, Menu[line].field_text, SMLSIZE + attrib)
|
||||
end
|
||||
elseif Menu[line].field_type == 0xA0 or Menu[line].field_type == 0xB0 then
|
||||
-- Decimal value
|
||||
value = 0
|
||||
for i = 1, Menu[line].field_len, 1 do
|
||||
value = value*256 + value
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(10+9*#Menu[line].text, 32+20*line, value, attrib)
|
||||
else
|
||||
lcd.drawText(2+5*#Menu[line].text, 1+8*line, value, SMLSIZE + attrib)
|
||||
end
|
||||
elseif Menu[line].field_type == 0xC0 or Menu[line].field_type == 0xD0 then
|
||||
-- Hex value
|
||||
text=""
|
||||
for i = 1, Menu[line].field_len, 1 do
|
||||
text = text .. string.format('%02X ', Menu[line].field_value[i])
|
||||
end
|
||||
if LCD_W == 480 then
|
||||
lcd.drawText(10+9*#Menu[line].text, 32+20*line, text, attrib)
|
||||
else
|
||||
lcd.drawText(2+5*#Menu[line].text, 1+8*line, text, SMLSIZE + attrib)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
--Draw RX Menu on LCD_W=128
|
||||
-- if multiBuffer( 4 ) == 0xFF then
|
||||
-- lcd.drawText(2,17,"No Config telemetry...",SMLSIZE)
|
||||
-- else
|
||||
-- if Timer_128 ~= 0 then
|
||||
--Intro page
|
||||
-- Timer_128 = Timer_128 - 1
|
||||
-- lcd.drawScreenTitle("Graupner Hott",0,0)
|
||||
-- lcd.drawText(2,17,"Configuration of RX" .. sensor_name[Config_Sensor+1] ,SMLSIZE)
|
||||
-- lcd.drawText(2,37,"Press menu to cycle Sensors" ,SMLSIZE)
|
||||
-- else
|
||||
--Menu page
|
||||
-- for line = 0, 7, 1 do
|
||||
-- for i = 0, 21-1, 1 do
|
||||
-- value=multiBuffer( line*21+6+i )
|
||||
-- if value > 0x80 then
|
||||
-- value = value - 0x80
|
||||
-- lcd.drawText(2+i*6,1+8*line,string.char(value).." ",SMLSIZE+INVERS)
|
||||
-- else
|
||||
-- lcd.drawText(2+i*6,1+8*line,string.char(value),SMLSIZE)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
-- Init
|
||||
local function Config_Init()
|
||||
--Find Multi module
|
||||
Module_int = model.getModule(0)
|
||||
Module_ext = model.getModule(1)
|
||||
if Module_int["Type"] ~= 6 and Module_ext["Type"] ~= 6 then
|
||||
error("No Multi module detected...")
|
||||
return 2
|
||||
end
|
||||
if Module_int["Type"] == 6 and Module_ext["Type"] == 6 then
|
||||
error("Two Multi modules detected, turn on only the one to be configured.")
|
||||
return 2
|
||||
end
|
||||
if Module_int["Type"] == 6 then
|
||||
ModuleNumber = 0
|
||||
ModuleType = "Internal"
|
||||
else
|
||||
ModuleNumber = 1
|
||||
ModuleType = "External"
|
||||
end
|
||||
--Get Module settings and set it to config protocol
|
||||
Module = model.getModule(ModuleNumber)
|
||||
InitialProtocol = Module.protocol
|
||||
Module.protocol = 86
|
||||
model.setModule(ModuleNumber, Module)
|
||||
--pause while waiting for the module to switch to config
|
||||
for i = 0, 10, 1 do end
|
||||
|
||||
--Set protocol to talk to
|
||||
multiBuffer( 0, string.byte('C') )
|
||||
--test if value has been written
|
||||
@ -105,12 +434,52 @@ local function Config_Init()
|
||||
error("Not enough memory!")
|
||||
return 2
|
||||
end
|
||||
|
||||
--Request init of the buffer
|
||||
multiBuffer( 4, 0xFF )
|
||||
multiBuffer(13, 0x00 )
|
||||
|
||||
--Continue buffer init
|
||||
multiBuffer( 1, string.byte('o') )
|
||||
multiBuffer( 2, string.byte('n') )
|
||||
multiBuffer( 3, string.byte('f') )
|
||||
|
||||
-- Test set
|
||||
-- multiBuffer( 12, 0 )
|
||||
-- multiBuffer( 13, 1 )
|
||||
-- multiBuffer( 14, 3 )
|
||||
-- multiBuffer( 15, 2 )
|
||||
-- multiBuffer( 16, 62 )
|
||||
-- multiBuffer( 17, 0 + 1*4 + 2*16 + 3*64)
|
||||
|
||||
-- multiBuffer( 33, string.byte('G') )
|
||||
-- multiBuffer( 34, string.byte('l') )
|
||||
-- multiBuffer( 35, string.byte('o') )
|
||||
-- multiBuffer( 36, string.byte('b') )
|
||||
-- multiBuffer( 37, string.byte('a') )
|
||||
-- multiBuffer( 38, string.byte('l') )
|
||||
-- multiBuffer( 39, string.byte(' ') )
|
||||
-- multiBuffer( 40, string.byte('I') )
|
||||
-- multiBuffer( 41, string.byte('D') )
|
||||
-- multiBuffer( 42, 0xD0 + 4 )
|
||||
-- multiBuffer( 43, 0x12 )
|
||||
-- multiBuffer( 44, 0x34 )
|
||||
-- multiBuffer( 45, 0x56 )
|
||||
-- multiBuffer( 46, 0x78 )
|
||||
-- multiBuffer( 47, 0x9A )
|
||||
-- multiBuffer( 48, 0xBC )
|
||||
|
||||
-- multiBuffer( 53, 0x90 + 9 )
|
||||
-- multiBuffer( 54, string.byte('R') )
|
||||
-- multiBuffer( 55, string.byte('e') )
|
||||
-- multiBuffer( 56, string.byte('s') )
|
||||
-- multiBuffer( 57, string.byte('e') )
|
||||
-- multiBuffer( 58, string.byte('t') )
|
||||
-- multiBuffer( 59, string.byte(' ') )
|
||||
-- multiBuffer( 60, string.byte('G') )
|
||||
-- multiBuffer( 61, string.byte('I') )
|
||||
-- multiBuffer( 62, string.byte('D') )
|
||||
-- multiBuffer( 63, 0x00 )
|
||||
end
|
||||
|
||||
-- Main
|
||||
@ -122,19 +491,33 @@ local function Config_Run(event)
|
||||
Config_Release()
|
||||
return 2
|
||||
else
|
||||
if event == EVT_VIRTUAL_PREV_PAGE then
|
||||
killEvents(event)
|
||||
Config_Page( event )
|
||||
elseif event == EVT_VIRTUAL_ENTER then
|
||||
Config_Menu( event )
|
||||
elseif event == EVT_VIRTUAL_PREV then
|
||||
Config_Menu( event )
|
||||
elseif event == EVT_VIRTUAL_NEXT then
|
||||
Config_Menu( event )
|
||||
elseif event == EVT_VIRTUAL_NEXT_PAGE then
|
||||
Config_Page( event )
|
||||
Config_Draw_Menu()
|
||||
if ( event == EVT_VIRTUAL_PREV_PAGE or event == EVT_VIRTUAL_NEXT_PAGE ) and Edit < 1 then
|
||||
-- Not editing, ok to change page
|
||||
if event == EVT_VIRTUAL_PREV_PAGE then
|
||||
killEvents(event)
|
||||
if Page > 0 then
|
||||
--Page = Page - 1
|
||||
--Config_Page()
|
||||
end
|
||||
else
|
||||
--Page = Page + 1
|
||||
--Config_Page()
|
||||
end
|
||||
end
|
||||
if Focus > 0 then
|
||||
-- At least one line has an action
|
||||
if Edit >= 0 then
|
||||
-- Currently editing
|
||||
Config_Draw_Edit( event )
|
||||
elseif event == EVT_VIRTUAL_ENTER then
|
||||
-- Switch to edit
|
||||
Config_Draw_Edit( 0 )
|
||||
elseif event == EVT_VIRTUAL_PREV or event == EVT_VIRTUAL_NEXT then
|
||||
-- Main menu selection
|
||||
Config_Next_Prev( event )
|
||||
end
|
||||
end
|
||||
Config_Draw_LCD()
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
@ -13,6 +13,17 @@ If you like this project and want to support further development please consider
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## MultiConfig
|
||||
|
||||
Enables to modify on a Multi module the Global ID, Cyrf ID or format the EEPROM.
|
||||
|
||||
Notes:
|
||||
- Supported from Multi v1.3.2.85 or above and OpenTX 2.3.12 or above
|
||||
- The Multi module to be configured must be active, if there is a second Multi module in the radio it must be off
|
||||
- Located on the radio SD card under \SCRIPTS\TOOLS
|
||||
|
||||
[![MultiCconfig](https://img.youtube.com/vi/lGyCV2kpqHU/0.jpg)](https://www.youtube.com/watch?v=lGyCV2kpqHU)
|
||||
|
||||
## MultiChannelsUpdater
|
||||
|
||||
Automatically name the channels based on the loaded Multi protocol and sub protocol including the module channel order convention.
|
||||
|
@ -79,13 +79,24 @@ uint8_t CYRF_Reset()
|
||||
void CYRF_GetMfgData(uint8_t data[])
|
||||
{
|
||||
#ifndef FORCE_CYRF_ID
|
||||
/* Fuses power on */
|
||||
CYRF_WriteRegister(CYRF_25_MFG_ID, 0xFF);
|
||||
if(eeprom_read_byte((EE_ADDR)EEPROM_CID_INIT_OFFSET)==0xf0)
|
||||
{//read Cyrf ID from EEPROM
|
||||
for(uint8_t i=0;i<6;i++)
|
||||
data[i] = eeprom_read_byte((EE_ADDR)EEPROM_CID_OFFSET+i);
|
||||
}
|
||||
else
|
||||
{//read Cyrf ID and store it EEPROM
|
||||
/* Fuses power on */
|
||||
CYRF_WriteRegister(CYRF_25_MFG_ID, 0xFF);
|
||||
|
||||
CYRF_ReadRegisterMulti(CYRF_25_MFG_ID, data, 6);
|
||||
CYRF_ReadRegisterMulti(CYRF_25_MFG_ID, data, 6);
|
||||
for(uint8_t i=0;i<6;i++)
|
||||
eeprom_write_byte((EE_ADDR)EEPROM_CID_OFFSET+i, data[i]);
|
||||
eeprom_write_byte((EE_ADDR)EEPROM_CID_INIT_OFFSET, 0xf0);
|
||||
|
||||
/* Fuses power off */
|
||||
CYRF_WriteRegister(CYRF_25_MFG_ID, 0x00);
|
||||
/* Fuses power off */
|
||||
CYRF_WriteRegister(CYRF_25_MFG_ID, 0x00);
|
||||
}
|
||||
#else
|
||||
memcpy(data,FORCE_CYRF_ID,6);
|
||||
#endif
|
||||
|
@ -19,13 +19,19 @@
|
||||
#include "iface_cyrf6936.h"
|
||||
#endif
|
||||
|
||||
void CONFIG_write_ID(uint32_t id)
|
||||
void CONFIG_write_GID(uint32_t id)
|
||||
{
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
eeprom_write_byte((EE_ADDR)EEPROM_ID_OFFSET+i,id >> (i*8));
|
||||
eeprom_write_byte((EE_ADDR)(EEPROM_ID_OFFSET+10),0xf0);
|
||||
//eeprom_write_byte((EE_ADDR)(EEPROM_ID_OFFSET+10),0xf0);
|
||||
}
|
||||
|
||||
void CONFIG_write_CID(uint8_t *data)
|
||||
{
|
||||
for(uint8_t i=0;i<6;i++)
|
||||
eeprom_write_byte((EE_ADDR)EEPROM_CID_OFFSET+i, data[i]);
|
||||
//eeprom_write_byte((EE_ADDR)EEPROM_CID_INIT_OFFSET, 0xf0);
|
||||
}
|
||||
uint16_t CONFIG_callback()
|
||||
{
|
||||
static uint8_t line=0, page=0;
|
||||
@ -51,7 +57,7 @@ uint16_t CONFIG_callback()
|
||||
id |= CONFIG_SerialRX_val[i+1];
|
||||
}
|
||||
debugln("Update ID to %lx", id);
|
||||
CONFIG_write_ID(id);
|
||||
CONFIG_write_GID(id);
|
||||
break;
|
||||
case 2:
|
||||
if(CONFIG_SerialRX_val[1]==0xAA)
|
||||
@ -59,7 +65,7 @@ uint16_t CONFIG_callback()
|
||||
#define STM32_UUID ((uint32_t *)0x1FFFF7E8)
|
||||
id = STM32_UUID[0] ^ STM32_UUID[1] ^ STM32_UUID[2];
|
||||
debugln("Reset GID to %lx", id);
|
||||
CONFIG_write_ID(id);
|
||||
CONFIG_write_GID(id);
|
||||
}
|
||||
break;
|
||||
#ifdef CYRF6936_INSTALLED
|
||||
@ -68,6 +74,7 @@ uint16_t CONFIG_callback()
|
||||
for(uint8_t i=0; i<6; i++)
|
||||
debug("%02X ",CONFIG_SerialRX_val[i+1]);
|
||||
debugln("");
|
||||
CONFIG_write_CID(&CONFIG_SerialRX_val[1]);
|
||||
case 5:
|
||||
if(CONFIG_SerialRX_val[1]==0xAA)
|
||||
{
|
||||
@ -79,6 +86,7 @@ uint16_t CONFIG_callback()
|
||||
for(uint8_t i=0; i<6; i++)
|
||||
debug("%02X ",data[i]);
|
||||
debugln("");
|
||||
CONFIG_write_CID(data);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
@ -192,7 +192,6 @@ enum
|
||||
const mm_protocol_definition multi_protocols[] = {
|
||||
// Protocol number, Protocol String, Sub_protocol strings, Number of sub_protocols, Option type, Failsafe, ChMap, RF switch, Init, Callback
|
||||
#if defined(MULTI_CONFIG_INO)
|
||||
{0x00, STR_CONFIG, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, 0, CONFIG_init, CONFIG_callback },
|
||||
{PROTO_CONFIG, STR_CONFIG, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, 0, CONFIG_init, CONFIG_callback },
|
||||
#endif
|
||||
#if defined(ASSAN_NRF24L01_INO)
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_REVISION 2
|
||||
#define VERSION_PATCH_LEVEL 84
|
||||
#define VERSION_PATCH_LEVEL 85
|
||||
|
||||
#define MODE_SERIAL 0
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
//******************
|
||||
enum PROTOCOLS
|
||||
{
|
||||
//PROTO_CONFIG = 0, // Module config
|
||||
PROTO_FLYSKY = 1, // =>A7105
|
||||
PROTO_HUBSAN = 2, // =>A7105
|
||||
PROTO_FRSKYD = 3, // =>CC2500
|
||||
@ -784,6 +783,8 @@ enum {
|
||||
#define SPEED_125K 3
|
||||
|
||||
/** EEPROM Layout */
|
||||
#define EEPROM_CID_INIT_OFFSET 0 // 1 byte flag that Cyrf ID is initialized
|
||||
#define EEPROM_CID_OFFSET 1 // 6 bytes Cyrf ID
|
||||
#define EEPROM_ID_OFFSET 10 // Module ID (4 bytes)
|
||||
#define EEPROM_BANK_OFFSET 15 // Current bank number (1 byte)
|
||||
#define EEPROM_ID_VALID_OFFSET 20 // 1 byte flag that ID is valid
|
||||
@ -800,7 +801,8 @@ enum {
|
||||
#define FRSKYX_CLONE_EEPROM_OFFSET 822 // (1) format + (3) TX ID + (47) channels, 51 bytes, end is 873
|
||||
#define FRSKYX2_CLONE_EEPROM_OFFSET 873 // (1) format + (3) TX ID, 4 bytes, end is 877
|
||||
#define DSM_RX_EEPROM_OFFSET 877 // (4) TX ID + format, 5 bytes, end is 882
|
||||
//#define CONFIG_EEPROM_OFFSET 882 // Current configuration of the multimodule
|
||||
#define MOULDKG_EEPROM_OFFSET 882 // RX ID, 3 bytes per model, end is 882+64*3=1074
|
||||
//#define CONFIG_EEPROM_OFFSET 1074 // Current configuration of the multimodule
|
||||
|
||||
/* STM32 Flash Size */
|
||||
#ifndef DISABLE_FLASH_SIZE_CHECK
|
||||
|
@ -190,7 +190,7 @@ static void multi_send_status()
|
||||
// Protocol next/prev
|
||||
if(multi_protocols[multi_protocols_index+1].protocol != 0xFF)
|
||||
{
|
||||
if(multi_protocols[multi_protocols_index+1].protocol == PROTO_SCANNER)
|
||||
if(multi_protocols[multi_protocols_index+1].protocol == PROTO_SCANNER )//|| multi_protocols[multi_protocols_index+1].protocol == PROTO_CONFIG )
|
||||
{// if next is scanner
|
||||
if(multi_protocols[multi_protocols_index+2].protocol != 0xFF)
|
||||
Serial_write(multi_protocols[multi_protocols_index+2].protocol); // skip to next protocol number
|
||||
@ -204,7 +204,7 @@ static void multi_send_status()
|
||||
Serial_write(multi_protocols[multi_protocols_index].protocol); // end of list
|
||||
if(multi_protocols_index>0 && multi_protocols[multi_protocols_index-1].protocol != 0)
|
||||
{
|
||||
if(multi_protocols[multi_protocols_index-1].protocol==PROTO_SCANNER)
|
||||
if(multi_protocols[multi_protocols_index-1].protocol == PROTO_SCANNER )//|| multi_protocols[multi_protocols_index-1].protocol == PROTO_CONFIG )
|
||||
{// if prev is scanner
|
||||
if(multi_protocols_index > 1)
|
||||
Serial_write(multi_protocols[multi_protocols_index-2].protocol); // skip to prev protocol number
|
||||
|
@ -168,6 +168,9 @@
|
||||
//All the protocols will not fit in the Atmega328p module so you need to pick and choose.
|
||||
//Comment the protocols you are not using with "//" to save Flash space.
|
||||
|
||||
//Protocol for module configuration
|
||||
#define MULTI_CONFIG_INO
|
||||
|
||||
//The protocols below need an A7105 to be installed
|
||||
#define AFHDS2A_A7105_INO
|
||||
#define AFHDS2A_RX_A7105_INO
|
||||
|
Loading…
x
Reference in New Issue
Block a user