-
Notifications
You must be signed in to change notification settings - Fork 1k
add: expose status byte in public API #1032
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
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
6745f03
to
3e5a7ec
Compare
Memory usage change @ 3db7cfa
Click for full report table
Click for full report CSV
|
This comment was marked as resolved.
This comment was marked as resolved.
e62f3bc
to
039c3ce
Compare
Ok, I reverted the use of a 69-byte string buffer (to translate the status byte like This proves that the new Now I'm curious if replacing other internal uses of the status byte will be optimized as well. 🤔 I'm going to cleanup the git history and keep at it. I haven't been hardware testing this yet. I just wanted to ensure compile size wasn't impacted negatively. |
Offers intuitive alternatives to `maskIRQ()` and `whatHappened()`. The API is more explicit, but there's less bit-banging and memory allocation involved. The StatusFlags API is implemented in the python wrapper also. All new API is grouped in the docs under the topic "Status flags".
d13ae51
to
756e6a9
Compare
This is looking good, but one critique, would be that I'm not sure we want to deprecate the To you it may seem simple, but I think this represents advanced usage, whereas a simpler user approach is to use the current API, which is what should be represented in the examples. Maybe converting everything and deprecation can be left for v2.0? |
TBH, I always hated1 the
Clang-tidy actually has a lint rule to flag these functions as "prone to bugs". Footnotes
|
Deprecated API should be deprecated for a long enough time before removal in the next major version (v2). Since we have no plans to actually pursue v2.0, Users should have ample time to update the lib and migrate to new API. It is considered breakage if a deprecated API is removed in a minor or patch release. Tip The new Arduino IDE will cross-out deprecated API in the editor thanks to the |
To be fair, providing constants to be used as masks is a common approach to exposing a bit-field. The Pico SDK has used this approach for many things rather successfully. |
After converting the internal API to use the new API, I only saw a 4 byte increase in flash size on ATSAMD21 for the ACK examples. I'm looking into that now. The IRQ example's flash size actually went down on both AVR and ATSAMD21. |
don't use `printStatus()` in arduino IRQ example
rm unnecessary ()
doc review
de4bb60
to
dbb4d00
Compare
Hehe, with your unrefined hate for those functions, I guess I'll withdraw my previous comments. |
I'm going to start a migration guide to highlight the differences in API for v1.5. |
in python example
My hardware tests on Linux (with and with python wrapper) now show this working successfully. 🎉 I still need to test the Arduino and Pico SDK examples... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick tested on Arduino with interruptConfigure & streaming examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final review
Offers intuitive alternatives to
maskIRQ()
andwhatHappened()
.The new API is more explicit (see example modifications), but there's less bit-banging (in lib internal definitions) and memory allocation involved .
The new API is implemented in the python wrapper also.
All new API is grouped in the docs under the topic "Status flags".
Alternative uses
Additionally, this exposes more than just the IRQ flags. Aside from the uses shown in this patch's example modifications, one can also...
can also be done like so:
and
can also be done (with less internal bit-banging) like so:
New and old API
setStatusFlags()
deprecatesmaskIRQ()
clearStatusFlags()
deprecateswhatHappened()
and allows for clearing all or individual flags.the private method
print_status()
is now publicly exposed asprintStatus()
the private method
get_status()
is now publicly exposed asupdate()
new
getStatusFlags()
allows read access to the privately cachedstatus
attribute. This means NO SPI transactions; that's whatupdate()
does now.new
rf24_irq_flags_e
defines constants to be used as masks.RF24_RX_DR
RF24_TX_DS
RF24_TX_DF
RF24_IRQ_ALL
(alias of above or'd together)RF24_IRQ_NONE
(alias of0
to avoid using "magic" numbers)These double as values passed to
setStatusFlags()
andclearStatusFlags()
. As with any masks, these constants can be or'd together to specify more than 1 STATUS flag when used with the aforementioned functions.