ThingPulse / esp8266-oled-ssd1306

Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
https://thingpulse.com
Other
1.98k stars 636 forks source link

Upgrade to library version 4.2.0 locks SSH1106 display - all good with version 4.1.0 #345

Closed ezplanet closed 7 months ago

ezplanet commented 3 years ago

Describe the bug Run a SSD1306SimpleDemo on a Wemos D1 with SSH1103 display connected to pin D2 (SDA) and D3 (SCL)

To Reproduce Steps to reproduce the behavior: Change the following:

// #include "SSD1306Wire.h"        // legacy: #include "SSD1306.h"
#include "SH1106Wire.h"   // legacy: #include "SH1106.h"

Add the following:

// SSD1306Wire display(0x3c, SDA, SCL);   // ADDRESS, SDA, SCL  -  SDA and SCL usually populate automatically based on your board's pins_arduino.h
SH1106Wire display(0x3c, D2, D3);

Expected behavior With library version 4.1.0 everything works fine After upgrading to version 4.2.0 the screen remains blank and the sketch program freezes A downgrade back to 4.1.0 restores functionality. Tried also starting from scratch with the demo provided with Library version 4.2.0

Screenshots If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

Additional context Add any other context about the problem here.

marcelstoer commented 3 years ago

Sorry, don't have the hardware to test. Assuming the issue is with src/SH1106Wire.h which of the 4.1->4.2 changes might cause this: https://github.com/ThingPulse/esp8266-oled-ssd1306/compare/4.1.0...4.2.0#diff-db4440a6b407fac3f22ed405f2f631933bb34cfc22472845d296cb2c88b9ceac ???

nobody1365 commented 2 years ago

Upgrading to 4.3 creates a directory in the libraries folder with some changes in lower and upper case name. This results in "the old directory is still there" Compiling that creates a non working display. to resolve: go to the libraries folder and manually delete the old directory.

bdryanovski commented 1 year ago

I'm not sure why - but it looks like this lines below are the root of my issues.

// SH1106Wire.h
#if !defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_ARCH8266)
      _wire->begin();
#else
      // On ESP32 arduino, -1 means 'don't change pins', someone else has called begin for us.
      if(this->_sda != -1)
        _wire->begin(this->_sda, this->_scl);
#endif 

It seems at least for me that I'm into the first section of the if block so in my case, I don't call _wire->begin(...) so my screen never start.

I'm testing it on d-duino-b v3 with set board name as nodemcu v0.9 so my headers may not be super fine ...

AlexeyMal commented 12 months ago

Dear Bozhidar Dryanovski, thanks for your investigation! I confirm the issue and the cause stated in the previous post. To fix the problem I commented out the

if ... block with _wire->begin();

to get the command _wire->begin(this->_sda, this->_scl); executed on my ESP8266 configured as SDA_PIN = D1 and SDC_PIN = D3. With this hotfix my SH1106 display is working again. Without this fix the display never gets initialized and remains black.

Dear Marcel Stör, please fix this issue in the next release! Thank you!

sprior commented 7 months ago

I just got bit by this same issue. Here is my fairly minimal testcase:

platformio.ini:

[env:nodemcuv2]
   platform = espressif8266
   board = nodemcuv2
   framework = arduino
   monitor_speed = 115200
   lib_deps = 
    Wire
    thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@4.1.0

main.cpp:

#include <Arduino.h>

#include "SH1106.h"

#define I2C_ADDR 0x3c
#define OLED_SDA D3
#define OLED_SCL D5

SH1106 display(I2C_ADDR, OLED_SDA, OLED_SCL);

void setup() {
  Serial.begin(115200);
  while(!Serial) {} // Wait
  Serial.println();

  Serial.println("SDA pin: " + String(OLED_SDA));
  Serial.println("SCL pin: " + String(OLED_SCL));
  display.init();
  display.flipScreenVertically();

  display.drawString(0, 0, "Hello1 World!");
  display.display();
}

void loop() {
}

It works with library version 4.1.0 but fails if I move to 4.2.0 or later. I'd love to see this fixed, thanks.

marcelstoer commented 7 months ago

@bdryanovski @sprior @AlexeyMal if the process ends up in the wrong if/else branch it likely means that your board definition does not include the necessary ARDUINO_ARCH*** defines. Or...wait, shouldn't it be ARDUINO_ARCH_ESP8266 rather than ARDUINO_ARCH8266? I guess that one slipped through when @benoitm974 added support for 2nd HW I2C in #292.

benoitm974 commented 7 months ago

Indeed good catch... Strange we didn't have this issue earlier... 8266 ? it should say ARDUINO_ARCH_ESP8266

marcelstoer commented 7 months ago

Strange we didn't have this issue earlier

Well, this issues is 2.5y old. I lack the hardware to test and it didn't click until I revisited the code sample that @bdryanovski posted above.

benoitm974 commented 7 months ago

@marcelstoer sorry my remark was not a complaints at all, I just surprise there is not so much 8266 users.

marcelstoer commented 7 months ago

@benoitm974 All good 😄 I didn't take it as a complaint. These days the SH1106 + ESP8266 combination is maybe becoming rare.

sprior commented 7 months ago

Thanks, what's the process to get this released and known to the PlatformIO library registry?

marcelstoer commented 7 months ago

@sprior It's a fairly simple process that doesn't take much time but I didn't get around to it until now.

sprior commented 7 months ago

@marcelstoer ok thanks, I look forward to seeing it when you get to it.

sprior commented 6 months ago

Thanks @marcelstoer , I confirmed that 4.4.1 fixes the issue.