diff --git a/README.md b/README.md index 36706a0..75d7aa9 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,8 @@ A [typical RGB panel available for purchase](https://www.aliexpress.com/item/256 Yes you can. If you want to use with a 64x64 pixel panel (typically a HUB75*E* panel) you MUST configure a valid *E_PIN* to your ESP32 and connect it to the E pin of the HUB75 panel! Hence the 'E' in 'HUB75E' -This library has only been tested with a 64 pixel (wide) and 32 (high) RGB panel. Theoretically, if you want to chain two of these horizontally to make a 128x32 panel you can do so with the cable and then set the MATRIX_WIDTH to '128'. +This library has only been tested with a 64 pixel (wide) and 32 (high) RGB panel. Theoretically, if you want to chain two of these horizontally to make a 128x32 panel you can do so with the cable and then set the MATRIX_WIDTH to '128'. Refer to the [Chained Panels](examples/ChainedPanels/) example. + ### New Feature diff --git a/examples/ChainedPanels/ChainedPanels.ino b/examples/ChainedPanels/ChainedPanels.ino new file mode 100644 index 0000000..ffdb5e2 --- /dev/null +++ b/examples/ChainedPanels/ChainedPanels.ino @@ -0,0 +1,158 @@ +/******************************************************************* + This is the PatternPlasma Demo adopted for use with multiple + displays arranged in a non standard order + + What is a non standard order? + + When you connect multiple panels together, the library treats the + multiple panels as one big panel arranged horizontally. Arranging + the displays like this would be a standard order. + + [ 4 ][ 3 ][ 2 ][ 1 ] (ESP32 is connected to 1) + + If you wanted to arrange the displays vertically, or in rows and + columns this example might be able to help. + + [ 4 ][ 3 ] + [ 2 ][ 1 ] + + It creates a virtual screen that you draw to in the same way you would + the matrix, but it will look after mapping it back to the displays. + + ----------- + Steps to use + ----------- + + 1) In ESP32-RGB64x32MatrixPanel-I2S-DMA.h: + + - Set the MATRIX_HEIGHT to be the y resolution of the physical chained panels in a line (if the panels are 32 x 16, set it to be 16) + - Set the MATRIX_WIDTH to be the sum of the x resolution of all the physical chained panels (i.e. If you have 4 x (32px w x 16px h) panels, 32x4 = 128) + + 2) In the sketch: + + - Set values for NUM_ROWS, NUM_COLS, PANEL_RES_X, PANEL_RES_Y. There are comments beside them + explaining what they are in more detail. + - Other than where the matrix is defined and matrix.begin in the setup, you should now be using the virtual display + for everything (drawing pixels, writing text etc). You can do a find and replace of all calls if it's an existing sketch + (just make sure you don't replace the definition and the matrix.begin) + - If the sketch makes use of MATRIX_HEIGHT or MATRIX_WIDTH, these will need to be replaced with the width and height + of your virtual screen. Either make new defines and use that, or you can use virtualDisp.width() or .height() + + Parts: + ESP32 D1 Mini * - https://s.click.aliexpress.com/e/_dSi824B + ESP32 I2S Matrix Shield (From my Tindie) = https://www.tindie.com/products/brianlough/esp32-i2s-matrix-shield/ + + * * = Affilate + + If you find what I do useful and would like to support me, + please consider becoming a sponsor on Github + https://github.com/sponsors/witnessmenow/ + + + Written by Brian Lough + YouTube: https://www.youtube.com/brianlough + Tindie: https://www.tindie.com/stores/brianlough/ + Twitter: https://twitter.com/witnessmenow + *******************************************************************/ + +//#define USE_CUSTOM_PINS // uncomment to use custom pins, then provide below + +#define A_PIN 26 +#define B_PIN 4 +#define C_PIN 27 +#define D_PIN 2 +#define E_PIN 21 + +#define R1_PIN 5 +#define R2_PIN 19 +#define G1_PIN 17 +#define G2_PIN 16 +#define B1_PIN 18 +#define B2_PIN 25 + +#define CLK_PIN 14 +#define LAT_PIN 15 +#define OE_PIN 13 + + +/* Include FastLED, DMA Display (for module driving), and VirtualMatrixPanel + * to enable easy painting & graphics for a chain of individual LED modules. + */ + +#define NUM_ROWS 2 // Number of rows panels in your overall display +#define NUM_COLS 1 // number of panels in each row + +#define PANEL_RES_X 64 // Number of pixels wide of each INDIVIDUAL panel module. +#define PANEL_RES_Y 32 // Number of pixels tall of each INDIVIDUAL panel module. + +/* Create physical module driver class AND virtual (chained) display class. */ +#include +RGB64x32MatrixPanel_I2S_DMA dma_display; +VirtualMatrixPanel virtualDisp(dma_display, NUM_ROWS, NUM_COLS, PANEL_RES_X, PANEL_RES_Y); + +/* FastLED Global Variables for Pattern */ +#include +int time_counter = 0; +int cycles = 0; +CRGBPalette16 currentPalette; +CRGB currentColor; + +CRGB ColorFromCurrentPalette(uint8_t index = 0, uint8_t brightness = 255, TBlendType blendType = LINEARBLEND) { + return ColorFromPalette(currentPalette, index, brightness, blendType); +} + +void setup() { + + Serial.begin(115200); + + Serial.println(""); Serial.println(""); Serial.println(""); + Serial.println("*****************************************************"); + Serial.println(" HELLO !"); + Serial.println("*****************************************************"); + +#ifdef USE_CUSTOM_PINS + dma_display.begin(R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN ); // setup the LED matrix +#else + dma_display.begin(); +#endif + + // fill the screen with 'black' + //dma_display.fillScreen(dma_display.color444(0, 0, 0)); + virtualDisp.fillScreen(virtualDisp.color444(0, 0, 0)); + + // Set current FastLED palette + currentPalette = RainbowColors_p; + + virtualDisp.drawRect(4, 4, PANEL_RES_X * NUM_COLS - 8, PANEL_RES_Y * NUM_ROWS - 8, virtualDisp.color565(255, 255, 255)); + delay(5000); + +} + + +void loop() { + + + for (int x = 0; x < virtualDisp.width(); x++) { + for (int y = 0; y < virtualDisp.height(); y++) { + int16_t v = 0; + uint8_t wibble = sin8(time_counter); + v += sin16(x * wibble * 3 + time_counter); + v += cos16(y * (128 - wibble) + time_counter); + v += sin16(y * x * cos8(-time_counter) / 8); + + currentColor = ColorFromPalette(currentPalette, (v >> 8) + 127); //, brightness, currentBlendType); + virtualDisp.drawPixelRGB888(x, y, currentColor.r, currentColor.g, currentColor.b); + + } + } + + time_counter += 1; + cycles++; + + if (cycles >= 2048) { + time_counter = 0; + cycles = 0; + } + + +} // end loop \ No newline at end of file diff --git a/examples/ChainedPanels/README.md b/examples/ChainedPanels/README.md new file mode 100644 index 0000000..b81d395 --- /dev/null +++ b/examples/ChainedPanels/README.md @@ -0,0 +1,54 @@ + ## Chained Panels example - Chaining individual LED matrix panels to make a larger panel ## + + This is the PatternPlasma Demo adopted for use with multiple + displays arranged in a non standard order + + ### What is a non standard order? ### + + When you connect multiple panels together, the library treats the + multiple panels as one big panel arranged horizontally. Arranging + the displays like this would be a standard order. + + [ 4 ][ 3 ][ 2 ][ 1 ] (ESP32 is connected to 1) + + If you wanted to arrange the displays vertically, or in rows and + columns this example might be able to help. + + [ 4 ][ 3 ] + [ 2 ][ 1 ] + + It creates a virtual screen that you draw to in the same way you would + the matrix, but it will look after mapping it back to the displays. + +### Steps to Use ### + + 1) In ESP32-RGB64x32MatrixPanel-I2S-DMA.h: + + - Set the MATRIX_HEIGHT to be the y resolution of the physical chained panels in a line (if the panels are 32 x 16, set it to be 16) + - Set the MATRIX_WIDTH to be the sum of the x resolution of all the physical chained panels (i.e. If you have 4 x (32px w x 16px h) panels, 32x4 = 128) + + 2) In the sketch: + + - Set values for NUM_ROWS, NUM_COLS, PANEL_RES_X, PANEL_RES_Y. There are comments beside them + explaining what they are in more detail. + - Other than where the matrix is defined and matrix.begin in the setup, you should now be using the virtual display + for everything (drawing pixels, writing text etc). You can do a find and replace of all calls if it's an existing sketch + (just make sure you don't replace the definition and the matrix.begin) + - If the sketch makes use of MATRIX_HEIGHT or MATRIX_WIDTH, these will need to be replaced with the width and height + of your virtual screen. Either make new defines and use that, or you can use virtualDisp.width() or .height() + +#### Contributor #### + Written by Brian Lough + YouTube: https://www.youtube.com/brianlough + Tindie: https://www.tindie.com/stores/brianlough/ + Twitter: https://twitter.com/witnessmenow + + Parts: + ESP32 D1 Mini * - https://s.click.aliexpress.com/e/_dSi824B + ESP32 I2S Matrix Shield (From my Tindie) = https://www.tindie.com/products/brianlough/esp32-i2s-matrix-shield/ + + * * = Affilate + + If you find what I do useful and would like to support me, + please consider becoming a sponsor on Github + https://github.com/sponsors/witnessmenow/ diff --git a/examples/PanelGFXDemo/PanelGFXDemo.ino b/examples/PanelGFXDemo/PanelGFXDemo.ino deleted file mode 100644 index 602043a..0000000 --- a/examples/PanelGFXDemo/PanelGFXDemo.ino +++ /dev/null @@ -1,579 +0,0 @@ -// Adafruit_NeoMatrix example for single NeoPixel Shield. -// By Marc MERLIN -// Contains code (c) Adafruit, license BSD - -#include -RGB64x32MatrixPanel_I2S_DMA matrix; -#include "smileytongue24.h" - -// Panel Matrix doesn't fully work like Neomatrix (which I wrote this -// demo for), so map a few calls to be compatible. The rest comes from -// Adafruit::GFX and works the same on both backends. -#define setBrightness(x) fillScreen(0) // no-op, no brightness on this board -#define clear() fillScreen(0) -#define show() drawPixel(0, 0, 0); // no show method in this GFX implementation -#define Color(x,y,z) color444(x/16,y/16,z/16) - -// Define matrix width and height. -#define mw 64 -#define mh 32 - -// This could also be defined as matrix.color(255,0,0) but those defines -// are meant to work for Adafruit::GFX backends that are lacking color() -#define LED_BLACK 0 - -#define LED_RED_VERYLOW (3 << 11) -#define LED_RED_LOW (7 << 11) -#define LED_RED_MEDIUM (15 << 11) -#define LED_RED_HIGH (31 << 11) - -#define LED_GREEN_VERYLOW (1 << 5) -#define LED_GREEN_LOW (15 << 5) -#define LED_GREEN_MEDIUM (31 << 5) -#define LED_GREEN_HIGH (63 << 5) - -#define LED_BLUE_VERYLOW 3 -#define LED_BLUE_LOW 7 -#define LED_BLUE_MEDIUM 15 -#define LED_BLUE_HIGH 31 - -#define LED_ORANGE_VERYLOW (LED_RED_VERYLOW + LED_GREEN_VERYLOW) -#define LED_ORANGE_LOW (LED_RED_LOW + LED_GREEN_LOW) -#define LED_ORANGE_MEDIUM (LED_RED_MEDIUM + LED_GREEN_MEDIUM) -#define LED_ORANGE_HIGH (LED_RED_HIGH + LED_GREEN_HIGH) - -#define LED_PURPLE_VERYLOW (LED_RED_VERYLOW + LED_BLUE_VERYLOW) -#define LED_PURPLE_LOW (LED_RED_LOW + LED_BLUE_LOW) -#define LED_PURPLE_MEDIUM (LED_RED_MEDIUM + LED_BLUE_MEDIUM) -#define LED_PURPLE_HIGH (LED_RED_HIGH + LED_BLUE_HIGH) - -#define LED_CYAN_VERYLOW (LED_GREEN_VERYLOW + LED_BLUE_VERYLOW) -#define LED_CYAN_LOW (LED_GREEN_LOW + LED_BLUE_LOW) -#define LED_CYAN_MEDIUM (LED_GREEN_MEDIUM + LED_BLUE_MEDIUM) -#define LED_CYAN_HIGH (LED_GREEN_HIGH + LED_BLUE_HIGH) - -#define LED_WHITE_VERYLOW (LED_RED_VERYLOW + LED_GREEN_VERYLOW + LED_BLUE_VERYLOW) -#define LED_WHITE_LOW (LED_RED_LOW + LED_GREEN_LOW + LED_BLUE_LOW) -#define LED_WHITE_MEDIUM (LED_RED_MEDIUM + LED_GREEN_MEDIUM + LED_BLUE_MEDIUM) -#define LED_WHITE_HIGH (LED_RED_HIGH + LED_GREEN_HIGH + LED_BLUE_HIGH) - -static const uint8_t PROGMEM - mono_bmp[][8] = - { - { // 0: checkered 1 - B10101010, - B01010101, - B10101010, - B01010101, - B10101010, - B01010101, - B10101010, - B01010101, - }, - - { // 1: checkered 2 - B01010101, - B10101010, - B01010101, - B10101010, - B01010101, - B10101010, - B01010101, - B10101010, - }, - - { // 2: smiley - B00111100, - B01000010, - B10100101, - B10000001, - B10100101, - B10011001, - B01000010, - B00111100 }, - - { // 3: neutral - B00111100, - B01000010, - B10100101, - B10000001, - B10111101, - B10000001, - B01000010, - B00111100 }, - - { // 4; frowny - B00111100, - B01000010, - B10100101, - B10000001, - B10011001, - B10100101, - B01000010, - B00111100 }, - }; - -static const uint16_t PROGMEM - // These bitmaps were written for a backend that only supported - // 4 bits per color with Blue/Green/Red ordering while neomatrix - // uses native 565 color mapping as RGB. - // I'm leaving the arrays as is because it's easier to read - // which color is what when separated on a 4bit boundary - // The demo code will modify the arrays at runtime to be compatible - // with the neomatrix color ordering and bit depth. - RGB_bmp[][64] = { - // 00: blue, blue/red, red, red/green, green, green/blue, blue, white - { 0x100, 0x200, 0x300, 0x400, 0x600, 0x800, 0xA00, 0xF00, - 0x101, 0x202, 0x303, 0x404, 0x606, 0x808, 0xA0A, 0xF0F, - 0x001, 0x002, 0x003, 0x004, 0x006, 0x008, 0x00A, 0x00F, - 0x011, 0x022, 0x033, 0x044, 0x066, 0x088, 0x0AA, 0x0FF, - 0x010, 0x020, 0x030, 0x040, 0x060, 0x080, 0x0A0, 0x0F0, - 0x110, 0x220, 0x330, 0x440, 0x660, 0x880, 0xAA0, 0xFF0, - 0x100, 0x200, 0x300, 0x400, 0x600, 0x800, 0xA00, 0xF00, - 0x111, 0x222, 0x333, 0x444, 0x666, 0x888, 0xAAA, 0xFFF, }, - - // 01: grey to white - { 0x111, 0x222, 0x333, 0x555, 0x777, 0x999, 0xAAA, 0xFFF, - 0x222, 0x222, 0x333, 0x555, 0x777, 0x999, 0xAAA, 0xFFF, - 0x333, 0x333, 0x333, 0x555, 0x777, 0x999, 0xAAA, 0xFFF, - 0x555, 0x555, 0x555, 0x555, 0x777, 0x999, 0xAAA, 0xFFF, - 0x777, 0x777, 0x777, 0x777, 0x777, 0x999, 0xAAA, 0xFFF, - 0x999, 0x999, 0x999, 0x999, 0x999, 0x999, 0xAAA, 0xFFF, - 0xAAA, 0xAAA, 0xAAA, 0xAAA, 0xAAA, 0xAAA, 0xAAA, 0xFFF, - 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, 0xFFF, }, - - // 02: low red to high red - { 0x001, 0x002, 0x003, 0x005, 0x007, 0x009, 0x00A, 0x00F, - 0x002, 0x002, 0x003, 0x005, 0x007, 0x009, 0x00A, 0x00F, - 0x003, 0x003, 0x003, 0x005, 0x007, 0x009, 0x00A, 0x00F, - 0x005, 0x005, 0x005, 0x005, 0x007, 0x009, 0x00A, 0x00F, - 0x007, 0x007, 0x007, 0x007, 0x007, 0x009, 0x00A, 0x00F, - 0x009, 0x009, 0x009, 0x009, 0x009, 0x009, 0x00A, 0x00F, - 0x00A, 0x00A, 0x00A, 0x00A, 0x00A, 0x00A, 0x00A, 0x00F, - 0x00F, 0x00F, 0x00F, 0x00F, 0x00F, 0x00F, 0x00F, 0x00F, }, - - // 03: low green to high green - { 0x010, 0x020, 0x030, 0x050, 0x070, 0x090, 0x0A0, 0x0F0, - 0x020, 0x020, 0x030, 0x050, 0x070, 0x090, 0x0A0, 0x0F0, - 0x030, 0x030, 0x030, 0x050, 0x070, 0x090, 0x0A0, 0x0F0, - 0x050, 0x050, 0x050, 0x050, 0x070, 0x090, 0x0A0, 0x0F0, - 0x070, 0x070, 0x070, 0x070, 0x070, 0x090, 0x0A0, 0x0F0, - 0x090, 0x090, 0x090, 0x090, 0x090, 0x090, 0x0A0, 0x0F0, - 0x0A0, 0x0A0, 0x0A0, 0x0A0, 0x0A0, 0x0A0, 0x0A0, 0x0F0, - 0x0F0, 0x0F0, 0x0F0, 0x0F0, 0x0F0, 0x0F0, 0x0F0, 0x0F0, }, - - // 04: low blue to high blue - { 0x100, 0x200, 0x300, 0x500, 0x700, 0x900, 0xA00, 0xF00, - 0x200, 0x200, 0x300, 0x500, 0x700, 0x900, 0xA00, 0xF00, - 0x300, 0x300, 0x300, 0x500, 0x700, 0x900, 0xA00, 0xF00, - 0x500, 0x500, 0x500, 0x500, 0x700, 0x900, 0xA00, 0xF00, - 0x700, 0x700, 0x700, 0x700, 0x700, 0x900, 0xA00, 0xF00, - 0x900, 0x900, 0x900, 0x900, 0x900, 0x900, 0xA00, 0xF00, - 0xA00, 0xA00, 0xA00, 0xA00, 0xA00, 0xA00, 0xA00, 0xF00, - 0xF00, 0xF00, 0xF00, 0xF00, 0xF00, 0xF00, 0xF00, 0xF00, }, - - // 05: 1 black, 2R, 2O, 2G, 1B with 4 blue lines rising right - { 0x000, 0x200, 0x000, 0x400, 0x000, 0x800, 0x000, 0xF00, - 0x000, 0x201, 0x002, 0x403, 0x004, 0x805, 0x006, 0xF07, - 0x008, 0x209, 0x00A, 0x40B, 0x00C, 0x80D, 0x00E, 0xF0F, - 0x000, 0x211, 0x022, 0x433, 0x044, 0x855, 0x066, 0xF77, - 0x088, 0x299, 0x0AA, 0x4BB, 0x0CC, 0x8DD, 0x0EE, 0xFFF, - 0x000, 0x210, 0x020, 0x430, 0x040, 0x850, 0x060, 0xF70, - 0x080, 0x290, 0x0A0, 0x4B0, 0x0C0, 0x8D0, 0x0E0, 0xFF0, - 0x000, 0x200, 0x000, 0x500, 0x000, 0x800, 0x000, 0xF00, }, - - // 06: 4 lines of increasing red and then green - { 0x000, 0x000, 0x001, 0x001, 0x002, 0x002, 0x003, 0x003, - 0x004, 0x004, 0x005, 0x005, 0x006, 0x006, 0x007, 0x007, - 0x008, 0x008, 0x009, 0x009, 0x00A, 0x00A, 0x00B, 0x00B, - 0x00C, 0x00C, 0x00D, 0x00D, 0x00E, 0x00E, 0x00F, 0x00F, - 0x000, 0x000, 0x010, 0x010, 0x020, 0x020, 0x030, 0x030, - 0x040, 0x040, 0x050, 0x050, 0x060, 0x060, 0x070, 0x070, - 0x080, 0x080, 0x090, 0x090, 0x0A0, 0x0A0, 0x0B0, 0x0B0, - 0x0C0, 0x0C0, 0x0D0, 0x0D0, 0x0E0, 0x0E0, 0x0F0, 0x0F0, }, - - // 07: 4 lines of increasing red and then blue - { 0x000, 0x000, 0x001, 0x001, 0x002, 0x002, 0x003, 0x003, - 0x004, 0x004, 0x005, 0x005, 0x006, 0x006, 0x007, 0x007, - 0x008, 0x008, 0x009, 0x009, 0x00A, 0x00A, 0x00B, 0x00B, - 0x00C, 0x00C, 0x00D, 0x00D, 0x00E, 0x00E, 0x00F, 0x00F, - 0x000, 0x000, 0x100, 0x100, 0x200, 0x200, 0x300, 0x300, - 0x400, 0x400, 0x500, 0x500, 0x600, 0x600, 0x700, 0x700, - 0x800, 0x800, 0x900, 0x900, 0xA00, 0xA00, 0xB00, 0xB00, - 0xC00, 0xC00, 0xD00, 0xD00, 0xE00, 0xE00, 0xF00, 0xF00, }, - - // 08: criss cross of green and red with diagonal blue. - { 0xF00, 0x001, 0x003, 0x005, 0x007, 0x00A, 0x00F, 0x000, - 0x020, 0xF21, 0x023, 0x025, 0x027, 0x02A, 0x02F, 0x020, - 0x040, 0x041, 0xF43, 0x045, 0x047, 0x04A, 0x04F, 0x040, - 0x060, 0x061, 0x063, 0xF65, 0x067, 0x06A, 0x06F, 0x060, - 0x080, 0x081, 0x083, 0x085, 0xF87, 0x08A, 0x08F, 0x080, - 0x0A0, 0x0A1, 0x0A3, 0x0A5, 0x0A7, 0xFAA, 0x0AF, 0x0A0, - 0x0F0, 0x0F1, 0x0F3, 0x0F5, 0x0F7, 0x0FA, 0xFFF, 0x0F0, - 0x000, 0x001, 0x003, 0x005, 0x007, 0x00A, 0x00F, 0xF00, }, - - // 09: 2 lines of green, 2 red, 2 orange, 2 green - { 0x0F0, 0x0F0, 0x0FF, 0x0FF, 0x00F, 0x00F, 0x0F0, 0x0F0, - 0x0F0, 0x0F0, 0x0FF, 0x0FF, 0x00F, 0x00F, 0x0F0, 0x0F0, - 0x0F0, 0x0F0, 0x0FF, 0x0FF, 0x00F, 0x00F, 0x0F0, 0x0F0, - 0x0F0, 0x0F0, 0x0FF, 0x0FF, 0x00F, 0x00F, 0x0F0, 0x0F0, - 0x0F0, 0x0F0, 0x0FF, 0x0FF, 0x00F, 0x00F, 0x0F0, 0x0F0, - 0x0F0, 0x0F0, 0x0FF, 0x0FF, 0x00F, 0x00F, 0x0F0, 0x0F0, - 0x0F0, 0x0F0, 0x0FF, 0x0FF, 0x00F, 0x00F, 0x0F0, 0x0F0, - 0x0F0, 0x0F0, 0x0FF, 0x0FF, 0x00F, 0x00F, 0x0F0, 0x0F0, }, - - // 10: multicolor smiley face - { 0x000, 0x000, 0x00F, 0x00F, 0x00F, 0x00F, 0x000, 0x000, - 0x000, 0x00F, 0x000, 0x000, 0x000, 0x000, 0x00F, 0x000, - 0x00F, 0x000, 0xF00, 0x000, 0x000, 0xF00, 0x000, 0x00F, - 0x00F, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x00F, - 0x00F, 0x000, 0x0F0, 0x000, 0x000, 0x0F0, 0x000, 0x00F, - 0x00F, 0x000, 0x000, 0x0F4, 0x0F3, 0x000, 0x000, 0x00F, - 0x000, 0x00F, 0x000, 0x000, 0x000, 0x000, 0x00F, 0x000, - 0x000, 0x000, 0x00F, 0x00F, 0x00F, 0x00F, 0x000, 0x000, }, -}; - - -// Convert a BGR 4/4/4 bitmap to RGB 5/6/5 used by Adafruit_GFX -void fixdrawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap, int16_t w, int16_t h) { - uint16_t RGB_bmp_fixed[w * h]; - for (uint16_t pixel=0; pixel> 8; - g = (color & 0x0F0) >> 4; - r = color & 0x00F; - //Serial.print(" "); - //Serial.print(b); - //Serial.print("/"); - //Serial.print(g); - //Serial.print("/"); - //Serial.print(r); - //Serial.print(" -> "); - // expand from 4/4/4 bits per color to 5/6/5 - b = map(b, 0, 15, 0, 31); - g = map(g, 0, 15, 0, 63); - r = map(r, 0, 15, 0, 31); - //Serial.print(r); - //Serial.print("/"); - //Serial.print(g); - //Serial.print("/"); - //Serial.print(b); - RGB_bmp_fixed[pixel] = (r << 11) + (g << 5) + b; - //Serial.print(" -> "); - //Serial.println(RGB_bmp_fixed[pixel], HEX); - } - matrix.drawRGBBitmap(x, y, RGB_bmp_fixed, w, h); -} - -// Fill the screen with multiple levels of white to gauge the quality -void display_four_white() { - matrix.clear(); - matrix.fillRect(0,0, mw,mh, LED_WHITE_HIGH); - matrix.drawRect(1,1, mw-2,mh-2, LED_WHITE_MEDIUM); - matrix.drawRect(2,2, mw-4,mh-4, LED_WHITE_LOW); - matrix.drawRect(3,3, mw-6,mh-6, LED_WHITE_VERYLOW); - matrix.show(); -} - -void display_bitmap(uint8_t bmp_num, uint16_t color) { - static uint16_t bmx,bmy; - - // Clear the space under the bitmap that will be drawn as - // drawing a single color pixmap does not write over pixels - // that are nul, and leaves the data that was underneath - matrix.fillRect(bmx,bmy, bmx+8,bmy+8, LED_BLACK); - matrix.drawBitmap(bmx, bmy, mono_bmp[bmp_num], 8, 8, color); - bmx += 8; - if (bmx >= mw) bmx = 0; - if (!bmx) bmy += 8; - if (bmy >= mh) bmy = 0; - matrix.show(); -} - -void display_rgbBitmap(uint8_t bmp_num) { - static uint16_t bmx,bmy; - - fixdrawRGBBitmap(bmx, bmy, RGB_bmp[bmp_num], 8, 8); - bmx += 8; - if (bmx >= mw) bmx = 0; - if (!bmx) bmy += 8; - if (bmy >= mh) bmy = 0; - matrix.show(); -} - -void display_lines() { - matrix.clear(); - - // 4 levels of crossing red lines. - matrix.drawLine(0,mh/2-2, mw-1,2, LED_RED_VERYLOW); - matrix.drawLine(0,mh/2-1, mw-1,3, LED_RED_LOW); - matrix.drawLine(0,mh/2, mw-1,mh/2, LED_RED_MEDIUM); - matrix.drawLine(0,mh/2+1, mw-1,mh/2+1, LED_RED_HIGH); - - // 4 levels of crossing green lines. - matrix.drawLine(mw/2-2, 0, mw/2-2, mh-1, LED_GREEN_VERYLOW); - matrix.drawLine(mw/2-1, 0, mw/2-1, mh-1, LED_GREEN_LOW); - matrix.drawLine(mw/2+0, 0, mw/2+0, mh-1, LED_GREEN_MEDIUM); - matrix.drawLine(mw/2+1, 0, mw/2+1, mh-1, LED_GREEN_HIGH); - - // Diagonal blue line. - matrix.drawLine(0,0, mw-1,mh-1, LED_BLUE_HIGH); - matrix.drawLine(0,mh-1, mw-1,0, LED_ORANGE_MEDIUM); - matrix.show(); -} - -void display_boxes() { - matrix.clear(); - matrix.drawRect(0,0, mw,mh, LED_BLUE_HIGH); - matrix.drawRect(1,1, mw-2,mh-2, LED_GREEN_MEDIUM); - matrix.fillRect(2,2, mw-4,mh-4, LED_RED_HIGH); - matrix.fillRect(3,3, mw-6,mh-6, LED_ORANGE_MEDIUM); - matrix.show(); -} - -void display_circles() { - matrix.clear(); - matrix.drawCircle(mw/2,mh/2, 2, LED_RED_MEDIUM); - matrix.drawCircle(mw/2-1-min(mw,mh)/8, mh/2-1-min(mw,mh)/8, min(mw,mh)/4, LED_BLUE_HIGH); - matrix.drawCircle(mw/2+1+min(mw,mh)/8, mh/2+1+min(mw,mh)/8, min(mw,mh)/4, LED_ORANGE_MEDIUM); - matrix.drawCircle(1,mh-2, 1, LED_GREEN_LOW); - matrix.drawCircle(mw-2,1, 1, LED_GREEN_HIGH); - matrix.show(); -} - -void display_resolution() { - // not wide enough; - if (mw<16) return; - matrix.clear(); - // Font is 5x7, if display is too small - // 8 can only display 1 char - // 16 can almost display 3 chars - // 24 can display 4 chars - // 32 can display 5 chars - matrix.setCursor(0, 0); - matrix.setTextColor(matrix.Color(255,0,0)); - if (mw>10) matrix.print(mw/10); - matrix.setTextColor(matrix.Color(255,128,0)); - matrix.print(mw % 10); - matrix.setTextColor(matrix.Color(0,255,0)); - matrix.print('x'); - // not wide enough to print 5 chars, go to next line - if (mw<25) { - if (mh==13) matrix.setCursor(6, 7); - else if (mh>=13) { - matrix.setCursor(mw-11, 8); - } else { - matrix.show(); - delay(2000); - matrix.clear(); - matrix.setCursor(mw-11, 0); - } - } - matrix.setTextColor(matrix.Color(0,255,128)); - matrix.print(mh/10); - matrix.setTextColor(matrix.Color(0,128,255)); - matrix.print(mh % 10); - // enough room for a 2nd line - if (mw>25 && mh >14 || mh>16) { - matrix.setCursor(0, mh-7); - matrix.setTextColor(matrix.Color(0,255,255)); - if (mw>16) matrix.print('*'); - matrix.setTextColor(matrix.Color(255,0,0)); - matrix.print('R'); - matrix.setTextColor(matrix.Color(0,255,0)); - matrix.print('G'); - matrix.setTextColor(matrix.Color(0,0,255)); - matrix.print("B"); - matrix.setTextColor(matrix.Color(255,255,0)); - matrix.print("*"); - } - - matrix.show(); -} - -void display_scrollText() { - matrix.clear(); - matrix.setTextWrap(false); // we don't wrap text so it scrolls nicely - matrix.setTextSize(1); - matrix.setRotation(0); - for (int8_t x=7; x>=-42; x--) { - matrix.clear(); - matrix.setCursor(x,0); - matrix.setTextColor(LED_GREEN_HIGH); - matrix.print("Hello"); - if (mh>11) { - matrix.setCursor(-20-x,mh-7); - matrix.setTextColor(LED_ORANGE_HIGH); - matrix.print("World"); - } - matrix.show(); - delay(50); - } - - // Rotation is broken in this implementation - matrix.setRotation(3); - matrix.setTextColor(LED_BLUE_HIGH); - for (int8_t x=7; x>=-45; x--) { - matrix.clear(); - matrix.setCursor(x,mw/2-4); - matrix.print("Rotate"); - matrix.show(); - delay(50); - } - matrix.setRotation(0); - matrix.setCursor(0,0); - matrix.show(); -} - -// Scroll within big bitmap so that all if it becomes visible or bounce a small one. -// If the bitmap is bigger in one dimension and smaller in the other one, it will -// be both panned and bounced in the appropriate dimensions. -void display_panOrBounceBitmap (uint8_t bitmapSize) { - // keep integer math, deal with values 16 times too big - // start by showing upper left of big bitmap or centering if the display is big - int16_t xf = max(0, (mw-bitmapSize)/2) << 4; - int16_t yf = max(0, (mh-bitmapSize)/2) << 4; - // scroll speed in 1/16th - int16_t xfc = 6; - int16_t yfc = 3; - // scroll down and right by moving upper left corner off screen - // more up and left (which means negative numbers) - int16_t xfdir = -1; - int16_t yfdir = -1; - - for (uint16_t i=1; i<1000; i++) { - bool updDir = false; - - // Get actual x/y by dividing by 16. - int16_t x = xf >> 4; - int16_t y = yf >> 4; - - matrix.clear(); - // bounce 8x8 tri color smiley face around the screen - if (bitmapSize == 8) fixdrawRGBBitmap(x, y, RGB_bmp[10], 8, 8); - // pan 24x24 pixmap - if (bitmapSize == 24) matrix.drawRGBBitmap(x, y, (const uint16_t *)bitmap24, bitmapSize, bitmapSize); - matrix.show(); - - // Only pan if the display size is smaller than the pixmap - if (mw= 0) { xfdir = -1; updDir = true ; }; - // we don't go negative past right corner, go back positive - if (xf <= ((mw-bitmapSize) << 4)) { xfdir = 1; updDir = true ; }; - } - if (mh= 0) { yfdir = -1; updDir = true ; }; - if (yf <= ((mh-bitmapSize) << 4)) { yfdir = 1; updDir = true ; }; - } - // only bounce a pixmap if it's smaller than the display size - if (mw>bitmapSize) { - xf += xfc*xfdir; - // Deal with bouncing off the 'walls' - if (xf >= (mw-bitmapSize) << 4) { xfdir = -1; updDir = true ; }; - if (xf <= 0) { xfdir = 1; updDir = true ; }; - } - if (mh>bitmapSize) { - yf += yfc*yfdir; - if (yf >= (mh-bitmapSize) << 4) { yfdir = -1; updDir = true ; }; - if (yf <= 0) { yfdir = 1; updDir = true ; }; - } - - if (updDir) { - // Add -1, 0 or 1 but bind result to 1 to 1. - // Let's take 3 is a minimum speed, otherwise it's too slow. - xfc = constrain(xfc + random(-1, 2), 3, 16); - yfc = constrain(xfc + random(-1, 2), 3, 16); - } - delay(10); - } -} - - -void loop() { - display_four_white(); - delay(3000); - - // clear the screen after X bitmaps have been displayed and we - // loop back to the top left corner - // 8x8 => 1, 16x8 => 2, 17x9 => 6 - static uint8_t pixmap_count = ((mw+7)/8) * ((mh+7)/8); - - Serial.print("Screen pixmap capacity: "); - Serial.println(pixmap_count); - - // multicolor bitmap sent as many times as we can display an 8x8 pixmap - for (uint8_t i=0; i<=pixmap_count; i++) - { - display_rgbBitmap(0); - } - delay(1000); - - display_resolution(); - delay(3000); - - // Cycle through red, green, blue, display 2 checkered patterns - // useful to debug some screen types and alignment. - uint16_t bmpcolor[] = { LED_GREEN_HIGH, LED_BLUE_HIGH, LED_RED_HIGH }; - for (uint8_t i=0; i<3; i++) - { - display_bitmap(0, bmpcolor[i]); - delay(500); - display_bitmap(1, bmpcolor[i]); - delay(500); - } - - // Display 3 smiley faces. - for (uint8_t i=2; i<=4; i++) - { - display_bitmap(i, bmpcolor[i-2]); - // If more than one pixmap displayed per screen, display more quickly. - delay(mw>8?500:1500); - } - // If we have multiple pixmaps displayed at once, wait a bit longer on the last. - delay(mw>8?1000:500); - - display_lines(); - delay(3000); - - display_boxes(); - delay(3000); - - display_circles(); - delay(3000); - - for (uint8_t i=0; i<=(sizeof(RGB_bmp)/sizeof(RGB_bmp[0])-1); i++) - { - display_rgbBitmap(i); - delay(mw>8?500:1500); - } - // If we have multiple pixmaps displayed at once, wait a bit longer on the last. - delay(mw>8?1000:500); - - display_scrollText(); - - // pan a big pixmap - display_panOrBounceBitmap(24); - // bounce around a small one - display_panOrBounceBitmap(8); -} - -void setup() { - Serial.begin(115200); - matrix.begin(); - matrix.setTextWrap(false); - matrix.setBrightness(BRIGHTNESS); - // Test full bright of all LEDs. If brightness is too high - // for your current limit (i.e. USB), decrease it. - matrix.fillScreen(LED_WHITE_HIGH); - matrix.show(); - delay(1000); - matrix.clear(); -} - -// vim:sts=4:sw=4 diff --git a/examples/PanelGFXDemo/smileytongue24.h b/examples/PanelGFXDemo/smileytongue24.h deleted file mode 100644 index 8a8814c..0000000 --- a/examples/PanelGFXDemo/smileytongue24.h +++ /dev/null @@ -1,52 +0,0 @@ -// Generated by : UTFTConverter v0.1 -// Generated from : smiley_tongue_24.jpg -// Time generated : 2017-04-24 16:31:50.352856 UTC -// Image Size : 24x24 pixels -// Memory usage : 1152 bytes - -#if defined(__AVR__) - #include -#elif defined(__PIC32MX__) - #define PROGMEM -#elif defined(__arm__) - #define PROGMEM -#endif - -const unsigned short bitmap24[576] PROGMEM={ -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0010 (16) pixels -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0020 (32) pixels -0x0000, 0x0000, 0x4207, 0xFFDD, 0xCE57, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0030 (48) pixels -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFBB, 0xFF56, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE564, 0xFF99, // 0x0040 (64) pixels -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xAD33, 0xF6D1, 0xE501, // 0x0050 (80) pixels -0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xFF9A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0060 (96) pixels -0x0000, 0x0000, 0x0000, 0x0000, 0xFFBB, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, // 0x0070 (112) pixels -0xE501, 0xE501, 0xFF57, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFDC, 0xE501, 0xE501, 0xDD01, 0xE501, // 0x0080 (128) pixels -0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xDD01, 0xE501, 0xE501, 0xFF78, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0090 (144) pixels -0x0000, 0x0000, 0x0000, 0xE501, 0xDD01, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE502, 0xE501, 0xE501, 0xDD01, 0xDD01, 0xE501, // 0x00A0 (160) pixels -0xE501, 0xDD01, 0xE501, 0xE501, 0xE501, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFF99, 0xE501, 0xE502, 0xE501, 0x4A69, 0x4A6A, // 0x00B0 (176) pixels -0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE502, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xDD01, 0x0000, 0x0000, 0x0000, // 0x00C0 (192) pixels -0x0000, 0x0000, 0xE501, 0xE501, 0xE501, 0x0000, 0x0000, 0x0000, 0x0000, 0x94B2, 0xE501, 0xE502, 0xE501, 0xE501, 0xE501, 0xE501, // 0x00D0 (208) pixels -0xDD01, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0x0000, 0x0000, 0x0000, 0xFFDC, 0xE501, 0xE501, 0xE501, 0x0000, 0x4A69, 0xE502, // 0x00E0 (224) pixels -0x4A69, 0x0000, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0x4A69, 0x0000, 0x0000, 0xE501, 0xE501, 0xE501, 0xFF58, 0x0000, 0x0000, // 0x00F0 (240) pixels -0x0000, 0xFF9A, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0x94B3, 0xE501, 0xE501, 0xE501, 0xE502, 0x0000, 0x0000, // 0x0100 (256) pixels -0x4A69, 0x0000, 0x0000, 0xE501, 0xE501, 0xE5A7, 0x0000, 0x0000, 0x0000, 0xFF79, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xDD01, // 0x0110 (272) pixels -0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE502, 0x94B2, 0xE501, 0xE501, 0xE501, 0x0000, 0xDD01, 0xDD01, 0xE501, 0x0000, 0x0000, // 0x0120 (288) pixels -0x0000, 0xFF79, 0xE501, 0xE501, 0xFE31, 0xFD91, 0xF5B0, 0xF5F1, 0xF5EC, 0xE501, 0xDD01, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, // 0x0130 (304) pixels -0xE501, 0xE501, 0xE501, 0xE502, 0xE501, 0xE501, 0x0000, 0x0000, 0x0000, 0xFF9A, 0xE501, 0xE501, 0xFE31, 0xF4D0, 0xF800, 0xF800, // 0x0140 (320) pixels -0xF800, 0xDC4D, 0xE4AE, 0xE50F, 0xED90, 0xFE52, 0xE501, 0xE501, 0xE502, 0xE501, 0xE501, 0xE501, 0xE501, 0xEDA7, 0x0000, 0x0000, // 0x0150 (336) pixels -0x0000, 0xFFDC, 0xE501, 0xE501, 0xED66, 0xE48E, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xDBAC, 0xE40D, 0xF4F0, 0xF4F0, 0xF530, // 0x0160 (352) pixels -0xFD91, 0xE501, 0xE501, 0xE501, 0xE501, 0xFF57, 0x0000, 0x0000, 0x0000, 0x0000, 0xE501, 0xE501, 0xE501, 0xF800, 0xF800, 0xF800, // 0x0170 (368) pixels -0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF4F0, 0xFDB1, 0xDD01, 0xE501, 0xE501, 0xE501, 0xE501, 0x0000, 0x0000, // 0x0180 (384) pixels -0x0000, 0x0000, 0xFF78, 0xE501, 0xED70, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF550, // 0x0190 (400) pixels -0xE501, 0xE501, 0xDD01, 0xE501, 0xE501, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE501, 0xE50E, 0xF800, 0xF800, 0xF800, // 0x01A0 (416) pixels -0xF800, 0xF800, 0xF800, 0xF800, 0xF800, 0xF4F0, 0xF550, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0x0000, 0x0000, 0x0000, // 0x01B0 (432) pixels -0x0000, 0x0000, 0x0000, 0xFFBC, 0xED90, 0xDC0D, 0xE30A, 0xF800, 0xF800, 0xDC0C, 0xE46E, 0xF510, 0xF570, 0xFE11, 0xE501, 0xE502, // 0x01C0 (448) pixels -0xDD01, 0xE501, 0xE501, 0xFF77, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFF7A, 0xE4AE, 0xE3CB, 0xE36A, // 0x01D0 (464) pixels -0xDBCC, 0xDC8E, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xE501, 0xFF57, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x01E0 (480) pixels -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFF9C, 0xEDD2, 0xED2F, 0xEDB0, 0xDD01, 0xE501, 0xE501, 0xDD01, 0xE501, 0xE521, 0xE501, // 0x01F0 (496) pixels -0xE501, 0xFF99, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFFBB, // 0x0200 (512) pixels -0xFF55, 0xE501, 0xE501, 0xE501, 0xE501, 0xE502, 0xE501, 0xFF79, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0210 (528) pixels -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xEF5B, 0xE501, 0xE501, 0x2103, 0x0000, 0x0000, // 0x0220 (544) pixels -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0230 (560) pixels -0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0240 (576) pixels -}; diff --git a/library.json b/library.json index ae62bea..1bdd4d8 100644 --- a/library.json +++ b/library.json @@ -26,9 +26,7 @@ "examples/Buffer_Swap_Test/*.ino", "examples/Buffer_Swap_Test/*.cpp", "examples/Buffer_Swap_Test/*.h", - "examples/PanelGFXDemo/*.ino", - "examples/PanelGFXDemo/*.cpp", - "examples/PanelGFXDemo/*.h", + "examples/ChainedPanels/*.ino", "examples/PatternPlasma/*.ino", "examples/PatternPlasma/*.cpp", "examples/PatternPlasma/*.h",