@@ -12,11 +12,12 @@ const vendorID = 0x0fd9
12
12
13
13
// deviceType represents one of the various types of StreamDeck (mini/orig/orig2/xl)
14
14
type deviceType struct {
15
- name string
16
- imageSize image.Point
17
- usbProductID uint16
18
- resetPacket []byte
19
- numberOfButtons uint
15
+ name string
16
+ imageSize image.Point
17
+ usbProductID uint16
18
+ resetPacket []byte
19
+ numberOfButtons uint
20
+ brightnessPacket []byte
20
21
}
21
22
22
23
var deviceTypes []deviceType
@@ -28,13 +29,15 @@ func RegisterDevicetype(
28
29
usbProductID uint16 ,
29
30
resetPacket []byte ,
30
31
numberOfButtons uint ,
32
+ brightnessPacket []byte ,
31
33
) {
32
34
d := deviceType {
33
- name : name ,
34
- imageSize : imageSize ,
35
- usbProductID : usbProductID ,
36
- resetPacket : resetPacket ,
37
- numberOfButtons : numberOfButtons ,
35
+ name : name ,
36
+ imageSize : imageSize ,
37
+ usbProductID : usbProductID ,
38
+ resetPacket : resetPacket ,
39
+ numberOfButtons : numberOfButtons ,
40
+ brightnessPacket : brightnessPacket ,
38
41
}
39
42
deviceTypes = append (deviceTypes , d )
40
43
}
@@ -103,13 +106,15 @@ func (d *Device) SetBrightness(pct int) {
103
106
pct = 100
104
107
}
105
108
106
- payload := []byte {'\x03' , '\x08' , byte (pct )}
109
+ preamble := d .deviceType .brightnessPacket
110
+ payload := append (preamble , byte (pct ))
107
111
d .fd .SendFeatureReport (payload )
108
112
}
109
113
110
114
// ClearButtons writes a black square to all buttons
111
115
func (d * Device ) ClearButtons () {
112
- for i := 0 ; i < 32 ; i ++ {
116
+ numButtons := int (d .deviceType .numberOfButtons )
117
+ for i := 0 ; i < numButtons ; i ++ {
113
118
d .WriteColorToButton (i , color .Black )
114
119
}
115
120
}
0 commit comments