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

GPIO pin 0 cannot be used? #40

Closed
henk65 opened this issue Mar 24, 2020 · 5 comments
Closed

GPIO pin 0 cannot be used? #40

henk65 opened this issue Mar 24, 2020 · 5 comments

Comments

@henk65
Copy link

henk65 commented Mar 24, 2020

Trying to use AceButton on pin 0 gives me this error:

exit status 1
call of overloaded 'AceButton(int)' is ambiguous

All other pins are okay, except pin 0. What can be done about this?

@bxparks
Copy link
Owner

bxparks commented Mar 24, 2020

Try AceButton((uint8_t) 0).

This is caused by 2 overloaded constructors:

  • AceButton(uint8_t pin, ...) and
  • AceButton(ButtonConfig* buttonConfig, ...)

C++ maps a 0 to either an int or a void*. I'm not really sure how to get around that. Open to suggestions.

@bxparks
Copy link
Owner

bxparks commented Mar 24, 2020

This stackoverlow suggests a way to disambiguate (https://stackoverflow.com/questions/4610503/how-to-resolve-ambiguity-of-call-to-overloaded-function-with-literal-0-and-point) but it's kinda ugly. Not sure I want to introduce that kind of clutter into the code.

@henk65
Copy link
Author

henk65 commented Mar 24, 2020

Okay, it's working now. That's not the way I usually do it, but it did the trick for me and I'm fine with it.

Shall I close this issue now, or do you want to leave it open for suggestions from others? You can close it if you want to, I'm okay with that...

bxparks added a commit that referenced this issue Mar 24, 2020
…ution to disambiguate overloaded constructors 'AceButton(0)' (see #40)
@bxparks bxparks closed this as completed Mar 24, 2020
@bxparks
Copy link
Owner

bxparks commented Mar 24, 2020

Added notes in the README.md.

@bxparks
Copy link
Owner

bxparks commented Mar 24, 2020

It occurred to me that an alternative, perhaps cleaner, solution is to use a const:

const uint8_t PIN = 0;
AceButton button(PIN);

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

No branches or pull requests

2 participants