mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
- use glog instead of Debug flag
- use glog instead of log - make code conform to the Go code guidelines
This commit is contained in:
parent
ca17879e6e
commit
9ab49745bc
23 changed files with 554 additions and 703 deletions
|
@ -3,7 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kidoman/embd"
|
||||
|
@ -26,7 +26,7 @@ func main() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Lighting is %v lx", lighting)
|
||||
fmt.Printf("Lighting is %v lx\n", lighting)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kidoman/embd"
|
||||
|
@ -24,19 +24,19 @@ func main() {
|
|||
for {
|
||||
temp, err := baro.Temperature()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Temp is %v", temp)
|
||||
fmt.Printf("Temp is %v\n", temp)
|
||||
pressure, err := baro.Pressure()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Pressure is %v", pressure)
|
||||
fmt.Printf("Pressure is %v\n", pressure)
|
||||
altitude, err := baro.Altitude()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Altitude is %v", altitude)
|
||||
fmt.Printf("Altitude is %v\n", altitude)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kidoman/embd"
|
||||
|
@ -24,19 +24,19 @@ func main() {
|
|||
for {
|
||||
temp, err := baro.Temperature()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Temp is %v", temp)
|
||||
fmt.Printf("Temp is %v\n", temp)
|
||||
pressure, err := baro.Pressure()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Pressure is %v", pressure)
|
||||
fmt.Printf("Pressure is %v\n", pressure)
|
||||
altitude, err := baro.Altitude()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Altitude is %v", altitude)
|
||||
fmt.Printf("Altitude is %v\n", altitude)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
@ -21,7 +21,6 @@ func main() {
|
|||
bus := embd.NewI2CBus(1)
|
||||
|
||||
gyro := l3gd20.New(bus, l3gd20.R250DPS)
|
||||
gyro.Debug = true
|
||||
defer gyro.Close()
|
||||
|
||||
gyro.Start()
|
||||
|
@ -31,7 +30,7 @@ func main() {
|
|||
|
||||
orientations, err := gyro.Orientations()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
timer := time.Tick(250 * time.Millisecond)
|
||||
|
@ -40,7 +39,7 @@ func main() {
|
|||
select {
|
||||
case <-timer:
|
||||
orientation := <-orientations
|
||||
log.Printf("x: %v, y: %v, z: %v", orientation.X, orientation.Y, orientation.Z)
|
||||
fmt.Printf("x: %v, y: %v, z: %v\n", orientation.X, orientation.Y, orientation.Z)
|
||||
case <-quit:
|
||||
return
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kidoman/embd"
|
||||
|
@ -24,9 +24,9 @@ func main() {
|
|||
for {
|
||||
heading, err := mems.Heading()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Heading is %v", heading)
|
||||
fmt.Printf("Heading is %v\n", heading)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
@ -33,7 +33,7 @@ func main() {
|
|||
default:
|
||||
voltage := rand.Intn(4096)
|
||||
if err := dac.SetVoltage(voltage); err != nil {
|
||||
log.Printf("mcp4725: %v", err)
|
||||
fmt.Printf("mcp4725: %v\n", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
@ -22,11 +21,10 @@ func main() {
|
|||
|
||||
pca9685 := pca9685.New(bus, 0x41)
|
||||
pca9685.Freq = 1000
|
||||
pca9685.Debug = true
|
||||
defer pca9685.Close()
|
||||
|
||||
if err := pca9685.SetPwm(15, 0, 2000); err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
|
|
|
@ -22,11 +22,9 @@ func main() {
|
|||
|
||||
pwm := pca9685.New(bus, 0x41)
|
||||
pwm.Freq = 50
|
||||
pwm.Debug = true
|
||||
defer pwm.Close()
|
||||
|
||||
servo := servo.New(pwm, 0)
|
||||
servo.Debug = true
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, os.Kill)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
@ -14,11 +13,9 @@ import (
|
|||
|
||||
func main() {
|
||||
sb := servoblaster.New()
|
||||
sb.Debug = true
|
||||
defer sb.Close()
|
||||
|
||||
servo := servo.New(sb, 0)
|
||||
servo.Debug = true
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, os.Kill)
|
||||
|
@ -43,7 +40,7 @@ func main() {
|
|||
err = servo.SetAngle(135)
|
||||
}
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
case <-c:
|
||||
return
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
|
@ -21,8 +21,8 @@ func main() {
|
|||
|
||||
sensor := tmp006.New(bus, 0x40)
|
||||
if status, err := sensor.Present(); err != nil || !status {
|
||||
log.Print("tmp006: not found")
|
||||
log.Print(err)
|
||||
fmt.Println("tmp006: not found")
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
defer sensor.Close()
|
||||
|
@ -35,9 +35,9 @@ func main() {
|
|||
for {
|
||||
select {
|
||||
case temp := <-sensor.ObjTemps():
|
||||
log.Printf("tmp006: got obj temp %.2f", temp)
|
||||
fmt.Printf("tmp006: got obj temp %.2f\n", temp)
|
||||
case temp := <-sensor.RawDieTemps():
|
||||
log.Printf("tmp006: got die temp %.2f", temp)
|
||||
fmt.Printf("tmp006: got die temp %.2f\n", temp)
|
||||
case <-stop:
|
||||
return
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/kidoman/embd"
|
||||
|
@ -31,9 +31,9 @@ func main() {
|
|||
for {
|
||||
distance, err := rf.Distance()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("Distance is %v", distance)
|
||||
fmt.Printf("Distance is %v\n", distance)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue