Skip to content

Commit

Permalink
lora-sx126x: Clean up some struct formatting.
Browse files Browse the repository at this point in the history
Changes are cosmetic - and maybe very minor code size - but not functional.
_reg_read() was calling struct.packinto() with an incorrect number of
arguments but it seems like MicroPython didn't mind, as result is correct
for both versions.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
  • Loading branch information
projectgus authored and dpgeorge committed Feb 20, 2024
1 parent 35bb795 commit 2242465
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions micropython/lora/lora-sx126x/lora/sx126x.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def calibrate(self):
# See DS 13.1.12 Calibrate Function

# calibParam 0xFE means to calibrate all blocks.
self._cmd("<BB", _CMD_CALIBRATE, 0xFE)
self._cmd("BB", _CMD_CALIBRATE, 0xFE)

time.sleep_us(_CALIBRATE_TYPICAL_TIME_US)

Expand Down Expand Up @@ -545,7 +545,7 @@ def start_recv(self, timeout_ms=None, continuous=False, rx_length=0xFF):
else:
timeout = 0 # Single receive mode, no timeout

self._cmd(">BBH", _CMD_SET_RX, timeout >> 16, timeout)
self._cmd(">BBH", _CMD_SET_RX, timeout >> 16, timeout) # 24 bits

return self._dio1

Expand Down Expand Up @@ -729,10 +729,10 @@ def _cmd(self, fmt, *write_args, n_read=0, write_buf=None, read_buf=None):
return res

def _reg_read(self, addr):
return self._cmd("BBBB", _CMD_READ_REGISTER, addr >> 8, addr & 0xFF, n_read=1)[0]
return self._cmd(">BHB", _CMD_READ_REGISTER, addr, 0, n_read=1)[0]

def _reg_write(self, addr, val):
return self._cmd("BBBB", _CMD_WRITE_REGISTER, addr >> 8, addr & 0xFF, val & 0xFF)
return self._cmd(">BHB", _CMD_WRITE_REGISTER, addr, val & 0xFF)


class _SX1262(_SX126x):
Expand Down
2 changes: 1 addition & 1 deletion micropython/lora/lora-sx126x/manifest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
metadata(version="0.1.1")
metadata(version="0.1.2")
require("lora")
package("lora")

0 comments on commit 2242465

Please sign in to comment.