Python package updated to 0.5.0

Python BlinkStick package has been updated to 0.5.0.

https://pypi.python.org/pypi/BlinkStick/

Rob Berwick has done an amazing job and created color animations for BlinkStick Python API. They are covered with 3 main functions:

  • blink – blinks the specified color
  • pulse – pulses the specified color
  • morph – morphs from current color to the specified color

pulse(self, red=0, green=0, blue=0, name=None, hex=None, repeats=1, duration=1000, steps=50)

Morph to the specified color from black and back again.

Parameters:

  • red – color intensity 0 is off, 255 is full red intensity
  • green – color intensity 0 is off, 255 is full green intensity
  • blue – color intensity 0 is off, 255 is full blue intensity
  • name – Use CSS colour name as defined here:- http://www.w3.org/TR/css3-color/
  • hex – Specify color using hexadecimal color value e.g. ‘#FF3366’
  • repeats – Number of times to pulse the LED
  • duration – Duration for pulse in milliseconds
  • steps – Number of gradient steps (default 50)

blink(self, red=0, green=0, blue=0, name=None, hex=None, repeats=1, delay=500)

Blink the specified color.

Parameters:

  • red – color intensity 0 is off, 255 is full red intensity
  • green – color intensity 0 is off, 255 is full green intensity
  • blue – color intensity 0 is off, 255 is full blue intensity
  • name – Use CSS colour name as defined here:- http://www.w3.org/TR/css3-color/
  • hex – Specify color using hexadecimal color value e.g. ‘#FF3366’
  • repeats – Number of times to blink the LED
  • delay – time in milliseconds to light LED for, and also between blinks

morph(self, red=0, green=0, blue=0, name=None, hex=None, duration=1000, steps=50)

Morph to the specified color.

Parameters:

  • red – color intensity 0 is off, 255 is full red intensity
  • green – color intensity 0 is off, 255 is full green intensity
  • blue – color intensity 0 is off, 255 is full blue intensity
  • name – Use CSS colour name as defined here:- http://www.w3.org/TR/css3-color/
  • hex – Specify color using hexadecimal color value e.g. ‘#FF3366’
  • duration – Duration for morph in milliseconds
  • steps – Number of gradient steps (default 50)

Each function has sensible defaults, so you can use

blink(name="red")

and your BlinkStick should blink red for 500ms once, but you can override the defaults with anything you like

blink(name="red", delay=100, repeats=5)

This would blink 5 times with 100ms delay for each blink.

BlinkStick object also has inverse mode. This means that each color sent to the USB device is inverse. Instead of sending #FF0000, BlinkStick receives #00FFFF. This is required in order to control IKEA DIODER with BlinkStick. A simple example looks like this:

stick = blinkstick.find_first()
stick.set_inverse(True)

stick.set_color(name="blue") # this correctly sets color to blue

The command line control script has also been updated and now utilizes all of those features. For example:

Blink red color twice:

blinkstick --set-color red --blink --repeats 2

Pulse green color three times:

blinkstick --set-color green --pulse --repeats 2

Morph to red, green and blue:

blinkstick --set-color red --morph
blinkstick --set-color gree --morph
blinkstick --set-color blue --morph

The control script also has an inverse mode. Just add –inverse parameter to all commands and the script will correctly send the color to the device:

blinkstick --inverse --set-color blue

All available control script parameters are accessible with command:

blinkstick --help

Installation is very simple:

sudo pip install blinkstick

If you already have blinkstick module installed, run the following command:

sudo pip install blinkstick --upgrade

Leave a Reply

Your email address will not be published. Required fields are marked *