/ examples / featherwing_joy_simpletest.py
featherwing_joy_simpletest.py
 1  """This example zeros the joystick, and prints when the joystick moves
 2     or the buttons are pressed."""
 3  import time
 4  from adafruit_featherwing import joy_featherwing
 5  
 6  wing = joy_featherwing.JoyFeatherWing()
 7  last_x = 0
 8  last_y = 0
 9  
10  while True:
11      x, y = wing.joystick
12      if (abs(x - last_x) > 3) or (abs(y - last_y) > 3):
13          last_x = x
14          last_y = y
15          print(x, y)
16      if wing.button_a:
17          print("Button A!")
18      if wing.button_b:
19          print("Button B!")
20      if wing.button_x:
21          print("Button X!")
22      if wing.button_y:
23          print("Button Y!")
24      if wing.button_select:
25          print("Button SELECT!")
26      time.sleep(0.01)