<commit_before>package main

import (
	"fmt"
	"time"

	"github.com/westphae/goflying/bmp280"
	"github.com/kidoman/embd"
)

func main() {
	var cur *bmp280.BMPData

	i2cbus := embd.NewI2CBus(1)
	bmp, err := bmp280.NewBMP280(&i2cbus, bmp280.Address1,
		bmp280.NormalMode, bmp280.StandbyTime63ms, bmp280.FilterCoeff16, bmp280.Oversamp16x, bmp280.Oversamp16x)
	if err != nil {
		fmt.Printf("Error: couldn't initialize BMP280: %s\n", err)
		return
	}

	defer bmp.Close()
	//fmt.Println("BMP280 initialized successfully")
	fmt.Println("t,temp,press,alt")

	clock := time.NewTicker(bmp.Delay)
	for {
		<-clock.C
		cur = <-bmp.C
		fmt.Printf("%v,%3.2f,%4.2f,%5.1f\n", cur.T, cur.Temperature, cur.Pressure, bmp280.CalcAltitude(cur.Pressure))
	}
}<commit_msg>read_bmp280.go can read from multiple chips<commit_after>package main

import (
	"fmt"
	"time"

	"github.com/westphae/goflying/bmp280"
	"github.com/kidoman/embd"
)

func main() {
	var cur *bmp280.BMPData

	i2cbus := embd.NewI2CBus(1)

	var bmps []*bmp280.BMP280
	for i, address:=range([]byte{bmp280.Address1,bmp280.Address2}) {
		bmp, err := bmp280.NewBMP280(&i2cbus, address,
			bmp280.NormalMode, bmp280.StandbyTime63ms, bmp280.FilterCoeff16, bmp280.Oversamp16x, bmp280.Oversamp16x)
		if err != nil {
			fmt.Printf("no BMP280 at address %d: %s\n", i, err)
			continue
		}
		bmps = append(bmps, bmp)
		defer bmp.Close()
	}
	if len(bmps)==0 {
		return
	}

	fmt.Println("t,chip,temp,press,alt")
	clock := time.NewTicker(bmps[0].Delay)
	for {
		<-clock.C
		for _, bmp:=range(bmps) {
			cur = <-bmp.C
			fmt.Printf("%v,%X,%3.2f,%4.2f,%5.1f\n", cur.T, bmp.Address, cur.Temperature, cur.Pressure, bmp280.CalcAltitude(cur.Pressure))
		}
	}
}
{'fraction_non_alphanumeric': 0.16934046345811052, 'fraction_numerical': 0.07605466428995841, 'mean_word_length': 4.29559748427673, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4120020', 'n_tokens_mistral': 881, 'n_tokens_neox': 766, 'n_words': 119}