Skip to content

Commit e727486

Browse files
committed
linted
1 parent 881c28d commit e727486

File tree

3 files changed

+37
-26
lines changed

3 files changed

+37
-26
lines changed

adafruit_focaltouch.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@
4545

4646
_FT6206_DEFAULT_I2C_ADDR = 0x38
4747

48-
_FT6XXX_REG_DATA = 0x00
49-
_FT6XXX_REG_NUMTOUCHES = 0x02
50-
_FT6XXX_REG_THRESHHOLD = 0x80
51-
_FT6XXX_REG_POINTRATE = 0x88
52-
_FT6XXX_REG_LIBH = 0xA1
53-
_FT6XXX_REG_LIBL = 0xA2
54-
_FT6XXX_REG_CHIPID = 0xA3
55-
_FT6XXX_REG_FIRMVERS = 0xA6
56-
_FT6XXX_REG_VENDID = 0xA8
57-
_FT6XXX_REG_RELEASE = 0xAF
48+
_FT6XXX_REG_DATA = const(0x00)
49+
_FT6XXX_REG_NUMTOUCHES = const(0x02)
50+
_FT6XXX_REG_THRESHHOLD = const(0x80)
51+
_FT6XXX_REG_POINTRATE = const(0x88)
52+
_FT6XXX_REG_LIBH = const(0xA1)
53+
_FT6XXX_REG_LIBL = const(0xA2)
54+
_FT6XXX_REG_CHIPID = const(0xA3)
55+
_FT6XXX_REG_FIRMVERS = const(0xA6)
56+
_FT6XXX_REG_VENDID = const(0xA8)
57+
_FT6XXX_REG_RELEASE = const(0xAF)
5858

5959
class Adafruit_FocalTouch:
6060
"""
@@ -63,41 +63,46 @@ class Adafruit_FocalTouch:
6363

6464
_debug = False
6565
chip = None
66-
66+
6767
def __init__(self, i2c, address=_FT6206_DEFAULT_I2C_ADDR, debug=False):
6868
self._i2c = I2CDevice(i2c, address)
6969
self._debug = debug
7070

7171
chip_data = self._read(_FT6XXX_REG_LIBH, 9)
72-
lib_ver, chip_id, g_mode, pwr_mode, firm_id, skip, vend_id = struct.unpack('>HBBBBBB', chip_data)
72+
lib_ver, chip_id, _, _, firm_id, _, vend_id = struct.unpack('>HBBBBBB', chip_data)
7373

7474
if vend_id != 0x11:
7575
raise RuntimeError("Did not find FT chip")
7676

7777
if chip_id == 0x06:
78-
chip = "FT6206"
78+
self.chip = "FT6206"
7979
elif chip_id == 0x64:
80-
chip = "FT6236"
80+
self.chip = "FT6236"
8181

8282
if debug:
8383
print("Library vers %04X" % lib_ver)
8484
print("Firmware ID %02X" % firm_id)
8585
print("Point rate %d Hz" % self._read(_FT6XXX_REG_POINTRATE, 1)[0])
8686
print("Thresh %d" % self._read(_FT6XXX_REG_THRESHHOLD, 1)[0])
87-
88-
8987

9088
@property
9189
def touched(self):
92-
return self._read(_FT6XXX_REG_NUMTOUCHES, 1)[0]
90+
""" Returns the number of touches currently detected """
91+
return self._read(_FT6XXX_REG_NUMTOUCHES, 1)[0]
9392

93+
94+
# pylint: disable=unused-variable
9495
@property
9596
def touches(self):
97+
"""
98+
Returns a list of touchpoint dicts, with 'x' and 'y' containing the
99+
touch coordinates, and 'id' as the touch # for multitouch tracking
100+
"""
96101
touchpoints = []
97102
data = self._read(_FT6XXX_REG_DATA, 32)
98103

99-
for t in range(2):
100-
point_data = data[t*6+3 : t*6+9]
104+
for i in range(2):
105+
point_data = data[i*6+3 : i*6+9]
101106
if all([i == 0xFF for i in point_data]):
102107
continue
103108
#print([hex(i) for i in point_data])
@@ -106,9 +111,10 @@ def touches(self):
106111
touch_id = y >> 12
107112
x &= 0xFFF
108113
y &= 0xFFF
109-
point = {'x':x , 'y': y, 'id': touch_id}
114+
point = {'x':x, 'y':y, 'id':touch_id}
110115
touchpoints.append(point)
111116
return touchpoints
117+
# pylint: enable=unused-variable
112118

113119
def _read(self, register, length):
114120
"""Returns an array of 'length' bytes from the 'register'"""
@@ -127,4 +133,3 @@ def _write(self, register, values):
127133
i2c.write(bytes(values))
128134
if self._debug:
129135
print("\t$%02X <= %s" % (values[0], [hex(i) for i in values[1:]]))
130-

examples/print_touches.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import time
1+
"""
2+
Example for getting touch data from an FT6206 or FT6236 capacitive
3+
touch driver, over I2C
4+
"""
5+
26
import busio
37
import board
48
import adafruit_focaltouch

examples/simple_paint.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
# Simple painting demo
1+
"""
2+
Simple painting demo that draws on an Adafruit capacitive touch shield with
3+
ILI9341 display and FT6206 captouch driver
4+
"""
25

3-
import time
46
import busio
57
import board
68
import digitalio
79
import adafruit_focaltouch
8-
10+
from adafruit_rgb_display import ili9341, color565
11+
912
# Create library object using our Bus I2C & SPI port
1013
i2c = busio.I2C(board.SCL, board.SDA)
1114
spi = busio.SPI(clock=board.SCK, MOSI=board.MOSI, MISO=board.MISO)
@@ -15,7 +18,6 @@
1518
dc_pin = digitalio.DigitalInOut(board.D9)
1619

1720
# Initialize display
18-
from adafruit_rgb_display import ili9341, color565
1921
display = ili9341.ILI9341(spi, cs=cs_pin, dc=dc_pin)
2022
# Fill with black!
2123
display.fill(color565(0, 0, 0))

0 commit comments

Comments
 (0)