81
81
82
82
83
83
class PyCameraBase : # pylint: disable=too-many-instance-attributes,too-many-public-methods
84
- """Base class for PyCamera hardware"""
84
+ """Base class for PyCamera hardware
85
85
86
- """Wrapper class for the PyCamera hardware with lots of smarts"""
86
+ Wrapper class for the PyCamera hardware with lots of smarts
87
+ """
87
88
88
89
_finalize_firmware_load = (
89
90
0x3022 ,
@@ -253,9 +254,6 @@ def __init__(self) -> None: # pylint: disable=too-many-statements
253
254
self .shutter_button .switch_to_input (Pull .UP )
254
255
self .shutter = Button (self .shutter_button )
255
256
256
- self ._cam_reset = DigitalInOut (board .CAMERA_RESET )
257
- self ._cam_pwdn = DigitalInOut (board .CAMERA_PWDN )
258
-
259
257
# AW9523 GPIO expander
260
258
self ._aw = adafruit_aw9523 .AW9523 (self ._i2c , address = 0x58 )
261
259
print ("Found AW9523" )
@@ -374,14 +372,6 @@ def init_neopixel(self):
374
372
375
373
def init_camera (self , init_autofocus = True ) -> None :
376
374
"""Initialize the camera, by default including autofocus"""
377
- print ("reset camera" )
378
- self ._cam_reset .switch_to_output (False )
379
- self ._cam_pwdn .switch_to_output (True )
380
- time .sleep (0.01 )
381
- self ._cam_pwdn .switch_to_output (False )
382
- time .sleep (0.01 )
383
- self ._cam_reset .switch_to_output (True )
384
- time .sleep (0.01 )
385
375
386
376
print ("Initializing camera" )
387
377
self .camera = espcamera .Camera (
@@ -390,6 +380,8 @@ def init_camera(self, init_autofocus=True) -> None:
390
380
pixel_clock_pin = board .CAMERA_PCLK ,
391
381
vsync_pin = board .CAMERA_VSYNC ,
392
382
href_pin = board .CAMERA_HREF ,
383
+ powerdown_pin = board .CAMERA_PWDN ,
384
+ reset_pin = board .CAMERA_RESET ,
393
385
pixel_format = espcamera .PixelFormat .RGB565 ,
394
386
frame_size = espcamera .FrameSize .HQVGA ,
395
387
i2c = board .I2C (),
@@ -455,13 +447,13 @@ def write_camera_list(self, reg_list: Sequence[int]) -> None:
455
447
456
448
def read_camera_register (self , reg : int ) -> int :
457
449
"""Read a 1-byte camera register"""
458
- b = bytearray (2 )
459
- b [0 ] = reg >> 8
460
- b [1 ] = reg & 0xFF
450
+ b_out = bytearray (2 )
451
+ b_out [0 ] = reg >> 8
452
+ b_out [1 ] = reg & 0xFF
453
+ b_in = bytearray (1 )
461
454
with self ._camera_device as i2c :
462
- i2c .write (b )
463
- i2c .readinto (b , end = 1 )
464
- return b [0 ]
455
+ i2c .write_then_readinto (b_out , b_in )
456
+ return b_in [0 ]
465
457
466
458
def autofocus_init_from_bitstream (self , firmware : bytes ):
467
459
"""Initialize the autofocus engine from a bytestring"""
0 commit comments