From e60ec1ead1203770b6b56a051998076fe04f74d5 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Sun, 17 Jul 2022 20:14:05 +0000 Subject: [PATCH] getting this up --- .devcontainer/Dockerfile | 20 +++++++++++ .devcontainer/devcontainer.json | 49 +++++++++++++++++++++++++++ Dockerfile | 7 ++++ go.mod | 22 ++++++++++++ main.go | 59 +++++++++++++++++++++++++++++++++ 5 files changed, 157 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 Dockerfile create mode 100644 go.mod create mode 100644 main.go diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..d675a01 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/go/.devcontainer/base.Dockerfile + +# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.18, 1.17, 1-bullseye, 1.18-bullseye, 1.17-bullseye, 1-buster, 1.18-buster, 1.17-buster +ARG VARIANT="1.18-bullseye" +FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} + +# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 +ARG NODE_VERSION="none" +RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment the next lines to use go get to install anything else you need +# USER vscode +# RUN go get -x + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..1ab9f58 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,49 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/go +{ + "name": "Go", + "build": { + "dockerfile": "Dockerfile", + "args": { + // Update the VARIANT arg to pick a version of Go: 1, 1.18, 1.17 + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local arm64/Apple Silicon. + "VARIANT": "1.18-bullseye", + // Options + "NODE_VERSION": "none" + } + }, + "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go" + ] + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "features": { + "docker-in-docker": "latest", + "kubectl-helm-minikube": "latest", + "git": "latest" + } +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..87639b2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +from registry.local/rgbarm64lib:latest + +workdir /usr/src/app/work +COPY . . +RUN go mod tidy + +RUN go build . \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..530f1e6 --- /dev/null +++ b/go.mod @@ -0,0 +1,22 @@ +module rgb + +go 1.18 + +require ( + gitea.wagshome.duckdns.org/publicWagsHome/go-rpi-rgb-led-matrix v0.0.0-20220709235716-bf87ebdb3e55 + github.com/fogleman/gg v1.3.0 +) + +require ( + dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037 // indirect + github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 // indirect + github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/jezek/xgb v1.0.0 // indirect + golang.org/x/exp/shiny v0.0.0-20220713135740-79cabaa25d75 // indirect + golang.org/x/image v0.0.0-20220617043117-41969df76e82 // indirect + golang.org/x/mobile v0.0.0-20220518205345-8578da9835fd // indirect + golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect +) + +replace gitea.wagshome.duckdns.org/publicWagsHome/go-rpi-rgb-led-matrix v0.0.0-20220709235716-bf87ebdb3e55 => /usr/src/app \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..b99bc11 --- /dev/null +++ b/main.go @@ -0,0 +1,59 @@ +package main + +import ( + "flag" + "fmt" + "image/color" + + rgbmatrix "gitea.wagshome.duckdns.org/publicWagsHome/go-rpi-rgb-led-matrix" +) + +var ( + rows = flag.Int("led-rows", 32, "number of rows supported") + cols = flag.Int("led-cols", 32, "number of columns supported") + parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels") + chain = flag.Int("led-chain", 2, "number of displays daisy-chained") + brightness = flag.Int("brightness", 100, "brightness (0-100)") + hardware_mapping = flag.String("led-gpio-mapping", "regular", "Name of GPIO mapping used.") + show_refresh = flag.Bool("led-show-refresh", false, "Show refresh rate.") + inverse_colors = flag.Bool("led-inverse", false, "Switch if your matrix has inverse colors on.") + disable_hardware_pulsing = flag.Bool("led-no-hardware-pulse", false, "Don't use hardware pin-pulse generation.") +) + +func main() { + config := &rgbmatrix.DefaultConfig + config.Rows = *rows + config.Cols = *cols + config.Parallel = *parallel + config.ChainLength = *chain + config.Brightness = *brightness + config.HardwareMapping = *hardware_mapping + config.ShowRefreshRate = *show_refresh + config.InverseColors = *inverse_colors + config.DisableHardwarePulsing = *disable_hardware_pulsing + + m, err := rgbmatrix.NewRGBLedMatrix(config) + fatal(err) + + c := rgbmatrix.NewCanvas(m) + defer c.Close() + + bounds := c.Bounds() + for x := bounds.Min.X; x < bounds.Max.X; x++ { + for y := bounds.Min.Y; y < bounds.Max.Y; y++ { + fmt.Println("x", x, "y", y) + c.Set(x, y, color.RGBA{255, 0, 0, 255}) + c.Render() + } + } +} + +func init() { + flag.Parse() +} + +func fatal(err error) { + if err != nil { + panic(err) + } +}