Show the code in these languages

Case studies

Two apps built on Dev's Go kit, as they are today: Focus, a focus timer, and Pet, a pet for kids. For each: what the robot and the phone show, how it is built, what it uses of the kit and of the robot, its key code with links to the exact lines, and what a developer learns from it.

Focus and Pet

A Stackchan robot running Focus: the time left in a red ring, its LEDs counting down

Focus

A focus timer: the robot shows the time left as a ring and on its LEDs, chimes and nods when a phase ends; a tap starts it. The basics of an app.

i41-eu/q41eu-focus at v0.5.0 · focus.q41.eu

A Stackchan robot running the pet: a happy face, its LEDs warm

Pet

A Tamagotchi for kids: the pet lives on a server, the robot is its body. Menus, food cards, games, a daily routine. The rest of the robot.

i41-eu/q41eu-pet at v0.14.1 · pet.q41.eu

Focus and Pet side by side
FocusPet
Code2,200 lines of Go and a 390-line page; 730 lines of tests6,900 lines of Go and 930 of pages; 2,400 lines of tests
Of the kitrobothub, soundrobothub, sound, leds
Of the robotpictures on the screen, the LEDs, the speaker, the head; touches on the screen and the headall that, and stored pictures and sounds (sprites, the file store), the speech bubble and the face, stickers, brightness and the screen saver, NFC cards, the motion sensors, the light sensor at 20 a second, the camera
Read it forthe kit's hub, a pure model with its tests, drawing the screen, sending only what changed, touchesmeaning from raw input, pictures kept on the robot, menus from tappable sprites, timed steps, streams, guarding the head, falling back

An app or a program

The rest of this site is about programs: a script, a page or an AI agent that uses the robot through Dev, with a key. Focus and Pet are apps: servers the robot connects to itself, as it connects to Dev. The robot runs one app at a time; its app switcher (the QR screen: Next, Connect) moves between them.

A program and an app compared
A program, through DevAn app, on the kit
Talks toDev's API (HTTP /v1, MCP), with a keythe robot itself, over the device wire protocol (robothub)
Runswhen you start itall the time, as a server
Inany languageGo (the kit)
ReachesDev's actions and eventsevery command, event, reading and stream of the robot
Its own pageno: Dev'syes, paired by the robot's QR code

Each case study maps what the app does to Dev's actions, so a program can do the same where Dev's API reaches.

The kit

The Go packages every app needs (pkg.go.dev), and who uses them today. Dev is built on all of them.

The kit's packages
PackageWhat it doesUsed by
robothubthe robot side of an app: tokens (the shared one, or a manager's per robot), one connection per robot, pairing codes, pings; the app gets callbacks (connected, events, telemetry, binary streams) and sends commands; Report tells the manager the paired browsersFocus, Pet, Dev
sound16 kHz sounds: tones, bells, glides, melodies, the named chimes (Focus's and Pet's among them), speaker messages, WAV filesFocus, Pet, Dev
ledsthe 12 LEDs in the robot's order: a bar, one colour, a screen colour corrected for the LEDsPet, Dev
robothigher-level calls on a connected robot: a card, a picture, say, a face, look, nod, LEDs, sounds paced for the speakerDev
screen320×240 pictures: a card with text that fits itself, a question with buttons and its hit test, the Go fontsDev
gesturethe robot's raw input as what a person did: a tap, a pat, a pet, a stroke, picked up, a tagDev