Skip to content

Add extra parameter to all callbacks #4659

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

Open
paulo-raca opened this issue Mar 6, 2016 · 0 comments
Open

Add extra parameter to all callbacks #4659

paulo-raca opened this issue Mar 6, 2016 · 0 comments
Labels
Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix) Library: Other Arduino libraries that don't have their own label Library: Wire The Wire Arduino library

Comments

@paulo-raca
Copy link
Contributor

On Arduino, you'll tipically declare a new callback on the main file for each thing you are listening on.

It's very difficult to write generic, reusable libraries that attach to interruptions or other callbacks.

In C/C++ world, we usually specify an extra void* parameter when registering the callback, where the listener can store any context necessary.

I suggest we adopt this on all Arduino callbacks: attachInterrupt(), Serial.serialEvent(), Wire.OnReceive(), etc

I've already create #4519, which upgrades attachInterrupt().

Keep in mind that the changes can be done in a backwars-compatible way, and the impact in performance, memory and flash storage is quite low (But not zero)

@per1234 per1234 added Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix) Library: Other Arduino libraries that don't have their own label Library: Wire The Wire Arduino library labels Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix) Library: Other Arduino libraries that don't have their own label Library: Wire The Wire Arduino library
Projects
None yet
Development

No branches or pull requests

2 participants