Expand description
Unified DAC backend abstraction for laser projectors.
This crate provides a common interface for communicating with various laser DAC (Digital-to-Analog Converter) hardware. Two API styles are available:
§Getting Started
§Frame Mode (recommended)
Submit complete frames with automatic transition blanking:
use laser_dac::{open_device, FrameSessionConfig, Frame, LaserPoint};
let device = open_device("my-device").unwrap();
let config = FrameSessionConfig::new(30_000);
let (session, _info) = device.start_frame_session(config).unwrap();
session.control().arm().unwrap();
session.send_frame(Frame::new(vec![
LaserPoint::new(-0.5, 0.0, 65535, 0, 0, 65535),
LaserPoint::new( 0.5, 0.0, 0, 65535, 0, 65535),
]));
// Frame replays automatically. Submit new frames for animation.For advanced frame-mode output-space processing on the final presented
sequence, use FrameSessionConfig::with_output_filter. The filter runs
after transition composition, blanking, and color delay, just before the
backend write.
For downstream watchdogs, FrameSession::metrics exposes a small liveness
surface with connectivity, last-loop-activity, and last-write-success
timestamps. Watchdog policy remains application-owned.
§Callback Mode (advanced, FIFO backends only)
Fill point buffers via zero-allocation callback for custom timing. Not available for frame-swap backends (Helios) — use Frame Mode instead.
use laser_dac::{open_device, StreamConfig, LaserPoint, ChunkRequest, ChunkResult};
let device = open_device("my-device").unwrap();
let config = StreamConfig::new(30_000);
let (stream, _info) = device.start_stream(config).unwrap();
stream.control().arm().unwrap();
let exit = stream.run(
|req: &ChunkRequest, buffer: &mut [LaserPoint]| {
let n = req.target_points;
for i in 0..n {
buffer[i] = LaserPoint::blanked(0.0, 0.0);
}
ChunkResult::Filled(n)
},
|err| eprintln!("Stream error: {}", err),
);§Supported DACs
- Helios - USB laser DAC, Frame API only (feature:
helios) - Ether Dream - Network laser DAC (feature:
ether-dream) - IDN - ILDA Digital Network protocol (feature:
idn) - LaserCube WiFi - WiFi-connected laser DAC (feature:
lasercube-wifi) - LaserCube USB - USB laser DAC / LaserDock (feature:
lasercube-usb) - Oscilloscope - XY mode via stereo audio output (feature:
oscilloscope) - AVB Audio Devices - AVB audio output via the system audio host: CoreAudio (macOS), WASAPI or ASIO (Windows, ASIO opt-in via the
asiofeature), ALSA (Linux). Feature:avb.
§Features
all-dacs(default): Enable all DAC protocolsusb-dacs: Enable USB DACs (Helios, LaserCube USB)network-dacs: Enable network DACs (Ether Dream, IDN, LaserCube WiFi)audio-dacs: Enable audio DACs (Oscilloscope, AVB)asio(default): ASIO host on Windows for AVB output. Requires the Steinberg ASIO SDK plusLIBCLANG_PATHandCPAL_ASIO_DIRset at build time. Disable withdefault-features = false(and re-enable the features you want) to fall back to the default cpal host (WASAPI on Windows) and skip the SDK requirement.
§Coordinate System
All backends use normalized coordinates:
- X: -1.0 (left) to 1.0 (right)
- Y: -1.0 (bottom) to 1.0 (top)
- Colors: 0-65535 for R, G, B, and intensity
Each backend handles conversion to its native format internally.
Re-exports§
pub use backend::BackendKind;pub use backend::DacBackend;pub use backend::FifoBackend;pub use backend::FrameSwapBackend;pub use backend::WriteOutcome;pub use discovery::downcast_connect_data;pub use discovery::slugify_device_id;pub use discovery::DacDiscovery;pub use discovery::DiscoveredDevice;pub use discovery::DiscoveredDeviceInfo;pub use discovery::Discoverer;pub use point::LaserPoint;pub use device::caps_for_dac_type;pub use device::DacCapabilities;pub use device::DacConnectionState;pub use device::DacDevice;pub use device::DacInfo;pub use device::DacType;pub use device::EnabledDacTypes;pub use device::OutputModel;pub use config::IdlePolicy;pub use config::ReconnectConfig;pub use config::StreamConfig;pub use config::UnderrunPolicy;Deprecated pub use stream::ChunkRequest;pub use stream::ChunkResult;pub use stream::Dac;pub use stream::RunExit;pub use stream::Stream;pub use stream::StreamControl;pub use stream::StreamInstant;pub use stream::StreamStats;pub use stream::StreamStatus;pub use presentation::default_transition;pub use presentation::Frame;pub use presentation::FrameSession;pub use presentation::FrameSessionConfig;pub use presentation::FrameSessionMetrics;pub use presentation::OutputFilter;pub use presentation::OutputFilterContext;pub use presentation::OutputResetReason;pub use presentation::PresentedSliceKind;pub use presentation::TransitionFn;pub use presentation::TransitionPlan;pub use backend::HeliosBackend;pub use protocols::helios;pub use backend::EtherDreamBackend;pub use protocols::ether_dream;pub use backend::IdnBackend;pub use protocols::idn;pub use backend::LasercubeWifiBackend;pub use protocols::lasercube_wifi;pub use backend::LasercubeUsbBackend;pub use protocols::lasercube_usb;pub use backend::AvbBackend;pub use protocols::avb;pub use protocols::lasercube_usb::rusb;
Modules§
- backend
- DAC backend traits and implementations for the streaming API.
- buffer_
estimate - Buffer fullness estimation for FIFO DAC backends.
- config
- Stream and reconnection configuration types.
- device
- DAC identity, capabilities, and discovery filtering.
- discovery
- DAC device discovery.
- point
- The DAC-agnostic laser point type and coordinate/colour conversion helpers.
- presentation
- Frame-first presentation types and engine.
- protocols
- Protocol implementations for various laser DAC types.
- stream
- Stream and Dac types for point output.
- types
- Backwards-compatible re-exports.
Enums§
- Error
- Streaming-specific error type.
Functions§
- list_
devices - List all available DACs.
- list_
devices_ filtered - List available DACs filtered by DAC type.
- open_
device - Open a DAC by ID.
- open_
device_ with - Open a DAC by ID using a custom discovery factory.
Type Aliases§
- Result
- Result type for streaming operations.