From 7785d6598240772818f5a1fd4dd0b764d2c68c63 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Mon, 2 Mar 2015 10:29:12 -0800 Subject: [PATCH] o doc update. --- README.md | 15 +++++++++------ lib/Makefile | 5 +++-- lib/framebuffer-internal.h | 18 +++++++++++------- lib/framebuffer.cc | 18 +++++++++--------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 2efc19895..a329df01a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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). diff --git a/lib/Makefile b/lib/Makefile index a2c31076c..78140d7d3 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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 @@ -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. diff --git a/lib/framebuffer-internal.h b/lib/framebuffer-internal.h index 38653870e..30b7c1d00 100644 --- a/lib/framebuffer-internal.h +++ b/lib/framebuffer-internal.h @@ -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) @@ -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 diff --git a/lib/framebuffer.cc b/lib/framebuffer.cc index 1cd51c7ca..911c545dd 100644 --- a/lib/framebuffer.cc +++ b/lib/framebuffer.cc @@ -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_ @@ -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 @@ -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; @@ -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; @@ -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. @@ -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