Struct blinkt::Blinkt
[−]
[src]
pub struct Blinkt { // some fields omitted }
Interface for a Blinkt! or any similar APA102 strips/boards.
By default, Blinkt is set up to communicate with an 8-pixel board through data pin 23 and clock pin 24. These settings can be changed to support alternate configurations.
Methods
impl Blinkt
[src]
fn new() -> Result<Blinkt>
Creates a new Blinkt
using the default settings for a Pimoroni
Blinkt! board.
This sets the data pin to 23, the clock pin to 24, and number of pixels to 8.
fn with_settings(pin_data: u8, pin_clock: u8, num_pixels: usize) -> Result<Blinkt>
Creates a new Blinkt
using custom settings for the data pin, clock
pin, and number of pixels.
fn set_clear_on_drop(&mut self, clear_on_drop: bool)
When enabled, clears all pixels when the Blinkt
goes out of scope.
Drop methods aren't called when a program is abnormally terminated,
for instance when a user presses Ctrl-C, and the SIGINT signal isn't
caught. You'll either have to catch those using crates such as
simple_signal
, or manually call cleanup()
.
Enabled by default.
fn cleanup(&mut self)
Changes the GPIO pin mode for the data and clock pins back to their original state, and optionally clears all pixels.
Normally, this method is automatically called when Blinkt goes out of
scope, but you can manually call it to handle early/abnormal termination.
After calling this method, any future calls to show()
won't have any
result.
fn set_pixel(&mut self, pixel: usize, red: u8, green: u8, blue: u8)
Sets the red, green and blue values for a single pixel in the local buffer.
For an 8-pixel board, valid values for pixel are 0-7. Valid values for red, green and blue are 0-255.
fn set_pixel_rgbb(&mut self, pixel: usize, red: u8, green: u8, blue: u8, brightness: f32)
Sets the red, green, blue and brightness values for a single pixel in the local buffer.
For an 8-pixel board, valid values for pixel are 0-7. Valid values for red, green and blue are 0-255. Valid values for brightness are 0.0-1.0, which is converted to a 5-bit value.
fn set_pixel_brightness(&mut self, pixel: usize, brightness: f32)
Sets the brightness value for a single pixel in the local buffer.
For an 8-pixel board, valid values for pixel are 0-7. Valid values for brightness are 0.0-1.0, which is converted to a 5-bit value.
fn set_all_pixels(&mut self, red: u8, green: u8, blue: u8)
Sets the red, green and blue values for all pixels in the local buffer.
Valid values for red, green and blue are 0-255.
fn set_all_pixels_rgbb(&mut self, red: u8, green: u8, blue: u8, brightness: f32)
Sets the red, green, blue and brightness values for all pixels in the local buffer.
Valid values for red, green and blue are 0-255. Valid values for brightness are 0.0-1.0, which is converted to a 5-bit value.
fn set_all_pixels_brightness(&mut self, brightness: f32)
Sets the brightness value for all pixels in the local buffer.
Valid values for brightness are 0.0-1.0, which is converted to a 5-bit value.
fn clear(&mut self)
Sets the red, green and blue values to 0 for all pixels in the local buffer.
fn show(&self)
Sends the contents of the local buffer to the pixels, updating their LED colors and brightness.