Modifications

Sauter à la navigation Sauter à la recherche
182 octets supprimés ,  23 septembre 2018 à 15:45
Ligne 57 : Ligne 57 :  
A common usage of the SPI Flash memory is the datalogging. The example '''fatfs_datalogging''' shows some datalogging/writing operation. Open the sketch into Arduino IDE then upload the Feather M0 board. Next, open the serial monitor (at 115200 baud) and you should see a message displayed every minutes when the sketch writes a new line in the SPI Flash file system.
 
A common usage of the SPI Flash memory is the datalogging. The example '''fatfs_datalogging''' shows some datalogging/writing operation. Open the sketch into Arduino IDE then upload the Feather M0 board. Next, open the serial monitor (at 115200 baud) and you should see a message displayed every minutes when the sketch writes a new line in the SPI Flash file system.
   −
Voyez le contenu de la fonction {{fname|loop()}} pour comprendre comment écrire dans le fichier:
+
See the content of the {{fname|loop()}} function to understand how to write into a file:
    
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
   // Ouvrir le fichier de datalogging en écritureLe mode FILE_WRITE ouvrira
+
   // Open the datalogging file in write modethe FILE_WRITE mode will
   // le fichier en mode ajout (ajoutera les données en fin de fichier).
+
   // open the file for appending (it will add the data a the end
 +
  //  of the file).
 
   File dataFile = fatfs.open(FILE_NAME, FILE_WRITE);
 
   File dataFile = fatfs.open(FILE_NAME, FILE_WRITE);
   // Vérifie si le fichier est ouvert et écrit des données.
+
   // Check if the file is open and write datas.
 
   if (dataFile) {
 
   if (dataFile) {
     // Obtenir les données depuis les senseurs, etc. Dans ce exemple
+
     // Grab the data from sensors. In this sample
     // nous créons juste un nombre aléatoire.
+
     // the data would be a random number.
 
     int reading = random(0,100);
 
     int reading = random(0,100);
     // Ecrire une nouvelle ligne dans le fichier.   
+
     // Write a new line in the file.   
     // Vous poyvez utiliser les mêmes fonctions print que celles
+
     // The user can use the same functions as print function
     // utilisées pour afficher des données sur le moniteur série.  
+
     // sending data to the serial monitor.  
     // Par exemple, pour écrire deux valeurs CSV (séparées par une virgule):
+
     // EG: to write 2 CSV entries (coma separated):
 
     dataFile.print("Sensor #1");
 
     dataFile.print("Sensor #1");
 
     dataFile.print(",");
 
     dataFile.print(",");
 
     dataFile.print(reading, DEC);
 
     dataFile.print(reading, DEC);
 
     dataFile.println();
 
     dataFile.println();
     // Pour finir, fermer le fichier lorsque l'opération
+
     // The file must be closed at the end of writing operation.
    // d'écriture est achevée. C'est une facon adéquate pour
+
     // This is the right way to ensure that data are writtebn
     // s'assurer que les données soient bien écrites dans
+
     // into the file.
     // le fichier.
   
     dataFile.close();
 
     dataFile.close();
     Serial.println("Nouvelle mesure écrite dans le fichier!");
+
     Serial.println("New value written to the file!");
 
   }
 
   }
 
</syntaxhighlight>
 
</syntaxhighlight>
29 837

modifications

Menu de navigation