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