97
97
98
98
class VC0706 :
99
99
"""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
100
102
"""
101
103
def __init__ (self , uart , * , buffer_size = 100 ):
102
104
self ._uart = uart
@@ -106,7 +108,7 @@ def __init__(self, uart, *, buffer_size=100):
106
108
for _ in range (2 ): # 2 retries to reset then check resetted baudrate
107
109
for baud in (9600 , 19200 , 38400 , 57600 , 115200 ):
108
110
self ._uart .baudrate = baud
109
- if self ._run_command (_RESET , bytes ([ 0x00 ]) , 5 ):
111
+ if self ._run_command (_RESET , b' \x00 ' , 5 ):
110
112
break
111
113
else : # for:else rocks! http://book.pythontips.com/en/latest/for_-_else.html
112
114
raise RuntimeError ('Failed to get response from VC0706, check wiring!' )
@@ -115,7 +117,7 @@ def __init__(self, uart, *, buffer_size=100):
115
117
def version (self ):
116
118
"""Return camera version byte string."""
117
119
# 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 ' )
119
121
readlen = self ._read_response (self ._buffer , len (self ._buffer ))
120
122
return str (self ._buffer [:readlen ], 'ascii' )
121
123
@@ -142,7 +144,6 @@ def baudrate(self, baud):
142
144
raise ValueError ("Unsupported baud rate" )
143
145
args = [0x03 , 0x01 , (divider >> 8 ) & 0xFF , divider & 0xFF ]
144
146
self ._run_command (_SET_PORT , bytes (args ), 7 )
145
- print ([hex (i ) for i in self ._buffer [0 :10 ]])
146
147
self ._uart .baudrate = baud
147
148
148
149
@property
@@ -151,7 +152,7 @@ def image_size(self):
151
152
IMAGE_SIZE_320x240, or IMAGE_SIZE_160x120.
152
153
"""
153
154
if not self ._run_command (_READ_DATA ,
154
- bytes ([ 0x4 , 0x4 , 0x1 , 0x00 , 0x19 ]) ,
155
+ b' \0 x04 \x04 \x01 \x00 \x19 ' ,
155
156
6 ):
156
157
raise RuntimeError ('Failed to read image size!' )
157
158
return self ._buffer [5 ]
@@ -170,7 +171,7 @@ def image_size(self, size):
170
171
def frame_length (self ):
171
172
"""Return the length in bytes of the currently capture frame/picture.
172
173
"""
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 ):
174
175
return 0
175
176
frame_length = self ._buffer [5 ]
176
177
frame_length <<= 8
0 commit comments