summaryrefslogtreecommitdiffstats
path: root/server/duty.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-11-21 17:53:22 -0500
committerSam Anthony <sam@samanthony.xyz>2024-11-21 17:53:22 -0500
commit460093026a28744acf24cd176f83674d5ead63eb (patch)
treea66c9406a0cd45176713305eb9d45d31e4c0b828 /server/duty.go
parente9ebb8126224353c7090889c38e49415497a53cd (diff)
downloadsoen422-460093026a28744acf24cd176f83674d5ead63eb.zip
server dashboard: display duty cycle
Diffstat (limited to 'server/duty.go')
-rw-r--r--server/duty.go11
1 files changed, 4 insertions, 7 deletions
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)
}