128x32 i2c OLED display - can it be dimmed?

Hi all! I'm using a 128x32 OLED display on my in car dash project and am running it with the Adafruit 1306 library. It all works well but it is a little bright for night driving so I was wondering whether it is possible to dim the display programatically to avoid dazzling the viewer in the dark?

Thanks!

If you use the Adafruit_SSD1306 library you can:

  display.ssd1306_command(SSD1306_SETCONTRAST);
  display.ssd1306_command(contrast);

The default for 128x32 is 0x8F.

You might find that this function is good enough for you.

  display.dim(true);

Hi David, thanks very much for that - the .dim function seems to work pretty well. How much contrast is this actually changing? I tried the other function but it didn't seem to do anything - I assumed the contrast figure was 0-255 and tried dropping it to 100 but no change...

In any case I think the .dim function might work ok but just curious as the contrast function may be allow some adjustability...

Just read the library source code. Search for dim(

For an OLED display, there will be no difference between "contrast" and "brightness" - there is no "black level" to set as there is with LCDs and CRT displays.

As long as you set individual pixels as a proportion of your nominal white level - clearly a required function of the library - contrast and colour will be fixed. :grinning:

david_prentice:
Just read the library source code. Search for dim(

Ah ha! Well spotted! I see this switches from 0 to contrast, and contrast is set to 0X8F which translates to 143 in decimal. Does this mean the function drops the brightness from 255 to 143? So perhaps I could adjust this value somehow to give brightness control?

No, it uses 0x8F as regular brightness.
And 0x00 as dimmed brightness

If you want something in between, you could try other values e.g. 0x47
I would not advise greater than 0x8F. It is too bright anyway.

David.

Oh right! So 0x00 is the min then...! I was going to see if it could go dimmer as an experiment - it's probably ok at that level. If it only works at 143 then I guess it would give you sunburn at 255!!

You can use displayOn(false) if you want to turn the OLED off completely.

Otherwise just stick with regular and dim.

David.