Skip to content

Commit 800c8d8

Browse files
committed
cleanup - make constants private - remove unneeded pylint disable - fix typos
1 parent b461075 commit 800c8d8

File tree

2 files changed

+107
-108
lines changed

2 files changed

+107
-108
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This is easily achieved by downloading
3030
Usage Example
3131
=============
3232

33-
see examples in githup repository: https://github.com/adafruit/Adafruit_CIrcuitPython_STMPE610/exmaples
33+
see examples in githup repository: https://github.com/adafruit/Adafruit_CircuitPython_STMPE610/exmaples
3434
Contributing
3535
============
3636

adafruit_stmpe610.py

Lines changed: 106 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -35,98 +35,98 @@
3535

3636

3737
__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"
3939

4040

4141

4242
_STMPE_ADDR = const(0x41)
4343
_STMPE_VERSION = const(0x0811)
4444

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)
130130

131131

132132

@@ -140,27 +140,28 @@ def __init__(self):
140140
version = self.get_version
141141
if _STMPE_VERSION != version:
142142
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)
144144
time.sleep(.001)
145145

146146

147-
self._write_register_byte(STMPE_SYS_CTRL2, 0x0) # turn on clocks!
147+
self._write_register_byte(_STMPE_SYS_CTRL2, 0x0) # turn on clocks!
148148
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)
151151
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)
154154
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)
164165

165166
def read_data(self):
166167
"""Request next stored reading - return tuple containing (x,y,pressure) """
@@ -173,7 +174,7 @@ def read_data(self):
173174
pressure = d_4
174175
# reset all ints (not sure what this does)
175176
if self.buffer_empty:
176-
self._write_register_byte(STMPE_INT_STA, 0xFF)
177+
self._write_register_byte(_STMPE_INT_STA, 0xFF)
177178
return (x_loc, y_loc, pressure)
178179

179180
def _read_byte(self, register):
@@ -192,7 +193,6 @@ def _write_register_byte(self, register, value):
192193
raise NotImplementedError
193194

194195

195-
# pylint: disable=unused-variable
196196
@property
197197
def touches(self):
198198
"""
@@ -205,7 +205,6 @@ def touches(self):
205205
point = {'x':x_loc, 'y':y_loc, 'pressure':pressure}
206206
touchpoints.append(point)
207207
return touchpoints
208-
# pylint: enable=unused-variable
209208

210209

211210
@property
@@ -220,19 +219,19 @@ def get_version(self):
220219
@property
221220
def touched(self):
222221
"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
224223
return touch == 0x80
225224

226225

227226
@property
228227
def buffer_size(self):
229228
"The amount of touch data in the buffer"
230-
return self._read_byte(STMPE_FIFO_SIZE)
229+
return self._read_byte(_STMPE_FIFO_SIZE)
231230

232231
@property
233232
def buffer_empty(self):
234233
"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
236235
return empty != 0
237236

238237

0 commit comments

Comments
 (0)