32x16 or 32x32 RGB LED Matrix - Where to start?

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby tdg8934 » Sat Mar 31, 2012 9:24 am

Ive been hearing for a while that the tutorial for the 32x16 or 32x32 RGB LED Matrix http://ladyada.net/products/rgbledmatrix/ will be updated for the Atmega 2560 http://www.adafruit.com/products/191 . Is this listed elsewhere?

I would like to buy an Atmega and more displays but don't want to have to guess at it too long.

Please let me know.
tdg8934
 
Posts: 25
Joined: Sat Feb 04, 2012 2:47 pm

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby tdg8934 » Sat May 19, 2012 5:29 pm

Still no one has connected this to a mega Arduino?

Any schematics, code out there?
tdg8934
 
Posts: 25
Joined: Sat Feb 04, 2012 2:47 pm

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby dreggory » Mon Jun 11, 2012 2:11 pm

I was wondering if anyone could help me adapt this code to the 32 x 32 matrix size. this might be a futile attempt but I was hoping to use this http://www.solderlab.de/index.php/software/glediator program to stream a screen capture to the matrix.
so far I have got the program to link with it and send colors to the display but it's garbled and it looks like it repeats four times. I'm not sure if the problem is with this code or with "Glediator" anyone know what to do?

Code: Select all
#include "RGBmatrixPanel.h"

#define A   A0
#define B   A1
#define C   A2
#define CLK 8
#define LAT A3
#define OE  9
#define WIDTH 32

int count = 0;
byte currentByte = 0;
byte lastByte = 0;
uint16_t color;
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, true);

void setup()
{
  Serial.begin(115200);
  matrix.begin();
}

void loop() {
  int index;
  while (Serial.available()) {

    lastByte = currentByte;
    currentByte = Serial.read();

    // Look for the frame marker 0xF000
    if ((lastByte == 0xF0) && (currentByte == 0x00)) {
      count = 0;
      matrix.swapBuffers(false);
    } else {
      if ((count % 2) == 1) {
        color = (lastByte << 8) | currentByte;
        index = (count-1)/2;
        matrix.drawPixel(index % WIDTH, index / WIDTH, color);
      }
      count++;
    }
  }
}
dreggory
 
Posts: 6
Joined: Mon Jun 11, 2012 10:32 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby pburgess » Mon Jun 11, 2012 3:23 pm

The 32x32 matrix has four row address lines and requires an extra parameter to the constructor, i.e. instead of:

Code: Select all
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, true);


Define your "D" pin and then use this:

Code: Select all
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, true);
User avatar
pburgess
 
Posts: 1343
Joined: Sun Oct 26, 2008 1:29 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby dreggory » Mon Jun 11, 2012 10:57 pm

thank you and sorry I should have told you that I tried that already, I was at work and all I had on that computer was the code I found earlier on the internet, this is what I actually have now
Code: Select all
#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#include <avr/pgmspace.h>

#define A   A3
#define B   A2
#define C   A1
#define D   A0
#define CLK 8  // MUST be on PORTB!
#define LAT 9
#define OE  10

#define WIDTH 32
#define HEIGHT 32

int count = 0;
byte currentByte = 0;
byte lastByte = 0;
uint16_t color;
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);

void setup()
{
  Serial.begin(115200);
  matrix.begin();
}

void loop() {
  int index;
  while (Serial.available()) {

    lastByte = currentByte;
    currentByte = Serial.read();
   
    // Look for the frame marker 0xF0
    if ((lastByte == 0xF0) && (currentByte == 0x00))
      {
        count = 0;
        matrix.swapBuffers(false);
      }
    else
      {
        if ((count % 2) == 1)
          {
       color = (lastByte << 8) | currentByte;
       index = (count-1)/2;
       matrix.drawPixel(index % WIDTH, index / HEIGHT, color);
          }
        count++;
      }
  }
}


I suspect that it has to do with
// Look for the frame marker 0xF0
if ((lastByte == 0xF0) && (currentByte == 0x00))

but I am not sure how to alter this properly, I tried 0xfff0 and 0x0000 instead of 0xF0 and 0x00, but it is still wrong what should I do?
dreggory
 
Posts: 6
Joined: Mon Jun 11, 2012 10:32 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby pburgess » Tue Jun 12, 2012 1:40 am

