Struct launchy::launchpad_s::Output
source · pub struct Output { /* private fields */ }
Expand description
The Launchpad S output connection handler.
Double buffering
To make more economical use of data, the Launchpad has a feature called double buffering. Essentially, Launchpad manages two sets of LED data - buffers - for each pad. By default, these are configured so that the buffer that is updated by incoming MIDI messages is the same as the one that is visible, so that note-on messages immediately change their respective pads. However, the buffers can also be configured so that Launchpad’s LED status is updated invisibly. With a single command, these buffers can then be swapped. The pads will instantly update to show their pre-programmed state, while the pads can again be updated invisibly ready for the next swap. The visible buffer can alternatively be configured to swap automatically at 280ms intervals in order to configure LEDs to flash.
Implementations§
source§impl Output
impl Output
Updates the state for a single LED, specified by button
. The color, as well as the double
buffering attributes, are specified in light_state
.
In order to make maximum use of the original Launchpad’s slow midi speeds, a rapid LED lighting mode was invented which allows the lighting of two leds in just a single message. To use this mode, simply start sending these message and the Launchpad will update the 8x8 grid in left-to-right, top-to-bottom order, then the eight scene launch buttons in top-to-bottom order, and finally the eight Automap/Live buttons in left-to-right order (these are otherwise inaccessible using note-on messages). Overflowing data will be ignored.
To leave the mode, simply send any other message. Sending another kind of message and then re-sending this message will reset the cursor to the top left of the grid.
sourcepub fn turn_on_all_leds(
&mut self,
brightness: Brightness
) -> Result<(), MidiError>
pub fn turn_on_all_leds( &mut self, brightness: Brightness ) -> Result<(), MidiError>
Turns on all LEDs to a certain brightness, dictated by the brightness
parameter. According
to the Launchpad documentation, sending this command resets various configuration settings -
see reset()
for more information. However, in my experience, that only sometimes happens.
Weird.
This function is primarily intended as a diagnostics tool to verify that the library and the device is working correctly.
sourcepub fn set_duty_cycle(
&mut self,
numerator: u8,
denominator: u8
) -> Result<(), MidiError>
pub fn set_duty_cycle( &mut self, numerator: u8, denominator: u8 ) -> Result<(), MidiError>
Launchpad controls the brightness of its LEDs by continually switching them on and off faster than the eye can see: a technique known as multiplexing. This command provides a way of altering the proportion of time for which the LEDs are on while they are in low- and medium-brightness modes. This proportion is known as the duty cycle.
Manipulating this is useful for fade effects, for adjusting contrast, and for creating custom palettes.
The default duty cycle is 1/5 meaning that low-brightness LEDs are on for only every fifth multiplex pass, and medium-brightness LEDs are on for two passes in every five. Generally, lower duty cycles (numbers closer to zero) will increase contrast between different brightness settings but will also increase flicker; higher ones will eliminate flicker, but will also reduce contrast. Note that using less simple ratios (such as 3/17 or 2/11) can also increase perceived flicker.
If you are particularly sensitive to strobing lights, please use this command with care when working with large areas of low-brightness LEDs: in particular, avoid duty cycles of 1/8 or less.
sourcepub fn control_double_buffering(
&mut self,
d: DoubleBuffering
) -> Result<(), MidiError>
pub fn control_double_buffering( &mut self, d: DoubleBuffering ) -> Result<(), MidiError>
This method controls the double buffering mode on the Launchpad. See the module documentation for an explanation on double buffering.
The default state is no flashing; the first buffer is both the update and the displayed buffer: In this mode, any LED data written to Launchpad is displayed instantly. Sending this message also resets the flash timer, so it can be used to resynchronise the flash rates of all the Launchpads connected to a system.
- If
copy
is set, copy the LED states from the new displayed buffer to the new updating buffer. - If
flash
is set, continually flip displayed buffers to make selected LEDs flash. updated
: the new updated bufferdisplayed
: the new displayed buffer
pub fn request_device_inquiry( &mut self, query: DeviceIdQuery ) -> Result<(), MidiError>
pub fn request_version_inquiry(&mut self) -> Result<(), MidiError>
pub fn scroll_text( &mut self, text: &[u8], color: Color, should_loop: bool ) -> Result<(), MidiError>
sourcepub fn reset(&mut self) -> Result<(), MidiError>
pub fn reset(&mut self) -> Result<(), MidiError>
All LEDs are turned off, and the mapping mode, buffer settings, and duty cycle are reset to their default values.