rust-embedded-community / sh1106

SH1106 driver for use with embedded_hal and (optionally) embedded_graphics
Apache License 2.0
34 stars 36 forks source link

Use correct addressing commands and fix display size/alignment #6

Closed mvirkkunen closed 5 years ago

mvirkkunen commented 5 years ago

I changed the addressing commands to the correct ones for this controller and implemented incrementing the page address as this controller doesn't do it automatically.

Also I added the 132x64 display size which is the maximum size this controller supports, and added a "panel column offset" to the smaller sizes because it seems that on modules in the wild it's common to have a panel that uses the middle 128 columns of the 132 available, as opposed to the leftmost 128. I suppose it's possible to have a module where the leftmost or rightmost columns are used instead, but the common case seems to be to use the middle ones.

With this commit at least the display module I have seems to work perfectly with no garbled pixels and with correct column alignment.

Closes #1 and #3.

jamwaffles commented 5 years ago

Cheers for this! I'll test on the display I have when I get some spare time and check if the column offsets etc work correctly.

implemented incrementing the page address as this controller doesn't do it automatically.

IIRC the datasheet is pretty ambiguous about this. The display I have shows stuff just fine without manually incrementing the page addr. Any idea why that might be?

mvirkkunen commented 5 years ago

On the display I got I only get stuff on the first "page" if I don't change the page address manually. In the datasheet it says this:

Because the column address is independent of the page address, when moving, for example, from page0 column 83H to page 1 column 00H, it is necessary to re-specify both the page address and the column address.

Is it possible that your display actually has a different controller...? Looks like there's many ones with a similar set of commands, and for instance on the SSD1306 the automatic wrapping might just make everything work without ever setting the address correctly.

N.b. I'm not 100% sure what the controller in my display is either, it's from some eBay order a long time ago and there's no markings - but it seems to behave exactly like the SH1106 datasheet says.

jamwaffles commented 5 years ago

Released in 0.2.0.