Page 1 of 1

ClearScreen yes/no Alternatives?

Posted: Thu Jan 16, 2014 6:56 pm
by LordN1kon
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?

Re: ClearScreen yes/no Alternatives?

Posted: Thu Jan 16, 2014 9:18 pm
by andrew
To be honest I pad stuff out with spaces. If anyone has any other suggestions, please reply.

Re: ClearScreen yes/no Alternatives?

Posted: Fri Jan 17, 2014 5:59 am
by Brissieboy
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
}

Re: ClearScreen yes/no Alternatives?

Posted: Fri Jan 17, 2014 6:10 am
by stryker
Thanks Brissieboy,

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

Cheers ! Geoff

Re: ClearScreen yes/no Alternatives?

Posted: Fri Jan 17, 2014 7:30 am
by LordN1kon
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 :)