Skip to content

Commit b9280af

Browse files
authored
Merge pull request #29 from tannewt/remove_debug
Remove debug param. It increases frozen and RAM by 800ish bytes.
2 parents 182eebd + 15235e2 commit b9280af

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

adafruit_bus_device/i2c_device.py

+2-18
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class I2CDevice:
5757
device.write(bytes_read)
5858
"""
5959

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

8080
self.i2c = i2c
8181
self.device_address = device_address
82-
self._debug = debug
8382

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

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

119114
#pylint: disable-msg=too-many-arguments
120115
def write_then_readinto(self, out_buffer, in_buffer, *,
@@ -148,26 +143,15 @@ def write_then_readinto(self, out_buffer, in_buffer, *,
148143
if in_end is None:
149144
in_end = len(in_buffer)
150145
if hasattr(self.i2c, 'writeto_then_readfrom'):
151-
if self._debug:
152-
print("i2c_device.writeto_then_readfrom.out_buffer:",
153-
[hex(i) for i in out_buffer[out_start:out_end]])
154146
# In linux, at least, this is a special kernel function call
155147
self.i2c.writeto_then_readfrom(self.device_address, out_buffer, in_buffer,
156148
out_start=out_start, out_end=out_end,
157149
in_start=in_start, in_end=in_end, stop=stop)
158-
if self._debug:
159-
print("i2c_device.writeto_then_readfrom.in_buffer:",
160-
[hex(i) for i in in_buffer[in_start:in_end]])
150+
161151
else:
162152
# If we don't have a special implementation, we can fake it with two calls
163153
self.write(out_buffer, start=out_start, end=out_end, stop=stop)
164-
if self._debug:
165-
print("i2c_device.write_then_readinto.write.out_buffer:",
166-
[hex(i) for i in out_buffer[out_start:out_end]])
167154
self.readinto(in_buffer, start=in_start, end=in_end)
168-
if self._debug:
169-
print("i2c_device.write_then_readinto.readinto.in_buffer:",
170-
[hex(i) for i in in_buffer[in_start:in_end]])
171155

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

0 commit comments

Comments
 (0)