Modifications

Sauter à la navigation Sauter à la recherche
284 octets ajoutés ,  16 mars 2015 à 15:19
Ligne 64 : Ligne 64 :  
{{traduction}}
 
{{traduction}}
   −
Let’s step through the details of what is happening with the switch callback. When you register a function with {{fname|sw.callback()}}, the switch sets up an external interrupt trigger (falling edge) on the pin that the switch is connected to. This means that the microcontroller will listen on the pin for any changes, and the following will occur:
+
Abordons ensemble les détails de ce qui se passe avec la fonction de rappel (''callback'') du switch. Lorsque vous enregistrez une fonction avec {{fname|sw.callback()}}, l'objet ''switch'' configure le déclenchement d'une interruption (''falling edge'' sur le flanc descendant du signal) sur la broche à laquelle est attaché le bouton utilisateur. Cela signifie que le microcontroleur surveillera les changements d'état de la broche, et voici ce qu'il se passe:
   −
# When the switch is pressed a change occurs on the pin (the pin goes from low to high), and the microcontroller registers this change.
+
# Lorsque le bouton (''switch'') est pressé, il y a un changement de signal sur la broche (la broche passe du niveau BAS au niveau HAUT) et le microcontroleur détecte ce changement.
# The microcontroller finishes executing the current machine instruction, stops execution, and saves its current state (pushes the registers on the stack). This has the effect of pausing any code, for example your running Python script.
+
# Le microcontroleur termine l'exécution de l'instruction machine en cours, stop l'exécution du programme et sauve son état actuel (pousse l'état des registres sur la pile). Cela à pour éffet de suspendre l'exécution de votre code (par exemple  for example your running Python script.
# The microcontroller starts executing the special interrupt handler associated with the switch’s external trigger. This interrupt handler get the function that you registered with sw.callback() and executes it.
+
# The microcontrolleur commence à exécuter le code de gestion de l'intérruption (cela s'appelle "''interrupt handler''") associé avec le bouton poussoir. Le code de gestion de l'interruption retrouve la fonction que vous avez enregistré à l'aide sw.callback() et l'exécute.
 
# Your callback function is executed until it finishes, returning control to the switch interrupt handler.
 
# Your callback function is executed until it finishes, returning control to the switch interrupt handler.
 
# The switch interrupt handler returns, and the microcontroller is notified that the interrupt has been dealt with.
 
# The switch interrupt handler returns, and the microcontroller is notified that the interrupt has been dealt with.
29 836

modifications

Menu de navigation