Monday, March 2, 2020

OLED

I bought a 0.96", 128x64, OLED for $7  to use with my micro:bit (price ranges from ~$4-10 based on quantity). It is tiny, the display is about 2.5 cm x 1.25 cm. It is an I2C device that needs 3.3-5 V. You connect it to the micro:bit via pins 19 (SCL) & 20 (SDA). Some extension boards have grove port connectors (white 4 pin jacks) already set up for this to make it easier to connect (1 cable 4 wires)

There are a couple of options for makecode extensions. The first and third by Tinkeracademy, with the third seeming to be an older version. The second is by "author: shaoziyang" and gives you  more control over what and where things go.

The first block that has to be used is an "initialize"or "init". I tend to put this block in "on start", but it just has to come before using other blocks. The default address for the device is 60. 

The next thing that is good to know is that there is a zoom mode which enlarges things to make it easier to read, but also shifts this to a 64x32 pixel resolution (zoom=true in the code ; tinkeacademy defaults to this). This means that with zoom=true, you have 4 lines of text (vs 8) and 12 columns of text (vs 24). You need to know this because you can choose where to start text. Likewise, if you are drawing lines or pixels, you have 64 (0-63) for x position and 32 (0-31) for y position












The third thing is color. Some blocks allow you to pick color, with your choices being 0 or 1. 1 is "normal", black screen with color text (mine is yellow on top line and blue on other 3 in zoom = true mode...double that for zoom=false). Color 0 is inverted, black text with color highlighting it.

The obvious use for this device is to display sensor or variable data. This can be easily done with the makecode blocks (example code






Here is me using the BitBooster from lectrify to make connections to pin 19 & 20 via their designated I2C grove port.

















I believe graphing and displaying images/icons/bitmaps is possible, but you will have to use micropython to accomplish this. The blocks are just too limited. More exploration is needed
Some possible places to read further
https://www.littlebird.com.au/a/how-to/81/0-96-oled-screen-with-micro-bit
and
http://www.suppertime.co.uk/blogmywiki/2019/11/microbit-oled-display/