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

Use ints instead of enum class to identify touch buttons #56

Open
alranel opened this issue Oct 2, 2022 · 0 comments
Open

Use ints instead of enum class to identify touch buttons #56

alranel opened this issue Oct 2, 2022 · 0 comments
Assignees
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@alranel
Copy link
Member

alranel commented Oct 2, 2022

As of now, touch buttons are identified using an enum class:

typedef enum {
TOUCH0 = 0,
TOUCH1,
TOUCH2,
TOUCH3,
TOUCH4
} touchButtons;

This means that in order to iterate over all the buttons to find out which one was pressed, a cast to the touchButtons type must be used:

for (int i = 0; i <= 4; ++i) {
   if (carrier.Buttons.onTouchDown((touchButtons)i)) {
      Serial.print("Button pressed: ");
      Serial.println(i);
   }
}

Considering this type is not documented anywhere and probably not strictly necessary, can't we just allow plan ints as arguments and get rid of those TOUCHx constants?

@alranel alranel added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

2 participants