MCExtension-DumbDisplay

DumbDisplay MakeCode Extension (for Microbit V1)

DumbDisplay MakeCode Extension is a simple tool to extend your Micro:bit screen to your Android phone via Micro:bit (V1) built-in Bluetooth LE or USB Serial.

DumbDisplay MakeCode Extension Illustration

Micro:bit Turtle LEDs + LCD

Description

You explode your creativity with a little help from this extension, and use DumbDisplay to realize an enhanced Micro:bit virtual screen on your Android phone.

You can install the free DumbDisplay app (v0.3.2 or later) from Android Play Store – https://play.google.com/store/apps/details?id=nobody.trevorlee.dumbdisplay

The app can accept connection via

In summary, this extension allows you to use DumbDisplay as a screen in place of the Micro:bit built-in screen

Usage

For example, you can take advantage of your phone high-resolution screen to render drawings from your Micro:bit with Turtle-like operations.

You can also make use of DumbDisplay LED Grid / LCD layers for showing your experiment results, without the need to actualy attach real LEDs and/or LCD to your Micro:bit.

Your program can be interactivity; your drawings on the different layers can be according to Micro:bit different input mechanisms like

There should be many ways you can use DumbDisplay as a tool to realize your creativity.

Sample Code

To start with, you should setup DumbDisplay (DD) like

// set a Micro:bit layer of size (5, 5)
ddmb.setup(5, 5)

Samples

1. Micro:bit 2. Turtle 3. LEDs + LCD 4. “Bar Meter” 5. Manual “pin” layers

Screenshot 1 – imitating your Micro:bit screen with your phone

Then you can program something more interesting, like

// setup a Micro:bit layer of size (5, 5)
ddmb.setup(5, 5)
basic.forever(function () {
    // draw a heart icon to Micro:bit layer
    ddmb.showIcon(IconNames.Heart)
    basic.pause(1000)
    // draw a small heart icon to Micro:bit layer
    ddmb.showIcon(IconNames.SmallHeart)
})

Screenshot 2 – showing drawings rendered by Turtle-like operations (with Micro:bit icons as background)

You can use Turtle-like operations to draw something interesting, like

// setup a Turtle layer of size (100, 100)
ddturtle.setup(100, 100)
// setup a Micro:bit layer of size (5, 5)
ddmb.setup(5, 5)

// set Micro:bit layer opacity to 20 (of 255)
ddmb.layer().layerOpacity(20)

basic.forever(function () {
    // turtle draws a circle
    ddturtle.circle(20)
    // turtle turns right 20
    ddturtle.right(20)  
    // draw a heart icon to Micro:bit layer
    ddmb.showIcon(IconNames.Heart)
    // pause a second
    basic.pause(1000)
    // draw a small heart icon to Micro:bit layer
    ddmb.showIcon(IconNames.SmallHeart)
    basic.pause(1000)
})

Screenshot 3 – using LEDs and LCD (“auto pinning” the layers)

By making use of LED / LCD layers, you can show experiment result values in various ways, like

// configure to "auto pin (layout) layers" in the vertical direction
dumbdisplay.configAutoPinLayers(AutoPinDirection.Vertical)

// create a LED layer
let ledLayer = dumbdisplay.setupLedGridLayer(3, 1)
// create a LCD layer
let lcdLayer = dumbdisplay.setupLcdLayer()

// turn on LEDs
ledLayer.ledOnColor("red")
ledLayer.ledOn(0, 0)
ledLayer.ledOnColor("green")
ledLayer.ledOn(1, 0)
ledLayer.ledOnColor("blue")
ledLayer.ledOn(2, 0)

// print messages to LCD
lcdLayer.setCursor(2, 0)
lcdLayer.print("Hello There!")
lcdLayer.setCursor(2, 1)
lcdLayer.print("How are you!")

Screenshot 4 – using LED Grid as Bar Meter

In fact, you can use the LED grid layer as some sort of “Bar Meter” that shows meter values, like

// create a LED layer of size 10 by 1 (with sub-led size 1 by 5)
let horiBarMeter = dumbdisplay.setupLedGridLayer(10, 1, 1, 5)

// set colors
horiBarMeter.layerBackgroundColor("darkblue")
horiBarMeter.ledOnColor("green")
horiBarMeter.ledOffColor("lightgray")

// loop show bar of different values 
basic.forever(function () {
    for (let c = 1; c <= 10; c++) {
        horiBarMeter.ledBar(c)
        basic.pause(200)
    }
})

Screenshot 5 – “pinning” 3 LEDs in a more controlled way

You can fine tune how different layers be “pinned”, like

// configure the imaginary "pin frame" to be 3 units x 3 units
dumbdisplay.configPinLayers(3, 3)

// create 3 LED layers
let ledLayer1 = dumbdisplay.setupLedGridLayer()
let ledLayer2 = dumbdisplay.setupLedGridLayer()
let ledLayer3 = dumbdisplay.setupLedGridLayer()

// pin LED layer 1 to position (0, 0) with size (1, 1)
dumbdisplay.pinLayer(ledLayer1, 0, 0, 1, 1)
// pin LED layer 2 to position (1, 1) with size (1, 1)
dumbdisplay.pinLayer(ledLayer2, 1, 1, 1, 1)
// pin LED layer 3 to position (2, 2) with size (1, 1)
dumbdisplay.pinLayer(ledLayer3, 2, 2, 1, 1)

// turn on LEDs
ledLayer1.layerBackgroundColor("lightgray")
ledLayer2.layerBackgroundColor("lightgray")
ledLayer3.layerBackgroundColor("lightgray")
ledLayer1.ledOnColor("red")
ledLayer1.ledOn()
ledLayer2.ledOnColor("green")
ledLayer2.ledOn()
ledLayer3.ledOnColor("blue")
ledLayer3.ledOn()

Reference

You largely do not need to use DumpDisplay package. Instead, you will mostly use DD.MB and/or DD.Turtle to render drawings on the corresponding layers.

Micro:bit

DD.MB:

Turtle

DD.Turtle:

DumbDisplay

DumbDisplay:

“Layers”

DDLayer – “layer” operations (all layer objects including applicable to Micro:bit layer and Turtle layer):

LedGridLayer

on top of DDLayer, additional LedGridLayer operations:

LcdLayer

on top of DDLayer, additional LcdLayer operations:

Reminder

A reminder – DumbDisplay will make use of both your Micro:bit Bluetooth and USB Serial, therefore you should not be making use of them for your own purposes. However, if you really need to use any one of them, you can call DumbDisplay.connect() explicitly, and set to disallow DumbDisplay to use Bluetooth or USB Serial.

Thank You!

Greeting from the author Trevor Lee:

Be good! Be happy! Peace be with you! Jesus loves you!

Supported target

PXT/microbit

License

MIT