C# Class BlinkStickDotNet.BlinkStick

A model of the BlinkStick device itself
Inheritance: IDisposable
Show file Open project: arvydas/BlinkStickDotNet Class Usage Examples

Protected Properties

Property Type Description
connectedToDriver bool

Public Methods

Method Description
Blink ( RgbColor color, int repeats = 1, int delay = 500 ) : void

Blink the LED.

Blink ( byte channel, byte index, RgbColor color, int repeats = 1, int delay = 500 ) : void

Blink the LED on BlinkStick Pro.

Blink ( byte channel, byte index, byte r, byte g, byte b, int repeats = 1, int delay = 500 ) : void

Blink the LED on BlinkStick Pro.

Blink ( byte r, byte g, byte b, int repeats = 1, int delay = 500 ) : void

Blink the LED.

Blink ( byte channel, byte index, string color, int repeats = 1, int delay = 500 ) : void

Blink the LED on BlinkStick Pro.

Blink ( string color, int repeats = 1, int delay = 500 ) : void

Blink the LED.

BlinkStick ( ) : System

Initializes a new instance of the BlinkStick class.

BlinkStickDeviceFromSerial ( string serial ) : BlinkStickDeviceEnum
CloseDevice ( ) : void

Closes the connection to the device.

Dispose ( ) : void

Disposes of the device and closes the connection.

Enable ( ) : void
FindAll ( ) : BlinkStickDotNet.BlinkStick[]

Find all BlinkStick devices.

FindBySerial ( String serial ) : BlinkStick

Finds BlinkStick by serial number.

FindFirst ( ) : BlinkStick

Find first BlinkStick.

GetColor ( byte &r, byte &g, byte &b ) : System.Boolean

Gets the color of the led.

GetColor ( byte index, byte &r, byte &g, byte &b ) : System.Boolean

Gets the color of the led.

GetColors ( byte &colorData ) : System.Boolean

Gets led data.

GetInfoBlock ( byte id, byte &data ) : System.Boolean

Gets the info block.

GetLedCount ( ) : int
GetMode ( ) : int

Gets the mode on BlinkStick Pro.

Morph ( RgbColor color, int duration = 1000, int steps = 50 ) : void

Morph from current color to new color.

Morph ( byte channel, byte index, RgbColor color, int duration = 1000, int steps = 50 ) : void

Morph from current color to new color on BlinkStick Pro.

Morph ( byte channel, byte index, byte r, byte g, byte b, int duration = 1000, int steps = 50 ) : void

Morph from current color to new color on BlinkStick Pro.

Morph ( byte r, byte g, byte b, int duration = 1000, int steps = 50 ) : void

Morph from current color to new color.

Morph ( byte channel, byte index, string color, int duration = 1000, int steps = 50 ) : void

Morph from current color to new color on BlinkStick Pro.

Morph ( string color, int duration = 1000, int steps = 50 ) : void

Morph from current color to new color.

OnReceiveColor ( byte index, byte &r, byte &g, byte &b ) : System.Boolean
OnSendColor ( byte channel, byte index, byte r, byte g, byte b ) : System.Boolean
OpenDevice ( ) : bool

Attempts to connect to a BlinkStick device. After a successful connection, a DeviceAttached event will normally be sent.

OpenDevice ( HidDevice adevice ) : bool

Opens the device.

Pulse ( RgbColor color, int repeats = 1, int duration = 1000, int steps = 50 ) : void

Pulse specified color.

Pulse ( byte channel, byte index, RgbColor color, int repeats = 1, int duration = 1000, int steps = 50 ) : void

Pulse specified color on BlinkStick Pro.

Pulse ( byte channel, byte index, byte r, byte g, byte b, int repeats = 1, int duration = 1000, int steps = 50 ) : void

Pulse specified color on BlinkStick Pro.

Pulse ( byte r, byte g, byte b, int repeats = 1, int duration = 1000, int steps = 50 ) : void

Pulse specified color.

