includes go-rpi-rgb-led-matrix as a dep

This commit is contained in:
2023-12-21 11:06:27 -05:00
parent d1d6e2d9f9
commit 4dcea50309
187 changed files with 1174372 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
package rpc
import (
"fmt"
"image/color"
"log"
"net"
"net/http"
"net/rpc"
"github.com/RockKeeper/go-rpi-rgb-led-matrix"
)
type RPCMatrix struct {
m rgbmatrix.Matrix
}
type GeometryArgs struct{}
type GeometryReply struct{ Width, Height int }
func (m *RPCMatrix) Geometry(_ *GeometryArgs, reply *GeometryReply) error {
w, h := m.m.Geometry()
reply.Width = w
reply.Height = h
return nil
}
type ApplyArgs struct{ Colors []color.Color }
type ApplyReply struct{}
func (m *RPCMatrix) Apply(args *ApplyArgs, reply *ApplyReply) error {
return m.m.Apply(args.Colors)
}
type CloseArgs struct{}
type CloseReply struct{}
func (m *RPCMatrix) Close(_ *CloseArgs, _ *CloseReply) error {
return m.m.Close()
}
func Serve(m rgbmatrix.Matrix) {
rpc.Register(&RPCMatrix{m})
rpc.HandleHTTP()
l, e := net.Listen("tcp", ":1234")
if e != nil {
log.Fatal("listen error:", e)
}
fmt.Println(l)
http.Serve(l, nil)
}