Skip to content

Commit a80e08f

Browse files
committed
Add some comments to remaining example files
1 parent 4f822b9 commit a80e08f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

examples/client3/client3.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,31 @@ import (
1010
)
1111

1212
func main() {
13-
13+
// initialise the device
1414
sd, err := streamdeck.New()
1515
if err != nil {
1616
panic(err)
1717
}
1818

19+
// create a text button
1920
btn1 := buttons.NewTextButton("Hello")
2021
sd.AddButton(1, btn1)
22+
// create an image button
2123
btn2, _ := buttons.NewImageFileButton("examples/test/play.jpg")
2224
sd.AddButton(2, btn2)
2325

2426

27+
// set a green border on both buttons
2528
greenBorder := decorators.NewBorder(10, color.RGBA{0, 255, 0, 255})
2629
sd.SetDecorator(1, greenBorder)
2730
sd.SetDecorator(2, greenBorder)
2831

32+
// wait for one second
2933
time.Sleep(1 * time.Second)
3034

35+
// remove decorators
3136
sd.UnsetDecorator(1)
3237
sd.UnsetDecorator(2)
33-
}
38+
39+
// program exits
40+
}

examples/test/test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,25 @@ import (
1010
)
1111

1212
func main() {
13+
// connect to a streamdeck
1314
sd, err := streamdeck.Open()
1415
if err != nil {
1516
panic(err)
1617
}
1718
fmt.Printf("Found device [%s]\n", sd.GetName())
1819

20+
// remove all button content
1921
sd.ClearButtons()
2022

23+
// manage brightness level
2124
sd.SetBrightness(50)
2225

26+
// show text in increasing lengths on three buttons
2327
sd.WriteTextToButton(2, "Hi!", color.RGBA{0, 0, 0, 255}, color.RGBA{0, 255, 255, 255})
2428
sd.WriteTextToButton(3, "Hi again!", color.RGBA{0, 0, 0, 255}, color.RGBA{0, 255, 255, 255})
2529
sd.WriteTextToButton(4, "Hi again again!", color.RGBA{0, 0, 0, 255}, color.RGBA{0, 255, 255, 255})
2630

27-
//sd.WriteImageToButton(9, "something.png")
28-
//sd.WriteImageToButton(10, "play.jpg")
29-
//sd.WriteColorToButton(color.RGBA{255, 0, 255, 0}, 1)
31+
// when any button is pressed, clear all buttons, and set an image on the pressed button
3032
sd.ButtonPress(func(btnIndex int, sd *streamdeck.Device, err error) {
3133
if err != nil {
3234
panic(err)
@@ -35,6 +37,7 @@ func main() {
3537
sd.WriteImageToButton(btnIndex, "examples/test/play.jpg")
3638
})
3739

40+
// keep the program running
3841
var wg sync.WaitGroup
3942
wg.Add(1)
4043
wg.Wait()

0 commit comments

Comments
 (0)