ed::Room is the Device SDK’s sketch API, in EscapeDirectorRoom.h. Declare
props and their capabilities in setup(), call room.begin(), and call
room.loop() at the top of every loop(). Every callback you pass runs from
room.loop(), never from an interrupt.
Declarations
Declare everything insetup() before room.begin().
If a declaration breaks a rule,
room.begin() prints the reason on USB serial
at 115200 baud and returns false. The sketch then runs on its own, without
connecting, until you fix it.
IDs and names
- IDs use lowercase letters, digits and hyphens, start with a letter, and have at most 40 characters. Enum values follow the same rule.
- Names have 1 to 80 characters. Names are what staff see, and you can change them at any time.
- IDs are permanent. The Room’s Puzzle links and Automations point to them. Never change or reuse one.
Inputs
ed::Input reads a button or switch every 5 ms, debounces it (20 ms by
default), and remembers each press with the time and game it happened in.
Declare inputs globally; room.begin() sets up their pins.
ed::Input(pin, mode, activeLow, debounceMs).
Use room.nextPress() for a sequence across several inputs, such as a button
code. It returns every input’s presses, so don’t also call pressed() for
those inputs.
How long a press waits
- One pass of loop(). A press stays available until the end of the first
loop()pass afterroom.loop()returns it. If that pass doesn’t ask for it withpressed()orroom.nextPress(), the press is dropped. A press made while your code wasn’t waiting for that input doesn’t act later. - 16 presses. Up to 16 presses wait while
loop()is paused. Later presses are dropped, never reordered, androom.lostPresses()returns how many were dropped since you last called it.
Timed outputs and delays
- Up to 8 pins can pulse at once, and up to 8
after()actions can wait. Both calls returnfalsewhen they can’t schedule. - Pulsing a pin again restarts its time and cancels a
donethat hasn’t run. - Set a pulsed pin as an
OUTPUTinsetup(). While it pulses, don’t write it yourself, except to set it back to its idle level early, as the train door example’s Close door does. The pulse still ends on time anddonestill runs. - Scheduling an
after()action that is already waiting replaces it.
Signals
Signals are sent only during a live game.
triggerWhen() still returns true
outside a game, so your puzzle logic works the same in Test mode.
Signals aren’t queued. A signal from an earlier game, or more than 2 seconds
old, is dropped. So a press that waited through a reconnect still drives your
puzzle, but Escape Director hears it only if it happened less than 2 seconds
earlier, in the current game. Always pass the input when a press caused the
signal, so an old press isn’t reported as new.
Test mode
In Test mode, staff try each prop before players arrive. A command runs in Test mode only if it declares a Test behavior, and that behavior must be temporary..testPin(pin, level, ms)drives the pin forms, then the SDK switches it back, even while the board reconnects. The command’s normal handler doesn’t run in Test mode..test(start, stop)callsstart.stopruns when Test ends or the Room resets. Use it for an effect that needs more than one pin.after()actions scheduled insidestartend with Test.- A Test behavior must not change ordinary puzzle state, such as marking a puzzle solved.
- Test mode never completes Puzzles or runs Automations.
Room reset
When a Game Master resets the Room, the SDK cancels waitingafter() actions
and ends every pulse, without calling done. Then it calls your
room.onReset() handler. Put your sketch’s own reset there.
While the board reconnects
The SDK keeps the board connected in the background. While it connects or reconnects,loop() can pause, usually for well under a second, and for up to
about 10 seconds when Room Connector can’t be reached.
ed::Inputpresses androom.pulse()outputs keep working.- Other code in
loop()waits. Keep your own calls short, such as reading an RFID reader or updating a display.
Capacity and memory
For more room, declare
ed::BasicRoom<8, 64, 24> room(name, version); in
place of ed::Room. The three numbers are props, total entries, and Test
behaviors plus number and choice fields. A Room never takes more than 8 props.
Use a smaller first number to save RAM.
The UNO R4 WiFi has 32 KB of RAM. Avoid building Strings in loop(), large
buffers and large JsonDocuments.