#[repr(u8)]pub enum TriggerCondition {
Show 14 variants
None = 0,
Switch {
state: Phro,
index: u16,
loop_condition_index: u16,
},
HidLed {
state: Aodo,
loop_condition_index: u16,
index: u8,
},
AnalogDistance {
reserved: u8,
index: u16,
val: i16,
},
AnalogVelocity {
reserved: u8,
index: u16,
val: i16,
},
AnalogAcceleration {
reserved: u8,
index: u16,
val: i16,
},
AnalogJerk {
reserved: u8,
index: u16,
val: i16,
},
Layer {
state: LayerState,
loop_condition_index: u16,
layer: u8,
},
Animation {
state: Dro,
index: u16,
loop_condition_index: u16,
},
Sleep {
state: Aodo,
loop_condition_index: u16,
},
Resume {
state: Aodo,
loop_condition_index: u16,
},
Inactive {
state: Aodo,
loop_condition_index: u16,
},
Active {
state: Aodo,
loop_condition_index: u16,
},
Rotation {
index: u8,
loop_condition_index: u16,
position: i8,
},
}
Expand description
Trigger condition definitions
XXX (HaaTa): Field order is extremely important. Rust will optimize field packing if done correctly. Static assertions are included to prevent bad mistakes. Changing the enum size is an API breaking change (requires KLL compiler updates).
Variants§
None = 0
Switch
6 bytes
Fields
HidLed
5 bytes
Fields
AnalogDistance
6 bytes
Fields
AnalogVelocity
6 bytes
Fields
AnalogAcceleration
6 bytes
Fields
AnalogJerk
6 bytes
Fields
Layer
5 bytes
Fields
state: LayerState
Layer state
Animation
6 bytes
Fields
Sleep
Sleep events are always index 0 4 bytes
Fields
Resume
Resume events are always index 0 4 bytes
Fields
Inactive
Inactive events are always index 0 4 bytes
Fields
Active
Active events are always index 0 4 bytes
Fields
Rotation
5 bytes
Implementations§
Source§impl TriggerCondition
impl TriggerCondition
Sourcepub const unsafe fn from_byte_array(bytes: [u8; 6]) -> Self
pub const unsafe fn from_byte_array(bytes: [u8; 6]) -> Self
Convert array of bytes to enum
§Safety
Sourcepub const unsafe fn from_bytes(bytes: &[u8]) -> Self
pub const unsafe fn from_bytes(bytes: &[u8]) -> Self
Convert slice of bytes to enum Aggressively casts the provide u8 slice to retrieve a TriggerCondition
§Safety
Sourcepub fn index(&self) -> u16
pub fn index(&self) -> u16
Attempts to determine the index value of the condition If an index is not valid, return 0 instead (index may not have any meaning)
Sourcepub fn evaluate(
&self,
event: TriggerEvent,
loop_condition_lookup: &[u32],
) -> Vote
pub fn evaluate( &self, event: TriggerEvent, loop_condition_lookup: &[u32], ) -> Vote
Compare TriggerEvent to TriggerCondition NOTE: This is not a direct equivalent comparison each type and state can influence how the loop_condition_index is evaluated. In a way, this is similar to the voting scheme of the older C KLL implementation.
Trait Implementations§
Source§impl Clone for TriggerCondition
impl Clone for TriggerCondition
Source§fn clone(&self) -> TriggerCondition
fn clone(&self) -> TriggerCondition
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TriggerCondition
impl Debug for TriggerCondition
Source§impl From<TriggerCondition> for TriggerEvent
Convert TriggerCondition to TriggerEvent
Used for mainly for kll validation, events are time index 0
and are assumed to be immediate with no history
impl From<TriggerCondition> for TriggerEvent
Convert TriggerCondition to TriggerEvent Used for mainly for kll validation, events are time index 0 and are assumed to be immediate with no history
Source§fn from(cond: TriggerCondition) -> Self
fn from(cond: TriggerCondition) -> Self
Source§impl From<TriggerCondition> for u8
Convert TriggerCondition into the u8 identifier
impl From<TriggerCondition> for u8
Convert TriggerCondition into the u8 identifier