BastatDoreau / Mbed 2 deprecated MoveYourTetris

Dependencies:   mbed APDS_9960 mbed-rtos

Dependents:   MoveYourTetris_OK

Files at this revision

API Documentation at this revision

Comitter:
Willheisen
Date:
Fri Apr 22 06:29:56 2016 +0000
Parent:
31:7313366789f2
Child:
33:a6f0be429ce0
Commit message:
debuggage des matrices

Changed in this revision

include/cBoussole.h Show diff for this revision Revisions of this file
include/cCollision.h Show annotated file Show diff for this revision Revisions of this file
include/cForme.h Show annotated file Show diff for this revision Revisions of this file
include/cLed.h Show annotated file Show diff for this revision Revisions of this file
include/cMatrice.h Show annotated file Show diff for this revision Revisions of this file
include/cSPI.h Show annotated file Show diff for this revision Revisions of this file
src/cBoussole.cpp Show diff for this revision Revisions of this file
src/cEl.cpp Show annotated file Show diff for this revision Revisions of this file
src/cJeu.cpp Show annotated file Show diff for this revision Revisions of this file
src/cMatrice.cpp Show annotated file Show diff for this revision Revisions of this file
src/cSPI.cpp Show annotated file Show diff for this revision Revisions of this file
src/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/include/cBoussole.h	Thu Apr 21 13:25:08 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-#ifndef CBOUSSOLE_H
-#define CBOUSSOLE_H
-
-#include "mbed.h"
-#include <new>
-
-//-----------
-// Registers
-//-----------
-#define CONFIG_A_REG    0x00
-#define CONFIG_B_REG    0x01
-#define MODE_REG        0x02
-#define OUTPUT_REG      0x03
-#define STATUS_REG      0x09
-
-// configuration register a
-#define AVG1_SAMPLES    0x00
-#define AVG2_SAMPLES    0x20
-#define AVG4_SAMPLES    0x80
-#define AVG8_SAMPLES    0xC0
-
-#define OUTPUT_RATE_0_75    0x00
-#define OUTPUT_RATE_1_5     0x04
-#define OUTPUT_RATE_3       0x08
-#define OUTPUT_RATE_7_5     0x0C
-#define OUTPUT_RATE_15      0x10
-#define OUTPUT_RATE_30      0x14
-#define OUTPUT_RATE_75      0x18
-
-#define NORMAL_MEASUREMENT  0x00
-#define POSITIVE_BIAS       0x01
-#define NEGATIVE_BIAS       0x02
-
-// mode register
-#define CONTINUOUS_MODE     0x00
-#define SINGLE_MODE         0x01
-#define IDLE_MODE           0x02
-
-// status register
-#define STATUS_LOCK         0x02
-#define STATUS_READY        0x01
-
-class cBoussole
-{
-public:
-    static const int I2C_ADDRESS = 0x3D;
-    cBoussole();    
-    cBoussole(PinName sda, PinName scl);
-    
-    ~cBoussole();
-    unsigned char detectionMvt();
-    void init();
-    void setConfigurationA(char);
-    void setConfigurationB(char);   
-    void setMode(char);    
-    void getXYZ(int16_t raw[3]); 
-private:
-    int16_t _values[3];
-    int16_t _oldValues[3];
-    int16_t _delta[3];
-    I2C &i2c_;
-    char i2cRaw[sizeof(I2C)];
-
-};
-
-#endif //CBOUSSOLE_H
\ No newline at end of file
--- a/include/cCollision.h	Thu Apr 21 13:25:08 2016 +0000
+++ b/include/cCollision.h	Fri Apr 22 06:29:56 2016 +0000
@@ -4,24 +4,18 @@
 #include "cMatrice.h"
 #include "cForme.h"
 
