Skip to content

Commit 3e9fbc3

Browse files
Camera: retry more
1 parent 7679db3 commit 3e9fbc3

File tree

1 file changed

+5
-4
lines changed
  • internal_filesystem/apps/com.micropythonos.camera/assets

1 file changed

+5
-4
lines changed

internal_filesystem/apps/com.micropythonos.camera/assets/camera_app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ def init_internal_cam(width, height):
401401
print(f"init_internal_cam: Using FrameSize for {width}x{height}")
402402

403403
# Try to initialize, with one retry for I2C poweroff issue
404-
for attempt in range(2):
404+
max_attempts = 3
405+
for attempt in range(max_attempts):
405406
try:
406407
cam = Camera(
407408
data_pins=[12,13,15,11,14,10,7,2],
@@ -421,10 +422,10 @@ def init_internal_cam(width, height):
421422
cam.set_vflip(True)
422423
return cam
423424
except Exception as e:
424-
if attempt == 0:
425-
print(f"init_cam attempt {attempt + 1} failed: {e}, retrying...")
425+
if attempt < max_attempts-1:
426+
print(f"init_cam attempt {attempt} failed: {e}, retrying...")
426427
else:
427-
print(f"init_cam exception: {e}")
428+
print(f"init_cam final exception: {e}")
428429
return None
429430
except Exception as e:
430431
print(f"init_cam exception: {e}")

0 commit comments

Comments
 (0)