whaleygeek / bitio

A micro:bit I/O device library for Python
Other
92 stars 31 forks source link

V2 support #31

Open whaleygeek opened 3 years ago

whaleygeek commented 3 years ago

V2 micro:bit has just been released this week. Noteable features to add support to bitio are:

Also, there is a new 'combined hex' format, so we should roll together the V1.5 and V2 hex files into a single combined hex using the tool that the foundation are releasing. This will also close https://github.com/whaleygeek/bitio/issues/23

Might choose to add some much needed GPIO features at same time.

Have some ideas to make api.py either an auto-sensing proxy, or a data driven table of API methods (rather than having to hand-code new method wrappers every time), so would like to experiment with that.

The auto sensing proxy would use getattr to build a wrapper for any function, and if it gets an exception when passing to the REPL on first use, it would replace it's implementation with an error handler. This might fail unhelpfully if the first call has an invalid parameter though.

The data-driven approach would be the same as the auto sensing proxy, but with the addition of a string table of valid method names. Thus, a generic call would look up the name in the table, reject it if not listed. If it is listed, it would build a proxy function and then pass whatever parameters you pass, on the REPL, and mirror the exception at the MicroPython end back at the host side as a similar exception. This would mean anyone could just add new function names to the table to get an auto proxy (and we should allow for manual functions as well where we still need to do a bit of data marshalling and type cleaning aka: https://github.com/whaleygeek/bitio/issues/30)

whaleygeek commented 3 years ago

I haven't merged this into mainline yet, just because I need to re-test all the chapters of our book before doing that.

But the motion sensor and V2 update .hex file is on this branch: https://github.com/whaleygeek/bitio/tree/newarch and if you use that bitio.hex file it should work fine on all devices.