-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples_test.go
60 lines (53 loc) · 1.16 KB
/
examples_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package fs90r_test
import (
"os"
"github.com/raspberrypi-go-drivers/fs90r"
"github.com/stianeikeland/go-rpio/v4"
)
func Example_ccw() {
err := rpio.Open()
if err != nil {
os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(50) // Set servo speed to 50% (CCW)
}
func Example_cw() {
err := rpio.Open()
if err != nil {
os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(-50) // Set servo speed to 50% (CW)
}
func ExampleNewFS90R() {
err := rpio.Open()
if err != nil {
os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(100) // Set servo speed to 100% (CCW)
}
func ExampleFS90R_SetSpeed() {
err := rpio.Open()
if err != nil {
os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(-25) // Set servo speed to 25% (CW)
}
func ExampleFS90R_SetBalancePoint() {
err := rpio.Open()
if err != nil {
os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(0) // if the servo is moving with this setup you can use SetBalancePoint
servo.SetBalancePoint(1.6)
// if the value used in SetBalancePoint is correct, the servo should now stay still
}