Example #1
0
func main() {

	log.Debug("Starting up...")

	dev, err := i2c.New(0x77, 1)
	if err != nil {
		log.Error("Error: %v", err)
	}
	bme, err := bme280.NewI2CDriver(dev)
	if err != nil {
		log.Error("Error: %v", err)
	}

	for {
		weather, err := bme.Readenv()

		density := atmosphere.AirDensity(atmosphere.TemperatureC(weather.Temp),
			atmosphere.Pressure(weather.Press*100),
			atmosphere.RelativeHumidity(weather.Hum))
		if err != nil {
			log.Error("Error: %v", err)
		} else {
			log.Debug(fmt.Sprintf("Temperature (degC) %2.2f, pressure (mbar) %4.2f, humidity %2.2f, Density %2.3f kg/m3, CorrFact %1.4f",
				weather.Temp, weather.Press, weather.Hum, float64(density), float64(density*0.8)))
		}

		<-time.After(5 * time.Second)
	}
}
Example #2
0
File: main.go Project: fikarzlf/i2c
func main() {
	i, err := i2c.New(0x27, 1)
	check(err)
	lcd, err := i2c.NewLcd(i, 2, 1, 0, 4, 5, 6, 7, 3)
	check(err)
	lcd.BacklightOn()
	lcd.Clear()
	for {
		lcd.Home()
		t := time.Now()
		lcd.SetPosition(1, 0)
		fmt.Fprint(lcd, t.Format("Monday Jan 2"))
		lcd.SetPosition(2, 0)
		fmt.Fprint(lcd, t.Format("15:04:05 2006"))
		lcd.SetPosition(4, 0)
		fmt.Fprint(lcd, "i2c, VGA, and Go")
		time.Sleep(333 * time.Millisecond)
	}
}
Example #3
0
File: main.go Project: fikarzlf/i2c
func main() {
	dev, err := i2c.New(0x27, 1) // vga port
	check(err)

	lcd, err := i2c.NewLcd(dev, 2, 1, 0, 4, 5, 6, 7, 3)
	check(err)
	lcd.BacklightOn()
	lcd.Clear()

	w := lcdWriter{lcd: lcd}
	fill(w.buf[:], 0x20)
	cmd := exec.Command(flags.Args()[0], flags.Args()[1:]...)
	cmd.Stdin = os.Stdin
	cmd.Stdout = &w
	if *stderr {
		cmd.Stderr = &w
	}

	cmd.Run()
}