On Mon, Nov 07, 2016 at 11:07:56AM +0000, Wayne Keenan wrote:
[...]
> 'm totally with you on it's best to keep Mynewt simple; an application
> developer can pass a user defined struct to the arg which has the actual
> user data and also a pointer to the pool to be freed; they can also create
> their own convenience functions/macros around it.
>
> In my case I'm (currently) passing inbound serial character data as an
> event, in order to decouple the IRQ handler context from the MicroPython
> interpreter and it's REPL.
>
> Eventually I'll switch back to using the Console when it has the low level
> TX/RX handler support, ticket #469.
>
> But, I also need to use the same pattern to decouple GPIO IRQ's and the
> Python callbacks, in order to support this:
>
> from gpiozero import Button
>
> def buttonA_pressed():
> print("Button pressed.")
>
> buttonA = Button(17)
> buttonA.when_pressed(buttonA_pressed)
>
> (In case you were wondering, I back ported the 0.10.0 nRF GPIO HAL to
> 0.9.0, thanks Will :)
>
> So the event struct wrapping and helper function could become a much more
> commonly used pattern as 3rd party libraries (which hook in into IRQ's and
> events) and other scripting languages are ported to Mynewt.
>
> I'm now not suggesting change what's in the core, instead, perhaps make
> available a simple struct wrapper and support functions/macros as
> 'codified' best practice of this pattern.
> I can take a look at creating a PR once I've seen the latest Event API and
> am closer to the v1.0 codebase.
I think that sounds great. Then it is possible to have it both ways :).
Thanks,
Chris