77import time
88
99
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
1212_CMD_Z1_READ = const (0xB0 )
1313_CMD_Z2_READ = const (0xC0 )
1414_MIN_RAW_COORD = const (10 )
@@ -40,6 +40,7 @@ def __init__(
4040 device ,
4141 touch_cal = None ,
4242 startup_rotation = pointer_framework .lv .DISPLAY_ROTATION ._0 , # NOQA
43+ swapxy = False ,
4344 debug = False
4445 ):
4546 self ._device = device
@@ -55,6 +56,12 @@ def __init__(
5556
5657 margin = max (min (self .margin , 100 ), 1 )
5758 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
5865
5966 super ().__init__ (
6067 touch_cal = touch_cal , startup_rotation = startup_rotation , debug = debug
@@ -112,8 +119,8 @@ def _normalize(self, x, y):
112119 return x , y
113120
114121 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 )
117124 if x > _MIN_RAW_COORD and y < _MAX_RAW_COORD : # touch pressed?
118125 return x , y
119126 else :
0 commit comments