Modifications

Sauter à la navigation Sauter à la recherche
1 987 octets supprimés ,  23 septembre 2018 à 19:47
Ligne 2 : Ligne 2 :     
== Forewords ==  
 
== Forewords ==  
{{traduction}}
   
One of the most exciting feature of the M0 Express board is this small FLASH chip wired on the SPI bus. That memory could be used to provide lot of services like storing files, python script and many more.
 
One of the most exciting feature of the M0 Express board is this small FLASH chip wired on the SPI bus. That memory could be used to provide lot of services like storing files, python script and many more.
   Ligne 168 : Ligne 167 :  
   if (pythonfs.exists("boot.py")) {
 
   if (pythonfs.exists("boot.py")) {
 
     File bootPy = pythonfs.open("boot.py", FILE_READ);
 
     File bootPy = pythonfs.open("boot.py", FILE_READ);
     Serial.println("Afficher boot.py...");
+
     Serial.println("Display boot.py...");
 
     while (bootPy.available()) {
 
     while (bootPy.available()) {
 
       char c = bootPy.read();
 
       char c = bootPy.read();
Ligne 180 : Ligne 179 :  
</syntaxhighlight>
 
</syntaxhighlight>
   −
Notez l'appel de la fonction '''exists''' qui vérifie la présence du fichier boot.py, puis l'utilisation de la fonction '''open''' pour ouvrir celui-ci en mode lecture (''read'' en anglais''). Une fois fichier ouvert vous obtenez une référence vers un objet de la classe File  qui permet de lire et écrire dans le fichier comme s'il s'agissait d'un périphérique Serial (encore une fois, [https://www.arduino.cc/en/Reference/SD toutes les fonctions de la classe File] sont identiques à celle de la classe carte SD).
+
Le file write operation is also very simple, the following sketch will add data to the '''data.txt''' file:
 
  −
Dans ce cas, la fonction '''available''' retournera le nombre d'octets (''bytes'') restant à lire jusqu'à la fin du fichier -et- la fonction '''read''' lit un caractère à la fois (pour l'afficher sur le moniteur série).
  −
 
  −
L'écriture d'un fichier est tout aussi simple, voici comment le croquis ajoute des données dans le fichier '''data.txt''':
      
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
   // Créer et ajouter des données dans le fichier data.txt  
+
   // Create and add data in the file data.txt  
   // puis ajouter un retour à la ligne.
+
   // then append a carriage return.
   // Le code CircuitPython pourra, plus tard, ou consulter
+
   // Later, the CircuitPython script will be able to
   // le contenu de ce fichier!
+
   // read the file content!
 
   File data = pythonfs.open("data.txt", FILE_WRITE);
 
   File data = pythonfs.open("data.txt", FILE_WRITE);
 
   if (data) {
 
   if (data) {
     // Ajouter une nouvelle ligne de donnée:
+
     // Add a new line of data:
     data.println("Un bonjour a CircuitPython de la part d Arduino!");
+
     data.println("A great day to CircuitPython from our beloved Arduino sketch!");
 
     data.close();
 
     data.close();
     // Voir les autre exemples fatfs comme fatfs_full_usage  
+
     // See also the examples from the fatfs_full_usage  
     // et fatfs_datalogging pour plus d'exemples concernant
+
     // and fatfs_datalogging for mode information about
     // les interactions avec les fichiers.
+
     // interaction with files.
     Serial.println("Nouvelle ligne ajoutée au fichier data.txt!");
+
     Serial.println("A new line was added to the data.txt file!");
 
   }
 
   }
 
   else {
 
   else {
Ligne 206 : Ligne 201 :  
</syntaxhighlight>
 
</syntaxhighlight>
   −
Cette fois encore, la fonction '''open''' est utilisée pour ouvrir le fichier si ce n'est que cette fois, le fichier est ouvert en lecture (''write'' en anglais). Dans ce mode, le fichier est ouvert en ajout (les données sont ajoutées en fin de fichier) si ce dernier existe. A noter le mode écriture crée le fichier si celui-ci n'existe pas. Une fois le fichier ouvert, les fonctions tels que '''print''' et '''println''' peuvent être utilisées pour écrire des données dans le fichier (juste comme envoi des données vers le moniteur série). Une fois le traitement terminé, la fonction '''close''' ferme le fichier!
+
== Access to the SPI Flash ==
 +
Arduino is not able to expose himself as a storage device (a "''mass storage''" device). Instead you will have to switch to CircuitPython to expose the SPI Flash as storage device. Here is the technique to use:
 +
* Start the bootloader of the Express board. Drag and drop the last version of the '''circuitpython''' (the UF2 file).
 +
* After a while, you should see a '''CIRCUITPY''' drive containing the file '''boot_out.txt'''. Great, the Circuit Python filesystem is initialized on the SPI Flash.
 +
* Open the Arduino IDE and upload the '''fatfs_circuitpython''' sketch available in the Adafruit's SPI FLASH library. Open the serial console and start the sketch. Voila! the CircuitPython file system is properly mounted and the file '''data.txt''' created and initialized.
   −
Voilà, nous en avons terminé avec les opérations fondamentales de lecture et d'écriture. Voyez l'exemple '''fatfs_full_usage''' pour un apercu des fonctionnalités avancées tels que la création de répertoire, effacement de fichiers et répertoires, obtention de la taille d'un fichier, etc!  Rappelez vous que pour interagir avec les fichiers CircuitPython, il faudra utiliser la classe '''Adafruit_Feather_M0_CircuitPython''' comme indiqué dans l'exemple ci-dessus!
+
{{ambox|text=So, the Arduino Sketch did manipulated a file onto the SPI Flash owning the CircuitPython filesystem!}}
   −
== Accéder à la Flash SPI ==
+
{{ADFImage|FEATHER-M0-ArduinoIDE-SPI-Flash-02.png}}
Arduino n'est malheureusement pas capable d'exposer un périphérique de stockage (dit "''mass storage''" en anglais). Par conséquent, il faut utiliser CircuitPython qui, lui, est capable de faire cela pour nous. Voici la technique à utiliser.Here's the full technique:
  −
* Démarrer le bootloader de votre carte Express. Faites un glisser/déposer de la dernière version du fichier uf2 '''circuitpython'''.
  −
* Après un moment, vous devriez voir apparaître le lecteur '''CIRCUITPY''' contenant un fichier '''boot_out.txt'''. Voilà, le système de fichier est initialisé sur la Flash SPI.
  −
* Ouvrez maintenant Arduino IDE et téléversez l'exemple '''fatfs_circuitpython''' disponible dans la bibliothèque SPI d'Adafruit. Ouvrez la console série pour démarrer le croquis. Voilà, le système de fichier CircuitPython sera correctement monté et le fichier '''data.txt''' créé et initialisé.
     −
{{ADFImage|FEATHER-M0-ArduinoIDE-SPI-Flash-02.png}}
+
This time, we will open the file created by the Arduino sketch.
   −
* Revenons sur notre ordinateur, redémarrez le bootloader de la carte Express --ET-- re-glissez/re-déposez '''circuitpython.uf2''' sur le lecteur '''BOOT''' rendu accessible par le bootloader. Voilà, CircuitPython est résintallé sur la carte Express.
+
* Let plug again the board on the computer, restart the bootloader on the Express board --AND-- drag/drop  the '''circuitpython.uf2''' on the drive '''BOOT''' made accessible by the bootloader. Great, CircuitPython is now installed (again) on the board.
* Au bout d'un moment, le lecteur '''CIRCUITPY''' redevient accessible. Celui-ci expose a nouveau le système de fichier MicroPython de la Flash SPI. Vous pouvez maintenant voir le fichier '''data.txt''', l'ouvrir et en consulté le contenu!
+
* After a a while, the '''CIRCUITPY''' drive is made available by CircuitPyhton. This would expose the SPI Flash content as a Mass Storage device. You can now see the file '''data.txt''' created by our Arduino Sketch, Open it and read it's content :-) !
    
{{ADFImage|FEATHER-M0-ArduinoIDE-SPI-Flash-03.png}}
 
{{ADFImage|FEATHER-M0-ArduinoIDE-SPI-Flash-03.png}}
   −
Une fois que votre croquis de datalogging Arduino fonctionne comme attendu, vous pouvez simplifier la procédure en copiant '''CURRENT.UF2''' depuis le lecteur '''BOOT''' pour faire une copie de sauvegarde de votre programme Arduino. Vous pourrez ensuite charger CircuitPython pour accéder au système de fichier de la Flash SPI et enfin recopier votre '''CURRENT.UF2''' sur le lecteur '''BOOT''' de la carte Express pour réactiver votre croquis Arduino!
+
Once your datalogging sketch finish, you can simplify the procedure by copying the '''CURRENT.UF2''' from the '''BOOT''' drive to make "ready to use copy" of your sketch. You could now load the CircuitPython to access the CircuitPython file system and then switch back to you Arduino sketch by restoring the '''CURRENT.UF2''' on the Express Board!
    
{{ENG-CANSAT-TRAILER}}
 
{{ENG-CANSAT-TRAILER}}
29 910

modifications

Menu de navigation