ov3660: add a driver for the OV3660 camera (ESP32 camera boards)

Abierto
#901 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
22/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
go
Área
embedded-iot

Línea de trabajo

This is a proposal, not a ready task: the author asks three design questions (one package per chip or a shared camera package, JPEG-only first version, and deferring the capture example). Read the proposed Config/Device API and the register-table generator idea, then wait for a maintainer decision on those questions before starting. Done means an agreed API and an approved first pull request.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

The short version

I want to add a driver for the OV3660 camera. It is the camera on many cheap ESP32 camera boards, for example the Freenove ESP32-WROVER CAM. Your CONTRIBUTING.md asks for an issue first, so here it is, with the API, the status and some questions.

The ESP32 side (the camera input that catches the picture bytes) is a separate proposal in TinyGo: https://github.com/tinygo-org/tinygo/issues/5820

Fun fact first

The Freenove book says the board has an OV2640. Mine has an OV3660. The chip ID register says 0x3660. So check yours before you trust the box!

What the driver does

It sets up the camera over I2C (the camera calls it SCCB):

  • finds the chip (product ID 0x3660)
  • resets it and loads the setup tables
  • sets the picture size, from 160 x 120 up to 2048 x 1536
  • JPEG output, with a quality setting
  • flip, mirror, and the colour bar test pattern

It does not read the pictures. That is the job of the camera input in TinyGo (see the link above).

The proposed API

It follows the driver design guide: a Config, a Device, New with a drivers.I2C, and no allocations.

package ov3660

const Address = 0x3C

type Size uint8 // QQVGA (160 x 120), QVGA, CIF, VGA, SVGA, XGA, UXGA, QXGA (2048 x 1536)
type Format uint8 // JPEG

type Config struct {
	Size    Size
	Format  Format
	Quality uint8  // JPEG quality, 0 to 63, lower is better
	XCLK    uint32 // the camera input clock in Hz
}

func DefaultConfig(xclk uint32) Config // 320 x 240, JPEG, quality 12
func (c Config) Validate() error

func New(bus drivers.I2C) Device
func (d *Device) Connected() bool
func (d *Device) Configure(cfg Config) error
func (d *Device) SetSize(s Size) error
func (d *Device) SetQuality(q uint8) error
func (d *Device) SetFlip(vertical, horizontal bool) error
func (d *Device) SetColorBar(on bool) error

Two details I am happy about

  • The register tables are generated, not typed by hand. A small generator (go generate) reads Espressif's esp32-camera header and writes tables.go. So we can compare with the source, and nobody has to check 200 lines of hex by eye.
  • The clock settings stay inside the datasheet limits. Espressif's values for the internal PLL are outside the range that the OV3660 datasheet allows, at the 10 MHz input clock the ESP32 can make. The driver computes values inside the range. On my board it gives about 27 pictures per second, against 14 with the Espressif values.

Status

  • Driver plus 8 unit tests with a fake I2C bus: all pass.
  • Tested on the Freenove ESP32-WROVER CAM: real JPEG pictures at 160 x 120, 320 x 240 and 640 x 480, plus 10 minutes non-stop without an error.
  • An example that finds and sets up the camera. It builds with TinyGo 0.42.

One honest known problem

In about 2 of 80 test runs, real pictures came out green. The JPEG is complete and valid, but its colour planes copy the brightness plane. The colour bar test pattern was always perfect. I could not trigger it again on purpose, so I did not "fix" it with a guess. If you have seen this with an OV3660 before, I would love a hint!

Questions for you

  1. One package per chip (ov3660, and later ov2640), or first a small shared camera package that detects which chip is there?
  2. JPEG only for a first version. OK?
  3. The capture example. An example that also takes pictures needs the new TinyGo camera input. The CI uses released TinyGo, so I would add that example in a later pull request, after a TinyGo release. OK?

Thanks for reading!

Lenguaje dominante
Go
Estrellas
756
Forks
251
Merge medio
7 d 12 h
PR fusionados (30 d)
8

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tinygo-org/drivers

Todos los issues de tinygo-org/drivers

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.