Frankie dsm fwrd prg enhancements (#776)

* #751 DSM Enhancements

 #751 DSM Forward Programming Enhancements (New GUI, etc)

* Make both work on EdgeTx and OpenTX

* #751 Turn OFF simulation by default

Distribution code with RX simulation OFF
Simulation should be only for Development

* #751 Update Readme Documentation

Updated the Readme.txt documentation
and removed compiled luac file that was check in by mistake

* #751 Fix problems With Reset RX

1. Fix problem when trying to Factory Reset. Enter Bind Mode. Save backup, Restore Backup

2. Found a way to advance on the Gyro initial Setup menus.. a bit of a hack, but works.

3. Handle RX resets properly. It needed after initial setup

* #751 Cosmetic and Show Orientation Images

#751
1. Fix problems when text contradictions between Menu/Line Headers and List Values
2. Show Images of RX orientations
3. Able to Hack getting into Initial Setup and other menus who was failing before
4. Custumize the way Flight Mode reports the Value on Screen

* #751 add check for required libraries

Add check that the required files in DSMLIB exist

* #751

Write documentation about the protocol so that we don't forget later what we know, and enable others to understand the logs and maybe help solve problems.

* #766

Change the way to detect that the files exist. now works on both ETX and OTX

* #766 Strange Flickering in OTX

Strange Flickering happening on OTX. Refreshing the screen on every cycle fixed the problem

* #766 Change way of dectecting EdgeTX

Change way of detecting OTX in multiple versions: OTX 2.3.14 and 2.3.15

* #766  make editable Gain Values

Gains and other settings should be editable even when they are VALUE_NOCHANGING. Flight Mode is an exception that is handled properly. Right align numbers.

* #766 More enhacements

Added AR630
Make numbers right justified
Cleanup some log messages and line types.
Updated DSM FWD prog documentation

* #751 more cosmetic things

1. Added AR10360T,
2. Simplify way to configured the hack for more receivers.
3. Change some texts on menus to march spektrum
4. Background color in Spektrum theme to match

* #751 A few final changes

1. Update channel names to include channel number. i.e: Ch5 (Gear)
2,  Fix flight mode display for Heli Receiver
3. i think the unknown lines are to request info about the TX settings

* #751

1. Added Warning Screen
2. Correct handling of Unknown lines in Gyro Settings->Initial Setup

Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
This commit is contained in:
Frankie Arzu 2022-12-02 01:53:13 -06:00 committed by GitHub
parent 2da8b3c42a
commit c4e70ab4fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 162 additions and 56 deletions

View File

@ -1,4 +1,5 @@
local toolName = "TNS|DSM Forward Prog v0.5 (Text B&W) |TNE"
local VERSION = "v0.5"
---- #########################################################################
---- # #
@ -74,6 +75,8 @@ local lastRefresh=0 -- Last time the screen was refreshed
local REFRESH_GUI_MS = 500/10 -- 500ms.. Screen Refresh Rate.. to not use unneded CPU time (in 10ms units to be compatible with getTime())
local originalValue = nil
local warningScreenON = true
------------------------------------------------------------------------------------------------------------
local function GUI_SwitchSimulationOFF()
dsmLib.ReleaseConnection()
@ -422,6 +425,33 @@ local function init_screen_pos()
end
end
local function GUI_Warning(event)
lcd.clear()
local header = "DSM Forward Programming "..VERSION.." "
--Draw title
lcd.drawFilledRectangle(0, 0, LCD_W, 17, TITLE_BGCOLOR)
lcd.drawText(5, 0, header, MENU_TITLE_COLOR + TEXT_SIZE)
lcd.drawText(100,20,"WARNING", BLINK+BOLD)
lcd.drawText(5,40,"Gyro settings-> Initial Setup and Initial SAFE Setup", BOLD)
lcd.drawText(5,70,"Has only been tested with normal wing type and normal tail.", 0)
lcd.drawText(5,90,"Make sure that your Gyro/Safe reacts correctly after setup", 0)
lcd.drawText(5,110,"with this tool. If not, set it up with a Spektrum TX.", 0)
lcd.drawText(5,150,"Gyro settings-> System Setup -> Relearn Servo Setting", BOLD)
lcd.drawText(5,180,"Will override Wing type, tail type, servo reverse, etc.", 0)
lcd.drawText(5,200,"If this RX was initally setup with a Spektrum Transmiter.", 0)
lcd.drawText(100,250," OK ", INVERS + BOLD)
if event == EVT_VIRTUAL_EXIT or event == EVT_VIRTUAL_ENTER then
warningScreenON = false
end
return 0
end
------------------------------------------------------------------------------------------------------------
-- Init
local function DSM_Init()
@ -444,6 +474,10 @@ local function DSM_Run(event)
return 2
end
if (warningScreenON) then
return GUI_Warning(event)
end
GUI_HandleEvent(event)
dsmLib.Send_Receive() -- Handle Send and Receive DSM Forward Programming Messages

View File

@ -93,6 +93,8 @@ local LCD_DEBUG_COLOR = LINE_COLOR
local LCD_BOX_COLOR = TEXT_DISABLE_COLOR
local warningScreenON = true
--------------------- lcd.sizeText replacement -------------------------------------------------
-- EdgeTx dont have lcd.sizeText, so we do an equivalent one using the string length and 5px per character
@ -609,6 +611,33 @@ local function init_colors()
end
end
local function GUI_Warning(event,touchState)
lcd.clear(LCD_TOOL_BGCOLOR)
local header = "DSM Forward Programming "..VERSION.." "
--Draw title
lcd.drawFilledRectangle(0, 0, LCD_W, 17, LCD_TOOL_HDR_BGCOLOR)
lcd.drawText(5, 0, header, LCD_TOOL_HDR_COLOR + SMLSIZE)
lcd.drawText(100,20,"WARNING", BLINK+BOLD)
lcd.drawText(5,40,"Gyro settings-> Initial Setup and Initial SAFE Setup", BOLD)
lcd.drawText(5,70,"Has only been tested with normal wing type and normal tail.", 0)
lcd.drawText(5,90,"Make sure that your Gyro/Safe reacts correctly after setup", 0)
lcd.drawText(5,110,"with this tool. If not, set it up with a Spektrum TX.", 0)
lcd.drawText(5,150,"Gyro settings-> System Setup -> Relearn Servo Setting", BOLD)
lcd.drawText(5,180,"Will override Wing type, tail type, servo reverse, etc.", 0)
lcd.drawText(5,200,"If this RX was initally setup with a Spektrum Transmiter.", 0)
lcd.drawText(100,250," OK ", INVERS + BOLD)
if event == EVT_VIRTUAL_EXIT or event == EVT_VIRTUAL_ENTER or event == EVT_TOUCH_TAP then
warningScreenON = false
end
return 0
end
------------------------------------------------------------------------------------------------------------
-- Init
local function DSM_Init()
@ -628,6 +657,10 @@ local function DSM_Run(event,touchState)
return 2
end
if (warningScreenON) then
return GUI_Warning(event,touchState)
end
GUI_HandleEvent(event,touchState)
dsmLib.Send_Receive() -- Handle Send and Receive DSM Forward Programming Messages

View File

@ -41,8 +41,6 @@
local DEBUG_ON = ... -- Get Debug_ON from parameters. -- 0=NO DEBUG, 1=HIGH LEVEL 2=MORE DETAILS
local LIB_VERSION = "0.5"
local FORCED_HACK = false
local Lib = { Init_Text = function (rxId) end }
@ -59,8 +57,6 @@ local RX = {
AR631 = 0x001E
}
local RX_HACK_TESTED = { RX.AR630, RX.AR631, RX.AR637T, RX.AR637TA, RX.AR8360T, RX.AR10360T }
local PHASE = {
RX_VERSION = 0,
WAIT_CMD = 1,
@ -115,6 +111,9 @@ local StartTime = 0 -- Start time since the start of the script
local Waiting_RX = 0 -- 1 if Waiting for an RX response, 0 if transmiting
local Value_Change_Step = 0 -- 2 Steps to update. 0=Send update value, 1=Send Verificatin request
local TxInfo_Type = 0
local TxInfo_Step = 0
-- Text Arrays for Display Text and Debuging
local PhaseText = {}
local LineTypeText = {}
@ -667,42 +666,78 @@ local function DSM_menuValueChangingWait(valId, text, line)
-- Pascal: i think the 2nd byte is the leghts of the entire message in bytes, so instead of 0x06, should be 0x04 for here.. work both ways
end
local function DSM_sentTxInfo(menuId,curLine)
if (TxInfo_Step == 0 and TxInfo_Type==0x00) then
-- AR636B.. but does not work
if (DEBUG_ON) then LOG_write("CALL DSM_SendTxInfo_22(#%d DATA=TX: 0x22 0x04 %02X %02X)\n", curLine,
0x00, 0x00) -- DATA part
end
DSM_send(0x22, 0x04, 0x00, 0x00)
elseif (TxInfo_Step == 0 and (TxInfo_Type==0x01 or TxInfo_Type==0x1F)) then
-- AR630 family: Both TxInfo_Type (ManinMenu=0x1, Other First Time Configuration = 0x1F)
local last_byte = { 0x40, 0x01, 0x02, 0x04, 0x00, 0x00 } -- unknown.
if (DEBUG_ON) then LOG_write("CALL DSM_SendTxInfo_20(#%d DATA=TX: 0x20 0x06 %02X %02X %02X %02X)\n", curLine,
curLine, curLine, 0, last_byte[curLine + 1]) -- DATA part
end
DSM_send(0x20, 0x06, curLine, curLine, 0x00, last_byte[curLine + 1]) -- line X
TxInfo_Step = TxInfo_Step + 1
if (TxInfo_Type == 0x1F) then
Waiting_RX = 0 -- keep Transmitig
end
elseif (TxInfo_Step == 1 and TxInfo_Type==0x1F) then
-- 23,6: 0 64 0 64
if (DEBUG_ON) then LOG_write("CALL DSM_SendTxInfo_23(#%d DATA=TX: 0x23 0x06 %02X %02X %02X %02X)\n", curLine,
0x00, 0x64, 0x00, 0x64) -- DATA part
end
DSM_send(0x23, 0x06, 0x00, 0x64, 0x00, 0x64)
TxInfo_Step = TxInfo_Step + 1
Waiting_RX = 0 -- keep Transmitig
elseif (TxInfo_Step == 2 and TxInfo_Type==0x1F) then
local data = {
{ 0x0, 0x00, 0x07, 0xFF }, -- #0: 0 00 07 FF
{ 0x0, 0x8E, 0x07, 0x72 }, -- #1: 0 8E 07 72
{ 0x0, 0x8E, 0x07, 0x72 }, -- #2: 0 8E 07 72
{ 0x0, 0x8E, 0x07, 0x72 } -- #3: 0 8E 07 72
}
if (DEBUG_ON) then LOG_write("CALL DSM_SendTxInfo_21(#%d DATA=TX: 0x21 0x06 %02X %02X %02X %02X)\n", curLine,
data[curLine+1][1], data[curLine+1][2], data[curLine+1][3], data[curLine+1][4]) -- DATA part
end
DSM_send(0x21, 0x06, data[curLine+1][1], data[curLine+1][2], data[curLine+1][3], data[curLine+1][4])
TxInfo_Step = TxInfo_Step + 1
Waiting_RX = 0 -- keep Transmitig
elseif (TxInfo_Step == 3 and TxInfo_Type==0x1F) then
-- 24,6: 0 83 5A B5
if (DEBUG_ON) then LOG_write("CALL DSM_SendTxInfo_24(#%d DATA=TX: 0x24 0x06 %02X %02X %02X %02X)\n", curLine,
0x00, 0x83, 0x5A, 0xB5) -- DATA part
end
DSM_send(0x24, 0x06, 0x00, 0x83, 0x5A, 0xB5)
TxInfo_Step = TxInfo_Step + 1
Waiting_RX = 0 -- keep Transmitig
elseif (TxInfo_Step == 4 and TxInfo_Type==0x1F) then
-- 24,6: 6 80 25 4B
if (DEBUG_ON) then LOG_write("CALL DSM_SendTxInfo_24(#%d DATA=TX: 0x24 0x06 %02X %02X %02X %02X)\n", curLine,
0x06, 0x80, 0x25, 0x4B) -- DATA part
end
DSM_send(0x24, 0x06, 0x06, 0x80, 0x25, 0x4B)
TxInfo_Step = TxInfo_Step + 1
Waiting_RX = 0 -- keep Transmitig
elseif (TxInfo_Step == 5 and TxInfo_Type==0x1F) then
-- 22,4: 0 0
if (DEBUG_ON) then LOG_write("CALL DSM_SendTxInfo_22(#%d DATA=TX: 0x22 0x04 %02X %02X)\n", curLine,
0x00, 0x00) -- DATA part
end
DSM_send(0x22, 0x04, 0x00, 0x00)
TxInfo_Step = TxInfo_Step + 1
end
end
-----------------------------------------------------------------------------------------------------------
local function DSM_RX_Match(RxId, List)
for i = 1, #List do
if List[i] == RxId then return true end
end
return false
end
local function DSM_SelLine_HACK()
-- This hack was to be able to access some menus, that with using the default ctx.SelLine as it was,
-- the menu start returning weird 0x05 Unknow lines, by overriding the ctx.SelLine to Zero or other value
-- they started to work.
-- Tested to work on the RX: AR631, AR637T, AR637TA
local ctx = DSM_Context
-- AR631/AR637 Family: Hack for "First time Setup" or "First Time AS3X Setup", use 0 instead of the ctx.SelLine
if (ctx.Menu.MenuId == 0x104F or ctx.Menu.MenuId==0x1055) and
(FORCED_HACK or DSM_RX_Match(ctx.RX.Id,RX_HACK_TESTED)) then
if (DEBUG_ON) then LOG_write("First time Setup Menu HACK: Overrideing LastSelectedLine to ZERO\n") end
if (DEBUG_ON) then LOG_write("%3.3f %s: ", getElapsedTime(), phase2String(ctx.Phase)) end
ctx.SelLine = 0
end
-- AR631/AR637 Hack for "Relearn Servo Settings", use 1 instead of the ctx.SelLine=0
-- REMOVE THE FIX FOR NOW.. Locks the Servos
--if (ctx.Menu.MenuId == 0x1023 and
-- (FORCED_HACK or DSM_RX_Match(ctx.RX.Id,RX_HACK_TESTED))) then
-- if (DEBUG_ON) then LOG_write("Relearn Servo Settings HACK: Overrideing LastSelectedLine to 1\n") end
-- if (DEBUG_ON) then LOG_write("%3.3f %s: ", getElapsedTime(), phase2String(ctx.Phase)) end
-- ctx.SelLine = 1
--end
end
local function DSM_sendRequest()
-- Send the proper Request message depending on the Phase
@ -719,7 +754,6 @@ local function DSM_sendRequest()
if ctx.Menu.MenuId == 0 then -- First time loading a menu ?
DSM_getMainMenu()
else
DSM_SelLine_HACK()
DSM_getMenu(ctx.Menu.MenuId, ctx.SelLine)
if (ctx.Menu.MenuId == 0x0001) then -- Executed the Reset Menu??
@ -732,13 +766,7 @@ local function DSM_sendRequest()
end
elseif ctx.Phase == PHASE.MENU_REQ_TX_INFO then
-- Guessing: Trying to Request TX info: Model Type, Wing Type, Tail (normal/V), Aileron Sevos (1/2), etc
local curLine = ctx.CurLine
if (DEBUG_ON) then LOG_write("CALL DSM_getNextUknownLine_0x05: LastLine=%s ", curLine) end
local last_byte = { 0x40, 0x01, 0x02, 0x04, 0x00, 0x00 } -- unknown.
DSM_send(0x20, 0x06, curLine, curLine, 0x00, last_byte[curLine + 1]) -- line X
if (DEBUG_ON) then LOG_write("DATA=TX: 20 06 %02X %02X %02X %02X\n", curLine, curLine, 0, last_byte[curLine + 1]) end
DSM_sentTxInfo(ctx.Menu.MenuId, ctx.CurLine)
elseif ctx.Phase == PHASE.MENU_LINES then -- request next menu lines
if ctx.CurLine == -1 then -- No previous menu line loaded ?
@ -884,6 +912,21 @@ local function DSM_parseMenuValue()
end
end
local function DSM_parseReqTxInfo()
-- unknown... I think is trying to request info about TX (Wing type, etc)
-- 0x09 0x05 0x01 0x01 0x00 0x00 0x00 0x00 0x07 Menu: MAIN MENU
-- 0x09 0x05 0x01 0x1F 0x00 0x00 0x00 0x00 0x07 Menu: First Time Setup
-- Line ?? ????
local curLine = multiBuffer(12)
TxInfo_Type = multiBuffer(13)
if (DEBUG_ON) then LOG_write("RESPONSE ReqTXInfo(LineNum=%d DataType=0x%0X DATA=%s)\n", curLine, TxInfo_Type, multiBuffer2String()) end
TxInfo_Step = 0
return curLine
end
-- Creates a fake line do display an error in the GUI
local function DSM_Add_Error_Menu_Line(i, text)
local ctx = DSM_Context
@ -956,14 +999,11 @@ local function DSM_processResponse()
elseif cmd == 0x04 then -- read menu values
DSM_parseMenuValue()
ctx.Phase = PHASE.MENU_VALUES
elseif cmd == 0x05 then -- Request TX Info
local lineNum = DSM_parseReqTxInfo()
elseif cmd == 0x05 then -- unknown... I think is trying to request info about TX (Wing type, etc)
-- 0x09 0x05 0x01 0x01 0x00 0x00 0x00 0x00 0x07
-- Line MenuId ????
local curLine = multiBuffer(12)
if (DEBUG_ON) then LOG_write("RESPONSE MenuUknownLine_0x05: LineNum=%s DATA=%s\n", curLine, multiBuffer2String()) end
if (curLine==ctx.CurLine) then
if (lineNum==ctx.CurLine) then
-- WEIRD BEHAVIOR
-- We got the same line we already got. thi will continue
-- on a loop and disconnect RX
@ -971,7 +1011,7 @@ local function DSM_processResponse()
if (DEBUG_ON) then LOG_write("ERROR: Received Same menu line\n") end
end -- Got the next line.. keep requesting more
ctx.CurLine = curLine
ctx.CurLine = lineNum
ctx.Phase = PHASE.MENU_REQ_TX_INFO
elseif cmd == 0xA7 then -- answer to EXIT command
@ -1261,7 +1301,6 @@ local function DSM_Init_Text(rxId)
Text[0x00CA] = "SAFE/Panic Mode Setup"
Text[0x00CD] = "Level model and capture attiude/M"; -- Different from List_Text , and force it to be a menu button
-- RX Orientations for AR631/AR637, Optionally attach an Image + Alt Text to display
List_Text[0x00CB] = "Position 1"; List_Text_Img[0x00CB] = "rx_pos_1.png|Pilot View: RX Label Up, Pins Back"
List_Text[0x00CC] = "Position 2"; List_Text_Img[0x00CC] = "rx_pos_2.png|Pilot View: RX Label Left, Pins Back"
@ -1332,7 +1371,7 @@ local function DSM_Init_Text(rxId)
Text[0x010A] = "" -- empty??
Text[0x010B] = "" -- empty??
Text[0x0190] = "DONT USE! Relearn Servo Settings"
Text[0x0190] = "Warning! Relearn Servo Settings"
Text[0x019C] = "Enter Receiver Bind Mode"
Text[0x01D7] = "SAFE Select Channel"
Text[0x01DC] = "AS3X/c/b" -- Subtitle, Center+bold