MD Parola Scroll Time from RTC DS3231

Hi, I require some help regarding scrolling Time values from DS3231 on a MAX7219 hardware using MD Parola library. With the help of examples, I was able to scroll static text. But when I try to do the same with RTC values, the compiler indicates:

no matching function for call to 'MD_Parola::displayText(String&, textPosition_t, int, int, textEffect_t, textEffect_t)'

Following is the code used to perform the desired task. As I understood, the issue lies in the conversion of String to Char (please correct me if I’m wrong), although I don’t understand how to do that.

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#include <RTClib.h>
#include <Wire.h>

#define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW
#define MAX_DEVICES 8
#define CLK_PIN   D5
#define DATA_PIN  D7
#define CS_PIN    D8

// Hardware SPI connection
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
RTC_DS1307 RTC;

void setup(void)
{
  Serial.begin(9600);
  Wire.begin(4, 5); //SDA, SCL
  P.begin();
  RTC.begin();
}

void loop(void)
{
  DateTime now = RTC.now();
  Serial.println();
  Serial.print(now.minute(), DEC); Serial.print(":"); Serial.print(now.minute(), DEC);
  String Time = String (now.hour(), DEC); + ":" + (now.minute(), DEC);;
  
  if (P.displayAnimate()) {
    //P.displayText("Hello", PA_CENTER, 20, 20, PA_SCROLL_LEFT, PA_SCROLL_LEFT); // This works
    P.displayText(Time, PA_CENTER, 20, 20, PA_SCROLL_LEFT, PA_SCROLL_LEFT); // Doesn't work
  }  
}

Please someone help me resolve this issue.

Thanks.

here String Time = String (now.hour(), DEC); + ":" + (now.minute(), DEC); you convert (unsigned 8-bit) integers into String so you can concatenate them, if you start out with char array of a defined size and use strcat then you don't have the issue of converting back to a c-string (which the function you want to call takes as an argument)

Deva_Rishi:
here

String Time = String (now.hour(), DEC); + ":" + (now.minute(), DEC);

you convert (unsigned 8-bit) integers into String so you can concatenate them, if you start out with char array of a defined size and use strcat then you don't have the issue of converting back to a c-string (which the function you want to call takes as an argument)

Thanks Deva for your reply. I'm new to programming, so I tried to implement the strcat function by changing the code in the loop section to the following:

  DateTime now = RTC.now();
  Serial.println();
  Serial.print(now.minute(), DEC); Serial.print(":"); Serial.print(now.minute(), DEC);
  char Time[80];
  strcat (Time, (now.hour(), DEC) + ":" + (now.minute(), DEC));
  Serial.println(Time);
  
  if (P.displayAnimate()) {
    //P.displayText("Hello", PA_CENTER, 20, 20, PA_SCROLL_LEFT, PA_SCROLL_LEFT); // This works
    P.displayText(Time, PA_CENTER, 20, 20, PA_SCROLL_LEFT, PA_SCROLL_LEFT); // Doesn't work
  }

Obviously I made some mistakes as the output i get on the serial monitor isn't what I expected.

17:17T⸮⸮?⸮#@T⸮⸮??D @dddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @ddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @dddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @ddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @dddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @ddddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @dddddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @ddddddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @dddddddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @ddddddddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @dddddddddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @ddddddddddddddddddddddddddddddd

17:17T⸮⸮?⸮#@T⸮⸮??D @dddddddddddddddddddddddddddddddd

I'd be glad if you could help me in the code section.

Thanks.

First of all, please don't do this, Serial.print(now.minute(), DEC); Serial.print(":"); Serial.print(now.minute(), DEC); but let every command line be a line in the code

Serial.print(now.minute(), DEC); 
Serial.print(":"); 
Serial.print(now.minute(), DEC);

this will make things a lot easier to read for most people here (mostly me .. hehe.)

What you need to do fill the char array bit by bit and do the conversion bit by bit. You can not just use the "+" operator and you can not use the 'String' method (poor choice of word maybe..) ( int, DEC).
instead you start out with strcpy and use itoa for conversion

char Time[80];
  strcpy(Time, "TIME = ");
  char  Hr[3]; // buffer here is 3,  2 for the digits and 1 the \0 terminator
  itoa(now.hour(), Hr, 10); // convert hour() to char array Hr
  strcat(Time, Hr);
  strcat(Time, ":");
  char Mn[3];
  itoa(now.minute(), Mn, 10);
  strcat(Time, Mn);
  Serial.println(Time);

It does all look a bit cumbersome, and instead of using itoa() i usually use a function i quickly write myself. Using and getting used to working with c-strings will help a lot later on. Main thing to keep in mind is that they are '\0' - Null terminated, which means that at the end of the string there should be a '\0' character. itoa(), strcpy() and strcat() add this '\0' for you, but you have to provide the space.
There is of course also a way of just using 'String' to add all the data up and the convert to char pointer afterwards. as such

String STime = String (now.hour(), DEC) + ":" +  String (now.minute(), DEC);
  char caTime[STime.length()+1];
  STime.toCharArray(caTime,STime.length()+1);
  Serial.println(caTime);

It will work just as well, but is using 'String' and there using dynamic memory and this may fragment and then cause your program to crash unexpectedly (or not) after quite a long time even.