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:
- 9:6f3d8b714a59
- Parent:
- 8:92d0c4961a16
- Child:
- 10:9ef3f520ff6c
--- a/src/cMatrice.cpp Wed Apr 06 15:41:24 2016 +0000 +++ b/src/cMatrice.cpp Wed Apr 06 21:53:55 2016 +0000 @@ -1,83 +1,90 @@ #include "cMatrice.h" +#include <algorithm> + +// CONSTRUCTEURS -cMatrice::cMatrice() { - _matrice = new unsigned char *[8]; - for (unsigned char i = 0; i <= 7; i++) { - _matrice[i] = new unsigned char[8]; +cMatrice::cMatrice() +{ + +} +cMatrice::cMatrice(unsigned char c, unsigned char l) +{ + _lig = l; + _col = c; + _matrice = new unsigned char*[_lig]; + for(unsigned char i = 0; i < _lig; i++){ + _matrice[i] = new unsigned char[_col]; } + clear(); +} - for (unsigned char i = 0; i < 8; i++) { - for (unsigned char j = 0; j < 8; j++) { - _matrice[i][j] = LED_BLEU_FONCE; - } +// DESTRUCTEUR +cMatrice::~cMatrice() +{ + for(unsigned char i = 0; i < _lig; i++){ + delete[] _matrice[i]; + delete[] _matrice; } } -cMatrice::~cMatrice() { - for (int i = 0; i < 8; i++) - delete[] _matrice[i]; - delete[] _matrice; +// GETTER +unsigned char cMatrice::getValTab(unsigned char l, unsigned char c) +{ + return _matrice[l][c]; } -/*// GETTER - unsigned char cMatrice::getMatrice() - { +unsigned char cMatrice::getCol(){ + return _col; +} - return _matrice; - }*/ +unsigned char cMatrice::getLig(){ + return _lig; +} // SETTER -void cMatrice::updateMatrice(cForme &f) { +void cMatrice::updateMatrice(cForme &f) +{ } -// METHODES -void cMatrice::envoyerMatrice() { - DigitalOut cs(p14); - SPI matrice(p11, p12, p13); - matrice.frequency(100000); - //matrice.format(8,3); - _matrice[0][0] = LED_ORANGE; +void cMatrice::setCol(unsigned char c){ + _col = c; +} - cs = 0; - wait(0.5); +void cMatrice::setLig(unsigned char l){ + _lig = l; +} + - for (char i = 0; i < 8; i++) { - for (char j = 0; j < 8; j++) { - matrice.write(_matrice[i][j]); - } - } - wait(0.5); - cs = 1; +// METHODES +void cMatrice::envoyerMatrice() +{ + } // Paramètres: // f: Forme à afficher // c: Couleur -void cMatrice::afficherForme(cForme &f, unsigned char c) { +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; - } + for (int i = 0; i < 4; i++) { + _matrice[f.getLed(i).getPositionX()][f.getLed(i).getPositionY()] = c; + } } -void cMatrice::ajouterForme(cForme & f, unsigned char c) { - _formes.insert(_formes.begin(), f); - afficherForme(f, c); -} // Description: // Nettoyage de la matrice, passage à 0 de la valeur de chaque Led -void cMatrice::clear() { - for (char i = 0; i < 8; i++) { - for (char j = 0; j < 8; j++) { +void cMatrice::clear() +{ + for(unsigned char i = 0; i < _lig; i++){ + for(unsigned char j = 0; j < _col; j++){ _matrice[i][j] = LED_NOIR; } } + _matrice[0][0] = LED_ROUGE; } -cForme cMatrice::getForme(unsigned int i){ - return _formes.at(i); -} +