ClearScreen yes/no Alternatives?

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
LordN1kon
Posts:7
Joined:Sat Dec 07, 2013 1:53 am
ClearScreen yes/no Alternatives?

Post by LordN1kon » Thu Jan 16, 2014 6:56 pm

Hey,

I tried to Display two char Arrays filled up with serial input :

Code: Select all

 dmd.drawString(  2, 1, stringa , 5, WHITE,BLACK );
    dmd.drawString(  2, 9, stringb , 5, WHITE,BLACK );
so the value of the Arrays can be different.
The DMD Show me my Array as it should, but if the next Array is shorter than that befor the old letters on that Position will be displayed to.
I don't know how to explain it better :)

e.g.

1.)Array: asdf -> DMD: asdf
2.)Array: axdf -> DMD: axdf
3.)Array: ac -> DMD: acdf


So the only possible solution i found is to clear the complete Display but this produce a flicker.
Another possible solution is to fill up the arry with blank so it would Display the blank but this isn't a nice solution i think.
Are there any other possible solutions i can try?

andrew
Freetronics Staff
Freetronics Staff
Posts:978
Joined:Sun Jul 14, 2013 7:06 am
Location:Melbourne, Australia
Contact:

Re: ClearScreen yes/no Alternatives?

Post by andrew » Thu Jan 16, 2014 9:18 pm

To be honest I pad stuff out with spaces. If anyone has any other suggestions, please reply.

Brissieboy
Posts:209
Joined:Fri Sep 20, 2013 7:25 am

Re: ClearScreen yes/no Alternatives?

Post by Brissieboy » Fri Jan 17, 2014 5:59 am

How about just clearing the unwanted part of the screen with:

Code: Select all

dmd.drawbox(x1,y1,x2,y2,BLACK);
immediately after you place your new string.
You will first need to know the coordinates which you can work out from the starting position of your string and its length. The length of the string can be calculated with this:

Code: Select all

//******************************************************************************
// Returns the width in pixels of the target string in the current font
//******************************************************************************
byte stringWidth(const char *bChars)
{
  int strWidth = 0;
  for (byte i = 0; i < strlen(bChars); i++) {  // step through the length of the string
    strWidth += dmd.charWidth(bChars[i]) + 1;  // increment by the width of this character in pixels,
                                               // plus the 1 pixel character spacing
  }
  return strWidth - 1;                         // don't allow for a character space at the end
}

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

Re: ClearScreen yes/no Alternatives?

Post by stryker » Fri Jan 17, 2014 6:10 am

Thanks Brissieboy,

I was unaware of the dmd.charWidth() function - til now. That will come in very handy.

Cheers ! Geoff

LordN1kon
Posts:7
Joined:Sat Dec 07, 2013 1:53 am

Re: ClearScreen yes/no Alternatives?

Post by LordN1kon » Fri Jan 17, 2014 7:30 am

I think the idea with spaces is the most comfortable version to clean it and it will take less process of the arduino.
But the drawing Methode is the best way to clean graphics, so i think i will use both :)
It's always nice to see that other people find out the same solutions as i did :)

Post Reply