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/cSPI.cpp
- Revision:
- 39:1aead50ff166
- Parent:
- 36:f58a566595ad
--- a/src/cSPI.cpp Sun Apr 24 20:15:03 2016 +0000
+++ b/src/cSPI.cpp Sun Apr 24 21:38:38 2016 +0000
@@ -1,10 +1,3 @@
-/*
- * cSPI.cpp
- *
- * Created on: 5 avr. 2016
- * Author: clement
- */
-
#include "cSPI.h"
#include "cMatrice.h"
@@ -61,8 +54,9 @@
_bits = bits;
}
-// METHODES
-
+//Méthode d'initialisation de la liaison SPI
+//Entrées: fréquence: valeur de la fréquence de la liaison
+//Sorties: aucune.
void cSPI::initSPI(unsigned int frequence)
{
_cs = 0;
@@ -72,40 +66,33 @@
_cs = 1;
}
-int cSPI::envoyerMatrice(cMatrice & mat) // Renvoi la reponse SPI
+//Méthode de rafraîchissemnt des matrices
+//Entrées: mat: matrice à afficher
+//Sorties: aucune.
+void cSPI::envoyerMatrice(cMatrice & mat)
{
Serial pc(USBTX, USBRX);
_cs = 0;
wait_ms(1);
+ //On rafraîchit la matrice la plus éloignée du Mbed
for(unsigned char i = 0; i < mat.getCol(); i++) {
for(unsigned char j = 0; j < mat.getLig()/2; j ++) {
_spi.write(mat.getValTab(i, j));
- /* if(mat.getValTab(i, j)) {
- pc.printf("1|");
- } else {
- pc.printf("0|");
- }*/
}
- //pc.printf("\n");
}
- //pc.printf("\n");
+ //Puis la seconde
for(unsigned char i = 0; i < mat.getCol(); i++) {
for(unsigned char j = mat.getLig()/2; j < mat.getLig(); j ++) {
_spi.write(mat.getValTab(i, j));
- /* if(mat.getValTab(i, j)) {
- pc.printf("1|");
- } else {
- pc.printf("0|");
- }*/
}
- //pc.printf("\n");
}
wait_ms(1);
- _cs = 1; //avant 0
- return 1; // temporaire
-
+ _cs = 1;
}
+//Méthode de configuration du nombre de matrices de LEDs en DaisyChain
+//Entrées: nb: entier qui correspond au nombre de matrices
+//Sorties: aucune.
void cSPI::setNbMatrice(unsigned int nb)
{
_cs = 0;