I could be wrong, but it looks like the frame marker should be a single byte, value of 1.
User avatar
pburgess
 
Posts: 1343
Joined: Sun Oct 26, 2008 1:29 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby dreggory » Tue Jun 12, 2012 8:57 am

I could be wrong, but it looks like the frame marker should be a single byte, value of 1.


ok so should it be this?

// Look for the frame marker 0x1
if ((lastByte == 0x1) && (currentByte == 0x0))


I'll try it tonight, isn't there a way to "swap buffers" when it indexes the X and Y as (0,0)?
dreggory
 
Posts: 6
Joined: Mon Jun 11, 2012 10:32 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby pburgess » Tue Jun 12, 2012 10:56 am

I don't know the ins & outs of Glediator...there's a lot of code there to slog through and this was just a cursory glance through the Arduino part of the code. But it looked like there was a hardcoded number of bytes that it counts up to for each frame, and then it looks for a single byte (not two) with a value of 1 before starting the next frame.

It was late, and my brain might have been somewhere else. A more authoritative answer might come from the programs' author(s). Have you tried contacting them?
User avatar
pburgess
 
Posts: 1343
Joined: Sun Oct 26, 2008 1:29 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby dreggory » Tue Jun 12, 2012 11:25 am

I am ashamed to say I have not asked them yet. sorry.
hey normally I don't post questions without doing a ton of research on my own first. for some reason I just felt like this was my only option but now that you mention it, that would be a very good idea... ask the authors.
dreggory
 
Posts: 6
Joined: Mon Jun 11, 2012 10:32 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby pburgess » Tue Jun 12, 2012 3:40 pm

Oh, also: what Arduino board are you using? There isn't enough RAM on an Uno to handle double-buffered animation on the 32x32 display. (Can do 32x32 single-buffered or 16x32 double-buffered.) The Arduino Mega has enough RAM but the library hasn't been really fully developed or tested in that configuration.
User avatar
pburgess
 
Posts: 1343
Joined: Sun Oct 26, 2008 1:29 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby dreggory » Tue Jun 12, 2012 7:02 pm

good to know. I guess I better see if is single or double, I have an Uno. I have an uno32 as well but I'm still learning how to port libraries. yeah this is starting to look like it's way over my head. do you know of any way I can stream screen capture to the 32 x 32 matrix? with an uno?
dreggory
 
Posts: 6
Joined: Mon Jun 11, 2012 10:32 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby tdg8934 » Wed Jun 13, 2012 6:21 am

The Arduino doesn't have enough RAM memory to stream and probably to show BMP pics either. This is one reason why, I went to the Parallax Propeller. See link:

http://forums.parallax.com/showthread.php?134241-Propellering-the-Adafruit-16x32xRGB-LED-array&highlight=32x16

Rayman has already written Propeller drivers for the 32x16 and if you ask him nicely, he may be able to answer your questions if you wanted to switch over the Propeller using SPIN. I was reluctant being a novice with the Arduino and going to the Propeller with this SPIN language but they have good manuals and an excellent beginner weekly audio tutorial to teach you everything. You can even buy the Propeller boards at Radio Shack now too!

http://www.firstspin.tv/2011/11/

Rayman's website is here: http://www.rayslogic.com/propeller/Programming/AdafruitRGB/AdafruitRGB.htm

What I like about his code is being able to display small BMP pictures fast on my 32x16 display.

Tim
tdg8934
 
Posts: 25
Joined: Sat Feb 04, 2012 2:47 pm

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby pburgess » Wed Jun 13, 2012 11:31 am

The Arduino doesn't have enough RAM memory to stream and probably to show BMP pics either.


It can be done, by doing the data reordering on the PC side and then streaming into the display's 'back buffer' on the Arduino side. Demos forthcoming!

The big win with the Propeller is that it can handle multiple matrices with 24-bit color, whereas even a single 12-bit display is pretty much using up all the Arduino's sauce.
User avatar
pburgess
 
Posts: 1343
Joined: Sun Oct 26, 2008 1:29 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby dreggory » Fri Jun 15, 2012 1:38 pm

I was wondering, is there a reason that the RGBMatrixPanel library wont let me define the UDR0 so that I can use USB?

