I’m working with a chained of four 16x32 HUB75 panels hooked up to a Teensy 3.6 with the SmartLED v3 shield using the master branch of the SmartMatrix library. It’s receiving commands via USB serial sent from a Raspberry Pi (though I don’t think that part is relevant here).
By default, const int textLayerMaxStringLength = 100;
in Layer_Scrolling.h
. I need this to be longer, so I bumped it up to 1024. However I am running into some strange issues with longer strings of text.
For example, I call SMLayerScrolling::update
with the following:
Once upon a midnight dreary, while I pondered, weak and weary, Over many a quaint and curious volume of forgotten lore—While I nodded, nearly napping, suddenly there came a tapping, As of some one gently rapping, rapping at my chamber door. Tis some visitor, I muttered, rapping at my chamber door—Only this and nothing more.
and the text displayed on the LED matrix will be
Once upon a midnight dreary, while I pondered, weak and weary, Over
The cutoff is 256 characters away from the endpoint. If I cut off the beginning of the string, it will still cutoff at the same point, so it is counting backwards from the end somehow.
I am certain at this point that the issue is unrelated to the serial communication - debugging prints show me that the entire string is stored in the Arduino at every point in my program that is calling the SmartMatrix library.
So I suspect the issue is somehow related to string manipulation code. Looking in the code for SMLayerScrolling::update
, strncpy
is used. I tried strlcpy
instead with no luck. But I am a complete noob to C/C++, so I don’t know what the best string practices are.
My program on the Arduino uses strdup
to get the string from the Serial port - but again, all the debugging lines show that it has a copy of the entire string. I tried bumping up size of the Teensy’s Serial rx buffer anyways, but it makes no difference.
I’m guessing there is a really simple fix here, but my inexperience leaves me clueless. Thanks in advance for the help!
Incase anyone wants to peek at my code, I think this is the potentially relevant file: qyron/SmartMatrixParser.h at longer-text · drbeefsupreme/qyron · GitHub Ignore the command struct stuff at the start, I’m doing this the dumb way by just doing a switch on hard coded command names for now.