Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

ssd1306 wrong resolution on 128x32 OLED #166

Closed
mikegleasonjr opened this issue Oct 23, 2017 · 10 comments
Closed

ssd1306 wrong resolution on 128x32 OLED #166

mikegleasonjr opened this issue Oct 23, 2017 · 10 comments

Comments

@mikegleasonjr
Copy link

mikegleasonjr commented Oct 23, 2017

Using this product on Raspberry Pi Zero W using latest stretch:

Adafruit PiOLED - 128x32 Monochrome OLED Add-on for Raspberry Pi
https://www.adafruit.com/product/3527

The image seems wrong using the ssd1306 cmd provided in the package:

./ssd1306 -h 32

Results in:

img_20171023_020257

It only writes to the second half of the screen, with tiny text cut in half.

# even though the display has a height of 32, I tried 64 to see
./ssd1306 -h 64

Results in:

img_20171023_020332

The display is working fine with their official python library: https://github.com/adafruit/Adafruit_Python_SSD1306/blob/master/Adafruit_SSD1306/SSD1306.py

The Adafruit 128x64 OLED Bonnet for Raspberry Pi is working fine with periph (https://www.adafruit.com/product/3531):

img_20171023_021111

@maruel
Copy link
Contributor

maruel commented Oct 23, 2017

Interesting. Can you try changing this line:
https://github.com/google/periph/blob/master/devices/ssd1306/ssd1306.go#L207
to 0xDA, 0x02, ?

@mikegleasonjr
Copy link
Author

@maruel nope, same problem.

I don't know if it is relevant/interesting or not but... if I try with -h 32 on the 128x64 display, it displays on the bottom half of the screen (like 1st screenshot, but on the 128x64 device)

@mikegleasonjr
Copy link
Author

@maruel I picked up the device again and found the problem this time.

I looked at how the device was initialized with the adafruit python library (https://github.com/adafruit/Adafruit_Python_SSD1306/blob/master/Adafruit_SSD1306/SSD1306.py#L309). I found a mismatch here https://github.com/google/periph/blob/master/devices/ssd1306/ssd1306.go#L207.

So I replaced...

0xDA, 0x12, // Set COM pins hardware configuration; see page 40

with...

0xDA, 0x02, // Set COM pins hardware configuration; see page 40

And now the display is working properly:

img_20171116_212949

There is no public interface to send commands directly to the display, what do you propose to make something flexible so I can make it work?

@mikegleasonjr
Copy link
Author

@maruel I feel silly, that was your proposed diagnosis the first time!

@mikegleasonjr
Copy link
Author

I found out how to do it:

if err = c.Tx(0x3C, []byte{
    0x00, // I²C transaction has stream of command bytes
    0xDA, // set comm pins
    0x02, // 2
}, nil); err != nil {
    return nil, err
}

I am going to close it now :)

@maruel
Copy link
Contributor

maruel commented Nov 20, 2017

No worries. :) Reopening because this is a bug.

So clearly the COM pins configuration needs to either have more conditions or be made configurable. I think we'll need the later as this really depends on the hardware configuration. :/ Expanding on the doc which isn't that clear;

Bits

  • 5 enables top and bottom panel swap
  • 4 enables alternative each side instead of using two subpannels

This is coupled with C0/C8:

  • C0 means bottom-top
  • C8 means top-bottom

It is used to rotate the display.

So we'll need an enum to clarify the above in a way that keeps the rotated functionality working (which I'd prefer if possible).

@maruel maruel reopened this Nov 20, 2017
@maruel
Copy link
Contributor

maruel commented Dec 9, 2017

FTR, I still want to fix this, I just need to figure out the best way to expose the bit.

@maruel
Copy link
Contributor

maruel commented Dec 12, 2017

I'm starting to think about v3, this should be fixed in time for this release, which will likely be in a few months.

@mikegleasonjr
Copy link
Author

@maruel thanks! in the meantime I have a workaround so that's great

@mikegleasonjr
Copy link
Author

Thank you very much!

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

No branches or pull requests

2 participants