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

virtual button init callback #69

Open
sercona opened this issue Mar 16, 2024 · 1 comment
Open

virtual button init callback #69

sercona opened this issue Mar 16, 2024 · 1 comment
Assignees

Comments

@sercona
Copy link

sercona commented Mar 16, 2024

this is a nice library.

I'm trying to use this with an i2c port expander and I understand I can create my own handler to read the i2c port and also it would break out the bits to simulate single button bits.

what seems to be missing is a user callback to init. like many things, there's a duality for a 'setup' and a 'loop' concept. same here. you have the user vector callback to get data but not to init it, the first time. you say the user has to do that outside. why not just provide a way in the begin() call, when you refer to VIRTUAL pins, to provide an optional callback. that extends the library more easily and hides that init code from the main app's setup() code.

maybe something like:

void myInitCB(void)
{
// user will setup their i2c PE, etc
}

button1.begin(VIRTUAL_PIN, myInitCB);

so just 1 more ctor that takes a 2nd parm and you call the callback once at that time. just a little bit of 'init hiding' but it feels more natural to have both vectors that the user provides instead of just the data polling one.

@LennartHennigs
Copy link
Owner

Hey,
like the idea to add an additional init callback.
Will add it to the todo list.

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

No branches or pull requests

2 participants