Skip to content

Commit

Permalink
print everything - going back under the hood
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Aug 2, 2019
1 parent 151a771 commit bd90f5a
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 229 deletions.
467 changes: 277 additions & 190 deletions circuitpython_nrf24l01/rf24.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["digitalio", "busio"]
autodoc_mock_imports = ["digitalio", "busio"]


intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
Expand Down Expand Up @@ -75,7 +75,7 @@
todo_include_todos = False

# If this is True, todo emits a warning for each TODO entries. The default is False.
todo_emit_warnings = True
todo_emit_warnings = False

napoleon_numpy_docstring = False

Expand Down
8 changes: 4 additions & 4 deletions examples/ack_payloads/m4_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
nrf.ack = (None, 1)

# recommended behavior is to keep in TX mode while idle
nrf.stop_listening() # put radio in TX mode
nrf.listen = False # put radio in TX mode

def master(count=5): # count = 5 will only transmit 5 packets
# set address of RX node into a TX pipe
nrf.open_tx_pipe(addresses[0])
# ensures the nRF24L01 is in TX mode
# nrf.stop_listening()
# nrf.listen = False

counter = count
while counter:
Expand All @@ -83,7 +83,7 @@ def master(count=5): # count = 5 will only transmit 5 packets
counter -= 1

# running slave to only fetch/receive count number of packets
# count = 3 will mimic a full RX FIFO behavior via nrf.stop_listening()
# count = 3 will mimic a full RX FIFO behavior via nrf.listen = False
def slave(count=3):
# set address of TX node into an RX pipe. NOTE you MUST specify
# which pipe number to use for RX, we'll be using pipe 0
Expand All @@ -107,7 +107,7 @@ def slave(count=3):
counter -= 1

# recommended behavior is to keep in TX mode while sleeping
nrf.stop_listening() # put radio in TX mode and power down
nrf.listen = False # put radio in TX mode and power down

def debugRF24(dumpADDR=False):
print('expected status =', bin(nrf.status))
Expand Down
8 changes: 4 additions & 4 deletions examples/ack_payloads/pi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
nrf.ack = (None, 1)

# recommended behavior is to keep in TX mode while idle
nrf.stop_listening() # put radio in TX mode
nrf.listen = False # put radio in TX mode

def master(count=5): # count = 5 will only transmit 5 packets
# set address of RX node into a TX pipe
nrf.open_tx_pipe(addresses[0])
# ensures the nRF24L01 is in TX mode
# nrf.stop_listening()
# nrf.listen = False

counter = count
while counter:
Expand All @@ -84,7 +84,7 @@ def master(count=5): # count = 5 will only transmit 5 packets
counter -= 1

# running slave to only fetch/receive count number of packets
# count = 3 will mimic a full RX FIFO behavior via nrf.stop_listening()
# count = 3 will mimic a full RX FIFO behavior via nrf.listen = False
def slave(count=3):
# set address of TX node into an RX pipe. NOTE you MUST specify
# which pipe number to use for RX, we'll be using pipe 0
Expand All @@ -108,7 +108,7 @@ def slave(count=3):
counter -= 1

# recommended behavior is to keep in TX mode while sleeping
nrf.stop_listening() # put radio in TX mode and power down
nrf.listen = False # put radio in TX mode and power down

def debugRF24(dumpADDR=False):
print('expected status =', bin(nrf.status))
Expand Down
4 changes: 2 additions & 2 deletions examples/interrupt/m4_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def master():
nrf.open_tx_pipe(addresses[0]) # set address of RX node into a TX pipe
# set address of TX node into an RX pipe. NOTE you MUST specify which pipe number to use for RX, we'll be using pipe 1 (options range [0,5])
nrf.open_rx_pipe(1, addresses[1])
nrf.stop_listening() # put radio in TX mode and power down
nrf.listen = False # put radio in TX mode and power down
i = 0.0 # data to send

while True:
Expand Down Expand Up @@ -53,7 +53,7 @@ def slave():
nrf.open_tx_pipe(addresses[1]) # set address of RX node into a TX pipe
# set address of TX node into an RX pipe. NOTE you MUST specify which pipe number to use for RX, we'll be using pipe 1 (options range [0,5])
nrf.open_rx_pipe(1, addresses[0])
nrf.start_listening() # put radio into RX mode and power up
nrf.listen = True # put radio into RX mode and power up

while True:
try:
Expand Down
4 changes: 2 additions & 2 deletions examples/interrupt/pi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def master():
nrf.open_tx_pipe(addresses[0]) # set address of RX node into a TX pipe
# set address of TX node into an RX pipe. NOTE you MUST specify which pipe number to use for RX, we'll be using pipe 1 (options range [0,5])
nrf.open_rx_pipe(1, addresses[1])
nrf.stop_listening() # put radio in TX mode and power down
nrf.listen = False # put radio in TX mode and power down
i = 0.0 # data to send

while True:
Expand Down Expand Up @@ -53,7 +53,7 @@ def slave():
nrf.open_tx_pipe(addresses[1]) # set address of RX node into a TX pipe
# set address of TX node into an RX pipe. NOTE you MUST specify which pipe number to use for RX, we'll be using pipe 1 (options range [0,5])
nrf.open_rx_pipe(1, addresses[0])
nrf.start_listening() # put radio into RX mode and power up
nrf.listen = True # put radio into RX mode and power up

