pub struct Lights { /* private fields */ }Expand description
Implementations§
Source§impl Lights
impl Lights
Sourcepub const COUNT: usize
pub const COUNT: usize
The number of lights on Boppo. Each button has four lights.
NOTE: that this is not the number of lights in this selection
which is obtained by calling self.len()
Sourcepub fn from_slice(arr: &[bool]) -> Lights
pub fn from_slice(arr: &[bool]) -> Lights
Returns a selection containing all indices marked true in arr.
§Panics
This function will panic if arr.len() > Lights::COUNT
Sourcepub const fn from_index(light_index: usize) -> Lights
pub const fn from_index(light_index: usize) -> Lights
Returns a Lights with only the light at light_index selected.
Sourcepub fn from_indices<I>(indexes: I) -> Lightswhere
I: IntoIterator<Item = usize>,
pub fn from_indices<I>(indexes: I) -> Lightswhere
I: IntoIterator<Item = usize>,
Sourcepub const fn from_bitset(bits: u64) -> Lights
pub const fn from_bitset(bits: u64) -> Lights
Returns a new Lights with bits.
Each bit in bits represents whether an individual light has been selected.
The least significant bit selects Button::B0.light_at(LightDir::Top).
§Ordering
See Lights ordering.
§Panics
This function will panic if bits >> Lights::COUNT != 0.
All 4 lights of button
Sourcepub const fn is_superset(&self, other: Self) -> bool
pub const fn is_superset(&self, other: Self) -> bool
Returns true if other selects only lights that self selects.
See also Lights::is_subset
Sourcepub const fn is_subset(&self, other: Self) -> bool
pub const fn is_subset(&self, other: Self) -> bool
Returns true if self selects only lights that other selects.
See also Lights::is_superset
Sourcepub const fn indices(&self) -> impl DoubleEndedIterator<Item = usize> + use<>
pub const fn indices(&self) -> impl DoubleEndedIterator<Item = usize> + use<>
Returns a double-ended iterator over the indices of every light in this selection.
Sourcepub fn choose_n_randomly(&self, n: usize) -> Lights
pub fn choose_n_randomly(&self, n: usize) -> Lights
Randomly choose n of the lights that are active in self.
Sourcepub const fn rotate_180(&self) -> Lights
pub const fn rotate_180(&self) -> Lights
Return the Lights as if the device was rotated 180 degrees. Light 0 becomes 39, 1 becomes 38…
Sourcepub const fn as_bitset(&self) -> u64
pub const fn as_bitset(&self) -> u64
A compact representation. The least significant bit represents if light 0 is selected…
Sourcepub fn set_colors(self, colors: &[RGB])
pub fn set_colors(self, colors: &[RGB])
Sets each light in this selection to the corresponding color in colors, up to exhaustion
of either the selection or colors.
Trait Implementations§
Source§impl BitAndAssign for Lights
impl BitAndAssign for Lights
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOrAssign for Lights
impl BitOrAssign for Lights
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitXorAssign for Lights
impl BitXorAssign for Lights
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read more