Renamed ExampleNewI2C & ExampleNewSpi to follow the recommandations. Exposed an I2CAddr for those who may need it.

pull/67/head
bpds 2 years ago
parent 60fc493f90
commit 0c715a3311
No known key found for this signature in database
GPG Key ID: B666D5C1144EADD6

@ -13,14 +13,16 @@ import (
"time" "time"
) )
// I2C uses an adxl345 device connected by I²C. var I2CAddr uint16 = 0x53
// ExampleNewI2C uses an adxl345 device connected by I²C.
// You can set the I²C address by setting I2CAddr (default is 0x53).
// it reads the acceleration values every 30ms for 30 seconds. // it reads the acceleration values every 30ms for 30 seconds.
// You can i use `i2dctools` to find the I²C bus number // You can i use `i2dctools` to find the I²C bus number
// e.g : sudo apt-get install i2c-tools // e.g : sudo apt-get install i2c-tools
// //
// sudo i2cdetect -y 1 // sudo i2cdetect -y 1
func I2C(addr uint16) { func ExampleNewI2C() {
mustInitHost() mustInitHost()
// Use i2creg to find the first available I²C bus. // Use i2creg to find the first available I²C bus.
@ -33,16 +35,16 @@ func I2C(addr uint16) {
defer p.Close() defer p.Close()
d, err := NewI2C(p, addr, &DefaultOpts) d, err := NewI2C(p, I2CAddr, &DefaultOpts)
if err != nil { if err != nil {
panic(err) panic(err)
} }
measure(d, 30*time.Second) measure(d, 30*time.Second)
} }
// Spi uses an adxl345 device connected by SPI. // ExampleNewSpi uses an adxl345 device connected by SPI.
// it reads the acceleration values every 30ms for 30 seconds. // it reads the acceleration values every 30ms for 30 seconds.
func Spi() { func ExampleNewSpi() {
mustInitHost() mustInitHost()

Loading…
Cancel
Save