Commit Graph

10 Commits

Author SHA1 Message Date
Jeff Epler 5bbbca4d44
lock and unlock i2c bus around any ops that might access it 2022-09-22 17:03:05 -05:00
Dan Halbert 60f43b1703 allow preserving pin state during deep sleep 2022-09-15 17:35:14 -04:00
Jeff Epler 2c6f57be5e
Update ports/espressif/common-hal/esp32_camera/Camera.c
Co-authored-by: Mark <56205165+gamblor21@users.noreply.github.com>
2022-08-28 16:46:50 -05:00
Jeff Epler dc27fb967d error at runtime if no psram actually reserved 2022-08-26 09:27:50 -05:00
Jeff Epler 9f22e75e5e error if camera is configured but no psram 2022-08-26 09:27:50 -05:00
Jeff Epler 98202c8568
Allow changing camera settings that require reinit
These can only be changed in a group, though any items to keep
unchanged can be unspecified or specified as None.
2022-08-04 15:12:11 -05:00
Jeff Epler 8bdbe0355a
Add more getters 2022-08-04 15:12:02 -05:00
Jeff Epler 258f72640a
Implement a pile of getters & setters 2022-08-04 15:11:57 -05:00
Jeff Epler 1d1e139379
fix taking multiple pictures 2022-08-04 15:11:53 -05:00
Jeff Epler 5db6db0128
add esp32-camera
This uses the esp32-camera code instead of our own homebrewed camera code.
In theory it supports esp32, esp32-s2 and esp32-s3, as long as they have
PSRAM.

This is very basic and doesn't support changing any camera parameters,
including switching resolution or pixelformat.

This is tested on the Kaluga (ESP32-S2) and ESP32-S3-Eye boards.

First, reserve some PSRAM by putting this line in `CIRCUITPY/_env`:
```
CIRCUITPY_RESERVED_PSRAM=524288
```
and hard-reset the board for it to take effect.

Now, the following script will take a very low-resolution jpeg file and print
it in the REPL in escape coded form:

```python
import board
import esp32_camera

c = esp32_camera.Camera(
    data_pins=board.CAMERA_DATA,
    external_clock_pin=board.CAMERA_XCLK,
    pixel_clock_pin=board.CAMERA_PCLK,
    vsync_pin=board.CAMERA_VSYNC,
    href_pin=board.CAMERA_HREF,
    pixel_format=esp32_camera.PixelFormat.JPEG,
    i2c=board.I2C(),
    external_clock_frequency=20_000_000)

m = c.take()
if m is not None:
    print(bytes(m))
```

Then on desktop open a python repl and run something like
```python
>>> with open("my.jpg", "wb") as f: f.write(<BIG PASTE FROM REPL>)
```
and open my.jpg in a viewer.
2022-08-04 15:11:50 -05:00