Countdown in the center of DMD

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
Abder_sama
Posts: 1
Joined: Sat May 07, 2016 6:57 pm

Countdown in the center of DMD

Post by Abder_sama » Sat May 07, 2016 7:33 pm

Hello everybody, hope you all fine!

I'm a new member and also a beginner in programming DMD with Arduino, so i hope learn few thing from you guys :)
I'm actually working on a project : DMD all the LEDs ON showing a countdown in the center with Arduino Uno, so as i said i already learn a lot about Arduino and i test the scrolling text it's working fine, i'm really thankful to you that your codes and explanation helps me to know more about scrolling text, now i faced a problem: what kind of code should i add to have a countdown in the middle of P10 LED (60-->0 or inverse)?

Thanks in advance.
Abder.

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

Re: Countdown in the center of DMD

Post by stryker » Sat May 07, 2016 9:34 pm

Hi Abder

Presuming your biggest challenge here is the centred text, if you're using the DMD2 library, there's a function stringWidth() which will give you the number of pixels wide a character string will need in the font that's currently active (or you can specify a font as the second parameter if you prefer). Here's the definition:

Code: Select all

unsigned int stringWidth(const __FlashStringHelper *flashStr, const uint8_t *font = NULL)
Therefore if you have your countdown value converted to a string you can see how wide it will be on the DMD and use that to work out where to display it. Here's a simple function I use to display strings centred on an array of DMDs that is 2 panels wide (ie max pixel number 31).

Code: Select all

// ---------------------------------------------------------------------------------
// display thisWord, centred on the 2x2 DMD array
//
void displayDMDstring(char * thisWord) {
  int Xstart = 31 - (dmd.stringWidth(thisWord) / 2);                  // work out where to display the first character
  if (0 > Xstart) Xstart = 0;
  dmd.drawString(Xstart, 0, thisWord);
}
Aside from this you'll need to add the counter logic, and have it invert the colours on the display which is straightforward.

All the best with your project - cheers!
Geoff

alvinchrist
Posts: 1
Joined: Tue Dec 18, 2018 10:41 am

Re: Countdown in the center of DMD

Post by alvinchrist » Tue Dec 18, 2018 10:45 am

I have a question.. dmd.stringWidth() is for centering the display horizontally, how to center the display vertically? I'm currently working on 2 P10 Dot matrix display (32x32)

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

Re: Countdown in the center of DMD

Post by Brissieboy » Wed Dec 19, 2018 10:59 am

Not very familiar with the DMD2 library, but doesn't the TextBox allow you set the vertical position? Would that work for you?
You can then read the height of the font and the display then work out where to place the text box.

Post Reply