I'm a little embarrassed to show you my code to try and get this panel to work with the Glediator program. because I really don't know what I'm doing but it compiles if I comment out either the RGBmatrixPanel.h or these lines:

ISR(USART_RX_vect)
{
volatile unsigned char RecievedChar;

RecievedChar=UDR0;

if (RecievedChar == CMD_NEW_DATA) {UDR0=RecievedChar; pos=0; ptr=display_buffer; return;}
if (pos == 3072) {UDR0=RecievedChar; return;} else {*ptr=RecievedChar; ptr++; pos++;}
}


so here is what I have tried to do so far:

Code: Select all
#include <gamma.h>
#include <RGBmatrixPanel.h>

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

#include <avr/pgmspace.h>


PROGMEM prog_uint16_t exp_table[] =
{
0,15,15,16,16,16,17,17,17,18,18,19,19,20,20,20,21,21,22,22,23,23,24,24,25,25,26,27,27,28,28,29,30,30,31,32,32,33,34,35,35,36,37,38,39,39,40,41,42,43,44,45,46,
47,48,49,50,51,53,54,55,56,57,59,60,61,63,64,65,67,68,70,72,73,75,76,78,80,82,83,85,87,89,91,93,95,97,99,102,104,106,109,111,114,116,119,121,124,127,130,132,
135,138,141,145,148,151,154,158,161,165,169,172,176,180,184,188,192,197,201,206,210,215,220,225,230,235,240,245,251,256,262,268,274,280,286,292,299,305,312,319,
326,334,341,349,356,364,372,381,389,398,407,416,425,434,444,454,464,474,485,496,507,518,529,541,553,566,578,591,604,618,631,645,660,674,689,705,720,736,753,770,
787,804,822,840,859,878,898,918,938,959,980,1002,1024,1047,1070,1094,1119,1143,1169,1195,1221,1249,1276,1305,1334,1364,1394,1425,1457,1489,1522,1556,1591,1626,
1662,1699,1737,1775,1815,1855,1897,1939,1982,2026,2071,2117,2164,2212,2262,2312,2363,2416,2470,2524,2581,2638,2697,2757,2818,2881,2945,3010,3077,3146,3216,3287,
3360,3435,3511,3590,3669,3751,3834,3920,4007,4095
};


#define A   A3
#define B   A2
#define C   A1
#define D   A0
#define CLK 8  // MUST be on PORTB!
#define LAT 9
#define OE  10
#define WIDTH 32
#define HEIGHT 32


#define Gray_Scale_Depth 4095
#define CMD_NEW_DATA 1
unsigned char display_buffer[3072];
volatile byte new_row = 0;
volatile byte need_lat = 0;
static unsigned char *ptr;
static unsigned int pos = 0;
byte row = 0;


int count = 0;
byte currentByte = 0;
byte lastByte = 0;
uint16_t color;
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);

void setup()
{
  Serial.begin(1000000);
  matrix.begin();
 
//  //Timer 1 (16bit)
//  TCCR1A  = (1<<WGM11) | (0<<WGM10);            // Fast PWM with ICR1 as top
//  TCCR1B  = (1<<WGM13) | (1<<WGM12);            // Fast PWM with ICR1 as top
//  TCCR1B |= (1<<CS12)  | (1<<CS11) | (1<<CS10); // external clock (T1) on rising egde
//  TIMSK1 |= (1<<TOIE1);                         // enable overflow interupt
//  ICR1    = Gray_Scale_Depth;                   // Grey scale depth for TLC-PW

//  //Timer 0 (8bit)
//  TCCR0A  = (1<<WGM01) | (0<<WGM00);            // CTC
  TCCR0A |= (0<<COM0A1) | (1<<COM0A0);          // Toggle on Compare Match
//  TCCR0B  = (0<<CS02) | (0<<CS01) | (1<<CS00);  // No Prescaler
//  OCR0A   = 0;                                  // f(OCR) = F_CPU/2/Prescaler
 
  //UART Initialisation
  UCSR0A |= (1<<U2X0);                                 // Double up UART
  UCSR0B |= (1<<RXEN0)  | (1<<TXEN0) | (1<<RXCIE0);    // UART RX, TX und RX Interrupt enable
  UCSR0C |= (1<<UCSZ01) | (1<<UCSZ00)             ;    // Asynchrous 8N1
  UBRR0H = 0;
  UBRR0L = 1; //Baud Rate 1 MBit   --> 0% Error at 16MHz :-)
 
  //Enable global interrupts
  sei();
   
  //Configure SPI 
  SPCR = (1<<SPE)|(1<<MSTR); 
  SPSR = B00000000;   
 
  ptr=display_buffer;
 
}

