greiman / SSD1306Ascii

Text only Arduino Library for SSD1306 OLED displays
MIT License
490 stars 120 forks source link

ShutDown OLED 1306 #120

Open error105 opened 1 month ago

error105 commented 1 month ago

Hi, there is any option to turn off OLED to save power?

greiman commented 1 month ago

There is no function to turn off the OLED. ssd1306WriteCmd() is public so you could try sendingSSD1306_DISPLAYOFF and SSD1306_DISPLAYON.

  oled.ssd1306WriteCmd(SSD1306_DISPLAYOFF);
  ...
  oled.ssd1306WriteCmd(SSD1306_DISPLAYON));

You can try it but I don't know if will save power or work properly.

deladriere commented 1 month ago

I have developed a bit of code to avoid the OLED fading off when displaying the same text Here, I am just diming it, but you can also turn it off with the level of contrast

void setDisplayDIM()
{
        display.ssd1306WriteCmd(SSD1306_SETPRECHARGE);
        display.ssd1306WriteCmd(0);
        display.ssd1306WriteCmd(SSD1306_SETVCOMDETECT);
        display.ssd1306WriteCmd(0);
        display.ssd1306WriteCmd(SSD1306_SETCONTRAST);
        display.ssd1306WriteCmd(10);
}
void setDisplayNORMAL()
{
        display.ssd1306WriteCmd(SSD1306_SETPRECHARGE);
        display.ssd1306WriteCmd(0xF1);
        display.ssd1306WriteCmd(SSD1306_SETVCOMDETECT);
        display.ssd1306WriteCmd(0x20);
        display.ssd1306WriteCmd(SSD1306_SETCONTRAST);
        display.ssd1306WriteCmd(0xAF);
      }