1use std::collections::HashMap;
15
16use autd3_derive::{Gain, Modulation};
17use autd3_driver::derive::prelude::*;
18
19#[derive(Gain, Default)]
20pub struct CustomGain {
21 drives: HashMap<usize, Vec<Drive>>,
22}
23
24impl CustomGain {
25 pub fn new() -> Self {
26 Self {
27 drives: Default::default(),
28 }
29 }
30
31 pub fn set(self, dev_idx: usize, drives: Vec<Drive>) -> Self {
32 let mut new = self;
33 new.drives.insert(dev_idx, drives);
34 new
35 }
36}
37
38impl autd3_driver::datagram::Gain for CustomGain {
39 fn calc(
40 &self,
41 _geometry: &Geometry,
42 _filter: GainFilter,
43 ) -> Result<HashMap<usize, Vec<Drive>>, AUTDInternalError> {
44 Ok(self.drives.clone())
45 }
46}
47
48#[derive(Modulation)]
49pub struct CustomModulation {
50 pub buf: Vec<EmitIntensity>,
51 pub config: SamplingConfiguration,
52}
53
54impl autd3_driver::datagram::Modulation for CustomModulation {
55 fn calc(&self) -> Result<Vec<EmitIntensity>, AUTDInternalError> {
56 Ok(self.buf.clone())
57 }
58}