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 using a streaming API that provides uniform pacing and backpressure across all device types.
§Getting Started
The streaming API uses a zero-allocation callback approach where the library manages timing and you fill buffers with points:
§Callback Mode
Use run() with a producer closure for simpler code:
use laser_dac::{list_devices, 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 (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) - AVB Audio Devices - AVB audio output via CoreAudio/ASIO (feature:
avb, macOS/Windows)
§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 (AVB)
§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::StreamBackend;pub use backend::WriteOutcome;pub use discovery::DacDiscovery;pub use discovery::DiscoveredDevice;pub use discovery::DiscoveredDeviceInfo;pub use discovery::ExternalDevice;pub use discovery::ExternalDiscoverer;pub use types::caps_for_dac_type;pub use types::ChunkRequest;pub use types::ChunkResult;pub use types::DacCapabilities;pub use types::DacConnectionState;pub use types::DacDevice;pub use types::DacInfo;pub use types::DacType;pub use types::EnabledDacTypes;pub use types::LaserPoint;pub use types::OutputModel;pub use types::RunExit;pub use types::StreamConfig;pub use types::StreamInstant;pub use types::StreamStats;pub use types::StreamStatus;pub use types::UnderrunPolicy;pub use session::ReconnectingSession;pub use session::SessionControl;pub use stream::Dac;pub use stream::Stream;pub use stream::StreamControl;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 trait and implementations for the streaming API.
- discovery
- DAC device discovery.
- protocols
- Protocol implementations for various laser DAC types.
- session
- Reconnecting session wrapper for automatic reconnection.
- stream
- Stream and Dac types for point output.
- types
- DAC types for laser output.
Structs§
- Frame
- A point buffer to be cycled by the adapter.
- Frame
Adapter - Converts a point buffer (frame) into a continuous stream.
- Shared
Frame Adapter - Thread-safe handle for updating frames from another thread.
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.
Type Aliases§
- Result
- Result type for streaming operations.