/ examples / st7735r_18tftshield_buttons.py
st7735r_18tftshield_buttons.py
 1  """
 2  This example will test out the display on the 1.8" TFT Shield
 3  """
 4  import time
 5  import board
 6  import displayio
 7  from adafruit_seesaw.tftshield18 import TFTShield18
 8  from adafruit_st7735r import ST7735R
 9  
10  # Release any resources currently in use for the displays
11  displayio.release_displays()
12  
13  ss = TFTShield18()
14  
15  spi = board.SPI()
16  tft_cs = board.D10
17  tft_dc = board.D8
18  
19  display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs)
20  
21  ss.tft_reset()
22  display = ST7735R(display_bus, width=160, height=128, rotation=90, bgr=True)
23  
24  ss.set_backlight(True)
25  
26  while True:
27      buttons = ss.buttons
28  
29      if buttons.right:
30          print("Button RIGHT!")
31  
32      if buttons.down:
33          print("Button DOWN!")
34  
35      if buttons.left:
36          print("Button LEFT!")
37  
38      if buttons.up:
39          print("Button UP!")
40  
41      if buttons.select:
42          print("Button SELECT!")
43  
44      if buttons.a:
45          print("Button A!")
46  
47      if buttons.b:
48          print("Button B!")
49  
50      if buttons.c:
51          print("Button C!")
52  
53      time.sleep(0.001)