Modifications

Sauter à la navigation Sauter à la recherche
472 octets ajoutés ,  13 décembre 2015 à 14:09
aucun résumé de modification
Ligne 2 : Ligne 2 :     
== La carte LCD + touch ==
 
== La carte LCD + touch ==
{{traduction}}
  −
   
L'extension LCD et senseur tactile est module qui prend place directement sur le PyBoard. Ce module offre un écran LCD graphique monochrome de 128x32 points ainsi qu'un senseur tactile à 12 canaux (dont 4 déjà raccorder sur les zones A, B, X, Y).
 
L'extension LCD et senseur tactile est module qui prend place directement sur le PyBoard. Ce module offre un écran LCD graphique monochrome de 128x32 points ainsi qu'un senseur tactile à 12 canaux (dont 4 déjà raccorder sur les zones A, B, X, Y).
   Ligne 29 : Ligne 27 :     
== Utiliser l'écran LCD ==
 
== Utiliser l'écran LCD ==
{{traduction}}
+
Pour débuter rapidement avec le LCD, essayez de saisir les commandes suivantes sur la ligne de commande MicroPython. Assurez-vous d'avoir attaché la carte d'extension LCD sur le PyBoard comme indiqué sur la photographie en début de cet article.
 
  −
To get started using the LCD, try the following at the MicroPython prompt. Make sure the LCD skin is attached to the pyboard as pictured at the top of this page.
      
  <nowiki>>>> import pyb
 
  <nowiki>>>> import pyb
 
>>> lcd = pyb.LCD('X')
 
>>> lcd = pyb.LCD('X')
 
>>> lcd.light(True)
 
>>> lcd.light(True)
>>> lcd.write('Hello uPy!\n')</nowiki>
+
>>> lcd.write('Salut uPy!\n')</nowiki>
   −
You can make a simple animation using the code:
+
Vous pouvez réaliser une animation simple en utilisant le code suivant:
    
  <nowiki>import pyb
 
  <nowiki>import pyb
Ligne 45 : Ligne 41 :  
for x in range(-80, 128):
 
for x in range(-80, 128):
 
     lcd.fill(0)
 
     lcd.fill(0)
     lcd.text('Hello uPy!', x, 10, 1)
+
     lcd.text('Salut uPy!', x, 10, 1)
 
     lcd.show()
 
     lcd.show()
 
     pyb.delay(25)</nowiki>
 
     pyb.delay(25)</nowiki>
    
== Utiliser le senseur tactile ==
 
== Utiliser le senseur tactile ==
To read the touch-sensor data you need to use the I2C bus. The MPR121 capacitive touch sensor has address 90.
+
Vous devez utiliser le bus I2C pour lire les données du senseur tactile. Le senseur capacitif MPR121 utilise l'adresse 90.
   −
To get started, try:
+
Vous pouvez saisir le code suivant pour lire les données du senseur:
 
  <nowiki>>>> import pyb
 
  <nowiki>>>> import pyb
 
>>> i2c = pyb.I2C(1, pyb.I2C.MASTER)
 
>>> i2c = pyb.I2C(1, pyb.I2C.MASTER)
Ligne 58 : Ligne 54 :  
>>> touch = i2c.mem_read(1, 90, 0)[0]</nowiki>
 
>>> touch = i2c.mem_read(1, 90, 0)[0]</nowiki>
   −
The first line above makes an I2C object, and the second line enables the 4 touch sensors. The third line reads the touch status and the {{fname|touch}} variable holds the state of the 4 touch buttons (A, B, X, Y).
+
La première ligne ci-dessus crée un objet I2C, la second active le senseur tactile à l'adresse.  
 +
 
 +
La troisième ligne lit le statut tactile du MPR121 et la variable {{fname|touch}} maintient l'état des 4 boutons tactiles (A, B, X, Y).
   −
There is a simple driver [http://micropython.org/resources/examples/mpr121.py here] which allows you to set the threshold and debounce parameters, and easily read the touch status and electrode voltage levels. Copy this script to your pyboard (either flash or SD card, in the top directory or {{fname|lib/}} directory) and then try:
+
Il existe un pilote [http://micropython.org/resources/examples/mpr121.py ici], il est simple d'emploi, permet de fixer le seuil de détection et effectue le déparasitage (pour ne pas avoir plusieurs activation successives). Il devient très aisé de lire le statut tactile et les niveaux de tension des électrodes. Copiez le script [http://micropython.org/resources/examples/ mpr121.py] sur votre PyBoard (soit sur la flash ou sur la carte SD, dans le répertoire racine ou un sous répertoire nommé {{fname|lib/}} directory) puis essayez ceci:
    
  <nowiki>>>> import pyb
 
  <nowiki>>>> import pyb
Ligne 70 : Ligne 68 :  
...</nowiki>
 
...</nowiki>
   −
This will continuously print out the touch status of all electrodes. Try touching each one in turn.
+
Ce qui affichera en continu (100 itérations uniquement) le statut tactile de toutes les électrodes. Essayez de toucher une-à-une chacune des électrodes.
   −
Note that if you put the LCD skin in the Y-position, then you need to initialise the I2C bus using:
+
Notez que si vous utilisez la carte LCD en "Y-position" alors vous devez initialiser le bus I2C en utilisant:
    
  <nowiki>>>> m = mpr121.MPR121(pyb.I2C(2, pyb.I2C.MASTER))</nowiki>
 
  <nowiki>>>> m = mpr121.MPR121(pyb.I2C(2, pyb.I2C.MASTER))</nowiki>
   −
There is also a demo which uses the LCD and the touch sensors together, and can be found [http://micropython.org/resources/examples/lcddemo.py here].
+
Il y a également une démo qui utilise le LCD et senseur tactile ensemble. Vous pourrez la trouver [http://micropython.org/resources/examples/lcddemo.py ici (lcddemo.py)].
    
== Classes ==
 
== Classes ==
29 917

modifications

Menu de navigation