Last active
July 18, 2020 14:21
-
-
Save Franck1333/e03be832d9b90510ba988100c5b67b83 to your computer and use it in GitHub Desktop.
That's how to use a 8*8 regular Matrix with the MAX7219 chip on Arduino boards.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Basic example code for MAX7219 LED dot matrix display with Arduino. More info: https://www.makerguides.com */ | |
//AIDE: https://www.makerguides.com/max7219-led-dot-matrix-display-arduino-tutorial/ | |
//AIDE {Sprite Generator}: https://gurgleapps.com/tools/matrix | |
//AIDE {Sprite Generator}: https://amperka.github.io/led-matrix-editor/ | |
//-----LIB_MATRICE----- | |
// Include the required Arduino libraries: | |
// Declaration des libs necessaires | |
#include <MD_Parola.h> | |
#include <MD_MAX72xx.h> | |
#include <SPI.h> | |
//-----LIB_MATRICE----- | |
//-----CONFIGURATION_MATRICE----- | |
// Define hardware type, size, and output pins: | |
// Declaration des infos de la matrice (Type,taille,Pins) | |
#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW | |
#define MAX_DEVICES 1 | |
#define CS_PIN 11 | |
// Setup for software SPI: | |
// Declaration specifique au protocole SPI | |
#define DATA_PIN 10 | |
#define CLK_PIN 12 | |
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES); | |
//-----CONFIGURATION_MATRICE----- | |
//---SPRITE--- | |
//Bitmap | |
const uint8_t F_WALKER = 5; // F mean Frame, number of Frame | |
const uint8_t W_WALKER = 7; // W mean Width, number of data | |
const uint8_t PROGMEM walker[F_WALKER * W_WALKER] = // walking man | |
{ | |
0x00, 0x48, 0x77, 0x1f, 0x1c, 0x94, 0x68, | |
0x00, 0x90, 0xee, 0x3e, 0x38, 0x28, 0xd0, | |
0x00, 0x00, 0xae, 0xfe, 0x38, 0x28, 0x40, | |
0x00, 0x00, 0x2e, 0xbe, 0xf8, 0x00, 0x00, | |
0x00, 0x10, 0x6e, 0x3e, 0xb8, 0xe8, 0x00, | |
}; | |
const uint8_t F_Arbre = 1; // F mean Frame, number of Frame | |
const uint8_t W_Arbre = 8; // W mean Width, number of data | |
const uint8_t PROGMEM Arbre[F_Arbre * W_Arbre] = | |
{ | |
0x18,0x18,0x3c,0x3c,0x7e,0xff,0x18,0x18 | |
}; | |
const uint8_t F_test = 1; // F mean Frame, number of Frame | |
const uint8_t W_test = 8; // W mean Width, number of data | |
const uint8_t PROGMEM test[F_test * W_test] = | |
{ | |
0x00,0xff,0xff,0xbd,0x99,0x81,0xff,0x00 | |
}; | |
const uint8_t F_Boisson = 5; // F mean Frame, number of Frame | |
const uint8_t W_Boisson = 8; // W mean Width, number of data | |
const uint8_t PROGMEM Boisson[F_Boisson * W_Boisson] = // Ma Boisson | |
{ | |
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff, | |
0x81, 0x81, 0x81, 0x81, 0x81, 0xbd, 0x81, 0xff, | |
0x81, 0x81, 0x81, 0xbd, 0x81, 0xbd, 0x81, 0xff, | |
0x81, 0xbd, 0x81, 0xbd, 0x81, 0xbd, 0x81, 0xff, | |
0x99, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xff | |
}; | |
//---SPRITE--- | |
void setup() { | |
myDisplay.begin(); // Initialisation de l'objet "MD_Parola" | |
myDisplay.setIntensity(0); // Indication de l'intensité des LEDs (0-15) | |
myDisplay.displayClear(); // Nettoyage de l'ecran | |
//Affichage_Matrice_Texte_Scrolling(); // Lancement d'un texte qui défile | |
Affichage_Sprite(); // Lancement d'un dessin animé | |
} | |
void loop() { | |
Outil_Refresh_Annimation(); // Outil permettant l'actualisation des dessins lancé | |
//Affichage_Matrice_Texte(); // Lancement de textes définit | |
} | |
void Affichage_Matrice_Texte(void){ | |
myDisplay.setTextAlignment(PA_CENTER); // Positionnement du texte au centre | |
myDisplay.print("1"); // Valeurs a afficher | |
delay(2000); // Petit delay | |
myDisplay.setTextAlignment(PA_LEFT); // Positionnement du texte a gauche | |
myDisplay.print("2"); | |
delay(2000); | |
myDisplay.setTextAlignment(PA_RIGHT); // Positionnement du text a droite | |
myDisplay.print("3"); | |
delay(2000); | |
myDisplay.setTextAlignment(PA_CENTER); // Positionnement du texte au centre | |
myDisplay.setInvert(true); // Remplissage de la zone non utilisé | |
myDisplay.print("4"); | |
delay(2000); | |
myDisplay.setInvert(false); // Aucun remplissage de la Zone non utilisé | |
myDisplay.print("I"); | |
delay(2000); | |
} | |
void Affichage_Matrice_Texte_Scrolling(void){ | |
myDisplay.displayClear(); | |
myDisplay.displayText("Love", PA_CENTER, 100, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT); | |
} | |
void Affichage_Sprite(void){ | |
//Fonction permettant l'affichage d'un dessin animé | |
myDisplay.displayClear(); // Methode permettant de nettoyer l'ecran | |
myDisplay.setSpriteData(Boisson, W_Boisson, F_Boisson, Boisson, W_Boisson, F_Boisson); // Methode permettant de selectionner le dessin a afficher et saisir ses specs // setSpriteData(inData, inWidth, inFrames, outData, outWidth, outFrames) | |
myDisplay.displayText("", PA_CENTER, 450, 1000,PA_SPRITE, PA_NO_EFFECT); // Methode permettant l'affichage du dessin animé //https://majicdesigns.github.io/MD_Parola/class_m_d___parola.html#a53b4c922a283ce2304a91e970e56c45d | |
//myDisplay.displayText("U", PA_CENTER, 50, 1000,PA_SPRITE, PA_SCROLL_UP); // Methode permettant l'affichage du dessin animé //https://majicdesigns.github.io/MD_Parola/class_m_d___parola.html#a53b4c922a283ce2304a91e970e56c45d | |
} | |
void Outil_Refresh_Annimation(void){ | |
//Pour les animations (Scrollin,Sprite,etc...): | |
//On verfie qu'une animation est lancée et une fois que c'est terminer on lance un RESET de l'ecran. | |
if (myDisplay.displayAnimate()) { | |
myDisplay.displayReset(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment