#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
///#define MAX_ZONES 2
const int MAX_DEVICES = 15; //nombre d'appareils dans la chaîne
const int DATA_PIN = 11, CLK_PIN = 13; // DATA PIN et CLOCK PIN Communes aux 4 matrices
// CS_PIN = CS (Chip Select) pour chaque matrice.
const int CS_PIN_M1 = 10, CS_PIN_M2 = 9, CS_PIN_M3 = 8, CS_PIN_M4 = 7; // CS (Chip Select) pour chaque matrice.
//défini les broches utilisées pour se connecter à l'Arduino
//Ayant tout cela défini, nous pouvons également déclarer le module lui-même "Matrice_1"
MD_Parola Matrice_1 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN_M1, MAX_DEVICES); // Matrice_1
MD_Parola Matrice_2 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN_M2, MAX_DEVICES); // Matrice_2
MD_Parola Matrice_3 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN_M3, MAX_DEVICES); // Matrice_3
MD_Parola Matrice_4 = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN_M4, MAX_DEVICES); // Matrice_4
static uint8_t display = 0; // Mode d'affichage actuel
int PotAlignement = A0, PotAlignementValue = 0, AlignementValue = 0;
int PotSpeed = A1, PotSpeedValue = 0, SpeedValue = 0;
int PotPause = A2, PotPauseValue = 0, PauseValue = 0;
char txtAlignement [4][10] = {"PA_LEFT", "PA_CENTER", "PA_RIGHT"};
char animations[29][18] = {"PA_NO_EFFECT",
"PA_PRINT",
"PA_SCROLL_UP",
"PA_SCROLL_DOWN",
"PA_SCROLL_LEFT",
"PA_SCROLL_RIGHT",
"PA_SPRITE",
"PA_SLICE",
"PA_MESH",
"PA_FADE",
"PA_DISSOLVE",
"PA_BLINDS",
"PA_RANDOM",
"PA_WIPE",
"PA_WIPE_CURSOR",
"PA_SCAN_HORIZ",
"PA_SCAN_HORIZX",
"PA_SCAN_VERT",
"PA_SCAN_VERTX",
"PA_OPENING",
"PA_OPENING_CURSOR",
"PA_CLOSING",
"PA_CLOSING_CURSOR",
"PA_SCROLL_UP_LEFT",
"PA_SCROLL_UP_RIGHT",
"PA_SCROLL_DOWN_LEFT",
"PA_SCROLL_DOWN_RIGHT",
"PA_GROW_UP",
"PA_GROW_DOWN"
};
char No[29][3] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28"};
char buffer[20];
void setup() {
lcd.init(); lcd.backlight();
Matrice_1.begin(); // démarrage de la matrice 1
Matrice_2.begin(); // démarrage de la matrice 2
Matrice_3.begin(); // démarrage de la matrice 3
Matrice_4.begin(); // démarrage de la matrice 4
}
void loop() {
PotAlignementValue = map(analogRead(PotAlignement), 0, 1023, 0, 100);
if (PotAlignementValue < 33) AlignementValue = 0;
if (PotAlignementValue > 33 && PotAlignementValue < 66) AlignementValue = 1;
if (PotAlignementValue > 66 && PotAlignementValue < 100) AlignementValue = 2;
SpeedValue = map(analogRead(PotSpeed), 0, 1023, 150, 0);
displayMatrice_3();
displayMatrice_2();
displayMatrice_1();
}
void displayMatrice_1() {
//displayLcd();
Matrice_1.displayAnimate();
if (Matrice_1.getZoneStatus(0)) {
Matrice_1.displayText("Message", // Texte à afficher
AlignementValue, // Alignement
SpeedValue, // Vitesse d'exécution
3000, // Pause (durée d'affichage)
display +1, // Animation en entrée
PA_SCROLL_UP); // Animation en sortie
Matrice_1.displayReset(0);
display++; if (display > 28)display = 0;
}
}
void displayMatrice_2() {
//displayLcd();
Matrice_2.displayAnimate();
if (Matrice_2.getZoneStatus(0)) {
Matrice_2.displayText(txtAlignement[AlignementValue], // Texte à afficher
PA_CENTER, // Alignement
0, // Vitesse d'excution
0, // Pause (durée d'affichage)
PA_PRINT, // Animation en entrée
PA_NO_EFFECT); // Animation en sortie
Matrice_2.displayReset(0);
}
}
void displayMatrice_3() {
Matrice_3.displayAnimate();
if (Matrice_3.getZoneStatus(0)) {
Matrice_3.displayText(animations[display], // Texte à afficher
PA_CENTER, // Alignement
0, // Vitesse d'excution
0, // Pause (durée d'affichage)
PA_PRINT, // Animation en entrée
PA_NO_EFFECT); // Animation en sortie
Matrice_3.displayReset(0);
}
}
void displayLcd() {
sprintf(buffer, "PotValue: %3d", PotAlignementValue);
lcd.setCursor(0, 0); lcd.print(buffer);
sprintf(buffer, "Alignement: %1d", AlignementValue);
lcd.setCursor(0, 1); lcd.print(buffer);
sprintf(buffer, ">>> %s ", txtAlignement[AlignementValue]);
lcd.setCursor(0, 2); lcd.print(buffer);
sprintf(buffer, "Speed: %d dis: %d ", SpeedValue, display - 1);
lcd.setCursor(0, 3); lcd.print(buffer);
}
Matrice_1
Matrice_2
Matrice_3
Matrice_4
|<--- Droite ---> |
|<-- GAUCHE -->|
|<-- CENTRE --> |