Multifunction LED Matrix Display

I have been playing around with your code and evererytime my banner gets bigger than 11 characters (including the null) the screen freaks out on me?

#include "MatrixDisplay.h"
#include "DisplayToolbox.h"
#include "font.h"

#define DEMOTIME 30000  // 30 seconds max on each demo is enough.
#define DISPDELAY 100    // Each "display" lasts this long
#define LONGDELAY 1000  // This delay BETWEEN demos

#define SCROLLSPEED 50 /// time in Miliseconds to wait between shifts
#define MAXSTRING 50

// Macro to make it the initDisplay function a little easier to understand
#define setMaster(dispNum, CSPin) initDisplay(dispNum,CSPin,true)
#define setSlave(dispNum, CSPin) initDisplay(dispNum,CSPin,false)

const byte nDisp = 2;//  Number of displays
const byte pinData = 10;// Data = 10/
const byte pinWR = 11;// WR == 11
const byte pinCS1 = 9; //
const byte pinCS2 = 8;

// Init Matrix
MatrixDisplay disp(nDisp,pinWR,pinData, true);
// Pass a copy of the display into the toolbox
DisplayToolbox toolbox(&disp);

// Prepare boundaries
uint8_t X_MAX = 0;
uint8_t Y_MAX = 0;

//setup banner
char banner[MAXSTRING];

void setup() {
  // Fetch bounds (dynamically work out how large this display is)
  X_MAX = disp.getDisplayCount() * (disp.getDisplayWidth()-1)+1;
  Y_MAX = disp.getDisplayHeight();

  // Prepare displays
  disp.setMaster(0,pinCS1);
  disp.setSlave(1,pinCS2);
 // disp.setSlave(2,6);
 // disp.setSlave(3,7);
 
}



void loop() {
    
    strcpy(banner,"01234567890");

    scrollText(); 
    delay(100);
  
}


/*
 * Copy a character glyph from the myfont data structure to
 * display memory, with its upper left at the given coordinate
 * This is unoptimized and simply uses setPixel() to draw each dot.
 */
void drawChar(uint8_t x, uint8_t y, char c)
{
  uint8_t dots;
  if (c >= 'A' && c <= 'Z' ||
    (c >= 'a' && c <= 'z') ) {
    c &= 0x1F;   // A-Z maps to 1-26
  } 
  else if (c >= '0' && c <= '9') {
    c = (c - '0') + 27;
  } 
  else if (c == ' ') {
    c = 0; // space
  }
  for (char col=0; col< 5; col++) {
    dots = pgm_read_byte_near(&myfont[c][col]);
    for (char row=0; row < 7; row++) {
      if (dots & (64>>row))              // only 7 rows.
        toolbox.setPixel(x+col, y+row, 1);
      else 
        toolbox.setPixel(x+col, y+row, 0);
    }
  }
}


// Write out an entire string (Null terminated)
void drawString(uint8_t x, uint8_t y, char* c)
{
      for(char i=0; i< strlen(c); i++)
      {
            drawChar(x, y, c[i]);
            x+=6; // Width of each glyph
      }
}

void scrollText(){
  int x = X_MAX;
  int charsFinished = 0;
  char visible[11];             //create visible array to hold string
  int i = 0;
  unsigned long lastUpdate = 0;   //variable used for scrolling function
  
  
  for (int n = 0; n < 11; n++){      //fill visible array with first char of string
    visible[n] = banner[n];
  }
  
  while(charsFinished < strlen(banner)){              //while string still has characters
    if(millis() - lastUpdate > SCROLLSPEED){        
      lastUpdate = millis();                      
      drawString(x, 0, visible);                 //draw visible array
      disp.syncDisplays();                       
        
      x--;
        
      if (x <= -6){                        //after each character is finished  
        charsFinished++;                   //advance one character
        x = 0;
        
        i = 0;
        while(i < 11 && banner[i + charsFinished] != '\0'){  
            visible[i] = banner[i + charsFinished];       
            i++;
        }
        visible[i] = banner[i + charsFinished];         
      }
      
      disp.clear();
    }
  }
}

any suggestions?

update: figured out the problem.

this loop

  for (int n = 0; n < 11; n++){      //fill visible array with first char of string
    visible[n] = c[n];
  }

would fill the visible array without a null termination if there were more than 11 char causing an error in the drawString function.

I fixed it by adding a

visible[11]=’\0’;

before the drawString call to always have a null terminated string.

the only problem is the scrolling for characters > 11 is weird. The characters will not pop up till the exiting char is 4 pixels off the screen.

I will post code once solved.

Can we get a link to the betterfont.h file?

Looks great, loving the little icon.

FYI the library already has a scrolling method iirc. If not I could easily add one.

how many 0832 can be hooked up to the arduino Duemilanove?

how many pins does the 0832 needs to work? details plz if i hook up 2x 0832 i have to double those pins? thnx in advanse

Hi there,

You inspired me to buy some of these displays. Now i am looking to download the library you mentioned but the link does not work. Any chance of you posting it up somewhere so I can download it and have a crack at it?

Kind Regards, Dansxmods

check here for the sure 0832 library

http://alastair.d-silva.org/sure-electronics-0832-led-matrix-displays-de-dp105-arduino

Can I have the source, Please!!!!!