Skip to content

Commit

Permalink
o doc update.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeller committed Mar 2, 2015
1 parent 090c083 commit 7785d65
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ needs to generate more pixels of course). For the same number of panels,
always prefer parallel chains before daisy chaining more panels, as it will
keep the refresh-rate higher.

Two panels will work right out of the box, for three panels, uncomment the
line
For multiple parallel boards to work, you want to uncomment

#DEFINES+=-DSUPPORT_TRIPLE_PARALLEL
#DEFINES+=-DSUPPORT_MULTI_PARALLEL

in [lib/Makefile](./lib/Makefile).
in [lib/Makefile](./lib/Makefile). While two parallel panels will work out
of the box without this, it frees up the pins for I²C, which you might
want to use for other things. However, for three panels to work, you definitely
want to uncomment this.

The second and third panel chain share some of the wires of the first panel:
connect **GND, A, B, C, D, OE, CLK** and **STR** to the same pins you already
Expand All @@ -106,9 +108,10 @@ Then connect the following
The third panel will use some pins that are otherwise used for I²C and the
serial interface. If you don't care about these, then we can use these to
connect a third chain of panels.
You need to uncomment

#DEFINES+=-DSUPPORT_TRIPLE_PARALLEL
For three panels, you need to uncomment

#DEFINES+=-DSUPPORT_MULTI_PARALLEL

in [lib/Makefile](./lib/Makefile).

Expand Down
5 changes: 3 additions & 2 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ TARGET=librgbmatrix.a
# This will only work on the plus models or RPi2 with 40 GPIO pins.
#
# This is useful in any case, _unless_ you have an older installation with
# slightly different cabeling or a Raspberry Pi 1, Revision 1 (very old).
# classic cabeling of previous versions of this library or a
# Raspberry Pi 1, Revision 1 (very old).
#
# The reason why this is disabled by default is that it is not compatible with
# GPIO cabelings of previous versions of this software and thus is already
Expand All @@ -19,7 +20,7 @@ TARGET=librgbmatrix.a
# Hence we leave this off for now for the least amount of surprise.
# If you connect 3 chains in parallel, switch this on. The default
# will work up to 2 chains just fine, but you won't be able to use I²C.
#DEFINES+=-DSUPPORT_TRIPLE_PARALLEL
DEFINES+=-DSUPPORT_MULTI_PARALLEL

