Porting scrollphat to scrollphat hd


hi does anyone know if there is an equivalent function of scrollphat.buffer_len() for the scrollphat hd?


There’s no direct equivalent. It depends what you’re trying to accomplish.

Scroll pHAT had a 1d buffer (kinda) in that it would only extend horizontally, so buffer_len was usually a reliable way of figuring out how long the text is you’ve just drawn to it for scrolling and other business.

Scroll pHAT HD updated to a rotate-able/pan-able/flip-able 2d buffer, and write_string returns a length when you write something to the display, which might be a good substitute.

Looking over the code now, there’s no reason why there shouldn’t be a get_buffer_shape though.


ok thanks phil. im just trying to fix my old tweettoscrollphat code


how to retrieve this?


Possibly not the clearest example, but it’s done here: https://github.com/pimoroni/scroll-phat-hd/blob/master/examples/advanced-scrolling.py#L36

lengths[line] = scrollphathd.write_string(text, x=offset_left, y=line_height * line)

Or, to simplify:

text_length_in_pixels = scrollphathd.write_string(text, x=0, y=0) 

Would draw a text string starting from position 0,0 and return the length in pixels.


many thanks phil, getting better results now :)


Look forward to seeing this i didn’t have much luck converting twitter reader on scroll phat to scroll phat hd


I’m getting there! I just need to resolve a confusing bug!


you can see the progress here - Twitter #hashtag to scroll pHAT


You might want to try the Scroll pHAT HD development branch to see how well it works with that ;)

You can grab and install it by running:

git clone http://github.com/pimoroni/scroll-phat-hd -b devel scroll-phat-hd-devel
cd scroll-phat-hd-devel/library
sudo python ./setup.py install

See: https://github.com/pimoroni/scroll-phat-hd/pull/14 for the list of changes/fixes.

Twitter #hashtag to scroll pHAT

cheers phil ill give that a go!


well phil that has fixed all my problems, but i guess you already knew that … many thanks kind sir!