-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtouchSetup.py
More file actions
32 lines (23 loc) · 778 Bytes
/
touchSetup.py
File metadata and controls
32 lines (23 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from ili9341 import Display
from machine import Pin, SPI
from xpt2046 import Touch
from micropython import const
TFT_CS_PIN = const(17)
TFT_RST_PIN = const(21)
TFT_DC_PIN = const(20)
XPT_CLK_PIN = const(2)
XPT_MOSI_PIN = const(3)
XPT_MISO_PIN = const(0)
XPT_CS_PIN = const(1)
XPT_INT = const(5)
def createMyDisplay():
spiTFT = SPI(0, baudrate=40000000)
display = Display(spiTFT,
dc=Pin(TFT_DC_PIN), cs=Pin(TFT_CS_PIN), rst=Pin(TFT_RST_PIN))
return display
def createXPT(touch_handler):
spiXPT = SPI(0, baudrate=1000000,
sck=Pin(XPT_CLK_PIN), mosi=Pin(XPT_MOSI_PIN), miso=Pin(XPT_MISO_PIN))
xpt = Touch(spiXPT, cs=Pin(XPT_CS_PIN), int_pin=Pin(XPT_INT),
int_handler=touch_handler)
return xpt