Take the course at /learn/path/oled-graphics. It is an intermediate course: it assumes the Uno course, and Displays: characters, digits and dots helps.
The bench
An Uno with a 0.96 inch 128x64 SSD1306 on its I2C pins, plus a knob on A0 and a button on pin 2 on a half breadboard. For the last two lessons a TCA9548A I2C switch joins the bus, with the SSD1306 on its channel 0 and a 1.3 inch SH1106 on channel 1, since both answer at 0x3C.
The lessons
The SSD1306 framebuffer. Bytes written straight into Adafruit_SSD1306's frame: eight pages of 128, each byte a column of eight pixels with bit 0 on top. The OLED's lit-pixel count checks every stage, and the free RAM shows the frame taking half the Uno.
Pixels and lines. Lines, rectangles and circles, each one's pixels counted, then a radar whose sweep follows the knob. Rubbing out the old line in black, rather than clearing, drops a frame from 348 ms to about 30.
Fonts. The 6x8 built-in cell at three sizes, a score centered with
getTextBounds(), and a GFXfont whose cursor is the baseline.
Bitmaps and sprites. A 16x16 rocket in 32 bytes of flash, flown over a starfield with the knob, a laser on the button, and a frame that redraws only what moved.
U8g2 pages. The picture loop draws Saturn eight times a frame from a one-page buffer, and switching to two pages halves the passes.
SH1106 and two screens. Two OLEDs at one address behind a TCA9548A. A second Adafruit frame does not fit in the RAM left, so the SH1106 is drawn a page at a time through a 128-byte strip, from its column 2.
Boss: a pocket dashboard. A space game on the SSD1306, with a fuel gauge, score, high score and shields on the SH1106: one frame where things move, a strip where they do not, dirty blocks on one screen and dirty pages on the other. Shoot, dodge, crash and add shields.
The sketches
| Sketch | What it does |
|---|---|
olxframe |
Writes page bytes into the frame and counts lit pixels |
olxlines |
Counts each shape's pixels, then a knob-driven radar |
olxfonts |
Text sizes, a centered score and a TomThumb label |
olxsprite |
A PROGMEM rocket over a starfield, with a laser |
olxpages |
U8g2 page mode drawing Saturn and a moon |
olxtwo |
SSD1306 with a frame and SH1106 by pages, through a TCA9548A |
olxboss |
The two-screen pocket space game |
What the simulation leaves out
The I2C bus here runs at about 30 kHz however fast a sketch asks for, so a whole 1 KB frame takes about a third of a second, where a real Uno at 400 kHz sends it in about 25 ms. Sending only what changed matters even more here, which is why every animated sketch in the course does it.
Mokxi's U8g2 keeps its page buffer as a window onto the display driver's own
1 KB frame, so the RAM a _1_ or _2_ constructor saves on a real Uno (it
uses 128 or 256 bytes there) is not modeled: free RAM drops by a whole
kilobyte either way. The page passes, the timing and the picture are as on a
real board. The fonts in U8g2 and in Adafruit_GFX's Fonts folder draw
Mokxi's own letters at each font's size, not the original typefaces.