autd3_driver/datagram/
segment.rs

1use std::convert::Infallible;
2
3use autd3_core::{
4    datagram::{Datagram, DeviceMask},
5    environment::Environment,
6    firmware::{FirmwareLimits, Segment, transition_mode::TransitionMode},
7    geometry::Geometry,
8};
9
10/// Change the [`Gain`] segment.
11///
12/// [`Gain`]: autd3_core::gain::Gain
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
14pub struct SwapSegmentGain(pub Segment);
15
16/// Change the [`Modulation`] segment.
17///    
18/// [`Modulation`]: autd3_core::modulation::Modulation
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
20pub struct SwapSegmentModulation<T>(pub Segment, pub T);
21
22/// Change the [`FociSTM`] segment.
23///
24/// [`FociSTM`]: crate::datagram::FociSTM
25#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
26pub struct SwapSegmentFociSTM<T>(pub Segment, pub T);
27
28/// Change the [`GainSTM`] segment.
29///
30/// [`GainSTM`]: crate::datagram::GainSTM
31#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
32pub struct SwapSegmentGainSTM<T>(pub Segment, pub T);
33
34impl Datagram<'_> for SwapSegmentGain {
35    type G = Self;
36    type Error = Infallible;
37
38    fn operation_generator(
39        self,
40        _: &Geometry,
41        _: &Environment,
42        _: &DeviceMask,
43        _: &FirmwareLimits,
44    ) -> Result<Self::G, Self::Error> {
45        Ok(self)
46    }
47}
48
49impl<T: TransitionMode> Datagram<'_> for SwapSegmentModulation<T> {
50    type G = Self;
51    type Error = Infallible;
52
53    fn operation_generator(
54        self,
55        _: &Geometry,
56        _: &Environment,
57        _: &DeviceMask,
58        _: &FirmwareLimits,
59    ) -> Result<Self::G, Self::Error> {
60        Ok(self)
61    }
62}
63
64impl<T: TransitionMode> Datagram<'_> for SwapSegmentFociSTM<T> {
65    type G = Self;
66    type Error = Infallible;
67
68    fn operation_generator(
69        self,
70        _: &Geometry,
71        _: &Environment,
72        _: &DeviceMask,
73        _: &FirmwareLimits,
74    ) -> Result<Self::G, Self::Error> {
75        Ok(self)
76    }
77}
78
79impl<T: TransitionMode> Datagram<'_> for SwapSegmentGainSTM<T> {
80    type G = Self;
81    type Error = Infallible;
82
83    fn operation_generator(
84        self,
85        _: &Geometry,
86        _: &Environment,
87        _: &DeviceMask,
88        _: &FirmwareLimits,
89    ) -> Result<Self::G, Self::Error> {
90        Ok(self)
91    }
92}