rdagger / micropython-ssd1351

MicroPython SSD1351 OLED Display Driver
MIT License
58 stars 13 forks source link

no way to rotate display #5

Closed Matt2D3 closed 2 years ago

Matt2D3 commented 2 years ago

there is no way to rotate the display that I can find, the ssd1351 I am using is rotated 90 degrees clockwise, I cannot physically rotate the display

rdagger commented 2 years ago

The font method has a landscape parameter to draw rotated text. For drawing lines and shapes you can swap X and Y.

Matt2D3 commented 2 years ago

the text is now upside down, is there a way to fix that

rdagger commented 2 years ago

I added limited support for flipping text upside down. There is a new demo: _demo_fontsflipped. It works by reversing the order of the 16-bit color byte array. demo_fonts_flipped

Furthermore, you could always turn the display upside down.

Sorry I currently have very little spare time so if you want a more robust solution you might also take a look at my SSD1309 library. It is a similar monochrome library that supports font rotation using an improved version of my xglcd_font.py class. It works with the same fonts but returns a frame buffer instead of a byte array. You probably could modify the text drawing methods of the SSD1351 library to work with a frame buffer but you would have to modify the frame buffer from MONO_VLSB to RGB565 format. At least in theory because it's been a while since I wrote that code. You should also look at the draw_text8x8 method because it uses the built-in Micropython font implemented as a frame buffer.

Many displays let you flip or rotate the display in hardware but I think the SSD1351 is limited to portrait or landscape. However, I could be mistaken so please take a look at the datasheet.

Matt2D3 commented 2 years ago

thanks, i used a slightly different method to fix this issue, I made an inverted font pack and changed SET_REMAP = const(0xA0) to SET_REMAP = const(0xA1)