From 1f681060dd3711b68e3d2eb45fea4cb6494d9ee4 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Fri, 28 Aug 2020 18:24:08 -0400 Subject: [PATCH] Moved LUX sensor code to ticket as it is a secondary feature for the time being --- cmd/ui/lux.go | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 cmd/ui/lux.go diff --git a/cmd/ui/lux.go b/cmd/ui/lux.go deleted file mode 100644 index 9a37955..0000000 --- a/cmd/ui/lux.go +++ /dev/null @@ -1,50 +0,0 @@ -package ui - -import ( - bh1750 "github.com/d2r2/go-bh1750" - i2c "github.com/d2r2/go-i2c" - logger "github.com/d2r2/go-logger" - "time" -) - -var lg = logger.NewPackageLogger("main", - logger.ErrorLevel, -) - -func main() { - defer logger.FinalizeLogger() - - logger.ChangePackageLogLevel("i2c", logger.ErrorLevel) - logger.ChangePackageLogLevel("bh1750", logger.ErrorLevel) - - // Create new connection to I2C to bh1750 - i2c, err := i2c.NewI2C(0x23, 1) - if err != nil { - lg.Fatal(err) - } - - // Free I2C connection on exit - defer i2c.Close() - - // Setup sensor - sensor := bh1750.NewBH1750() - - // Reset sensor prior to use - err = sensor.Reset(i2c) - if err != nil { - lg.Fatal(err) - } - - // Read sensor value over time - for { - resolution := bh1750.HighResolution - lux, err := sensor.MeasureAmbientLight(i2c, resolution) - if err != nil { - lg.Fatal(err) - } - - println("Illuminance:", lux, "lx") - - time.Sleep(500 * time.Millisecond) - } -}