Go Down

Topic: LED matrix display - MD_Parola, MD_MAX72xx and MD_MAXPanel (Read 438604 times) previous topic - next topic

PriSim

Do you understand that the second number parameter here (1500)
Code: [Select]
P.displayText(szBuf, PA_CENTER, 50, 1500, PA_PRINT, PA_NO_EFFECT);
is the delay between the end of PA_PRINT and PA_NO_EFFECT?
If you are trying to update a clock every second then having a 1.5 second delay before the animation is finished does not seem like a good idea.
You should probably just use the .print() method for Parola and then update it again after you have detected that 1000ms have passed (like in blink without delay).
Yes that was the main issue, Pause time , I was using it globally for all of my print routines , But now i am using a different pause and speed time for clock display and different for other text routines.
using:

Code: [Select]

 P.setPause();
    P.setSpeed();


Everything is working fine now. Thanks for the Help :)

Azazel32

Greetings I'm implemented Parola Double Height Displays in 2 rows of 8 with serial communication but I can not make the text show someone could help me please correct me, I ask disuculpas for my English my mother tongue is Spanish

I am trying to display the text in a double matrix with serial communication

Code: [Select]


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

#if USE_GENERIC_HW || USE_PAROLA_HW
#define INVERT_UPPER_ZONE 1
#endif

// Turn debugging on and off
#define DEBUG 1


#if DEBUG
#define PRINTS(s)   { Serial.print(F(s)); }
#define PRINT(s, v) { Serial.print(F(s)); Serial.print(v); }
#else
#define PRINTS(s)
#define PRINT(s, v)
#endif

// Define the main direction for scrolling double height.
// if 1, scroll left; if 0, scroll right
#define SCROLL_LEFT 1

#if INVERT_UPPER_ZONE

#if SCROLL_LEFT // invert and scroll left
#define SCROLL_UPPER  PA_SCROLL_RIGHT
#define SCROLL_LOWER  PA_SCROLL_LEFT
#else           // invert and scroll right
#define SCROLL_UPPER  PA_SCROLL_LEFT
#define SCROLL_LOWER  PA_SCROLL_RIGHT
#endif

#else // not invert

#if SCROLL_LEFT // not invert and scroll left
#define SCROLL_UPPER  PA_SCROLL_LEFT
#define SCROLL_LOWER  PA_SCROLL_LEFT
#else           // not invert and scroll right
#define SCROLL_UPPER  PA_SCROLL_RIGHT
#define SCROLL_LOWER  PA_SCROLL_RIGHT
#endif

#endif


// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers may not work with your hardware and may need changing
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_ZONES 2
#define ZONE_SIZE 8
#define MAX_DEVICES (MAX_ZONES * ZONE_SIZE)

#define ZONE_UPPER  1
#define ZONE_LOWER  0

#define PAUSE_TIME 0
#define SCROLL_SPEED 50

#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
char *msgL[] =
{
  //"Double height with custom font & 2 zones",
  "HOLA MUNDO",

 //"abcdefghijklmnopqrstuvwxyz",
 //"0123456789",
// "`!@#$%^&*()_+-={};:'<>\"?,./|\\{}",
};
char *msgH; // allocated memory in setup()

void setup(void)
{
  uint8_t max = 0;

#if DEBUG
  Serial.begin(57600);
  PRINTS("\n[Double_Height_v2]");
#endif

  // work out the size of buffer required
  for (uint8_t i = 0; i<ARRAY_SIZE(msgL); i++)
    if (strlen(msgL[i]) > max) max = strlen(msgL[i]);

  msgH = (char *)malloc(sizeof(char)*(max + 2));

  // initialise the LED display
  P.begin(MAX_ZONES);

  // Set up zones for 2 halves of the display
  P.setZone(ZONE_LOWER, 0, ZONE_SIZE - 1);
  P.setZone(ZONE_UPPER, ZONE_SIZE, MAX_DEVICES-1);
  P.setFont(BigFont);
  P.setCharSpacing(P.getCharSpacing() * 2); // double height --> double spacing
#if INVERT_UPPER_ZONE
  P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_UD);
  P.setZoneEffect(ZONE_UPPER, true, PA_FLIP_LR);
#endif
  PRINT("\nFLIP_UD=", P.getZoneEffect(ZONE_UPPER, PA_FLIP_UD));
  PRINT("\nFLIP_LR=", P.getZoneEffect(ZONE_UPPER, PA_FLIP_LR));
  PRINT("\nSCROLL_LEFT=", SCROLL_LEFT);
}

void createHString(char *pH, char *pL)
{
  for (; *pL != '\0'; pL++)
    *pH++ = *pL | 0x80;   // offset character

  *pH = '\0'; // terminate the string
}

