One more question about Arduino and DMD

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
Posts: 11
Joined: Fri Sep 27, 2013 5:56 pm

One more question about Arduino and DMD

Post by RadioDJ » Mon Oct 14, 2013 2:58 pm

Now I have some problem with showing strings on the DMD.
In the program a get some information from the serialport that I shall show on the display.
I get minutes, seconds and hundreds of second.
I have declared 3 variables to hold this. The variable is set in the "serialEvent".
Even if I set the variable myself if doesn't work.

String timeMinutes = "00";
String timeSeconds = "00";
String timeHundreds = "000";

Then in the loop I shall show this on the display.

void loop(void)
dmd.clearScreen( true );
dmd.drawString( 0, 2, timeMinutes, 2, GRAPHICS_NORMAL );
dmd.drawString( 7, 2, timeSeconds, 2, GRAPHICS_NORMAL );
dmd.drawString( 16, 2, timeHundreds, 3, GRAPHICS_NORMAL );

This doesn't work. When I compile the code I get "no matching function for call to 'DMD::drawString(int, int, String&, int, int)'"
But if I put the timeMinutes like "timeMinutes" it works.

Somewhere I have done something wrong but I can't find where.

Anyone that have some clue??


Re: One more question about Arduino and DMD

Post by TheRevva » Tue Oct 15, 2013 7:10 am

Well, since I seem to be 'on a roll', I may as well do my best to try to answer this one too...
You'll have to forgive the fact that I've got LESS exposure to an Arduino than YOU have...
(However, I've been cutting 'C' code for the past 30 years, so I'm perhaps not as totally 'green' as you'd expect)...

The error that you're getting is giving you all the hints you need to locate the issue.
Specifically, it's saying that it cannot find a function inside the DMD class named drawString that expects to be given 2 int variables, 1 String variable and the 2 more int variables.
If you now take a look at the DMD library code (DMD.cpp), you will find that there IS a function named drawString inside the DMD class, but the third variable is not of type 'String'. Instead, it's expecting it to be of type 'const char *'
While us mere mortal humans can look at any bunch of arranged characters and call it a word, sentence etc, our digital cousins (such as the Arduino) aren't quite as bright...
If we take a bunch of characters "Hello world" and place them into a plastic bucket named "String", and then take another bunch of characters "Goodbye cruel world" and place them into a different plastic bucket named "const char *", we can figure things out pretty quickly. The actual name on the bucket to us humans is pretty immaterial!
However, the Arduino and other such digital friends can be a bit more fussy than us humans... In this case, you're giving a bunch of characters that you grabbed out of the 'String' bucket to a function that will only accept bunches of characters coming from the 'const char *' bucket. Since there's not a one-to-one match, the compiler is throwing back an error!!!

Rather than SOLVE this problem for you completely, I'll leave it to you to think this through a bit and see if you can come up with the answer... (If you are still stuck, let us know and we'll give you some more clues...) I know it's terribly frustrating having to go through this STEEP learning curve, but this is one issue that is too 'valuable' for you in your Arduino / C++ / OOP future.

Post Reply