Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Helios laser DAC support to nannou_laser #863

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion examples/laser/laser_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ fn main() {
// Synchronous DAC detection.
println!("Detecting DAC...");
let mut dac = std::mem::MaybeUninit::<nannou_laser::ffi::DetectedDac>::uninit();
let res = nannou_laser::ffi::detect_dac(&mut api, dac.as_mut_ptr());
let res = nannou_laser::ffi::detect_dac(
&mut api,
dac.as_mut_ptr(),
nannou_laser::ffi::DacVariant::DacVariantEtherdream,
);
if res as u32 != 0 {
let err_cstr = std::ffi::CStr::from_ptr(nannou_laser::ffi::api_last_error(&api));
eprintln!("failed to detect DAC: {:?}", err_cstr);
Expand Down
24 changes: 22 additions & 2 deletions examples/laser/laser_frame_stream_gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,29 @@ fn model(app: &App) -> Model {
let laser_api2 = laser_api.clone();
std::thread::spawn(move || {
let mut detected = std::collections::HashSet::new();

// detect Helios DACs first since they can't be detected while simultaneously sending data to them
for res in laser_api2.detect_dacs(laser::DacVariant::DacVariantHelios) {
if let laser::DetectDacs::Helios { previous_dac } = res {
if !detected.insert(laser::DetectedDac::from(previous_dac).id()) {
break;
}
}
}
for detected_helios in &detected {
if let laser::dac_manager::Id::Helios { id } = *detected_helios {
let dac: laser::helios_dac::NativeHeliosDacParams = id.into();
println!("{:#?}", dac);
if dac_tx.send(dac.into()).is_err() {
break;
}
}
}

// for Etherdream DAC
for res in laser_api2
.detect_dacs()
.expect("failed to start detecting DACs")
.detect_dacs(laser::DacVariant::DacVariantEtherdream)
.expect("failed to start detecting Etherdream DACs")
{
let dac = res.expect("error occurred during DAC detection");
if detected.insert(dac.id()) {
Expand Down
1 change: 1 addition & 0 deletions guide/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ back to the origins.
- Move `nannou_conrod` and `nannou_timeline` into a new repository:
https://github.com/nannou-org/nannou_conrod. Both crates are deprecated in
favour of `nannou_egui`.
- Added support for the Helios DAC to nannou_laser

---

Expand Down
5 changes: 3 additions & 2 deletions nannou_laser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "nannou_laser"
version ="0.18.0"
authors = ["mitchmindtree <[email protected]>"]
authors = ["mitchmindtree <[email protected]>, Waseem G <[email protected]>"]
description = "A cross-platform laser DAC detection and streaming API."
edition = "2018"
keywords = ["laser", "dac", "stream", "frame", "ether-dream"]
keywords = ["laser", "dac", "stream", "frame", "ether-dream", "helios"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/nannou-org/nannou_laser.git"
homepage = "https://github.com/nannou-org/nannou_laser"
Expand All @@ -15,6 +15,7 @@ crate-type = ["rlib", "staticlib", "cdylib"]

[dependencies]
ether-dream = "~0.2.5"
helios-dac = { git = "https://github.com/seem-less/helios-dac-rs.git", branch="nannou-integration", default-features = false, features = ["native"] }
ilda-idtf = { version = "0.1", optional = true }
lasy = "0.4.1"
thiserror = "1"
Expand Down
16 changes: 14 additions & 2 deletions nannou_laser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,20 @@ streams.*

## Supported Protocols

Currently, **nannou_laser** only supports the open source [Ether Dream
DAC](https://ether-dream.com/) protocol. The plan is to progressively add
Currently, **nannou_laser** supports the [Ether Dream](https://ether-dream.com/) and [Helios](https://bitlasers.com/helios-laser-dac/) open-source DAC protocols.

When creating a new Frame/Raw Stream the type of DAC to be detected can be specified using the `Builder::dac_variant()` method. If this is not specified the Ether dream variant is selected by default.

```
let _laser_api = laser::Api::new();
let laser_stream = _laser_api
.new_raw_stream(laser_model, laser)
.dac_variant(laser::DacVariant::DacVariantHelios)
.build()
.unwrap();
```

The plan is to progressively add
support for more protocols as they are needed by ourselves and users throughout
the lifetime of the project.

Expand Down
194 changes: 0 additions & 194 deletions nannou_laser/src/dac.rs

This file was deleted.

Loading