CircuitPython_nRF24L01 icon indicating copy to clipboard operation
CircuitPython_nRF24L01 copied to clipboard

Split out `rewrite()` from current `resend()`

Open 2bndy5 opened this issue 1 year ago • 0 comments

Currently resend() is designed to be used like send() without uploading a payload. I think it would help user code that is async-oriented if rewrite() is abstracted from resend() (similar to how write() is a helper to send()).

Pseudo code

def resend() -> bool:
    if not rewrite():
         return False
    while not self._status & 0x70:
        self.update()
    return self.irq_ds

def rewrite() -> bool:
    if self.fifo(about_tx=true, check_empty=True):
        return False  # return early if nothing in TX FIFO
    self._ce_pin = False
    self.clear_status_flags()
    # self._reg_write_bytes(0xE3, b"")  # dont't issue REUSE_TX_PL command
    self._ce_pin.value = True
    # CircuitPython is slow enough to skip the mandatory 10us delay on CE pin
    # time.sleep(0.00001)

Of course, there is more nuance in the current implementation for resend() where it can return a payload from the ACK packet (if that feature is enabled).

2bndy5 avatar Aug 11 '24 12:08 2bndy5