Member-only story
Build a Tiny, Fast OLED Framebuffer Driver in C (for CH32V003/006)
TL;DR: On resource-constrained MCUs like the CH32V003 (16 KB Flash, 2 KB SRAM), heavyweight graphics libraries are overkill. This post shows how to write a minimal, framebuffer-based OLED driver in C using bitwise operations — capable of rendering fonts and XBMP bitmaps at arbitrary positions on a 0.96" 128×64 OLED.
When working on the CH32V003 series, I often use a 0.96-inch 128×64 OLED for displaying data and basic UI. I initially grabbed oled_min.c from the CH32V003-GameConsole project, but it only drew a single bitmap and didn’t support arbitrary positioning—so I rebuilt it.
I also wanted drop-in compatibility with the popular DCfont struct that many dot-matrix fonts use. That way I can swap fonts easily across projects.
Why roll my own library? Because on the CH32V003 every byte counts: with 16 KB Flash and 2 KB SRAM, Arduino-style graphics stacks are too heavy. Writing a lean C driver was the most practical path — and a great excuse to brush up on bit-twiddling.
Font & Bitmap Data Structures
Here’s the DCfont structure:
struct DCfont {
uint8_t *data;
uint8_t width;
uint8_t height;
uint8_t min, max;
};