Open pelikhan opened 8 years ago
thanks @pelikhan
Sure, that would be a trivial but useful enhancement. I hate to introduce duplication though: @dpgeorge - would upstreaming this API be a welcome move, assuming we preserve semantics with your API of course?
I thought the point of having the message bus with primitives like BUTTON_EVT_DOWN was so that we could easily implement such semantics ourselves (which is what we do, we listen for EVT_DOWN and use that to update the state about button presses). Adding wasPressed would complicate the button API in the DAL.
@dpgeorge @pelikhan
For sure, the aim is to allow folks to use the building blocks here to create the best programming experience possible for higher level languages. It also makes sense to consider sharing best practice round too though, where it make sense to do so to reduce effort and duplication.
For most drivers we support calls for basic synchronous and asynchronous use, and for microBitButton we already have isPressed(), so I'm happy either way on this one.
It would be great to have the same API as micropython for button presses:
It's particularly usefull in a tight loop when button presses are missed/.
http://microbit-micropython.readthedocs.io/en/latest/microbit_micropython_api.html?highlight=was_pressed