Struct TimedSignal

Source
pub struct TimedSignal { /* private fields */ }
Expand description

Signal state and scheduled tick action.

Implementations§

Source§

impl TimedSignal

Source

pub fn new() -> Self

Return a new instance.

Source

pub fn update(&mut self, tick: u64) -> bool

Update internals and return state. When an action is scheduled and tick reaches the specific value for that action, the state is updated accordingly.

Source

pub fn state(&self) -> bool

Return current state.

Source

pub fn set_inverted(&mut self, inverted: bool)

Set inverted state on/off.

Source

pub fn is_inverted(&self) -> bool

Return if state is inverted.

Source

pub fn set(&mut self, state: bool)

Set state according to a boolean value.

Source

pub fn on(&mut self)

Set on state.

Source

pub fn off(&mut self)

Set off state.

Source

pub fn toggle(&mut self)

Toggle state.

Toggle state at a predefined rate with a 50% ratio. period is the number of ticks for one period. E.g. if set to 4, the state will be on for 2 ticks and off for another 2 ticks.

Source

pub fn set_at(&mut self, trigger_tick: u64, state: bool)

Set a state when a tick is reached.

Source

pub fn set_until(&mut self, trigger_tick: u64, state: bool)

Set a state until a tick is reached, then return to previous state.

Source

pub fn set_for(&mut self, duration_ticks: u64, state: bool)

Set a state for a number of ticks, then invert it. Single trigger.

Source

pub fn set_for_retrigger(&mut self, duration_ticks: u64, state: bool)

Set a state for a number of ticks, then invert it. Retrigger.

Source

pub fn on_at(&mut self, trigger_tick: u64)

Set on state when a tick is reached.

Source

pub fn on_until(&mut self, trigger_tick: u64)

Set on state until a tick is reached, then set it off.

Source

pub fn on_for(&mut self, duration_ticks: u64)

Set on state for a number of ticks, then set it off.

Source

pub fn off_at(&mut self, trigger_tick: u64)

Set off state when a tick is reached.

Source

pub fn off_until(&mut self, trigger_tick: u64)

Set off state until a tick is reached, then set it on.

Source

pub fn off_for(&mut self, duration_ticks: u64)

Set off state for a number of ticks, then set it on.

Source

pub fn toggle_at(&mut self, trigger_tick: u64)

Toggle state when a tick is reached.

Source

pub fn toggle_until(&mut self, trigger_tick: u64)

Toggle state until a tick is reached, then return to previous state.

Source

pub fn toggle_for(&mut self, duration_ticks: u64)

Toggle state for a number of ticks, then return to previous state. Single trigger.

Source

pub fn toggle_for_retrigger(&mut self, duration_ticks: u64)

Toggle state for a number of ticks, then return to previous state. Retrigger.

Trait Implementations§

Source§

impl Clone for TimedSignal

Source§

fn clone(&self) -> TimedSignal

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimedSignal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TimedSignal

Source§

fn default() -> TimedSignal

Returns the “default value” for a type. Read more
Source§

impl PartialEq for TimedSignal

Source§

fn eq(&self, other: &TimedSignal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TimedSignal

Source§

impl StructuralPartialEq for TimedSignal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.