|
17 | 17 | powering on or resetting the board.
|
18 | 18 | """
|
19 | 19 |
|
| 20 | +import time |
| 21 | + |
20 | 22 | import board
|
21 | 23 | import busio
|
22 | 24 | import adafruit_ov5640
|
| 25 | +import microcontroller |
23 | 26 |
|
| 27 | +try: |
| 28 | + with open("/boot_out.txt", "a") as f: |
| 29 | + pass |
| 30 | +except OSError as e: |
| 31 | + print(e) |
| 32 | + print( |
| 33 | + "A 'read-only filesystem' error occurs if you did not correctly install" |
| 34 | + "\nov5640_jpeg_kaluga1_3_boot.py as CIRCUITPY/boot.py and reset the" |
| 35 | + '\nboard while holding the "mode" button' |
| 36 | + ) |
| 37 | + raise SystemExit |
24 | 38 |
|
25 | 39 | bus = busio.I2C(scl=board.CAMERA_SIOC, sda=board.CAMERA_SIOD)
|
26 | 40 | cam = adafruit_ov5640.OV5640(
|
|
30 | 44 | vsync=board.CAMERA_VSYNC,
|
31 | 45 | href=board.CAMERA_HREF,
|
32 | 46 | mclk=board.CAMERA_XCLK,
|
33 |
| - mclk_frequency=20_000_000, |
34 |
| - size=adafruit_ov5640.OV5640_SIZE_QVGA, |
| 47 | + size=adafruit_ov5640.OV5640_SIZE_SXGA, |
35 | 48 | )
|
36 | 49 |
|
37 | 50 | cam.colorspace = adafruit_ov5640.OV5640_COLOR_JPEG
|
| 51 | +cam.quality = 5 |
38 | 52 | b = bytearray(cam.capture_buffer_size)
|
| 53 | +print(f"Capturing jpeg image of up to {len(b)} bytes") |
39 | 54 | jpeg = cam.capture(b)
|
40 | 55 |
|
41 | 56 | print(f"Captured {len(jpeg)} bytes of jpeg data")
|
42 | 57 | try:
|
43 |
| - with open("/jpeg.jpg", "wb") as f: |
| 58 | + print("Writing to internal storage (this is SLOW)") |
| 59 | + with open("/cam.jpg", "wb") as f: |
44 | 60 | f.write(jpeg)
|
| 61 | + print("Wrote to CIRCUITPY/cam.jpg") |
| 62 | + print("Resetting so computer sees new content of CIRCUITPY") |
| 63 | + time.sleep(0.5) |
| 64 | + microcontroller.reset() |
| 65 | + |
45 | 66 | except OSError as e:
|
46 | 67 | print(e)
|
47 | 68 | print(
|
48 | 69 | "A 'read-only filesystem' error occurs if you did not correctly install"
|
49 | 70 | "\nov5640_jpeg_kaluga1_3_boot.py as CIRCUITPY/boot.py and reset the board"
|
50 | 71 | )
|
51 |
| -print("Wrote to CIRCUITPY/jpeg.jpg") |
|
0 commit comments