bla
This commit is contained in:
parent
94f0c7430e
commit
fabc54f9c7
3 changed files with 12 additions and 5 deletions
|
@ -18,6 +18,7 @@ func init() {
|
||||||
r = radar_lib.New(config.C.Radar.Port, config.C.Radar.Baud)
|
r = radar_lib.New(config.C.Radar.Port, config.C.Radar.Baud)
|
||||||
r.SetEventHandler(onEvent)
|
r.SetEventHandler(onEvent)
|
||||||
r.SetSpeedHandler(onSpeedEvent)
|
r.SetSpeedHandler(onSpeedEvent)
|
||||||
|
SetCommunicationConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
func onSpeedEvent(speed int) {
|
func onSpeedEvent(speed int) {
|
||||||
|
@ -42,15 +43,19 @@ func onEvent(speed int) {
|
||||||
printer.PrintTicket(speedingTicket)
|
printer.PrintTicket(speedingTicket)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetConfig(height int, angle int) {
|
func SetConfig(height int, angle int, waveform bool) {
|
||||||
r.SetBaseConfig(height, angle, 0)
|
if waveform {
|
||||||
|
r.SetBaseConfig(height, angle, 1)
|
||||||
|
} else {
|
||||||
|
r.SetBaseConfig(height, angle, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetSpeedConfig(speed int, minDistance, maxDistance, minSpeed, maxSpeed, triggerDistance int) {
|
func SetSpeedConfig(speed int, minDistance, maxDistance, minSpeed, maxSpeed, triggerDistance int) {
|
||||||
r.SetTargetSpeedConfig(radar_lib.DirectionBidirectional, minDistance*2, maxDistance*2, minSpeed, maxSpeed, speed, radar_lib.OutputLogicMostPlausible)
|
r.SetTargetSpeedConfig(radar_lib.DirectionIncoming, minDistance*2, maxDistance*2, minSpeed, maxSpeed, speed, radar_lib.OutputLogicMostPlausible)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetBaseConfig() {
|
func SetCommunicationConfig() {
|
||||||
r.SetCommunicationConfig(radar_lib.PortRS485, radar_lib.Baud115200, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, 50)
|
r.SetCommunicationConfig(radar_lib.PortRS485, radar_lib.Baud115200, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, radar_lib.OutputTypeNoOutput, 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ func (r *Radar) write(data []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.Printf("data written")
|
||||||
return r.port.Drain()
|
return r.port.Drain()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,5 +37,6 @@ func HandleSetupSave(ctx *gin.Context) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
}
|
||||||
radar.SetConfig(cfg.RadarHeight, cfg.RadarAngle)
|
radar.SetConfig(cfg.RadarHeight, cfg.RadarAngle, cfg.RadarWaveform)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue