From 8bc066ce2d7bfd1a8d0253dfdee71faf208cd015 Mon Sep 17 00:00:00 2001 From: JessamyT Date: Tue, 31 Dec 2024 11:43:53 -0800 Subject: [PATCH 1/3] QA board examples --- components/board/board.go | 9 ++++++++- components/board/gpio_pin.go | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/components/board/board.go b/components/board/board.go index a068e48b55d..75a7eaa0fa8 100644 --- a/components/board/board.go +++ b/components/board/board.go @@ -71,6 +71,13 @@ func Named(name string) resource.Name { // // Get the GPIOPin with pin number 15. // pin, err := myBoard.GPIOPinByName("15") // +// AnalogNames example: +// +// myBoard, err := board.FromRobot(robot, "my_board") +// +// // Get the names of all known analog pins +// names := myBoard.AnalogNames() +// // SetPowerMode example: // // myBoard, err := board.FromRobot(robot, "my_board") @@ -142,7 +149,7 @@ type Board interface { // analog, err := myBoard.AnalogByName("my_example_analog") // // // Set the pin to value 48. -// err := analog.Write(context.Background(), 48, nil) +// err = analog.Write(context.Background(), 48, nil) type Analog interface { // Read reads off the current value. Read(ctx context.Context, extra map[string]interface{}) (AnalogValue, error) diff --git a/components/board/gpio_pin.go b/components/board/gpio_pin.go index 9d53b58298c..fa77475bf21 100644 --- a/components/board/gpio_pin.go +++ b/components/board/gpio_pin.go @@ -17,7 +17,7 @@ import ( // pin, err := myBoard.GPIOPinByName("15") // // // Set the pin to high. -// err := pin.Set(context.Background(), "true", nil) +// err = pin.Set(context.Background(), true, nil) // // Get example: // @@ -27,7 +27,7 @@ import ( // pin, err := myBoard.GPIOPinByName("15") // // // Get if it is true or false that the state of the pin is high. -// high := pin.Get(context.Background(), nil) +// high, err := pin.Get(context.Background(), nil) // // PWM example: // @@ -37,7 +37,7 @@ import ( // pin, err := myBoard.GPIOPinByName("15") // // // Returns the duty cycle. -// duty_cycle := pin.PWM(context.Background(), nil) +// duty_cycle, err := pin.PWM(context.Background(), nil) // // SetPWM example: // @@ -47,7 +47,7 @@ import ( // pin, err := myBoard.GPIOPinByName("15") // // // Set the duty cycle to .6, meaning that this pin will be in the high state for 60% of the duration of the PWM interval period. -// err := pin.SetPWM(context.Background(), .6, nil) +// err = pin.SetPWM(context.Background(), .6, nil) // // PWMFreq example: // @@ -67,7 +67,7 @@ import ( // pin, err := myBoard.GPIOPinByName("15") // // // Set the PWM frequency of this pin to 1600 Hz. -// high := pin.SetPWMFreq(context.Background(), 1600, nil) +// err = pin.SetPWMFreq(context.Background(), 1600, nil) type GPIOPin interface { // Set sets the pin to either low or high. Set(ctx context.Context, high bool, extra map[string]interface{}) error From 8de749cc0f81057b5e3c468f56d57ff46e7b9453 Mon Sep 17 00:00:00 2001 From: JessamyT Date: Tue, 31 Dec 2024 12:11:26 -0800 Subject: [PATCH 2/3] lint --- components/board/board.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/board/board.go b/components/board/board.go index 75a7eaa0fa8..47cd4481bf1 100644 --- a/components/board/board.go +++ b/components/board/board.go @@ -73,10 +73,10 @@ func Named(name string) resource.Name { // // AnalogNames example: // -// myBoard, err := board.FromRobot(robot, "my_board") -// -// // Get the names of all known analog pins -// names := myBoard.AnalogNames() +// myBoard, err := board.FromRobot(robot, "my_board") +// +// // Get the names of all known analog pins +// names := myBoard.AnalogNames() // // SetPowerMode example: // From 3b20aaed9b429291bacd632dde4b9ce8824b5f73 Mon Sep 17 00:00:00 2001 From: JessamyT <75634662+JessamyT@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:29:34 -0800 Subject: [PATCH 3/3] Update components/board/board.go --- components/board/board.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/components/board/board.go b/components/board/board.go index 47cd4481bf1..83a3e30e325 100644 --- a/components/board/board.go +++ b/components/board/board.go @@ -71,13 +71,6 @@ func Named(name string) resource.Name { // // Get the GPIOPin with pin number 15. // pin, err := myBoard.GPIOPinByName("15") // -// AnalogNames example: -// -// myBoard, err := board.FromRobot(robot, "my_board") -// -// // Get the names of all known analog pins -// names := myBoard.AnalogNames() -// // SetPowerMode example: // // myBoard, err := board.FromRobot(robot, "my_board")