7
7
import time
8
8
9
9
10
- _CMD_X_READ = const ( 0xD0 ) # 12 bit resolution
11
- _CMD_Y_READ = const ( 0x90 ) # 12 bit resolution
10
+ # _CMD_X_READ = 0xD0 # 12 bit resolution
11
+ # _CMD_Y_READ = 0x90 # 12 bit resolution
12
12
_CMD_Z1_READ = const (0xB0 )
13
13
_CMD_Z2_READ = const (0xC0 )
14
14
_MIN_RAW_COORD = const (10 )
@@ -40,6 +40,7 @@ def __init__(
40
40
device ,
41
41
touch_cal = None ,
42
42
startup_rotation = pointer_framework .lv .DISPLAY_ROTATION ._0 , # NOQA
43
+ swapxy = False ,
43
44
debug = False
44
45
):
45
46
self ._device = device
@@ -55,6 +56,12 @@ def __init__(
55
56
56
57
margin = max (min (self .margin , 100 ), 1 )
57
58
self .__margin = margin * margin
59
+ if swapxy : # some very popular/prolific esp32_2432S028R boards require this
60
+ self ._cmd_x_read = 0x90
61
+ self ._cmd_y_read = 0xD0
62
+ else :
63
+ self ._cmd_x_read = 0xD0
64
+ self ._cmd_y_read = 0x90
58
65
59
66
super ().__init__ (
60
67
touch_cal = touch_cal , startup_rotation = startup_rotation , debug = debug
@@ -112,8 +119,8 @@ def _normalize(self, x, y):
112
119
return x , y
113
120
114
121
def _get_raw (self ):
115
- x = self ._read_reg (_CMD_X_READ , 3 )
116
- y = self ._read_reg (_CMD_Y_READ , 3 )
122
+ x = self ._read_reg (self . _cmd_x_read , 3 )
123
+ y = self ._read_reg (self . _cmd_y_read , 3 )
117
124
if x > _MIN_RAW_COORD and y < _MAX_RAW_COORD : # touch pressed?
118
125
return x , y
119
126
else :
0 commit comments