Starbit Commander II

Well on my quest to learn python, I poked and peeked around on the web of inters. And came across some nice sites about the micro:bits, projects and coding.

One site inspired me to create a python version of Starbit Commander. This site is home to a lot of projects of Derek Graham. Next to Micro:bit bits, he has a lot of other stuff too on his site.

But why remake of Starbit Commander? Derek has this nice example of “Tiny Astroids”, which resembled a lot like Starbit Commander. And he created it in Python… sooo.. mine Starbit Commander should get a python version too… In this little gem from Derek, he created a really really nice piece of code that animated an explosion on this 5×5 led display. I loved it. And although I wanted to create Starbit from scratch in OO, I really wanted to adopt this nice little tiny explosion.. So I contacted Derek via twitter, asked if he agreed me borrowing his explosion-code. we had a short but very nice chat on twitter and he agreed for the code to be reuse in Starbit Commander. Thanks Derek!

Well, I wanted to test and learn more python and also OO in python. So I decided to try to make Starbit Commander in an OO-style. I have no experience in this but I think (as far as I can tell) this is an OO-version of the game now. Derek mentioned on micro:bit V1’s coding OO would let you ran into out of memory errors. I haven’t seen them on the microbit V2 with Starbit Commander. (Now I’m worried if I did a proper OO-coding style ;-0)

I differed a bit from the original Starbit code. While de MakeCode version has power-ups to collect, in this python-version I decided to skip that and make the astroidfield a bit more challenging by starting slow and easy and ending fast and astroid-crowded. Giving you more and more bonus score along the way you go.

This code can by found here. And watch that explosion… Thanks again Derek Graham!

Micro:bit Fireflies

My first attempt to write some (micro)Python code. Fireflies. This leds simulate fireflies in the air…

btw. I found that display.get_pixel does not return the correct value a led on a micro:bit. There is function to correct this behavior in the code.

from microbit import *
import random

# This fucntions fixes the "display.get_pixel" bug.
# a full bright led does not return a "9" but a "255".
def fixPixelBug(brightness):
    if brightness == 4:
        return 3
    elif brightness == 8:
        return 4
    elif brightness == 16:
        return 5
    elif brightness == 32:
        return 6
    elif brightness == 64:
        return 7
    elif brightness == 128:
        return 8
    elif brightness == 255:
        return 9
    else:
        return brightness


while True:
    sleep(50)

    brightness = random.randint(1, 9)
    x = random.randint(0, 4)
    y = random.randint(0, 4)
    if display.get_pixel(x, y) == 0:
        display.set_pixel(x, y, brightness)

    for fireflies in range(0, 5):
        x = random.randint(0, 4)
        y = random.randint(0, 4)

        if fixPixelBug(display.get_pixel(x, y)) > 0:
            display.set_pixel(x, y, fixPixelBug(display.get_pixel(x, y)) - 1)

https://github.com/marc0janssen/microbit-fireflies/blob/main/fireflies%20v2.py

Simple Simon Says

The game Simon in the late 70’s was maybe the first “computer” game I played. Well maybe it was a real computer. I was just a kid, but the game stayed always with me. In my mind that is. The game was from a friend and we played it for ages.

Now with the Micro:bit I wanted to revive this memory and use the Micro:bit as a vehicle to get this to life again. Below is my make code attempt. I used an Micro:bit version2 for this.

This Simon listens to Buton A, Button B, Button C (the touch sensitive logo), Button D (= Button A+B).

It was fun to create and a good way to set me off with the possibilities of the Micro:bit…

To edit this repository in MakeCode.

Starbit Commander

This game is my first coding for The BBC Micro:bit. The goal is to have a nice target to practice and learn microPython on this device. But first I wanted to have a go on the makeCode editor for the Micro:bit.

I made this simple little game. Flying a spaceship through an astroidfield. Sometimes a blinking power-up will appear. This gives a the advance to survive an astroid collision. Catching two power-ups will destroy all astroids in the field. Astroids will speed up in time but slow down if a double power-up is acquired.

To edit this repository in MakeCode.

Pretty Good Privacy with keybase.io

I used PGP back in the 90’s just because it was possible. The internet was growing and my friends and I liked to experiment in those days with all that we found on the internet. PGP was one of those things. We had great fun back then but never used it again the following decades.

But a few days ago I saw a talk from Mike Godwin about privacy on the internet. He pointed out https://www.keybase.io/ in his talk as a start to set up PGP and ways to communicate with him.

I got curious again about PGP and Keybase.io and I had no trouble at all to quickly setup an account and a PGP key pair with these guys. They have nice low-level tooling to encrypt and decrypt messages on their website.

What I wanted again was a way to have my email encrypted, like I had back then in the 90’s when my friends and I played around with it. I found a great tutorial on the internet from the Electronic Frontier Foundation on how to het PGP setup on a MAC.

It is setup with Thunderbird Mail Client and within this tutorial they let you generate a PGP key pair with GnuPG. Which will do the job but I wanted to set it up with my Keybase.io key pair. I needed to export my Keybase.io key pair to the GnuPG keychain.

Reading the docs at their site, I found out that I could pull my Keybase.io Key to GnuPG keychain by the following command.

keybase pgp pull-private –all


But this gave me the following error

▶ ERROR .keys doesn’t exist

Error that .keys does not exist

Just following this workaround to fix it.

Make sure that in the linked device to your keybase.io account the option “Forbid account changes from the website” is disabled in the advanced settings. By disabling this option more possibles are enabled on the keybase.io site. One of them is to export your private key.

After you have disabled this option on your device, go to the website of keybase.io and visit your profile page. And find an “edit” link behind the signature of the public key. Select the edit link and you get the option to export your private key.

Exporting your private key

Copy the key and save it to your desktop. Use the following command to import the private key to the GnuPG keychain. Where “Private_Key.asc” holds your private key.

gpg2 –allow-secret-key-import –import Private_Key.asc

Also save your public key to your desktop. And import this one with the following command. Where “Public_Key.asc” holds your public key.

gpg2 –import Public_Key.asc

This serie of actions will replace the generation of a PGP key pair with GnuPG and import your keybase.io key pair.

DON’T FORGET TO DELETE YOUR PRIVATE KEY FROM YOUR DESKTOP.

Make sure it’s cleaned up!

Now finish the thunderbird tutorial from EFF with the keybase.io key pair. And you have a PGP mailclient setup with keybase.io. There is also a nice integration possible with the MacOS MAIL.APP with https://gpgtools.org but this requires a paid license. Whatever suites your needs.

Ok I hope this helps you.

Find me here on keybase.io and if you like to send me a PGP encrypted email, here is my public key. But this one can also be found on keybase.io.

Oh and don’t forget to send me your public key or your keybase.io profile page so I can download your public key if you shared it. If you want a message back of course ;-).

Use the following command pull in my public key in your GnuPG keychain. And a follow on keybase.io.

curl https://keybase.io/marc0janssen/pgp_keys.asc | gpg2 –import

keybase follow marc0janssen


Thanks for reading!