docuentation
parent
e0ab4bf8de
commit
8c16625657
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 Máximo Cuadros
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,88 @@
|
||||
# go-rpi-rgb-led-matrix [![GoDoc](https://godoc.org/github.com/mcuadros/go-rpi-rgb-led-matrix?status.svg)](https://godoc.org/github.com/mcuadros/go-rpi-rgb-led-matrix) [![Build Status](https://travis-ci.org/mcuadros/go-rpi-rgb-led-matrix.svg?branch=master)](https://travis-ci.org/mcuadros/go-rpi-rgb-led-matrix)
|
||||
<img width="250" src="https://cloud.githubusercontent.com/assets/1573114/20248154/c17c1f2e-a9dd-11e6-805b-bf7d8ee73121.gif" align="right" />
|
||||
Go binding for [`rpi-rgb-led-matrix`](https://github.com/hzeller/rpi-rgb-led-matrix) an excellent C++ library to control [RGB LED displays](https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/overview) with Raspberry Pi GPIO.
|
||||
|
||||
This library includes the basic bindings to control de LED Matrix directly and also a convenient [ToolKit](https://godoc.org/github.com/mcuadros/go-rpi-rgb-led-matrix#ToolKit) with more high level functions. Also some [examples](https://github.com/mcuadros/go-rpi-rgb-led-matrix/tree/master/examples) are included to test the library and the configuration.
|
||||
|
||||
The [`Canvas`](https://godoc.org/github.com/mcuadros/go-rpi-rgb-led-matrix#Canvas) struct implements the [`image.Image`](https://golang.org/pkg/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](https://github.com/hzeller/rpi-rgb-led-matrix), is highly detailed and well explained.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
The recommended way to install `go-rpi-rgb-led-matrix` is:
|
||||
|
||||
```sh
|
||||
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 have installed the `rgbmatrix` C bindings, execute the following commands to install it:
|
||||
|
||||
```sh
|
||||
cd $GOPATH/src/github.com/mcuadros/go-rpi-rgb-led-matrix/vendor/rpi-rgb-led-matrix/
|
||||
git submodule update --init
|
||||
make install
|
||||
cd $GOPATH/src/github.com/mcuadros/go-rpi-rgb-led-matrix/
|
||||
go install -v ./...
|
||||
```
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Setting all the pixels to white:
|
||||
|
||||
```go
|
||||
// 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:
|
||||
|
||||
```go
|
||||
// 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
|
||||
```
|
||||
|
||||
Using this the running Mario gif, and three 32x64 pannels, was recorded the image from this readme.
|
||||
<img src="https://cloud.githubusercontent.com/assets/1573114/20248173/2e2f97ae-a9de-11e6-95e6-e0548199501d.gif" align="right" width="100" />
|
||||
|
||||
Check the folder [`examples`](https://github.com/mcuadros/go-rpi-rgb-led-matrix/tree/master/examples) folder for more examples
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT, see [LICENSE](LICENSE)
|
Loading…
Reference in New Issue