Files
StarPilot/mapd_repo/utils/tracked_state.go
T
firestar5683 1ce9f73ae2 Navigation and maps
Add navigation and map matching providers with the vendored map service sources.
2026-10-03 22:34:37 +00:00

26 lines
455 B
Go

package utils
import (
"math"
"time"
)
type Float32Tracker struct {
LastValue float32
Value float32
UpdatedTime time.Time
AllowNullLastValue bool
}
func (t *Float32Tracker) Update(val float32) (updated bool) {
if t.Value != val {
if t.AllowNullLastValue || !(math.IsNaN(float64(t.Value)) || t.Value == 0) {
t.LastValue = t.Value
}
t.UpdatedTime = time.Now()
t.Value = val
return true
}
return false
}