Skip to content

Commit 8c16625

Browse files
committed
docuentation
1 parent e0ab4bf commit 8c16625

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Máximo Cuadros
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# 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)
2+
<img width="250" src="https://cloud.githubusercontent.com/assets/1573114/20248154/c17c1f2e-a9dd-11e6-805b-bf7d8ee73121.gif" align="right" />
3+
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.
4+
5+
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.
6+
7+
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.
8+
9+
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.
10+
11+
Installation
12+
------------
13+
14+
The recommended way to install `go-rpi-rgb-led-matrix` is:
15+
16+
```sh
17+
go get github.com/mcuadros/go-rpi-rgb-led-matrix
18+
```
19+
20+
Then you will get an *expected* error like this:
21+
22+
```
23+
# github.com/mcuadros/go-rpi-rgb-led-matrix
24+
/usr/bin/ld: cannot find -lrgbmatrix
25+
collect2: error: ld returned 1 exit status
26+
```
27+
28+
This happens because you need to have installed the `rgbmatrix` C bindings, execute the following commands to install it:
29+
30+
```sh
31+
cd $GOPATH/src/github.com/mcuadros/go-rpi-rgb-led-matrix/vendor/rpi-rgb-led-matrix/
32+
git submodule update --init
33+
make install
34+
cd $GOPATH/src/github.com/mcuadros/go-rpi-rgb-led-matrix/
35+
go install -v ./...
36+
```
37+
38+
Examples
39+
--------
40+
41+
Setting all the pixels to white:
42+
43+
```go
44+
// create a new Matrix instance with the DefaultConfig
45+
m, _ := rgbmatrix.NewRGBLedMatrix(&rgbmatrix.DefaultConfig)
46+
47+
// create the Canvas, implements the image.Image interface
48+
c := rgbmatrix.NewCanvas(m)
49+
defer c.Close() // don't forgot close the Matrix, if not your leds will remain on
50+
51+
// using the standard draw.Draw function we copy a white image onto the Canvas
52+
draw.Draw(c, c.Bounds(), &image.Uniform{color.White}, image.ZP, draw.Src)
53+
54+
// don't forget call Render to display the new led status
55+
c.Render()
56+
```
57+
58+
Playing a GIF into your matrix during 30 seconds:
59+
60+
```go
61+
// create a new Matrix instance with the DefaultConfig
62+
m, _ := rgbmatrix.NewRGBLedMatrix(&rgbmatrix.DefaultConfig)
63+
64+
// create a ToolKit instance
65+
tk := rgbmatrix.NewToolKit(m)
66+
defer tk.Close() // don't forgot close the Matrix, if not your leds will remain on
67+
68+
// open the gif file for reading
69+
file, _ := os.Open("mario.gif")
70+
71+
// play of the gif using the io.Reader
72+
close, _ := tk.PlayGIF(f)
73+
fatal(err)
74+
75+
// we wait 30 seconds and then we stop the playing gif sending a True to the returned chan
76+
time.Sleep(time.Second * 30)
77+
close <- true
78+
```
79+
80+
Using this the running Mario gif, and three 32x64 pannels, was recorded the image from this readme.
81+
<img src="https://cloud.githubusercontent.com/assets/1573114/20248173/2e2f97ae-a9de-11e6-95e6-e0548199501d.gif" align="right" width="100" />
82+
83+
Check the folder [`examples`](https://github.com/mcuadros/go-rpi-rgb-led-matrix/tree/master/examples) folder for more examples
84+
85+
License
86+
-------
87+
88+
MIT, see [LICENSE](LICENSE)

0 commit comments

Comments
 (0)