[][src]Trait joycon_rs::joycon::lights::Lights

pub trait Lights: JoyConDriver {
    const LIGHT_UP: [LightUp; 4];
    const FLASH: [Flash; 4];
    fn set_player_lights(
        &mut self,
        light_up: &Vec<LightUp>,
        flash: &Vec<Flash>
    ) -> JoyConResult<[u8; 362]> { ... }
fn get_player_lights(
        &mut self
    ) -> JoyConResult<StandardInputReport<SubCommandReport<LightsStatus>>>
    where
        Self: Sized
, { ... }
fn set_home_light(
        &mut self,
        pattern: &LightEmittingPattern
    ) -> JoyConResult<[u8; 362]> { ... } }

Operations of player lights.

Associated Constants

Loading content...

Provided methods

fn set_player_lights(
    &mut self,
    light_up: &Vec<LightUp>,
    flash: &Vec<Flash>
) -> JoyConResult<[u8; 362]>

Light up or flash LEDs on controller, vice versa.

Example

If you run this code,

use joycon_rs::prelude::{*, lights::*};

// some code omitted
joycon_driver.set_player_lights(&vec![LightUp::LED0],&vec![]).unwrap();

player lights will be...

[SL Button] 💡🤔🤔🤔 [SR Button]

For another example,

joycon_driver.set_player_lights(&vec![LightUp::LED2], &vec![Flash::LED3]).unwrap();

player lights will be...

[SL Button] 🤔🤔💡📸 [SR Button]

Duplication

If a command to a certain LED is duplicated, the lighting command takes precedence.

joycon_driver.set_player_lights(&vec![LightUp::LED1], &vec![Flash::LED1]).unwrap();

Player lights will be...

[SL Button] 🤔💡🤔🤔 [SR Button]

fn get_player_lights(
    &mut self
) -> JoyConResult<StandardInputReport<SubCommandReport<LightsStatus>>> where
    Self: Sized

Get status of player lights on controller.

Example

use joycon_rs::prelude::{*, lights::*};

let player_lights_status = joycon_driver.get_player_lights()
    .unwrap()
    .extra;
dbg!(player_lights_status);

fn set_home_light(
    &mut self,
    pattern: &LightEmittingPattern
) -> JoyConResult<[u8; 362]>

Set HOME light.

Example

use joycon_rs::prelude::{*, lights::{*, home_button::*}};

let pattern =
    // loop pattern forever
    LightEmittingPattern::new(100, 0, 0u8.into())
        // 0.5 seconds to light up
        .add_phase(100,500,0)
        // 0.5 seconds to turn off
        .add_phase(0,500,0);
let player_lights_status = joycon_driver.set_home_light(&pattern);
Loading content...

Implementors

impl<D> Lights for D where
    D: JoyConDriver
[src]

Loading content...