#include <MD_Parola.h> // inclure la bibliothèque MajicDesigns Parola
#include <MD_MAX72xx.h> // inclure la bibliothèque de matrices LED MajicDesigns MAX72xx
#include <SPI.h> // inclure la bibliothèque Arduino SPI
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
const int DATA_PIN = 11, CLK_PIN = 13; // DATA PIN et CLOCK PIN Communes aux 4 matrices
const int CS_PIN_M1 = 10, CS_PIN_M2 = 9, CS_PIN_M3 = 8, CS_PIN_M4 = 7; // CS (Chip Select) pour chaque matrice.
const int MAX_DEVICES = 16; //nombre d'appareils que nous avons dans la chaîne et l'interface matérielle
// MATÉRIEL SPI
MD_Parola Matrice_1 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN_M1, MAX_DEVICES); // top
MD_Parola Matrice_2 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN_M2, MAX_DEVICES); // 2e
MD_Parola Matrice_3 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN_M3, MAX_DEVICES); // 3e
MD_Parola Matrice_4 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN_M4, MAX_DEVICES); // 4e
/*
// LOGICIEL SPI
uint8_t scrollSpeed = 25; // définir la vitesse de défilement initiale, peut être une valeur comprise entre 10 (max) et 150 (min)
textEffect_t scrollEffect = PA_SCROLL_LEFT; // sens de défilement, de droite à gauche
textPosition_t scrollAlign = PA_CENTER; // alignement du défilement LEFT CENTER RIGHT
uint16_t scrollPause = 5000; // pause de défilement en millisecondes
*/
// Tampons de messages globaux partagés par les fonctions série et de défilement
#define BUF_SIZE 75 // longeur du tampon
char curMessage[BUF_SIZE] = { "" };
char newMessage1[BUF_SIZE] = { "Cipad 60e Edition" };
char newMessage2[BUF_SIZE] = { "Matrice de points max7219" };
char newMessage3[BUF_SIZE] = { "Calendrier" };
char newMessage4[BUF_SIZE] = { "Horloge" };
char newMessage5[BUF_SIZE] = { "Tempetature & Humidity" };
static uint8_t display = 0; // Mode d'affichage actuel
void setup() {
Matrice_1.begin(); Matrice_2.begin();
Matrice_3.begin(); Matrice_4.begin();
lcd.init(); lcd.backlight();
//Matrice_1.getZoneStatus(0);
//Matrice_2.getZoneStatus(0);
//Matrice_3.getZoneStatus(0);
// Matrice_4.getZoneStatus(0);
//Matrice_1.displayText(newMessage1, PA_CENTER, 25, 5000, PA_SCROLL_UP, PA_SCROLL_DOWN);
// Matrice_2.displayText(newMessage3, PA_CENTER, 25, 5000, PA_SCROLL_UP, PA_SCROLL_DOWN);
// Matrice_3.displayText(newMessage4, PA_CENTER, 25, 5000, PA_SCROLL_UP, PA_SCROLL_DOWN);
// Matrice_4.displayText(newMessage5, PA_CENTER, 25, 5000, PA_SCROLL_UP, PA_SCROLL_DOWN);
}
void loop() {
/*
Matrice_1.displayText(newMessage1, PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
Matrice_2.displayText("Effect in: SCROLL_UP", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
Matrice_3.displayText("Effect OUT: SCROLL_UP", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
Matrice_4.displayText("Txt alignement: CENTER", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
if (Matrice_1.displayAnimate()) Matrice_1.displayReset(0);
if (Matrice_2.displayAnimate()) Matrice_2.displayReset(0);
if (Matrice_3.displayAnimate()) Matrice_3.displayReset(0);
if (Matrice_4.displayAnimate()) Matrice_4.displayReset(0);
*/
lcd.setCursor(0, 0); lcd.print(display);
Matrice_1.displayAnimate(); Matrice_2.displayAnimate();
Matrice_3.displayAnimate(); Matrice_4.displayAnimate();
// if (Matrice_1.getZoneStatus(0) && Matrice_2.getZoneStatus(0) && Matrice_3.getZoneStatus(0) && Matrice_4.getZoneStatus(0))
if (Matrice_1.getZoneStatus(0) && Matrice_2.getZoneStatus(0) && Matrice_3.getZoneStatus(0) && Matrice_4.getZoneStatus(0)) {
switch (display) {
case 0:
//Matrice_1.displayAnimate(); Matrice_2.displayAnimate();
//Matrice_3.displayAnimate(); Matrice_4.displayAnimate();
//Matrice_1.setTextEffect(0, PA_SCROLL_UP, PA_SCROLL_UP);
Matrice_1.displayText(newMessage1, PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
Matrice_2.displayText("Effect in: SCROLL_UP", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
Matrice_3.displayText("Effect OUT: SCROLL_UP", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
Matrice_4.displayText("Txt alignement: CENTER", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_UP);
display++;
break;
case 1:
// Matrice_1.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_UP);
//Matrice_1.displayText(newMessage1, PA_CENTER, 25, 3000, PA_SCROLL_LEFT, PA_SCROLL_UP);
Matrice_1.displayText(newMessage2, PA_RIGHT, 5, 3000, PA_SCROLL_LEFT, PA_SCROLL_UP);
Matrice_2.displayText("Effect IN: SCROLL_LEFT", PA_RIGHT, 25, 3000, PA_SCROLL_LEFT, PA_SCROLL_UP);
Matrice_3.displayText("Effect OUT: SCROLL_UP", PA_RIGHT, 25, 3000, PA_SCROLL_LEFT, PA_SCROLL_UP);
Matrice_4.displayText("Txt alignement: RIGHT", PA_RIGHT, 25, 10000, PA_SCROLL_UP, PA_SCROLL_DOWN);
display++;
break;
case 2:
//Matrice_1.setTextEffect(0, PA_SCROLL_RIGHT, PA_SCROLL_UP);
Matrice_1.displayText(newMessage1, PA_LEFT, 5, 3000, PA_SCROLL_RIGHT, PA_SCROLL_UP);
Matrice_2.displayText("Effect IN:, SCROLL_RIGHT", PA_LEFT, 25, 3000, PA_SCROLL_RIGHT, PA_SCROLL_UP);
Matrice_3.displayText("Effect OUT:, SCROLL_UP", PA_LEFT, 25, 3000, PA_SCROLL_RIGHT, PA_SCROLL_UP);
Matrice_4.displayText("Txt alignement: LEFT", PA_LEFT, 25, 10000, PA_SCROLL_UP, PA_SCROLL_DOWN);
display++;
break;
case 3:
//displayText(const char *pText, textPosition_t align, speed, pause, textEffect_t effectIn, textEffect_t effectOut = PA_NO_EFFECT)
Matrice_1.displayText(newMessage2, PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
Matrice_2.displayText("Effect IN:, SCROLL_UP", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
Matrice_3.displayText("Effect OUT:, SCROLL_DOWN", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
Matrice_4.displayText("Txt alignement: CENTER", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
display++;
break;
case 4:
Matrice_1.displayText(newMessage2, PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
Matrice_2.displayText("Effect IN:, SCROLL_UP", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
Matrice_3.displayText("Effect OUT:, SCROLL_DOWN", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
Matrice_4.displayText("Txt alignement: CENTER", PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
display++;
break;
/*case 5:
Matrice_1.displayText(newMessage2, PA_CENTER, 25, 3000, PA_SCROLL_UP, PA_SCROLL_DOWN);
Matrice_2.displayText("Effect IN:, SCROLL_LEFT", PA_CENTER, 25, 3000, PA_SCROLL_LEFT, PA_SCROLL_DOWN);
Matrice_3.displayText("Effect OUT:, SCROLL_RIGHT", PA_CENTER, 25, 3000, PA_SCROLL_RIGHT, PA_SCROLL_LEFT);
Matrice_4.displayText("Txt alignement: CENTER", PA_CENTER, 25, 3000, PA_SCROLL_DOWN, PA_SCROLL_UP);
display++;
break;
*/
default:
// menu();
display = 0;
break;
}
lcd.setCursor(0, 0); lcd.print(display);
Matrice_1.displayReset(0); //top
Matrice_2.displayReset(0);
Matrice_3.displayReset(0);
Matrice_4.displayReset(0);
}
}