-
Notifications
You must be signed in to change notification settings - Fork 13
/
dreamcheeky.go
36 lines (31 loc) · 934 Bytes
/
dreamcheeky.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package led
import (
"github.com/boombuler/hid"
"image/color"
)
// Device type: DreamCheeky USBMailNotifier
var DreamCheeky DeviceType
func init() {
DreamCheeky = addDriver(usbDriver{
Name: "DreamCheeky USBMailNotifier",
Type: &DreamCheeky,
VendorId: 0x1D34,
ProductId: 0x0004,
Open: func(d hid.Device) (Device, error) {
if err := d.Write([]byte{0x00, 0x1F, 0x01, 0x29, 0x00, 0xB8, 0x54, 0x2C, 0x03}); err != nil {
return nil, err
}
if err := d.Write([]byte{0x00, 0x00, 0x01, 0x29, 0x00, 0xB8, 0x54, 0x2C, 0x04}); err != nil {
return nil, err
}
return &simpleHidDevice{
device: d,
setColorFn: dreamCheekyDevSetColor,
}, nil
},
})
}
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})
}