Modifications

Sauter à la navigation Sauter à la recherche
aucun résumé de modification
Ligne 4 : Ligne 4 :     
== Le joystick ==
 
== Le joystick ==
{{bloc-etroit|text=The Sense HAT joystick is mapped to the four keyboard cursor keys, with the joystick middle-click being mapped to the Return key. This means that moving the joystick has exactly the same effect as pressing those keys on the keyboard. Remember that the down direction is with the HDMI port facing downwards.}}
+
{{bloc-etroit|text=Le joystick du Sense Hat est mis en correspondance (ont dit "''map''" en anglais) avec les 4 touches de déplacement du curseur, le click du joystick presse la touche "retour clavier" (dite "''Return''" ou "''Enter''" en anglais). Le joystick du Hat Sense se ''comporte'' donc comme ''un clavier''. Rappelez vous que la direction 'vers le bas' se trouve face au port HDMI.}}
    
[[fichier:RASP-SENSE-HAT-ASTRO-PI-Joystick-01.jpg]]
 
[[fichier:RASP-SENSE-HAT-ASTRO-PI-Joystick-01.jpg]]
Ligne 10 : Ligne 10 :  
== Keyboard Mapping ==
 
== Keyboard Mapping ==
 
{{bloc-etroit|text=
 
{{bloc-etroit|text=
"Keyboard Mapping" que nous traduirons par "mappage clavier" qui est pris en charge par un pilote et transforme l'utilisation du joystick en simulation d'activation sur le clavier du PC.
+
"Keyboard Mapping" que nous traduirons par "mappage clavier" (''correspondance clavier'') est pris en charge par un pilote et transforme l'utilisation du joystick en simulation d'activation sur le clavier du PC.
    
L'utilisation d'un pilote et du "Keyboard Mapping" est plus que pratique, votre programme n'a pas besoin de savoir comment lire l'état du joystick... il a juste besoin de détecter les touches pressées sur le clavier (et cela, tous les programmes savent le faire).   
 
L'utilisation d'un pilote et du "Keyboard Mapping" est plus que pratique, votre programme n'a pas besoin de savoir comment lire l'état du joystick... il a juste besoin de détecter les touches pressées sur le clavier (et cela, tous les programmes savent le faire).   
 
}}
 
}}
   −
'''1.''' Open '''Python 3''' from a terminal window as {{fname|sudo}} by typing:
+
'''1.''' Ouvrez '''Python 3''' depuis une fenêtre terminal et utilisez la commande suivante avec {{fname|sudo}}:
    
  <nowiki>sudo idle3 &</nowiki>
 
  <nowiki>sudo idle3 &</nowiki>
   −
'''2.''' A Python Shell window will now appear.
+
'''2.''' Une fenêtre de commande Python va apparaître.
   −
'''3.''' Select {{fname|File > New Window}}.
+
'''3.''' Sélectionnez l'option {{fname|File > New Window}} (Fichier > Nouvelle fenêtre).
    
'''4.''' Et tapez le code suivant:
 
'''4.''' Et tapez le code suivant:
Ligne 44 : Ligne 44 :  
             print("AU REVOIR")</nowiki>
 
             print("AU REVOIR")</nowiki>
   −
'''5.''' Select {{fname|File > Save}} and choose a file name for your program.
+
'''5.''' Sélectionnez {{fname|File > Save}} (pour "Fichier > Sauver") et choissisez un nom pour votre programme.
   −
'''6.''' Then select {{fname|Run > Run module}}.<br /><br />Note that we are using the {{underline|pygame}} Python module to detect the key presses.
+
'''6.''' Sélectionnez ensuite {{fname|Run > Run module}} (pour "Executer > Exécutez module").<br /><br />Notez que nous utilisons le module Python {{underline|pygame}} pour détecter les touches pressées.
   −
'''7.''' A blank window will appear. Use the mouse to move it to one side of your screen so that the Python Shell window is also visible.
+
'''7.''' Une fenêtre va apparaître. Utilisez la souris pour bouger cette fenêtre sur le côté de votre bureau de façon à pouvoir voir la fenêtre du Shell Python.
   −
'''8.''' Keep the blank window selected but move the mouse over it, press and release some keys on the keyboard and waggle the Sense HAT joystick. Try pressing and holding a key for a moment and then releasing it a few seconds later. You should notice that two events occur when you do this: one for the key going down, and another for the key being released. For this program you will only use the '''KEY DOWN''' event.<small><br />KEY DOWN signifie FLECHE BAS</small>
+
'''8.''' Gardez le nouvelle fenêtre sélectionnée et bougez la souris au dessus de celle-ci, pressez et relachez des touches sur le clavier et jouez avec le joystick du Sense Hat. Essayez de presser et maintenir une touche enfoncé pendant un moment puis la relâcher quelques secondes. Vous pouvez noter que deux événements ("''EVENT'' en anglais) se passent durant ce temps: un événement lorsque la touche est enfoncée, et un autre événement lorsque la touche est relâchée. Dans ce programme vous allez uniquement utiliser l'événement '''KEY DOWN'''.<small><br />KEY DOWN signifie FLECHE BAS</small>
   −
'''9.''' Click the {{fname|x}} in the corner of the blank pygame window. You should see the {{fname|AU REVOIR}} message appear in the Python Shell window but the blank window does not close.
+
'''9.''' Cliquez sur le {{fname|x}} dans coin supérieur droit de la fenêtre Pygame (dans laquelle nous n'affichons rien). Vous devriez voir le message {{fname|AU REVOIR}} apparâitre dans la fenêtre Shell Python Shell (mais la fenêtre vide ne se ferme pas).
    
We're consuming the pygame event queue using the {{fname|for event in pygame.event.get():}} syntax. This will loop through all keyboard and mouse events that occur. Inside the loop, we display what the event was by using {{fname|print(event)}} and then test to see if the event type is {{fname|QUIT}}. If it is, we set {{fname|running}} to {{fname|False}} which causes the {{fname|while}} loop to end and the program to finish. The program should print a line of text in the Python Shell window whenever we move the mouse, click the mouse, and press or release a keyboard key.
 
We're consuming the pygame event queue using the {{fname|for event in pygame.event.get():}} syntax. This will loop through all keyboard and mouse events that occur. Inside the loop, we display what the event was by using {{fname|print(event)}} and then test to see if the event type is {{fname|QUIT}}. If it is, we set {{fname|running}} to {{fname|False}} which causes the {{fname|while}} loop to end and the program to finish. The program should print a line of text in the Python Shell window whenever we move the mouse, click the mouse, and press or release a keyboard key.
29 918

modifications

Menu de navigation