Modifications

Sauter à la navigation Sauter à la recherche
Ligne 65 : Ligne 65 :  
</syntaxhighlight>
 
</syntaxhighlight>
    +
== Enregistrement de la classe ==
 +
En fin de fichier {{fname|doggy.py}}, il suffit d'ajouter la ligne suivante pour enregistrer la classe {{fname|Hello}} dans les mouvements disponibles.
 +
 +
<syntaxhighlight lang="python">
 +
MovementsCls.append( Hello )
 +
</syntaxhighlight>
 +
 +
== Tester ==
 +
Maintenant, nous pouvons tester notre nouveau mouvement.
 +
 +
<syntaxhighlight lang="python">
 +
from doggy import *
 +
from pyb import delay
 +
d = Doggy()
 +
 +
# Dit bonjour (HELLO, H) avec la patte gauche
 +
d.prepare( 'H' )                                                           
 +
d.move( 'H' )                                                             
 +
 +
# Dit bonjour avec la patte droite (le faire deux fois)
 +
d.prepare( 'H', right=True )                                             
 +
d.move( 'H', right=True  )                                               
 +
d.move( 'H', right=True  )
 +
 +
# Mise au repos des moteurs
 +
d.release()
 +
</syntaxhighlight>
    
{{Hack-micropython-ServoRobot-TRAILER}}
 
{{Hack-micropython-ServoRobot-TRAILER}}
29 917

modifications

Menu de navigation