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

Ergonomics improvements (keypad_new and RefCell in release are no more) #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PaulRaUnite
Copy link

Hello, and thank you for the library.

I hope this PR will be useful.

Motivation:

  • I am testing my hardware setup, and I would like to reuse my keypad code in several applications;
  • the struct fields are always private (as should be, I think), thus it is not possible to instantiate the struct with keypad_new anywhere else other than the origin module;
  • to circumvent that, I would need to write a "new" function, i.e I have to repeat all the types in the signature and write RefCell wrapping;
  • if I change the wiring and so the struct signature, I have to rewrite that function and I would like to avoid it.

Thus, in this PR I removed keypad_new macro and implemented new function in the main macro (RefCell wrapping included).
As an additional improvement, release method now returns pins without RefCell.

(I don't really like the macro rule duplication, but it works.)

@e-matteson
Copy link
Owner

Thanks for the PR! I'll try to take a closer look at it soon.

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

Successfully merging this pull request may close these issues.

2 participants