mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
simplify package structure
This commit is contained in:
parent
3cae4064dc
commit
36f2c0486d
41 changed files with 736 additions and 885 deletions
|
@ -6,17 +6,17 @@ import (
|
|||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/kidoman/embd/i2c"
|
||||
"github.com/kidoman/embd"
|
||||
"github.com/kidoman/embd/sensor/bh1750fvi"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := i2c.Open(); err != nil {
|
||||
if err := embd.InitI2C(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer i2c.Close()
|
||||
defer embd.CloseI2C()
|
||||
|
||||
bus := i2c.NewBus(1)
|
||||
bus := embd.NewI2CBus(1)
|
||||
|
||||
sensor := bh1750fvi.New(bh1750fvi.High, bus)
|
||||
defer sensor.Close()
|
||||
|
@ -24,7 +24,7 @@ func main() {
|
|||
for {
|
||||
lighting, err := sensor.Lighting()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Lighting is %v lx", lighting)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue