Skip to content
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

SSD1306_I2C poweron method #2837

Closed
wants to merge 1 commit into from

Conversation

belimawr
Copy link
Contributor

@belimawr belimawr commented Feb 5, 2017

I was using a OLED display with the SSD1306 diver and noticed that the SSD1306_I2C class does not implement the poweron method.

Looking at the init_display I found way to implement it that seems to make sense and worked very well for me.

@peterhinch
Copy link
Contributor

Out of curiosity what physical problem does this fix? The existing driver works fine here.

@belimawr
Copy link
Contributor Author

belimawr commented Feb 6, 2017

This is not a physical problem. Actually it is a feature. The I2C driver (SSD1306_I2C) does not implement the poweron method, so it is not possible to turn the display off the turn it on.

@kfricke
Copy link
Contributor

kfricke commented Feb 10, 2017

That is only partially correct. The poweroff() method does switch off the display, but the current driver does initialize the display using the init_display() with full contrast set and resetting all other settings.

So the addition of this PR lets me assume that it would allow a user to physically save power by turning it off and reactivate it on the previous contrast level.
Using the init_display() method would likely let the display flicker a little in the worst case, because the contrast would need to be reduced again after reactivating the display.

One segment of the display seems to consume ~25uA at lowest contrast compared to 100uA on full contrast.

To really prove the usefulness one needs to...

  1. ...verify that the method really saves reasonable amounts of power. Otherwise this only makes sense to me in a semi low power situation (as far as i do understand the datasheet, but i can not really grab the precise benefit or proove that it than only consumes ~10 uA).
  2. ...check that the display does awake in the exact previous state. Else driver would better be enhanced by persisting the set contrast level in a member variable.
  3. ...take into account that my displays of this type did never support reducing the contrast level at all.

@mcauser
Copy link
Contributor

mcauser commented Jun 6, 2017

It's not just reactivating the display with previous contrast level. The previous state is persisted in RAM.

You can write "Hello" to the display, invert it, power it off, power it on and Hello is re-displayed inverted.

display.text('Hello',0,0,1)
display.invert(True)
display.write_cmd(0xae) #aka display.poweroff()
display.write_cmd(0xaf) #proposed display.poweron()

Without this PR, calling power on (pass) makes you think you have powered on the display, but when there is nothing displayed, you call init_display() which reinitialises everything and you lose your previous state.

The datasheet specifies 0xAE for display off (sleep mode) and 0xAF for display on (normal mode) :shipit:

Copy link
Contributor

@kfricke kfricke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no breaking changes to existing code by this (atomic) PR. But instead it is implementing a missing feature.

@mcauser
Copy link
Contributor

mcauser commented Oct 5, 2017

https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf - Page 37

10.1.12 Set Display ON/OFF (AEh/AFh)
These single byte commands are used to turn the OLED panel display ON or OFF.

@dpgeorge this one is safe to merge.

@dpgeorge
Copy link
Member

dpgeorge commented Oct 6, 2017

Thanks for confirming @mcauser , now merged in 7df4083

And then in ca2427c I updated the SSD1306_SPI driver to have the same behaviour: do a soft power-on when this poweron() method is called.

@dpgeorge dpgeorge closed this Oct 6, 2017
xobs pushed a commit to xobs/micropython that referenced this pull request May 19, 2020
Add support for a debug console, such as ST-Link VCP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants