From 460093026a28744acf24cd176f83674d5ead63eb Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 21 Nov 2024 17:53:22 -0500 Subject: server dashboard: display duty cycle --- server/duty.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'server/duty.go') diff --git a/server/duty.go b/server/duty.go index ae32ecb..82bf60f 100644 --- a/server/duty.go +++ b/server/duty.go @@ -2,20 +2,19 @@ package main import ( "fmt" + "github.com/sam-rba/share" "log" "net/http" "strconv" - "sync" ) type DutyCycle float32 type DutyCycleHandler struct { - mu sync.Mutex - dc DutyCycle + dc share.Val[DutyCycle] } -func (h *DutyCycleHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { +func (h DutyCycleHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Println(r.Method, r.URL) if r.Method != http.MethodPost { @@ -30,7 +29,5 @@ func (h *DutyCycleHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - h.mu.Lock() - defer h.mu.Unlock() - h.dc = DutyCycle(dc) + h.dc.Set <- DutyCycle(dc) } -- cgit v1.2.3