1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::{
datagram::{DatagramHeader, Empty, Filled, Sendable},
geometry::{Geometry, Transducer},
};
use anyhow::Result;
pub struct SilencerConfig {
step: u16,
cycle: u16,
}
impl SilencerConfig {
pub fn new(step: u16, cycle: u16) -> Self {
SilencerConfig { step, cycle }
}
pub fn none() -> Self {
Self::new(0xFFFF, 4096)
}
}
impl DatagramHeader for SilencerConfig {
type O = autd3_driver::ConfigSilencer;
fn operation(&mut self) -> Result<Self::O> {
Ok(autd3_driver::ConfigSilencer::new(self.step, self.cycle))
}
}
impl<T: Transducer> Sendable<T> for SilencerConfig {
type H = Filled;
type B = Empty;
type O = <Self as DatagramHeader>::O;
fn operation(&mut self, _: &Geometry<T>) -> Result<Self::O> {
<Self as DatagramHeader>::operation(self)
}
}
impl Default for SilencerConfig {
fn default() -> Self {
Self::new(10, 4096)
}
}