[][src]Crate launchy

An interfacing library for your Novation Launchpads, providing both low-level access as well as powerful high-level abstractions.

High-level access through the Canvas API

High-level access is possible through the Canvas API. The Canvas trait simply represents a grid of LEDs that can be written to, and consequently flushed to the actual hardware. A number of high-level utilities make the Canvas API a pleasure to use.

use launchy::{CanvasMessage, Color};

let (mut canvas, input_poller) = launchy::s::Canvas::guess_polling()?;

for msg in input_poller.iter() {
	match msg {
		CanvasMessage::Press { pad } => canvas[pad] = Color::WHITE,
		CanvasMessage::Release { pad } => canvas[pad] = Color::BLACK,

The above match statement could also be written in a more concise way:

canvas[msg.pad()] = if msg.is_press() { Color::WHITE } else { Color::BLACK };

Low-level access

Low-level access is provided via the Input and Output structs. Care has been taken to ensure that this library has 100% coverage of the Launchpads' functionality: all documented Launchpad features are accessible in Launchy's low-level API.

This means you get the real deal: rapid LED updates, double buffering capabilities, device and firmware information.

Furthermore, we know that a low-level API is not the place for hidden abstractions - and that's why every function in Launchy's low-level APIs corresponds to exactly one MIDI message (unless noted otherwise in the documentation). That way, the user has fine control over the data that's actually being sent.

Using double-buffering to produce a continuous red flash

use launchy::Color;
use launchy::s::{DoubleBuffering, DoubleBufferingBehavior, Buffer};

let mut output = launchy::s::Output::guess()?;

// Start editing buffer A
output.control_double_buffering(DoubleBuffering {
	copy: false,
	flash: false,
	edited_buffer: Buffer::A,
	displayed_buffer: Buffer::B,

// Light all buttons red, using the rapid update feature - just 40 midi messages
for _ in 0..40 {
		Color::RED, DoubleBufferingBehavior::None,
		Color::RED, DoubleBufferingBehavior::None,

// Now buffer A is completely red and B is empty. Let's leverage the Launchpad S flash
// feature to continually flash between both buffers, producing a red flash:
output.control_double_buffering(DoubleBuffering {
	copy: false,
	flash: true, // this is the important bit
	edited_buffer: Buffer::A,
	displayed_buffer: Buffer::A,


pub use launchpad_s as s;
pub use launchpad_mk2 as mk2;
pub use launch_control as control;
pub use launch_control as launch_control_xl;
pub use launch_control as control_xl;



Launch Control low-level API


Launchpad MK2 low-level API


Launchpad S low-level API




An iterator over the buttons of a given Canvas. Create an iterator by calling .iter() on a Canvas.


Imagine this - you have multiple launchpads, you line them up, and now you use the Launchpads as if they were a single device?! You can do that, with CanvasLayout.


Utility to be able to process messages from a CanvasLayout by polling


A simple float-based color struct. Each component should lie in 0..=1, but it can also be outside that range. If outside, it will be clipped for some operations


A generic Canvas implementation for all launchpads, that relies on a DeviceSpec. You as a user of the library don't need to access this struct directly. Use the "Canvas" type aliases that each launchpad module provides, for example launchy::mk2::Canvas or launchy::s::Canvas.


Utility to be able to process messages from a CanvasLayout by polling


A handler for a Launchpad input connection. This variant is used when an input connection is initiated with callback


A handler for a Launchpad input connection that can be polled for new messages. The actual polling methods are implemented inside MsgPollingWrapper. Look there for documentation on how to poll messages.


An iterator that yields canvas input messages for some user-defined time duration. For more information, see MsgPollingWrapper::iter_for


A 2d point that represents a single pad on a grid of pads. For convenience, the coordinates can be negative.


A canvas wrapper that fills holes and other irregularities to provide a perfectly rectangular grid.





A trait that abstracts over the specifics of a Launchpad and allows generic access and manipulation of a Launchpad's LEDs.


Launchpad's implement this trait to signify how they can be used as a Canvas. Based on this specification, DeviceCanvas provides a generic Canvas implemention that can be used for all devices.