Modifications

Sauter à la navigation Sauter à la recherche
729 octets ajoutés ,  21 juillet 2016 à 09:39
Ligne 152 : Ligne 152 :  
  import pibrella
 
  import pibrella
 
  help( pibrella.input.a )
 
  help( pibrella.input.a )
 +
 +
=== Tester les entrées ===
 +
Voici un petit bout de code Python qui vous permettra de tester facilement toutes les entrées sur un PiBrella.
 +
 +
<syntaxhighlight lang="python">
 +
inputs = { pibrella.input.a : 'a', pibrella.input.b : 'b', pibrella.input.c : 'c', pibrella.input.d : 'd', pibrella.button : 'BUTTON' }
 +
 +
def testinputs():
 +
  # Vérifie chacune des entrées (celles enregsitrées dans le dictionnaire inputs)
 +
  # k sera l'objet pibrella.input.xxx et v le nom de l'entree correspondante
 +
  for k, v in inputs.items():
 +
      # SI l'entree est activee ALORS afficher son nom
 +
      if k.is_high():
 +
          print( v )
 +
 +
# boucle infinie de test (presser ctrl+c pour arrêter)
 +
while True:
 +
  testinputs()
 +
</syntaxhighlight>
    
=== Brancher un Switch Magnétique ===
 
=== Brancher un Switch Magnétique ===
29 836

modifications

Menu de navigation