staticcheck formatting

This commit is contained in:
KemoNine 2020-08-25 20:18:29 -04:00
parent 19c192f0e3
commit 12fc1f059a

View file

@ -1,10 +1,10 @@
package main package main
import ( import (
"time"
i2c "github.com/d2r2/go-i2c"
bh1750 "github.com/d2r2/go-bh1750" bh1750 "github.com/d2r2/go-bh1750"
i2c "github.com/d2r2/go-i2c"
logger "github.com/d2r2/go-logger" logger "github.com/d2r2/go-logger"
"time"
) )
var lg = logger.NewPackageLogger("main", var lg = logger.NewPackageLogger("main",
@ -19,7 +19,9 @@ func main() {
// Create new connection to I2C to bh1750 // Create new connection to I2C to bh1750
i2c, err := i2c.NewI2C(0x23, 1) i2c, err := i2c.NewI2C(0x23, 1)
if err != nil { lg.Fatal(err) } if err != nil {
lg.Fatal(err)
}
// Free I2C connection on exit // Free I2C connection on exit
defer i2c.Close() defer i2c.Close()
@ -29,13 +31,17 @@ func main() {
// Reset sensor prior to use // Reset sensor prior to use
err = sensor.Reset(i2c) err = sensor.Reset(i2c)
if err != nil { lg.Fatal(err) } if err != nil {
lg.Fatal(err)
}
// Read sensor value over time // Read sensor value over time
for { for {
resolution := bh1750.HighResolution resolution := bh1750.HighResolution
lux, err := sensor.MeasureAmbientLight(i2c, resolution) lux, err := sensor.MeasureAmbientLight(i2c, resolution)
if err != nil { lg.Fatal(err) } if err != nil {
lg.Fatal(err)
}
println("Illuminance:", lux, "lx") println("Illuminance:", lux, "lx")