summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wallace <kevin@pentabarf.net>2026-03-05 20:18:45 -0800
committerKevin Wallace <kevin@pentabarf.net>2026-03-05 20:30:22 -0800
commit2ef3182af5118bc170f5e42c458e2c2c16288e6c (patch)
treea1b9d7918196aab06f6a43505616266b67fbb6d3
parentmake protocol trace logging optional, default off (diff)
beep when you press the buttonHEADmaster
Polls PIC32 ignition button state, tells the cVEND to beep.
-rw-r--r--Makefile8
-rw-r--r--autorun.sh5
-rw-r--r--cmd/beep/main.go42
3 files changed, 49 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 1620c85..07e308d 100644
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,9 @@ export GOARM=7
USB_ROOT=/Volumes/MP_SD
GOSOURCES:=$(shell find . -name *.go)
+BINS:=bin/cvend-ipp bin/pic32-ipp bin/beep
-all: bin/cvend-ipp bin/pic32-ipp
+all: ${BINS}
clean:
rm -r bin
@@ -15,8 +16,7 @@ bin/%: ${GOSOURCES}
mkdir -p bin
go build -o $@ ./cmd/$*
-usb: autorun.sh bin/cvend-ipp bin/pic32-ipp
+usb: autorun.sh ${BINS}
install autorun.sh ${USB_ROOT}/
install -d ${USB_ROOT}/bin/
- install bin/cvend-ipp ${USB_ROOT}/bin/
- install bin/pic32-ipp ${USB_ROOT}/bin/
+ install ${BINS} ${USB_ROOT}/bin/
diff --git a/autorun.sh b/autorun.sh
index c67c48f..4d6697c 100644
--- a/autorun.sh
+++ b/autorun.sh
@@ -1,4 +1,5 @@
#!/bin/bash -x
cd "$(dirname "$0")"
-systemd-run -p StandardOutput=tty -d bin/cvend-ipp
-systemd-run -p StandardOutput=tty -d bin/pic32-ipp
+#systemd-run -p StandardOutput=tty -d bin/cvend-ipp
+#systemd-run -p StandardOutput=tty -d bin/pic32-ipp
+systemd-run -p StandardOutput=tty -d bin/beep
diff --git a/cmd/beep/main.go b/cmd/beep/main.go
new file mode 100644
index 0000000..56263d5
--- /dev/null
+++ b/cmd/beep/main.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "encoding/binary"
+ "time"
+
+ "pm3.dev/cvend"
+ "pm3.dev/pic32"
+)
+
+func must[V any](v V, err error) V {
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
+func main() {
+ cv := must(cvend.OpenIPP(nil))
+ defer cv.Close()
+ var lastIgnition bool
+ pic := must(pic32.OpenIPP(func(msgType byte, msgData []byte) {
+ if msgType == 0x03 && binary.BigEndian.Uint16(msgData[:2]) == 0x03fb {
+ ignition := msgData[2] != 0
+ if lastIgnition != ignition {
+ lastIgnition = ignition
+ if ignition {
+ if err := cv.SendIPP(0x22, []byte{0x06, 0x00, 0x01, 0x00}); err != nil {
+ panic(err)
+ }
+ }
+ }
+ }
+ }))
+ defer pic.Close()
+ for {
+ if err := pic.SendIPP(0x02, []byte{0x03, 0xfb}); err != nil {
+ panic(err)
+ }
+ time.Sleep(100 * time.Millisecond)
+ }
+}