From a66696e3eda35fb58a31cfc66f2c334031fb9a65 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Mon, 12 Aug 2024 15:02:44 +0200 Subject: [PATCH] chore: play buzzer when new message received --- api/cammie.go | 2 ++ buzzer/buzzer.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/cammie.go b/api/cammie.go index 2e36dc1..94b6f66 100644 --- a/api/cammie.go +++ b/api/cammie.go @@ -3,6 +3,7 @@ package api import ( "fmt" "net/http" + "scc/buzzer" "scc/config" "scc/screen" "slices" @@ -77,6 +78,7 @@ func cammiePostMessage(app *screen.ScreenApp, c *gin.Context) { cammieMessages++ app.Cammie.Update(newMessage) + go buzzer.PlayBuzzer() c.JSON(http.StatusOK, gin.H{"message": "Message received"}) } diff --git a/buzzer/buzzer.go b/buzzer/buzzer.go index eef8226..ffb2299 100644 --- a/buzzer/buzzer.go +++ b/buzzer/buzzer.go @@ -12,7 +12,7 @@ var buzzerOptions = map[string]func(rpio.Pin){ "default": playMusic, } -func playBuzzer() { +func PlayBuzzer() { err := rpio.Open() if err != nil { log.Printf("Error: Unable to open pin: %s", err)