micro:bitworldtour

micro:bit worldtour

Mohandas micro:bit

Nick's GitHub avatar

Nick Coghlan Brisbane, AUS.

Monday, 18th January 2016

When I received the Mohandas micro:bit, I had two goals:

  • Setting up a Docker image to make it easier to get started hacking on the micro:bit
  • Creating my own micro:bit experiment doing zero-cross detection on the signal from a small electret microphone

After some interesting detours, and the introduction of dependency version constraints for both micropython and microrepl, I was able to publish a micro:bit MicroPython build environment to DockerHub as ncoghlan/microbit-dev.

That image includes a full yotta build environment together with Nicholas Tollervey's microrepl project, making it straightforward both to use the micro:bit interactively, to build new custom firmware images and to experiment with image ideas by using `pyboard.py` to upload and run scripts on the device directly from within the container.

Together with other interruptions, getting a reliable build container together took longer than I anticipated though, so I never got to starting on the second goal - instead, I'll include the microphone along with Mark Schafer's 3D printed micro:bit diffuser in the package I pass along to the next Mohandas recipient, Clinton Roy

One of Mark's Neon Artworks

Mark Schafer Auckland, NZ.

Monday, 7th December 2015

After many days of fruitless work I have not succeeded in creating the neopixel library. I was using the neopixel branch in the bbcmicrobit repository But my C language skills are not up to it.

I have sent the Microbit onto Nick Coghan in Australia for the next step in Mohandas's journey.

One of Mark's Neon Artworks

Mark Schafer Auckland, NZ.

Tuesday, 1st December 2015

The fire simulation is working pretty well but a diffuser would soften the pinpoints and make it look much better. The simplest way is to put a piece of paper on top of the LEDs. It needs some separation between the LEDs and the paper to soften the glow. So I decided to do it the hard way and quickly write something in OpenSCAD and print it out on a 3D printer. The 3D file is hosted on thingiverse here: Microbit Diffuser

The program uses the two buttons to control the delay between frames and the amount of interpolation that occurs between new lines of fire being added. The program works in the following way:

It starts by making a line of brightness points on the bottom row of the display. Each time it generates a new line, it moves the previous one up. But this is not what makes it look like fire.

To do this we do interpolation frames between the major "new line of fire" frames. The interpolation looks at a line and its preceeding one and performs an interpolation to calculate an intermediate frame. This is done several times before a new line of fire points is added to the bottom row.

We also multiply the resulting pixel values by a mask. This mask tapers off the values and gives us a kind of shape to the grid instead of a square block.

Here's a video of the fire in action, both without and with the 3D diffuser.

One of Mark's Neon Artworks

Mark Schafer Auckland, NZ.

Monday, 30th November 2015

Finally got everything sorted out, building, checkouts, talking to the Microbit. All set to go. Thought I'd start with a little program to simulate fire on the display. I'm using the mechanism where you type in a command and it transfers the program to the Microbit, runs it and reports any messages (errors, print(), etc) directly back to you. Good for debugging. Looks like this:

micropython/tools/pyboard.py /dev/ttyACM0 your_code.py
Where the "pyboard.py" program is from the cloned repository, "your_code.py" is your program, and "ttyACM0" is the USB port for communicating with the Microbit.

So I started a fire simulation program. Needed to choose between making and updating an Image, and then telling the display to show it, or setting pixel values directly in the display. In the end I went with

display.set_pixel(x, y, value)
to make the code small. There's nota lot of room on the Microbit and all the comments are included in the memory footprint of the code. This means I need to try to keep the programs small.

The code for this is on the github repo here

The fire simulation is working pretty well but a diffuser would soften the pinpoints and make it look much better. I'll try for one tomorrow. Here we can see the code that generates a new line of fire points

    # Generate a new bottom row of random values for the flames
    def generate_line(line, start=min_brightness, end=max_brightness):
        "start and end define range of dimmest to brightest 'flames'"
        for i in range(display_width):
            line[i] = start + microbit.random(end-start)
The function takes in an array of 5 values, called line, and puts 5 new random values into it. The range of the values represents the brightness of the flames.

One of Mark's Neon Artworks

Mark Schafer Auckland, NZ.

Friday, 27th November 2015

Spent the day setting up my Ubuntu14.04LTS machine and getting git and the other tools on. Because I'm developing a new library, I have more to do than the usual user.

Needed to work out how to build from the repo using Yotta, as well as download and connect using a serial terminal program. I ended up using gtkterm which is pretty useful on Linux. Making lots of notes to pass back to Nicholas for the next person.

Typing:

dmesg | grep tty
at a linux command line prompt tells you which serial port the Microbit connected as, when you plugged it in.

One of Mark's Neon Artworks

Mark Schafer Auckland, NZ.

Saturday, 28th November 2015

Yay the Microbit arrived today. I'll start setting up the machine and logging how it goes tomorrow. Very exciting!

A picture of Nicholas

Nicholas Tollervey Towcester, UK.

Saturday, 7th November 2015

I've finally finished the website and I'm ready to post Mohandas micro:bit to Mark Schafer.