Skip to content

i2c SSD1306 bug with sending device address #354

@agento2

Description

@agento2

file with the issue : lines 109, 130

In both the send command and send buffer methods the call to the i2c library looks like this

i2c_write_blocking(i2c_default, (SSD1306_I2C_ADDR & SSD1306_WRITE_MODE), buf, 2, false);

this issue is with the address parameter, (SSD1306_I2C_ADDR & SSD1306_WRITE_MODE), it should be just SSD1306_I2C_ADDR because the anding of SSD1306_WRITE_MODE which is 0xFE only works for some people using this example if their device address matches the 0x3C that is defaulted here. This is because that & FE is a no-op for addresses that are even, where as in my case the device address is 0x3D results in changing the address sent to 0x3C.
Another illustration for why that shouldn't be there is that if you were to change it to & SSD1306_READ_MODE it would be a no-op for all addresses and the example would still work.

My guess is this is a vestige from using a different i2c library that did not have both read and write methods but just send, even then the & doesn't seem like the right operator.

I can file a PR for this simple change or someone else can. I just hope it saves someone else the time i spent figuring out why my sparkfun made ssd1306 based Oled display with address 0x3D wouldn't do anything at all when running this example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions