|
phyphox BLE
Plot your Arduino's data in the phyphox app and control the board from the phone
|
Elements the user operates on the phone. Each writes into an input channel (1…16) on the board, chosen with setChannel(k) or the constructor's last argument. The board reads a channel with PhyphoxBLE::read(...), PhyphoxBLE::readChannel(k) or PhyphoxBLE::changed(k), or attaches a callback: element.onChange(fn), button.onPress(fn), PhyphoxBLE::onChange(k, fn). Callbacks are plain functions (a captureless lambda works):
Two elements may share a channel — an edit field and a slider for the same value, say. A button owns its channel.
The phone sends a channel when its value changes, not continuously. Before the first change read() returns the element's default. A button press always arrives, even if the value is the same as last time. Values flow only while the experiment is running (▶ in the app) — an edit made while paused reaches the board when the user starts again. experiment.setResendUnchanged(true) makes the phone write every channel on every analysis cycle instead (about a hundred times per second), which is useful as a heartbeat from the phone.
| element | constructor | setters |
|---|---|---|
Edit | Edit(label, channel) | setDefault(v), setUnit, setSigned(b), setDecimal(b), setMin(v), setMax(v), setFactor(f), submitWith(button) |
Slider | Slider(label, min, max, step, channel) | setMinValue, setMaxValue, setStepSize, setDefault, setPrecision(n), setShowValue(b), setColor |
Dropdown | Dropdown(label, channel) | addOption(text, value) (up to 8) or setOptions(n, labels, values) (any number), setDefault(value), setColor |
Toggle | Toggle(label, channel) | setDefault(0 \| 1) |
Button | Button(label, channel) | setValue(v) — what a press writes, default 1 — and onPress(fn) |
All have setLabel, setChannel, onChange (not meaningful for a button), setVisibility and setXMLAttribute.
edit.submitWith(button) delivers the field only when that button is pressed:
Set the button's channel before calling submitWith.
phyphox's remote access (the web interface and its API) can write these channels too: an edit field corresponds to cmd=set, a button to cmd=trigger. The board sees no difference.