Skip to content

Suppress debug messages #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions adafruit_focaltouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ def __init__(self, i2c, address=_FT_DEFAULT_I2C_ADDR, debug=False, irq_pin=None)
lib_ver, chip_id, _, _, firm_id, _, vend_id = struct.unpack(
">HBBBBBB", chip_data
)
print(
"lib_ver: {:02X}, chip_id: {:02X}, firm_id: {:02X}, vend_id: {:02X}".format(
lib_ver, chip_id, firm_id, vend_id
if debug:
print(
"lib_ver: {:02X}, chip_id: {:02X}, firm_id: {:02X}, vend_id: {:02X}".format(
lib_ver, chip_id, firm_id, vend_id
)
)
)

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

if self._debug:
Expand Down