Skip to main content

Lights

Struct Lights 

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

A selection of button lights on the tablet. There are 10 buttons with 4 lights each for a total of 40 lights.

§Ordering

The order is in `Button’ order from Button::B0 to Button::B9 where each button has 4 lights together in the following order:

  • “Top”
  • “Left”
  • “Right”
  • “Bottom”

Implementations§

Source§

impl Lights

Source

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()

Source

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

Source

pub const fn from_index(light_index: usize) -> Lights

Returns a Lights with only the light at light_index selected.

Source

pub fn from_indices<I>(indexes: I) -> Lights
where I: IntoIterator<Item = usize>,

Returns a new Lights constructed from light indices contained in indexes.

§Panics

This function will panic if indexes contains an index >= Lights::COUNT.

Source

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::B1.light_at(LightDir::Top).

§Ordering

See Lights ordering.

§Panics

This function will panic if bits >> Lights::COUNT != 0.

Source

pub const fn all_from_button(button: Button) -> Lights

All 4 lights of button

Source

pub const fn all() -> Lights

Returns a Lights with every light selected

Source

pub const fn none() -> Lights

Returns a Lights with no light selected

Source

pub fn len(&self) -> u32

Returns the number of lights in this selection.

Source

pub fn is_empty(&self) -> bool

Returns true if no lights are selected.

Source

pub fn is_superset(&self, other: Self) -> bool

Returns true if other selects only buttons that self selects.

See also Lights::is_subset

Source

pub fn is_subset(&self, other: Self) -> bool

Returns true if other selects only buttons that self selects.

See also Lights::is_superset

Source

pub fn indices(&self) -> impl DoubleEndedIterator<Item = usize> + use<>

Returns a double-ended iterator over the indices of every Button in this selection.

Source

pub const fn invert(&self) -> Lights

Returns the inversion of the current selection.

Source

pub fn choose_n_randomly(&self, n: usize) -> Lights

Randomly choose n of the lights that are active in self.

Source

pub fn rotate_180(&self) -> Lights

Return the Lights as if the device was rotate 180 degrees. Light 0 becomes 39, 1 becomes 38…

Source

pub const fn as_bitset(&self) -> u64

A compact representation. The least significant bit represents if button 1 is pressed…

Source

pub fn set_color(self, color: RGB)

Sets all lights in this selection to color

Source

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.

Source

pub const fn only(self, dir: LightDir) -> Lights

Returns a new Lights with only the lights in the dir direction from this selection.

Trait Implementations§

Source§

impl BitAnd for Lights

Source§

type Output = Lights

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for Lights

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for Lights

Source§

type Output = Lights

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign for Lights

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl BitXor for Lights

Source§

type Output = Lights

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXorAssign for Lights

Source§

fn bitxor_assign(&mut self, rhs: Self)

Performs the ^= operation. Read more
Source§

impl Clone for Lights

Source§

fn clone(&self) -> Lights

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Lights

Source§

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

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

impl From<Button> for Lights

Source§

fn from(button: Button) -> Self

Converts to this type from the input type.
Source§

impl From<Buttons> for Lights

Source§

fn from(buttons: Buttons) -> Self

Converts to this type from the input type.
Source§

impl IntoIterator for Lights

Source§

fn into_iter(self) -> Self::IntoIter

Iterates in order of index.

Source§

type Item = (Button, LightDir)

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = (Button, LightDir)>>

Which kind of iterator are we turning this into?
Source§

impl Not for Lights

Source§

type Output = Lights

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl Ord for Lights

Source§

fn cmp(&self, other: &Lights) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Lights

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 PartialOrd for Lights

Source§

fn partial_cmp(&self, other: &Lights) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Lights

Source§

impl Eq for Lights

Source§

impl StructuralPartialEq for Lights

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V