mirror of
https://github.com/kidoman/embd
synced 2025-01-03 10:31:36 +01:00
servo: assume good defaults for minus and maxus (544 and 2400, as per
the Arduino documentation: http://arduino.cc/en/Reference/ServoAttach)
This commit is contained in:
parent
7c32e907e1
commit
7809d9d6ba
@ -7,6 +7,11 @@ import (
|
|||||||
"github.com/kid0m4n/go-rpi/util"
|
"github.com/kid0m4n/go-rpi/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
minus = 544
|
||||||
|
maxus = 2400
|
||||||
|
)
|
||||||
|
|
||||||
// A PWM interface implements access to a pwm controller.
|
// A PWM interface implements access to a pwm controller.
|
||||||
type PWM interface {
|
type PWM interface {
|
||||||
SetMicroseconds(channel int, us int) error
|
SetMicroseconds(channel int, us int) error
|
||||||
@ -22,7 +27,7 @@ type Servo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Servo interface.
|
// New creates a new Servo interface.
|
||||||
func New(pwm PWM, channel int, minus, maxus int) *Servo {
|
func New(pwm PWM, channel int) *Servo {
|
||||||
return &Servo{
|
return &Servo{
|
||||||
PWM: pwm,
|
PWM: pwm,
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
|
@ -21,7 +21,7 @@ func main() {
|
|||||||
pwm.Debug = true
|
pwm.Debug = true
|
||||||
defer pwm.Close()
|
defer pwm.Close()
|
||||||
|
|
||||||
servo := servo.New(pwm, 0, 500, 2500)
|
servo := servo.New(pwm, 0)
|
||||||
servo.Debug = true
|
servo.Debug = true
|
||||||
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
|
@ -15,7 +15,7 @@ func main() {
|
|||||||
sb.Debug = true
|
sb.Debug = true
|
||||||
defer sb.Close()
|
defer sb.Close()
|
||||||
|
|
||||||
servo := servo.New(sb, 0, 500, 2500)
|
servo := servo.New(sb, 0)
|
||||||
servo.Debug = true
|
servo.Debug = true
|
||||||
|
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user