35
35
36
36
37
37
__version__ = "0.0.0-auto.0"
38
- __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_stmpe610 .git"
38
+ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_STMPE610 .git"
39
39
40
40
41
41
42
42
_STMPE_ADDR = const (0x41 )
43
43
_STMPE_VERSION = const (0x0811 )
44
44
45
- STMPE_SYS_CTRL1 = const (0x03 )
46
- STMPE_SYS_CTRL1_RESET = const (0x02 )
47
- STMPE_SYS_CTRL2 = const (0x04 )
48
-
49
- STMPE_TSC_CTRL = const (0x40 )
50
- STMPE_TSC_CTRL_EN = const (0x01 )
51
- STMPE_TSC_CTRL_XYZ = const (0x00 )
52
- STMPE_TSC_CTRL_XY = const (0x02 )
53
-
54
- STMPE_INT_CTRL = const (0x09 )
55
- STMPE_INT_CTRL_POL_HIGH = const (0x04 )
56
- STMPE_INT_CTRL_POL_LOW = const (0x00 )
57
- STMPE_INT_CTRL_EDGE = const (0x02 )
58
- STMPE_INT_CTRL_LEVEL = const (0x00 )
59
- STMPE_INT_CTRL_ENABLE = const (0x01 )
60
- STMPE_INT_CTRL_DISABLE = const (0x00 )
61
-
62
-
63
-
64
- STMPE_INT_EN = const (0x0A )
65
- STMPE_INT_EN_TOUCHDET = const (0x01 )
66
- STMPE_INT_EN_FIFOTH = const (0x02 )
67
- STMPE_INT_EN_FIFOOF = const (0x04 )
68
- STMPE_INT_EN_FIFOFULL = const (0x08 )
69
- STMPE_INT_EN_FIFOEMPTY = const (0x10 )
70
- STMPE_INT_EN_ADC = const (0x40 )
71
- STMPE_INT_EN_GPIO = const (0x80 )
72
-
73
- STMPE_INT_STA = const (0x0B )
74
- STMPE_INT_STA_TOUCHDET = const (0x01 )
75
-
76
- STMPE_ADC_CTRL1 = const (0x20 )
77
- STMPE_ADC_CTRL1_12BIT = const (0x08 )
78
- STMPE_ADC_CTRL1_10BIT = const (0x00 )
79
-
80
- STMPE_ADC_CTRL2 = const (0x21 )
81
- STMPE_ADC_CTRL2_1_625MHZ = const (0x00 )
82
- STMPE_ADC_CTRL2_3_25MHZ = const (0x01 )
83
- STMPE_ADC_CTRL2_6_5MHZ = const (0x02 )
84
-
85
- STMPE_TSC_CFG = const (0x41 )
86
- STMPE_TSC_CFG_1SAMPLE = const (0x00 )
87
- STMPE_TSC_CFG_2SAMPLE = const (0x40 )
88
- STMPE_TSC_CFG_4SAMPLE = const (0x80 )
89
- STMPE_TSC_CFG_8SAMPLE = const (0xC0 )
90
- STMPE_TSC_CFG_DELAY_10US = const (0x00 )
91
- STMPE_TSC_CFG_DELAY_50US = const (0x08 )
92
- STMPE_TSC_CFG_DELAY_100US = const (0x10 )
93
- STMPE_TSC_CFG_DELAY_500US = const (0x18 )
94
- STMPE_TSC_CFG_DELAY_1MS = const (0x20 )
95
- STMPE_TSC_CFG_DELAY_5MS = const (0x28 )
96
- STMPE_TSC_CFG_DELAY_10MS = const (0x30 )
97
- STMPE_TSC_CFG_DELAY_50MS = const (0x38 )
98
- STMPE_TSC_CFG_SETTLE_10US = const (0x00 )
99
- STMPE_TSC_CFG_SETTLE_100US = const (0x01 )
100
- STMPE_TSC_CFG_SETTLE_500US = const (0x02 )
101
- STMPE_TSC_CFG_SETTLE_1MS = const (0x03 )
102
- STMPE_TSC_CFG_SETTLE_5MS = const (0x04 )
103
- STMPE_TSC_CFG_SETTLE_10MS = const (0x05 )
104
- STMPE_TSC_CFG_SETTLE_50MS = const (0x06 )
105
- STMPE_TSC_CFG_SETTLE_100MS = const (0x07 )
106
-
107
- STMPE_FIFO_TH = const (0x4A )
108
-
109
- STMPE_FIFO_SIZE = const (0x4C )
110
-
111
- STMPE_FIFO_STA = const (0x4B )
112
- STMPE_FIFO_STA_RESET = const (0x01 )
113
- STMPE_FIFO_STA_OFLOW = const (0x80 )
114
- STMPE_FIFO_STA_FULL = const (0x40 )
115
- STMPE_FIFO_STA_EMPTY = const (0x20 )
116
- STMPE_FIFO_STA_THTRIG = const (0x10 )
117
-
118
- STMPE_TSC_I_DRIVE = const (0x58 )
119
- STMPE_TSC_I_DRIVE_20MA = const (0x00 )
120
- STMPE_TSC_I_DRIVE_50MA = const (0x01 )
121
-
122
- STMPE_TSC_DATA_X = const (0x4D )
123
- STMPE_TSC_DATA_Y = const (0x4F )
124
- STMPE_TSC_FRACTION_Z = const (0x56 )
125
-
126
- STMPE_GPIO_SET_PIN = const (0x10 )
127
- STMPE_GPIO_CLR_PIN = const (0x11 )
128
- STMPE_GPIO_DIR = const (0x13 )
129
- STMPE_GPIO_ALT_FUNCT = const (0x17 )
45
+ _STMPE_SYS_CTRL1 = const (0x03 )
46
+ _STMPE_SYS_CTRL1_RESET = const (0x02 )
47
+ _STMPE_SYS_CTRL2 = const (0x04 )
48
+
49
+ _STMPE_TSC_CTRL = const (0x40 )
50
+ _STMPE_TSC_CTRL_EN = const (0x01 )
51
+ _STMPE_TSC_CTRL_XYZ = const (0x00 )
52
+ _STMPE_TSC_CTRL_XY = const (0x02 )
53
+
54
+ _STMPE_INT_CTRL = const (0x09 )
55
+ _STMPE_INT_CTRL_POL_HIGH = const (0x04 )
56
+ _STMPE_INT_CTRL_POL_LOW = const (0x00 )
57
+ _STMPE_INT_CTRL_EDGE = const (0x02 )
58
+ _STMPE_INT_CTRL_LEVEL = const (0x00 )
59
+ _STMPE_INT_CTRL_ENABLE = const (0x01 )
60
+ _STMPE_INT_CTRL_DISABLE = const (0x00 )
61
+
62
+
63
+
64
+ _STMPE_INT_EN = const (0x0A )
65
+ _STMPE_INT_EN_TOUCHDET = const (0x01 )
66
+ _STMPE_INT_EN_FIFOTH = const (0x02 )
67
+ _STMPE_INT_EN_FIFOOF = const (0x04 )
68
+ _STMPE_INT_EN_FIFOFULL = const (0x08 )
69
+ _STMPE_INT_EN_FIFOEMPTY = const (0x10 )
70
+ _STMPE_INT_EN_ADC = const (0x40 )
71
+ _STMPE_INT_EN_GPIO = const (0x80 )
72
+
73
+ _STMPE_INT_STA = const (0x0B )
74
+ _STMPE_INT_STA_TOUCHDET = const (0x01 )
75
+
76
+ _STMPE_ADC_CTRL1 = const (0x20 )
77
+ _STMPE_ADC_CTRL1_12BIT = const (0x08 )
78
+ _STMPE_ADC_CTRL1_10BIT = const (0x00 )
79
+
80
+ _STMPE_ADC_CTRL2 = const (0x21 )
81
+ _STMPE_ADC_CTRL2_1_625MHZ = const (0x00 )
82
+ _STMPE_ADC_CTRL2_3_25MHZ = const (0x01 )
83
+ _STMPE_ADC_CTRL2_6_5MHZ = const (0x02 )
84
+
85
+ _STMPE_TSC_CFG = const (0x41 )
86
+ _STMPE_TSC_CFG_1SAMPLE = const (0x00 )
87
+ _STMPE_TSC_CFG_2SAMPLE = const (0x40 )
88
+ _STMPE_TSC_CFG_4SAMPLE = const (0x80 )
89
+ _STMPE_TSC_CFG_8SAMPLE = const (0xC0 )
90
+ _STMPE_TSC_CFG_DELAY_10US = const (0x00 )
91
+ _STMPE_TSC_CFG_DELAY_50US = const (0x08 )
92
+ _STMPE_TSC_CFG_DELAY_100US = const (0x10 )
93
+ _STMPE_TSC_CFG_DELAY_500US = const (0x18 )
94
+ _STMPE_TSC_CFG_DELAY_1MS = const (0x20 )
95
+ _STMPE_TSC_CFG_DELAY_5MS = const (0x28 )
96
+ _STMPE_TSC_CFG_DELAY_10MS = const (0x30 )
97
+ _STMPE_TSC_CFG_DELAY_50MS = const (0x38 )
98
+ _STMPE_TSC_CFG_SETTLE_10US = const (0x00 )
99
+ _STMPE_TSC_CFG_SETTLE_100US = const (0x01 )
100
+ _STMPE_TSC_CFG_SETTLE_500US = const (0x02 )
101
+ _STMPE_TSC_CFG_SETTLE_1MS = const (0x03 )
102
+ _STMPE_TSC_CFG_SETTLE_5MS = const (0x04 )
103
+ _STMPE_TSC_CFG_SETTLE_10MS = const (0x05 )
104
+ _STMPE_TSC_CFG_SETTLE_50MS = const (0x06 )
105
+ _STMPE_TSC_CFG_SETTLE_100MS = const (0x07 )
106
+
107
+ _STMPE_FIFO_TH = const (0x4A )
108
+
109
+ _STMPE_FIFO_SIZE = const (0x4C )
110
+
111
+ _STMPE_FIFO_STA = const (0x4B )
112
+ _STMPE_FIFO_STA_RESET = const (0x01 )
113
+ _STMPE_FIFO_STA_OFLOW = const (0x80 )
114
+ _STMPE_FIFO_STA_FULL = const (0x40 )
115
+ _STMPE_FIFO_STA_EMPTY = const (0x20 )
116
+ _STMPE_FIFO_STA_THTRIG = const (0x10 )
117
+
118
+ _STMPE_TSC_I_DRIVE = const (0x58 )
119
+ _STMPE_TSC_I_DRIVE_20MA = const (0x00 )
120
+ _STMPE_TSC_I_DRIVE_50MA = const (0x01 )
121
+
122
+ _STMPE_TSC_DATA_X = const (0x4D )
123
+ _STMPE_TSC_DATA_Y = const (0x4F )
124
+ _STMPE_TSC_FRACTION_Z = const (0x56 )
125
+
126
+ _STMPE_GPIO_SET_PIN = const (0x10 )
127
+ _STMPE_GPIO_CLR_PIN = const (0x11 )
128
+ _STMPE_GPIO_DIR = const (0x13 )
129
+ _STMPE_GPIO_ALT_FUNCT = const (0x17 )
130
130
131
131
132
132
@@ -140,27 +140,28 @@ def __init__(self):
140
140
version = self .get_version
141
141
if _STMPE_VERSION != version :
142
142
raise RuntimeError ('Failed to find STMPE610! Chip Version 0x%x' % version )
143
- self ._write_register_byte (STMPE_SYS_CTRL1 , STMPE_SYS_CTRL1_RESET )
143
+ self ._write_register_byte (_STMPE_SYS_CTRL1 , _STMPE_SYS_CTRL1_RESET )
144
144
time .sleep (.001 )
145
145
146
146
147
- self ._write_register_byte (STMPE_SYS_CTRL2 , 0x0 ) # turn on clocks!
147
+ self ._write_register_byte (_STMPE_SYS_CTRL2 , 0x0 ) # turn on clocks!
148
148
self ._write_register_byte (
149
- STMPE_TSC_CTRL , STMPE_TSC_CTRL_XYZ | STMPE_TSC_CTRL_EN ) # XYZ and enable!
150
- self ._write_register_byte (STMPE_INT_EN , STMPE_INT_EN_TOUCHDET )
149
+ _STMPE_TSC_CTRL , _STMPE_TSC_CTRL_XYZ | _STMPE_TSC_CTRL_EN ) # XYZ and enable!
150
+ self ._write_register_byte (_STMPE_INT_EN , _STMPE_INT_EN_TOUCHDET )
151
151
self ._write_register_byte (
152
- STMPE_ADC_CTRL1 , STMPE_ADC_CTRL1_10BIT | (0x6 << 4 )) # 96 clocks per conversion
153
- self ._write_register_byte (STMPE_ADC_CTRL2 , STMPE_ADC_CTRL2_6_5MHZ )
152
+ _STMPE_ADC_CTRL1 , _STMPE_ADC_CTRL1_10BIT | (0x6 << 4 )) # 96 clocks per conversion
153
+ self ._write_register_byte (_STMPE_ADC_CTRL2 , _STMPE_ADC_CTRL2_6_5MHZ )
154
154
self ._write_register_byte (
155
- STMPE_TSC_CFG , STMPE_TSC_CFG_4SAMPLE | STMPE_TSC_CFG_DELAY_1MS
156
- | STMPE_TSC_CFG_SETTLE_5MS )
157
- self ._write_register_byte (STMPE_TSC_FRACTION_Z , 0x6 )
158
- self ._write_register_byte (STMPE_FIFO_TH , 1 )
159
- self ._write_register_byte (STMPE_FIFO_STA , STMPE_FIFO_STA_RESET )
160
- self ._write_register_byte (STMPE_FIFO_STA , 0 ) # unreset
161
- self ._write_register_byte (STMPE_TSC_I_DRIVE , STMPE_TSC_I_DRIVE_50MA )
162
- self ._write_register_byte (STMPE_INT_STA , 0xFF ) # reset all ints
163
- self ._write_register_byte (STMPE_INT_CTRL , STMPE_INT_CTRL_POL_HIGH | STMPE_INT_CTRL_ENABLE )
155
+ _STMPE_TSC_CFG , _STMPE_TSC_CFG_4SAMPLE | _STMPE_TSC_CFG_DELAY_1MS
156
+ | _STMPE_TSC_CFG_SETTLE_5MS )
157
+ self ._write_register_byte (_STMPE_TSC_FRACTION_Z , 0x6 )
158
+ self ._write_register_byte (_STMPE_FIFO_TH , 1 )
159
+ self ._write_register_byte (_STMPE_FIFO_STA , _STMPE_FIFO_STA_RESET )
160
+ self ._write_register_byte (_STMPE_FIFO_STA , 0 ) # unreset
161
+ self ._write_register_byte (_STMPE_TSC_I_DRIVE , _STMPE_TSC_I_DRIVE_50MA )
162
+ self ._write_register_byte (_STMPE_INT_STA , 0xFF ) # reset all ints
163
+ self ._write_register_byte (
164
+ _STMPE_INT_CTRL , _STMPE_INT_CTRL_POL_HIGH | _STMPE_INT_CTRL_ENABLE )
164
165
165
166
def read_data (self ):
166
167
"""Request next stored reading - return tuple containing (x,y,pressure) """
@@ -173,7 +174,7 @@ def read_data(self):
173
174
pressure = d_4
174
175
# reset all ints (not sure what this does)
175
176
if self .buffer_empty :
176
- self ._write_register_byte (STMPE_INT_STA , 0xFF )
177
+ self ._write_register_byte (_STMPE_INT_STA , 0xFF )
177
178
return (x_loc , y_loc , pressure )
178
179
179
180
def _read_byte (self , register ):
@@ -192,7 +193,6 @@ def _write_register_byte(self, register, value):
192
193
raise NotImplementedError
193
194
194
195
195
- # pylint: disable=unused-variable
196
196
@property
197
197
def touches (self ):
198
198
"""
@@ -205,7 +205,6 @@ def touches(self):
205
205
point = {'x' :x_loc , 'y' :y_loc , 'pressure' :pressure }
206
206
touchpoints .append (point )
207
207
return touchpoints
208
- # pylint: enable=unused-variable
209
208
210
209
211
210
@property
@@ -220,19 +219,19 @@ def get_version(self):
220
219
@property
221
220
def touched (self ):
222
221
"Report if any touches have been detectd"
223
- touch = self ._read_byte (STMPE_TSC_CTRL )& 0x80
222
+ touch = self ._read_byte (_STMPE_TSC_CTRL )& 0x80
224
223
return touch == 0x80
225
224
226
225
227
226
@property
228
227
def buffer_size (self ):
229
228
"The amount of touch data in the buffer"
230
- return self ._read_byte (STMPE_FIFO_SIZE )
229
+ return self ._read_byte (_STMPE_FIFO_SIZE )
231
230
232
231
@property
233
232
def buffer_empty (self ):
234
233
"Buffer empty status"
235
- empty = self ._read_byte (STMPE_FIFO_STA ) & STMPE_FIFO_STA_EMPTY
234
+ empty = self ._read_byte (_STMPE_FIFO_STA ) & _STMPE_FIFO_STA_EMPTY
236
235
return empty != 0
237
236
238
237
0 commit comments