Skip to content

Commit d3cd1dc

Browse files
committed
First implementation sending date time over MSP
1 parent fc03833 commit d3cd1dc

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

X9.lua

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
-- load msp.lua
2+
assert(loadScript("/SCRIPTS/BF/msp_sp.lua"))()
3+
4+
-- pages
15
SetupPages = {
26
{
37
title = "PIDs",
@@ -69,5 +73,36 @@ MenuBox = { x=40, y=12, w=120, x_offset=36, h_line=8, h_offset=3 }
6973
SaveBox = { x=40, y=12, w=120, x_offset=4, h=30, h_offset=5 }
7074
NoTelem = { 70, 55, "No Telemetry", BLINK }
7175

76+
--
77+
-- THIS CODE HAS TO BE MOVED TO A SEPERATE LUA FILE
78+
--
79+
80+
local MSP_SET_TX_INFO = 187
81+
82+
--
83+
84+
local INTERVAL = 200 -- 100 = 1 second, 200 = 2 seconds, ...
85+
local lastSendTS = 0
86+
87+
local function run_bg()
88+
89+
if lastSendTS == 0 or lastSendTS + INTERVAL < getTime() then
90+
local now = getDateTime()
91+
local values = { now.year-2000, now.mon, now.day, now.hour, now.min, now.sec, getRSSI().rssi }
92+
93+
-- send info
94+
mspSendRequest(MSP_SET_TX_INFO, values)
95+
96+
playNumber(getTime(), 0, 0)
97+
98+
lastSendTS = getTime()
99+
end
100+
101+
end
102+
103+
--
104+
-- END
105+
--
106+
72107
local run_ui = assert(loadScript("/SCRIPTS/BF/ui.lua"))()
73-
return {run=run_ui}
108+
return { run=run_ui, background=run_bg }

common/ui.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
-- load msp.lua
2-
assert(loadScript("/SCRIPTS/BF/msp_sp.lua"))()
3-
41
-- getter
52
local MSP_RC_TUNING = 111
63
local MSP_PID = 112

0 commit comments

Comments
 (0)