rust-embedded-community / ssd1306

SSD1306 OLED driver
Apache License 2.0
282 stars 69 forks source link

[N00b help request] Init fails with Raspberry Pi Pico and Adafruit OLED #167

Closed afternoon closed 1 year ago

afternoon commented 1 year ago

Description of the problem/feature request/other

My issue is very likely not with this crate or the code, but I’m a total n00b and I’m a bit stuck, so I’m reaching out to see if anyone here has any suggestions.

I have a Pi Pico and an Adafruit display. The display is wired to pins 26 and 27 (I2C1 on the Pico). It’s working fine under the Arduino-pico core with the Adafruit_SSD1306 library.

When I run this example code from the rp-hal crate (updated to point to the correct pins), the display doesn’t init. I’m getting an error result back from the init call, but I’m not sure which of the commands is failing. I’m attempting to debug with gdb, openocd and picoprobe but I couldnt figure out how to set a breakpoint in the library init function (I’m a gdb n00b too!).

I’ve also tried on pins 16 and 17 (the defaults for the Pico’s I2C0 bus), with the same result.

One thing about this display is that it has no reset pin connection.

Test case (if applicable)

See https://github.com/rp-rs/rp-hal/blob/8d52f37dd1056ad3dcef78c4a74b663771a8b952/boards/rp-pico/examples/pico_i2c_oled_display_ssd1306.rs

afternoon commented 1 year ago

I managed to unearth that I'm getting a display_interface::DisplayError::BusWriteError when the DisplayOn command is sent to the screen with arg false (so 0xAF byte is sent). This is the first command sent in init_with_addr_mode - lib.rs:200).

rfuest commented 1 year ago

The display might use a different I2C address. Try to change new into new_alternate_address in this line: https://github.com/rp-rs/rp-hal/blob/8d52f37dd1056ad3dcef78c4a74b663771a8b952/boards/rp-pico/examples/pico_i2c_oled_display_ssd1306.rs#L140

afternoon commented 1 year ago

The display might use a different I2C address. Try to change new into new_alternate_address in this line: https://github.com/rp-rs/rp-hal/blob/8d52f37dd1056ad3dcef78c4a74b663771a8b952/boards/rp-pico/examples/pico_i2c_oled_display_ssd1306.rs#L140

Yep, that was the issue! Thank you for your help.