void loop(void)
{
  static uint8_t cycle = 0;
    if (Serial.available())
   {
      uint8_t max = 0;
     msgH = Serial.read();
    Serial.println(msgH);

     // work out the size of buffer required
  for (uint8_t i = 0; i<ARRAY_SIZE(msgL); i++)
    if (strlen(msgL[i]) > max) max = strlen(msgL[i]);

  msgH = (char *)malloc(sizeof(char)*(max + 2));

   }



  P.displayAnimate();

  if (P.getZoneStatus(ZONE_LOWER) && P.getZoneStatus(ZONE_UPPER))
  {
    PRINT("\n", cycle);
    PRINT(": ", msgL[cycle]);

    // set up the string
    createHString(msgH, msgL[cycle]);

    P.displayClear();
#if INVERT_UPPER_ZONE
    P.displayZoneText(ZONE_UPPER, msgH, PA_CENTER, SCROLL_SPEED, PAUSE_TIME, SCROLL_UPPER, SCROLL_UPPER);
    P.displayZoneText(ZONE_LOWER, msgL[cycle], PA_CENTER, SCROLL_SPEED, PAUSE_TIME, SCROLL_LOWER, SCROLL_LOWER);
#else
    P.displayZoneText(ZONE_LOWER, msgL[cycle], PA_LEFT, SCROLL_SPEED, PAUSE_TIME, SCROLL_LOWER, SCROLL_LOWER);
    P.displayZoneText(ZONE_UPPER, msgH, PA_LEFT, SCROLL_SPEED, PAUSE_TIME, SCROLL_UPPER, SCROLL_UPPER);
#endif

    // prepare for next pass
    cycle = (cycle + 1) % ARRAY_SIZE(msgL);

    // synchronise the start and run the display
    P.synchZoneStart();
  }
}

marco_c

Quote
can not make the text show
Have you tried just running the example program without your changes. Does this work?

Also, in this part of the code
Code: [Select]
    if (Serial.available())
   {
      uint8_t max = 0;
     msgH = Serial.read();
    Serial.println(msgH);

     // work out the size of buffer required
  for (uint8_t i = 0; i<ARRAY_SIZE(msgL); i++)
    if (strlen(msgL[i]) > max) max = strlen(msgL[i]);

  msgH = (char *)malloc(sizeof(char)*(max + 2));

   }

You need to free() the string before you allocate a new one, otherwise you get a memory leak. Also, you are measuring the size of msgL, which has not changed from the start of the program.

Also, Serial.available() only tells you if there is ONE (or more) characters at the Serial port. You are not constructing the string as it arrives. Please see the Parola_Scrolling example for how this is done reliably.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Rodrigo Yoshiaki

#1323
Jul 20, 2018, 06:17 pm Last Edit: Jul 20, 2018, 06:19 pm by Rodrigo Yoshiaki
Hey guys, how r u doing ? Someone can help me ?
print of error : http://prntscr.com/k8y0v8

And look my code, maybe u guys can help me.

obs : I am using nodemcu v3 + 4 matrix module of 8x32 ( making a matrix of 16x64 or ( 64x16 ) )

Code: [Select]

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include "Font_Data.h"
#include "Arduino.h"
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>

#define MAX_DEVICES 8
#define MAX_ZONES 2
#define ZONE_SIZE (MAX_DEVICES/MAX_ZONES)

#define DIN_PIN 15 
#define CS_PIN  13 
#define CLK_PIN 12

const char* ssid     = "xxxxxx";      // SSID do wifi
const char* password = "xxxxxx";    // senha wifi
String ytApiV3Key = "xxxxxxxxxxx";                // YouTube Data API v3 key
String channelId = "xxxxxxxxxxxx";   // YT id do canal
long utcOffset = -3;                        // fuso local   

MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);

void setup(void)
{
  Serial.begin(9600);
  delay(2000);
  P.begin(MAX_ZONES);
  P.setInvert(false);
  P.setIntensity(0);
 
  P.setZone(0, 0, ZONE_SIZE-1);
  P.setZone(1, ZONE_SIZE, MAX_DEVICES-1);
  P.setFont(0, BigFontBottom);
  P.setFont(1, BigFontUp);
  Serial.begin(115200);
  Serial.print("Connecting WiFi ");
  WiFi.begin(ssid, password);
  P.displayZoneText(0, " Bem Vindo ...~",CENTER,30, PRINT,SCROLL_LEFT);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print("."); delay(500);
  }
  P.setFont(0, BigFontBottom);
  P.setFont(1, BigFontUp);
  Serial.println("");
  Serial.print("Connected: "); Serial.println(WiFi.localIP());
  Serial.println("Getting data ...");
  P.displayZoneText(1," Gui Toledo ...~",CENTER,30,0,PRINT, SCROLL_LEFT);

}

long viewCount, viewCount24h=-1, viewsGain24h;
long subscriberCount, subscriberCount1h=-1, subscriberCount24h=-1, subsGain1h=0, subsGain24h=0;
long videoCount;
int cnt = 0;
unsigned long time1h, time24h;
long localEpoc = 0;
long localMillisAtUpdate = 0;
int h, m, s;
String date;

void loop()
{
  if(cnt<=0) {
    if(getYTData()==0) {
      cnt = 1; 
      if(subscriberCount1h<0) {
        time1h = time24h = millis();
        subscriberCount1h = subscriberCount24h = subscriberCount;
        viewCount24h = viewCount;
      }
      if(millis()-time1h>1000*60*60) {
        time1h = millis();
        subscriberCount1h = subscriberCount;
      }
      if(millis()-time24h>1000*60*60*24) {
        time24h = millis();
        subscriberCount24h = subscriberCount;
        viewCount24h = viewCount;
     
    }
  }
  cnt--;
  P.setZone(0, 0, ZONE_SIZE-1);
  P.setZone(1, ZONE_SIZE, MAX_DEVICES-1);
  P.setFont(0, BigFontBottom);
  P.setFont(1, BigFontUp);
  P.synchZoneStart();
  updateTime();
  P.displayZoneText(0, "               %02d:%02d        " ,h,m, CENTER, 30, 2000, PRINT, SCROLL_DOWN);
  P.displayZoneText(1, "               %02d:%02d        " ,h,m, CENTER, 30, 2000, PRINT, SCROLL_UP);
 delay(3000);
  P.displayZoneText(0, "Inscritos", CENTER, 30, 0, PRINT, NO_EFFECT);
  P.setFont(1, NULL);
  P.displayZoneText(1, subscriberCount, CENTER, 30, 0, SCROLL_LEFT, SCROLL_LEFT);
  delay(5000);
}
}

const char *ytHost = "www.googleapis.com";

int getYTData()
{
  WiFiClientSecure client;
  Serial.print("connecting to "); Serial.println(ytHost);
  if (!client.connect(ytHost, 443)) {
    Serial.println("connection failed");
    return -1;
  }
  String cmd = String("GET /youtube/v3/channels?part=statistics&id=") + channelId + "&key=" + ytApiV3Key+ " HTTP/1.1\r\n" +
                "Host: " + ytHost + "\r\nUser-Agent: ESP8266/1.1\r\nConnection: close\r\n\r\n";
  client.print(cmd);

  int repeatCounter = 10;
  while (!client.available() && repeatCounter--) {
    Serial.println("y."); delay(500);
  }
  String line,buf="";
  int startJson=0, dateFound=0;
  while (client.connected() && client.available()) {
    line = client.readStringUntil('\n');
    if(line[0]=='{') startJson=1;
    if(startJson) {
      for(int i=0;i<line.length();i++)
        if(line[i]=='[' || line[i]==']') line[i]=' ';
      buf+=line+"\n";
    }
    if(!dateFound && line.startsWith("Date: ")) {
      dateFound = 1;
      date = line.substring(6, 22);
      h = line.substring(23, 25).toInt();
      m = line.substring(26, 28).toInt();
      s = line.substring(29, 31).toInt();
      localMillisAtUpdate = millis();
      localEpoc = (h * 60 * 60 + m * 60 + s);
    }
  }
  client.stop();

  DynamicJsonBuffer jsonBuf;
  JsonObject &root = jsonBuf.parseObject(buf);
  if (!root.success()) {
        P.setFont(0, BigFontBottom);
          P.setFont(1, BigFontUp);
          P.synchZoneStart();
    Serial.println("parseObject() failed");
    P.displayZoneText(0, "json error!", CENTER, 30, 0, PRINT, NO_EFFECT);
    delay(10);
    return -1;
  }
  viewCount       = root["items"]["statistics"]["viewCount"];
  subscriberCount = root["items"]["statistics"]["subscriberCount"];
  videoCount      = root["items"]["statistics"]["videoCount"];
  return 0;
}

// =======================================================================

void updateTime()
{
  long curEpoch = localEpoc + ((millis() - localMillisAtUpdate) / 1000);
  long epoch = round(curEpoch + 3600 * utcOffset + 86400L) % 86400L;
  h = ((epoch  % 86400L) / 3600) % 24;
  m = (epoch % 3600) / 60;
  s = epoch % 60;
}

// =======================================================================



marco_c

#1324
Jul 21, 2018, 12:41 am Last Edit: Jul 21, 2018, 12:42 am by marco_c
Looks like you are using an old example with the new libraries. Please read the changes to the library in the revision log.

Also, better to cut and paste the text of the error than make us follow a like to a graphic of text.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Rodrigo Yoshiaki

#1325
Jul 21, 2018, 01:33 am Last Edit: Jul 21, 2018, 01:48 am by Rodrigo Yoshiaki
Looks like you are using an old example with the new libraries. Please read the changes to the library in the revision log.

Also, better to cut and paste the text of the error than make us follow a like to a graphic of text.
Ok I will revise this, and the error its :
I downloaded the new libraries but the error remains

Code: [Select]
Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200"

teste2zonas:23: error: invalid conversion from 'int' to 'MD_MAX72XX::moduleType_t' [-fpermissive]

 MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);

                                            ^

In file included from C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino:2:0:

C:\Users\Yoshiaki\Documents\Arduino\libraries\MD_Parola-master\src/MD_Parola.h:1095:3: error:   initializing argument 1 of 'MD_Parola::MD_Parola(MD_MAX72XX::moduleType_t, uint8_t, uint8_t)' [-fpermissive]

   MD_Parola(MD_MAX72XX::moduleType_t mod, uint8_t csPin, uint8_t numDevices = 1);

   ^

C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino: In function 'void setup()':

teste2zonas:40: error: 'CENTER' was not declared in this scope

   P.displayZoneText(0, " Bem Vindo ...~",CENTER,30, PRINT,SCROLL_LEFT);

                                          ^

teste2zonas:40: error: 'PRINT' was not declared in this scope

   P.displayZoneText(0, " Bem Vindo ...~",CENTER,30, PRINT,SCROLL_LEFT);

                                                     ^

teste2zonas:40: error: 'SCROLL_LEFT' was not declared in this scope

   P.displayZoneText(0, " Bem Vindo ...~",CENTER,30, PRINT,SCROLL_LEFT);

                                                           ^

C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino: In function 'void loop()':

teste2zonas:91: error: 'CENTER' was not declared in this scope

   P.displayZoneText(0, "               %02d:%02d        " ,h,m, CENTER, 30, 2000, PRINT, SCROLL_DOWN);

                                                                 ^

teste2zonas:91: error: 'PRINT' was not declared in this scope

   P.displayZoneText(0, "               %02d:%02d        " ,h,m, CENTER, 30, 2000, PRINT, SCROLL_DOWN);

                                                                                   ^

teste2zonas:91: error: 'SCROLL_DOWN' was not declared in this scope

   P.displayZoneText(0, "               %02d:%02d        " ,h,m, CENTER, 30, 2000, PRINT, SCROLL_DOWN);

                                                                                          ^

teste2zonas:92: error: 'SCROLL_UP' was not declared in this scope

   P.displayZoneText(1, "               %02d:%02d        " ,h,m, CENTER, 30, 2000, PRINT, SCROLL_UP);

                                                                                          ^

teste2zonas:94: error: 'NO_EFFECT' was not declared in this scope

   P.displayZoneText(0, "Inscritos", CENTER, 30, 0, PRINT, NO_EFFECT);

                                                           ^

teste2zonas:96: error: 'SCROLL_LEFT' was not declared in this scope

   P.displayZoneText(1, subscriberCount, CENTER, 30, 0, SCROLL_LEFT, SCROLL_LEFT);

                                                        ^

C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino: In function 'int getYTData()':

teste2zonas:148: error: 'CENTER' was not declared in this scope

     P.displayZoneText(0, "json error!", CENTER, 30, 0, PRINT, NO_EFFECT);

                                         ^

teste2zonas:148: error: 'PRINT' was not declared in this scope

     P.displayZoneText(0, "json error!", CENTER, 30, 0, PRINT, NO_EFFECT);

                                                        ^

teste2zonas:148: error: 'NO_EFFECT' was not declared in this scope

     P.displayZoneText(0, "json error!", CENTER, 30, 0, PRINT, NO_EFFECT);

                                                               ^

exit status 1
invalid conversion from 'int' to 'MD_MAX72XX::moduleType_t' [-fpermissive]

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


Hey @Edit now i modify the code and

Code: [Select]
Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200"

"Center was not declared in this scope"

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


And maybe its good u see the new code

https://pastebin.com/am5qUfTu


marco_c

#1326
Jul 21, 2018, 09:10 am Last Edit: Jul 21, 2018, 09:11 am by marco_c
The error remains because the error is in your code.

YOU ARE USING OLD SYNTAX CODE WITH THE NEW LIBRARY. See post #1306

As per the release notes, documentation and all the examples in the new version, this
Code: [Select]
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);
Is OBSOLETE and needs to have the module type added to the syntax.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Rodrigo Yoshiaki

#1327
Jul 21, 2018, 05:00 pm Last Edit: Jul 21, 2018, 07:10 pm by Rodrigo Yoshiaki
The error remains because the error is in your code.

YOU ARE USING OLD SYNTAX CODE WITH THE NEW LIBRARY. See post #1306

As per the release notes, documentation and all the examples in the new version, this
Code: [Select]
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);
Is OBSOLETE and needs to have the module type added to the syntax.
Hey thanks but new error appears look the new code :

Code: [Select]
#include <MD_MAXPanel.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include "Font_Data.h"
#include "Arduino.h"
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include <SPI.h>
#define MAX_ZONES 2
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define DIN_PIN 15 
#define CS_PIN  13 
#define CLK_PIN 12
#define ZONE_SIZE 7
#define MAX_DEVICES (MAX_ZONES * ZONE_SIZE)

#define ZONE_UPPER  1
#define ZONE_LOWER  0

#include <Wire.h>

const char* ssid     = "xxxxxx";      // SSID do wifi
const char* password = "xxxxxx";    // senha wifi
String ytApiV3Key = "xxxxxxxxxxx";                // YouTube Data API v3 key
String channelId = "xxxxxxxxxxxx";   // YT id do canal
long utcOffset = -3;                        // fuso local   

MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

void setup(void)
{
  Serial.begin(9600);
  delay(2000);
  P.begin(MAX_ZONES);
  P.setInvert(false);
  P.setIntensity(0);
 
  P.setZone(0, 0, ZONE_SIZE-1);
  P.setZone(1, ZONE_SIZE, MAX_DEVICES-1);
  P.setFont(0, BigFontBottom);
  P.setFont(1, BigFontUp);
  Serial.begin(115200);
  Serial.print("Connecting WiFi ");
  WiFi.begin(ssid, password);
  P.displayZoneText(0, " Bem Vindo ...~",PA_CENTER,30, PA_PRINT,PA_SCROLL_LEFT);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print("."); delay(500);
  }
  P.setFont(0, BigFontBottom);
  P.setFont(1, BigFontUp);
  Serial.println("");
  Serial.print("Connected: "); Serial.println(WiFi.localIP());
  Serial.println("Getting data ...");
  P.displayZoneText(1," Gui Toledo ...~",PA_CENTER,30,0,PA_PRINT, PA_SCROLL_LEFT);

}

long viewCount, viewCount24h=-1, viewsGain24h;
long subscriberCount, subscriberCount1h=-1, subscriberCount24h=-1, subsGain1h=0, subsGain24h=0;
long videoCount;
int cnt = 0;
unsigned long time1h, time24h;
long localEpoc = 0;
long localMillisAtUpdate = 0;
int h, m, s;
String date;

void loop()
{
  if(cnt<=0) {
    if(getYTData()==0) {
      cnt = 1; 
      if(subscriberCount1h<0) {
        time1h = time24h = millis();
        subscriberCount1h = subscriberCount24h = subscriberCount;
        viewCount24h = viewCount;
      }
      if(millis()-time1h>1000*60*60) {
        time1h = millis();
        subscriberCount1h = subscriberCount;
      }
      if(millis()-time24h>1000*60*60*24) {
        time24h = millis();
        subscriberCount24h = subscriberCount;
        viewCount24h = viewCount;
     
    }
  }
  cnt--;
  P.setZone(0, 0, ZONE_SIZE-1);
  P.setZone(1, ZONE_SIZE, MAX_DEVICES-1);
  P.setFont(0, BigFontBottom);
  P.setFont(1, BigFontUp);
  P.synchZoneStart();
  updateTime();
  P.displayZoneText(0, "               %02d:%02d        " ,h,m, PA_CENTER, 30, 2000, PA_PRINT, PA_SCROLL_DOWN);
  P.displayZoneText(1, "               %02d:%02d        " ,h,m, PA_CENTER, 30, 2000, PA_PRINT, PA_SCROLL_UP);
 delay(3000);
  P.displayZoneText(0, "Inscritos", PA_CENTER, 30, 0, PA_PRINT, PA_NO_EFFECT);
  P.setFont(1, NULL);
  P.displayZoneText(1, subscriberCount, PA_CENTER, 30, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
  delay(5000);
}
}

const char *ytHost = "www.googleapis.com";

int getYTData()
{
  WiFiClientSecure client;
  Serial.print("connecting to "); Serial.println(ytHost);
  if (!client.connect(ytHost, 443)) {
    Serial.println("connection failed");
    return -1;
  }
  String cmd = String("GET /youtube/v3/channels?part=statistics&id=") + channelId + "&key=" + ytApiV3Key+ " HTTP/1.1\r\n" +
                "Host: " + ytHost + "\r\nUser-Agent: ESP8266/1.1\r\nConnection: close\r\n\r\n";
  client.print(cmd);

  int repeatCounter = 10;
  while (!client.available() && repeatCounter--) {
    Serial.println("y."); delay(500);
  }
  String line,buf="";
  int startJson=0, dateFound=0;
  while (client.connected() && client.available()) {
    line = client.readStringUntil('\n');
    if(line[0]=='{') startJson=1;
    if(startJson) {
      for(int i=0;i<line.length();i++)
        if(line[i]=='[' || line[i]==']') line[i]=' ';
      buf+=line+"\n";
    }
    if(!dateFound && line.startsWith("Date: ")) {
      dateFound = 1;
      date = line.substring(6, 22);
      h = line.substring(23, 25).toInt();
      m = line.substring(26, 28).toInt();
      s = line.substring(29, 31).toInt();
      localMillisAtUpdate = millis();
      localEpoc = (h * 60 * 60 + m * 60 + s);
    }
  }
  client.stop();

  DynamicJsonBuffer jsonBuf;
  JsonObject &root = jsonBuf.parseObject(buf);
  if (!root.success()) {
        P.setFont(0, BigFontBottom);
          P.setFont(1, BigFontUp);
          P.synchZoneStart();
    Serial.println("parseObject() failed");
    P.displayText("JSon Error", PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
    delay(10);
    return -1;
  }
  viewCount       = root["items"]["statistics"]["viewCount"];
  subscriberCount = root["items"]["statistics"]["subscriberCount"];
  videoCount      = root["items"]["statistics"]["videoCount"];
  return 0;
}

void updateTime()
{
  long curEpoch = localEpoc + ((millis() - localMillisAtUpdate) / 1000);
  long epoch = round(curEpoch + 3600 * utcOffset + 86400L) % 86400L;
  h = ((epoch  % 86400L) / 3600) % 24;
  m = (epoch % 3600) / 60;
  s = epoch % 60;
}


the new error :

Code: [Select]
Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200"

C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino: In function 'void loop()':

teste2zonas:98: error: no matching function for call to 'MD_Parola::displayZoneText(int, const char [33], int&, int&, textPosition_t, int, int, textEffect_t, textEffect_t)'

   P.displayZoneText(0, "               %02d:%02d        " ,h,m, PA_CENTER, 30, 2000, PA_PRINT, PA_SCROLL_DOWN);

                                                                                                              ^

C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino:98:110: note: candidate is:

In file included from C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino:2:0:

C:\Users\Yoshiaki\Documents\Arduino\libraries\MD_Parola-master\src/MD_Parola.h:1322:8: note: void MD_Parola::displayZoneText(uint8_t, char*, textPosition_t, uint16_t, uint16_t, textEffect_t, textEffect_t)

   void displayZoneText(uint8_t z, char *pText, textPosition_t align, uint16_t speed, uint16_t pause, textEffect_t effectIn, textEffect_t effectOut = PA_NO_EFFECT);

        ^

C:\Users\Yoshiaki\Documents\Arduino\libraries\MD_Parola-master\src/MD_Parola.h:1322:8: note:   candidate expects 7 arguments, 9 provided

teste2zonas:99: error: no matching function for call to 'MD_Parola::displayZoneText(int, const char [33], int&, int&, textPosition_t, int, int, textEffect_t, textEffect_t)'

   P.displayZoneText(1, "               %02d:%02d        " ,h,m, PA_CENTER, 30, 2000, PA_PRINT, PA_SCROLL_UP);

                                                                                                            ^

C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino:99:108: note: candidate is:

In file included from C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino:2:0:

C:\Users\Yoshiaki\Documents\Arduino\libraries\MD_Parola-master\src/MD_Parola.h:1322:8: note: void MD_Parola::displayZoneText(uint8_t, char*, textPosition_t, uint16_t, uint16_t, textEffect_t, textEffect_t)

   void displayZoneText(uint8_t z, char *pText, textPosition_t align, uint16_t speed, uint16_t pause, textEffect_t effectIn, textEffect_t effectOut = PA_NO_EFFECT);

        ^

C:\Users\Yoshiaki\Documents\Arduino\libraries\MD_Parola-master\src/MD_Parola.h:1322:8: note:   candidate expects 7 arguments, 9 provided

teste2zonas:103: error: invalid conversion from 'long int' to 'char*' [-fpermissive]

   P.displayZoneText(1, subscriberCount, PA_CENTER, 30, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);

                                                                                         ^

In file included from C:\Users\Yoshiaki\Desktop\teste2zonas\teste2zonas.ino:2:0:

C:\Users\Yoshiaki\Documents\Arduino\libraries\MD_Parola-master\src/MD_Parola.h:1322:8: error:   initializing argument 2 of 'void MD_Parola::displayZoneText(uint8_t, char*, textPosition_t, uint16_t, uint16_t, textEffect_t, textEffect_t)' [-fpermissive]

   void displayZoneText(uint8_t z, char *pText, textPosition_t align, uint16_t speed, uint16_t pause, textEffect_t effectIn, textEffect_t effectOut = PA_NO_EFFECT);

        ^

exit status 1
no matching function for call to 'MD_Parola::displayZoneText(int, const char [33], int&, int&, textPosition_t, int, int, textEffect_t, textEffect_t)'


marco_c

#1328
Jul 22, 2018, 12:14 am Last Edit: Jul 22, 2018, 12:18 am by marco_c
I am not sure where you got this piece of archeology for code, but it is way out of date with the libraries.

The compiler message is telling you that the function is not defined he way you are using it. You should be able to look up what the type is and check the header file to see whether it has changed in any way or whether the error is in your use.

It is likely that you will also find that some #defines have changed or are no longer available, so please try and work those out yourself.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Rodrigo Yoshiaki

Hey marco_c , I cleaned up my code, and I found my mistakes and I fixed them, look :

Code: [Select]

#include <MD_MAXPanel.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include <Wire.h>
#include <SPI.h>
#include "Font_Data.h"
#include "Arduino.h"

#define DIN_PIN 15  
#define CS_PIN  13  
#define CLK_PIN 12

#define MAX_DEVICES 8
#define MAX_ZONES 2
#define ZONE_SIZE (MAX_DEVICES/MAX_ZONES)
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW

MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

const char* ssid     = "xxxxxx";      // SSID do wifi
const char* password = "xxxxxx";    // senha wifi
String ytApiV3Key = "xxxxxxxxxxx";                // YouTube Data API v3 key
String channelId = "xxxxxxxxxxxx";   // YT id do canal
long utcOffset = -3;                        // fuso local  



void setup(void)
{
  Serial.begin(9600);
  delay(2000);
  P.begin(MAX_ZONES);
  P.setInvert(false);
  P.setIntensity(0);
  
  P.setZone(0, 0, ZONE_SIZE-1);
  P.setZone(1, ZONE_SIZE, MAX_DEVICES-1);

  Serial.begin(115200);
  Serial.print("Connecting WiFi ");
  WiFi.begin(ssid, password);
  P.displayZoneText(0, " Bem Vindo ...~",PA_CENTER,30, PA_PRINT,PA_SCROLL_LEFT);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print("."); delay(500);
  }
  Serial.println("");
  Serial.print("Connected: "); Serial.println(WiFi.localIP());
  Serial.println("Getting data ...");
  P.displayZoneText(1," Gui Toledo ...~",PA_CENTER,30,0,PA_PRINT, PA_SCROLL_LEFT);

}

long viewCount, viewCount24h=-1, viewsGain24h;
long subscriberCount;
int cnt = 0;
unsigned long time1h, time24h;
long localEpoc = 0;
long localMillisAtUpdate = 0;
int h, m, s;
String date;

void loop()
{
  P.setZone(0, 0, ZONE_SIZE-1);
  P.setZone(1, ZONE_SIZE, MAX_DEVICES-1);
  P.setFont(0, BigFontBottom);
  P.setFont(1, BigFontUp);
  P.displayZoneText(0, "Inscritos" + subscriberCount, PA_CENTER, 30, 0, PA_PRINT, PA_NO_EFFECT);
  P.synchZoneStart();
}

const char *ytHost = "www.googleapis.com";

int getYTData()
{
  WiFiClientSecure client;
  Serial.print("connecting to "); Serial.println(ytHost);
  if (!client.connect(ytHost, 443)) {
    Serial.println("connection failed");
    return -1;
  };
  String cmd = String("GET /youtube/v3/channels?part=statistics&id=") + channelId + "&key=" + ytApiV3Key+ " HTTP/1.1\r\n" +
                "Host: " + ytHost + "\r\nUser-Agent: ESP8266/1.1\r\nConnection: close\r\n\r\n";
  client.print(cmd);

  int repeatCounter = 10;
  while (!client.available() && repeatCounter--) {
    Serial.println("y."); delay(500);
  }
  String line,buf="";
  int startJson=0, dateFound=0;
  while (client.connected() && client.available()) {
    line = client.readStringUntil('\n');
    if(line[0]=='{') startJson=1;
    if(startJson) {
      for(int i=0;i<line.length();i++)
        if(line[i]=='[' || line[i]==']') line[i]=' ';
      buf+=line+"\n";
    }
    if(!dateFound && line.startsWith("Date: ")) {
      dateFound = 1;
      date = line.substring(6, 22);
      h = line.substring(23, 25).toInt();
      m = line.substring(26, 28).toInt();
      s = line.substring(29, 31).toInt();
      localMillisAtUpdate = millis();
      localEpoc = (h * 60 * 60 + m * 60 + s);
    }
  }
  client.stop();

  DynamicJsonBuffer jsonBuf;
  JsonObject &root = jsonBuf.parseObject(buf);
  if (!root.success()) {
        P.setFont(0, BigFontBottom);
        P.setFont(1, BigFontUp);
    Serial.println("parseObject() failed");
    P.displayText("JSon Error", PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
    P.synchZoneStart();
    delay(10);
    return -1;
  }
  subscriberCount = root["items"]["statistics"]["subscriberCount"];
  return 0;
}



This only error that shows in the code :

Code: [Select]
Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200"

Build options changed, rebuilding all
C:\Users\Yoshiaki\Desktop\teste2zonasv2\teste2zonasv2.ino: In function 'void loop()':

teste2zonasv2:70: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]

   P.displayZoneText(0, "Inscritos" + subscriberCount, PA_CENTER, 30, 0, PA_PRINT, PA_NO_EFFECT);

                                    ^

In file included from C:\Users\Yoshiaki\Desktop\teste2zonasv2\teste2zonasv2.ino:2:0:

C:\Users\Yoshiaki\Documents\Arduino\libraries\MD_Parola-master\src/MD_Parola.h:1322:8: error:   initializing argument 2 of 'void MD_Parola::displayZoneText(uint8_t, char*, textPosition_t, uint16_t, uint16_t, textEffect_t, textEffect_t)' [-fpermissive]

   void displayZoneText(uint8_t z, char *pText, textPosition_t align, uint16_t speed, uint16_t pause, textEffect_t effectIn, textEffect_t effectOut = PA_NO_EFFECT);



subscriberCount its a number in getYTData .

marco_c

What type is the result of a string added to a long?
Code: [Select]
"Inscritos" + subscriberCount
The compiler is already pointing to this as the cause of the error ...
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Rodrigo Yoshiaki

#1331
Jul 22, 2018, 06:55 pm Last Edit: Jul 22, 2018, 06:56 pm by Rodrigo Yoshiaki
What type is the result of a string added to a long?
Code: [Select]
"Inscritos" + subscriberCount
The compiler is already pointing to this as the cause of the error ...
The string is a number in this case I dont know about the error.

You can find here
Code: [Select]


  DynamicJsonBuffer jsonBuf;
  JsonObject &root = jsonBuf.parseObject(buf);
  if (!root.success()) {
        P.setFont(0, BigFontBottom);
        P.setFont(1, BigFontUp);
    Serial.println("parseObject() failed");
    P.displayText("JSon Error", PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
    P.synchZoneStart();
    delay(10);
    return -1;
  }
  subscriberCount = root["items"]["statistics"]["subscriberCount"];
  return 0;
}


and the error in this line

Code: [Select]

 P.displayZoneText(1, "Inscritos : %08d " ,subscriberCount, PA_CENTER, 30, 0, PA_PRINT, PA_NO_EFFECT);


I tried follow a example but, i didn't find something simillar.

 P.displayZoneText(ZONE, TEXT ,in char, PA_CENTER, 30, 0, PA_PRINT, PA_NO_EFFECT);

Rodrigo Yoshiaki

A question, can i use parola library in other hardware ?

example :
 
Module matrix led 32*8

marco_c

Please make the best use of the information you already have available to you. This is the documentation for the library https://majicdesigns.github.io/MD_MAX72XX/ and there is a copy in your library folder as well. Read it.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

memet05

what you have done is awesome marco_c.....
i'm new in arduino and i use arduino nano.
i have try your library example and it's work fine but when i try to add some library(ds1307) for one or two hour its become freeze. some thing is wrong.
here is my sketch:

// 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>
#include <Wire.h>
#include <TimeLib.h>
#include <DS1307RTC.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::GENERIC_HW
#define MAX_DEVICES 4
#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);

char buff[4];           //8]; ///< This is the buffer for the string the sprintf outputs to

byte men;
byte m=0;
byte ja;
byte a;
byte c;
byte tkn= 9 ;


textEffect_t  effect[] =
{
  PA_PRINT,
  PA_SCAN_HORIZ,
  PA_SCROLL_LEFT,
  PA_WIPE,
  PA_SCROLL_UP_LEFT,
  PA_SCROLL_UP,
  PA_OPENING_CURSOR,
  PA_GROW_UP,
  PA_MESH,
  PA_SCROLL_UP_RIGHT,
  PA_BLINDS,
  PA_CLOSING,
  PA_RANDOM,
  PA_GROW_DOWN,
  PA_SCAN_VERT,
  PA_SCROLL_DOWN_LEFT,
  PA_WIPE_CURSOR,
  PA_DISSOLVE,
  PA_OPENING,
  PA_CLOSING_CURSOR,
  PA_SCROLL_DOWN_RIGHT,
  PA_SCROLL_RIGHT,
  PA_SLICE,
  PA_SCROLL_DOWN,
};

void setup(void)
{
  Wire.begin();
  P.begin();
  P.setIntensity(1);
  P.setInvert(false);
  P.displayText("Salam", PA_CENTER, 30, 500, PA_PRINT, PA_CLOSING);
 
  pinMode(tkn,INPUT);
  digitalWrite(tkn,HIGH);
}

void loop(void)
{
  tmElements_t tm;
  RTC.read(tm);
  men = tm.Minute;
  ja= tm.Hour;

  if (digitalRead(tkn)==LOW) {
    tm.Minute = men-1;
    RTC.write(tm);
    delay(200);
  }

  if (m != men){
    m=men;
    sprintf(buff, "%02d:%02d", ja, men);      //, det); ///< This has 2 2-digit integers with lead
  }
 
  c=c+1;                                              //change animasi
 
  if (P.displayAnimate()) {                           // animates and returns true when an animation is completed
      if (a==0){                                      //animasi clock
        a=a+1;
        P.setTextBuffer(buff);
        P.setTextAlignment(PA_CENTER);
        P.setPause(2000);
        P.setTextEffect(effect[c], effect[c]);        //(PA_SCROLL_LEFT, PA_SCROLL_UP);
        P.displayReset();
      }
      else if (a==1){                                                   //animasi text
        a=a+1;
        P.setTextBuffer("Muhammad Kahfi Balamantra");    //the text is my son name
        P.setPause(30);
        P.setTextEffect(PA_SCROLL_LEFT, PA_SCROLL_LEFT); 
        P.displayReset();
      }
      else if (a>1){
        /*
         * 
         */
        a=0;   
      }
  }

  if(c>23){
      c=0;
  }
   
}



best regard,

Go Up