Skip to content

Commit 45239af

Browse files
committed
Fix camera properties when not init
Delete delay after init (causing problems) and properly handle properties when camera is not initialized Fix candidate for #51
1 parent 0fd1f6c commit 45239af

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/modcamera_api.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static mp_obj_t mp_camera_make_new(const mp_obj_type_t *type, size_t n_args, siz
205205
sda_pin, scl_pin, i2c_port, xclock_frequency, pixel_format, frame_size, jpeg_quality, fb_count, grab_mode);
206206

207207
mp_camera_hal_init(self);
208-
mp_hal_delay_ms(10); // Small delay to ensure I2C/SCCB is fully initialized
208+
209209
if (mp_camera_hal_capture(self) == mp_const_none){
210210
mp_camera_hal_deinit(self);
211211
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Failed to capture initial frame. Construct a new object with appropriate configuration."));
@@ -299,7 +299,10 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_camera___exit___obj, 4, 4, mp_came
299299
static void camera_obj_property(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
300300
mp_camera_obj_t *self = MP_OBJ_TO_PTR(self_in);
301301
if (self->initialized == false) {
302-
mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("Camera not initialized"));
302+
if (dest[0] == MP_OBJ_NULL) {
303+
dest[1] = MP_OBJ_SENTINEL;
304+
}
305+
return;
303306
}
304307

305308
if (dest[0] == MP_OBJ_NULL) {

0 commit comments

Comments
 (0)