Pārlūkot izejas kodu

Added default PCA address

master
Tim Schuster 2 gadus atpakaļ
vecāks
revīzija
74cb2202e8
Parakstījis: Tim Schuster <mail@timschuster.info> GPG atslēgas ID: F9E27097EFB77F61
2 mainītis faili ar 8 papildinājumiem un 2 dzēšanām
  1. 0
    1
      consts.go
  2. 8
    1
      pca9685.go

+ 0
- 1
consts.go Parādīt failu

@@ -3,7 +3,6 @@ package adafruitPCA9685 // import "go.rls.moe/misc/adafruitPCA9685"
3 3
 /* https://github.com/adafruit/Adafruit_Python_PCA9685/blob/master/Adafruit_PCA9685/PCA9685.py */
4 4
 
5 5
 const (
6
-	c_I2C_SLAVE       = 0x0703
7 6
 	c_PCA9685_ADDRESS = 0x40
8 7
 	c_MODE1           = 0x00
9 8
 	c_MODE2           = 0x01

+ 8
- 1
pca9685.go Parādīt failu

@@ -13,7 +13,14 @@ type PCA9685 struct {
13 13
 	debugger *log.Logger
14 14
 }
15 15
 
16
-func NewPCA9685(address int, bus byte, debug *log.Logger) (*PCA9685, error) {
16
+func NewPCA9685(addressPtr *int, bus byte, debug *log.Logger) (*PCA9685, error) {
17
+	var address int
18
+	if addressPtr == nil {
19
+		address = c_PCA9685_ADDRESS
20
+	} else {
21
+		address = *addressPtr
22
+	}
23
+
17 24
 	i2cDev := fmt.Sprintf("/dev/i2c-%d", i2c)
18 25
 	d, err := i2c.Open(&i2c.Devfs{Dev: i2cDev}, address)
19 26
 	if err != nil {

Notiek ielāde…
Atcelt
Saglabāt