Skip to content

Architecture

SrPivete edited this page Dec 2, 2026 · 2 revisions

Architecture

Single static binary, five small modules, zero runtime dependencies.

main.c --> hid.c --> /dev/hidrawN (USB HID, VID 0xAA88 PID 0x8666)
   |   +--> sensors.c --> /sys/class/hwmon, /sys/class/thermal
   |   +--> display.c (blink policy, pure function)
   +------> util.c (logging, sysfs reads)

Modules

Module Responsibility
main.c CLI parsing, probe, daemon loop, test lock
hid.c Device discovery, HID report-descriptor parser, report writes, --report modes
sensors.c CPU temperature: Intel averages Core N; AMD uses Tdie/Tccd, then Tctl; thermal zones as fallback
display.c Value to show per cycle, as a pure function of (code, temp, blink, iter)
util.c log_msg and tolerant/strict sysfs readers

Panel behavior

  • The panel latches at about 1 Hz. Faster writes fight its own refresh and render an illegible mix. Every effect toggles once per loop iteration (default 1 s).
  • Sending 0 does not blank the mirrored LED panel. Error blinks alternate 88 and 11 for maximum segment contrast.
  • Error codes are distinguished by rhythm: E1 every 1 s, E2 every 2 s, E3 every 3 s.
  • A boot animation was tried and removed: at 12 ms per step the panel flickered; at 30 ms per step it was too slow to be useful.

Protocol

The descriptor announces an 11-byte output report. Byte 1 is the temperature in degrees Celsius (0-99). --report 24 exercises the reverse-engineered variant used by the official Windows writer; --report both tries 24 first, then the descriptor.

Build

make
./build.sh

Both compile src/*.c with -Wall -Wextra -Werror -fstack-protector-strong -D_FORTIFY_SOURCE=2. make test runs the pure-helper tests (display policy, parsers, report layout). CI compiles every push to main with Zig for x86_64-linux-musl and runs make test. Every tag publishes a static binary, a debug binary, install.sh, SHA256SUMS, a .deb and an .rpm.

Delivery constraints

  • install.sh is intentionally a single file: the delivery model is curl | bash.
  • The .deb and .rpm payloads live under packaging/ and are versioned from the release tag at CI time.

Full details: https://github.com/SrPivete/risemode-linux-display/blob/main/docs/ARCHITECTURE.md

Clone this wiki locally