Skip to content

Remove debug param. It increases frozen and RAM by 800ish bytes. #29

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 1 commit into from
Jun 12, 2019
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
20 changes: 2 additions & 18 deletions adafruit_bus_device/i2c_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class I2CDevice:
device.write(bytes_read)
"""

def __init__(self, i2c, device_address, *, debug=False):
def __init__(self, i2c, device_address):
"""
Try to read a byte from an address,
if you get an OSError it means the device is not there
Expand All @@ -79,7 +79,6 @@ def __init__(self, i2c, device_address, *, debug=False):

self.i2c = i2c
self.device_address = device_address
self._debug = debug

def readinto(self, buf, **kwargs):
"""
Expand All @@ -95,8 +94,6 @@ def readinto(self, buf, **kwargs):
:param int end: Index to write up to but not include
"""
self.i2c.readfrom_into(self.device_address, buf, **kwargs)
if self._debug:
print("i2c_device.readinto:", [hex(i) for i in buf])

def write(self, buf, **kwargs):
"""
Expand All @@ -113,8 +110,6 @@ def write(self, buf, **kwargs):
:param bool stop: If true, output an I2C stop condition after the buffer is written
"""
self.i2c.writeto(self.device_address, buf, **kwargs)
if self._debug:
print("i2c_device.write:", [hex(i) for i in buf])

#pylint: disable-msg=too-many-arguments
def write_then_readinto(self, out_buffer, in_buffer, *,
Expand Down Expand Up @@ -148,26 +143,15 @@ def write_then_readinto(self, out_buffer, in_buffer, *,
if in_end is None:
in_end = len(in_buffer)
if hasattr(self.i2c, 'writeto_then_readfrom'):
if self._debug:
print("i2c_device.writeto_then_readfrom.out_buffer:",
[hex(i) for i in out_buffer[out_start:out_end]])
# In linux, at least, this is a special kernel function call
self.i2c.writeto_then_readfrom(self.device_address, out_buffer, in_buffer,
out_start=out_start, out_end=out_end,
in_start=in_start, in_end=in_end, stop=stop)
if self._debug:
print("i2c_device.writeto_then_readfrom.in_buffer:",
[hex(i) for i in in_buffer[in_start:in_end]])

else:
# If we don't have a special implementation, we can fake it with two calls
self.write(out_buffer, start=out_start, end=out_end, stop=stop)
if self._debug:
print("i2c_device.write_then_readinto.write.out_buffer:",
[hex(i) for i in out_buffer[out_start:out_end]])
self.readinto(in_buffer, start=in_start, end=in_end)
if self._debug:
print("i2c_device.write_then_readinto.readinto.in_buffer:",
[hex(i) for i in in_buffer[in_start:in_end]])

#pylint: enable-msg=too-many-arguments

Expand Down