Creating Custom Modulation
In the Rust version, you can create your own Modulation
.
Here, let’s create a Burst
that outputs only at a certain moment during the period1.
NOTE: This feature is not available in the C++, C#, and Python libraries. However, you can use Custom for the same purpose.
Below is a sample of this Burst
.
use autd3::prelude::*;
use autd3::core::derive::*;
#[derive(Modulation, Debug)]
pub struct Burst {
config: SamplingConfig,
}
impl Burst {
pub fn new() -> Self {
Self {
config: SamplingConfig::FREQ_4K,
}
}
}
impl Modulation for Burst {
fn calc(self) -> Result<Vec<u8>, ModulationError> {
Ok((0..4000)
.map(|i| if i == 3999 { u8::MAX } else { u8::MIN })
.collect())
}
fn sampling_config(&self) -> SamplingConfig {
self.config
}
}
fn main() {
}
1
Not included in the SDK.