Browse Source

Gofmt

master
Tim Schuster 2 years ago
parent
commit
5abf3511e8
Signed by: Tim Schuster <mail@timschuster.info> GPG Key ID: F9E27097EFB77F61
3 changed files with 16 additions and 17 deletions
  1. 1
    1
      example/main.go
  2. 2
    2
      pca9685.go
  3. 13
    14
      servo.go

+ 1
- 1
example/main.go View File

@@ -117,7 +117,7 @@ func parseKeyboardInput(step int16) (int16, error) {
117 117
 		return angle, nil
118 118
 	}
119 119
 	if strings.HasPrefix(command, "select ") {
120
-		servChan := strings.TrimPrefix(command,"select ")
120
+		servChan := strings.TrimPrefix(command, "select ")
121 121
 		servChan = strings.TrimSpace(servChan)
122 122
 		servChanI, err := strconv.Atoi(servChan)
123 123
 		if err != nil {

+ 2
- 2
pca9685.go View File

@@ -12,7 +12,7 @@ type PCA9685 struct {
12 12
 	dev      *i2c.Device
13 13
 	mode1    byte
14 14
 	debugger *log.Logger
15
-	lock sync.Mutex
15
+	lock     sync.Mutex
16 16
 }
17 17
 
18 18
 func NewPCA9685(addressPtr *int, bus byte, debug *log.Logger) (*PCA9685, error) {
@@ -33,7 +33,7 @@ func NewPCA9685(addressPtr *int, bus byte, debug *log.Logger) (*PCA9685, error)
33 33
 	}
34 34
 	pca := &PCA9685{dev: d, debugger: debug, lock: sync.Mutex{}}
35 35
 	pca.logDebug("Setting up Controller")
36
-	err = pca.SetAllPWM(0,0)
36
+	err = pca.SetAllPWM(0, 0)
37 37
 	if err != nil {
38 38
 		pca.logDebug("Error on SetAllPWM : ", err)
39 39
 		return nil, err

+ 13
- 14
servo.go View File

@@ -11,15 +11,15 @@ var (
11 11
 )
12 12
 
13 13
 type Servo struct {
14
-	lock sync.Mutex
15
-	controller                                    *PCA9685
16
-	settings ServoSettings
14
+	lock         sync.Mutex
15
+	controller   *PCA9685
16
+	settings     ServoSettings
17 17
 	currentAngle int16
18
-	channel                                       byte
18
+	channel      byte
19 19
 }
20 20
 
21 21
 type ServoSettings struct {
22
-	OffsetAngle int16
22
+	OffsetAngle                                 int16
23 23
 	StartAngle, MinAngle, MaxAngle, MiddleAngle int16
24 24
 }
25 25
 
@@ -29,11 +29,10 @@ func NewServo(controller *PCA9685, channel byte, sc ServoSettings) (*Servo, erro
29 29
 	}
30 30
 
31 31
 	ns := &Servo{
32
-		controller: controller,
33
-		settings: sc,
34
-		channel: channel,
32
+		controller:   controller,
33
+		settings:     sc,
34
+		channel:      channel,
35 35
 		currentAngle: sc.StartAngle,
36
-		lock: sync.Mutex{},
37 36
 	}
38 37
 	if err := ns.controller.SetPWM(ns.channel, 0, ns.currentAngle); err != nil {
39 38
 		return nil, err
@@ -71,9 +70,9 @@ func (s *Servo) CurrentAngle() int16 {
71 70
 	return s.currentAngle
72 71
 }
73 72
 
74
-func (s *Servo) GetSettings() ServoSettings { return s.settings }
73
+func (s *Servo) GetSettings() ServoSettings   { return s.settings }
75 74
 func (s *Servo) SetSettings(sc ServoSettings) { s.settings = sc }
76
-func (s *Servo) Offset() int16 { return s.settings.OffsetAngle }
77
-func (s *Servo) Controller() *PCA9685 { return s.controller }
78
-func (s *Servo) Channel() byte        { return s.channel }
79
-func (s *Servo) Center() error { return s.TurnTo(s.settings.MiddleAngle) }
75
+func (s *Servo) Offset() int16                { return s.settings.OffsetAngle }
76
+func (s *Servo) Controller() *PCA9685         { return s.controller }
77
+func (s *Servo) Channel() byte                { return s.channel }
78
+func (s *Servo) Center() error                { return s.TurnTo(s.settings.MiddleAngle) }

Loading…
Cancel
Save