Skip to content

Commit

Permalink
what_happened() pass on m4
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jul 30, 2019
1 parent 0e38f02 commit 519c8d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions circuitpython_nrf24l01/rf24.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ def __init__(self, spi, csn, ce, channel=76, payload_length=32, address_length=5
self._reg_write(FEATURE, self._features)

# configure registers for which each bit is specific per pipe
self._ack = None # init RX ACK payload buffer
self._auto_ack = int(auto_ack) * 0x3F # <- means all enabled
self._reg_write(1, self._auto_ack)
self._open_pipes = 0 # <- means all closed
self._reg_write(2, self._open_pipes)

# set dynamic_payloads and automatic acknowledgment packets on all pipes
self._dyn_pl = self._reg_read(DYNPD)
self.dynamic_payloads = dynamic_payloads
# config interrupt to go LOW when any of the 3 most significant bits in status register are set True. See funcion comments for more detail
self.interrupt_config(irq_DR, irq_DS, irq_DF) # (all True == nRF24L01's default)
Expand Down Expand Up @@ -429,7 +431,7 @@ def what_happened(self, dump_pipes=False):
"TX FIFO empty": bool(self.fifo & 0x10),
"RX FIFO full": bool(self.fifo & 2),
"RX FIFO empty": bool(self.fifo & 1),
"Custom ACK Payload": self.ack is not None or (self.features & 2),
"Custom ACK Payload": bool(self.ack is not None or (self.features & 2)),
"Ask no ACK": bool(self.features & 1),
"Automatic Acknowledgment": bin(self.auto_ack),
"Dynamic Payloads": bin(self._dyn_pl) if self.dynamic_payloads else False,
Expand Down Expand Up @@ -577,7 +579,7 @@ def dynamic_payloads(self, enable):
# save changes to register(&its Shadow)
self._features = (self.features & 3) | (enable << 2)
self._reg_write(FEATURE, self.features)
self._dyn_pl = b'0x3F' if enable else b'0'
self._dyn_pl = 0x3F if enable else 0
self._reg_write(DYNPD, self._dyn_pl)

@property
Expand Down

0 comments on commit 519c8d1

Please sign in to comment.