Modifications

Sauter à la navigation Sauter à la recherche
2 655 octets ajoutés ,  28 septembre 2015 à 07:46
Ligne 69 : Ligne 69 :     
  <nowiki>sudo idle3 &</nowiki>
 
  <nowiki>sudo idle3 &</nowiki>
 +
 +
 +
'''2.'''  Select {{fname|File > New Window}} (''Fichier > Nouvelle fenêtre'') and enter the following code:
 +
 +
<nowiki>from sense_hat import SenseHat
 +
sense = SenseHat()
 +
sense.clear()
 +
 +
o = sense.get_orientation()
 +
pitch = o["pitch"]
 +
roll = o["roll"]
 +
yaw = o["yaw"]
 +
print("pitch %s roll %s yaw %s" % (pitch, roll, yaw))</nowiki>
 +
 +
'''3.''' Select {{fname|File > Save}} (''Fichier > Sauver sous'') and choose a file name for your program.
 +
 +
'''4.'''  Select {{fname|Run > Run module}} (''Executer > Exécuter module'').
 +
 +
'''5.''' If you see the error {{fname|IMU Init Failed, please run as root / use sudo}} on the last line in red, it means you haven't followed the instructions above. Close everything and go back to step 1.
 +
 +
Le message "IMU Init Failed" signifie "''Echec d'initialisation de l'IMU''".
 +
 +
'''6.''' You should now see something like this:
 +
 +
<nowiki>IMU Init Succeeded
 +
pitch 356.35723002363454 roll 303.4986602798494 yaw 339.19880231669873</nowiki>
 +
 +
La première ligne "IMU Init Succeeded" signifie que l'IMU à été initialisé avec succès.
 +
 +
'''7.'''  We don't need all the numbers after the decimal point so let's round them off. Just before the print("pitch %s roll %s yaw %s" % (pitch, roll, yaw)) line, add these lines below:
 +
 +
<nowiki>pitch = round(pitch, 1)
 +
roll = round(roll, 1)
 +
yaw = round(yaw, 1)</nowiki>
 +
 +
== Surveiller les mouvements ==
 +
It would be good to monitor the axis values changing during movements, so let's put your code into a {{fname|while}} loop and run it again:
 +
 +
<nowiki>while True:
 +
  o = sense.get_orientation()
 +
  pitch = o["pitch"]
 +
  roll = o["roll"]
 +
  yaw = o["yaw"]
 +
 +
  pitch = round(pitch, 1)
 +
  roll = round(roll, 1)
 +
  yaw = round(yaw, 1)
 +
 +
  print("pitch %s roll %s yaw %s" % (pitch, roll, yaw))<nowiki>
 +
 +
Move the Pi around in your hand and you should see the numbers changing. See if you can just make one axis change by moving only in the pitch direction for example. Do this for all three axes. Press {{fname|Ctrl - C}} to stop the program.
 +
 +
== Afficher l'orientation sur la matrice LED ==
 +
'''1.'''
 +
 +
Displaying something which is 3D in a 2D way is always a challenge, especially when your screen is only 8 x 8 pixels in size. One way which might work well is to have one LED for each axis and then make them move in different ways. For example:
 +
 +
* The pitch LED (''élévation'') could go up and down
 +
* The roll LED (''roulis, roulement'') could go side to side
 +
* The yaw LED (''embardée'') could chase around the edge
 +
 +
'''2.''' Here is a clever trick you can do. The table below shows the sequential LED numbers laid out in horizontal rows.
 +
 +
[[Fichier:RASP-SENSE-HAT-ASTRO-PI-Mouvement-20.jpg]]
 +
 
{{RASP-SENSE-HAT-ASTRO-PI-TRAILER}}
 
{{RASP-SENSE-HAT-ASTRO-PI-TRAILER}}
29 922

modifications

Menu de navigation