Modifications

Sauter à la navigation Sauter à la recherche
370 octets ajoutés ,  12 juillet 2016 à 11:10
Ligne 58 : Ligne 58 :     
== La boucle principale ==
 
== La boucle principale ==
Here we scan through the GPIOs to see if the buttons are pressed. We simply loop over the map we created earlier pulling out the GPIO number and the RGB tuple into k and v. If the GPIO is set False then the button is down. In which case we fill the background with the color referenced by v and then draw the text of the GPIO number.
+
Dans cette partie du code, nous allons scanner les GPIOS et tester les boutons pour voir si l'un d'entre-eux est pressé.  
 +
 
 +
Nous parcourons simplement la structure {{fname|button_map}} que nous avons précédemment créée. Nous allons récupérer des paires d'information (la clé et la valeur, respectivement appelés ''Key'' et ''Value''... ou ''k'' et ''v''). Cette paire d'information correspond à la broche GPIO et la couleur... tels qu'associés dans {{fname|button_map}} .
 +
 
 +
ulling out the GPIO number and the RGB tuple into k and v. If the GPIO is set False then the button is down. In which case we fill the background with the color referenced by v and then draw the text of the GPIO number.
    
Note the {{fname|sleep(0.1)}} call at the end of the loop. This simply ensures that our program is yielding and not running at 100% CPU usage.  
 
Note the {{fname|sleep(0.1)}} call at the end of the loop. This simply ensures that our program is yielding and not running at 100% CPU usage.  
29 917

modifications

Menu de navigation