STM32 TouchGFX Chess — Embedded C++ Firmware & Architecture
Developed by Anders Lillelund Clausen and Mathias Gorm Petersen for the STM32H7B3I-DK microcontroller using TouchGFX and FreeRTOS. Features a decoupled OOP board architecture, dynamic 34×34 square rendering, quintEaseIn snackbar animations, a recursive Minimax AI with Alpha-Beta pruning, and RapidJSON save states written to a microSD card over a 4-bit SDMMC bus. Later compiled to WebAssembly via an AI-assisted SDL2 shim so the original C++ firmware can be played directly in the browser.
- Decoupled C++ class hierarchy (Board, BoardState, BoardRenderer, SquareRenderer, PieceSelector, Snackbar, ChessAI, GameStateSerializer) evolved from an initial polymorphic AbstractPiece design.
- Singleplayer recursive Minimax search engine with Alpha-Beta pruning reducing best-case complexity from O(b^d) to O(√(b^d)) on the Cortex-M7.
- RapidJSON game-state serialization persisted to a physical microSD card via FatFs and SDMMC1 (4-bit wide bus @ 100 MHz), diagnosed with ST-Link JTAG debugging.