blync

package module
v0.0.0-...-37af0da Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

README

GoBlync

goblync is a Go library for interacting with BlyncLight devices. This library is compatible with BlyncLight v3.

Building

Based on the dependency on Go HID, the following operating systems are supported targets (as used by $GOOS environment variable)

  • darwin (uses native IOKit framework)
  • linux (uses libusb 1.0+)
  • windows (uses native Windows HID library)
go get github.com/boombuler/hid
go build

For building on Windows, see the potential quirks listed here.

Usage

package main

import (
	"github.com/davidehringer/goblync"
	"time"
)

func main() {

	light := blync.NewBlyncLight()
	time.Sleep(time.Second * 2)
	//flash all lights in order based on USB path
	light.FlashOrder()

	// set all lights connected to red with music
	light.SetColor(blync.Red,0)
	light.Play(52,0)
	time.Sleep(time.Second * 5)
	light.StopPlay(0)

	//set only first blync light to blue
	light.SetColor(blync.Blue,1)
	time.Sleep(time.Second * 5)

	//reset all blynclights
	light.Reset(0)


	for i := 0; i < 256; i++ {
		light.SetColor([3]byte{byte(i), 255 - byte(i), 0x00},0)
		time.Sleep(13 * time.Millisecond)
	}
	light.SetBlinkRate(blync.BlinkMedium,0)
	time.Sleep(time.Second * 5)
	light.Close() //Close always affects all lights
}

Note on multiple BlyncLights.

Blync lights are ordered based on USB ID. You can use system info based on your OS tools, or call light.flashOrder().

When calling subsequent blynclight functions use 0 to interact with all, or specific ID starting as 1 based on relative order.

Documentation

Index

Constants

View Source
const (
	BlinkOff    = 0x00
	BlinkFast   = 0x46
	BlinkMedium = 0x64
	BlinkSlow   = 0x96
)

Variables

View Source
var Blue = [3]byte{0x00, 0x00, 0xFF}
View Source
var Green = [3]byte{0x00, 0xFF, 0x00}
View Source
var Red = [3]byte{0xFF, 0x00, 0x00}

Functions

This section is empty.

Types

type BlyncLight

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

func NewBlyncLight

func NewBlyncLight() (blync BlyncLight)

func (BlyncLight) Close

func (b BlyncLight) Close(id int)

func (BlyncLight) FlashOrder

func (b BlyncLight) FlashOrder()

func (BlyncLight) Play

func (b BlyncLight) Play(mp3 byte, id int)

16-30 play a tune single time 49-59 plays never ending versions of the tunes

func (BlyncLight) Reset

func (b BlyncLight) Reset(id int)

func (BlyncLight) SetBlinkRate

func (b BlyncLight) SetBlinkRate(rate byte, id int)

func (BlyncLight) SetColor

func (b BlyncLight) SetColor(color [3]byte, id int)

color[0] = r color[1] = g color[2] = b

func (BlyncLight) StopPlay

func (b BlyncLight) StopPlay(id int)

Jump to

Keyboard shortcuts

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