blinkstick

package module
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2017 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Build Status GoDoc Go Report Card

Blinkstick SDK & CLI

SDK and CLI for BlinkStick

/!\ Work in progress.

Download

See https://github.com/yesnault/blinkstick/releases

Supported device

  • Blinckstick Nano
  • Blinckstick Flex
  • Blinckstick Strip & Square

Usage

Main Menu
$blink
Blink - Command Line for Blinkstick

Usage:
  blink [command]

Available Commands:
  color       Color list
  device      device <command>
  flex        flex <command>
  nano        nano <command>
  strip       strip <command>
  update      Update blink to the latest release version: blink update
  version     Display Version of blink: blink version

Flags:
      --log-level string   Log Level : debug, info or warn

Use "blink [command] --help" for more information about a command.
Nano

Example:

$ blink nano --help
  nano <command>

  Usage:
    blink nano [flags]
    blink nano [command]

  Available Commands:
    color       Color a blinkstick nano: blink nano color [<color>] [--brightness=n] [--top=<color>] [--bottom=<color>] [--serial=s] [--duration=n] [--repeats=n] [--blink]
    list        List all blinkstick nano
$blink nano color --help
  Color a blinkstick nano:

  Set the same color for both led with 50% brightness :
    blink nano color orange --brightness 50

  Set a color for bottom Led and another for top Led:
    blink nano color --bottom red --top green

  Examples:
   blink nano color --top purple --brightness 1
   blink nano color --bottom red --brightness 100
   blink nano color green --brightness 12
   blink nano color --serial BS008173-3.0 --duration=500 --repeats=10 --brightness 30 --blink --bottom red

  Turn off light:
    blink nano color black

  Usage:
    blink nano color [flags]

  Flags:
        --blink            Blink LED
        --bottom string    Color for botton led
        --brightness int   Limit the brightness of the color 0..100 (default 1)
        --duration int     Set duration of transition in milliseconds (use with --blink) (default 100)
        --repeats int      Number of repetitions (use with --blink) (default 10)
        --serial string    Select device by serial number. If unspecified, action will be performed on all BlinkSticks Strip
        --top string       Color for top led: blink nano color red
Flex

Example:

$ blink flex --help
  flex <command>

  Usage:
    blink flex [flags]
    blink flex [command]

  Available Commands:
    color       Color a blinkstick flex: blink flex color [<color>] [--brightness=n] [--led=n] [--serial=s] [--duration=n] [--repeats=n] [--blink]
    list        List all blinkstick flex

$ blink flex color --help
  Color a blinkstick flex:

  Set the same color for all leds with 50% brightness :
    blink flex color orange --brightness 50

  Color led 0 and 7
   blink flex color red --led 0 --led 7

  Examples:
   blink flex color powderblue
   blink flex color powderblue --brightness 60 --blink --repeats 1
   blink flex color ghostwhite --led 0 --led 2 --led 3 --led 5 --led 7 --led 11 --led 13 --led 17 --led 19 --led 23 --led 29 --led 31

  Turn off light:
    blink flex color black

  Usage:
    blink flex color [flags]

  Flags:
        --blink            Blink LED
        --brightness int   Limit the brightness of the color 0..100 (default 10)
        --duration int     Set duration of transition in milliseconds (use with --blink) (default 100)
        --led intSlice     Led to manipulate: 0..7. If unspecified, action will be performed on all leds
        --repeats int      Number of repetitions (use with --blink) (default 10)
        --serial string    Select device by serial number. If unspecified, action will be performed on all BlinkSticks Flex
Strip & Square

Idem as flex, but max led is 7.

$ blink strip --help
  strip <command>

  Usage:
    blink strip [flags]
    blink strip [command]

  Available Commands:
    color       Color a blinkstick strip: blink strip color [<color>] [--brightness=n] [--serial=s] [--duration=n] [--repeats=n] [--blink]
    list        List all blinkstick strip
$ blink strip color --help
  Color a blinkstick strip:

  Set the same color for all leds with 50% brightness :
    blink flex color orange --brightness 50

  Color led 0 and 7
   blink flex color red --led 0 --led 7

  Examples:
   blink flex color powderblue
   blink flex color powderblue --brightness 60 --blink --repeats 1
   blink flex color ghostwhite --led 0 --led 2 --led 3 --led 5 --led 7

  Turn off light:
    blink flex color black

  Usage:
    blink strip color [flags]

  Flags:
        --blink            Blink LED
        --brightness int   Limit the brightness of the color 0..100 (default 10)
        --color string     Color for top and bottom led: blink strip color red
        --duration int     Set duration of transition in milliseconds (use with --blink) (default 100)
        --led intSlice     Led to manipulate: 0..7. If unspecified, action will be performed on all leds
        --repeats int      Number of repetitions (use with --blink) (default 10)
        --serial string    Select device by serial number. If unspecified, action will be performed on all BlinkSticks Strip

Color
for i in `./blink color list`; do echo $i && ./blink flex color $i; done;