Pulse ( byte channel, byte index, string color, int repeats = 1, int duration = 1000, int steps = 50 ) : void

Pulse specified color on BlinkStick Pro.

Pulse ( string color, int repeats = 1, int duration = 1000, int steps = 50 ) : void

Pulse specified color.

SetColor ( RgbColor color ) : void

Sets the color of the led.

SetColor ( String color ) : void

Sets the color of the led.

SetColor ( byte channel, byte index, RgbColor color ) : void

Sets the color of the led.

SetColor ( byte r, byte g, byte b ) : void

Sets the color of the led.

SetColor ( byte channel, byte index, byte r, byte g, byte b ) : void

Sets the color of the led.

SetColor ( byte channel, byte index, string color ) : void

Sets the color of the led.

SetColors ( byte channel, byte colorData ) : void

Send a packet of data to LEDs

SetLedCount ( byte count ) : void
SetMode ( byte mode ) : void

Sets the mode for BlinkStick Pro.

Stop ( ) : void
TurnOff ( ) : void

Turn BlinkStick off.

WaitThread ( long milliseconds ) : System.Boolean

Protected Methods

Method Description
SetInfoBlock ( byte id, byte data ) : void

Private Methods

Method Description
CheckRequiresSoftwareColorPatch ( ) : void

Checks if BlinkStick requires software color patch due to hardware bug.

Dispose ( bool disposing ) : void

Closes any connected devices.

GetFeature ( byte buffer ) : void
GetInfoBlock ( byte id, string &data ) : System.Boolean
InternalSetColor ( byte channel, byte index, byte r, byte g, byte b ) : void

Automatically sets the color of the device using either BlinkStick or BlinkStick Pro API

OpenCurrentDevice ( ) : bool

Opens the current device.

SetFeature ( byte buffer ) : void
SetInfoBlock ( byte id, string data ) : void

Sets the info block.

Method Details

Blink() public method

Blink the LED.
public Blink ( RgbColor color, int repeats = 1, int delay = 500 ) : void
color RgbColor Must be in #rrggbb format or named color ("red", "green", "blue")
repeats int How many times to repeat (default 1)
delay int Delay delay between on/off sequences (default 500)
return void

Blink() public method

