keypad icon indicating copy to clipboard operation
keypad copied to clipboard

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

Open PaulRaUnite opened this issue 2 years ago • 1 comments

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.)

PaulRaUnite avatar Jan 18 '23 13:01 PaulRaUnite

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

e-matteson avatar Jan 23 '23 01:01 e-matteson