Skip to content

Commit 6d3d688

Browse files
authored
Merge pull request #32 from ilikecake/main
Suppress debug messages
2 parents fbb1429 + 394fe4f commit 6d3d688

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

adafruit_focaltouch.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ def __init__(self, i2c, address=_FT_DEFAULT_I2C_ADDR, debug=False, irq_pin=None)
8484
lib_ver, chip_id, _, _, firm_id, _, vend_id = struct.unpack(
8585
">HBBBBBB", chip_data
8686
)
87-
print(
88-
"lib_ver: {:02X}, chip_id: {:02X}, firm_id: {:02X}, vend_id: {:02X}".format(
89-
lib_ver, chip_id, firm_id, vend_id
87+
if debug:
88+
print(
89+
"lib_ver: {:02X}, chip_id: {:02X}, firm_id: {:02X}, vend_id: {:02X}".format(
90+
lib_ver, chip_id, firm_id, vend_id
91+
)
9092
)
91-
)
9293

9394
if vend_id not in (0x11, 0x42, 0x01):
9495
raise RuntimeError("Did not find FT chip")
@@ -166,7 +167,8 @@ def _write(self, register, values) -> None:
166167
"""Writes an array of 'length' bytes to the 'register'"""
167168
with self._i2c as i2c:
168169
values = [(v & 0xFF) for v in [register] + values]
169-
print("register: %02X, value: %02X" % (values[0], values[1]))
170+
if self._debug:
171+
print("register: %02X, value: %02X" % (values[0], values[1]))
170172
i2c.write(bytes(values))
171173

172174
if self._debug:

0 commit comments

Comments
 (0)