-
Notifications
You must be signed in to change notification settings - Fork 1k
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
SH1107 128x128 OLED text jumbled around #2433
Comments
I need to add: the option to define SDA and SCL pins is not an issue. Just connect the OLED where Adafruit wants it. But I want to be able to use the "screen saver" which Adafruit does not seem to have. |
The reference position for the string is the lower left corner of the glyphs (baseline) as you can see in the example image here: https://github.com/olikraus/u8g2/wiki/u8g2reference#drawstr This can be change with the font-position functions: https://github.com/olikraus/u8g2/wiki/u8g2reference#setfontpostop Wrap around effects can be avoided by putting u8g2 into 16 bit mode (see FAQ https://github.com/olikraus/u8g2/blob/master/doc/faq.txt). 16 Bit mode is automatically activated with ESP32. |
Thank you for your reply.
I have read the documentation. And according to it and your comments the following lines of code should show the following as it actually does in the first working example:
OLED display 128x64:
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE, 22, 21);
u8g2.setFont(u8g2_font_ncenB14_tr);
u8g2.drawStr(0,15,"Hello World!");
displays as expected:
Hello World!
Not working example:
OLED dislay 128x128:
U8G2_SH1107_128X128_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE, 22, 21);
u8g2.setFont(u8g2_font_ncenB14_tr);
u8g2.drawStr(0,15,"Hello World!");
displays:
lo World! Hel
I hope this explains the problem I am encountering a little better.
I provided screen shots in attached files.
Please advise.
Thank you.
Christoph
…________________________________
From: olikraus ***@***.***>
Sent: Tuesday, April 23, 2024 11:04 PM
To: olikraus/u8g2 ***@***.***>
Cc: chauens ***@***.***>; Author ***@***.***>
Subject: Re: [olikraus/u8g2] SH1107 128x128 OLED text jumbled around (Issue #2433)
The reference position for the string is the lower left corner of the glyphs (baseline) as you can see in the example image here: https://github.com/olikraus/u8g2/wiki/u8g2reference#drawstr
This can be change with the font-position functions: https://github.com/olikraus/u8g2/wiki/u8g2reference#setfontpostop
Wrap around effects can be avoided by putting u8g2 into 16 bit mode (see FAQ https://github.com/olikraus/u8g2/blob/master/doc/faq.txt). 16 Bit mode is automatically activated with ESP32.
—
Reply to this email directly, view it on GitHub<#2433 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A4F33R5VCJCJ4XMH3SYXFEDY644MPAVCNFSM6AAAAABGTGED4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZUGAZTINJQHE>.
You are receiving this because you authored the thread.
|
Using the Adafruit_SH110X.h and Adafruit_GFX.h libraries provides the solution to the problem as well as a "screen saver" as I just found out. So I wil go this route. |
Hi, @chauens, I got the same problem. the default display config for sh1107_128x128 has a big x offset (check L519-520): Lines 501 to 523 in 3e86287
you can try to use pimoroni's config or seeed's config : Lines 600 to 622 in 3e86287
I don't use Arduino, but I think you can try to use |
Hi, thank you for the tip, that appears to be very helpful. I will try that. |
Discussed in #2430
Originally posted by chauens April 18, 2024
Hi,
I am using the Adafruit 5297 128x128 OLED with the U8g2 library and have a problem with the way the text is displayed. The OLED is mounted into an enclosure with its top pointing up as described on Adafruits website. Using a simple code to display "Hello World!" starting at line position 0 shows: "World! Hello" .
If I use rotation 90 degrees the text shows correct, correct sequence, but of course turned sideways... 90 degrees.
I can't turn the OLED in the enclosure and I want to use U8G2 since it offers the power save mode and more importantly has the option to define the boards I2C SDA/SCL pins since my board (ESP32 Feather) is not using the defaults.
Any ideas how to get around this? Any help appreciated.
This is the test code:
#include <U8g2lib.h>
#include <Wire.h>
#define I2C_Adr 0x3d //OLED I2C address
#define SDA 23 //sda pin# on ESP32 board is 23 (some boards use 21)
#define SCL 22 //scl pin# on ESP32 board is 22
#define rotation U8G2_R0 //flawed, but I need this rotation
U8G2_SH1107_128X128_F_HW_I2C u8g2(rotation, U8X8_PIN_NONE, SCL, SDA);
void setup(void) {
int i2cAdr = (I2C_Adr * 2); //per u8g2 reference manual address must be multiplied by 2
u8g2.setI2CAddress(i2cAdr);
u8g2.begin();
u8g2.setFont(u8g2_font_helvR10_tf);
}
void loop(void) {
u8g2.clearDisplay();
u8g2.drawStr(0,15,"Hello World!");
u8g2.sendBuffer();
delay(500);
u8g2.drawStr(0,30,"1234567890");
u8g2.sendBuffer();
delay(1000);
}
B.t.w. "1234567890" displays like "567890 1234"
I uploaded a shortened version of Adafruits "Hello World" test sketch onto the ESP32 board and found that the text is displayed correctly. So it seems to me that the problem is in U8G2 for the SH1107 chip.
I would like to stick with u8g2 for the power save mode (screen saver).
The text was updated successfully, but these errors were encountered: