problem with bluetooth dmd

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
parvguptaece
Posts: 3
Joined: Mon Jun 13, 2016 3:01 am

problem with bluetooth dmd

Post by parvguptaece » Mon Jun 13, 2016 3:10 am

I am having problem when i connect dmd with bluetooth . It displays on 64 characters on the dmd and rest are rejected.
can anyone help me solving the problem.
here is my code:

#include<EEPROM.h>
#include <SPI.h> //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h> //
#include <TimerOne.h> //
#include "SystemFont5x7.h"
#include "Arial_black_16.h" //Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 4
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN); //number max of characters in your message
#define max_char 500
char message[max_char]; // stores you message
int count=0;
char inchar;
int initi=0;
int second=0;
int lostr =0;
int pos=0;

void ScanDMD()
{
dmd.scanDisplayBySPI();
}

void setup(void)
{ //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
Timer1.initialize( 10000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
Timer1.pwm(PIN_DMD_nOE, 100);
//Timer1.attachInterrupt(ScanDMD); //clear/init the DMD pixels held in RAM
dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)
Serial.begin(9600);
}

void loop()
{
if(Serial.available())
{
for(int i=0; i<EEPROM.length(); i++)
{
EEPROM.write(i, '\0');
}
pos=0; //resests the index
initi=0;
lostr=0;
second=0;
}
while(Serial.available()>0)
{
inchar=Serial.read();
message[pos]=inchar;
EEPROM.write(pos, message[pos]);
pos++;
message[pos]='\0';
}

if(initi==0)
{
lostr=max_char;
}
else
{
if(second==0)
{
lostr=initi;
second++;
}
else
{
initi=0;
}
}

for(int j=0; j<=lostr; j++)
{
message[j]= EEPROM.read(j);
initi++;
if(message[j]=='\0')
{
break;
}
}

if(pos=EEPROM.length())
{
pos=0;
}

Serial.println(message);
dmd.clearScreen( true );
dmd.selectFont(Arial_Black_16); //displays the message
dmd.drawMarquee(message, lostr, (32*DISPLAYS_ACROSS)-1, 0);
long start=millis();
long timer=start;
boolean ret=false;
while(!ret)
{
if ((timer+50) < millis())
{
ret=dmd.stepMarquee(-1,0);
timer=millis();
}
}
Serial.println(lostr);
}

User avatar
stryker
Posts: 263
Joined: Sat Jan 14, 2012 2:44 pm

Re: problem with bluetooth dmd

Post by stryker » Mon Jun 13, 2016 6:42 am

Hi

How are you validating the length of text shown? The dmd marquee text is a char array of length 256 which will be shorter than the EEPROM size.

Geoff

parvguptaece
Posts: 3
Joined: Mon Jun 13, 2016 3:01 am

Re: problem with bluetooth dmd

Post by parvguptaece » Mon Jun 13, 2016 6:55 am

No , I am not validating the lenght of charc. shown . I think each char take 1 byte and arduino uno has 1kb eeprom.
I want approx 500 char to be displayed.
what should i change in the code to make it.

User avatar
stryker
Posts: 263
Joined: Sat Jan 14, 2012 2:44 pm

Re: problem with bluetooth dmd

Post by stryker » Mon Jun 13, 2016 8:29 am

Then you will need to either implement your own code for the marquee, or modify your library.

Check the code in the dmd.cpp source file (available from github here or in your local ../Arduino/libraries/ directory) you'll see the implenentation for DMD::drawMarquee(). In that, a character array marqueeText is used to store the text to be displayed. That array is defined in the header dmd.h as

Code: Select all

char marqueeText[256];
...which is only half the size you're wanting.

You could try to increase the array size in the header to 500, and see if that runs still okay. That won't be ideal if you intend sharing your code as anyone using your project code will also need to modify the library the same way. The other way would be to create your own marquee functions (say myDrawMarquee() and myStepMarquee()) in your code. The starting point would be copying the content of the library functions from dmd.cpp, then modifying it to taste.

All the best with your project,
Geoff

parvguptaece
Posts: 3
Joined: Mon Jun 13, 2016 3:01 am

Re: problem with bluetooth dmd

Post by parvguptaece » Mon Jun 13, 2016 11:37 am

you are saying right my brother.
the problem is something different.

In the example given if i write a string of upto 500 words in the place of "message" in draw marquee then it works.
but when i send the string through Bluetooth . then it displays only 64 charc on the dmd. I am not getting why this is happening.
what is problem in my code.

User avatar
stryker
Posts: 263
Joined: Sat Jan 14, 2012 2:44 pm

Re: problem with bluetooth dmd

Post by stryker » Mon Jun 13, 2016 12:06 pm

Perhaps move your bluetooth module to different pins, and use software serial to receive that data and write it to EEPROM, then you'll be able to use your serial monitor to debug if the full string is received, stored, and retrieved from EEPROM.

deathcool
Posts: 1
Joined: Wed Jun 22, 2016 2:06 pm

Re: problem with bluetooth dmd

Post by deathcool » Wed Jun 22, 2016 2:09 pm

remove Timer1.attachInterrupt( ScanDMD );

Post Reply