Skip to content

lhpt2/launchpad_mini_control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Launchpad_Mini_Control

Overview

This is a low level library for communicating with the Launchpad Mini. It provides functionality to set the LED lights, read button presses and make use of features like double buffering.

Devices known to work

So far testing has only be done with the Launchpad Mini MK 1.

Example

[dependencies]
launchpad_mini_control = "0.1.0"

Then, on your main.rs:

use launchpad_mini_control::{MidiImpl, MatPos};

fn main() {
    let midi: MidiImpl = MidiImpl::new().expect("initialization");
    let mut lpad = launchpad_mini_control::new_launch_device_from_midi_interface(&midi);
    
    // reset Launchpad
    lpad.reset().unwrap();
    
    // set row 3, column 5 to MedYellow
    lpad.set_position(3_u8, 5_u8, Color::MedYellow).unwrap();
    
    // wait for button presses and print to terminal 
    loop {
        std::thread::sleep(Duration::from_millis(700));
        if lpad.poll().is_ok() {
            if let Some(buf) = lpad.read_single_msg().expect("valid read") {
                println!("{:?}", buf);
                println!();
                let tappos = MatPos::from(buf);
                println!("{:?}", tappos);
                if tappos.get_as_tuple() == (3_u8, 5_u8) {
                    lpad.blackout().unwrap();
                    lpad.set_all(Color::Green).unwrap();
                    lpad.set_position(2, 5, Color::DimGreen).unwrap();
                }
            }
        }
    }
}

Adding another backend

For adding another backend apart from Portmidi:

  • add library to Cargo.toml
  • implement traits in midilib.rs in own module (like in pm_impl.rs)
  • implement types InputPort, OutputPort and MidiImpl (like in pm_impl.rs)
  • expose module in lib.rs (see lib.rs)

Contributing

🎈 Thanks for your help improving the project! Just fork the project and create a pull request with an appropriate description, we will find a way to include the suggested changes into the project.

License

This project is licensed under the LGPL license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Launchpad_Mini_Control by you, shall be licensed as LGPLv3+, without any additional terms or conditions.

About

low level access communication library for Launchpad Mini

Resources

License

Stars

Watchers

Forks

Languages