while True:
try:
Expand Down
24 changes: 9 additions & 15 deletions examples/simple/m4_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
nrf = RF24(spi, csn, ce)

# recommended behavior is to keep in TX mode while sleeping
nrf.stop_listening() # put the nRF24L01 is in TX and power down modes
nrf.listen = False # put the nRF24L01 is in TX and power down modes

def master(count=5): # count = 5 will only transmit 5 packets
# set address of RX node into a TX pipe
nrf.open_tx_pipe(addresses[0])
# ensures the nRF24L01 is in TX and power down modes
# nrf.stop_listening()
# nrf.listen = False

i = 0.0 # init data to send

Expand Down Expand Up @@ -62,42 +62,36 @@ def master(count=5): # count = 5 will only transmit 5 packets
counter -= 1

# recommended behavior is to keep in TX mode while sleeping
nrf.stop_listening() # put the nRF24L01 is in TX and power down modes
nrf.listen = False # put the nRF24L01 is in TX and power down modes

# running slave to only fetch/receive count number of packets
# count = 3 will mimic a full RX FIFO behavior via nrf.stop_listening()
# count = 3 will mimic a full RX FIFO behavior via nrf.listen = False
def slave(count=3):
# set address of TX node into an RX pipe. NOTE you MUST specify
# which pipe number to use for RX, we'll be using pipe 0
# pipe number options range [0,5]
# the pipe numbers used during a transition don't have to match
nrf.open_rx_pipe(0, addresses[0])
nrf.start_listening() # put radio into RX mode and power up
nrf.listen = True # put radio into RX mode and power up

counter = count
while counter:
# print details about the received packet (if any)
print("Found {} bytes on pipe {}".format(int(nrf.any()), nrf.pipe()))
if nrf.any():
# print details about the received packet
print('RX payload size =', nrf.any())
print('RX payload on pipe', nrf.available())
# retreive the received packet's payload
rx = nrf.recv() # clears flags & empties RX FIFO
# expecting a long int, thus the string format '<d'
temp = struct.unpack('<d', rx)
# print the only item in the resulting tuple from
# using `struct.unpack()`
print("Received: {}, Raw: {}".format(temp[0],\
repr(rx)))
print("Received: {}, Raw: {}".format(temp[0], repr(rx)))
# this will listen indefinitely till counter == 0
counter -= 1
time.sleep(0.25)

# recommended behavior is to keep in TX mode while sleeping
nrf.stop_listening() # put the nRF24L01 is in TX and power down modes

def debugRF24(dumpADDR=False):
for k,v in nrf.what_happened(dumpADDR).items():
print('{} : {}'.format(k, v))
nrf.listen = False # put the nRF24L01 is in TX and power down modes

print("""\
nRF24L01 Simple test.\n\
Expand Down
17 changes: 7 additions & 10 deletions examples/simple/pi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
nrf = RF24(spi, csn, ce)

# recommended behavior is to keep in TX mode while sleeping
nrf.stop_listening() # put the nRF24L01 is in TX and power down modes
nrf.listen = False # put the nRF24L01 is in TX and power down modes

def master(count=5): # count = 5 will only transmit 5 packets
# set address of RX node into a TX pipe
nrf.open_tx_pipe(addresses[0])
# ensures the nRF24L01 is in TX and power down modes
# nrf.stop_listening()
# nrf.listen = False

i = 0.0 # init data to send

Expand Down Expand Up @@ -60,20 +60,21 @@ def master(count=5): # count = 5 will only transmit 5 packets
counter -= 1

# running slave to only fetch/receive count number of packets
# count = 3 will mimic a full RX FIFO behavior via nrf.stop_listening()
# count = 3 will mimic a full RX FIFO behavior via nrf.listen = False
def slave(count=3):
# set address of TX node into an RX pipe. NOTE you MUST specify
# which pipe number to use for RX, we'll be using pipe 1
# pipe number options range [0,5]
nrf.open_rx_pipe(1, addresses[0])
nrf.start_listening() # put radio into RX mode and power up
nrf.listen = True # put radio into RX mode and power up

counter = count
while counter:
print("payload in RX FIFO ? {}".format(nrf.any()))
if nrf.any():
# print details about the received packet
print('RX payload size =', nrf.any())
print('RX payload on pipe', nrf.available())
print('RX payload on pipe', nrf.pipe())
# retreive the received packet's payload
rx = nrf.recv() # clears flags & empties RX FIFO
# expecting a long int, thus the string format '<d'
Expand All @@ -87,11 +88,7 @@ def slave(count=3):
time.sleep(0.25)

# recommended behavior is to keep in TX mode while sleeping
nrf.stop_listening() # put the nRF24L01 is in TX and power down modes

def debugRF24(dumpADDR=False):
for item in nrf.what_happened(dumpADDR).items():
print('{} : {}'.format(item[0], item[1]))
nrf.listen = False # put the nRF24L01 is in TX and power down modes

print("""\
nRF24L01 Simple test.\n\
Expand Down

0 comments on commit bd90f5a

Please sign in to comment.