Skip to content

Commit

Permalink
button wired up
Browse files Browse the repository at this point in the history
  • Loading branch information
sudermanjr committed Feb 19, 2023
1 parent f38ec9f commit 66a8ca1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ func (a *App) buttonHandler(w http.ResponseWriter, r *http.Request) {
}
a.Logger.Debugw("got json from button", "json", data)

//TODO - handle the button press
var errFade error
if a.Array.Brightness == 0 {
errFade = a.Array.Fade(a.Array.MaxBrightness)
} else {
errFade = a.Array.Fade(a.Array.MinBrightness)
}
if errFade != nil {
a.Logger.Errorw("could not change brightness from button press", "error", err)
}

w.WriteHeader(http.StatusOK)
_, err = w.Write([]byte("button press received"))
Expand Down

0 comments on commit 66a8ca1

Please sign in to comment.