Skip to content

Commit 2242465

Browse files
projectgusdpgeorge
authored andcommitted
lora-sx126x: Clean up some struct formatting.
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]>
1 parent 35bb795 commit 2242465

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

micropython/lora/lora-sx126x/lora/sx126x.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def calibrate(self):
469469
# See DS 13.1.12 Calibrate Function
470470

471471
# calibParam 0xFE means to calibrate all blocks.
472-
self._cmd("<BB", _CMD_CALIBRATE, 0xFE)
472+
self._cmd("BB", _CMD_CALIBRATE, 0xFE)
473473

474474
time.sleep_us(_CALIBRATE_TYPICAL_TIME_US)
475475

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

548-
self._cmd(">BBH", _CMD_SET_RX, timeout >> 16, timeout)
548+
self._cmd(">BBH", _CMD_SET_RX, timeout >> 16, timeout) # 24 bits
549549

550550
return self._dio1
551551

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

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

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

737737

738738
class _SX1262(_SX126x):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.1.1")
1+
metadata(version="0.1.2")
22
require("lora")
33
package("lora")

0 commit comments

Comments
 (0)