Skip to content

Commit 94e6dbc

Browse files
committed
More memory savings
1 parent 9b14264 commit 94e6dbc

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

src/SCRIPTS/BF/MSP/common.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
-- Protocol version
3-
MSP_VERSION = bit32.lshift(1,5)
4-
MSP_STARTFLAG = bit32.lshift(1,4)
2+
local MSP_VERSION = bit32.lshift(1,5)
3+
local MSP_STARTFLAG = bit32.lshift(1,4)
54

65
-- Sequence number for next MSP packet
76
local mspSeq = 0
@@ -17,8 +16,6 @@ local mspTxIdx = 1
1716
local mspTxCRC = 0
1817
local mspTxPk = 0
1918

20-
mspPendingRequest = false
21-
2219
function mspProcessTxQ()
2320
if (#(mspTxBuf) == 0) then
2421
return false

src/SCRIPTS/BF/MSP/crsf.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
21
-- CRSF Devices
3-
CRSF_ADDRESS_BETAFLIGHT = 0xC8
4-
CRSF_ADDRESS_RADIO_TRANSMITTER = 0xEA
2+
local CRSF_ADDRESS_BETAFLIGHT = 0xC8
3+
local CRSF_ADDRESS_RADIO_TRANSMITTER = 0xEA
54
-- CRSF Frame Types
6-
CRSF_FRAMETYPE_MSP_REQ = 0x7A -- response request using msp sequence as command
7-
CRSF_FRAMETYPE_MSP_RESP = 0x7B -- reply with 60 byte chunked binary
8-
CRSF_FRAMETYPE_MSP_WRITE = 0x7C -- write with 60 byte chunked binary
5+
local CRSF_FRAMETYPE_MSP_REQ = 0x7A -- response request using msp sequence as command
6+
local CRSF_FRAMETYPE_MSP_RESP = 0x7B -- reply with 60 byte chunked binary
7+
local CRSF_FRAMETYPE_MSP_WRITE = 0x7C -- write with 60 byte chunked binary
98

109
crsfMspCmd = 0
11-
crsfMspHeader = {}
1210

1311
protocol.mspSend = function(payload)
1412
local payloadOut = { CRSF_ADDRESS_BETAFLIGHT, CRSF_ADDRESS_RADIO_TRANSMITTER }

src/SCRIPTS/BF/MSP/sp.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
2-
LOCAL_SENSOR_ID = 0x0D
3-
SMARTPORT_REMOTE_SENSOR_ID = 0x1B
4-
FPORT_REMOTE_SENSOR_ID = 0x00
5-
REQUEST_FRAME_ID = 0x30
6-
REPLY_FRAME_ID = 0x32
1+
local LOCAL_SENSOR_ID = 0x0D
2+
local SMARTPORT_REMOTE_SENSOR_ID = 0x1B
3+
local FPORT_REMOTE_SENSOR_ID = 0x00
4+
local REQUEST_FRAME_ID = 0x30
5+
local REPLY_FRAME_ID = 0x32
76

87
local lastSensorId, lastFrameId, lastDataId, lastValue
98

src/SCRIPTS/BF/protocols.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ local supportedProtocols =
2626
}
2727
}
2828

29-
function getProtocol()
29+
local function getProtocol()
3030
if supportedProtocols.smartPort.push() then
3131
return supportedProtocols.smartPort
3232
elseif supportedProtocols.crsf.push() then

src/SCRIPTS/BF/ui.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ end
4848

4949
local function saveSettings(new)
5050
if Page.values then
51+
local payload = {}
5152
if Page.preSave then
5253
payload = Page.preSave(Page)
5354
else
54-
payload = {}
5555
for i=1,(Page.outputBytes or #Page.values) do
5656
payload[i] = Page.values[i]
5757
end

0 commit comments

Comments
 (0)