How to call this function - display_message(String message)

Hi Programmers,

This code displays a text message on an LED matrix when published to the subscribed MQTT topic then reverts to displaying the current time.
I want the last text message sent
to display whenever IO5 is taken low.
I believe I need to call the function described below but cannot get the code to compile.

How do I call this function below ?


void display_message(String message) {
  // Displays a message on the matrix
  for ( int i = 0 ; i < width * message.length() + matrix.width() - spacer; i++ ) {
    int letter = i / width;
    int x = (matrix.width() - 1) - i % width;
    int y = (matrix.height() - 8) / 2; // center the text vertically
    while ( x + width - spacer >= 0 && letter >= 0 ) {
      if ( letter < message.length() ) {
        matrix.drawChar(x, y, message[letter], HIGH, LOW, 1); // HIGH LOW means foreground ON, background off, reverse to invert the image
      }
      letter--;
      x -= width;
    }
    matrix.write(); // Send bitmap to display
    delay(wait / 2);
  }
}

I want to call the above function when IO5 goes low ..

  if (digitalRead(5) == LOW)   {                       // D1 Mini input D1 =  IO5
    display_message(String message);   //  Not working
  }

This gives me a a compiler error saying

expected primary-expression before 'message'

Can someone show me the correct syntax and explain why the usual command I use ie function_name(); does not work here.

Full code attached in zip file.
Arduino_Forum.zip (3.7 KB)

Cheers

Get rid of the parameter's datatype in the function call:

  if (digitalRead(5) == LOW)   {
    display_message(message);
  }

Thank you,it now compiles now but no message gets displayed on the LED matrix when taking IO5 low but does display message when a text string is published from the MQTT broker.
Does the buffer get cleared when exiting the
display_message(String message)
function and this is why there is no message to display ?
If so,is there a way to retain this message until another one gets sent from the MQTT broker to overwrite it ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.