use autd3_driver::{float, Drive};
use crate::{datagram::*, error::AUTDInternalError, geometry::*};
pub struct Amplitudes {
amp: float,
}
impl Amplitudes {
pub fn uniform(amp: float) -> Self {
Self { amp }
}
pub fn none() -> Self {
Self::uniform(0.0)
}
pub fn amp(&self) -> float {
self.amp
}
}
impl Datagram<AdvancedPhaseTransducer> for Amplitudes {
type H = autd3_driver::NullHeader;
type B = autd3_driver::GainAdvancedDuty;
fn operation(
&mut self,
geometry: &Geometry<AdvancedPhaseTransducer>,
) -> Result<(Self::H, Self::B), AUTDInternalError> {
Ok((
Self::H::default(),
<Self::B as autd3_driver::operation::GainOp>::new(
vec![
Drive {
phase: 0.0,
amp: self.amp,
};
geometry.num_transducers()
],
|| geometry.transducers().map(|tr| tr.cycle()).collect(),
),
))
}
}