pimoroni / scroll-phat-hd

Python library for Scroll pHAT HD
https://shop.pimoroni.com/products/scroll-phat-hd
MIT License
159 stars 64 forks source link

example:twitter-hashtag wrapping error #40

Closed MrGJones closed 5 years ago

MrGJones commented 6 years ago

there appears to be a wrapping error.

after the scrolling tweet has completed, the '>>>>>' from the beginning of the string is wrapped and then gets cleared from the scrollphat. seems to be some buffer length problem?

Gadgetoid commented 6 years ago

I think I came across this when I was modifying the example for something else actually, the issue is that status_length is the total length of the string in pixels, rather than the total amount of pixels it needs to be scrolled to fully slide across the display.

It needs rewritten to:

But for now you can probably do something like:

status_length -= scrollphathd.width

I think it also needs one more pixel lopped off, so it might have to be:

status_length = status_length - scrollphathd.width - 1
MrGJones commented 6 years ago

Ok thanks Phil. I'm sure it used to be Ok? Has something changed in the library?

On 13 Nov 2017 21:05, "Philip Howard" notifications@github.com wrote:

I think I came across this when I was modifying the example for something else actually, the issue is that status_length is the total length of the string in pixels, rather than the total amount of pixels it needs to be scrolled to fully slide across the display.

It needs rewritten to:

  • Subtract the width of Scroll pHAT HD from status_length
  • Pause for a second when first showing the text
  • Scroll as normal
  • Pause for a second at the last point in scrolling
  • Clear

But for now you can probably do something like:

status_length -= scrollphathd.width

I think it also needs one more pixel lopped off, so it might have to be:

status_length = status_length - scrollphathd.width - 1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pimoroni/scroll-phat-hd/issues/40#issuecomment-344057510, or mute the thread https://github.com/notifications/unsubscribe-auth/AZZbPC3aSkFMs0dDXHn68eQHdkizG2m3ks5s2K78gaJpZM4QbEfU .

MrGJones commented 6 years ago

phil we had a similar problem during earlier stages of this and it was fixed in your development branch! (somehow) :) https://forums.pimoroni.com/t/porting-scrollphat-to-scrollphat-hd/4431/11

On 13 November 2017 at 21:22, Mr-G Jones mailmrg@gmail.com wrote:

Ok thanks Phil. I'm sure it used to be Ok? Has something changed in the library?

On 13 Nov 2017 21:05, "Philip Howard" notifications@github.com wrote:

I think I came across this when I was modifying the example for something else actually, the issue is that status_length is the total length of the string in pixels, rather than the total amount of pixels it needs to be scrolled to fully slide across the display.

It needs rewritten to:

  • Subtract the width of Scroll pHAT HD from status_length
  • Pause for a second when first showing the text
  • Scroll as normal
  • Pause for a second at the last point in scrolling
  • Clear

But for now you can probably do something like:

status_length -= scrollphathd.width

I think it also needs one more pixel lopped off, so it might have to be:

status_length = status_length - scrollphathd.width - 1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pimoroni/scroll-phat-hd/issues/40#issuecomment-344057510, or mute the thread https://github.com/notifications/unsubscribe-auth/AZZbPC3aSkFMs0dDXHn68eQHdkizG2m3ks5s2K78gaJpZM4QbEfU .

MrGJones commented 6 years ago

@Gadgetoid hey phil i've just run this on the old rpi with this dev build on it and it works ok on there.

Gadgetoid commented 6 years ago

But the devel branch was merged into master back in April, so that's pretty ancient history.

I can't see what's broken it, but it should be easy enough to update and fix, with a couple of timing tweaks too.

For my ScrollBot web API I used the following variation:

    while running:
        try:
            scrollphathd.clear()
            status = q.get(False)
            scrollphathd.write_string(status,font=font5x7, brightness=0.1)
            status_length = scrollphathd.write_string(status, x=0, y=0, font=font5x7, brightness=0.1) - scrollphathd.width - 1

            # Show string at start
            scrollphathd.show()

            # Pause for a second
            time.sleep(1)

            # Scroll through the string
            while status_length > 0:
                scrollphathd.scroll(1)
                scrollphathd.show()
                status_length -= 1
                time.sleep(0.02)

            # Pause again at the end
            time.sleep(1)

            # Clear the display
            scrollphathd.clear()
            scrollphathd.show()

            q.task_done()

        except queue.Empty:
            time.sleep(1)

This pauses at the beginning/end of the scrolling message, too, to make it less jarring.

MrGJones commented 6 years ago

Hi phil thanks for the reply mate..i need to check the code again as I've been tinkering with versions of the btc ticker and aiy again lately 😁

On 21 Nov 2017 14:27, "Philip Howard" notifications@github.com wrote:

But the devel branch was merged into master back in April, so that's pretty ancient history.

I can't see what's broken it, but it should be easy enough to update and fix, with a couple of timing tweaks too.

For my ScrollBot web API I used the following variation:

while running:
    try:
        scrollphathd.clear()
        status = q.get(False)
        scrollphathd.write_string(status,font=font5x7, brightness=0.1)
        status_length = scrollphathd.write_string(status, x=0, y=0, font=font5x7, brightness=0.1) - scrollphathd.width - 1

        # Show string at start
        scrollphathd.show()

        # Pause for a second
        time.sleep(1)

        # Scroll through the string
        while status_length > 0:
            scrollphathd.scroll(1)
            scrollphathd.show()
            status_length -= 1
            time.sleep(0.02)

        # Pause again at the end
        time.sleep(1)

        # Clear the display
        scrollphathd.clear()
        scrollphathd.show()

        q.task_done()

    except queue.Empty:
        time.sleep(1)

This pauses at the beginning/end of the scrolling message, too, to make it less jarring.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pimoroni/scroll-phat-hd/issues/40#issuecomment-346042680, or mute the thread https://github.com/notifications/unsubscribe-auth/AZZbPAlKPNN0Zvi_soSk7NM9azUh9RfEks5s4t3ogaJpZM4QbEfU .

Gadgetoid commented 6 years ago

Ahoy @MrGJones - did you have an opportunity to look into this?

MrGJones commented 6 years ago

Not yet mate, too much graphics work lately I'm afraid.. but it's still on my list to do.

On 23 Jan 2018 11:56, "Philip Howard" notifications@github.com wrote:

Ahoy @MrGJones https://github.com/mrgjones - did you have an opportunity to look into this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pimoroni/scroll-phat-hd/issues/40#issuecomment-359768125, or mute the thread https://github.com/notifications/unsubscribe-auth/AZZbPJY-vBl3d3ko0YwMYbWilVnVb7VVks5tNcjSgaJpZM4QbEfU .

MrGJones commented 5 years ago

@Gadgetoid hey phil, i've tested this and all seems ok now? so you can del this case i think!

on another note it appears the tweets being fetched by tweepy are being truncated to 140chars so i need to look into this "extended_tweet" function: https://developer.twitter.com/en/docs/tweets/tweet-updates