Hacking

  • $GOPATH/src/github.com/yesnault/blinkstick contains SDK
  • $GOPATH/src/github.com/yesnault/blinkstick/cli/blink contains CLI
mkdir -p $GOPATH/src/github.com/yesnault
cd $GOPATH/src/github.com/yesnault
git clone git@github.com:yesnault/blinkstick.git
cd blinkstick
go install ./...
blink version

You've developed a new cool feature? Fixed an annoying bug? We'd be happy to hear from you! Make sure to read CONTRIBUTING.md before.

License

This work is under the BSD license, see the LICENSE file for details.

Documentation

Index

Constants

View Source
const Version = "0.1.7"

Version of Blinkstick One Line for this, used by release.sh script Keep "const Version on one line"

Variables

This section is empty.

Functions

func ColorList

func ColorList() []string

ColorList returns all available colors

func GetColor

func GetColor(s string, brightness int) (color.Color, error)

GetColor returns a color from a name

func SetBlinkOnLed added in v0.1.0

func SetBlinkOnLed(blinkstick Blinkstick, col color.Color, index int, duration int, times int) error

SetBlinkOnLed color with given duration and times

func SetColorOnLed added in v0.1.0

func SetColorOnLed(blinkstick Blinkstick, color color.Color, index int) error

SetColorOnLed set color on a led

Types

type Blinkstick

type Blinkstick interface {
	List() []Blinkstick
	SetColor(color.Color) error
	Blink(color.Color, int, int) error
	GetDeviceInfo() *hid.DeviceInfo
	ListFilter(hid *hid.DeviceInfo) (bool, Blinkstick)
	// contains filtered or unexported methods
}

Blinkstick represents a blinkstick device

func List

func List(opts ...ListFilter) []Blinkstick

List gets all blinkstick device

type Flex added in v0.1.4

type Flex struct {
	// contains filtered or unexported fields
}

Flex represents a BlinkFlex Flex https://www.blinkstick.com/products/blinkstick-flex

func (flex Flex) Blink(color color.Color, duration, times int) error

Blink blink color for all led on current Blinkstick flex

func (Flex) GetDeviceInfo added in v0.1.4

func (flex Flex) GetDeviceInfo() *hid.DeviceInfo

GetDeviceInfo returns device info

func (Flex) List added in v0.1.4

func (flex Flex) List() []Blinkstick

List returns blinkstick flex

func (Flex) ListFilter added in v0.1.4

func (flex Flex) ListFilter(hid *hid.DeviceInfo) (bool, Blinkstick)

ListFilter used for filter List Device

func (Flex) SetColor added in v0.1.4

func (flex Flex) SetColor(color color.Color) error

SetColor set color for all led on current Blinkstick flex

type ListFilter

type ListFilter func(*hid.DeviceInfo) (bool, Blinkstick)

ListFilter is used to filter device on List

type Nano

type Nano struct {
	// contains filtered or unexported fields
}

Nano represents a BlinkStick Nano https://www.blinkstick.com/products/blinkstick-nano

func (nano Nano) Blink(color color.Color, duration, times int) error

Blink blink color for all led on current Blinkstick nano

func (Nano) GetDeviceInfo

func (nano Nano) GetDeviceInfo() *hid.DeviceInfo

GetDeviceInfo returns device info

func (Nano) List

func (nano Nano) List() []Blinkstick

List returns blinkstick nano

func (Nano) ListFilter

func (nano Nano) ListFilter(hid *hid.DeviceInfo) (bool, Blinkstick)

ListFilter used for filter List Device

func (Nano) SetColor

func (nano Nano) SetColor(color color.Color) error

SetColor set color for all led on current Blinkstick nano

func (Nano) SetColorBottom

func (nano Nano) SetColorBottom(color color.Color) error

SetColorBottom set color for bottom on top on current Blinkstick nano

func (Nano) SetColorTop

func (nano Nano) SetColorTop(color color.Color) error

SetColorTop set color for led on top on current Blinkstick nano

type Strip added in v0.1.0

type Strip struct {
	// contains filtered or unexported fields
}

Strip represents a BlinkStrip Strip https://www.blinkstick.com/products/blinkstick-strip

func (strip Strip) Blink(color color.Color, duration, times int) error

Blink blink color for all led on current Blinkstick strip

func (Strip) GetDeviceInfo added in v0.1.0

func (strip Strip) GetDeviceInfo() *hid.DeviceInfo

GetDeviceInfo returns device info

func (Strip) List added in v0.1.0

func (strip Strip) List() []Blinkstick

List returns blinkstick strip

func (Strip) ListFilter added in v0.1.0

func (strip Strip) ListFilter(hid *hid.DeviceInfo) (bool, Blinkstick)

ListFilter used for filter List Device

func (Strip) SetColor added in v0.1.0

func (strip Strip) SetColor(color color.Color) error

SetColor set color for all led on current Blinkstick strip

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL