Skip to content

Commit 7d0c75e

Browse files
authored
Merge pull request #3 from siddacious/str_format_update
updating string format to match BusIO
2 parents 1357662 + 3ae6294 commit 7d0c75e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

adafruit_debug_i2c.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
__version__ = "0.0.0-auto.0"
4242
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Debug_I2C.git"
4343

44-
4544
class DebugI2C:
4645
"""
4746
Wrapper library for debugging I2C.
@@ -107,7 +106,9 @@ def readfrom_into(self, address, buffer, *args, start=0, end=None):
107106
108107
"""
109108
self._i2c.readfrom_into(address, buffer, *args, start=start, end=end)
110-
print("i2c.readfrom_into at address {}:".format(hex(address)), [hex(i) for i in buffer])
109+
110+
in_buffer_str = ", ".join([hex(i) for i in buffer])
111+
print("\tI2CREAD @ {} ::".format(hex(address)), in_buffer_str)
111112

112113
def scan(self):
113114
"""
@@ -146,7 +147,9 @@ def writeto(self, address, buffer, *args, **kwargs):
146147
buffer is written
147148
"""
148149
self._i2c.writeto(address, buffer, *args, **kwargs)
149-
print("i2c.writeto at address {}:".format(hex(address)), [hex(i) for i in buffer])
150+
151+
out_buffer_str = ", ".join([hex(i) for i in buffer])
152+
print("\tI2CWRITE @ {} ::".format(hex(address)), out_buffer_str)
150153

151154
def _writeto_then_readfrom(self, address, buffer_out, buffer_in, *args, out_start=0,
152155
out_end=None, in_start=0, in_end=None):
@@ -167,9 +170,11 @@ def _writeto_then_readfrom(self, address, buffer_out, buffer_in, *args, out_star
167170
:param int in_end: End of the slice; this index is not included. Defaults to
168171
``len(buffer_in)``
169172
"""
170-
print("i2c.writeto_then_readfrom.buffer_out at address {}:".format(hex(address)),
171-
[hex(i) for i in buffer_out[out_start:out_end]])
173+
out_buffer_str = ", ".join([hex(i) for i in buffer_out[out_start:out_end]])
174+
print("\tI2CWRITE @ {} ::".format(hex(address)), out_buffer_str)
175+
172176
self._i2c.writeto_then_readfrom(address, buffer_out, buffer_in, *args, out_start=out_start,
173177
out_end=out_end, in_start=in_start, in_end=in_end)
174-
print("i2c.writeto_then_readfrom.buffer_in at address {}:".format(hex(address)),
175-
[hex(i) for i in buffer_in[in_start:in_end]])
178+
179+
in_buffer_str = ", ".join([hex(i) for i in buffer_in[in_start:in_end]])
180+
print("\tI2CREAD @ {} ::".format(hex(address)), in_buffer_str)

0 commit comments

Comments
 (0)