Skip to content
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

display.begin() always true #251

Open
NuclearPhoenixx opened this issue Nov 8, 2022 · 3 comments
Open

display.begin() always true #251

NuclearPhoenixx opened this issue Nov 8, 2022 · 3 comments

Comments

@NuclearPhoenixx
Copy link

Hi there! I have an issue where the display.begin() function will always return true regardless if there is an actual display plugged in or not. It works fine if there is a display, of course, but if there is none it doesn't register that and thinks there still is one.

  • Arduino board: Raspberry Pi Pico with arduino-pico core

  • Arduino IDE version (found in Arduino -> About Arduino menu): 2.0.1

  • List the steps to reproduce the problem below (if possible attach a sketch or
    copy the sketch code in too):

    • Load the ssd1306_128x64_i2c example.
    • Upload.
    • Serial.println(F("SSD1306 allocation failed")); will never show because display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS) will never be false.
    • That's literally it for me. Nothing more, that easy.

Maybe it's got something to do with the Raspberry Pi Pico? I don't think so tbh, because everything else works fine, so there must be an issue here.

@nyckidryan
Copy link

I can confirm this is the case on ESP32-WROOM-32 38 pin dev module as well, in Arduino IDE 1.8.19 and 2.0.1.

@PitHerm
Copy link

PitHerm commented Oct 10, 2023

Yes, i display.begin returns always TRUE
on Pi Pico , ESP8266 , ESP32

@PitHerm
Copy link

PitHerm commented Oct 10, 2023

Well, i digged around within the source code of the lib and found NO return of FALSE if the display is not avaiable !

I thought about a workaround and here is the tested and working result:
Wire.begin();
Wire.beginTransmission (SCREEN_ADDRESS);
if (Wire.endTransmission () > 0){
Serial.println("SSD1306 allocation failed");
for(;;); // Don't proceed, loop forever
}
Wire.end();
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 FAIL: Buffer allocation error, not enough memory"));
for(;;); // Don't proceed, loop forever
}

instead of:
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}

Additional Info:

if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}

works but NOT as expected , it only returns FALSE if not enough memory for display buffer is avaiable.
so it would be better to change the phrase " Serial.println(F("SSD1306 allocation failed")); " to
" Serial.println(F("SSD1306 FAIL: Buffer allocation error, not enough memory")); "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants