keypad
keypad copied to clipboard
Ergonomics improvements (keypad_new and RefCell in release are no more)
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_newanywhere 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
RefCellwrapping; - 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.)
Thanks for the PR! I'll try to take a closer look at it soon.