[][src]Struct lp_tetris::Pad

pub struct Pad {
    pub x: u8,
    pub y: u8,
}

Represents a pad on the Launchpad Provides methods to convert to and from a note byte

Fields

x: u8y: u8

Methods

impl Pad[src]

pub fn note(&self) -> u8[src]

Returns the MIDI note corresponding to the pad.

assert_eq!(Pad { x: 0, y: 0 }.note(), 11);

assert_eq!(Pad { x: 7, y: 0 }.note(), 18);

assert_eq!(Pad { x: 0, y: 7 }.note(), 81);

assert_eq!(Pad { x: 7, y: 7 }.note(), 88);

This is the inverse of ::from_note

let pad = Pad { x: 3, y: 5 };
assert_eq!(pad, Pad::from_note(pad.note()));

pub fn from_note(note: u8) -> Pad[src]

Returns a Pad corresponding to the given MIDI note.

assert_eq!(Pad { x: 0, y: 0 }, Pad::from_note(11));

assert_eq!(Pad { x: 7, y: 0 }, Pad::from_note(18));

assert_eq!(Pad { x: 0, y: 7 }, Pad::from_note(81));

assert_eq!(Pad { x: 7, y: 7 }, Pad::from_note(88));

This is the inverse of .note

let note = 0x22;
assert_eq!(note, Pad::from_note(note).note());

Trait Implementations

impl Clone for Pad[src]

impl Copy for Pad[src]

impl Debug for Pad[src]

impl PartialEq<Pad> for Pad[src]

impl StructuralPartialEq for Pad[src]

Auto Trait Implementations

impl RefUnwindSafe for Pad

impl Send for Pad

impl Sync for Pad

impl Unpin for Pad

impl UnwindSafe for Pad

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.