Repository navigation
Run the games through a game host with its screens, high scores and the Arcade's live host - #84
Merged
Merged
Conversation
Game holds the lifecycle the host runs a game through, from start() to stop(), with its players and their scores. Machine gives a game the screen, the sounds, the lamps, the video player and the file system. GAMES lists the games the firmware carries, with the built-in game first. The game abstraction's interfaces link both headers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The screen, the sounds, the video player and the file system keep the functions only the game host calls private and open them to ScreenAccess, SoundsAccess, VideoPlayerAccess and FileSystemAccess in src/host. The test programs, the Arcade's stand-in host and the cost bench call them there, in place of the classes named GameHost and VideoPlayer each of them declared for itself, which would have met the real GameHost in the test image. The stand-in host in main.cpp moves into an anonymous namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cost bench builds every file of src/, core/watchdog.cpp among them, which includes WDT_T4. The stream bench takes all of io/, where i2c-bus.cpp includes Wire. Both take the library at the version the root project pins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…parse The test task's stack lies in RAM1, as the firmware's main task's does, in place of 32 KB of RAM2's heap. The lighting program's counts and ramp share one driver with the longest chain on chain F, so the heap holds one frame of 48.7 KB for both. The event-queue program's queues lie in the PSRAM. With that, video-player.frames, lighting.ramp and both config tests find their memory in a run of every test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The card service refuses PUT, MOVE and DELETE in a directory that guard() names, of the directory itself and of a directory that holds it. Every other path, CHECK and reading go on while a game runs, since the streams of sound and video outrank the service's requests and their rings and read-ahead carry them through the card's longest stall. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GameHost hands every driver event to its components in order and their pinball events to the running game, and copies TOGGLE_SWITCHED from the toggle switch to the game. It keeps the failed devices out of the game, restarts the display once the touch controller answers again, plays the boot film before the first game and moves each game through Intro, Play and Post-game. A launched game starts once the screen has settled. Links arm the solenoids in Play and guard the running game's directory on the card. FreePlay is the built-in game until one with rules replaces it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… beam main.cpp hands every driver event to the host and updates it in every pass, in place of its stand-in for the host. The host gets the screen, the sounds and the video player, plays the boot film after host.boot_film and starts FREE PLAY, and the card service guards the running game's directory. The break beam and the servo start with the other drivers, the servo with its angles and speed from the config, and the device monitor watches both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The touch driver reads a controller that did not answer at begin() as it reads one that did. Past 100 ms it counts as failed, and its first answer recovers it, so the host sets the display up again. Before, the driver never asked again, and a module powered after the Teensy stayed white. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The last fold of a curtain drew past its right edge, inside the area its shadow draws in, so the open left curtain left a red stripe at the screen's left edge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
teensy41-tests.ld is teensy41.ld with lines added, and it lacked the lines that keep the code and the tables of libyaml, the YAML tree and the config in the flash. The test image now has their room in RAM1 again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HostScreens shows the game choice after the boot film, with the firmware's games first and the card's other games as ones that cannot start yet, or the notice when no card is in. Play closes the curtain, starts the game behind it and opens on the launch card. During a game the menu follows the swipe from the right edge, End game asks first and returns to the game choice, and the status bulb and the toasts show failed devices. The game host gets stop() and ready(), and begin() can leave the first start to the screens. LVGL's heap grows to 96 KB, since the menu and the curtain left too little for a drawn layer. The test image's game-host program carries the bench tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A finger that drags the open drawer to the right moves it with itself. Let go past half the drawer's width it closes, before that it snaps open again, and a drag chooses no row. During a game a tap beside the open menu closes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LVGL keeps a control pressed while the finger slides off and clicks it on the lift wherever the finger is. The screen now ends such a press without a click when the finger leaves the screen beside the control it came down on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The valance stood over the screen's top while the curtain was open, so it covered the host's pages and the menu's header with its mute and close. The curtain now hides once it has opened and shows again when it closes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The host plays the game choice's music and the sample of the effects' level while any game's directory is in use, so Sounds opens them by their full path through two calls that only the host reaches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settings leads from the game choice to Sound, Lights and Options, and the menu's Sound and Lights rows open their pages over the running game. The levels and the options stand in the config and outlast a game switch, and the menu's mute silences every channel. The game choice plays the theme below the music's level, the effects' level plays the intro's bumper once it rests, and free play lights the left perimeter in a rainbow. The test image keeps the host's fonts in the flash and its program objects in the PSRAM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Touch::reading() gives the controller's readings before the mapping, and configure() takes new edges while the driver runs, which the next read maps with. Config::source() tells a read file from a missing and a rejected one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Service names the firmware and where the config came from, and saves the lights adapter for the next start after its warning. The touch calibration takes a tap on each of four marks near the corners, works out the readings at the picture's edges and hands them to the touch driver and the config at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…devices a source watches Watchdog::lastByWatchdog() and lastCrashed() keep what begin() read from the reset status and from CrashReport, so the host can name a restart without a noted cause. DeviceMonitor::watches() tells whether a source reports on a device. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s screens A restart by a crash, a coil left on, a hang or the watchdog shows a notice before the game choice, and a device failed at the start shows the start report. The warning lights show a tile per device: full green where the driver confirms it works, a green ring where it cannot, neon red with the fault dialog where it failed. The warnings open from their count in the header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libyaml reads a question mark at the start of a value inside braces or brackets as the mark of a name, so "???" written there unquoted did not read back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Teensy Loader takes the file and PlatformIO reported success whether a Teensy took it or not. upload-check.py now requires a Teensy on USB before the upload and its serial port to go and come back during it, for the firmware, the test image and every bench program. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…high scores After a game the host shows Game over, asks every player for a name from the known names or on the keyboard, and shows the game's high scores with a countdown to Play again. The lists stand in /games/<id>/highscores.yml and the names in /names.yml. The host reads both right after the config at the start, while the heap has room for libyaml, and never writes a file it could not read. The game choice gets a speaker that mutes the sound and shows each game's best score. FREE PLAY scores taps and moves of the toggle switch, which main.cpp now starts, and ends on a resting finger. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The display sends its pixels one ahead of the panel's kept pixel. The test image keeps this branch's memory layout: the test task's stack lies in RAM1, which leaves RAM2's heap room for the card service's chunk, and the event-queue program's queues lie in the PSRAM. Main's move of both into RAM1 left RAM1 30.6 KB short of nothing beside the stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
firmware/card-resources.json lists /audio/theme.wav and /audio/bumper.wav, and the Arcade's resource page found no source for them, so it could not copy them onto a card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Arcade's module runs the firmware's GameHost and HostScreens with the games of src/game/games.cpp, which main.cpp takes as well. npm run wasm lists those games, the Games page shows them under Firmware, and a firmware game picked in the Studio's Screens runs in the real host. The stand-in for the host's menu stays for the gallery's scenes of a running game, and a waiting card request is served at once in the browser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The drivers on main and in the driver branches take all eight slots between them, so the next driver that runs on the tick would find none. Twelve leave four free, and the firmware model holds the code's SLOTS to its n_tick_slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libyaml took 64 KB of heap for every parse, which RAM2 holds in one piece only right after the start, so a parse after the boot film failed. libyaml-buffers.py sets INPUT_RAW_BUFFER_SIZE to 1024 in the pinned sources before every build, the Arcade's module included, and a parse then takes about 4 KB. A file and a text larger than the buffer read whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
testing.md's row named 16 KB, which no figure of the model holds since the buffer is 1 KB, so figcheck failed. The row and the test give the file and the long text as multiples of the buffer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
game-host.boot-film plays the boot film through a host of its own and starts it once more with the film's files set aside. game-host.setting sets the music's level twice at once and reads a config of its own anew, so it runs on the Teensy alone. game-host.card-pulled runs a game with music and a small film while the card is pulled and put back. The program begins the audio driver for the film's sound and the music. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
storage.card-back's checks move into game-host.card-pulled: a request to the pulled card fails at once, the card reads again once it is back, and a quarter of the storage task's stack stays untouched. logger.card-missing moves into storage.no-card: without a card the log does not begin, and a line is lost and counted at once. no-card ends by asking that the card is back, since a card put in after a start without one waits for the next start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The firmware gets its game host. A
GameHostruns the games through their phases, hands them the driver events and the time, and keeps the list of failed devices.HostScreensleads the player around the games on the touch display: game choice, curtain and launch card, the menu at the right edge, Settings, Service, the warning lights, and after a game Game over, the players' names and the high scores. FREE PLAY stands in as the built-in game until the loader ofgame.ymlbrings real games.What changes
Game abstraction and host
src/game/:Game,Machineand the listGAMESingames.cpp, whichmain.cppand the Arcade's module both take.src/host/game-host.*: phases, dispatch, fault list, arming hook, launch once the screen has settled, the boot film, and the card guard for the running game's directory. A game can be held in Post-game while the screens ask for names.HostAccessclasses open the components' host-only functions, so a game cannot call them through itsMachine.main.cppruns the host in the main loop and starts the servo, the break beam and the toggle switch. The toggle switch reads pin 5, as the bench is wired today.Host screens
/games/<id>/highscores.ymland names in/names.yml. Both are read right after the config at the start, since libyaml finds no room on the heap later. A file that could not be read is never written.Components and tools
/audio/.firmware/tools/upload-check.pyfails an upload that reached no Teensy. PlatformIO'steensy-guiupload reported success with no board attached.firmware/tools/libyaml-buffers.pysets libyaml's input buffer to 1 KB before every build, so a parse takes about 4 KB of heap and finds it at any time.Arcade
GameHostandHostScreenswith the firmware's games.npm run wasmlists them insrc/wasm/firmware-games.json, the Games page shows them under Firmware, and a firmware game picked in the Studio's Screens runs in the real host. The view gallery stays.theme.wavandbumper.wav.Testing
high-scoresand the game-host rows for every screen flow.watchdog.crash,watchdog.start-up,touch.*,config.*, and the game-host bench testsswitch,menuandmenu-switch.PUTinto the running game's directory while accepting it after End game.Not in this PR
🤖 Generated with Claude Code