-
Notifications
You must be signed in to change notification settings - Fork 13
/
dealextreme.go
39 lines (35 loc) · 983 Bytes
/
dealextreme.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
37
38
39
package led
import (
"github.com/boombuler/hid"
"image/color"
)
// Device type: DealExtreme USBMailNotifier
var DealExtreme DeviceType
func init() {
DealExtreme = addDriver(usbDriver{
Name: "DealExtreme USBMailNotifier",
Type: &DealExtreme,
VendorId: 0x1294,
ProductId: 0x1320,
Open: func(d hid.Device) (Device, error) {
return &simpleHidDevice{
device: d,
setColorFn: dealExtremeSetColor,
}, nil
},
})
}
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))})
}