Beispiel #1
0
func dealExtremeSetColor(d hid.Device, c color.Color) error {
	palette := color.Palette{
		color.RGBA{0x00, 0x00, 0x00, 0x00},
		color.RGBA{0x00, 0xff, 0x00, 0xff},
		color.RGBA{0xff, 0x00, 0x00, 0xff},
		color.RGBA{0x00, 0x00, 0xff, 0xff},
		color.RGBA{0x00, 0xff, 0xff, 0xff},
		color.RGBA{0x00, 0xff, 0xff, 0xff},
		color.RGBA{0xff, 0xff, 0x00, 0xff},
		color.RGBA{0xff, 0x00, 0xff, 0xff},
		color.RGBA{0xff, 0xff, 0xff, 0xff},
	}
	return d.Write([]byte{0x00, byte(palette.Index(c))})
}
Beispiel #2
0
func blyncDevSetColor(d hid.Device, c color.Color) error {
	palette := color.Palette{
		color.RGBA{0x00, 0x00, 0x00, 0x00}, // black
		color.RGBA{0xff, 0xff, 0xff, 0xff}, // white
		color.RGBA{0x00, 0xff, 0xff, 0xff}, // cyan
		color.RGBA{0xff, 0x00, 0xff, 0xff}, // magenta
		color.RGBA{0x00, 0x00, 0xff, 0xff}, // blue
		color.RGBA{0xff, 0xff, 0x00, 0xff}, // yellow
		color.RGBA{0x00, 0xff, 0x00, 0xff}, // lime
		color.RGBA{0xff, 0x00, 0x00, 0xff}, // red
	}

	value := byte((palette.Index(c) * 16) + 127)
	return d.Write([]byte{0x00, 0x55, 0x53, 0x42, 0x43, 0x00, 0x40, 0x02, value})
}
Beispiel #3
0
func newBusyLight(d hid.Device, setcolorFn func(c color.Color)) *busylightDev {
	closeChan := make(chan struct{})
	colorChan := make(chan color.Color)
	ticker := time.NewTicker(20 * time.Second) // If nothing is send after 30 seconds the device turns off.
	go func() {
		var curColor color.Color = color.Black
		closed := false
		for !closed {
			select {
			case <-ticker.C:
				setcolorFn(curColor)
			case col := <-colorChan:
				curColor = col
				setcolorFn(curColor)
			case <-closeChan:
				ticker.Stop()
				setcolorFn(color.Black) // turn off device
				d.Close()
				closed = true
			}
		}
	}()
	return &busylightDev{closeChan: closeChan, colorChan: colorChan}
}
Beispiel #4
0
func blinkMSetColor(d hid.Device, c color.Color) error {
	r, g, b, _ := c.RGBA()
	return d.WriteFeature([]byte{0x01, 0xDA, 0x01, 0x05, 0x00, 0x09, 0x6E, byte(r >> 8), byte(g >> 8), byte(b >> 8)})
}
Beispiel #5
0
func dreamCheekyDevSetColor(d hid.Device, c color.Color) error {
	r, g, b, _ := c.RGBA()
	return d.Write([]byte{0x00, byte(r >> 10), byte(g >> 10), byte(b >> 10), 0x00, 0x00, 0x54, 0x2C, 0x05})
}