Skip to content

Commit 41a60d0

Browse files
committed
Add code samples for button and switch
1 parent a7715b2 commit 41a60d0

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

components/button/button.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ func Named(name string) resource.Name {
3636
}
3737

3838
// A Button represents a physical button.
39+
// For more information, see the [Push component docs].
40+
//
41+
// Push example:
42+
//
43+
// myButton, err := switch.FromRobot(machine, "my_button")
44+
//
45+
// err := myButton.Push(context.Background(), nil)
46+
//
47+
// For more information, see the [Push method docs].
48+
//
49+
// [Button component docs]: https://docs.viam.com/dev/reference/apis/components/button/
50+
// [Push method docs]: https://docs.viam.com/dev/reference/apis/components/button/#push
3951
type Button interface {
4052
resource.Resource
4153

components/switch/switch.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,36 @@ func Named(name string) resource.Name {
3636
}
3737

3838
// A Switch represents a physical multi-position switch.
39+
// For more information, see the [Switch component docs].
40+
//
41+
// SetPosition example:
42+
//
43+
// mySwitch, err := switch.FromRobot(machine, "my_switch")
44+
//
45+
// err := mySwitch.SetPosition(context.Background(), 0 , nil)
46+
//
47+
// For more information, see the [SetPosition method docs].
48+
//
49+
// GetPosition example:
50+
//
51+
// mySwitch, err := switch.FromRobot(machine, "my_switch")
52+
//
53+
// position, err := mySwitch.GetPosition(context.Background(), nil)
54+
//
55+
// For more information, see the [GetPosition method docs].
56+
//
57+
// GetNumberOfPositions example:
58+
//
59+
// mySwitch, err := switch.FromRobot(machine, "my_switch")
60+
//
61+
// positions, err := mySwitch.GetNumberOfPositions(context.Background(), nil)
62+
//
63+
// For more information, see the [GetNumberOfPositions method docs].
64+
//
65+
// [Switch component docs]: https://docs.viam.com/dev/reference/apis/components/switch/
66+
// [SetPosition method docs]: https://docs.viam.com/dev/reference/apis/components/switch/#setposition
67+
// [GetPosition method docs]: https://docs.viam.com/dev/reference/apis/components/switch/#getposition
68+
// [GetNumberOfPositions method docs]: https://docs.viam.com/dev/reference/apis/components/switch/#getnumberofpositions
3969
type Switch interface {
4070
resource.Resource
4171

0 commit comments

Comments
 (0)