Scroll pHAT: scroll speed, brightness etc


Just having some fun fiddling with some python scripts on the scroll phat. Here’s what I’m wondering:

  • What is the maximum brightness? I love the way it has finer control of brightness than the unicorn hat, but still haven’t worked out the maximum yet… I think it is 100. Is it 100?
  • Is it possible to control the brightness of individual LEDs? When I try setting brightness in my scripts, every LED changes, not just the one I am setting. Is my code rubbish?
  • Using the example text scrolling scripts, can the speed of scrolling be controlled? I want it to go a little quicker.
  • Is there a maximum size for the scrolling buffer? Say, if I put an entire book in to be scrolled, would it work?

Thanks for your help :)

I think the maximum brightness is 128, according to the datasheet for the matrix driver chip.

It’s not possible to individually control the brightness of each LED. You’d need a charlieplexed LED matrix for that. Adafruit have a very nice one, that we stock in our shop.

To speed up the text scrolling, all you would have to do would be to decrease the delay time in the while loop, for example changing time.sleep(0.1) to be time.sleep(0.05) would make it scroll twice as fast. The sleep times are in seconds.

In theory, I don’t think there’s a limit, but it may struggle with very large amounts of characters since I think it would have to hold it all in memory. If you were wanting to do this, you’d be better to write some custom code with something like a Python iterator which would iterate over chunks of text and be much more memory efficient (this is how file parsing works in Python).

Excellent, thank you.

Yes - confirmed that it has 128 brightness levels.

Next thing I need to figure out is how to scroll a single iteration of the message, rather than a loop. At the moment I am multiplying the [scrollphat.scroll()] command by the number of the characters in the message, multiplied by 5 for the number of pixels across each letter is. Most are 3 or 4 pixels across, but some are more, so I have to over-estimate. I’m sure this is a silly way of doing things…

scrollphat has a buffer_len() method that tells you the pixel width of the buffer, so you can use that to get the exact width.

I’ll cover this in my tutorial, but here’s a quick example:

status_length = scrollphat.buffer_len()
while status_length > 0:
    status_length -= 1

Hope that helps…

Yeah that is getting there, thanks. The messages have to be surrounded with spaces otherwise it repeats the first characters of the message again for the final 11 pixels, which isn’t much a problem. However, given the task of taking random lines from a file and scrolling them, it still seems to trip over itself and the strings become mixed together. Maybe it’s my coding. I think it can be solved by having large wait times around each message, which I was planning on anyway.

lines = open(‘text_to_scroll.txt’).read().splitlines()

while True:
sp.write_string(" " + random.choice(lines) + " ")
status_length = sp.buffer_len()
while status_length > 0:
status_length -= 1
except KeyboardInterrupt:
Hmm that’s not indented properly ^^ nevermind