rust-embedded-community / ssd1306

SSD1306 OLED driver
Apache License 2.0
283 stars 69 forks source link

Fix display rotation for different screen sizes #145

Closed bugadani closed 3 years ago

bugadani commented 3 years ago

Hi! Thank you for helping out with SSD1306 development! Please:

PR description

All display sizes, except for the 96x16 are centered, meaning OFFSETX is same for both 0 and 180 rotations. The 96x16 is an exception to this, where it's OFFSETX is 0.

This PR changes flush() so it doesn't assume a symmetrical display. I also added the option to specify different driver sizes, but I'm pretty sure the only reason for that in this driver is to avoid a magic number (128) in the code.

Also 72x40 rotation was broken due to swapped X/Y offsets.

Tested on 128x32, 72x40 and 96x16 displays.

Closes #138