Skip to content

Commit 672b23d

Browse files
committed
some example review
1 parent 34d4178 commit 672b23d

8 files changed

Lines changed: 18 additions & 12 deletions

File tree

.cspell.config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ words:
44
- adafruit
55
- addopts
66
- armv
7+
- ATSAMD
78
- baudrate
89
- blinka
910
- busdevice
@@ -12,9 +13,12 @@ words:
1213
- circuitpython
1314
- digitalio
1415
- Disabl
16+
- Dmitry
1517
- Doherty
18+
- Eddystone
1619
- elif
1720
- Fals
21+
- Grinberg
1822
- hexlified
1923
- HHHBB
2024
- Kbps
@@ -33,3 +37,4 @@ words:
3337
- setuptools
3438
- spidev
3539
- testpaths
40+
- urandom

circuitpython_nrf24l01/fake_ble.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def __init__(
195195
self._addr_len = 4 # use only 4 byte address length
196196
self._tx_address[:4] = b"\x71\x91\x7d\x6b"
197197
with self:
198-
super().open_rx_pipe(0, b"\x71\x91\x7d\x6b\0")
198+
super().open_rx_pipe(1, b"\x71\x91\x7d\x6b\0")
199199
#: The internal queue of received BLE payloads' data.
200200
self.rx_queue: List[QueueElement] = []
201201
self.rx_cache: bytearray = bytearray(0)

circuitpython_nrf24l01/rf24.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ def _reg_read(self, reg: int, command: bool = False) -> int:
174174
# time.sleep(0.000005)
175175
spi.write_readinto(self._out, self._in, out_end=len, in_end=len)
176176
# if command:
177-
# print("SPI command", ("%02X" % reg))
177+
# if reg != 0xFF:
178+
# print("SPI command", ("%02X" % reg))
178179
# else:
179180
# print(
180181
# "SPI read", len, "byte from", ("%02X" % reg), ("%02X" % self._in[1])
@@ -210,8 +211,7 @@ def _reg_write(self, reg: int, value: int):
210211
with self._spi as spi:
211212
# time.sleep(0.000005)
212213
spi.write_readinto(self._out, self._in, out_end=buf_len, in_end=buf_len)
213-
# if reg != 0xFF:
214-
# print("SPI write 1 byte to", ("%02X" % reg), ("%02X" % value))
214+
# print("SPI write 1 byte to", ("%02X" % reg), ("%02X" % value))
215215

216216
@property
217217
def address_length(self) -> int:

examples/nrf24l01_ack_payload_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ def slave(timeout=6):
140140
buffer = b"World \0" + bytes([counter[0]]) # build new ACK
141141
nrf.load_ack(buffer, 1) # load ACK for next response
142142

143-
# recommended behavior is to keep in TX mode while idle
144-
nrf.listen = False # put radio in TX mode
145-
nrf.flush_tx() # flush any ACK payloads that remain
143+
# recommended behavior is to keep in TX mode when in idle
144+
nrf.listen = False # enter inactive TX mode
145+
# entering TX mode (when ACK payloads are enabled) also flushes the TX FIFO
146146

147147

148148
def set_role():

examples/nrf24l01_interrupt_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,13 @@ def slave(timeout=6): # will listen for 6 seconds before timing out
130130
while not nrf.fifo(0, 0) and time.monotonic() - start_timer < timeout:
131131
# if RX FIFO is not full and timeout is not reached, then keep going
132132
pass
133-
nrf.listen = False # put nRF24L01 in Standby-I mode when idling
133+
# recommended behavior is to keep in TX mode when in idle
134+
nrf.listen = False # enter inactive TX mode
135+
# entering TX mode (when ACK payloads are enabled) also flushes the TX FIFO
134136
if not nrf.fifo(False, True): # if RX FIFO is not empty
135137
# all 3 payloads received were 5 bytes each, and RX FIFO is full
136138
# so, fetching 15 bytes from the RX FIFO also flushes RX FIFO
137139
print("Complete RX FIFO:", nrf.read(15))
138-
nrf.flush_tx() # discard any pending ACK payloads
139140

140141

141142
def set_role():

examples/nrf24l01_manual_ack_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def slave(timeout=6):
142142
start_timer = time.monotonic() # reset timeout
143143

144144
# recommended behavior is to keep in TX mode when in idle
145-
nrf.listen = False # put the nRF24L01 in TX mode + Standby-I power state
145+
nrf.listen = False # enter inactive TX mode
146146

147147

148148
def set_role():

examples/nrf24l01_simple_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def slave(timeout=6):
116116
start = time.monotonic()
117117

118118
# recommended behavior is to keep in TX mode while idle
119-
nrf.listen = False # put the nRF24L01 is in TX mode
119+
nrf.listen = False # enter inactive TX mode
120120

121121

122122
def set_role():

examples/nrf24l01_stream_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def slave(timeout=5):
154154
start_timer = time.monotonic() # reset timer on every RX payload
155155

156156
# recommended behavior is to keep in TX mode while idle
157-
nrf.listen = False # put the nRF24L01 is in TX mode
157+
nrf.listen = False # enter inactive TX mode
158158

159159

160160
def set_role():

0 commit comments

Comments
 (0)