collapse

Author Topic: ESP32 "Life is Life" 64x32 flexible P4 RGB LED  (Read 724 times)

Gareth

  • Global Moderator
  • Member
  • *
  • Posts: 60
ESP32 "Life is Life" 64x32 flexible P4 RGB LED
« on: May 18, 2019, 08:23:58 AM »
Here is a test of a flexible P4 RGB LED 64x32 matrix screen.

My trusty "Conway's Life" program was used as the test culprit along with a variant of the

adafruits P3 matrix driver Library     (arduino/mega/etcetc)

ESP32 P3/P4 matrix driver Library [url=https://github.com/NeoCat/ESP32-P3RGB64x32MatrixPanel/]https://github.com/NeoCat/ESP32-P3RGB64x32MatrixPanel/


Its blisteringly fast on the ESP32 , the gif below has been slowed down BTW.


Its one of the recuring loops that can happen , " Repetition is the Mother of Skill"

ESP32  "Life is Life" Conways Life
Code: [Select]
/*
 * Conway's "Life", adapted for ESP32
 */

#include <Adafruit_GFX.h>   // Core graphics library
#include <P3RGB64x32MatrixPanel.h>

// constructor with default pin wiring
P3RGB64x32MatrixPanel matrix;
 
byte world[64][64][2];
long density = 20;
int polltime;

void setup() {
 matrix.begin();
 randomSeed(analogRead(0));
 randomscreen();
 }

void loop() {
 if (millis()-polltime >=50)  { displayoutput(); polltime=millis();}; 
}

int neighbours(int x, int y) {
 return
         world[(x + 1)        % 64][  y                   ]        [0] +
         world[ x                          ][ (y + 1)        % 32] [0] +
         world[(x + 64 - 1) % 64][  y                   ]       [0] +
         world[ x                          ][ (y + 32 - 1) % 32] [0] +
         world[(x + 1)        % 64][ (y + 1)        % 32] [0] +
         world[(x + 64 - 1) % 64][ (y + 1)        % 32] [0] +
         world[(x + 64 - 1) % 64][ (y + 32 - 1) % 32] [0] +
         world[(x + 1) % 64       ][ (y + 32 - 1) % 32] [0];
}

void randomscreen() {
    for (int y = 0; y < 32; y++) {
    for (int x = 0; x < 64; x++) {
      if (random(100) < density) {world[x][y][0] = 1; }
      else                       {world[x][y][0] = 0;}
      world[x][x][1] = 0;
    }
  }
 }

void displayoutput(){
  for (int y = 0; y < 32; y++) {
    for (int x = 0; x < 64; x++) {
      // Default is for cell to stay the same
      world[x][y][1] = world[x][y][0];
      int count = neighbours(x, y);
      if (count == 3 && world[x][y][0] == 0)               { world[x][y][1] = 1;matrix.drawPixel(x, y, matrix.color444(0,255,0)); } //new cell
      if ((count < 2 || count > 3) && world[x][y][0] == 1) { world[x][y][1] = 0;matrix.drawPixel(x, y, matrix.color444(0,0,0)); } //cell dies
    }
  }
  // swap next generation into place
  for (int y = 0; y < 32; y++) {
    for (int x = 0; x < 64; x++) {
      world[x][y][0] = world[x][y][1];
    }
   }
  }


...and those interested in the colours.... its wrapped around my metal bin (it comes with magnetic feet stand-offs)

« Last Edit: May 18, 2019, 08:36:45 AM by Gareth »

jinx

  • calling from free Europe
  • Sr. Member
  • *****
  • Posts: 469
Re: ESP32 "Life is Life" 64x32 flexible P4 RGB LED
« Reply #1 on: May 18, 2019, 11:19:44 AM »
MULTI COLOUR! nice
I build bots

 

* Search


* Recent Topics

"1984 Nixie Time" by Gareth
[August 22, 2019, 05:59:29 AM]


Just wanted to say Hi. by ErwinCanto
[August 18, 2019, 10:11:28 PM]


SDR (Software Defined Radio) by Gareth
[August 14, 2019, 01:12:21 PM]


It may be dangerous to work in the virtual realm by fritsl
[August 09, 2019, 09:52:05 AM]


PLX-DAQ by AmandaG
[August 06, 2019, 01:58:42 PM]


DIY Yellow Servo by AmandaG
[August 06, 2019, 01:08:09 PM]


Comp? :o by Impala
[August 02, 2019, 07:32:20 PM]


Website to do list by Killer Angel
[August 02, 2019, 05:38:30 AM]


I Like the new front page! by James
[July 31, 2019, 12:29:53 AM]


Pictures on the front page! by tinhead
[July 30, 2019, 05:17:20 AM]


4x5 Macro Keypad by James
[July 28, 2019, 08:30:41 PM]


My name is Frits and I am Making a Game called TIXITAXI by Killer Angel
[July 08, 2019, 04:01:58 AM]


Coding a Nano i2c Slave by AmandaG
[June 11, 2019, 02:48:03 PM]


repetierHost 2.1.6 not working? by MEgg
[June 09, 2019, 03:11:34 PM]


Servo Calibrator by Bajdi
[May 24, 2019, 04:01:10 AM]

* Recent Posts

Re: "1984 Nixie Time" - Update 20190822 by Gareth
[August 22, 2019, 05:59:29 AM]


Re: "1984 Nixie Time" - Update by Gareth
[August 20, 2019, 11:15:36 AM]


Re: "1984 Nixie Time" by Bajdi
[August 20, 2019, 09:35:39 AM]


Just wanted to say Hi. by ErwinCanto
[August 18, 2019, 10:11:28 PM]


Re: "1984 Nixie Time" by viswesh
[August 18, 2019, 01:48:07 AM]


Re: "1984 Nixie Time" by James
[August 16, 2019, 06:37:11 AM]


"1984 Nixie Time" by Gareth
[August 15, 2019, 06:16:37 AM]


Re: SDR (Software Defined Radio) by Gareth
[August 14, 2019, 01:12:21 PM]


Re: SDR (Software Defined Radio) by fritsl
[August 09, 2019, 09:54:11 AM]


It may be dangerous to work in the virtual realm by fritsl
[August 09, 2019, 09:52:05 AM]


Re: PLX-DAQ by AmandaG
[August 06, 2019, 01:58:42 PM]


Re: DIY Yellow Servo by AmandaG
[August 06, 2019, 01:08:09 PM]


SDR (Software Defined Radio) by Gareth
[August 06, 2019, 11:12:09 AM]


Comp? :o by Impala
[August 02, 2019, 07:32:20 PM]


Re: Website to do list by Killer Angel
[August 02, 2019, 05:38:30 AM]