![]() |
CHGame 0.3.0
Libraries for the CHGame handheld
|
The reference for every library the CHGame board package installs. CHGame is a small open colour handheld: a WCH CH32X035 RISC-V microcontroller (48 MHz, 62 KB flash, 20 KB SRAM), a 128x128 ST7735S colour LCD, a microSD slot, eight buttons, a piezo speaker, a status LED and USB-C. It is programmed from the Arduino IDE or arduino-cli, like an Arduboy.
| Library | Header | What it is for |
|---|---|---|
| CHGame | CHGame.h | Start here. Everything a game needs: buttons and frame pacing, the house palette, drawing helpers and the 3x5 font, outlined lettering, effects maths, particles, sound and music, saving to flash, number formatting, and the debug protocol the simulator drives a game through. Includes CHGfx. |
| CHGfx | CHGfx.h | The screen: a 16-colour framebuffer sent to the panel by DMA at up to 119 fps, sprites, shapes, text and fonts, partial updates and full-colour streaming. |
| CHSd | SdSpi.h, Fat.h | Reading files from the microSD card (FAT16/FAT32, read-only). |
| SPI, Wire, EEPROM | SPI.h, Wire.h, EEPROM.h | The standard Arduino libraries, ported to the chip. |
examples/Hello adds a sound effect and a counter saved in flash. The twenty casino games under File > Examples > CHGame > Games are complete programs built on the same loop.
chgame object is a CHGame, the palette calls are in pal::, sound in audio::, saving in save::.The CHGame library is modelled on Arduboy2: one global object with the same button names (A_BUTTON, UP_BUTTON ...), nextFrame(), pollButtons(), pressed(), justPressed() and everyXFrames(). The differences: the screen is 128x128 in 16 colours chosen from 4096, drawing is CHGfx's gfx_* calls, and a frame is sent with gfx_flushAsync() instead of display(). Getting started maps Arduboy2 calls to CHGame's one by one.
https://github.com/bateske/CHGame/releases/latest/download/package_chgame_index.json).