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

Bulk set gpio direction support #94

Open
drakejest opened this issue Apr 8, 2023 · 1 comment
Open

Bulk set gpio direction support #94

drakejest opened this issue Apr 8, 2023 · 1 comment

Comments

@drakejest
Copy link

Hello would it be possible to add a function for bulk setting of INPUT/OUTPUT of the GPIO? im currently using 5 of these and 80 lines of code is used up for just setting the direction of the GPIO, i mean its not really a bad thing, just to make the code cleaner to look at. Alternatively having a function to read/write register directly would also be good as i can do the bulk setting of gpio direction there.

Thanks ! :)

@jankokert
Copy link

Hi.
I'm also missing this feature, but I found a workaround. Fortunately, the pin argument in the function pinMode is an integer, and you can simply iterate over the whole port:

for (int8_t i = 0; i <= 15; i++) {
  mcp.pinMode(i, INPUT);
}

The same applies for the interrupt:

for (int8_t i = 0; i <= 15; i++) {
  mcp.setupInterruptPin(i, CHANGE);
}

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