Go binding for rpi-rgb-led-matrix an excellent C++ library to control RGB LED displays with Raspberry Pi GPIO.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Nathan Wagner 3d3b3fbf7b
build lightwatch / build (push) Has started running Details
new playAnimationUntil that stops animation when notify channel receives message
10 months ago
.devcontainer removed submodule, adding rt_options 1 year ago
.gitea/workflows
depends/rpi-rgb-led-matrix
emulator
examples
rpc
.gitmodules
.travis.yml
Dockerfile nailing it 1 year ago
LICENSE
README.md
builder
canvas.go
canvas_test.go
go.mod removed submodule, adding rt_options 1 year ago
go.sum removed submodule, adding rt_options 1 year ago
matrix.go duh exporting 1 year ago
toolkit.go new playAnimationUntil that stops animation when notify channel receives message 10 months ago

README.md

Nathan readme

sudo docker build . -t registry.local/rgbarm64lib:latest running this will get the build environment created

go app has to be built in /usr/src/app/subdir directory for now

go-rpi-rgb-led-matrix GoDoc Build Status

Go binding for rpi-rgb-led-matrix an excellent C++ library to control RGB LED displays with Raspberry Pi GPIO.

This library includes the basic bindings to control de LED Matrix directly and also a convenient ToolKit with more high level functions. Also some examples are included to test the library and the configuration.

The Canvas struct implements the image.Image interface from the Go standard library. This makes the interaction with the matrix simple as work with a normal image in Go, allowing the usage of any Go library build around the image.Image interface.

To learn about the configuration and the wiring go to the original library, is highly detailed and well explained.

Installation

The recommended way to install go-rpi-rgb-led-matrix is:

go get github.com/mcuadros/go-rpi-rgb-led-matrix

Then you will get an expected error like this:

# github.com/mcuadros/go-rpi-rgb-led-matrix
/usr/bin/ld: cannot find -lrgbmatrix
collect2: error: ld returned 1 exit status

This happens because you need to compile the rgbmatrix C bindings:

cd $GOPATH/src/github.com/mcuadros/go-rpi-rgb-led-matrix/vendor/rpi-rgb-led-matrix/
git submodule update --init
make
cd $GOPATH/src/github.com/mcuadros/go-rpi-rgb-led-matrix/
go install -v ./...

Examples

Setting all the pixels to white:

// create a new Matrix instance with the DefaultConfig
m, _ := rgbmatrix.NewRGBLedMatrix(&rgbmatrix.DefaultConfig)

// create the Canvas, implements the image.Image interface
c := rgbmatrix.NewCanvas(m)
defer c.Close() // don't forgot close the Matrix, if not your leds will remain on
 
// using the standard draw.Draw function we copy a white image onto the Canvas
draw.Draw(c, c.Bounds(), &image.Uniform{color.White}, image.ZP, draw.Src)

// don't forget call Render to display the new led status
c.Render()

Playing a GIF into your matrix during 30 seconds:

// create a new Matrix instance with the DefaultConfig
m, _ := rgbmatrix.NewRGBLedMatrix(&rgbmatrix.DefaultConfig)

// create a ToolKit instance
tk := rgbmatrix.NewToolKit(m)
defer tk.Close() // don't forgot close the Matrix, if not your leds will remain on

// open the gif file for reading
file, _ := os.Open("mario.gif")

// play of the gif using the io.Reader
close, _ := tk.PlayGIF(f)
fatal(err)

// we wait 30 seconds and then we stop the playing gif sending a True to the returned chan
time.Sleep(time.Second * 30)
close <- true

The image of the header was recorded using this few lines, the running Mario gif, and three 32x64 pannels.

Check the folder examples folder for more examples

Matrix Emulation

As part of the library an small Matrix emulator is provided. The emulator renderize a virtual RGB matrix on a window in your desktop, without needing a real RGB matrix connected to your computer.

To execute the emulator set the MATRIX_EMULATOR environment variable to 1, then when NewRGBLedMatrix is used, a emulator.Emulator is returned instead of a interface the real board.

License

MIT, see LICENSE