Skip to content
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

When rotating displays dimensions are not getting updated #104

Open
riskable opened this issue Apr 4, 2022 · 4 comments · May be fixed by #105
Open

When rotating displays dimensions are not getting updated #104

riskable opened this issue Apr 4, 2022 · 4 comments · May be fixed by #105

Comments

@riskable
Copy link

riskable commented Apr 4, 2022

If you call display.set_rotation(DisplayRotation::Rotate90); or display.set_rotation(DisplayRotation::Rotate270); the display's dimensions (WIDTH/HEIGHT) should be swapped so that embedded-graphics text alignment features can work properly. As things are right now, if you rotate the display 90° or 270° only left-aligned text will display properly.

@riskable
Copy link
Author

riskable commented Apr 4, 2022

Example of how another embedded-graphics crate handles dimensions after rotation:

https://github.com/jamwaffles/ssd1306/blob/master/src/lib.rs#L279

...and:

https://github.com/jamwaffles/ssd1306/blob/master/src/mode/buffered_graphics.rs#L237

riskable added a commit to riskable/epd-waveshare that referenced this issue Apr 4, 2022
…d) when rotating displays 90 and 270 degrees.
@riskable
Copy link
Author

riskable commented Apr 4, 2022

Turns out it was pretty easy to fix this... Just a bit tedious (had to make small changes to graphics.rs for every supported display). Here's the confirmation that it works (this display has: display.set_rotation(DisplayRotation::Rotate270); applied)

Before:

PXL_20220404_163738183

After:

PXL_20220404_184400585

@eflukx
Copy link

eflukx commented Apr 16, 2022

Yep just wanted to create this exact same issue.. and found this one.. :)

Fixed it for my display as follows: (and works fine now with 'embedded graphics' and 'embedded layout')

impl OriginDimensions for Display2in13 {
    fn size(&self) -> Size {
        match self.rotation() {
            DisplayRotation::Rotate0 | DisplayRotation::Rotate180 => Size::new(WIDTH, HEIGHT),
            DisplayRotation::Rotate90 | DisplayRotation::Rotate270 => Size::new(HEIGHT, WIDTH),
        }
    }
}

If needed/wanted I could make a PR for this change (missed the already outstanding PR)

Ps. I see there's quite some code duplication in this library, also the screen/controller code is not very well separated either. I'd say some major (probably API-breaking) refactoring are in order.. (maybe even an name change, as this is really not about supporting Waveshare EPD's only..)

@jquesada2016
Copy link

CAme here for the same thing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants