Skip to content

Commit

Permalink
Merge pull request #4 from teckel12/development
Browse files Browse the repository at this point in the history
More consolidation, removed crossfire (as it doesn't work with Lua Te…
  • Loading branch information
teckel12 authored Aug 10, 2018
2 parents b15dbe3 + dc84bee commit 41a7d42
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 132 deletions.
54 changes: 51 additions & 3 deletions SCRIPTS/TELEMETRY/VTx.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,60 @@
SCRIPT_HOME = "/SCRIPTS/TELEMETRY/VTx"
LOCAL_SENSOR_ID = 0x0D
SMARTPORT_REMOTE_SENSOR_ID = 0x1B
FPORT_REMOTE_SENSOR_ID = 0x00
REQUEST_FRAME_ID = 0x30
REPLY_FRAME_ID = 0x32

MenuBox = { x=15, y=12, w=100, x_offset=36, h_line=8, h_offset=3 }
SaveBox = { x=15, y=12, w=100, x_offset=4, h=30, h_offset=5 }
NoTelem = { 30, 55, "No Telemetry", BLINK }

protocol = assert(loadScript(SCRIPT_HOME.."/protocols.luac", "T"))()
assert(loadScript(protocol.transport, "T"))()
collectgarbage()
protocol = {
rssi = function() return getValue("RSSI") end,
exitFunc = function() return 0 end,
stateSensor = "Tmp1",
push = sportTelemetryPush,
maxTxBufferSize = 6,
maxRxBufferSize = 6,
saveMaxRetries = 2,
saveTimeout = 300
}

protocol.mspSend = function(payload)
local dataId = 0
dataId = payload[1] + bit32.lshift(payload[2],8)
local value = 0
value = payload[3] + bit32.lshift(payload[4],8)
+ bit32.lshift(payload[5],16) + bit32.lshift(payload[6],24)
return sportTelemetryPush(LOCAL_SENSOR_ID, REQUEST_FRAME_ID, dataId, value)
end

protocol.mspRead = function(cmd)
return mspSendRequest(cmd, {})
end

protocol.mspWrite = function(cmd, payload)
return mspSendRequest(cmd, payload)
end

protocol.mspPoll = function()
local sensorId, frameId, dataId, value = sportTelemetryPop()
if (sensorId == SMARTPORT_REMOTE_SENSOR_ID or sensorId == FPORT_REMOTE_SENSOR_ID) and frameId == REPLY_FRAME_ID then
local payload = {}
payload[1] = bit32.band(dataId,0xFF)
dataId = bit32.rshift(dataId,8)
payload[2] = bit32.band(dataId,0xFF)
payload[3] = bit32.band(value,0xFF)
value = bit32.rshift(value,8)
payload[4] = bit32.band(value,0xFF)
value = bit32.rshift(value,8)
payload[5] = bit32.band(value,0xFF)
value = bit32.rshift(value,8)
payload[6] = bit32.band(value,0xFF)
return mspReceivedReply(payload)
end
return nil
end

assert(loadScript(SCRIPT_HOME.."/common.luac", "T"))()
collectgarbage()
Expand Down
Binary file modified SCRIPTS/TELEMETRY/VTx.luac
Binary file not shown.
43 changes: 0 additions & 43 deletions SCRIPTS/TELEMETRY/VTx/crsf.lua

This file was deleted.

Binary file removed SCRIPTS/TELEMETRY/VTx/crsf.luac
Binary file not shown.
44 changes: 0 additions & 44 deletions SCRIPTS/TELEMETRY/VTx/protocols.lua

This file was deleted.

Binary file removed SCRIPTS/TELEMETRY/VTx/protocols.luac
Binary file not shown.
42 changes: 0 additions & 42 deletions SCRIPTS/TELEMETRY/VTx/sp.lua

This file was deleted.

Binary file removed SCRIPTS/TELEMETRY/VTx/sp.luac
Binary file not shown.

0 comments on commit 41a7d42

Please sign in to comment.