fix: set temperature every 5 seconds

This commit is contained in:
kolaente 2021-10-02 14:41:13 +02:00
parent 5f819c467b
commit 9de57394c8
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 9 additions and 3 deletions

View File

@ -34,8 +34,10 @@ func main() {
fmt.Printf("Using sensor %s\n", sensor)
go func() {
time.Sleep(5 * time.Second)
ParseAndSetTemp()
for {
time.Sleep(5 * time.Second)
ParseAndSetTemp()
}
}()
fmt.Println("Starting http server on port 2112")

View File

@ -18,7 +18,11 @@ func ParseAndSetTemp() {
return
}
currentTemp.Set(parse(string(f)))
ct := parse(string(f))
fmt.Printf("Setting current temperature to %f\n", ct)
currentTemp.Set(ct)
}
func parse(w1Out string) float64 {