From 2e7b1dc904c33cea78f1823278846a3ffb392b2a Mon Sep 17 00:00:00 2001 From: Frankie Arzu <32604366+frankiearzu@users.noreply.github.com> Date: Sun, 27 Nov 2022 08:10:02 -0600 Subject: [PATCH] #766 change validation of required files (#768) * #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 Co-authored-by: pascallanger --- Lua_scripts/DSM FwdPrg_05_BW.lua | 21 +++++++++++++-------- Lua_scripts/DSM FwdPrg_05_Color.lua | 20 +++++++++----------- Lua_scripts/DSMLIB/DsmFwPrgSIMLib.lua | 2 +- Lua_scripts/DSMLIB/readme.md | 4 ++++ 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Lua_scripts/DSM FwdPrg_05_BW.lua b/Lua_scripts/DSM FwdPrg_05_BW.lua index 9293e9f..a7fed61 100644 --- a/Lua_scripts/DSM FwdPrg_05_BW.lua +++ b/Lua_scripts/DSM FwdPrg_05_BW.lua @@ -23,17 +23,12 @@ local DEBUG_ON_LCD = false -- Interactive Information on LCD of Menu data from local DSMLIB_PATH = "/SCRIPTS/TOOLS/DSMLIB/" -local dirExist = fstat(DSMLIB_PATH.."DsmFwPrgLib.lua") -if (dirExist==nil) then error("Make sure "..DSMLIB_PATH.." contains DsmFwPrgLib.lua") end -dirExist = fstat(DSMLIB_PATH.."DsmFwPrgSIMLib.lua") -if (dirExist==nil) then error("Make sure "..DSMLIB_PATH.." contains DsmFwPrgSIMLib.lua") end - local dsmLib if (SIMULATION_ON) then -- library with SIMILATION VERSION. Works really well in Companion for GUI development - dsmLib = loadScript(DSMLIB_PATH .. "DsmFwPrgSIMLib.lua")(DEBUG_ON) + dsmLib = assert(loadScript(DSMLIB_PATH.."DsmFwPrgSIMLib.lua"), "Not-Found: DSMLIB/DsmFwPrgSIMLib.lua")(DEBUG_ON) else - dsmLib = loadScript(DSMLIB_PATH .. "DsmFwPrgLib.lua")(DEBUG_ON) + dsmLib = assert(loadScript(DSMLIB_PATH.."DsmFwPrgLib.lua"),"Not-Found: DSMLIB/DsmFwPrgLib.lua")(DEBUG_ON) end local PHASE = dsmLib.PHASE @@ -42,6 +37,8 @@ local DISP_ATTR = dsmLib.DISP_ATTR local DSM_Context = dsmLib.DSM_Context +local IS_EDGETX = false -- DEFAULT until Init changed it + local LCD_W_USABLE = LCD_W-10 -- X for Menu Lines local LCD_X_LINE_MENU = 10 @@ -388,6 +385,12 @@ local function GUI_HandleEvent(event, touchState) end local function init_screen_pos() + -- osName in OpenTX is nil, otherwise is EDGETX + local ver, radio, maj, minor, rev, osname = getVersion() + if (osname==nil) then osname = "OpenTX" end -- OTX 2.3.14 and below returns nil + + IS_EDGETX = string.sub(osname,1,1) =='E' + if LCD_W == 480 then -- TX16 -- use defaults in the script header elseif LCD_W == 128 then --TX12 (128x64) -- Still needs some work on the vertical @@ -445,8 +448,10 @@ local function DSM_Run(event) refreshInterval = 20 -- 200ms end + if (not IS_EDGETX) then -- OPENTX NEEDS REFRESH ON EVERY CYCLE + GUI_Display() -- Refresh display only if needed and no faster than 500ms, utilize more CPU to speedup DSM communications - if (ctx.Refresh_Display and (getTime()-lastRefresh) > refreshInterval) then --300ms from last refresh + elseif (ctx.Refresh_Display and (getTime()-lastRefresh) > refreshInterval) then --300ms from last refresh GUI_Display() ctx.Refresh_Display=false lastRefresh=getTime() diff --git a/Lua_scripts/DSM FwdPrg_05_Color.lua b/Lua_scripts/DSM FwdPrg_05_Color.lua index e541d9c..b20db2e 100644 --- a/Lua_scripts/DSM FwdPrg_05_Color.lua +++ b/Lua_scripts/DSM FwdPrg_05_Color.lua @@ -25,20 +25,14 @@ local USE_SPECKTRUM_COLORS = true -- true: Use spectrum colors, false: use theme local DSMLIB_PATH = "/SCRIPTS/TOOLS/DSMLIB/" local IMAGE_PATH = DSMLIB_PATH .. "img/" -local dirExist = fstat(DSMLIB_PATH.."DsmFwPrgLib.lua") -if (dirExist==nil) then error("Make sure "..DSMLIB_PATH.." contains DsmFwPrgLib.lua") end -dirExist = fstat(DSMLIB_PATH.."DsmFwPrgSIMLib.lua") -if (dirExist==nil) then error("Make sure "..DSMLIB_PATH.." contains DsmFwPrgSIMLib.lua") end - local dsmLib if (SIMULATION_ON) then -- library with SIMILATION VERSION. Works really well in Companion for GUI development - dsmLib = loadScript(DSMLIB_PATH.."DsmFwPrgSIMLib.lua")(DEBUG_ON) + dsmLib = assert(loadScript(DSMLIB_PATH.."DsmFwPrgSIMLib.lua"), "Not-Found: DSMLIB/DsmFwPrgSIMLib.lua")(DEBUG_ON) else - dsmLib = loadScript(DSMLIB_PATH.."DsmFwPrgLib.lua")(DEBUG_ON) + dsmLib = assert(loadScript(DSMLIB_PATH.."DsmFwPrgLib.lua"),"Not-Found: DSMLIB/DsmFwPrgLib.lua")(DEBUG_ON) end - local PHASE = dsmLib.PHASE local LINE_TYPE = dsmLib.LINE_TYPE local DISP_ATTR = dsmLib.DISP_ATTR @@ -80,7 +74,7 @@ local LCD_MENU_BGCOLOR = MENU_TITLE_BGCOLOR -- LINE SELECTED local LCD_SELECTED_COLOR = TEXT_INVERTED_COLOR local LCD_SELECTED_BGCOLOR = TEXT_INVERTED_BGCOLOR -local LCD_EDIT_BGCOLOR = WARNING_COLOR +local LCD_EDIT_BGCOLOR = MENU_TITLE_BGCOLOR -- WARNING_COLOR -- NORMAL TEXT local LCD_NORMAL_COLOR = TEXT_COLOR local LCD_DISABLE_COLOR = TEXT_DISABLE_COLOR @@ -578,7 +572,9 @@ end local function init_colors() -- osName in OpenTX is nil, otherwise is EDGETX local ver, radio, maj, minor, rev, osname = getVersion() - IS_EDGETX = osname~=nil + if (osname==nil) then osname = "OpenTX" end -- OTX 2.3.14 and below returns nil + + IS_EDGETX = string.sub(osname,1,1) == 'E' if (IS_EDGETX and USE_SPECKTRUM_COLORS) then -- SPECKTRUM COLORS (only works on EDGETX) @@ -632,8 +628,10 @@ local function DSM_Run(event,touchState) refreshInterval = 20 -- 200ms end + if (not IS_EDGETX) then -- OPENTX NEEDS REFRESH ON EVERY CYCLE + GUI_Display() -- Refresh display only if needed and no faster than 300ms, utilize more CPU to speedup DSM communications - if (ctx.Refresh_Display and (getTime()-lastRefresh) > refreshInterval) then --300ms from last refresh + elseif (ctx.Refresh_Display and (getTime()-lastRefresh) > refreshInterval) then --300ms from last refresh GUI_Display() ctx.Refresh_Display=false lastRefresh=getTime() diff --git a/Lua_scripts/DSMLIB/DsmFwPrgSIMLib.lua b/Lua_scripts/DSMLIB/DsmFwPrgSIMLib.lua index adb465c..8a30c21 100644 --- a/Lua_scripts/DSMLIB/DsmFwPrgSIMLib.lua +++ b/Lua_scripts/DSMLIB/DsmFwPrgSIMLib.lua @@ -27,7 +27,7 @@ local DEBUG_ON = ... -- Get DebugON from parameters -local dsmLib = loadScript("/SCRIPTS/TOOLS/DSMLIB/DsmFwPrgLib.lua")(DEBUG_ON) +local dsmLib = assert(loadScript("/SCRIPTS/TOOLS/DSMLIB/DsmFwPrgLib.lua"))(DEBUG_ON) local PHASE = dsmLib.PHASE local LINE_TYPE = dsmLib.LINE_TYPE diff --git a/Lua_scripts/DSMLIB/readme.md b/Lua_scripts/DSMLIB/readme.md index c640887..1a27f2f 100644 --- a/Lua_scripts/DSMLIB/readme.md +++ b/Lua_scripts/DSMLIB/readme.md @@ -27,6 +27,10 @@ Please report of you have test it with other receivers to update the documentati If you get `"Unable to Load menu lines"` when trying to navidate to a menu, could be that the code needs to be specially adapter to mandle that menu in a different way than others. We did that HACK for AR631/AR637 for the `Initial Setup` and `Initial Safe Setup` menus. Before starting the script again, the problem shouls show at the log. Usually not been able to process some `Unknown_0x5` lines who has not been fully reversed engineered (you can share the logs with us to try to understand what is going on. +# Flight mode/Gain channels + +I ran into a case where trying to set Aux2 or Aux3 for flight mode, but the RX was correcting it to Aux1.. the RX only was allowing Gear or Aux1 (AR631/AR637). +This is because the RX don't know that we are using more than 6 channels. To make the RX aware that there are other channels, while edditing the channel, you have to toggle the switch to excersist the channel, and now the RX will recognize it. # Deployment