OK - I just tossed off that bit of code as a suggestion - I haven't actually tried it.
Looking at it now, I should have made the first parameter a
pointer to the display object you declare in your sketch. And you're really not setting brightness, you're setting contrast, (which is going to amount to roughly the same thing on an OLED). So, let's change the same of the function accordingly:
- Code: Select all
void setContrast(Adafruit_SSD1306 *display, uint8_t contrast)
{
display->ssd1306_command(SSD1306_SETCONTRAST);
display->ssd1306_command(contrast);
}
So, in your sketch, you've got something like this:
- Code: Select all
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oledDisplay(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
This declares an object of type Adafruit_SSD1306 with the name oledDisplay.
To call the contrast function, you pass it a reference (i.e., pointer) to oledDisplay, and a value for the desired contrast setting. For example, to set the contrast level to 50%, you would do this:
- Code: Select all
setContrast(&oledDisplay, 128); //contrast is a number between 0 and 255. Use a lower number for lower contrast
I STILL haven't tested it

. I'm just going on what I see in the library code and tin the datasheet.