#[derive(Modulation)]
{
// Attributes available to this derive:
#[no_change]
}
Available on crate feature
derive only.Expand description
A macro to define a custom Modulation.
§Example
The following example shows how to define a modulation that outputs the maximum value only for a moment.
Modulation struct must have config: SamplingConfig and loop_behavior: LoopBehavior.
If you add #[no_change] attribute to config, you can’t change the value of config except for the constructor.
use autd3_driver::derive::*;
#[derive(Modulation, Debug)]
pub struct Burst {
config: SamplingConfig,
loop_behavior: LoopBehavior,
}
impl Burst {
pub fn new() -> Self {
Self {
config: SamplingConfig::FREQ_4K,
loop_behavior: LoopBehavior::infinite(),
}
}
}
impl Modulation for Burst {
fn calc(self) -> Result<Vec<u8>, AUTDDriverError> {
Ok((0..4000)
.map(|i| if i == 3999 { u8::MAX } else { u8::MIN })
.collect())
}
}