-class cCollision{
-    
+// Définition de la classe cCollision
+// Classe qui gère les collisions possibles entre la pièce en cours et les pièces déjà placées
+
+class cCollision
+{
 private:
-    
-    // ATTRIBUTS
-        
 public:
-    
-    // CONSTRUCTEURS
-    
+    // CONSTRUCTEUR
     cCollision();
-        
-    // DESTRUCTEURS
-    
+    // DESTRUCTEUR
     ~cCollision();
-    
     // METHODES
-        
     bool bordDroit(cForme &);
     bool bordGauche(cForme &);
     bool bordBas(cForme &, cMatrice &);
--- a/include/cForme.h	Thu Apr 21 13:25:08 2016 +0000
+++ b/include/cForme.h	Fri Apr 22 06:29:56 2016 +0000
@@ -3,19 +3,22 @@
 
 #include "cLed.h"
 
+// Définition de la classe cForme
+// Classe qui définit les caractéristiques d'une pièce
 class cForme
 {
-
 protected:
     unsigned int _orientation; // 4 orientations : rotation de 90° --> de 1 à 4
     unsigned int _typeForme;//0=ligne, 1=carré, 2=Z, 3=T, 4=L
+    //Position actuelle du point de référence
     int _positionX;
     int _positionY;
+    //Ancienne position  du point de référence
     int _oldPositionX;
     int _oldPositionY;
-    cLed _Leds[4]; // LEDS
+    //Toute forme est composée de 4 LEDs
+    cLed _Leds[4];
 private:
-
 public:
     // CONSTRUCTEURS
     cForme();
@@ -28,7 +31,6 @@
      int getOldPositionX();
      int getOldPositionY();
     cLed &getLed(unsigned int i);
-    //////////////////////////////////////////////
     unsigned int getTypeForme();
     // SETTERS
     void setOrientation(unsigned int orientation);
@@ -36,15 +38,12 @@
     void setPositionY( int y);
     void setOldPositionX( int);
     void setOldPositionY( int);
-    //virtual void afficherForme();
-
     // METHODES
     void deplacementBas();
     void deplacementDroite();
     void deplacementGauche();
     // METHODES VIRTUELLES
     virtual void rotationHoraire();
-
 };
 
 #endif
--- a/include/cLed.h	Thu Apr 21 13:25:08 2016 +0000
+++ b/include/cLed.h	Fri Apr 22 06:29:56 2016 +0000
@@ -5,38 +5,37 @@
 #include "mbed.h"
 
 // Classe Led
-// Gestion d'une Led de la matrice de led
-
-class cLed {
-private:
-	 int _positionX;
-	 int _positionY;
-	 int _oldPositionX;
-	 int _oldPositionY;
-	unsigned int _couleur;
-public:
-	// CONSTRUCTEUR
-	cLed();
-	cLed( int x,  int y);
-	cLed( int x,  int y, unsigned int c);
-	// GETTERS
+// Gestion d'une LED de la matrice de LEDs
 
-	 int getPositionX();
-	 int getPositionY();
-	 int getOldPositionX();
-	 int getOldPositionY();
-	unsigned int getCouleur();
-
-	// SETTER
-
-	void setPositionX( int);
-	void setPositionY( int);
-	void setOldPositionX( int);
-	void setOldPositionY( int);
-	void setCouleur(unsigned int c);
-
-	// METHODES
-
+class cLed
+{
+    // ATTRIBUTS
+private:
+    //position actuelle de la LED
+    int _positionX;
+    int _positionY;
+    //ancienne position de la LED
+    int _oldPositionX;
+    int _oldPositionY;
+    //couleur de la LED
+    unsigned int _couleur;
+public:
+    // CONSTRUCTEURS
+    cLed();
+    cLed( int x, int y);
+    cLed( int x, int y, unsigned int c);
+    // GETTERS
+    int getPositionX();
+    int getPositionY();
+    int getOldPositionX();
+    int getOldPositionY();
+    unsigned int getCouleur();
+    // SETTERS
+    void setPositionX( int);
+    void setPositionY( int);
+    void setOldPositionX( int);
+    void setOldPositionY( int);
+    void setCouleur(unsigned int c);
 };
 
 #endif
--- a/include/cMatrice.h	Thu Apr 21 13:25:08 2016 +0000
+++ b/include/cMatrice.h	Fri Apr 22 06:29:56 2016 +0000
@@ -2,43 +2,32 @@
 #define CMATRICE_H
 
 #include "cForme.h"
-#include <vector>
 #include "mbed.h"
 
-// Déclaration de la classe Matrice
+// Définition de la classe cMatrice
+// Classe qui représente la matrice du jeu
 
 class cMatrice {
+// ATTRIBUTS
 private:
 	cForme * _pForme;
 	int ** _matrice;
 	int _col;
 	int _lig;
-	////////////////////////////////////////////////////////
-	// Gestion des collisions aux bords
-	////////////////////////////////////////////////////////
-/*	bool _collisionBordGauche;
-	bool _collisionBordDroit;
-	bool _collisionBordBas;
-	void controleCollisionBords();
-	////////////////////////////////////////////////////////
-	// Gestion des collisions aux pièces
-	////////////////////////////////////////////////////////
-	*/
-protected:
 public:
-// CONSTRUCTEUR
+// CONSTRUCTEURS
 	cMatrice();
 	cMatrice(int, int);
 
 // DESTRUCTEUR
-	virtual ~cMatrice();
+	~cMatrice();
 
-// GETTER
+// GETTERS
 	int getValTab(int l, int c);
 	int getCol();
 	int getLig();
 	cForme* get_pForme();
-// SETTER
+// SETTERS
 	void setCol(int);
 	void setLig(int);
 	void setValTab(int l, int c, unsigned int coul);
@@ -46,7 +35,6 @@
 	void updateMatrice();
 	void afficherForme(cForme * f, unsigned int c);
 	void clear();
-
 };
 
 
--- a/include/cSPI.h	Thu Apr 21 13:25:08 2016 +0000
+++ b/include/cSPI.h	Fri Apr 22 06:29:56 2016 +0000
@@ -1,17 +1,15 @@
-/*
- * cSPI.h
- *
- *  Created on: 5 avr. 2016
- *      Author: clement
- */
-
 #ifndef CSPI_H_
 #define CSPI_H_
 
 #include "mbed.h"
 #include "cMatrice.h"
 
-class cSPI {
+// Définition de la classe cSPI
+// Classe de gestion de la liaison SPI (initialisation et envoi de la matrice).
+
+class cSPI
+{
+    // ATTRIBUTS
 private:
     unsigned int _freq;
     unsigned int _mode;
@@ -35,7 +33,7 @@
     void setNbMatrices(unsigned int nb);
     // METHODES
     void initSPI(unsigned int frequence, unsigned int bits, unsigned int mode);
-    int envoyerMatrice(cMatrice &); // Renvoi la reponse SPI
+    int envoyerMatrice(cMatrice &);
     void configurerNbMatrices(const int nb);
 
 };
--- a/src/cBoussole.cpp	Thu Apr 21 13:25:08 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-#include "cBoussole.h"
-
-
-
-cBoussole::cBoussole(PinName sda, PinName scl) : i2c_(*reinterpret_cast<I2C*>(i2cRaw)) 
-{
-    // Placement new to avoid additional heap memory allocation.
-    new(i2cRaw) I2C(sda, scl);
-    for(unsigned char i=0; i< 3; i++) {
-        _values[i] = 0;
-        _oldValues[i] = 0;
-        _delta[i] = 0;
-    }
-    init();
-
-}
-
-cBoussole::~cBoussole()
-{
-    // If the I2C object is initialized in the buffer in this object, call destructor of it.
-    if(&i2c_ == reinterpret_cast<I2C*>(&i2cRaw))
-        reinterpret_cast<I2C*>(&i2cRaw)->~I2C();
-}
-
-void cBoussole::init()
-{
-    // init - configure your setup here
-    setConfigurationA(AVG8_SAMPLES | OUTPUT_RATE_15); // 8 sample average, 15Hz, normal mode
-    setConfigurationB(0x20); // default gain
-    setMode(CONTINUOUS_MODE); // continuous sample mode
-    wait(0.006);//wait 6ms as told in the datasheet
-}
-
-void cBoussole::setConfigurationA(char config)
-{
-    char cmd[2];
-    cmd[0] = CONFIG_A_REG; // register a address
-    cmd[1] = config;
-
-    i2c_.write(I2C_ADDRESS, cmd, 2);
-}
-
-void cBoussole::setConfigurationB(char config)
-{
-    char cmd[2];
-    cmd[0] = CONFIG_B_REG; // register b address
-    cmd[1] = config;
-
-    i2c_.write(I2C_ADDRESS, cmd, 2);
-}
-
-void cBoussole::setMode(char mode = SINGLE_MODE)
-{
-    char cmd[2];
-    cmd[0] = MODE_REG; // mode register address
-    cmd[1] = mode;
-    i2c_.write(I2C_ADDRESS,cmd,2);
-}
-
-
-void cBoussole::getXYZ(int16_t output[3])
-{
-    char cmd[2];
-    char data[6];
-    cmd[0] = 0x03; // starting point for reading
-    i2c_.write(I2C_ADDRESS, cmd, 1, true); // set the pointer to the start of x
-    i2c_.read(I2C_ADDRESS, data, 6, false);
-
-    for(int i = 0; i < 3; i++) // fill the output variables
-        output[i] = int16_t(((unsigned char)data[i*2] << 8) | (unsigned char)data[i*2+1]);
-}
-
-unsigned char cBoussole::detectionMvt()
-{
-    Serial pc (USBTX, USBRX);
-    unsigned char mvt;
-    getXYZ(_values);
-    _oldValues[0] = _values[0];
-    _oldValues[1] = _values[1];
-    _oldValues[2] = _values[2];
-    wait(0.1);
-    getXYZ(_values);
-    _delta[0] = _values[0] - _oldValues[0];
-    _delta[1] = _values[1] - _oldValues[1];
-    _delta[2] = _values[2] - _oldValues[2];
-            //rotation vers l'avant
-        //if ((abs(delta[0]) > 200) && (abs(delta[1]) > 200) && (abs(delta[2]) < 100 ))
-        if ((abs(_delta[0]) > 2000) && (abs(_delta[1]) > 2000) && (abs(_delta[2]) < 2000 ))
-        {
-                pc.printf("avant\n");
-                mvt = 'a';         
-        }        
-        //rotation  gauche
-        else if ((_delta[0] < 100) && (_delta[1] < -200) && (_delta[2] < -200 ))
-        {
-                pc.printf("rotation gauche\n");
-                mvt = 'l';     
-        }
-        //rotation  droite
-        else if ((_delta[0] < 100) && (_delta[1] < -200) && (_delta[2] > 200 ))
-        {
-                pc.printf("rotation droite\n"); 
-                mvt = 'r';           
-        }
-        //translation droite
-        //if ((delta[0] > 100) && (delta[1] < 100 ) && (delta[2] > 100))
-        else if ((_delta[0] < 100) && (_delta[1] > 1000 ) && (_delta[2] > 1000))
-        {
-                pc.printf("translation droite\n");
-                mvt = 'd';          
-        }
-        //translation gauche
-        
-        //if (((delta[0] < -100) && (delta[1] < 100) && (delta[2] > 100 )))
-        else if ((_delta[0] < 100) && (_delta[1] < 100 ) && (_delta[2] > 1000))
-        
-        {
-                pc.printf("translation gauche\n");
-                mvt = 'g';           
-        }
-        else{
-            return 0;
-        }
-        /*
-    //rotation vers l'avant
-    if ((abs(_delta[0]) > 200) && (abs(_delta[1]) > 200) && (abs(_delta[2]) < 100 )) {
-        pc.printf("avant\n");
-        mvt = 'a';
-    }
-    //rotation  gauche
-    if ((_delta[0] < 100) && (_delta[1] < -200) && (_delta[2] < -200 )) {
-        pc.printf("rotation gauche\n");
-        mvt = 'l';
-    }
-    //rotation  droite
-    if ((_delta[0] < 100) && (_delta[1] < -200) && (_delta[2] > 200 )) {
-        pc.printf("rotation droite\n");
-        mvt = 'r';
-    }
-    //translation gauche
-    if (((_delta[0] < -100) && (_delta[1] < 100) && (_delta[2] > 100 ))) {
-        pc.printf("translation gauche\n");
-        mvt = 'g';
-    }
-    //translation droite
-    if ((_delta[0] > 100) && (_delta[1] < 100 ) && (_delta[2] > 100)) {
-        pc.printf("translation droite\n");
-        mvt = 'd';
-    }
-    */
-    _oldValues[0] = _values[0];
-    _oldValues[1] = _values[1];
-    _oldValues[2] = _values[2];
-    return mvt;
-}
--- a/src/cEl.cpp	Thu Apr 21 13:25:08 2016 +0000
+++ b/src/cEl.cpp	Fri Apr 22 06:29:56 2016 +0000
@@ -12,13 +12,13 @@
     //  |1|2|3|
     //  |0|
     _Leds[0].setPositionX(_positionX - 1);
-    _Leds[0].setPositionY(_positionY);
+    _Leds[0].setPositionY(_positionY + 1);
     _Leds[1].setPositionX(_positionX - 1);
-    _Leds[1].setPositionY(_positionY - 1);
+    _Leds[1].setPositionY(_positionY);
     _Leds[2].setPositionX(_positionX);
-    _Leds[2].setPositionY(_positionY - 1);
+    _Leds[2].setPositionY(_positionY);
     _Leds[3].setPositionX(_positionX + 1);
-    _Leds[3].setPositionY(_positionY - 1);
+    _Leds[3].setPositionY(_positionY);
     for(int i = 0; i<4; i++) {
         _Leds[i].setOldPositionX(_Leds[i].getPositionX());
     }
--- a/src/cJeu.cpp	Thu Apr 21 13:25:08 2016 +0000
+++ b/src/cJeu.cpp	Fri Apr 22 06:29:56 2016 +0000
@@ -1,10 +1,6 @@
 #include "cJeu.h"
-//////////////////////////////////////////////
 #include "rtos.h"
 
-//////////////////////////////////////////////
-DigitalOut led2(LED2);
-
 
 //Constructeur par défaut
 cJeu::cJeu()
@@ -13,12 +9,9 @@
 }
 
 //Second constructeur:
-//Il crée de crée une matrice de x LEDs de large sur y LEDS de HAUT,
-//avec la broche pin comme entrée d'interruption si détection de mouvement du capteur
+//Il crée une matrice de  y LEDS de HAUT sur x LEDs de large
 cJeu::cJeu(unsigned int y, unsigned int x)
 {
-//create the InterruptIn on the pin specified to Counter
-
     //on crée une nouvelle matrice
     _mat = new cMatrice(y, x);
     //on initialise la générateur de nombres pseudo-aléatoires
@@ -43,7 +36,6 @@
     _mat = mat;
 }
 
-
 //Mutateur pour le score
 void cJeu::set_score(unsigned int sc)
 {
@@ -71,7 +63,7 @@
 }
 
 //Méthode de création d'une nouvelle pièce de manière pseudo-aléatoire
-void cJeu::nouvellePiece(int x, int y)
+void cJeu::nouvellePiece(int y, int x)
 {
     //On génère un nombre aléatoire entre 1 et 5 pour la pièce
     unsigned int nb = 1 + ((float)rand()/RAND_MAX) * 5;
@@ -152,8 +144,6 @@
     delete _ptrForme;
 }
 
-
-
 void cJeu::nouvelleManche()
 {
     //cJeu::nouvelleLigne();
@@ -248,7 +238,7 @@
             //On colore toute la matrice en bleue
             for(unsigned int i = 0; i < _mat->getLig(); i++) {
                 for(unsigned int j = 0; j < _mat->getCol(); j++) {
-                    _mat->setValTab(i, j, LED_BLEU_FONCE);
+                    _mat->setValTab(j, i, LED_BLEU_FONCE);
                 }
             }
              wait(1);
--- a/src/cMatrice.cpp	Thu Apr 21 13:25:08 2016 +0000
+++ b/src/cMatrice.cpp	Fri Apr 22 06:29:56 2016 +0000
@@ -2,13 +2,14 @@
 #include <algorithm>
 
 // CONSTRUCTEURS
-
+// Constructeur par défaut
 cMatrice::cMatrice()
 {
     _lig = 0;
     _col = 0;
 }
 
+//Constructeur qui crée une matrice de l lignes sur c colonnes
 cMatrice::cMatrice(int l, int c)
 {
     _lig = l;
@@ -67,44 +68,53 @@
 
 // METHODES
 
-//      Paramètres:
-//  f: Forme à afficher
-//  c: Couleur
+//afficherForme: méthode qui "colle la pièce en cours" à la matrice
+// Entrées: f: Forme à afficher
+//          c: Couleur
+// Sorties: aucune.
 void cMatrice::afficherForme(cForme* f, unsigned int c)
 {
+    //////////////////////
+    Serial pc(USBTX, USBRX);
+    //////////////////////////////////////////
     _pForme = f;
     // Changement de couleur des Leds
     for (int i = 0; i < 4; i++) {
         _pForme->getLed(i).setCouleur(c);
-        _matrice[_pForme->getLed(i).getPositionY()][_pForme->getLed(i).getPositionX()] = c;
-
+        _matrice[_pForme->getLed(i).getPositionX()][_pForme->getLed(i).getPositionY()] = c;
+        /////////////////////////////////////
+        pc.printf("x: %d, y: %d\n", _pForme->getLed(i).getPositionX(), _pForme->getLed(i).getPositionY());
     }
 }
 
 
-//      Description:
+
+//clear: méthode qui efface la matrice
+// Entrées: aucune.
+// Sorties: aucune.
 //  Nettoyage de la matrice, passage à 0 de la valeur de chaque Led
 void cMatrice::clear()
 {
     for( int i = 0; i < _lig; i++) {
         for( int j = 0; j < _col; j++) {
-            _matrice[i][j] = LED_NOIR;
+            _matrice[j][i] = LED_NOIR;
         }
     }
     //////////////////////////////////////////////////////////////////////////////////////
     _matrice[0][0] = LED_ROUGE;
-    //_matrice[8][0] = LED_ROUGE;
+    //_matrice[6][7] = LED_VERT;
+    //_matrice[5][12] = LED_BLEU_CLAIR;
 }
 
+//updateMatrice: méthode qui éteint les LEDs correspondant à l'anceinne position de la pièce en cours
+// Entrées: aucune.
+// Sortie: aucune.
 void cMatrice::updateMatrice()
 {
     // On éteint les leds de la pièce
     for (int i = 0; i < 4; i++) {
-        _matrice[_pForme->getLed(i).getOldPositionY()][_pForme->getLed(i).getOldPositionX()] = LED_NOIR;
+        _matrice[_pForme->getLed(i).getOldPositionX()][_pForme->getLed(i).getOldPositionY()] = LED_NOIR;
     }
     // Affichage de la nouvelle position
     afficherForme(_pForme, _pForme->getLed(0).getCouleur());
-    ///////////////////////////////////////////////////////////////////////////////////////////////
-    // Controle de la collision avec les bords
-    ///////////////////////////////////////////////////////////////////////////////////////////////
 }
--- a/src/cSPI.cpp	Thu Apr 21 13:25:08 2016 +0000
+++ b/src/cSPI.cpp	Fri Apr 22 06:29:56 2016 +0000
@@ -15,7 +15,7 @@
 
 cSPI::cSPI()
 {
-    
+
 }
 
 cSPI::cSPI(unsigned int f, unsigned int m, unsigned int b)
@@ -23,7 +23,7 @@
     _freq = f;
     _mode = m;
     _bits = b;
-    
+
     _cs = 0;
     wait(0.5);
     _spi.frequency(_freq);
@@ -81,30 +81,51 @@
     _cs = 0;
     wait_us(500);
     _spi.frequency(_freq);
-    //_spi.format(bits, mode);
+    //_spi.format(bits);
     wait_us(500);
     _cs = 1;
     pc.printf("Liaison SPI Initialisee\n");
-    
+
 }
 
 int cSPI::envoyerMatrice(cMatrice & mat)  // Renvoi la reponse SPI
 {
-       
+    Serial pc2(USBTX, USBRX);
+
     _cs = 0;
-    wait_us(500);
-    for(int i = 0; i < mat.getLig()/2; i++) {
+    wait(0.2);
+    for(int i = 0; i < mat.getLig(); i++) {
         for(int j = 0; j < mat.getCol(); j ++) {
-            _spi.write(mat.getValTab(j, i));
+            if(mat.getValTab(j, i) != 0) {
+                pc2.printf("%d|", 1);
+            } else {
+                pc2.printf("%d|", 0);
+            }
+        }
+        pc2.printf("\n");
+    }
+    for(int i = 0; i < mat.getCol(); i++) {
+        for(int j = 0; j < mat.getLig()/2; j ++) {
+            _spi.write(mat.getValTab(i, j));
         }
     }
-    for(int i = mat.getLig()/2; i < mat.getLig(); i++) {
-        for(int j = 0; j < mat.getCol(); j ++) {
-            _spi.write(mat.getValTab(j, i));
+    for(int i = 0; i < mat.getCol(); i++) {
+        for(int j = mat.getLig()/2; j < mat.getLig(); j ++) {
+            _spi.write(mat.getValTab(i, j));
         }
     }
-    wait_us(500);
+    wait(0.2);
     _cs = 1; //avant 0
+    wait(0.1);
+    /*_cs = 0;
+    wait(0.01);
+    for(int i =0; i<64; i++) {
+        _spi.write(LED_NOIR);
+    }
+    wait(0.01);
+    _cs=1;*/
+
+
     return 1; // temporaire
 }
 
--- a/src/main.cpp	Thu Apr 21 13:25:08 2016 +0000
+++ b/src/main.cpp	Fri Apr 22 06:29:56 2016 +0000
@@ -18,9 +18,9 @@
 {
     Serial pc(USBTX, USBRX);
     if ( GSensor.ginit() ) {
-        pc.printf("APDS-9960 initialization complete\n\r");
+        //pc.printf("APDS-9960 initialization complete\n\r");
     } else {
-        pc.printf("Something went wrong during APDS-9960 init\n\r");
+        //pc.printf("Something went wrong during APDS-9960 init\n\r");
     }
 
     //Start running the APDS-9960 gesture sensor engine
@@ -63,7 +63,7 @@
                 }
             }
             osMessagePut(queue, (uint32_t)message, osWaitForever);
-            pc.printf("Message ==> Envoye \n");
+            //pc.printf("Message ==> Envoye \n");
             osDelay(10);
         }
     }
@@ -73,27 +73,21 @@
 
 int main()
 {
-
     mpool = osPoolCreate(osPool(mpool));
     queue = osMessageCreate(osMessageQ(queue), NULL);
     Serial pc(USBTX, USBRX);
     osThreadCreate(osThread(detectionMouvement), NULL);
     Thread thread(detectionMouvement); // Lancement du thread
 
-    cJeu jeu(16,8);
+    cJeu jeu(16, 8);
     jeu.initialiser();
-    //jeu.nouvellePiece(4,4);
+    jeu.nouvellePiece(0, 3);
     jeu.setQueue(&queue, &mpool);
-
-
-
+/*
     while (!jeu.partieEnCours()) {
     }
     ///////////////////////////////
-    //A VOIR
+    //A VOIR*/
     jeu.fin();
 
-
-
-
 }