Scroll Phat - Scroll Text


#1

Hi,

Having a bit of bother getting the simple text example working.

It compiles and runs fine but no text on the Phat, the shell shows the following:
python simple-text-scroll.py “message” press CTRL-C to exit

The Phat works fine with all the other examples but i cant figure this one out.
Im am guessing that the required text goes in the speak marks as shown below?

Any help appreciated:

import scrollphat
import sys
import time

if len(sys.argv) != 2:
        print("\nusage: python simple-text-scroll.py \"message\" \npress CTRL-C to exit\n")
        sys.exit(0)

scrollphat.write_string(sys.argv[1] + "HELLO WORLD ")

while True:
        scrollphat.scroll()
        time.sleep(0.1)

#2

Ooh, how are you running it? You should do something like:

python simple-text-scroll.py "Hello this is my text!"

It accepts the text string on the command line. The " " at the end of the write_string line only serves to pad it with spaces so it wraps nicely.

The len(sys.argv) != 2: line is checking to see how many arguments are being passed to the script. By default all scripts get their name passed as the first argument, but this script is expecting at least 2 arguments- the second being the text string to display.


#3

Thanks for the quick response.

I was look to put the text in the code itself.
I was also running it from the python shell IDEL rather than the command line.

All make sense now.

Thanks =)


#4

Sorry for our lack of documentation so far. I’m in a mad panic to get everything up to speed.

You could modify the example to do what you’re looking for, like so:

import scrollphat
import time

scrollphat.write_string("HELLO WORLD ")

while True:
        scrollphat.scroll()
        time.sleep(0.1)

#5

I made exactly the same mistake/s as above :)

However, I now have the same problem from the command line that I was having in Idle:

ImportError: No module named scrollphat

I’ve updated the pi and I tried apt-get install python, but it says I have the latest version.

I’m sure I’m doing something really obvious wrong-please help!


#6

Please run

curl -sS get.pimoroni.com/scrollphat | bash

… it will reinstall the scrollphat library if required if you answer ‘yes’ to all questions.


#7

Thanks for the quick reply. Running now…and many Ooooooohs in this household :)