Modifications

Sauter à la navigation Sauter à la recherche
aucun résumé de modification
Ligne 107 : Ligne 107 :  
{{traduction}}
 
{{traduction}}
   −
Let's look a little more closely at the code to understand how reading and writing digital GPIO works.
+
Jetons un petit coup d'oeil sous le capot pour voir comment le programme fonctionne pour effectuer les lectures et écritures sur les GPIOs.
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
Ligne 118 : Ligne 118 :  
</syntaxhighlight>
 
</syntaxhighlight>
   −
First the required modules are loaded for this script. The time module will be used to delay for a short period of time.   
+
Pour commencer, le programme charge les modules nécessaire pour le fonctionnement du script. Le module {{fname|time}} est utilisé pour insérer des délais de pause dans le programme.   
   −
The '''Adafruit_GPIO''' and '''Adafruit_GPIO.FT232H''' modules will be imported with shorter names using the 'as' keyword. These modules have all the logic for reading and writing GPIO on the FT232H.
+
Les modules '''Adafruit_GPIO''' et '''Adafruit_GPIO.FT232H''' sont importés et un alias (nom raccourcis) est associé aux modules à l'aide du mot clée {{fname|as}}. Ces modules dispose de toute la logique nécessaire pour lire les écrire des valeurs sur les GPIO du FT232H.
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
# Temporarily disable the built-in FTDI serial driver on Mac & Linux platforms.
+
# Désactiver temporairement le pilote FTDI série sur les plateformes Mac et Linux.
 
FT232H.use_FT232H()
 
FT232H.use_FT232H()
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
Next the '''use_FT232H()''' function is called to temporarily disable any FTDI serial drivers. This command is necessary on Mac or Linux platforms because the libftdi library will interfere with the built-in FTDI serial drivers.   
+
Ensuite, l'utilisation de la fonction '''use_FT232H()''' est pour temporairement désactiver le le pilote série FTDI. Cette commande est nécessaire sur les plateformes Mac ou Linux parce que la bibliothèque libftdi interfère avec la pilote FTDI série.   
   −
You don't really need to run this command on Windows because the FTDI serial driver was disabled using the Zadig tool, however it can't hurt to call the function as it will do nothing on Windows.
+
Vous n'avez pas vraiment besoin d'exécuter cette commande sur Windows parce que le pilote FTDI série a été désactivé avec l'outil Zadig. Cet appel ne perturbera pas le fonctionnement de du script sous Windows.
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
# Create an FT232H object that grabs the first available FT232H device found.
+
# Créer un objet FT232H qui récupère le premier périphérique FT232H disponible.
 
ft232h = FT232H.FT232H()
 
ft232h = FT232H.FT232H()
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
Now an FT232H object is created and assigned to the ft232h variable. This will detect the first available FT232H device connected to the computer and initialize its MPSSE for use with GPIO.
+
Maintenant que l'objet FT232H est créé et assigné à la variable ft232h. Cette opération détecte le premier périphérique FT232H disponible sur l'ordinateur et l'initialise en mode MPSSE pour utiliser son GPIO.
   −
Make sure the '''use_FT232H()''' function was previously called or else this function will fail!
+
Assurez vous d'avoir appelé la fonction '''use_FT232H()''' avant la création de l'objet sinon la création échouera!
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
# Configure digital inputs and outputs using the setup function.
+
# Configure les entrées et sorties digitales en utilisant la fonction setup.
# Note that pin numbers 0 to 15 map to pins D0 to D7 then C0 to C7 on the board.
+
# Note: les broches 0 à 15 correspondent aux broches D0 à D7 puis à C0 à C7 de la carte.
ft232h.setup(7, GPIO.IN)  # Make pin D7 a digital input.
+
ft232h.setup(7, GPIO.IN)  # Déclare la broche D7 comme un entrée digitale.
ft232h.setup(8, GPIO.OUT)  # Make pin C0 a digital output.
+
ft232h.setup(8, GPIO.OUT)  # Déclare la broche C0 comme une sortie digitale.
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
Next the '''setup()''' function is called on the FT232H object. This function takes two parameters, the first is the pin number and the second is either '''GPIO.IN''' or '''GPIO.OUT''' to set the pin as a digital input or output.   
+
Ensuite, la fonction '''setup()''' de l'objet FT232H est appelé. Cette fonction prend deux paramètres: le premier est le numéro de broche et le second soit '''GPIO.IN''' ou '''GPIO.OUT''' pour déclarer la broche en entrée ou en sortie.   
   −
Remember the pin numbers are <font color="orange">'''0 to 7'''</font> for <font color="orange">'''D0 to D7'''</font>, and <font color="teal">'''8 to 15'''</font> for <font color="teal">'''C0 to C7'''</font>.
+
Rappelez vous que les numeros de broche sont <font color="orange">'''de 0 à 7'''</font> pour les <font color="orange">'''broches D0 à D7'''</font>, et <font color="teal">'''de 8 à 15'''</font> pour les <font color="teal">'''broches C0 à C7'''</font>.
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
# Loop turning the LED on and off and reading the input state.
+
# Boucle allumant et éteignant la LED -- et -- lisant l'état de l'entrée .
 +
# Presser contrôle C pour quitter le programme.
 
print 'Press Ctrl-C to quit.'
 
print 'Press Ctrl-C to quit.'
 
while True:
 
while True:
# Set pin C0 to a high level so the LED turns on.
+
# Mettre la broche C0 au niveau haut (HIGH) pour allumer la LED.
 
ft232h.output(8, GPIO.HIGH)
 
ft232h.output(8, GPIO.HIGH)
# Sleep for 1 second.
+
# Attendre une seconde.
 
time.sleep(1)
 
time.sleep(1)
# Set pin C0 to a low level so the LED turns off.
+
# Mettre la broche C0 au niveau bas (LOW) pour eteindre la LED.
 
ft232h.output(8, GPIO.LOW)
 
ft232h.output(8, GPIO.LOW)
# Sleep for 1 second.
+
# Attendre une seconde.
 
time.sleep(1)
 
time.sleep(1)
 
</syntaxhighlight>
 
</syntaxhighlight>
29 918

modifications

Menu de navigation