mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-08 08:53:40 +00:00
16d2b71820
These constants were always a bit weird:
* they use an uncommon name (TWI instead of I2C)
* they don't follow Go naming conventions (CamelCase)
* the constants don't provide much value: their name is their value
(100KHZ => 100e3).
Therefore, I propose we remove them and replace them with regular
numeric constants.
28 lines
343 B
Go
28 lines
343 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"machine"
|
|
"time"
|
|
|
|
"tinygo.org/x/drivers/adt7410"
|
|
)
|
|
|
|
var (
|
|
i2c = &machine.I2C0
|
|
sensor = adt7410.New(i2c)
|
|
)
|
|
|
|
func main() {
|
|
|
|
i2c.Configure(machine.I2CConfig{Frequency: 400e3})
|
|
sensor.Configure()
|
|
|
|
for {
|
|
temp := sensor.ReadTempF()
|
|
fmt.Printf("temperature: %f\r\n", temp)
|
|
time.Sleep(time.Second)
|
|
}
|
|
|
|
}
|