Skip to content

displayio: make 'rotation' property settable #2390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2019

Conversation

jepler
Copy link

@jepler jepler commented Dec 16, 2019

Discord's andyleer and I both recently noticed that it is not possible to set the rotation property of a
display. This is inconvenient if you want to change the rotation, as you have to copy the initialization from core C code into Python. Since e.g., the Pynt's blurb on adafruit.com says

Rotate it 90 degrees, it’s a web-connected conference badge #badgelife.

we should probably make it easy.

This lightly tested change does that, including resizing the terminal when you do. If you've got your own Groups displaying, you may need to reinitialize them. (I only tested it with terminal or with resetting the displayed group immediately)

(I also want to use this as a workaround for #2386 in JEplayer, I'll just flip the display orientation to the one that is faster)

@jepler jepler requested a review from tannewt December 16, 2019 21:29
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this cause a refresh if the displayed Group is from the user?

@jepler
Copy link
Author

jepler commented Dec 20, 2019

@tannewt Yes, this program continually rotates the given text in 90 degree increments, automatically refreshing:

import board
import displayio
import terminalio
import time
import adafruit_display_text.label

g = displayio.Group()
l = adafruit_display_text.label.Label(font=terminalio.FONT, text="hi mom")
l.x = l.y = 32
g.append(l)
board.DISPLAY.show(g)

while True:
    board.DISPLAY.rotation = (board.DISPLAY.rotation + 90) % 360
    time.sleep(1)

@jepler jepler requested a review from tannewt December 20, 2019 17:30
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks!

@tannewt tannewt merged commit 5fc2014 into adafruit:master Dec 20, 2019
@jepler jepler deleted the displayio-set-rotation branch November 3, 2021 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants