Skip to main content

autd3_cpu_wire/payload/
silencer.rs

1use zerocopy::little_endian::U16;
2use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, Unaligned};
3
4pub const SILENCER_FLAG_BIT_STRICT_MODE: u8 = 1;
5pub const SILENCER_FLAG_STRICT_MODE: u8 = 1 << SILENCER_FLAG_BIT_STRICT_MODE;
6
7pub const SILENCER_DEFAULT_UPDATE_RATE: u16 = 256;
8pub const SILENCER_DEFAULT_COMPLETION_STEPS_INTENSITY: u16 = 10;
9pub const SILENCER_DEFAULT_COMPLETION_STEPS_PHASE: u16 = 40;
10
11#[derive(FromBytes, IntoBytes, KnownLayout, Immutable, Unaligned)]
12#[repr(C)]
13pub struct SilencerPayload {
14    pub flag: u8,
15    pub reserved: u8,
16    pub update_rate_intensity: U16,
17    pub update_rate_phase: U16,
18    pub completion_steps_intensity: U16,
19    pub completion_steps_phase: U16,
20}
21
22const _: () = assert!(core::mem::offset_of!(SilencerPayload, flag) == 0);
23const _: () = assert!(core::mem::offset_of!(SilencerPayload, update_rate_intensity) == 2);
24const _: () = assert!(core::mem::offset_of!(SilencerPayload, update_rate_phase) == 4);
25const _: () = assert!(core::mem::offset_of!(SilencerPayload, completion_steps_intensity) == 6);
26const _: () = assert!(core::mem::offset_of!(SilencerPayload, completion_steps_phase) == 8);
27const _: () = assert!(core::mem::size_of::<SilencerPayload>() == 10);