I'm creating a scrolling youtube subs & views display for my son.
I'm using a mAX7219 32 x 8 display, and then using the MD_PAROLA library.
If I just pass a straightforward text to the library, it scrolls and displays fine.
However I need to combine some text and the subscriber/view count from youtube api and although when I use Serial.print it shows the combined text fine, on the display it shows as random junk.
The displayText needs a const char array as the text input field, which is why I end up creating a string to begin with and then convert it to a char array.
The 2 Serial.println commands both show me the exact same text.
I suspect that I'm not understanding some fundamental principle relating to the variables and how they are passed?
void loop() {
const char *yt0,*yt1,*yt2;
String subsString;
if (myDisplay.displayAnimate()) {
if (i == 0){
if(api.getChannelStatistics(CHANNEL_ID)) {
Serial.println("\n---------Stats-------------");
Serial.print("Subscriber #: ");
Serial.println(api.channelStats.subscriberCount);
Serial.print(" View #: ");
Serial.println(api.channelStats.viewCount);
Serial.println("----------------------------");
subsString = "Subs: " + String(api.channelStats.subscriberCount);
yt1 = subsString.c_str();
Serial.println(subsString.c_str());
Serial.println(yt1);
}
switch(cnt){
case 0:
myDisplay.displayText(yt1, PA_RIGHT, 50, 5000, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
cnt =1;
break;
case 1:
myDisplay.displayText("Views: 138762", PA_RIGHT, 50, 5000, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
cnt =0;
break;
}
myDisplay.displayReset();
}
}
}