Skip to content

Commit 6297810

Browse files
Updated Ch naming across all display, and updated Docs (#786)
* #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 * #751 New v0.51 version. - Added new menus to configure Model/Wing type. Without it, the initial setup will not work properly. * #751 More fixes on mixers and servo reverse -- Fix problem reversing servos when using vtail/delta mix -- Properly detect ch order of multimodule * #751 Updated channel naming and docs Updated readme documentation Consistent naming of Ch across the code. Co-authored-by: pascallanger <pascal_langer@yahoo.fr>
1 parent 01aef0a commit 6297810

File tree

5 files changed

+77
-65
lines changed

5 files changed

+77
-65
lines changed

Lua_scripts/DSM FwdPrg_05_Color.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ local VERSION = "v0.52"
2727
-- Rewrite/Enhancements By: Francisco Arzu
2828
------------------------------------------------------------------------------
2929

30-
local SIMULATION_ON = true -- FALSE: use real communication to DSM RX (DEFAULT), TRUE: use a simulated version of RX
30+
local SIMULATION_ON = false -- FALSE: use real communication to DSM RX (DEFAULT), TRUE: use a simulated version of RX
3131
local DEBUG_ON = 1 -- 0=NO DEBUG, 1=HIGH LEVEL 2=LOW LEVEL (Debug logged into the /LOGS/dsm.log)
3232
local DEBUG_ON_LCD = false -- Interactive Information on LCD of Menu data from RX
3333
local USE_SPECKTRUM_COLORS = true -- true: Use spectrum colors, false: use theme colors (default on OpenTX)

Lua_scripts/DSMLIB/DsmFwPrgLib.lua

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ local DSM_Context = {
126126
local MODEL = {
127127
modelName = "", -- The name of the model comming from OTX/ETX
128128
modelOutputChannel = {}, -- Output information from OTX/ETX
129+
130+
TX_CH_TEXT = {},
129131
PORT_TEXT = {},
130132
DSM_ChannelInfo = {} -- Data Created by DSM Configuration Script
131133
}
@@ -596,14 +598,14 @@ local function DSM_ReadTxModelData()
596598

597599
-- Read Ch1 to Ch10
598600
local i= 0
599-
for i = 0, 9 do
601+
for i = 0, 12 do
600602
local ch = model.getOutput(i) -- Zero base
601603
if (ch~=nil) then
602604
MODEL.modelOutputChannel[i] = ch
603605
if (string.len(ch.name)==0) then
604-
ch.formatName = string.format("TX:Ch%i",i+1)
606+
ch.formatCh = string.format("TX:Ch%i",i+1)
605607
else
606-
ch.formatName = string.format("TX:Ch%i/%s",i+1,ch.name or "--")
608+
ch.formatCh = string.format("TX:Ch%i/%s",i+1,ch.name or "--")
607609
end
608610
end
609611
end
@@ -628,8 +630,9 @@ local function DSM_ReadTxModelData()
628630
for i = 0, 9 do
629631
local ch = MODEL.modelOutputChannel[i]
630632
if (ch~=nil) then
631-
MODEL.PORT_TEXT[i] = string.format("Port%i (%s) ",i+1,ch.formatName)
632-
LOG_write("Port%d %s [%d,%d] Rev=%d, Off=%d, ppmC=%d, syn=%d\n",i+1,ch.formatName,math.floor(ch.min/10),math.floor(ch.max/10), ch.revert, ch.offset, ch.ppmCenter, ch.symetrical)
633+
MODEL.TX_CH_TEXT[i] = ch.formatCh
634+
MODEL.PORT_TEXT[i] = string.format("Port%i (%s) ",i+1,MODEL.TX_CH_TEXT[i])
635+
LOG_write("Port%d %s [%d,%d] Rev=%d, Off=%d, ppmC=%d, syn=%d\n",i+1,MODEL.TX_CH_TEXT[i],math.floor(ch.min/10),math.floor(ch.max/10), ch.revert, ch.offset, ch.ppmCenter, ch.symetrical)
633636
end
634637
end
635638
end
@@ -1386,6 +1389,11 @@ local function DSM_Init_Text(rxId)
13861389
-- usually is Ihnibit + range of contiguos values, but cant seems to find in the RX data receive the values
13871390
-- to do it automatically
13881391

1392+
local function getTxChText(ch)
1393+
return " ("..(MODEL.TX_CH_TEXT[ch] or "--")..")"
1394+
end
1395+
1396+
13891397
List_Text[0x0001] = "Off"
13901398
List_Text[0x0002] = "On"
13911399

@@ -1395,8 +1403,7 @@ local function DSM_Init_Text(rxId)
13951403

13961404
-- Channel selection for SAFE MODE and GAINS on FC6250HX
13971405
List_Text[0x000C] = "Inhibit?" --?
1398-
List_Text[0x000D] = "Ch5 (Gear)"
1399-
for i = 1, 7 do List_Text[0x000D + i] = "Ch"..(i+5) .. " (Aux" .. i .. ")" end -- Aux channels
1406+
for i = 0, 7 do List_Text[0x000D + i] = "Ch"..(i+5) ..getTxChText(i+4) end -- Aux channels (Ch5 and Greater)
14001407

14011408
-- Servo Output values..
14021409
local servoOutputValues = {0x0003,0x002D,0x002E,0x002F} --Inh (GAP), 5.5ms, 11ms, 22ms. Fixing L_m1 with 0..244 range!
@@ -1416,15 +1423,10 @@ local function DSM_Init_Text(rxId)
14161423
local channelValues = {0x0035,0x003A,0x003B,0x003C,0x003D,0x003E,0x003F,0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048,0x0049}
14171424

14181425
List_Text[0x0035] = "Inhibit?"
1419-
List_Text[0x0036] = "Throttle"
1420-
List_Text[0x0037] = "Aileron"
1421-
List_Text[0x0038] = "Elevator"
1422-
List_Text[0x0039] = "Rudder"
1423-
List_Text[0x003A] = "Ch5 (Gear)"
1424-
for i = 1, 7 do List_Text[0x003A + i] = "Ch"..(i+5) .. " (Aux" .. i .. ")" end -- Aux channels on AR637T
1426+
for i = 0, 11 do List_Text[0x0036 + i] = "Ch"..(i+1) .. getTxChText(i) end -- Channels on AR637T
14251427

14261428
for i = 1, 8 do -- 41..49
1427-
List_Text[0x0041 + i] = "Ch"..(i+13) .." (XPlus-" .. i .. ")"
1429+
List_Text[0x0041 + i] = "Ch"..(i+13)
14281430
end
14291431

14301432
-- ****No longer overrides of previous XPlus values, since using different array
@@ -1526,7 +1528,7 @@ local function DSM_Init_Text(rxId)
15261528
Text[0x00C7] = "Calibrate Sensor"
15271529
Text[0x00C8] = "Complete" -- FC6250HX calibration complete
15281530
Text[0x00CA] = "SAFE/Panic Mode Setup"
1529-
Text[0x00CD] = "Level model and capture attiude/M"; -- Different from List_Text , and force it to be a menu button
1531+
Text[0x00CD] = "Level model and capture attitude/M"; -- Different from List_Text , and force it to be a menu button
15301532

15311533
-- RX Orientations for AR631/AR637, Optionally attach an Image + Alt Text to display
15321534
List_Text[0x00CB] = "Position 1"; List_Text_Img[0x00CB] = "rx_pos_1.png|Pilot View: RX Label Up, Pins Back"
@@ -1725,9 +1727,9 @@ local function DSM_Init_Text(rxId)
17251727
Text[0x026A] = "Use CAUTION for Yaw gain!/b" -- SubTitle
17261728

17271729
Text[0x8000] = "Flight Mode/c/b" --FC6250HX: 1=NORMAL 2= Stunt-1, 3=Stunt-2, 4=Hold
1728-
Text[0x8001] = "Flight Mode/c/b" -- WAS "Flight Mode 1".. This usually is a Flight Mode w value relative to 0 (AR631/AR637)
1729-
Text[0x8002] = "Flight Mode 2/c/b" -- what RX does this show up??
1730-
Text[0x8003] = "Flight Mode 3/c/b"
1730+
Text[0x8001] = "Flight Mode/c/b" --AR63X family: WAS "Flight Mode 1".. This usually is a Flight Mode w value relative to 0 (AR631/AR637)
1731+
Text[0x8002] = "Flight Mode/c/b" -- what RX does this show up??
1732+
Text[0x8003] = "Flight Mode/c/b"
17311733
end
17321734

17331735
-- Adjust the displayed value for Flight mode line as needed
@@ -1750,14 +1752,14 @@ local function GetFlightModeValue(line)
17501752
end
17511753
else
17521754
-- No adjustment needed
1753-
out = header .. " " .. value
1755+
out = header .. " " .. (value + 1)
17541756
end
17551757
elseif (textId == 0x8001) then -- AR630-637, AR8360T, AR10360T
17561758
-- Seems that we really have to add +1 to the value, so Flight Mode 0 is Really Flight Mode 1
17571759
out = header .. " " .. (value + 1)
17581760
else
17591761
-- Default, return the value as we Have it
1760-
out = header .. " " .. value
1762+
out = header .. " " .. (value + 1)
17611763
end
17621764
return out
17631765
end

Lua_scripts/DSMLIB/DsmSetupLib.lua

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
-- Author: Francisco Arzu
2424
------------------------------------------------------------------------------
2525

26-
2726
local DEBUG_ON, SIMULATION_ON = ... -- Get DebugON from parameters
2827
local SETUP_LIB_VERSION = "0.52"
2928

30-
local DATA_PATH = "/SCRIPTS/TOOLS/DSMLIB/data/" -- Path to store model settings files
29+
local DATA_PATH = "/MODELS/DSMDATA" -- Path to store model settings files
3130
local dsmLib = assert(loadScript("/SCRIPTS/TOOLS/DSMLIB/DsmFwPrgLib.lua"))(DEBUG_ON)
3231

3332
local PHASE = dsmLib.PHASE
@@ -151,10 +150,10 @@ local function printChannelSummary()
151150
end
152151

153152
local function printServoReverseInfo()
154-
print("SERVO Normal/Reversed INFORMATION")
153+
print("SERVO Normal/Reverse INFORMATION")
155154
for i=0,10 do
156155
local s="--"
157-
if (MENU_DATA[MEMU_VAR.PORT1_MODE+i] or 0) == 0 then s="NORMAL" else s="REVERT" end
156+
if (MENU_DATA[MEMU_VAR.PORT1_MODE+i] or 0) == 0 then s="NORMAL" else s="REVERSE" end
158157
print(string.format("Port%d: %s", i+1, s))
159158
end
160159
end
@@ -415,7 +414,7 @@ function ST_LoadFileData()
415414

416415
print("Loading File:"..fname)
417416

418-
local dataFile = io.open(DATA_PATH .. fname, "r") -- read File
417+
local dataFile = io.open(DATA_PATH .. "/".. fname, "r") -- read File
419418
-- cannot read file???
420419
if (dataFile==nil) then return 0 end
421420

@@ -459,7 +458,7 @@ function ST_SaveFileData()
459458
local fname = hashName(MODEL.modelName)..".txt"
460459

461460
print("Saving File:"..fname)
462-
local dataFile = io.open(DATA_PATH .. fname, "w") -- write File
461+
local dataFile = assert(io.open(DATA_PATH .. "/" .. fname, "w"),"Please create "..DATA_PATH.." folder") -- write File
463462

464463
-- Foreach MENU_DATA with a value write Var_Id:Value into file
465464
for i = 0, MEMU_VAR.DATA_END do
@@ -688,7 +687,7 @@ local function ST_LoadMenu(menuId)
688687
local ctx = dsmLib.DSM_Context
689688

690689
local function formatTXRevert(port)
691-
return ((MODEL.modelOutputChannel[port].revert==0 and " (Tx:Normal)") or " (Tx:Reverted)")
690+
return ((MODEL.modelOutputChannel[port].revert==0 and " (Tx:Normal)") or " (Tx:Reverse)")
692691
end
693692

694693
clearMenuLines()
@@ -1030,8 +1029,8 @@ local function ST_Init_Text(rxId)
10301029
List_Text[200+TAIL_TYPE.TRAILERON_B] = "Traileron B"; List_Text_Img[200+TAIL_TYPE.TRAILERON_B] = "tt_traileron.png|Traileron B"
10311030

10321031
-- Servo Reverse
1033-
List_Text[300+CH_MODE_TYPE.NORMAL] = "Normal "
1034-
List_Text[300+CH_MODE_TYPE.REVERSE] = "Reverted"
1032+
List_Text[300+CH_MODE_TYPE.NORMAL] = "Normal "
1033+
List_Text[300+CH_MODE_TYPE.REVERSE] = "Reverse"
10351034

10361035
end
10371036

Lua_scripts/DSMLIB/data/readme.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

Lua_scripts/DSMLIB/readme.md

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,66 @@
11
# Credits
22
Code is based on the code/work by: Pascal Langer (Author of the Multi-Module)
3+
Rewrite/Enhancements by: Francisco Arzu
34

4-
Rewrite/Enhancements By: Francisco Arzu
5+
Thanks to many other people who volunteer to test it.
56

6-
# Introduction
7+
# Introduction (v0.52)
78

8-
This script library is a rewrite of the original DSM forward programming Lua
9-
Script. The goal was to make it easier to understand, mantain, and to
10-
separate the GUI from the DSM Forward programming engine/logic.
11-
In this way, GUIs can evolve independent. Color/Touch Gui, Text only GUI, etc.
9+
This script library enhace the original DSM Forward Programming tool. DSM Forward Programming is needed to setup many of
10+
the new Spektrum Receivers with Gyro AS3X/SAFE features. For the Gyro (/Safe) to correct the plane in flight, it needs to move the right surfaces, the RX needs to know the
11+
configuration of the plane (Wing Type, Tail Type, Mixers, Servo Assigments, Servo Reverse). That info tells the RX where the aileron(s) are (one of two), where the elevator(s) are (one or two), V-Tail, Delta Wing, etc.
1212

13-
Changes and fixes
14-
1. Menus to be able to configure Plane in a similar way as Spektrum Radio
13+
Since EdgeTx/OpenTx don't have equivalent setup that is persisted/stored in the radio, we had to create our own version. This info is stored inside the `/MODELS/DSMDATA` directory/folder (needs to be created by hand).
14+
15+
During `"Gyro Settings->initial setup"`, the RX asks the TX for model information behind the scenes. After setup, `"Gyro Settings->System Tools-> Relearn Servo Settings"` request the TX configuration and store it in the RX.
16+
17+
# Deployment
18+
Make sure to manually create `/MODELS/DSMDATA` . The script will complain at startup.
19+
20+
/SCRIPTS/TOOLS/DsmFwdPrg_05_BW.lua -- black/white text only radios
21+
/SCRIPTS/TOOLS/DsmFwdPrg_05_Color.lua -- Color+touch radios
22+
/SCRIPTS/TOOLS/DSMLIB/ -- (ALL CAPITALS) Libraries ane extra files
23+
/SCRIPTS/TOOLS/DSMLIB/DsmFwPrgLib.lua -- DSM Protocol Message and Menu engine
24+
/SCRIPTS/TOOLS/DSMLIB/DsmFwPrgSIMLib.lua -- Simulation of AR631, FC6250HX
25+
/SCRIPTS/TOOLS/DSMLIB/SetupLib.lua -- Model Setup Screns
26+
/SCRIPTS/TOOLS/DSMLIB/img --Images for RX orientations
27+
28+
Other Directories
29+
30+
/MODELS/DSMDATA --(ALL CAPITALS) Data of model config (Wing Type, Servo Assigments)
31+
/LOGS/dsm_log.txt --Readable log of the last RX/TX session, usefull for debuging problems
32+
33+
When upgrading from a previous version of this tool, delete your /SCRIPTS/TOOLS/DSMLIB before copying the new one (if you customized your images, inside "DSMLIB/img" do a backup first)
34+
35+
# Common Questions
36+
1. `RX not accepting channels greater Ch6 for Flight-mode o Gains:` The RX corrects your channel to ch5 or ch6. This means that the RX is not detecting the upper channles from the TX. You need to exersise (move the switch) so that the RX detects it. Put the Channel Field on edit (changing) mode, change it to Ch7 (or any other), flip the switch for Ch7 3 times, now confim the edit. The RX now will not reject it. All Spektrum RX are 20 channels internally, even if it only have 6 external Ch/Ports to connect servos.
37+
38+
2. `Why Ch1 says Ch1 (TX:Ch3/Thr)?`:
39+
Radios with Multi-Module are usually configured to work the standard AETR convention. Spektrum uses TAER. The multi-module does the conversion when transmiting the signals. So `Spektrum Ch1 (Throttle)` really comes from the `TX Ch3`. We show both information (+name from the TX output). If your multi-module/radio is setup as TAER, the script will not do the re-arrangement.
40+
41+
---
42+
---
43+
44+
# Changes and fixes
45+
1. Menus to be able to configure Plane in a similar way as Spektrum Radio (v0.52)
1546
1. Make "Gyro Settings"->"Initial Setup" works (Tested on AR631,AR637xx with PLANE type of arcraft)
1647
2. Properly reset and restart after initial configuration and SAFE changes.
1748
3. Write Log of the conversation between RX/TX. To be use for debugging when some reports a problem.
1849
4. Provide a simulation of RX to do GUI development in Companion, and undestand patterns of how the data is organized.
1950

2051
# Tested RXs
21-
- AR631/AR637xx Coded a hack to be able to make `Initial Setup` to work
22-
- FC6250HX (Helicopter)
23-
24-
Most RX will run without problems, it could be that some others receivers will need to apply the same hack as the AR631 for some specific menus to work.
25-
Since is RX and Menu specific, we cannot create a general hack.
52+
- AR631/AR637xx
53+
- FC6250HX (Blade 230S V2 Helicopter)
54+
- AR636 (Blade 230S V1 Heli firmaware 4.40)
2655

27-
Please report of you have test it with other receivers to update the documentation.
56+
Please report of you have test it with other receivers to update the documentation. Code should work up to 10 channels for the main surfaces (Ail/Ele/etc). All Spektrum RX are internally 20 channels, so you can use Ch7 for Flight Mode even if your RX is only 6 channels (See common Questions)
2857

2958
# Flight mode/Gain channels
3059

3160
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).
3261
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 (3 times), and now the RX will recognize it.
3362

34-
# Deployment
3563

36-
/SCRIPTS/TOOLS/DsmFwdPrg_05_BW.lua -- black/white text only radios
37-
/SCRIPTS/TOOLS/DsmFwdPrg_05_Color.lua -- Color+touch radios
38-
/SCRIPTS/TOOLS/DSMLIB/ -- (ALL CAPITALS) Libraries ane extra files
39-
/SCRIPTS/TOOLS/DSMLIB/DsmFwPrgLib.lua -- DSM Protocol Message and Menu engine
40-
/SCRIPTS/TOOLS/DSMLIB/DsmFwPrgSIMLib.lua -- Simulation of AR631, FC6250HX
41-
/SCRIPTS/TOOLS/DSMLIB/SetupLib.lua -- Model Setup Screns
42-
/SCRIPTS/TOOLS/DSMLIB/img --Images for RX orientations
43-
/SCRIPTS/TOOLS/DSMLIB/data --Data of model config (Wing Type, Servo Assigments)
44-
/LOGS/dsm_log.txt --Readable log of the last RX/TX session, usefull for debuging new RX
4564

4665
# Messages Displayed in the GUI
4766

@@ -131,7 +150,7 @@ If you go to the logs, you can see that the RX was correcting the value:
131150
- Properly detect Moltimodule Ch settings AETR
132151
---
133152

134-
# Version 0.51
153+
# Version 0.51 (voluteer testing version, not for production)
135154
- New Screens to Configure Model (Wing Type/Tail Tail, etc)
136155
- Finally got understanding that the previous unknown 0x05 lines are to send Model/Servo data to RX.
137156
- Fix use of AR636B (Firmare version 4.40.0 for Blade 230 heli, is the only one with Forward Programing)
@@ -165,10 +184,9 @@ If you go to the logs, you can see that the RX was correcting the value:
165184
1. **Incorrect List Value Options:** Some Menu List line (`LINE_TYPE.LIST_MENU1` or `L_m1` in logs), the range (min/max) of valid values seems to be incorrect, but cannot see in the data how to fix it.
166185
Some of the valid values are not even sequential, very spread apart. There has to be a list of valid options somewhere. Currently fixed some by overriding the valid values in the script code (config for each field).
167186

168-
2. **Unable to Load menu lines**: The RX return unknow lines when requesting menu lines. **Realy don't understand what they are for**. Some menus
169-
seems to stay stuck in the same return line or no response to the request, making the RX reset/close the connection and terminate.
170-
Was able to hack it for AR631/AR637 `"First Time Setup"`, `"First Time SAFE Setup"`, and `"Servo Realm"`. Maybe this hack will work in other RX, so let us know if you get this problem.
187+
2. Glider/Heli/Drone wing types not ready.
171188

189+
For Helicopter, use airplane normal wing and normal tail
172190

173191

174192
# Version 0.2

0 commit comments

Comments
 (0)