Adafruit_SSD1306_PLUS (I2c only)
madias Sun Oct 07, 2018 9:43 pm
as I’m working on my MP3 player project, I needed to do some adapts to the Adafruit_SSD1306 library (included in Rogers core, adapted by myself some years ago).
Warning: This library was only tested with a 128×64 I2C Oled without RST pin. For SPI you need to adapt my new I2C functions!
Here some changes:
full speed HW I2C again (was modified by someone, but forgotten to insert a Wire.setClock(400000) after Wire.begin
encapsulated the whole screen buffer from private to public. This “costs” only 1KB (on a 128×64 display) But now you can copy the buffer into a temporary array, do something on screen and after that putting the state before on screen again. So with other words: You don’t need to take care what was on screen before. Saves many lines of code
delete the pre built adafruit logos in the buffer: Saves flash memory (about 1KB)
Not only full screen update, but pages:
Ok, the screen is only 1024 bytes, but with I2C this can be a lot of time, so I read the datasheet of SSD1306 and recognized that the screen can also be updated by pages (8 lines), so you have 8 pages on a 128×64 display. Here is a practical example:
void oled_invert_entry(byte page) {
for (int z = 0; z < 128; z++) {
display.buffer[z + page* 128] = ~display.buffer[z + page * 128]; // invert page
}
display.display(page, page );
}
