Nº 11of 22Index

CacaOS

C++ firmware for an ESP32 with a touch screen: 8 LVGL mini-apps and an SDL2 simulator for developing without the board

Year
2026
Status
IN PROGRESS
Stack
C++ · PlatformIO · LVGL · ESP32 +2
cacaos
C

C++

No public screen — generated cover

01The project

Application firmware in C++ for an ESP32 with a 320×240 touch display, built as a physical gift: a launcher with eight pixel-art mini-apps (gallery, counter, tamagotchi, pomodoro, mood tracker and others). It is not an operating system — no kernel, no scheduler of its own; it is a cooperative loop on top of the Arduino framework, with LVGL drawing the interface. The engineering worth reading is outside the apps: a second build environment compiles the same UI code against SDL2 on the Mac, swapping in shims only for the hardware modules, and a WiFi state machine pauses and resumes the radio so it can scan networks during a connection attempt.

02What was built

  1. A native SDL2 simulator environment alongside the hardware build: the whole UI runs on the Mac without the board, with shims only in the display, touch, SD, WiFi and sensor modules

  2. A WiFi state machine that pauses and resumes the radio, because starting a scan during a connection attempt fails silently in ESP-IDF; changing credentials rolls back automatically when the new network does not connect

  3. Touch driver rewritten with bit-banging to hand the real SPI bus back to the SD card, which was contending for the same pins

  4. CI on GitHub Actions that actually compiles the firmware on every push and reports flash and RAM usage

  5. Custom asset pipeline: PNG sprite sheets converted to LVGL's binary format to cut RAM and flash usage on the device

03Decisions

Decision 01

Question: How do you test the UI before the board arrives?

Answer: A second build environment compiles the same app and UI code against SDL2 on the desktop; only display, touch, SD, WiFi and sensors are replaced by shims. Everything else runs identically to what runs on the board.

Decision 02

Question: Why bit-bang the touch instead of using the stock SPI driver?

Answer: The touch controller and the SD card contend for the same bus. Rewriting the touch as manual bit-banging of the pins gave the real SPI back to the SD card, which stopped working otherwise.

04Stack

  • C++
  • PlatformIO
  • LVGL
  • ESP32
  • SDL2
  • GitHub Actions
Next project →Nº 12

Compiler in Java: lexer, recursive-descent parser, tree-walking interpreter and a NASM x86 32-bit assembly generator