[Microbit-Python] A request for help... fancy designing a Pythonic API that up to 1 million kids would use..?

Nicholas H.Tollervey ntoll at ntoll.org
Fri Aug 28 17:08:25 CEST 2015


Hi Folks,

Although this list has been a tad quiet recently, things are moving
along when it comes to Python on the micro:bit.

The "blessed" device abstraction layer (DAL) created by Lancaster
University for the BBC to use with the micro:bit is now working with
MicroPython.

What we need to do is create a Pythonic "microbit" module that gives
users of Python direct access to the device hardware via the DAL.

In terms of the work, this is simply a task of code-plumbing. However,
the challenge will be in creating something that is Pythonic and easy
enough for the nation's 11yo to get their heads around. That means
obvious mono-syllabic names and shallow namespaces while still retaining
the "shape" of the DAL.

So, I'm going to start writing some documentation about the various
features that the DAL exposes and both Damien and I would like help in
designing the API (since actually coding it is a relatively simple task
of connecting Python to the DAL). It's definitely a case of more eyes
will make this better.

In case you're wondering, we already have made a start. So for example,
here's the output from MicroPython's help() function:

>>> help()
Welcome to MicroPython on the micro:bit!

Be brave! Break things! Learn and have fun! :-)

Type 'import microbit', press return and try these commands:
  microbit.display.scroll('Hello')
  microbit.system_time()
  microbit.sleep(1000)
  microbit.button_a.is_pressed()
What do these commands do? Can you improve them? HINT: use the up and
down arrow keys to get your command history (saves you typing).

Explore:
Type 'help(something)' to find out about it. Type 'dir(something)' to
see what it can do.

Stuff to explore:
  microbit.accelerometer         -- detect the device's position
(orientation)
  microbit.button_a.is_pressed() -- is button A pressed? (True or False)
  microbit.button_b.is_pressed() -- is button B pressed? (True or False)
  microbit.compass               -- detect the device's heading
  microbit.display               -- display things (pixels, characters,
words)
  microbit.panic()               -- go into panic mode (requires a restart)
  microbit.random(n)             -- get a random number between 0 and n
  microbit.sleep(n)              -- wait for n milliseconds (1 second =
1000)
  microbit.system_time()         -- get the number of milliseconds since
reset

Control commands:
  CTRL-C        -- stop a running program
  CTRL-D        -- on a blank line, do a soft reset of the micro:bit


The only major part of the DAL we've not already started to reference is
the IO namespace for accessing the pins along the bottom of the device.

Pretty much all of the above namespaces have things missing or clunkily
named.

So, fancy helping 1 million kids learn and play with Python? You will be
given credit in the code and perhaps an easter egg I have in mind. ;-)

Let me know your thoughts!

Best wishes,

Nicholas.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://mail.python.org/mailman/private/microbit/attachments/20150828/3a3b5935/attachment.sig>


More information about the Microbit mailing list