pub struct BeepPattern {
pub freq_hz: u32,
pub duty_pct: u8,
pub on_ms: u32,
pub off_ms: u32,
pub cycles: u32,
}Expand description
A bounded software-PWM beep description.
The envelope toggles the line on for on_ms then off for off_ms, for
cycles. During each on phase the service also drives the carrier a
passive buzzer needs: the line toggles at freq_hz with duty_pct high
time (carrier_timing). With freq_hz 0 (an active buzzer or an LED) the
on phase is a steady high.
Every field is advisory until clamp bounds it; the service
always clamps before scheduling, so a value out of range is corrected, never
trusted.
Fields§
§freq_hz: u32Buzzer carrier frequency in Hz (0 = no carrier, a plain on/off envelope
for an active buzzer or LED). Clamped to MAX_CARRIER_HZ.
duty_pct: u8Carrier duty cycle as a percentage (0..=100). Clamped to 100.
on_ms: u32Milliseconds the line is held high per cycle.
off_ms: u32Milliseconds the line is held low between cycles.
cycles: u32Number of on/off cycles to run.
Implementations§
Source§impl BeepPattern
impl BeepPattern
Sourcepub fn clamp(self) -> Self
pub fn clamp(self) -> Self
Clamp every field into the safe bounds. duty_pct is capped at 100,
freq_hz at MAX_CARRIER_HZ, on_ms/off_ms at MAX_PHASE_MS,
cycles at MAX_BEEP_CYCLES. Idempotent: clamping an already-clamped
pattern is a no-op.
Trait Implementations§
Source§impl Clone for BeepPattern
impl Clone for BeepPattern
impl Copy for BeepPattern
Source§impl Debug for BeepPattern
impl Debug for BeepPattern
Source§impl<'de> Deserialize<'de> for BeepPattern
impl<'de> Deserialize<'de> for BeepPattern
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for BeepPattern
Source§impl PartialEq for BeepPattern
impl PartialEq for BeepPattern
Source§impl Serialize for BeepPattern
impl Serialize for BeepPattern
impl StructuralPartialEq for BeepPattern
Auto Trait Implementations§
impl Freeze for BeepPattern
impl RefUnwindSafe for BeepPattern
impl Send for BeepPattern
impl Sync for BeepPattern
impl Unpin for BeepPattern
impl UnsafeUnpin for BeepPattern
impl UnwindSafe for BeepPattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.