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
src/cMatrice.cpp
- Committer:
- clementdoreau
- Date:
- 2016-03-31
- Revision:
- 6:0e6c1cccb275
- Parent:
- 3:493dd1cf30a4
File content as of revision 6:0e6c1cccb275:
#include "cMatrice.h" cMatrice::cMatrice() { _matrice = new unsigned char *[8]; for(unsigned char i = 0; i <= 7; i++) { _matrice[i] = new unsigned char[8]; for(unsigned char j = 0; j < 7; j++){ _matrice[i][j] = COULEUR_LED_BLEU_FONCE; } } } cMatrice::~cMatrice() { //dtor } // GETTER unsigned char **cMatrice::getMatrice() { return _matrice; } // SETTER // METHODES void cMatrice::envoyerMatrice() { DigitalOut cs(p14); SPI matrice(p11,p12,p13); _matrice[0][0] = COULEUR_LED_ORANGE; cs = 0; wait(0.5); for(char i=0; i<8; i++) { for(char j=0; j<8; j++) { matrice.write(_matrice[i][j]); } } 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(char i = 0; i < 4 ; i++){ f.getLed()[i].allumer(c); _matrice[f.getLed()[i].getPositionY()][f.getLed()[i].getPositionX()] = f.getLed()[i].getCouleur(); } } void cMatrice::ajouterForme(cForme & f){ _formes.insert(_formes.begin(), f); afficherForme(f, COULEUR_LED_VERT); } 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; }