Skip to content

Better Brightness / Contrast control suggestion #134

@lorol

Description

@lorol

Using any 0-255 value of setContrast(char contrast), almost doesn't affect how bright the OLED looks. Here is a suggestion, after searching and playing with 2 more parameters, so the really low brightness & contrast would be set:
display.setContrast(10, 5, 0);
and a normal brightness & contrast:
display.setContrast(100);

Changes:

OLEDDisplay.h
...
void setContrast(char contrast, char precharge = 241, char comdetect = 64);

OLEDDisplay.cpp
...
void OLEDDisplay::setContrast(char contrast, char precharge, char comdetect) {
sendCommand(SETPRECHARGE); //0xD9
sendCommand(precharge); //0xF1 default, to lower the contrast, put 1-1F
sendCommand(SETCONTRAST);
sendCommand(contrast); // 0-255
sendCommand(SETVCOMDETECT); //0xDB, (additionally needed to lower the contrast)
sendCommand(comdetect); //0x40 default, to lower the contrast, put 0
sendCommand(DISPLAYALLON_RESUME);
sendCommand(NORMALDISPLAY);
sendCommand(DISPLAYON);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions