Skip to content

Commit 4de9a5e

Browse files
committed
Start adding comments as documentation for examples
1 parent 0bed5cc commit 4de9a5e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

examples/client/client.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,58 @@ func main() {
1919
}
2020
fmt.Printf("Found device [%s]\n", sd.GetName())
2121

22+
// Button in position 2, changes to "Bye!" at the end of the program
23+
// When pressed, this prints "You pressed me" to the terminal
2224
myButton := buttons.NewTextButton("Hi world")
2325
myButton.SetActionHandler(&actionhandlers.TextPrintAction{Label: "You pressed me"})
2426
sd.AddButton(2, myButton)
2527

28+
// Button in position 3, prints "5" to the terminal when pressed
2629
myOtherButton := buttons.NewTextButton("4")
2730
myOtherButton.SetActionHandler(&actionhandlers.NumberPrintAction{Number: 5})
2831
sd.AddButton(3, myOtherButton)
2932

33+
// Button in position 7 (top right on Streamdeck XL), says 7
34+
// When pressed, changes to display "8"
3035
myNextButton := buttons.NewTextButton("7")
3136
myNextButton.SetActionHandler(&actionhandlers.TextLabelChangeAction{NewLabel: "8"})
3237
sd.AddButton(7, myNextButton)
3338

39+
// Image button, no action handler
3440
anotherButton, err := buttons.NewImageFileButton("examples/test/play.jpg")
3541
if err != nil {
3642
panic(err)
3743
}
3844
sd.AddButton(9, anotherButton)
3945

46+
// Yellow button, no action handler but it goes to blue at the end of the program
4047
cButton := buttons.NewColourButton(color.RGBA{255, 255, 0, 255})
4148
sd.AddButton(26, cButton)
4249

50+
// One button, two actions (uses ChainedAction)
51+
// Purple button, prints to the console and turns red when pressed
4352
multiActionButton := buttons.NewColourButton(color.RGBA{255, 0, 255, 255})
4453
thisActionHandler := &actionhandlers.ChainedAction{}
4554
thisActionHandler.AddAction(&actionhandlers.TextPrintAction{Label: "Purple press"})
4655
thisActionHandler.AddAction(&actionhandlers.ColourChangeAction{NewColour: color.RGBA{255, 0, 0, 255}})
4756
multiActionButton.SetActionHandler(thisActionHandler)
4857
sd.AddButton(27, multiActionButton)
4958

59+
// Text button, gets a red highlight after 2 seconds, then a green
60+
// highlight after another 2 seconds
5061
decoratedButton := buttons.NewTextButton("ABC")
5162
sd.AddButton(19, decoratedButton)
52-
5363
time.Sleep(2 * time.Second)
5464
decorator1 := decorators.NewBorder(10, color.RGBA{0, 255, 0, 255})
5565
sd.SetDecorator(19, decorator1)
5666
time.Sleep(2 * time.Second)
5767
decorator2 := decorators.NewBorder(5, color.RGBA{255, 0, 0, 255})
5868
sd.SetDecorator(19, decorator2)
59-
6069
time.Sleep(2 * time.Second)
6170

71+
// When this button says "Bye!", the program ends
6272
myButton.SetText("Bye!")
73+
// When this button goes blue, the program ends
6374
cButton.SetColour(color.RGBA{0, 255, 255, 255})
6475
sd.UnsetDecorator(19)
6576
}

0 commit comments

Comments
 (0)