Struct blinkt::Blinkt

source ·
pub struct Blinkt { /* private fields */ }
Expand description

Interface for the Pimoroni Blinkt!, and any similar APA102 or SK9822 LED strips or boards.

By default, Blinkt is set up to communicate with an 8-pixel board through data pin GPIO 23 (physical pin 16) and clock pin GPIO 24 (physical pin 18). These settings can be changed to support alternate configurations.

Implementations

Creates a new Blinkt using the default settings for a Pimoroni Blinkt! board.

This sets the data pin to GPIO 23 (physical pin 16), the clock pin to GPIO 24 (physical pin 18), and number of pixels to 8.

Creates a new Blinkt using bitbanging mode, with custom settings for the data pin, clock pin, and number of pixels. Pins should be specified by their BCM GPIO pin numbers.

Creates a new Blinkt using hardware SPI, with custom settings for the clock speed and number of pixels.

This sets the data pin to GPIO 10 (physical pin 19) and the clock pin to GPIO 11 (physical pin 23).

The Raspberry Pi allows SPI clock speeds up to 125MHz (125_000_000), but the maximum speed supported by LED strips depends a lot on the number of pixels and wire quality, and requires some experimentation. 32MHz (32_000_000) seems to be the maximum clock speed for a typical short LED strip. Visit the Raspberry Pi SPI Documentation page for a complete list of supported clock speeds.

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.

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.

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.

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.

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.

Sets the red, green and blue values for all pixels in the local buffer.

Valid values for red, green and blue are 0-255.

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.

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.

Sets the red, green and blue values to 0 for all pixels in the local buffer.

Sends the contents of the local buffer to the pixels, updating their LED colors and brightness.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.