# If you see that your display is inverse, you might have a matrix variant
# has uses inverse logic for the RGB bits. In that case: uncomment this.
Expand Down
18 changes: 11 additions & 7 deletions lib/framebuffer-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,18 @@ class RGBMatrix::Framebuffer {

union IoBits {
struct {
// This bitset reflects the GPIO mapping.
#ifdef SUPPORT_TRIPLE_PARALLEL
// This bitset reflects the GPIO mapping. The naming of the
// pins of type 'p0_r1' means 'first parallel chain, red-bit one'
#ifdef SUPPORT_MULTI_PARALLEL
unsigned int unused_0_1 : 2; // 0..1 (only on RPi 1, Revision 1)
unsigned int p2_g1 : 1; // 2 (masks SDA)
unsigned int p2_b1 : 1; // 3 (masks SCL)
unsigned int p2_g1 : 1; // 2 (masks SDA when parallel=3)
unsigned int p2_b1 : 1; // 3 (masks SCL when parallel=3)
#else
// The Revision1 and Revision2 boards have different GPIO mappings
// on the same pin. Just use both.
// on the pins 2 and 3. Just use both interpretations.
// To keep the I2C pins free, we don't use these anymore.
// We keep this backward compatible unless SUPPORT_MULTI_PARALLEL
// is explicitly chosen.
unsigned int output_enable_rev1 : 1; // 0 (RPi 1, Revision 1)
unsigned int clock_rev1 : 1; // 1 (RPi 1, Revision 1)
unsigned int output_enable_rev2 : 1; // 2 (Pi1.Rev2; masks: I2C SDA)
Expand All @@ -87,8 +91,8 @@ class RGBMatrix::Framebuffer {
unsigned int clock : 1; // 11 (masks: SCKL of SPI_0)
unsigned int p1_r1 : 1; // 12 (only on A+/B+/Pi2)
unsigned int p1_g2 : 1; // 13 (only on A+/B+/Pi2)
unsigned int p2_r1 : 1; // 14 (masks: TxD)
unsigned int p2_r2 : 1; // 15 (masks: RxD)
unsigned int p2_r1 : 1; // 14 (masks TxD when parallel=3)
unsigned int p2_r2 : 1; // 15 (masks RxD when parallel=3)
unsigned int unused_16 : 1; // 16 (only on A+/B+/Pi2)
unsigned int p0_r1 : 1; // 17
unsigned int p0_g1 : 1; // 18
Expand Down
18 changes: 9 additions & 9 deletions lib/framebuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ enum {

static const long kBaseTimeNanos = 200;

// Only if SUPPORT_TRIPLE_PARALLEL is not defined, we allow classic wiring.
// This is just the negative of SUPPORT_TRIPLE_PARALLEL, but conceptually
// Only if SUPPORT_MULTI_PARALLEL is not defined, we allow classic wiring.
// This is just the negative of SUPPORT_MULTI_PARALLEL, but conceptually
// it is something different as it means some 'classic' GPIO pins have a
// different function. So make it a separate #define for readability.
#ifdef SUPPORT_TRIPLE_PARALLEL
#ifdef SUPPORT_MULTI_PARALLEL
# undef SUPPORT_CLASSIC_LED_GPIO_WIRING_
#else
# define SUPPORT_CLASSIC_LED_GPIO_WIRING_
Expand All @@ -51,10 +51,10 @@ RGBMatrix::Framebuffer::Framebuffer(int rows, int columns, int parallel)
Clear();
assert(rows_ <= 32);
assert(parallel >= 1 && parallel <= 3);
#ifndef SUPPORT_TRIPLE_PARALLEL
#ifndef SUPPORT_MULTI_PARALLEL
if (parallel >= 3) {
fprintf(stderr, "In order for parallel=3 to work, you need to "
"define SUPPORT_TRIPLE_PARALLEL in lib/Makefile.\n");
"define SUPPORT_MULTI_PARALLEL in lib/Makefile.\n");
assert(parallel < 3);
}
#endif
Expand Down Expand Up @@ -86,7 +86,7 @@ RGBMatrix::Framebuffer::~Framebuffer() {
b.bits.p1_r2 = b.bits.p1_g2 = b.bits.p1_b2 = 1;
}

#ifdef SUPPORT_TRIPLE_PARALLEL
#ifdef SUPPORT_MULTI_PARALLEL
if (parallel_ >= 3) {
b.bits.p2_r1 = b.bits.p2_g1 = b.bits.p2_b1 = 1;
b.bits.p2_r2 = b.bits.p2_g2 = b.bits.p2_b2 = 1;
Expand Down Expand Up @@ -170,7 +170,7 @@ void RGBMatrix::Framebuffer::Fill(uint8_t r, uint8_t g, uint8_t b) {
plane_bits.bits.p1_g1 = plane_bits.bits.p1_g2 = (green & mask) == mask;
plane_bits.bits.p0_b1 = plane_bits.bits.p0_b2 =
plane_bits.bits.p1_b1 = plane_bits.bits.p1_b2 = (blue & mask) == mask;
#ifdef SUPPORT_TRIPLE_PARALLEL
#ifdef SUPPORT_MULTI_PARALLEL
plane_bits.bits.p2_r1 = plane_bits.bits.p2_r2 = (red & mask) == mask;
plane_bits.bits.p2_g1 = plane_bits.bits.p2_g2 = (green & mask) == mask;
plane_bits.bits.p2_b1 = plane_bits.bits.p2_b2 = (blue & mask) == mask;
Expand Down Expand Up @@ -236,7 +236,7 @@ void RGBMatrix::Framebuffer::SetPixel(int x, int y,
bits += columns_;
}
}
#ifdef SUPPORT_TRIPLE_PARALLEL
#ifdef SUPPORT_MULTI_PARALLEL
} else {
// Parallel chain #3
if (y - 2*rows_ < double_rows_) { // Upper sub-panel.
Expand Down Expand Up @@ -278,7 +278,7 @@ void RGBMatrix::Framebuffer::DumpToMatrix(GPIO *io) {
= color_clk_mask.bits.p1_b2 = 1;
}

#ifdef SUPPORT_TRIPLE_PARALLEL
#ifdef SUPPORT_MULTI_PARALLEL
if (parallel_ >= 3) {
color_clk_mask.bits.p2_r1
= color_clk_mask.bits.p2_g1
Expand Down

0 comments on commit 7785d65

Please sign in to comment.