Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed APDS_9960 mbed-rtos
Diff: src/cMatrice.cpp
- Revision:
- 4:b7a46af55574
- Parent:
- 3:493dd1cf30a4
- Child:
- 5:d6b0bf27bac6
diff -r 493dd1cf30a4 -r b7a46af55574 src/cMatrice.cpp
--- a/src/cMatrice.cpp Wed Mar 30 10:22:07 2016 +0000
+++ b/src/cMatrice.cpp Thu Mar 31 11:18:41 2016 +0000
@@ -44,7 +44,7 @@
{
DigitalOut cs(p14);
SPI matrice(p11,p12,p13);
- _matrice[5][2] = COULEUR_LED_ORANGE;
+ _matrice[0][0] = COULEUR_LED_ORANGE;
cs = 0;
wait(0.5);
@@ -59,5 +59,44 @@
wait(0.5);
cs = 1;
}
+// Paramètres:
+// f: Forme à afficher
+// c: Couleur
+void cMatrice::afficherForme(cForme &f, unsigned char c){
+// Changement de couleur des Leds
+ for(unsigned char i = 0; i < 4 ; i++){
+ f.getLed(i).allumer(c);
+ _matrice[f.getLed(i).getPositionX()][f.getLed(i).getPositionY()] = c;//f.getLed(i).getCouleur();
+ Serial pc(USBTX, USBRX); //tx, rx
+ pc.printf("x: %d, y: %d\n", f.getLed(i).getPositionX(), f.getLed(i).getPositionY());
+ }
+}
+
+void cMatrice::ajouterForme(cForme & f){
+ _formes.insert(_formes.begin(), f);
+ afficherForme(f, COULEUR_LED_ROUGE);
+}
+
+void cMatrice::supprimerForme(cForme & f){
+ _formes.push_back(f);
+}
+
+// Description:
+// Nettoyage de la matrice, passage à 0 de la valeur de chaque Led
+void cMatrice::clear(){
+ DigitalOut cs(p14);
+ SPI matrice(p11,p12,p13);
+ cs = 0;
+
+ for(char i=0; i<8; i++)
+ {
+ for(char j=0; j<8; j++)
+ {
+ _matrice[i][j] = COULEUR_LED_NOIR;
+ matrice.write(_matrice[i][j]);
+ }
+ }
+ cs = 1;
+}