Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out rewrite() from current resend() #60

Open
2bndy5 opened this issue Aug 11, 2024 · 0 comments
Open

Split out rewrite() from current resend() #60

2bndy5 opened this issue Aug 11, 2024 · 0 comments

Comments

@2bndy5
Copy link
Member

2bndy5 commented Aug 11, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant