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@9:6f3d8b714a59, 2016-04-06 (annotated)
- Committer:
- Willheisen
- Date:
- Wed Apr 06 21:53:55 2016 +0000
- Revision:
- 9:6f3d8b714a59
- Parent:
- 8:92d0c4961a16
- Child:
- 10:9ef3f520ff6c
rotationHoraire pour le L; m?thodes d?placements Bas, Gauche, Droite; ;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
clementdoreau | 1:ab5f440f4156 | 1 | #include "cMatrice.h" |
Willheisen | 9:6f3d8b714a59 | 2 | #include <algorithm> |
Willheisen | 9:6f3d8b714a59 | 3 | |
Willheisen | 9:6f3d8b714a59 | 4 | // CONSTRUCTEURS |
clementdoreau | 1:ab5f440f4156 | 5 | |
Willheisen | 9:6f3d8b714a59 | 6 | cMatrice::cMatrice() |
Willheisen | 9:6f3d8b714a59 | 7 | { |
Willheisen | 9:6f3d8b714a59 | 8 | |
Willheisen | 9:6f3d8b714a59 | 9 | } |
clementdoreau | 1:ab5f440f4156 | 10 | |
Willheisen | 9:6f3d8b714a59 | 11 | cMatrice::cMatrice(unsigned char c, unsigned char l) |
Willheisen | 9:6f3d8b714a59 | 12 | { |
Willheisen | 9:6f3d8b714a59 | 13 | _lig = l; |
Willheisen | 9:6f3d8b714a59 | 14 | _col = c; |
Willheisen | 9:6f3d8b714a59 | 15 | _matrice = new unsigned char*[_lig]; |
Willheisen | 9:6f3d8b714a59 | 16 | for(unsigned char i = 0; i < _lig; i++){ |
Willheisen | 9:6f3d8b714a59 | 17 | _matrice[i] = new unsigned char[_col]; |
clementdoreau | 7:4b283e36b147 | 18 | } |
Willheisen | 9:6f3d8b714a59 | 19 | clear(); |
Willheisen | 9:6f3d8b714a59 | 20 | } |
clementdoreau | 1:ab5f440f4156 | 21 | |
Willheisen | 9:6f3d8b714a59 | 22 | // DESTRUCTEUR |
Willheisen | 9:6f3d8b714a59 | 23 | cMatrice::~cMatrice() |
Willheisen | 9:6f3d8b714a59 | 24 | { |
Willheisen | 9:6f3d8b714a59 | 25 | for(unsigned char i = 0; i < _lig; i++){ |
Willheisen | 9:6f3d8b714a59 | 26 | delete[] _matrice[i]; |
Willheisen | 9:6f3d8b714a59 | 27 | delete[] _matrice; |
clementdoreau | 7:4b283e36b147 | 28 | } |
clementdoreau | 1:ab5f440f4156 | 29 | } |
clementdoreau | 1:ab5f440f4156 | 30 | |
Willheisen | 9:6f3d8b714a59 | 31 | // GETTER |
Willheisen | 9:6f3d8b714a59 | 32 | unsigned char cMatrice::getValTab(unsigned char l, unsigned char c) |
Willheisen | 9:6f3d8b714a59 | 33 | { |
Willheisen | 9:6f3d8b714a59 | 34 | return _matrice[l][c]; |
clementdoreau | 1:ab5f440f4156 | 35 | } |
clementdoreau | 1:ab5f440f4156 | 36 | |
Willheisen | 9:6f3d8b714a59 | 37 | unsigned char cMatrice::getCol(){ |
Willheisen | 9:6f3d8b714a59 | 38 | return _col; |
Willheisen | 9:6f3d8b714a59 | 39 | } |
clementdoreau | 1:ab5f440f4156 | 40 | |
Willheisen | 9:6f3d8b714a59 | 41 | unsigned char cMatrice::getLig(){ |
Willheisen | 9:6f3d8b714a59 | 42 | return _lig; |
Willheisen | 9:6f3d8b714a59 | 43 | } |
Willheisen | 3:493dd1cf30a4 | 44 | |
clementdoreau | 1:ab5f440f4156 | 45 | // SETTER |
Willheisen | 9:6f3d8b714a59 | 46 | void cMatrice::updateMatrice(cForme &f) |
Willheisen | 9:6f3d8b714a59 | 47 | { |
clementdoreau | 1:ab5f440f4156 | 48 | |
clementdoreau | 1:ab5f440f4156 | 49 | } |
clementdoreau | 7:4b283e36b147 | 50 | |
Willheisen | 9:6f3d8b714a59 | 51 | void cMatrice::setCol(unsigned char c){ |
Willheisen | 9:6f3d8b714a59 | 52 | _col = c; |
Willheisen | 9:6f3d8b714a59 | 53 | } |
clementdoreau | 7:4b283e36b147 | 54 | |
Willheisen | 9:6f3d8b714a59 | 55 | void cMatrice::setLig(unsigned char l){ |
Willheisen | 9:6f3d8b714a59 | 56 | _lig = l; |
Willheisen | 9:6f3d8b714a59 | 57 | } |
Willheisen | 9:6f3d8b714a59 | 58 | |
clementdoreau | 7:4b283e36b147 | 59 | |
Willheisen | 9:6f3d8b714a59 | 60 | // METHODES |
Willheisen | 9:6f3d8b714a59 | 61 | void cMatrice::envoyerMatrice() |
Willheisen | 9:6f3d8b714a59 | 62 | { |
Willheisen | 9:6f3d8b714a59 | 63 | |
clementdoreau | 1:ab5f440f4156 | 64 | } |
clementdoreau | 7:4b283e36b147 | 65 | |
Willheisen | 4:b7a46af55574 | 66 | // Paramètres: |
Willheisen | 4:b7a46af55574 | 67 | // f: Forme à afficher |
Willheisen | 4:b7a46af55574 | 68 | // c: Couleur |
Willheisen | 9:6f3d8b714a59 | 69 | void cMatrice::afficherForme(cForme &f, unsigned char c) |
Willheisen | 9:6f3d8b714a59 | 70 | { |
Willheisen | 4:b7a46af55574 | 71 | // Changement de couleur des Leds |
Willheisen | 9:6f3d8b714a59 | 72 | for (int i = 0; i < 4; i++) { |
Willheisen | 9:6f3d8b714a59 | 73 | _matrice[f.getLed(i).getPositionX()][f.getLed(i).getPositionY()] = c; |
Willheisen | 9:6f3d8b714a59 | 74 | } |
Willheisen | 4:b7a46af55574 | 75 | } |
Willheisen | 4:b7a46af55574 | 76 | |
Willheisen | 4:b7a46af55574 | 77 | |
Willheisen | 4:b7a46af55574 | 78 | // Description: |
Willheisen | 4:b7a46af55574 | 79 | // Nettoyage de la matrice, passage à 0 de la valeur de chaque Led |
Willheisen | 9:6f3d8b714a59 | 80 | void cMatrice::clear() |
Willheisen | 9:6f3d8b714a59 | 81 | { |
Willheisen | 9:6f3d8b714a59 | 82 | for(unsigned char i = 0; i < _lig; i++){ |
Willheisen | 9:6f3d8b714a59 | 83 | for(unsigned char j = 0; j < _col; j++){ |
clementdoreau | 7:4b283e36b147 | 84 | _matrice[i][j] = LED_NOIR; |
clementdoreau | 7:4b283e36b147 | 85 | } |
clementdoreau | 7:4b283e36b147 | 86 | } |
Willheisen | 9:6f3d8b714a59 | 87 | _matrice[0][0] = LED_ROUGE; |
Willheisen | 4:b7a46af55574 | 88 | } |
clementdoreau | 1:ab5f440f4156 | 89 | |
Willheisen | 9:6f3d8b714a59 | 90 |