Skip to content

ssd1306.py: Change the init values for a 64x32 display #5837

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

Closed
wants to merge 1 commit into from

Conversation

robert-hh
Copy link
Contributor

The parameter for the SET_COM_PIN_CFG setting was wrong for that size,
at least for the display I have here for testing. I am not sure whether
other displays of that size behave different.

@dpgeorge
Copy link
Member

dpgeorge commented Apr 2, 2020

I used this driver only on a 128x32 display, so couldn't say either way about this issue. Reading the docs for the SSD1306 it says there are 6 combinations for display configurations (for a size of 128x64 pixels) for this option, so it may be that it's hardware dependent what value to use here.

How do other drivers (Arduino etc) configure this value?

@robert-hh
Copy link
Contributor Author

Actually after studying the data sheet w/o getting better clues I tried another driver, which worked, and compared the difference. The setting for SET_COM_PIN_CFG was the only one, and implement that made the driver work. But, as I noted, I tested just that device. Other 64x32 units may behave differently. The 128x32 you used should not be affected by the change.

@dpgeorge
Copy link
Member

dpgeorge commented Apr 4, 2020

I did a brief search for SSD1306 tutorials and all seem to rely on Adafruit's driver https://github.com/adafruit/Adafruit_SSD1306/blob/master/Adafruit_SSD1306.cpp. For this setting (grep for SSD1306_SETCOMPINS) 0x02 is the default, and 0x12 is used only for w=128, h=64. Although it doesn't seem to officially support 64x32 displays.

So, maybe it's best here to change the code to 0x02 if (self.height == 32 and self.width != 64) else 0x12. At least that will only have a change for 64x32 displays.

@robert-hh
Copy link
Contributor Author

Whatever works. As said, I have not much confidence that the suggested change will work for all devices.

@mcauser
Copy link
Contributor

mcauser commented Apr 4, 2020

There's only two I know if that use 0x02. Use "sequential" (bit 4 = 0) when there are two sub panels - a panel at the top and one at the bottom. Use "alternating" (bit 4 = 1) when it's a large panel and each com pin maps to even rows, then odd rows, like interlacing.

0xDA, 0x02:

  • 96x16
  • 128x32

0xDA, 0x12:

  • 64x32
  • 64x48
  • 48x64
  • 72x40
  • 128x64

@dpgeorge
Copy link
Member

dpgeorge commented Apr 5, 2020

Thanks @mcauser for the data. I have a 128x64 SPI based SSD1306 display and I tested it and it does need 0x12.

It looks like a value of 0x02 is used only when the aspect ratio is greater than 2. So that means the formula could be:

0x02 if self.width > 2 * self.height else 0x12

That would lead to smaller and faster bytecode than checking a set of specific w/h values.

Making it more specific to use 0x02 for display with an aspect ratio
> 2 and 0x12 for all othe sizes as recommended by @mcauser.
Tested with a 64x32 display which did not work before.
@robert-hh
Copy link
Contributor Author

Changed accordingly. Thanks for testing. Besides that one, I have only displays with other controllers at hand.

@dpgeorge
Copy link
Member

dpgeorge commented Apr 7, 2020

Thanks for updating, merged in 8680a74

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

Successfully merging this pull request may close these issues.

3 participants