SSD1306 brightness/contrast?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- bobgardner
- Posts: 49
- Joined: Fri Mar 08, 2013 8:35 pm
SSD1306 brightness/contrast?
I can draw stuff no prob. I tried to adjust contrast with command 0x81 then a command with contrast from 0 to 255, but no dim. Anybody know how to adjust the brightness/contrast? Thanks.
- adafruit_support_mike
- Posts: 67391
- Joined: Thu Feb 11, 2010 2:51 pm
Re: SSD1306 brightness/contrast?
No command in the library specifically controls the display brightness, but the sequence:
is the part that sets the display's brightness during the startup sequence. The 'contrast' value controls the amount of current that goes to the OLEDs, and according to the datasheet (http://www.adafruit.com/datasheets/SSD1306.pdf) accepts values from 0 to 255.
More current should equal more light from the OLEDs, but I have absolutely no idea what the relationship between current and brightness will be, or what tinkering with the display current will do to the device. I'll pass that question along to someone who knows the details better than I do.
Code: Select all
ssd1306_command(SSD1306_SETCONTRAST); // 0x81
ssd1306_command(0x8F);
More current should equal more light from the OLEDs, but I have absolutely no idea what the relationship between current and brightness will be, or what tinkering with the display current will do to the device. I'll pass that question along to someone who knows the details better than I do.
- adafruit_support_mike
- Posts: 67391
- Joined: Thu Feb 11, 2010 2:51 pm
Re: SSD1306 brightness/contrast?
Just got a pointer to this thread where someone tried the same thing: http://forums.adafruit.com/viewtopic.ph ... st#p172367
Apparently it doesn't make much difference in the light output.
Apparently it doesn't make much difference in the light output.
- rtek1000
- Posts: 2
- Joined: Mon Apr 03, 2017 12:15 am
Re: SSD1306 brightness/contrast?
There is a (great) hardware contrast control:
ISEG = Contrast / 256 x IREF x scale factor
in which
the contrast (0~255) is set by Set Contrast command 81h; and
the scale factor is 8 by default.
The magnitude of IREF is controlled by the value of resistor, which is connected between IREF pin and
VSS as shown in Figure 8-15. It is recommended to set IREF to 12.5 ± 2uA so as to achieve ISEG =
100uA at maximum contrast 255.
IREF Current Setting by Resistor Value
Voltage at IREF = VCC – 2.5V. For VCC = 7.5V, IREF = 12.5uA:
R = (Voltage at IREF - VSS) / IREF
= (7.5-2.5) / 12.5u
=400KΩ
My 0.96" OLED have a 914 resistor (910k Ohms) I believe this is it
Check the Datasheet at page 27 and 59:
https://www.olimex.com/Products/Modules ... SD1306.pdf
And for u8glib: https://code.google.com/archive/p/u8glib/downloads
u8g.setContrast(n);
in which
the contrast n = (0~255)
ISEG = Contrast / 256 x IREF x scale factor
in which
the contrast (0~255) is set by Set Contrast command 81h; and
the scale factor is 8 by default.
The magnitude of IREF is controlled by the value of resistor, which is connected between IREF pin and
VSS as shown in Figure 8-15. It is recommended to set IREF to 12.5 ± 2uA so as to achieve ISEG =
100uA at maximum contrast 255.
IREF Current Setting by Resistor Value
Voltage at IREF = VCC – 2.5V. For VCC = 7.5V, IREF = 12.5uA:
R = (Voltage at IREF - VSS) / IREF
= (7.5-2.5) / 12.5u
=400KΩ
My 0.96" OLED have a 914 resistor (910k Ohms) I believe this is it
Check the Datasheet at page 27 and 59:
https://www.olimex.com/Products/Modules ... SD1306.pdf
And for u8glib: https://code.google.com/archive/p/u8glib/downloads
u8g.setContrast(n);
in which
the contrast n = (0~255)
- Attachments
-
- IMG_20170403_011143411.jpg (795.07 KiB) Viewed 15941 times
- rtek1000
- Posts: 2
- Joined: Mon Apr 03, 2017 12:15 am
Re: SSD1306 brightness/contrast?
u8g.setContrast(n);
Can be run at any time, it does not have to be at startup
Can be run at any time, it does not have to be at startup
Please be positive and constructive with your questions and comments.