void loop()
{
 
 
if (new_row)
  {   
    shift_out_data(row);
           
    need_lat = 1;
                                             
    new_row = 0;       
  }
    if (need_lat)
  {
   matrix.updateDisplay();
  }

   row++;
  if (row == 32) {row = 0; matrix.swapBuffers(false);}   
  new_row = 1;

}


ISR(USART_RX_vect)
{
volatile unsigned char RecievedChar;
 
  RecievedChar=UDR0;
 
  if (RecievedChar == CMD_NEW_DATA)  {UDR0=RecievedChar; pos=0; ptr=display_buffer;  return;}   
  if (pos == 3072) {UDR0=RecievedChar; return;} else {*ptr=RecievedChar; ptr++; pos++;} 
}



void spi_transfer(byte data)
{
  SPDR = data;     // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
  {
  };
}



void shift_out_data(byte row)
{
 
    unsigned int index_offset = (row) * 96;
 
    //Shift Out Blue Data
    for(byte i = 0; i<32; i++)
    {
      unsigned int index = index_offset + 6*(i) + 2;
      unsigned int t1 = pgm_read_word_near(exp_table + display_buffer[index + 3]);
      unsigned int t2 = pgm_read_word_near(exp_table + display_buffer[index]);
     
      byte d1 = (highByte(t2) << 4) | (lowByte(t2) >> 4);
      spi_transfer(d1);
     
      byte d2 = (lowByte(t2) << 4) | (highByte(t1));
      spi_transfer(d2);
     
      byte d3 = (lowByte(t1));
      spi_transfer(d3);     
    }
   
    //Shift Out Green Data
    for(byte i = 0; i<32; i++)
    {
      unsigned int index = index_offset + 6*(i) + 1;
      unsigned int t1 = pgm_read_word_near(exp_table + display_buffer[index + 3]);
      unsigned int t2 = pgm_read_word_near(exp_table + display_buffer[index]);
     
      byte d1 = (highByte(t2) << 4) | (lowByte(t2) >> 4);
      spi_transfer(d1);
     
      byte d2 = (lowByte(t2) << 4) | (highByte(t1));
      spi_transfer(d2);
     
      byte d3 = (lowByte(t1));
      spi_transfer(d3);     
    }
           
    //Shift Out Red Data
    for(byte i = 0; i<32; i++)
    {
      unsigned int index = index_offset + 6*(i);
      unsigned int t1 = pgm_read_word_near(exp_table + display_buffer[index + 3]);
      unsigned int t2 = pgm_read_word_near(exp_table + display_buffer[index]);
     
      byte d1 = (highByte(t2) << 4) | (lowByte(t2) >> 4);
      spi_transfer(d1);
     
      byte d2 = (lowByte(t2) << 4) | (highByte(t1));
      spi_transfer(d2);
     
      byte d3 = (lowByte(t1));
      spi_transfer(d3);     
    }
 
}


just tell me straight, am I an idiot?
dreggory
 
Posts: 6
Joined: Mon Jun 11, 2012 10:32 am

Re: 32x16 or 32x32 RGB LED Matrix - Where to start?

Postby pburgess » Fri Jun 15, 2012 3:52 pm

You can't use the Serial library and define your own USART_RX_vect at the same time, has to be one or the other.

Try commenting out the Serial.begin line in your sketch, and the Serial-related calls in the dumpMatrix() method in RGBmatrixPanel.cpp. Should compile after that, though I'm not sure if all the UART code in the sketch is valid.

Alternative is to remove the UART init and ISR in the sketch, and just use standard Serial init/available/read calls.
User avatar
pburgess
 
Posts: 1343
Joined: Sun Oct 26, 2008 1:29 am

PreviousNext

Return to Glowy things (LCD, LED, TFT, EL) purchased at Adafruit

Who is online

Users browsing this forum: No registered users and 4 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [103]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[61]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]