libblinkstick
A library for the blinkstick LED controller
|
Header for libBlinkStick. More...
#include <hidapi.h>
#include <stdbool.h>
Go to the source code of this file.
Classes | |
struct | blinkstick_device |
A blinkstick_device holds a pointer to the hid device and is used when setting colors, modes, or turning the device off. More... | |
struct | blinkstick_color |
Typedefs | |
typedef struct blinkstick_device | blinkstick_device |
A blinkstick_device holds a pointer to the hid device and is used when setting colors, modes, or turning the device off. | |
typedef struct blinkstick_color | blinkstick_color |
Enumerations | |
enum | blinkstick_mode { unknown =-1 , normal =0 , inverse =1 , smart_pixel =2 } |
Possible blink stick modes (only valid for Blinkstick Pro). | |
Functions | |
BLINKSTICK_API blinkstick_device ** | blinkstick_find_many (const int count) |
Given a count will return a pointer array of blinkstick devices. This will abort if the number found is less than the given count. | |
BLINKSTICK_API blinkstick_device * | blinkstick_find () |
Find the first blinkstick device on the bus registered with HID. | |
BLINKSTICK_API bool | blinkstick_set_color (blinkstick_device *blinkstick, const int channel, const int index, const int red, const int green, const int blue) |
Sets the LED at the given index and channel to the specified color for the provided device. | |
BLINKSTICK_API blinkstick_color * | blinkstick_get_color (struct blinkstick_device *blinkstick, const int index) |
Reads the color from the blinkstick at a given index. | |
BLINKSTICK_API bool | blinkstick_set_mode (blinkstick_device *blinkstick, enum blinkstick_mode mode) |
Set the mode of the blinkstick. | |
BLINKSTICK_API enum blinkstick_mode | blinkstick_get_mode (blinkstick_device *blinkstick) |
Read the mode currently set on the blinkstick. | |
BLINKSTICK_API bool | blinkstick_off (blinkstick_device *blinkstick, const int channel, const int index) |
Turns off the led at the specified index for the provided device. This is the same as using set_color with the RGB value (0, 0, 0) | |
BLINKSTICK_API void | blinkstick_debug () |
Turns on debug logging. | |
BLINKSTICK_API void | blinkstick_destroy (blinkstick_device *device) |
Frees the given blinkstick device. | |
Header for libBlinkStick.
libBlinkStick is meant to to be a simple library for talking to a blinkstick. The BlinkStick Square, BlinkStick v1.1, and the BlinkStick Pro are officially supported and it's likely that other devices work as well.
libBlinkStick depends on hidapi for interacting with the USB devices, but otherwise has no other dependencies.
Included are functions to turn on and off any of the LEDs and change their color via an rgb color. Multiple devices are supported.
typedef struct blinkstick_device blinkstick_device |
A blinkstick_device holds a pointer to the hid device and is used when setting colors, modes, or turning the device off.
Construct this device by using blinkstick_find and free it with blinkstick_destroy. Example:
BLINKSTICK_API void blinkstick_destroy | ( | blinkstick_device * | device | ) |
Frees the given blinkstick device.
device | the device to free. |
BLINKSTICK_API blinkstick_device * blinkstick_find | ( | ) |
Find the first blinkstick device on the bus registered with HID.
Note the caller is responsible for deleting the instance of the blinkstick_device using blinkstick_destroy.
BLINKSTICK_API blinkstick_device ** blinkstick_find_many | ( | const int | count | ) |
Given a count will return a pointer array of blinkstick devices. This will abort if the number found is less than the given count.
count | the number of blinkstick devices to find. |
BLINKSTICK_API blinkstick_color * blinkstick_get_color | ( | struct blinkstick_device * | blinkstick, |
const int | index ) |
Reads the color from the blinkstick at a given index.
blinkstick | pointer to the blinckstick_device to read from. |
index | the index of the LED to read from. |
BLINKSTICK_API enum blinkstick_mode blinkstick_get_mode | ( | blinkstick_device * | blinkstick | ) |
Read the mode currently set on the blinkstick.
blinkstick | pointer to the blinkstick device. |
BLINKSTICK_API bool blinkstick_set_color | ( | blinkstick_device * | blinkstick, |
const int | channel, | ||
const int | index, | ||
const int | red, | ||
const int | green, | ||
const int | blue ) |
Sets the LED at the given index and channel to the specified color for the provided device.
blinkstick | pointer to the blinkstick_device to modify. |
channel | the channel to set the LED color on. |
index | which LED to set the color of. |
red | the red component of the new color. |
green | the green component of the new color. |
blue | the blue component of the new color. |
BLINKSTICK_API bool blinkstick_set_mode | ( | blinkstick_device * | blinkstick, |
enum blinkstick_mode | mode ) |
Set the mode of the blinkstick.
Possible modes are "normal" (non-inverse LED control), "inverse" (LED values are inverted) and "smart" (LEDs are WS2812 smart LEDs). Note that you'll need to implement a delay after setting the mode before setting the color on the blinkstick device.