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...

7 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
    Replies
    1. I think you should enter "python test.py" to run it...

      Delete
  4. This is a lovely thing, which I would like to use on my UnicornhatHD. I've managed to get it to run using a quarter of the display, but cannot see how to make it use the full width of the display, for the life of me. It's five years old - can you remember what would need changing?

    ReplyDelete
    Replies
    1. I did find out how to do it, but forgot to say so...

      https://www.blogger.com/blog/post/edit/19190782/7770159591643869664

      Delete
  5. The Unicorn HAT provides a compact and colourful way to display scrolling messages on your Raspberry Pi.
    RazorSQL Crack

    ReplyDelete