Modifications

Sauter à la navigation Sauter à la recherche
Ligne 456 : Ligne 456 :  
{{traduction}}
 
{{traduction}}
   −
You can find out the orientation of the Sense HAT using the sense.get_orientation() method:
+
Vous pouvez obtenir l'orientation du Sense Hat en appelant la méthode {{fname|sense.get_orientation()}}:
    
  <nowiki>pitch, roll, yaw = sense.get_orientation().values()</nowiki>
 
  <nowiki>pitch, roll, yaw = sense.get_orientation().values()</nowiki>
   −
This would get the three orientation values (measured in degrees) and store them as the three variables {{fname|pitch}}, {{fname|roll}} et {{fname|yaw}}. The {{fname|.values()}} obtains the three values so that they can be stored separately.
+
Cela donne les trois valeurs d'orientation (mesuré en degrés) et stocke ces valeurs dans trois variables respectivement nommées {{fname|pitch}}, {{fname|roll}} et {{fname|yaw}}. La partie {{fname|.values()}} de l'appel obtient les 3 valeurs ce qui permet de les stocker séparéments.
   −
'''1.''' You can explore these values with a simple program:
+
'''1.''' Vous pouvez découvrir et explorer ces valeurs à l'aide du programme suivant:
    
  <nowiki>from sense_hat import SenseHat
 
  <nowiki>from sense_hat import SenseHat
Ligne 470 : Ligne 470 :  
while True:
 
while True:
 
     pitch, roll, yaw = sense.get_orientation().values()
 
     pitch, roll, yaw = sense.get_orientation().values()
     print("pitch=%s, roll=%s, yaw=%s" % (pitch,yaw,roll))</nowiki>
+
     print("Elevation/pitch=%s, Roulis/roll=%s, Embardee/yaw=%s" % (pitch,yaw,roll))</nowiki>
   −
'''2.''' Click File -- Save As, give your program a name e.g. {{fname|orientation.py}}, then press F5 to run.
+
'''2.''' Cliquer sur "File -- Save As" (''Fichier -- Sauver comme'') et donner un nom au programme - exemple {{fname|orientation.py}}. Pressez '''F5''' pour exécuter le programme.
   −
{{tmbox|Note: When using the movement sensors it is important to poll them often in a tight loop. If you poll them too slowly, for example with time.sleep(0.5) in your loop, you will see strange results. This is because the code behind needs lots of measurements in order to successfully combine the data coming from the gyroscope, accelerometer and magnetometer.}}
+
{{tmbox|Note: Lorsque l'on utilise des senseurs de mouvement, il est important de les interroger souvent à l'aide d'une boucle très courte. Par exemple, une pause de 0.5 seconde dans votre boucle provoquera un affichage un affichage bizarre. C'est parce que le code de la bibliothèque à besoin de faire beaucoup de mesure de façon à parfaitement combiner les données provenant du gyroscope, accelérometre et du magnétomètre.}}
   −
'''3.''' Another way to detect orientation is to use the {{fname|sense.get_accelerometer_raw()}} method which tells you the amount of g-force acting on each axis. If any axis has ±1g then you know that axis is pointing downwards.
+
'''3.''' Une autre façon de détecter l'orientation est d'utiliser la méthode {{fname|sense.get_accelerometer_raw()}} qui vous indique la quantité de force-g agissant sur les 3 axes. Si n'importe quel axe indique une valeur d'environ 1g alors cet axe pointe vers le bas.
   −
In this example, the amount of gravitational acceleration for each axis (x, y, and z) is extracted and is then rounded to the nearest whole number:
+
Dans cette exemple, la 'accélération gravitationnelle (celle qui nous tient au sol) est quantifié pour chaque axe  (x, y et z) puis arrondi au nombre entier le plus proche:
    
  <nowiki>from sense_hat import SenseHat
 
  <nowiki>from sense_hat import SenseHat
Ligne 484 : Ligne 484 :  
sense = SenseHat()
 
sense = SenseHat()
   −
while True:
+
while True: # boucle inifinie
 
     x, y, z = sense.get_accelerometer_raw().values()
 
     x, y, z = sense.get_accelerometer_raw().values()
   Ligne 493 : Ligne 493 :  
     print("x=%s, y=%s, z=%s" % (x, y, z))</nowiki>
 
     print("x=%s, y=%s, z=%s" % (x, y, z))</nowiki>
   −
'''4.''' Click File -- Save As, give your program a name e.g. {{fname|acceleration.py}}, then press F5 to run.
+
'''4.''' Cliquer sur "File -- Save As" (''Fichier -- Sauver comme'') et donner un nom au programme - par exemple {{fname|acceleration.py}}. Ensuite, presser F5 pour exécuter le programme.
   −
As you turn the screen you should see the values for x and y change between -1 and 1. If you place the Pi flat or turn it upside down, the z axis will be 1 and then -1.
+
En tournant l'écran, vous devriez vous les valeurs de x et y osciller entre -1 et 1. Si vous placez le Pi à plat (ou retourner votre Pi), l'axe Z afficher la valeur 1 puis -1.
   −
'''5.''' If we know which way round the Raspberry Pi is, then we can use that information to set the orientation of the LED matrix. First you would display something on the matrix, then continually check which way round the board is, and use that to update the orientation of the display.
+
'''5.''' Si vous connaissez l'orientation de votre Pi... alors vous pouvez modifier l'orientation d'affichage de la matrice de sorte que le texte soit toujours lisible. C'est exactement comme cela que votre smartphone détecte le changement d'orientation pour faire une rotation de l'écran.<br />Pour commencer, vous afficher quelque-chose sur la matrice puis vous vérifiez constalement l'orientation de la carte. Vous utiliser cette information d'orientation pour faire une mise-à-jour de l'orientation de l'afficheur.
    
  <nowiki>from sense_hat import SenseHat
 
  <nowiki>from sense_hat import SenseHat
Ligne 522 : Ligne 522 :       −
'''6.''' Click File -- Save As, give your program a name e.g. {{fname|rotating_letter.py}}, then press F5 to run.
+
'''6.''' Cliquer sur "File -- Save As" (''Fichier -- Sauver comme'') et donner un nom au programme - {{fname|rotating_letter.py}} par exemple (signifiant ''lettre tournante''). Pressez ensuite '''F5''' pour exécuter le programme.
    
In this program you are using an {{fname|if, elif, else}} structure to check which way round the Raspberry Pi is. The {{fname|if}} and {{fname|elif}} test three of the orientations, and if the orientation doesn't match any of these then the program assumes it is the "right" way round. By using the {{fname|else}} statement we also catch all those other situations, like when the board is at 45 degrees or sitting level.
 
In this program you are using an {{fname|if, elif, else}} structure to check which way round the Raspberry Pi is. The {{fname|if}} and {{fname|elif}} test three of the orientations, and if the orientation doesn't match any of these then the program assumes it is the "right" way round. By using the {{fname|else}} statement we also catch all those other situations, like when the board is at 45 degrees or sitting level.
29 917

modifications

Menu de navigation