Add extra parameter to all callbacks
- Dominant language
- Java
- Stars
- 14.6k
- Forks
- 7k
- PR merge metrics
- No merged PRs in 30d
Description
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)
Contributor guide
Research direction
Read the existing proposal in #4519, then inspect the callback registration APIs named here: attachInterrupt(), Serial.serialEvent(), and Wire.OnReceive(). Done would require a consistent, backward-compatible extra context parameter across the relevant Arduino callbacks, with its performance, memory, and flash-storage impact evaluated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- arduino, cpp
- Domain
- api, embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100