Modifications

Sauter à la navigation Sauter à la recherche
Ligne 285 : Ligne 285 :  
Si vous avez suivi le plan de montage avec le MCP23017 alors c'est cette partie du tutoriel qui vous intéresse.
 
Si vous avez suivi le plan de montage avec le MCP23017 alors c'est cette partie du tutoriel qui vous intéresse.
   −
The '''char_lcd_mcp.py''' file in the library's examples folder demonstrates the usage of a character LCD (non-RGB version) with an MCP23017 IO extender. Run the script by executing this command inside the examples directory:  
+
La répertoire de la bibliothèque contient le fichier d'exemple '''char_lcd_mcp.py''' qui montre comment utiliser un afficheur LCD (version non-RGB) avec un GPIO expander MCP23017.  
 +
 
 +
Executez le script depuis le répertoire "examples" :  
    
  sudo python char_lcd_mcp.py
 
  sudo python char_lcd_mcp.py
   −
You should see a simple demo of the LCD displaying text, cursors, and scrolling just like the '''char_lcd.py''' demo described on the previous page.
+
Vous verrez une simple démo qui affiche du texte sur le LCD, manipule le curseur et fait défiler du texte comme pour la démo '''char_lcd.py''' (décrit dans la section précédente).
 +
 
 +
Vous pourrez voir comment l'exemple fonctionne avec un composant MCP si vous ouvrez le fichier '''char_lcd_mcp.py''' dans un éditeur de texte.
 +
 
 +
Voyez l'aperçu du fichier ci-dessous:
 +
 
 +
Le script commence par importer les modules nécessaires.  
   −
If you open '''char_lcd_mcp.py''' in a text editor you can see how to use the character LCD library with the MCP chip. Below is an overview of the file:
+
Notez qu'en plus d'importer le module Adafruit_GPIO.MCP230xx (importé sous le nom MCP). Cette classe MCP230xx sera utilisé pour dialoguer avec la puce MCP pour envoyer des informations sur l'interface du LCD.  
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
Ligne 301 : Ligne 309 :  
</syntaxhighlight>
 
</syntaxhighlight>
   −
First the required modules are imported. Notice the addition of the Adafruit_GPIO.MCP230xx module (imported under the name MCP). This MCP230xx class will be used to talk to the MCP chip and interface with the LCD.
+
Ensuite, les broches de l'écran LCD sont définie dans le script.  
 +
 
 +
{{ambox-stop|text=Notez que ces numéros de broches sont celle des GPIOs de la puce MCP ET NON les numéros de broches du Raspberry Pi/BeagleBone Black!}}
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
# Define MCP pins connected to the LCD.
+
# Definir les broches du MCP connectées sur le LCD.
 
lcd_rs        = 0
 
lcd_rs        = 0
 
lcd_en        = 1
 
lcd_en        = 1
Ligne 312 : Ligne 322 :  
lcd_d7        = 5
 
lcd_d7        = 5
 
lcd_backlight = 6
 
lcd_backlight = 6
# Optionally if the backlight is not controllable then set:
+
# Optionnel si le rétro-éclairage n'est pas contrôllable alors definisez:
 
# lcd_backlight = None
 
# lcd_backlight = None
   −
# Define LCD column and row size for 16x2 LCD.
+
# Définir le nombre de ligne (rows) et nombre de colonne (columns).
 +
# La taille définie ici est 16x2.
 
lcd_columns = 16
 
lcd_columns = 16
 
lcd_rows    = 2
 
lcd_rows    = 2
   −
# Alternatively specify a 20x4 LCD.
+
# Vous pouvez definir une taille alternative, par exemple 20x4.
 
# lcd_columns = 20
 
# lcd_columns = 20
 
# lcd_rows    = 4
 
# lcd_rows    = 4
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
Next the LCD pins are defined in the script. '''Note that these pin numbers are the MCP chip GPIO pin numbers, and NOT Raspberry Pi/BeagleBone Black pin numbers!'''
+
Ensuite, une instance de la classe MCP23017 est créée. Par défaut, cette class utilise l'adresse par défaut du MCP sur le bus I2C (0x20). La classe utilise également le bus par défaut de la plateforme de développement.
 +
 
 +
Si vous avez besoin d'utiliser une autre adresse ou autre bus I2C alors référez vous aux autres ligne en commentaire ci-dessous.
    
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
# Initialize MCP23017 device using its default 0x20 I2C address.
+
# Initialiser le périphérique MCP23017 en utilisant l'adresse I2C par défaut (0x20).
 
gpio = MCP.MCP23017()
 
gpio = MCP.MCP23017()
   −
# Alternatively you can initialize the MCP device on another I2C address or bus.
+
# Initialisation alternative en utilisant une autre adresse I2C et autre bus.
 
# gpio = MCP.MCP23017(0x24, busnum=1)
 
# gpio = MCP.MCP23017(0x24, busnum=1)
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
Next an instance of the MCP23017 class is created. By default this class will use the I2C address 0x20 (default for MCP chips) and appropriate I2C bus for the running development board. However if you need to override the address or bus number you can see in the commented line how these are passed as parameters.
+
Vous pouvez également utiliser un MCP23008 mais dans ce cas, il faudra utiliser une instance de la classe '''MCP23008'''. Cette classe est exactement la même que celle du '''MCP23017''' mais elle supporte uniquement 8 broches GPIO.  
   −
Also note if you're using an MCP23008 chip you can instead create an instance of the '''MCP23008''' class. This class is exactly the same as the '''MCP23017''' class, but only supports 8 GPIO pins.
+
{{traduction}}
    
Now the Adafruit_CharLCD class instance is created. The big difference with this line and previous examples is that the MCP23017 class (created with the name 'gpio') is passed in as the gpio parameter. By passing in an explicit gpio parameter, the char LCD class will use that GPIO class for talking to the LCD instead of the default development board GPIO pins.
 
Now the Adafruit_CharLCD class instance is created. The big difference with this line and previous examples is that the MCP23017 class (created with the name 'gpio') is passed in as the gpio parameter. By passing in an explicit gpio parameter, the char LCD class will use that GPIO class for talking to the LCD instead of the default development board GPIO pins.
29 917

modifications

Menu de navigation