Skip to content

Commit 93a2cc8

Browse files
authored
Version 0.55 (#883)
1 parent abfebb3 commit 93a2cc8

32 files changed

Lines changed: 3555 additions & 3958 deletions

Lua_scripts/DSM FwdPrg_05_BW.lua

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

Lua_scripts/DSM FwdPrg_05_Color.lua

Lines changed: 220 additions & 138 deletions
Large diffs are not rendered by default.

Lua_scripts/DSM FwdPrg_05_MIN.lua

Lines changed: 510 additions & 396 deletions
Large diffs are not rendered by default.

Lua_scripts/DSMLIB/DSM Fwd Prog Protocol.md

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

Lua_scripts/DSMLIB/DsmFwPrgLib.lua

Lines changed: 284 additions & 1109 deletions
Large diffs are not rendered by default.

Lua_scripts/DSMLIB/DsmLogLib.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
local LogLib = { }
2+
3+
local LOG_FILE = "/LOGS/dsm_log.txt"
4+
local logFile = nil
5+
local logCount=0
6+
7+
function LogLib.LOG_open()
8+
logFile = io.open(LOG_FILE, "w") -- Truncate Log File
9+
end
10+
11+
function LogLib.LOG_write(...)
12+
if (logFile==nil) then LogLib.LOG_open() end
13+
local str = string.format(...)
14+
15+
if (str==nil) then return end
16+
17+
io.write(logFile, str)
18+
19+
str = string.gsub(str,"\n"," ") -- Elimitate return from line, since print will do it
20+
print(str)
21+
22+
if (logCount > 10) then -- Close an re-open the file
23+
io.close(logFile)
24+
logFile = io.open(LOG_FILE, "a")
25+
logCount =0
26+
end
27+
end
28+
29+
function LogLib.LOG_close()
30+
if (logFile~=nil) then io.close(logFile) end
31+
end
32+
33+
return LogLib
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
local Log, menuLib, modelLib, DEBUG_ON, SIMULATION_ON = ... -- Get DebugON from parameters
2+
local MAIN_MENU_LIB_VERSION = "0.55"
3+
local MODEL = modelLib.MODEL
4+
5+
local PHASE = menuLib.PHASE
6+
local LINE_TYPE = menuLib.LINE_TYPE
7+
8+
local lastGoodMenu=0
9+
10+
-- Creates the menus to Render with the GUI
11+
local function ST_LoadMenu(menuId)
12+
local ctx = menuLib.DSM_Context
13+
menuLib.clearMenuLines()
14+
15+
if (menuId==0x1000) then -- MAIN MENU
16+
ctx.Menu = { MenuId = 0x1000, Text = "Main Menu ("..MODEL.modelName..")", PrevId = 0, NextId = 0, BackId = 0, TextId=0 }
17+
ctx.MenuLines[0] = { Type = LINE_TYPE.MENU, Text = "Model Setup", ValId = 0xFFF3,TextId=0 }
18+
19+
if (SIMULATION_ON) then
20+
ctx.MenuLines[4] = { Type = LINE_TYPE.MENU, Text = "RX Simulator (GUI dev only)", ValId = 0xFFF1, TextId=0 } -- Menu 0xFFF2 to SIMULATOR
21+
end
22+
ctx.MenuLines[6] = { Type = LINE_TYPE.MENU, Text = "Forward Programming RX", ValId = 0xFFF2, TextId=0 } -- Menu 0xFFF2 to Real RX
23+
ctx.SelLine = 6
24+
25+
lastGoodMenu = menuId
26+
else
27+
--print("NOT IMPLEMENTED")
28+
ctx.Menu = { MenuId = 0x0002, Text = "NOT IMPLEMENTED", TextId = 0, PrevId = 0, NextId = 0, BackId = lastGoodMenu }
29+
ctx.SelLine = menuLib.BACK_BUTTON
30+
end
31+
32+
menuLib.PostProcessMenu()
33+
end
34+
35+
local function Main_Send_Receive()
36+
local ctx = menuLib.DSM_Context
37+
38+
if ctx.Phase == PHASE.RX_VERSION then -- Just Init RX Version
39+
ctx.RX.Name = "Main Menu"
40+
ctx.RX.Version = MAIN_MENU_LIB_VERSION
41+
ctx.Phase = PHASE.MENU_TITLE
42+
ctx.Menu.MenuId = 0
43+
44+
ctx.Refresh_Display = true
45+
elseif ctx.Phase == PHASE.WAIT_CMD then
46+
47+
elseif ctx.Phase == PHASE.MENU_TITLE then -- request menu title
48+
if ctx.Menu.MenuId == 0 then -- First time loading a menu ?
49+
ST_LoadMenu(0x01000)
50+
else
51+
ST_LoadMenu(ctx.Menu.MenuId)
52+
end
53+
ctx.Phase = PHASE.WAIT_CMD
54+
ctx.Refresh_Display = true
55+
56+
elseif ctx.Phase == PHASE.VALUE_CHANGING then -- send value
57+
local line = ctx.MenuLines[ctx.SelLine] -- Updated Value of SELECTED line
58+
--if (DEBUG_ON) then Log.LOG_write("%3.3f %s: ", menuLib.getElapsedTime(), menuLib.phase2String(ctx.Phase)) end
59+
--if (DEBUG_ON) then Log.LOG_write("SEND SIM_updateMenuValue(ValueId=0x%X Text=\"%s\" Value=%s)\n", line.ValId, line.Text, menuLib.lineValue2String(line)) end
60+
ctx.Phase = PHASE.VALUE_CHANGING_WAIT
61+
62+
elseif ctx.Phase == PHASE.VALUE_CHANGING_WAIT then
63+
local line = ctx.MenuLines[ctx.SelLine]
64+
65+
elseif ctx.Phase == PHASE.VALUE_CHANGE_END then -- send value
66+
local line = ctx.MenuLines[ctx.SelLine] -- Updated Value of SELECTED line
67+
--if (DEBUG_ON) then Log.LOG_write("%3.3f %s: ", menuLib.getElapsedTime(), menuLib.phase2String(ctx.Phase)) end
68+
--if (DEBUG_ON) then Log.LOG_write("SEND SIM_updateMenuValue(ValueId=0x%X Text=\"%s\" Value=%s)\n", line.ValId, line.Text, menuLib.lineValue2String(line)) end
69+
--if (DEBUG_ON) then Log.LOG_write("SEND SIM_validateMenuValue(ValueId=0x%X Text=\"%s\" Value=%s)\n", line.ValId, line.Text, menuLib.lineValue2String(line)) end
70+
ctx.Phase = PHASE.WAIT_CMD
71+
72+
elseif ctx.Phase == PHASE.EXIT then
73+
ctx.Phase=PHASE.EXIT_DONE
74+
return 1
75+
end
76+
77+
return 0
78+
end
79+
80+
local function Main_Init()
81+
local ctx = menuLib.DSM_Context
82+
ctx.Phase = PHASE.RX_VERSION
83+
end
84+
85+
local function Main_Done()
86+
local ctx = menuLib.DSM_Context
87+
ctx.Phase = PHASE.EXIT_DONE
88+
end
89+
90+
return { init=Main_Init, run=Main_Send_Receive, done=Main_Done }

0 commit comments

Comments
 (0)