forked from urshofer/ofxRpiLED
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# All variables and this file are optional, if they are not present the PG and the | ||
# makefiles will try to parse the correct values from the file system. | ||
# | ||
# Variables that specify exclusions can use % as a wildcard to specify that anything in | ||
# that position will match. A partial path can also be specified to, for example, exclude | ||
# a whole folder from the parsed paths from the file system | ||
# | ||
# Variables can be specified using = or += | ||
# = will clear the contents of that variable both specified from the file or the ones parsed | ||
# from the file system | ||
# += will add the values to the previous ones in the file or the ones parsed from the file | ||
# system | ||
# | ||
# The PG can be used to detect errors in this file, just create a new project with this addon | ||
# and the PG will write to the console the kind of error and in which line it is | ||
|
||
meta: | ||
ADDON_NAME = ofxRpiLED | ||
ADDON_DESCRIPTION = Addon for driving an LED matrix on the Raspberry PI | ||
ADDON_AUTHOR = Urs Hofer | ||
ADDON_TAGS = "Hardware Interface" | ||
ADDON_URL = https://github.com/urshofer/ofxRpiLED | ||
|
||
common: | ||
# dependencies with other addons, a list of them separated by spaces | ||
# or use += in several lines | ||
# ADDON_DEPENDENCIES = | ||
|
||
# include search paths, this will be usually parsed from the file system | ||
# but if the addon or addon libraries need special search paths they can be | ||
# specified here separated by spaces or one per line using += | ||
# ADDON_INCLUDES = | ||
|
||
# any special flag that should be passed to the compiler when using this | ||
# addon | ||
# ADDON_CFLAGS = | ||
|
||
# any special flag that should be passed to the linker when using this | ||
# addon, also used for system libraries with -lname | ||
# ADDON_LDFLAGS = | ||
|
||
# linux only, any library that should be included in the project using | ||
# pkg-config | ||
# ADDON_PKG_CONFIG_LIBRARIES = | ||
|
||
# osx/iOS only, any framework that should be included in the project | ||
# ADDON_FRAMEWORKS = | ||
|
||
# source files, these will be usually parsed from the file system looking | ||
# in the src folders in libs and the root of the addon. if your addon needs | ||
# to include files in different places or a different set of files per platform | ||
# they can be specified here | ||
# ADDON_SOURCES = | ||
|
||
# some addons need resources to be copied to the bin/data folder of the project | ||
# specify here any files that need to be copied, you can use wildcards like * and ? | ||
# ADDON_DATA = | ||
|
||
# when parsing the file system looking for libraries exclude this for all or | ||
# a specific platform | ||
# ADDON_LIBS_EXCLUDE = | ||
|
||
# when parsing the file system looking for sources exclude this for all or | ||
# a specific platform | ||
ADDON_SOURCES_EXCLUDE = libs/oscpack/src/ip/win32/% | ||
|
||
# when parsing the file system looking for include paths exclude this for all or | ||
# a specific platform | ||
# ADDON_INCLUDES_EXCLUDE = | ||
|
||
linuxarmv6l: | ||
ADDON_PKG_CONFIG_LIBRARIES = matrix | ||
ADDON_LIBS_EXCLUDE = libs/matrix | ||
ADDON_INCLUDES_EXCLUDE = libs/matrix/% | ||
|
||
linuxarmv7l: | ||
ADDON_PKG_CONFIG_LIBRARIES = matrix | ||
ADDON_LIBS_EXCLUDE = libs/matrix | ||
ADDON_INCLUDES_EXCLUDE = libs/matrix/% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
#include "ofxRpiLED.h" | ||
|
||
|
||
// Constructor | ||
ofxRpiLED::ofxRpiLED() { | ||
rows = 32; // A 32x32 display. Use 16 when this is a 16x32 display. | ||
chain = 1; // Number of boards chained together. | ||
parallel = 1; // Number of chains in parallel (1..3). > 1 for plus or Pi2 | ||
} | ||
|
||
// Desonstructor | ||
ofxRpiLED::~ofxRpiLED() { | ||
canvas->Clear(); | ||
delete canvas; | ||
} | ||
|
||
void ofxRpiLED::setup(int _rows, int _chain, int _parallel){ | ||
rows = _rows; | ||
chain = _chain; | ||
parallel = _parallel; | ||
*canvas = new RGBMatrix(&io, rows, chain, parallel); | ||
canvas->Fill(0, 0, 0); | ||
cW = canvas->width(); | ||
cH = canvas->height(); | ||
} | ||
|
||
void ofxRpiLED::clear(){ | ||
canvas->Clear(); | ||
} | ||
|
||
void ofxRpiLED::draw(ofPixels p){ | ||
if (cW != p.getWidth() && cH != p.getHeight()) | ||
p.resize(cW, cH); | ||
for (int x = 0; x < cW; x++) { | ||
for (int y = 0; y < cH; y++) { | ||
ofColor c = p.getColor(x, y); | ||
canvas->SetPixel(x, y, c.r, c.g, c.b); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#include "ofMain.h" | ||
#include "led-matrix.h" | ||
|
||
using namespace rgb_matrix; | ||
|
||
class ofxRpiLED { | ||
|
||
private: | ||
|
||
int rows = 32; // A 32x32 display. Use 16 when this is a 16x32 display. | ||
int chain = 1; // Number of boards chained together. | ||
int parallel = 1; // Number of chains in parallel (1..3). > 1 for plus or Pi2 | ||
int cW; | ||
int cH; | ||
Canvas *canvas; | ||
|
||
|
||
public: | ||
|
||
ofxRpiLED(); | ||
~ofxRpiLED(); | ||
|
||
void setup(int _rows, int _chain, int _parallel); | ||
void clear(); | ||
void draw(ofPixels p); | ||
|
||
}; | ||
|
||
#endif |