Hi guys,
i have a LED Matrix 8 x 8x8 . I want to show a mqtt message (Temperature, Pressure etc) on this Display with the MD_Parola library. I have this Problem:
Prepare the Data:
String tmsg ;
.
.
.
void TempCallback(char* ttopic, byte* tpayload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(ttopic);
Serial.print("] ");
newMessageAvailable = true;
for (int i = 0; i < length; i++) {
Serial.print((char)tpayload*);*
_ tmsg += (char)tpayload*;_
_ }_
_}_
_._
_._
_.*_
parola.displayText (tmsg, PA_CENTER, 40, 1200, PA_SCROLL_UP_LEFT , PA_SCROLL_UP_RIGHT );
makes Compiler ERROR:
no matching function for call to 'MD_Parola::displayText(String&, textPosition_t, int, int, textEffect_t, textEffect_t)'
Why Comes this Compiler ERROR
Thanks in Advance OLLI
'MD_Parola::displayText(String&,
The displayText() function has no overload (version) that will print Strings. The function wants a pointer to a string (null terminated character array).
From MD_Parola.cpp file, the displayText function definition. Note the argument const char *pText.
inline void displayText(const char *pText, textPosition_t align, uint16_t speed, uint16_t pause, textEffect_t effectIn, textEffect_t effectOut = PA_NO_EFFECT)
Thanks groundFungus,
i work with
strcpy(tbuffer, tmsg.c_str());
but Nothing is printed on the Display
Why
Thanks Olli
strcpy(tbuffer, tmsg.c_str());
Why copy to a buffer? tmsg.c_str() returns a pointer to a string and that is what you want as the argument. Tested, and works, with my Uno and a LED matrix. You may need to change the hardware interface and pins to suit what you have.
Here is a sketch (modified Parols_HelloWorld) that uses the c_str() function.
// Program to demonstrate the MD_Parola library
//
// Simplest program that does something useful - Hello World!
//
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 8
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// Hardware SPI connection
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Arbitrary output pins
// MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
String hi = "HELLO";
char *strHi = hi.c_str();
void setup(void)
{
P.begin();
P.displayText(strHi, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
}
void loop(void)
{
P.displayAnimate();
}
tmsg += (char)tpayload;
tpayload is a byte pointer but you cast it to a char.