Monday, 22 December 2014

Unicorn Hat text scroller

After I wrote my Xmas Tree code for the Unicorn Hat I felt like I needed to also be able to display a festive message. Although it is quite narrow, I reckoned a text scrolling app would work quite well on the Unicorn Hat if I kept the character size slightly smaller than full-screen(grid?).


I decided to fix most characters to 6x4 pixels (with the exception of those fatties M and W) which allows for portions of 2 characters on the screen simultaneously.

I've stuck the various Python files up on GitHub. In includes a test script which produces this output:



Anyway, my son liked it and wrote a program to create a random 5 letter word and display it in a random colour:

from UHScroll import*import random import string
bill=['red','white','pink','blue','green','cyan']
def wordpick():    qwerty = ''    for q in range(5):        bob=random.choice(string.letters)        qwerty = qwerty + bob    return qwerty
for w in range(5):    dad=wordpick()    print dad    unicorn_scroll(dad,random.choice(bill),254,0.5)
He likes doing stuff with the Python random module at the moment...

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. When I enter sudo ./test.py I've got a command not found in Terminal. I'm a noob I'll admit but how do I start the program, since it's not the same way as the pimoroni examples.

    ReplyDelete
  3. When I enter sudo ./test.py I've got a command not found in Terminal. I'm a noob I'll admit but how do I start the program, since it's not the same way as the pimoroni examples.

    ReplyDelete