stealthylabs / libssd1306

C graphics and device driver library to write to OLED SSD1306 128x64 or 128x32 using I2C
MIT License
19 stars 8 forks source link

how to rotate #2

Closed or78rXxZ closed 3 years ago

or78rXxZ commented 3 years ago

first thing thanks test_libev_clock works ok except the display is upside down and backwards i can't rearrange the position of the device how can i rotate the text

stealthylabs commented 3 years ago

Hello @or78rXxZ

That's interesting.

or78rXxZ commented 3 years ago

On 2021-01-26 04:47 AM, Stealthy Labs wrote:

Hello @or78rXxZ [1]

That's interesting.

  • Are you not seeing the display like in my blog post: https://stealthy.io/blog/2020/08/09/oled-ssd1306-libev-clock.html [2] ?
  • Can you verify that you have connected your OLED screen correctly to the I2C board such as Raspberry Pi ? Could just be an orientation issue.
  • Have you tried clearing your OLED screen using the ssd1306_i2c_display_clear function [3] explicitly first ?

the device i am using is https://www.hardkernel.com/shop/odroid-hc4-oled/ i'm guessing the display is mounted "upside down" i figured out how to rotate the text and i'm using your libev_clock.c example to display date and time someone on another forum mentioned that when displaying lower case text the letters are shifted up i've not tried this

stealthylabs commented 3 years ago

the device i am using is

https://www.hardkernel.com/shop/odroid-hc4-oled/

i'm guessing the display is mounted "upside down"

Yes the orientation of the SSD1306 OLED in that device is most likely upside down from a pin diagram perspective. This may also be using a clone of the SSD1306 chip.

Super interested to know which forum you are mentioning above. Are they using our library or some other one ?

Excited to see you try our library out. We did plan on adding scrolling and other features but that requirement didn't materialize so it did not get done. However, we will try to do it by summer of this year.

Thanks.

or78rXxZ commented 3 years ago

On 2021-01-26 01:25 PM, Stealthy Labs wrote:

the device i am using is

https://www.hardkernel.com/shop/odroid-hc4-oled/ [1]

i'm guessing the display is mounted "upside down"

Yes the orientation of the SSD1306 OLED in that device is most likely upside down from a pin diagram perspective. This may also be using a clone of the SSD1306 chip.

Super interested to know which forum you are mentioning above. Are they using our library or some other one ?

Excited to see you try our library out. We did plan on adding scrolling and other features but that requirement didn't materialize so it did not get done. However, we will try to do it by summer of this year.

https://forum.odroid.com/viewtopic.php?p=319324#p319324

stealthylabs commented 3 years ago

@or78rXxZ that's great to see. Happy to help get everything working for you as needed. I did not think anyone would use our library really but this is positive feedback.

Btw, did you try the sample example test_i2c_128x32 ? you could recompile for your 128x64 size screen. The lowercase font issue should not exist really. You may want to try a new font. I use the Microsoft fonts which provide the Comic Sans look and the Courier New look. Let me know if you see any differences, preferably with a picture. Could be a calculation thing too with positioning of the (x,y) of the text when you do a ssd1306_framebuffer_draw_text_extra() call.

In the end, you are drawing to a pixel framebuffer in RAM and then dumping that straight to the OLED chip's RAM via I2C. So you can print the framebuffer and view it on a standard terminal to see positioning of the fonts.

or78rXxZ commented 3 years ago

On 2021-01-27 04:16 PM, Stealthy Labs wrote:

@or78rXxZ [1] that's great to see. Happy to help get everything working for you as needed. I did not think anyone would use our library really but this is positive feedback.

Btw, did you try the sample example test_i2c_128x32 ? you could recompile for your 128x64 size screen. The lowercase font issue should not exist really. You may want to try a new font. I use the Microsoft fonts which provide the Comic Sans look and the Courier New look. Let me know if you see any differences, preferably with a picture. Could be a calculation thing too with positioning of the (x,y) of the text when you do a ssd1306_framebuffer_draw_text_extra() call.

In the end, you are drawing to a pixel framebuffer in RAM and then dumping that straight to the OLED chip's RAM via I2C. So you can print the framebuffer and view it on a standard terminal to see positioning of the fonts.

i'll give this try thanks

stealthylabs commented 3 years ago

@or78rXxZ Just so you know, we took the framebuffer approach for making it easy to debug what is going into the RAM of the I2C device because that is hard to debug especially if you are doing a complex screen display. Another reason is we wanted to use the capability of a fast processor like that of the Raspberry Pi to hold multiple framebuffers while displaying them one at a time on a slower I2C device.

So for example, you may lose microseconds doing I2C display but in that time the Pi/BBB/Odroid could draw up another framebuffer in memory and be ready to push it via the I2C bus to the OLED. so you could in essence, do what GPUs do which is have 2 or more framebuffers and pre-draw screens and then just send them to the display slowly. This allows for more efficiency and lower power usage overall, and a better smoother visual experience.

All the core library functions are Re-entrant by design so you can do this in a multi-thread application too.

Hope this helps.