Skip to content

Commit 35e6a98

Browse files
committed
Merge branch 'device_updates'
2 parents a399164 + cc1d811 commit 35e6a98

File tree

5 files changed

+58
-10
lines changed

5 files changed

+58
-10
lines changed

comms.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type deviceType struct {
1818
usbProductID uint16
1919
resetPacket []byte
2020
numberOfButtons uint
21+
buttonRows uint
22+
buttonCols uint
2123
brightnessPacket []byte
2224
buttonReadOffset uint
2325
imageFormat string
@@ -34,6 +36,8 @@ func RegisterDevicetype(
3436
usbProductID uint16,
3537
resetPacket []byte,
3638
numberOfButtons uint,
39+
buttonRows uint,
40+
buttonCols uint,
3741
brightnessPacket []byte,
3842
buttonReadOffset uint,
3943
imageFormat string,
@@ -46,6 +50,8 @@ func RegisterDevicetype(
4650
usbProductID: usbProductID,
4751
resetPacket: resetPacket,
4852
numberOfButtons: numberOfButtons,
53+
buttonRows: buttonRows,
54+
buttonCols: buttonCols,
4955
brightnessPacket: brightnessPacket,
5056
buttonReadOffset: buttonReadOffset,
5157
imageFormat: imageFormat,

devices/mini.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ func init() {
6161
streamdeck.RegisterDevicetype(
6262
miniName, // Name
6363
image.Point{X: int(miniButtonWidth), Y: int(miniButtonHeight)}, // Width/height of a button
64-
0x63, // USB productID
65-
[]byte{0x0B, 0x63}, // Reset packet
66-
6, // Number of buttons
67-
[]byte{0x05, 0x55, 0xaa, 0xd1, 0x01}, // Reset packet
68-
0, // Button read offset
69-
"BMP", // Image format
64+
0x63, // USB productID
65+
resetPacket17(), // Reset packet
66+
6, // Number of buttons
67+
2, // Number of rows
68+
3, // Number of cols
69+
brightnessPacket17(), // Brightness packet
70+
1, // Button read offset
71+
"BMP", // Image format
7072
miniImageReportPayloadLength, // Amount of image payload allowed per USB packet
7173
GetImageHeaderMini, // Function to get the comms image header
7274
)

devices/origv2.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ func init() {
4646
ov2Name, // Name
4747
image.Point{X: int(ov2ButtonWidth), Y: int(ov2ButtonHeight)}, // Width/height of a button
4848
0x6d, // USB productID
49-
[]byte{'\x03', '\x02'}, // Reset packet
49+
resetPacket32(), // Reset packet
5050
15, // Number of buttons
51-
[]byte{'\x03', '\x08'}, // Set brightness packet preamble
51+
3, // Number of rows
52+
5, // Number of columns
53+
brightnessPacket32(), // Set brightness packet preamble
5254
4, // Button read offset
5355
"JPEG", // Image format
5456
ov2ImageReportPayloadLength, // Amount of image payload allowed per USB packet

devices/shared.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package devices
2+
3+
// resetPacket17 gives the reset packet for devices which need it to be 17 bytes long
4+
func resetPacket17() []byte {
5+
pkt := make([]byte, 17)
6+
pkt[0] = 0x0b
7+
pkt[1] = 0x63
8+
return pkt
9+
}
10+
11+
// resetPacket32 gives the reset packet for devices which need it to be 32 bytes long
12+
func resetPacket32() []byte {
13+
pkt := make([]byte, 32)
14+
pkt[0] = 0x03
15+
pkt[1] = 0x02
16+
return pkt
17+
}
18+
19+
// brightnessPacket17 gives the brightness packet for devices which need it to be 17 bytes long
20+
func brightnessPacket17() []byte {
21+
pkt := make([]byte, 17)
22+
pkt[0] = 0x05
23+
pkt[1] = 0x55
24+
pkt[2] = 0xaa
25+
pkt[3] = 0xd1
26+
pkt[4] = 0x01
27+
return pkt
28+
}
29+
30+
// brightnessPacket32 gives the brightness packet for devices which need it to be 32 bytes long
31+
func brightnessPacket32() []byte {
32+
pkt := make([]byte, 32)
33+
pkt[0] = 0x03
34+
pkt[1] = 0x08
35+
return pkt
36+
}

devices/xl.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ func init() {
4646
xlName, // Name
4747
image.Point{X: int(xlButtonWidth), Y: int(xlButtonHeight)}, // Width/height of a button
4848
0x6c, // USB productID
49-
[]byte{'\x03', '\x02'}, // Reset packet
49+
resetPacket32(), // Reset packet
5050
32, // Number of buttons
51-
[]byte{'\x03', '\x08'}, // Set brightness packet preamble
51+
4, // Number of rows
52+
8, // Number of cols
53+
brightnessPacket32(), // Set brightness packet preamble
5254
4, // Button read offset
5355
"JPEG", // Image format
5456
xlImageReportPayloadLength, // Amount of image payload allowed per USB packet

0 commit comments

Comments
 (0)