bla
This commit is contained in:
parent
fabc54f9c7
commit
ae7a9a55bb
3 changed files with 19 additions and 8 deletions
|
@ -2,6 +2,7 @@ package radar
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"git.ctdo.de/henne/blitzer-v2/camera"
|
||||
"git.ctdo.de/henne/blitzer-v2/config"
|
||||
|
@ -45,18 +46,30 @@ func onEvent(speed int) {
|
|||
|
||||
func SetConfig(height int, angle int, waveform bool) {
|
||||
if waveform {
|
||||
r.SetBaseConfig(height, angle, 1)
|
||||
err := r.SetBaseConfig(height, angle, 1)
|
||||
if err != nil {
|
||||
log.Printf("%v", err)
|
||||
}
|
||||
} else {
|
||||
r.SetBaseConfig(height, angle, 0)
|
||||
err := r.SetBaseConfig(height, angle, 0)
|
||||
if err != nil {
|
||||
log.Printf("%v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SetSpeedConfig(speed int, minDistance, maxDistance, minSpeed, maxSpeed, triggerDistance int) {
|
||||
r.SetTargetSpeedConfig(radar_lib.DirectionIncoming, minDistance*2, maxDistance*2, minSpeed, maxSpeed, speed, radar_lib.OutputLogicMostPlausible)
|
||||
err := r.SetTargetSpeedConfig(radar_lib.DirectionIncoming, minDistance*2, maxDistance*2, minSpeed, maxSpeed, speed, radar_lib.OutputLogicMostPlausible)
|
||||
if err != nil {
|
||||
log.Printf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func SetCommunicationConfig() {
|
||||
r.SetCommunicationConfig(radar_lib.PortRS485, radar_lib.Baud115200, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, 50)
|
||||
err := r.SetCommunicationConfig(radar_lib.PortRS485, radar_lib.Baud115200, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, 50)
|
||||
if err != nil {
|
||||
log.Printf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -104,11 +104,11 @@ type Radar struct {
|
|||
func (r *Radar) write(data []byte) error {
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
_, err := r.port.Write(data)
|
||||
n, err := r.port.Write(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("data written")
|
||||
log.Printf("%d data written", n)
|
||||
return r.port.Drain()
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ func Show(speed int) {
|
|||
return
|
||||
}
|
||||
free = false
|
||||
log.Printf("%d", db.GetConfig().TriggerSpeed)
|
||||
if speed > db.GetConfig().TriggerSpeed {
|
||||
_, err := http.Get("http://" + config.C.SpeedsignIP + "/api/color/FF0000")
|
||||
if err != nil {
|
||||
|
@ -32,6 +31,5 @@ func Show(speed int) {
|
|||
if err != nil {
|
||||
log.Printf("err: %v", err)
|
||||
}
|
||||
log.Printf("send speed %d", speed)
|
||||
free = true
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue