Contatore Iscritti Youtube con display a matrice

salve a tutti sto realizzato un progetto con cui posso visualizzare su un display a matrice pilotato da un max7219, premetto che avevo già realizzato un progetto simile ma con display a 7 segmenti, ma ho dovuto rifarlo per questo nuovo display. il file modello lo ho trovato in rete e ho cercato di adattarlo alle mie necessita vi posto il codice:

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

// YT api
#include <YoutubeApi.h>
#define API_YT_REFRESH  5000       //Lettura ogni 5 secondi
#define API_KEY ""                 //Api Key Canale
#define CHANNEL_ID ""              //ID Canale YouTube

// Openweathermap
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>

// Drive Display
#include "max7219.h"

// Numero di display
#define NUM_MAX       4

// MAX7219 Matrice
#define DIN 2         //D4 of WeMos
#define LOAD  0    //D3 of WeMos
#define CLK 4           //D2 of WeMos

// Buzzer
int buzzer = 15;                  //D8 of WeMos

// Display mode
#define YTSUBS     11

// CREDENZIALI d'accesso
// Wi-Fi credenziali
const char ssid[] = "";        //   SSID WIFI
const char pass[] = "";       // Password WIFI

// Inizializzazione wifi, MAX7219
WiFiUDP Udp;
WiFiClientSecure client;
YoutubeApi YTApi(API_KEY, client);

// Creazione Classe Display Max7219
MAX7219 max7219(NUM_MAX, DIN, LOAD, CLK);

// YT
long YTSubs = 0;
long api_lasttime;

// YT Iscritti divisi in singole cifre per mostrarli con un font
int  YTSubs_unita;
int  YTSubs_decine;
int  YTSubs_centinaia;
int  YTSubs_migliaia;
int  YTSubs_dmigliaia;

// Aggiorna il conteggio degli iscritti
void UpdateSubs();

// Cosa scrivere sul display
int ascii2int(char *buf);
void render(int displayMode);
void stringSub();
void autoDisp();
void showYTSubs();

void setup() {}
  max7219.initMAX7219();
  max7219.clr();
  max7219.refreshAll();
  max7219.sendCmdAll(CMD_SHUTDOWN, 1);
  max7219.sendCmdAll(CMD_INTENSITY, 0);
  max7219.showString(0, (char*)"WiFi...");
  max7219.refreshAll();

  Udp.begin(localPort);
    setSyncProvider(updateNtpTime);
  setSyncInterval(UPDATE_NTP);
  max7219.clr();
  max7219.refreshAll();
  while (now() != prevTimeData) {
    prevTimeData = now();
    max7219.showString(0, (char*)"Clock...");
    max7219.refreshAll();
    delay(100);
  }
}

// Aggiorno iscritti YouTube
void UpdateSubs() {
  if (millis() > api_lasttime + API_YT_REFRESH)  {
    if (YTApi.getChannelStatistics(CHANNEL_ID)) {
      YTSubs = YTApi.channelStats.subscriberCount;
    }
    api_lasttime = millis();
  }
}

#ifdef DEBUG_SERIAL
  Serial.println("No NTP Response :-(");
#endif

  return 0; // return 0 if unable to get the time
}

// chiama le funzioni corrispondenti per mostrare i vari dati sui display
void render(int displayMode) {
  switch (displayMode) {
    case YTSUBS:        showYTSubs();     break;
    default:            showYTSubs();     break;
  }
}

// Funzioni per mostrare del contenuto sul display
// Stringa prima degli iscritti di YouTube
void stringSub() {
  String str = "YTSubs";
  max7219.showString(0, (char*)str.c_str());
}

// Convertire un char in int
int ascii2int(char *buf) {
  return (buf[0] & 0xf) * 10 + (buf[1] & 0x0f);
}

