The displayZoneText function is indeed used to display text on specific zones of the LED matrix. However, this function expects a string as its second argument. In your case, you are trying to pass an integer value (Score1) to the function, which is causing an error.
To fix this issue, you need to convert the integer values to strings before passing them to the displayZoneText function. You can achieve this using the String() function. Here is how you can modify your code:
void loop() {
String score1Str = String(Score1);
String score2Str = String(Score2);
P.displayZoneText(0, score2Str.c_str(), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(1, score1Str.c_str(), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayAnimate();
}
In this code, Score1 and Score2 are converted to strings using the String() function. The c_str() method is then used to convert these string objects to C-style strings (null-terminated arrays of characters), which is what the displayZoneText function expects.
Please note that the c_str() method returns a pointer to the internal array of the string object. This means that if the original string object is destroyed, the returned pointer will become invalid. Therefore, make sure that the string object stays alive until after you're done using the returned pointer.
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 8
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
int Score1 = 1001;
int Score2 = 128;
void setup() {
P.begin(2);
P.setIntensity(2);
P.setZone(0, 0, 3);
P.setZone(1, 4, 7);
}
void loop() {
String score1Str = String(Score1);
String score2Str = String(Score2);
P.displayZoneText(0, score2Str.c_str(), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayZoneText(1, score1Str.c_str(), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayAnimate();
}