Modifications

Sauter à la navigation Sauter à la recherche
45 octets supprimés ,  23 septembre 2018 à 18:40
Ligne 130 : Ligne 130 :  
Remember that SPI Flash library is designed to expose the same interface than [https://www.arduino.cc/en/reference/SD Arduino's SD library]. So the codes and samples storing data on SD card would would be easy to adapt to the SPI Flash library. Just create a {{fname|fatfs}} object like the examples here upper. You will also have to use the {{fname|open}} method on the object (instead of the global open function). Once the reference to the file object, all the functions and usages would be identifcal between the SPI Flash and Arduino's SD library!
 
Remember that SPI Flash library is designed to expose the same interface than [https://www.arduino.cc/en/reference/SD Arduino's SD library]. So the codes and samples storing data on SD card would would be easy to adapt to the SPI Flash library. Just create a {{fname|fatfs}} object like the examples here upper. You will also have to use the {{fname|open}} method on the object (instead of the global open function). Once the reference to the file object, all the functions and usages would be identifcal between the SPI Flash and Arduino's SD library!
   −
== Lire et écrire des fichiers CircuitPython ==
+
== Read and Write CircuitPython files ==
L'exemple '''fatfs_circuitpython''' montre comment lire et écrire des fichiers sur la mémoire flash de sorte qu'ils puissent être accéssible depuis CircuitPython/MicroPythonCela signifie que vous pouvez exécuter un programme CircuitPython sur votre carte pour y stocker des données, puis utiliser un croquis Arduino qui utilise cette bibliothèque pour interagir avec ces mêmes données.
+
The example '''fatfs_circuitpython''' demonstrate how to read and write the files from the SPI Flash from CircuitPython file systemThis means that you can execute CircuitPython script to store data in the CircuitPython file system, then use an Arduino sketch using this library to interact with those data.
   −
Notez qu'avant d'utiliser l'exemple '''fatfs_circuitpython''' vous '''devez''' avoir chargé CircuitPython sur votre carte. [[FEATHER-M0-MicroPython|Voyez ce guide pour charger la dernière version de CircuitPython]] afin que le système de fichier CircuitPython soit écrit et initialisé sur la puce Flash. Une fois CircuitPython chargé sur la carte, vous pouvez exécuter le croquis '''fatfs_circuitpython'''.
+
Note: before running the exemple '''fatfs_circuitpython''' you '''must''' have loaded the CircuitPython on the board. [https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-circuitpython/what-is-circuitpython|Please, see the Adafruit's M0 Express guide] to initialize the CircuitPython file system in the SPI Flash. Once the CircuitPython loaded on the board, you can execute the sketch '''fatfs_circuitpython'''.
   −
Pour exécuter le croquis, il faut le charger dans Arduino IDE et le téléverser sur la carte Feather M0. Ensuite, il faut ouvrir le moniteur série à 115200 baud. Vous devriez voir des messages s'afficher lorsqu'il essaye de lire et écrire des fichiers sur la mémoire Flash.
+
To execute the sketch, you have to load it inside Arduino IDE then upload it to the Feather M0 board. Then, you have to open a serial monitor a 115200 baud. You should see messages displayed when the sketch tries to read and write files on the Flask memory.
   −
Plus spécifiquement, l'exemple cherche les fichiers '''boot.py''' et '''main.py''' (puisque CircuitPython exécute ces fichiers au démarrage) et affiche leur contenu. Puis il ajoute une ligne à la fin du fichier '''data.txt''' présent sur la carte (le fichier est créé s'il n'existe pas encore). Après avoir exécuté le croquis, vous pouvez recharger CircuitPython sur la carte et charger et lire le fichier '''data.txt''' depuis CircuitPython!
+
Specifically, the example looks for the files '''boot.py''' and '''main.py''' (since CircuitPython execute thos file when starting the board) to display their content. After, the sketch add a line at the end of the '''data.txt''' file available in the CircuitPython file system (the file is created if not yet existing).  
   −
Voyons un peu le code du croquis pour comprendre comment lire et écrire des fichiers CircuitPython. Pour commencer une instance de la classe '''Adafruit_M0_Express_CircuitPython''' est crée en lui passant un instance de la classe SPIFlash (permettant d'accéder à la mémoire Flash):
+
When done, you can reload CircuitPython on the board to load and read the  exécuté le croquis, vous pouvez recharger CircuitPython sur la carte pour lire le fichier '''data.txt''' directement depuis CircuitPython!
 +
 
 +
Let's have a loot to the sketch code to understant how to read and write files in CircuitPython. First, an instance of the '''Adafruit_M0_Express_CircuitPython''' class is created with the instance of the SPIFlash class (SPIFlash is used to access the Flash content):
    
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
#define FLASH_SS      SS1                    // broche SSP de la Flash
+
#define FLASH_SS      SS1                    // SSP pin from Flash
#define FLASH_SPI_PORT SPI1                  // port SPI surlequel est branché la mémoire Flash
+
#define FLASH_SPI_PORT SPI1                  // SPI port where the Flash is wired
   −
Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT);    // Utiliser le bus SPI matériel
+
Adafruit_SPIFlash flash(FLASH_SS, &FLASH_SPI_PORT);    // Use the hardware SPI bus  
   −
// Il est possible d'utiliser d'autres broches comme bus SPI (SPI logiciel)!
+
// Other pins can also be used for the SPI bus (software SPI)!
 
//Adafruit_SPIFlash flash(SCK1, MISO1, MOSI1, FLASH_SS);
 
//Adafruit_SPIFlash flash(SCK1, MISO1, MOSI1, FLASH_SS);
   −
// Pour finir, créer un objet Adafruit_M0_Express_CircuitPython qui offre un accès
+
// Finally, create an Adafruit_M0_Express_CircuitPython object to gain access
// à une interface de type Carte SD pour interagir avec les fichiers stockés dans
+
// to a SD alike interface. The Adafruit_M0_Express_CircuitPython would allow
// le système de fichier Flash de CircuitPython.
+
// the sketch to access the CircuitPython file system stored inside the Flash.
 
Adafruit_M0_Express_CircuitPython pythonfs(flash);
 
Adafruit_M0_Express_CircuitPython pythonfs(flash);
 
</syntaxhighlight>
 
</syntaxhighlight>
29 837

modifications

Menu de navigation