micropython / micropython-lib

Core Python libraries ported to MicroPython
Other
2.39k stars 994 forks source link

minor lora sx126x _cmd optimization #895

Closed maholli closed 2 months ago

maholli commented 2 months ago

Currently, the micropython-lib lora sx126x driver dynamically creates at least one, sometimes two, memoryview objects with each call to _cmd. This PR simply provides the class with a long-lived memoryview object for _cmd to easily slice as necessary.

Unlike the SX127x chips, Semtech unfortunately designed the SX126x modems to be more command-centric (as opposed to directly setting registers). Given the amount _cmd is called during normal device operation, even a minor improvement here should have a decent impact.

Basic TX and RX tests pass on hardware.

@projectgus, care to review?

maholli commented 2 months ago

Requested changes have been made and the checks are happy. Let me know if there's anything else. Thanks again, @projectgus.

maholli commented 2 months ago

Looks good to me, thanks @maholli. I would probably squash the two commits into one, but we can probably also do that when we merge this.

@projectgus Yes, feel free to squash when you merge. Thanks again!

dpgeorge commented 2 months ago

Thanks for the contribution. Squashed and merged in 60d137029f169efde062464970cdee6f7367abb8