Appendix A: API Reference
Every public method on view (the Plotter instance), grouped by purpose.
Defaults shown in parentheses. The "Desktop result" column describes the visible
effect once the desktop app is connected and negotiated.
Lifecycle
| Method |
Behavior |
Desktop result |
begin(unsigned long baud = 115200, PlotType type = Cartesian, Mode mode = Continuous, int packetSize = VIEWPOINT_DEFAULT_PACKET_SIZE) |
Initialize default Serial at baud, set the trailing plot type, mode, and packet size, start protocol negotiation |
App opens the session and reports connection on the next [viewpoint]version= exchange |
begin(Stream& serial, PlotType type = Cartesian, Mode mode = Continuous, int packetSize = default) |
Use a caller-initialized Stream (the caller owns serial.begin()); same trailing defaults |
Same handshake, on the supplied stream |
begin(PlotType type, Mode mode = Continuous, int packetSize = default) |
Default Serial at 115200, leading with plot type |
App opens with the chosen plot type |
begin(Mode mode, int packetSize = default) |
Default Serial at 115200, Cartesian by default, leading with mode |
App opens in the chosen mode |
send(const char* timestamp = "") |
Process incoming protocol bytes, send any pending configuration, drain buffered trace data, optionally emit a timestamp, send the frame-complete marker in Frames mode, clear trace buffers |
App receives the configured frame or batch of points |
reset() |
Free library-owned traces, clear plot config, restore type/mode/packet defaults; triggers a full handshake on next send() |
App clears all state on the next [viewpoint]version=… |
removeTrace(int id) |
Free the trace at id, drop any derived traces that referenced it, force a full handshake |
App removes the trace and its legend entry |
clearTraces() |
Free every trace and derived trace; force a full handshake |
App clears all traces |
clearPlots() |
Reset every plot's title, axes, grid, display mode, and trace list |
App resets all plot configuration |
The four begin(...) overloads cover the four natural starting shapes: default
Serial with optional baud and trailing defaults, a caller-provided Stream,
plot-type-first, or mode-first. Default arguments fill in the rest, so a sketch
can write view.begin(), view.begin(scatter), view.begin(frames, 512), or
view.begin(Serial1, polar, frames, 360) without juggling argument order beyond
the leading type.
Plot Type, Mode, and Delay
| Method |
Behavior |
Desktop result |
setPlotType(PlotType) |
Set Cartesian, Scatter, or Polar; switching to Polar forces packet size to 360 |
App switches to the chosen layout |
setMode(Mode) |
Set Continuous or Frames; sets a sensible default delayMs_ for each (2 ms / ~16.7 ms) and enables TX buffering in Frames mode |
App treats the stream as live points or bounded frames |
setPacketSize(int size) |
Set the points-per-frame target in Frames mode |
App expects this many points per [frames]complete=true |
setDelay(float ms) |
Override the inter-sample (Continuous) or inter-frame (Frames) delay in milliseconds |
None directly — slows or speeds the stream rate |
setLegacyMode(bool) |
Bypass the [viewpoint] handshake, suppress frame-complete markers, clamp send() to 500 points per call |
None — legacy mode targets non-ViewPoint receivers |
Default Plot Configuration
These calls configure the default plot — the implicit plot every sketch
starts with. In a multi-plot sketch, the same setters are available on
view.plot(i) for per-plot configuration.
| Method |
Behavior |
Desktop result |
setVerticalRange(min, max) |
Set the y-axis range |
App draws the y-axis with these bounds |
setVerticalRange(min, max, int divisions) |
Range plus division count |
Axis gridlines split into divisions segments |
setVerticalRange(min, max, float minor, float major) |
Range plus explicit minor and major step |
Axis gridlines at the given spacings |
setHorizontalRange(min, max) and overloads |
Same idea for the x-axis |
App draws the x-axis with these bounds |
setUnits(const char* h, const char* v) |
Set horizontal and vertical unit strings |
Units appear in the axis labels |
setRadialRange(min, max) and overloads |
Polar radial limits and divisions; mirrors the vertical-range API |
App draws the radial axis from min to max |
setAngularOffset(float) |
Rotate the polar angle reference |
Polar grid rotates by this offset |
setAngularStep(int) |
Set the angular grid spacing |
Polar grid lines step by this amount |
setAngularUnits(AngularUnit) |
Switch between degrees and radians |
App interprets incoming angle values accordingly |
setRadians() |
Shortcut for setAngularUnits(Radians) |
Same as above |
setAxisLabels(const char* h, const char* v) |
Set the axis label text (independent of units) |
App shows the labels next to each axis |
setTitle(const char* title) |
Set the sketch-level title, shown above the plot region and in the window title |
App displays the sketch title |
setPlotTitle(const char* title) |
Set the title of the default plot |
App displays the plot title |
Logarithmic Scale
| Method |
Behavior |
Desktop result |
enableLogarithmicScale(bool mapData = true) |
Enable log scaling on the default plot's vertical axis. mapData=true means trace data is linear and the app maps it; false means data is already in log-space (e.g., dB) and is plotted linearly against log-spaced axis bounds |
App renders the y-axis with log gridlines and treats incoming data as configured |
disableLogarithmicScale() |
Disable log scaling on the vertical axis |
App reverts to linear y-axis |
For axis-specific control, use
view.plot(i).enableLogarithmicScale(axis, mapData).
Grid and Reference Lines
| Method |
Behavior |
Desktop result |
setGridColors(uint32_t minor, uint32_t major) |
Set the minor and major gridline colors |
Grid redraws with the chosen colors |
setGridColors(uint32_t labels, uint32_t minor, uint32_t major) |
Also sets axis-label color |
Labels and gridlines redraw with the chosen colors |
addHorizontalReferenceLine(float value, bool isMajor = false) |
Add a horizontal line on the vertical axis at value. The line is drawn flat across the plot at constant y |
App overlays a horizontal line at the given y-value |
addHorizontalReferenceLine(float value, uint32_t color, float stroke = 1.0f) |
Same with explicit color and stroke |
Same, in the requested color and weight |
addVerticalReferenceLine(float value, bool isMajor = false) |
Add a vertical line on the horizontal axis at value. The line is drawn straight up at constant x |
App overlays a vertical line at the given x-value |
addVerticalReferenceLine(float value, uint32_t color, float stroke = 1.0f) |
Same with explicit color and stroke |
Same, in the requested color and weight |
Display Modes
| Method |
Behavior |
Desktop result |
setDisplayMode(DisplayMode mode) |
Apply a display mode to the default plot (Cartesian + Frames only) |
App switches the plot's renderer to the chosen mode |
setDisplayMode(DisplayMode mode, int traceId) |
Same, scoped to one trace |
App applies the display mode to that trace's drawing only |
Multi-Plot
| Method |
Behavior |
Desktop result |
setNumberOfPlots(int count) |
Allocate count plot panels (clamped to VIEWPOINT_MAX_PLOTS) |
App splits the canvas into the requested number of stacked plots |
plot(int index) |
Return a Plot& for the plot at index. The returned object exposes the same axis, title, units, display-mode, and reference-line API as view itself |
None directly — subsequent setters on the returned Plot configure that panel |
Trace Management
| Method |
Behavior |
Desktop result |
createTrace(int id) |
Allocate a library-owned trace at id with capacity packetSize |
A new trace is added to the legend on the next handshake |
createTrace(int id, size_t capacity) |
Same with explicit capacity |
Same |
createTrace(int id, float* buffer, size_t size) |
Wrap a caller-provided single-value buffer (no allocation, no growth) |
Same |
createTrace(int id, float* x, float* y, size_t size) |
Wrap caller-provided paired buffers |
Same |
trace(int id) |
Return the existing trace at id, or create a library-owned one if missing |
Same as createTrace if a trace is created |
trace(const char* label) |
Look up a trace by label; create one if there is no match |
A new trace is added with the supplied label |
addData(int id, float value) |
Append a single value to the trace at id |
Trace updates on next send() |
addData(const char* label, float value) |
Append by label (creates the trace if missing) |
Same |
addData(id, float x, float y), addData(label, x, y) |
Append a paired value |
Trace updates on next send() |
addData(id, const float* data, size_t count) and label variant |
Append an array of values in one call |
Trace updates on next send() |
addData(id, const float* x, const float* y, size_t count) |
Append paired arrays |
Trace updates on next send() |
addBreak(int id), addBreak(const char* label) |
Insert a discontinuity in a Scatter or Polar trace |
App starts a new line segment without connecting back to the previous point |
sendData(int id, float value) |
Send one value for a single trace channel immediately, without buffering through Trace |
App receives one out-of-band data line |
sendData(int id, float x, float y) |
Same for paired values |
Same |
Messaging
| Method |
Behavior |
Desktop result |
sendInfo(const char* fmt, ...) |
printf-style formatted info message (up to ~500 chars) |
App shows a [message] notification |
sendInfo(const char* title, const char* msg) |
Titled info message |
App shows the titled message |
sendError(const char* fmt, ...) |
printf-style formatted error message |
App shows an [error] notification |
sendError(const char* title, const char* msg) |
Titled error message |
App shows the titled error |
State Queries
| Method |
Returns |
isReady() |
true once the protocol is in Negotiated or DataOnly state, or whenever legacy mode is enabled |
isNegotiated() |
true only after the [viewpoint]version=… handshake completed |
packetSize() |
Current packet size (Frames mode target) |
traceCount() |
Number of active traces |
plotType() |
Current PlotType |
mode() |
Current Mode |
isLegacyMode() |
Whether setLegacyMode(true) is in effect |
Advanced
| Method |
Behavior |
update() |
Run the protocol state machine and drain incoming bytes without sending data. Useful when a sketch polls a slow sensor and may not call send() for seconds at a time |
protocol() |
Return the Protocol& for advanced use: version checks (protocol().supports(major, revision)), state inspection (protocol().isNegotiated()), and direct command building |