This is code for Freetronic‘s Dot Matrix Display devices and their libraries.

In the dmd_demo there is a sample of code that says

long start=millis();
long timer=start;
boolean ret=false;
while(!ret){
if ((timer+30) < millis()) {
ret=dmd.stepMarquee(-1,0);
timer=millis();
}
}

However having to put that everywhere you want to advance a marquee probably isn’t fun.

So I came up with a function, advanceMarquee, that does it for you! Put this somewhere:

void advanceMarquee(unsigned int gap, int x, int y)
{
long start,timer=millis();
boolean ret=false;
while(!ret){
if ((timer+gap) < millis()) {
ret=dmd.stepMarquee(x,y);
timer=millis();
}
}
}

Replace the dmd in dmd.stepMarquee bit (line 7) with whatever you’re using for your class (I’m getting my head around how to make dmd.advanceMarquee a valid call).

Call after drawMarquee. First parameter is milliseconds between advances, second param is pixels to move in x direction and third is pixels to move in y direction (x and y increase as you go left and down).

It certainly makes life more compact (and easier)!