Blink the LED on BlinkStick Pro.
public Blink ( byte channel, byte index, RgbColor color, int repeats = 1, int delay = 500 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
color RgbColor Color parameter as RgbColor class instance
repeats int How many times to repeat (default 1)
delay int Delay delay between on/off sequences (default 500)
return void

Blink() public method

Blink the LED on BlinkStick Pro.
public Blink ( byte channel, byte index, byte r, byte g, byte b, int repeats = 1, int delay = 500 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
r byte The red component.
g byte The green component.
b byte The blue component.
repeats int How many times to repeat (default 1)
delay int Delay delay between on/off sequences (default 500)
return void

Blink() public method

Blink the LED.
public Blink ( byte r, byte g, byte b, int repeats = 1, int delay = 500 ) : void
r byte The red component.
g byte The green component.
b byte The blue component.
repeats int How many times to repeat (default 1)
delay int Delay delay between on/off sequences (default 500)
return void

Blink() public method

Blink the LED on BlinkStick Pro.
public Blink ( byte channel, byte index, string color, int repeats = 1, int delay = 500 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
color string Must be in #rrggbb format or named color ("red", "green", "blue")
repeats int How many times to repeat (default 1)
delay int Delay delay between on/off sequences (default 500)
return void

Blink() public method

Blink the LED.
public Blink ( string color, int repeats = 1, int delay = 500 ) : void
color string Must be in #rrggbb format or named color ("red", "green", "blue")
repeats int How many times to repeat (default 1)
delay int Delay delay between on/off sequences (default 500)
return void

BlinkStick() public method

Initializes a new instance of the BlinkStick class.
public BlinkStick ( ) : System
return System

BlinkStickDeviceFromSerial() public static method

public static BlinkStickDeviceFromSerial ( string serial ) : BlinkStickDeviceEnum
serial string
return BlinkStickDeviceEnum

CloseDevice() public method

Closes the connection to the device.
public CloseDevice ( ) : void
return void

Dispose() public method

Disposes of the device and closes the connection.
public Dispose ( ) : void
return void

Enable() public method

public Enable ( ) : void
return void

FindAll() public static method

Find all BlinkStick devices.
public static FindAll ( ) : BlinkStickDotNet.BlinkStick[]
return BlinkStickDotNet.BlinkStick[]

FindBySerial() public static method

Finds BlinkStick by serial number.
public static FindBySerial ( String serial ) : BlinkStick
serial String Serial number to search for
return BlinkStick

FindFirst() public static method

Find first BlinkStick.
public static FindFirst ( ) : BlinkStick
return BlinkStick

GetColor() public method

Gets the color of the led.
public GetColor ( byte &r, byte &g, byte &b ) : System.Boolean
r byte The red component.
g byte The green component.
b byte The blue component.
return System.Boolean

GetColor() public method

Gets the color of the led.
public GetColor ( byte index, byte &r, byte &g, byte &b ) : System.Boolean
index byte
r byte The red component.
g byte The green component.
b byte The blue component.
return System.Boolean

GetColors() public method

Gets led data.
public GetColors ( byte &colorData ) : System.Boolean
colorData byte
return System.Boolean

GetInfoBlock() public method

Gets the info block.
public GetInfoBlock ( byte id, byte &data ) : System.Boolean
id byte Identifier.
data byte Data.
return System.Boolean

GetLedCount() public method

public GetLedCount ( ) : int
return int

GetMode() public method

Gets the mode on BlinkStick Pro.
public GetMode ( ) : int
return int

Morph() public method

Morph from current color to new color.
public Morph ( RgbColor color, int duration = 1000, int steps = 50 ) : void
color RgbColor Must be in #rrggbb format or named color ("red", "green", "blue")
duration int How long should the morph last
steps int How many steps for color changes
return void

Morph() public method

Morph from current color to new color on BlinkStick Pro.
public Morph ( byte channel, byte index, RgbColor color, int duration = 1000, int steps = 50 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
color RgbColor Color parameter as RgbColor class instance
duration int How long should the morph last
steps int How many steps for color changes
return void

Morph() public method

Morph from current color to new color on BlinkStick Pro.
public Morph ( byte channel, byte index, byte r, byte g, byte b, int duration = 1000, int steps = 50 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
r byte The red component.
g byte The green component.
b byte The blue component.
duration int How long should the morph last
steps int How many steps for color changes
return void

Morph() public method

Morph from current color to new color.
public Morph ( byte r, byte g, byte b, int duration = 1000, int steps = 50 ) : void
r byte The red component.
g byte The green component.
b byte The blue component.
duration int How long should the morph last
steps int How many steps for color changes
return void

Morph() public method

Morph from current color to new color on BlinkStick Pro.
public Morph ( byte channel, byte index, string color, int duration = 1000, int steps = 50 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
color string Must be in #rrggbb format or named color ("red", "green", "blue")
duration int How long should the morph last
steps int How many steps for color changes
return void

Morph() public method

Morph from current color to new color.
public Morph ( string color, int duration = 1000, int steps = 50 ) : void
color string Must be in #rrggbb format or named color ("red", "green", "blue")
duration int How long should the morph last
steps int How many steps for color changes
return void

OnReceiveColor() public method

public OnReceiveColor ( byte index, byte &r, byte &g, byte &b ) : System.Boolean
index byte
r byte
g byte
b byte
return System.Boolean

OnSendColor() public method

public OnSendColor ( byte channel, byte index, byte r, byte g, byte b ) : System.Boolean
channel byte
index byte
r byte
g byte
b byte
return System.Boolean

OpenDevice() public method

Attempts to connect to a BlinkStick device. After a successful connection, a DeviceAttached event will normally be sent.
public OpenDevice ( ) : bool
return bool

OpenDevice() public method

Opens the device.
public OpenDevice ( HidDevice adevice ) : bool
adevice HidLibrary.HidDevice Pass the parameter of HidDevice to open it directly
return bool

Pulse() public method

Pulse specified color.
public Pulse ( RgbColor color, int repeats = 1, int duration = 1000, int steps = 50 ) : void
color RgbColor Must be in #rrggbb format or named color ("red", "green", "blue")
repeats int
duration int How long should the morph last
steps int How many steps for color changes
return void

Pulse() public method

Pulse specified color on BlinkStick Pro.
public Pulse ( byte channel, byte index, RgbColor color, int repeats = 1, int duration = 1000, int steps = 50 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
color RgbColor Color parameter as RgbColor class instance
repeats int
duration int How long should the morph last
steps int How many steps for color changes
return void

Pulse() public method

Pulse specified color on BlinkStick Pro.
public Pulse ( byte channel, byte index, byte r, byte g, byte b, int repeats = 1, int duration = 1000, int steps = 50 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
r byte The red component.
g byte The green component.
b byte The blue component.
repeats int
duration int How long should the morph last
steps int How many steps for color changes
return void

Pulse() public method

Pulse specified color.
public Pulse ( byte r, byte g, byte b, int repeats = 1, int duration = 1000, int steps = 50 ) : void
r byte The red component.
g byte The green component.
b byte The blue component.
repeats int
duration int How long should the morph last
steps int How many steps for color changes
return void

Pulse() public method

Pulse specified color on BlinkStick Pro.
public Pulse ( byte channel, byte index, string color, int repeats = 1, int duration = 1000, int steps = 50 ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
color string Must be in #rrggbb format or named color ("red", "green", "blue")
repeats int
duration int How long should the morph last
steps int How many steps for color changes
return void

Pulse() public method

Pulse specified color.
public Pulse ( string color, int repeats = 1, int duration = 1000, int steps = 50 ) : void
color string Must be in #rrggbb format or named color ("red", "green", "blue")
repeats int
duration int How long should the morph last
steps int How many steps for color changes
return void

SetColor() public method

Sets the color of the led.
public SetColor ( RgbColor color ) : void
color RgbColor Color as RgbColor class.
return void

SetColor() public method

Sets the color of the led.
public SetColor ( String color ) : void
color String Must be in #rrggbb format
return void

SetColor() public method

Sets the color of the led.
public SetColor ( byte channel, byte index, RgbColor color ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
color RgbColor Color parameter as RgbColor class instance
return void

SetColor() public method

Sets the color of the led.
public SetColor ( byte r, byte g, byte b ) : void
r byte The red component.
g byte The green component.
b byte The blue component.
return void

SetColor() public method

Sets the color of the led.
public SetColor ( byte channel, byte index, byte r, byte g, byte b ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
r byte The red component.
g byte The green component.
b byte The blue component.
return void

SetColor() public method

Sets the color of the led.
public SetColor ( byte channel, byte index, string color ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
index byte Index of the LED
color string Must be in #rrggbb format or named color ("red", "green", "blue")
return void

SetColors() public method

Send a packet of data to LEDs
public SetColors ( byte channel, byte colorData ) : void
channel byte Channel (0 - R, 1 - G, 2 - B)
colorData byte
return void

SetInfoBlock() protected method

protected SetInfoBlock ( byte id, byte data ) : void
id byte
data byte
return void

SetLedCount() public method

public SetLedCount ( byte count ) : void
count byte
return void

SetMode() public method

Sets the mode for BlinkStick Pro.
public SetMode ( byte mode ) : void
mode byte 0 - Normal, 1 - Inverse, 2 - WS2812
return void

Stop() public method

public Stop ( ) : void
return void

TurnOff() public method

Turn BlinkStick off.
public TurnOff ( ) : void
return void

WaitThread() public method

public WaitThread ( long milliseconds ) : System.Boolean
milliseconds long
return System.Boolean

Property Details

connectedToDriver protected property

protected bool connectedToDriver
return bool