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.
Diff: Matrice.cpp
- Revision:
- 0:31b36057b213
- Child:
- 1:bb64b6783fa9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Matrice.cpp Sun Mar 12 13:34:59 2017 +0000
@@ -0,0 +1,54 @@
+#include "Matrice.h"
+
+Matrice ::~Matrice(void){
+ if (_spi) delete _spi; // destruction de l'objet SPI
+ if (_cs) delete _cs;
+}
+
+Matrice::Matrice(void)
+{
+_spi=NULL;
+_cs=NULL;
+state=false;
+}
+
+Matrice::Matrice(SPI * spi,DigitalOut *cs ){ // Constructeur avec la liason SPI
+ beginSPI(spi, cs);
+}
+
+void Matrice::beginSPI( SPI * spi, DigitalOut *cs){
+ state=false;
+ if (_spi) delete _spi; // on verifie qu'une liason spi n'existe pas déja
+ _spi=spi;
+ if (_cs)delete _cs;//Creation du Chip Select/
+ _cs=cs;
+ if (_spi && _cs)
+ {
+ state = true; // Etat de la liason SPI
+ _spi->format(8); // 8 bits de données
+ _spi->frequency(100000); // frequence 10khz -> Max 125khz
+ _cs->write(1); // CS/ a 1)
+ }
+
+ }
+
+void Matrice::ecrireMatrice( char * buffer)
+{
+
+ if (state == true)
+ {
+ // Select the device by seting chip select low
+ _cs->write(0);
+
+ wait_ms(1);
+ //Ecriture des 64 leds
+ for ( int i =0; i<=64;i++)
+ {
+ _spi->write(buffer[i]);
+ }
+ wait_ms(1);
+ // Remontee de CS/
+ _cs->write(1);
+ }
+
+}
\ No newline at end of file