Skip to content

Commit 20ca342

Browse files
committed
more bytestrings, less bytes()!
1 parent 6c3ec24 commit 20ca342

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

adafruit_vc0706.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797

9898
class VC0706:
9999
"""Driver for VC0706 serial TTL camera module.
100+
:param ~busio.UART uart: uart serial or compatible interface
101+
:param int buffer_size: Receive buffer size
100102
"""
101103
def __init__(self, uart, *, buffer_size=100):
102104
self._uart = uart
@@ -106,7 +108,7 @@ def __init__(self, uart, *, buffer_size=100):
106108
for _ in range(2): # 2 retries to reset then check resetted baudrate
107109
for baud in (9600, 19200, 38400, 57600, 115200):
108110
self._uart.baudrate = baud
109-
if self._run_command(_RESET, bytes([0x00]), 5):
111+
if self._run_command(_RESET, b'\x00', 5):
110112
break
111113
else: # for:else rocks! http://book.pythontips.com/en/latest/for_-_else.html
112114
raise RuntimeError('Failed to get response from VC0706, check wiring!')
@@ -115,7 +117,7 @@ def __init__(self, uart, *, buffer_size=100):
115117
def version(self):
116118
"""Return camera version byte string."""
117119
# Clear buffer to ensure the end of a string can be found.
118-
self._send_command(_GEN_VERSION, bytes([0x01]))
120+
self._send_command(_GEN_VERSION, b'\x01')
119121
readlen = self._read_response(self._buffer, len(self._buffer))
120122
return str(self._buffer[:readlen], 'ascii')
121123

@@ -142,7 +144,6 @@ def baudrate(self, baud):
142144
raise ValueError("Unsupported baud rate")
143145
args = [0x03, 0x01, (divider>>8) & 0xFF, divider & 0xFF]
144146
self._run_command(_SET_PORT, bytes(args), 7)
145-
print([hex(i) for i in self._buffer[0:10]])
146147
self._uart.baudrate = baud
147148

148149
@property
@@ -151,7 +152,7 @@ def image_size(self):
151152
IMAGE_SIZE_320x240, or IMAGE_SIZE_160x120.
152153
"""
153154
if not self._run_command(_READ_DATA,
154-
bytes([0x4, 0x4, 0x1, 0x00, 0x19]),
155+
b'\0x04\x04\x01\x00\x19',
155156
6):
156157
raise RuntimeError('Failed to read image size!')
157158
return self._buffer[5]
@@ -170,7 +171,7 @@ def image_size(self, size):
170171
def frame_length(self):
171172
"""Return the length in bytes of the currently capture frame/picture.
172173
"""
173-
if not self._run_command(_GET_FBUF_LEN, bytes([0x01, 0x00]), 9):
174+
if not self._run_command(_GET_FBUF_LEN, b'\x01\x00', 9):
174175
return 0
175176
frame_length = self._buffer[5]
176177
frame_length <<= 8

0 commit comments

Comments
 (0)