// mostra gli iscritti di YouTube
void showYTSubs() {
  UpdateSubs();
  
  YTSubs_dmigliaia = YTSubs / 10000;
  YTSubs_migliaia = (YTSubs - (YTSubs_dmigliaia * 10000)) / 1000;
  YTSubs_centinaia = (YTSubs - (YTSubs_dmigliaia * 10000) - (YTSubs_migliaia * 1000) ) / 100;
  YTSubs_decine = (YTSubs - (YTSubs_dmigliaia * 10000) - (YTSubs_migliaia * 1000) - (YTSubs_centinaia * 100) ) / 10;
  YTSubs_unita = YTSubs % 10;
  
  max7219.showDigit(YTSubs_dmigliaia, 1, dig5x8rn);
  max7219.showDigit(YTSubs_migliaia, 7, dig5x8rn);
  max7219.showDigit(YTSubs_centinaia, 13, dig5x8rn);
  max7219.showDigit(YTSubs_decine, 19, dig5x8rn);
  max7219.showDigit(YTSubs_unita, 25, dig5x8rn);
}

quando lo compilo mi da questo errore:
Arduino:1.8.12, Scheda:"WeMos D1 R1, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

Contatore_Visite:67:3: error: 'max7219' does not name a type

max7219.initMAX7219();

^

Contatore_Visite:68:3: error: 'max7219' does not name a type

max7219.clr();

^

Contatore_Visite:69:3: error: 'max7219' does not name a type

max7219.refreshAll();

^

Contatore_Visite:70:3: error: 'max7219' does not name a type

max7219.sendCmdAll(CMD_SHUTDOWN, 1);

^

Contatore_Visite:71:3: error: 'max7219' does not name a type

max7219.sendCmdAll(CMD_INTENSITY, 0);

^

Contatore_Visite:72:3: error: 'max7219' does not name a type

max7219.showString(0, (char*)"WiFi...");

^

Contatore_Visite:73:3: error: 'max7219' does not name a type

max7219.refreshAll();

^

Contatore_Visite:75:3: error: 'Udp' does not name a type

Udp.begin(localPort);

^

Contatore_Visite:76:20: error: expected constructor, destructor, or type conversion before '(' token

setSyncProvider(updateNtpTime);

^

Contatore_Visite:77:18: error: expected constructor, destructor, or type conversion before '(' token

setSyncInterval(UPDATE_NTP);

^

Contatore_Visite:78:3: error: 'max7219' does not name a type

max7219.clr();

^

Contatore_Visite:79:3: error: 'max7219' does not name a type

max7219.refreshAll();

^

Contatore_Visite:80:3: error: expected unqualified-id before 'while'

while (now() != prevTimeData) {

^

Contatore_Visite:86:1: error: expected declaration before '}' token

}

^

exit status 1
'max7219' does not name a type

Ciao, ho dato un'occhiata veloce guarda void setup() {} cambia con void setup() {

C'è anche un return 0 dopo la #ifdef che sembra fuori dalla funzione.
E non riesco a trovare la loop()

genovese64:
Ciao, ho dato un'occhiata veloce guarda void setup() {} cambia con void setup() {

avevi visto giusto!

ma per amplificare il mio progetto sto usando ESP Matrix, funziona bene perchè sono riuscito ad attivare il mio display a matrice ma non riesco a capire perchè non riesco a comunicare con il WIFI ESP, mi ha dato il segnale una sola volta mica si è rotto?

Ho rifatto il codice adesso mi da questo errore:
Arduino:1.8.12, Scheda:"WeMos D1 R1, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

D:\Documenti\Elettronica\Schemi\Arduino\Contatore di iscritti Youtube\Programma\ESP_LEDMatrix_YT_subs_apiv3_cleaned\ESP_LEDMatrix_YT_subs_apiv3_cleaned.ino: In function 'void updateTime()':

ESP_LEDMatrix_YT_subs_apiv3_cleaned:335:62: error: invalid operands of types 'double' and 'long int' to binary 'operator%'

long epoch = round(curEpoch + 3600 * utcOffset + 86400L) % 86400L;
^

exit status 1
invalid operands of types 'double' and 'long int' to binary 'operator%'

Questa è la riga a cui fa riferimento:

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;
}