rust-embedded-community / ssd1306

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

Fix terminal mode #129

Closed bugadani closed 3 years ago

bugadani commented 4 years ago

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

PR description

~I had a go with #85 and failed miserably. But while doing so, I discovered the driver crashes with 90° rotation. This PR fixes that crash, but does nothing to fix the rotation issue.~

The issue is, properties.get_dimension flips width and height but set_draw_area expects them in the original order. I think for clearing it doesn't matter which direction we go, so I'm using the original physical size instead.

This is a performance hit, because every cursor move sends several display commands, but all the rotation values are rendered correctly.

jamwaffles commented 4 years ago

This fixes the clear issue, but the terminal_i2c demo crashes if I add .with_rotation(DisplayRotation::Rotate90) or .with_rotation(DisplayRotation::Rotate270) to it with this odd result:

image

I haven't had time to investigate but it would be great to fix this new crash in this PR as well, even if the characters remain garbled.

bugadani commented 4 years ago

Thanks I forgot to fill my screen to see if there's anything more fishy. Current code writes in the correct direction but newline handling is still incorrect and characters are rotated.

bugadani commented 4 years ago

I've fixed the whole thing instead. Code quality could use some love, but hey, priorities :)

Closes #85

therealprof commented 4 years ago

@therealprof you were the original author of TerminalMode so I'll let you approve and merge this PR if you're happy with it.

I was afraid you would say that. 😅

bugadani commented 4 years ago

reset_pos still needs to be checked, and the docs updated, so take your time :)

bugadani commented 4 years ago

Once CI is happy, this is ready for review

jamwaffles commented 3 years ago

Awesome. I'll do a release later this evening. Thanks for your patience all!