Arduino_LED_Matrix printing variables, not text

Hello,

I am now using Text-With-Arduino-Graphics functionality with the Uno Rev 4 wifi, in earnest. I love the text printing features (in addition to the general graphics).

However I need to print to screen some sensor variable data, and can see no obvious way to do it, other than code some output functions myself. I have to believe that the Text With Graphics functionality is set up to print numbers/data beyond simply text strings. I have read the various Arduino examples and looked at the limited documentation available for the libraries, but its not obvious to me you can easily do this.

My main reference is the Arduino page on LED matrix and this Github: ArduinoCore-renesas/libraries/Arduino_LED_Matrix/examples/TextWithArduinoGraphics/

Is there an easy and obvious solution to printing variable data (int or fp) to the LED matrix screen?

Thanks, Steven Lightfoot

I might be misunderstanding, but doesn't String(var) work?

Maybe, but I don't really know. If you look at the code in the example:

const char text[] = " Scrolling text! ";
matrix.textFont(Font_5x7);
matrix.beginText(0, 1, 0xFFFFFF);
matrix.println(text);
matrix.endText(SCROLL_LEFT);

In CPP the library is made of a class I think, and (I think) an object is defined as 'matrix' and then a series of functions/methods for the objects related to the matrix printing are employed. The print method: matrix.println(text) seems to be set up to print text made up of a char string, I tried to make an int variable and then use the method to print the variable name, but nothing happened........

But what other possible functions/methods exist with the object/class for Arduino_LED_Matrix.h library are not clear to me, and I cant find any robust documentation that explains it, though as a relative newbie I may simply being obtuse. Further comments are welcome!!!!

Steve

Change it to

matrix.println(String(integer variable));

cool I will try that. Is that documented anywhere?

Yes, the Language Reference Manual. STUDY IT at https://docs.arduino.cc/programming/

Thanks, did not work. It compiled without error, but didnt print the value 99, which was the value of 'intvariable'.

Code line: UnoR4ECCCawardmatrix.println(String(intvariable));

OK thanks, actually I am now fairly familiar with the language reference, I was asking more about documentation specifically for the library and methods within the classes. etc.

I just tested it and it works fine. Try a test, assign a number to an int variable and print it with the String(in variable) statement. Did you look at the link I sent????

OK thanks, that is encouraging, I will try again later today. I will post the entire code too. I will come back on this.

1 Like

Cool, works, I started from the ground up using the example, and it works exactly as you described. In terms of language references, I am quite familiar with the Arduino ref page, but I was looking more for docs relating to the library in question. Anyway, I will look closed at the use of String() within the standard println function.

Thank you!!!

Steven Lightfoot

Library doc is the responsibility of the author. Generally start at the Github page for the library and sometimes there will be some docs. Otherwise read the library code starting at the hdr for an overview, then the C++ for any further details. None of that would have helped in this case as it was a simple case of you not knowing about String.

If the library is inheriting from Print then there is probably no reason to use any String.

The String class can be a memory killer in small systems. It's known to cause issues with stability on many boards.

Fair enough, how would you 'stringize' a numeric variable?

Thanks. Then in this case, do you have suggestion for printing an int variable to the LED matrix, with code such as: NewR4matrix.println(String(count)); ?

Steve

In that case, it's just NewR4matrix.println(count);

The Print class does all of that for you. It's just like using Serial.print.

That's assuming the library actually derives from Print, but 99% of the time a library as a print method it does.

1 Like

Cool. The issue was it didnt work before, which was the whole reason I made the post.

And with the new code (the example, copied, basically) it works just as-is, without even the String part. Which is good because that is what I tried the first time, and it wouldnt work, despite thinking it appeared simple to do. which it is.

Dont know what happened!

Anyway, thanks for both, its simple and it works.

Steven Lightfoot

That is what I assumed, I got thrown off by something somebody said earlier.

1 Like