circuitpython/ports/atmel-samd
Jeff Epler a8614a61dc ParallelImageCapture: Add continuous capture on espressif
By having a pair of buffers, the capture hardware can fill one buffer while
Python code (including displayio, etc) operates on the other buffer.  This
increases the responsiveness of camera-using code.

On the Kaluga it makes the following improvements:
 * 320x240 viewfinder at 30fps instead of 15fps using directio
 * 240x240 animated gif capture at 10fps instead of 7.5fps

As discussed at length on Discord, the "usual end user" code will look like
this:

    camera = ...

    with camera.continuous_capture(buffer1, buffer2) as capture:
        for frame in capture:
            # Do something with frame

However, rather than presenting a context manager, the core code consists of
three new functions to start & stop continuous capture, and to get the next
frame.  The reason is twofold.  First, it's simply easier to implement the
context manager object in pure Python.  Second, for more advanced usage, the
context manager may be too limiting, and it's easier to iterate on the right
design in Python code.  In particular, I noticed that adapting the
JPEG-capturing programs to use continuous capture mode needed a change in
program structure.

The camera app was structured as
```python
while True:
    if shutter button was just pressed:
        capture a jpeg frame
    else:
        update the viewfinder
```

However, "capture a jpeg frame" needs to (A) switch the camera settings and (B)
capture into a different, larger buffer then (C) return to the earlier
settings. This can't be done during continuous capture mode. So just
restructuring it as follows isn't going to work:

```python
with camera.continuous_capture(buffer1, buffer2) as capture:
    for frame in capture:
        if shutter button was just pressed:
            capture a jpeg frame, without disturbing continuous capture mode
        else:
            update the viewfinder
```

The continuous mode is only implemented in the espressif port; others
will throw an exception if the associated methods are invoked.  It's not
impossible to implement there, just not a priority, since these micros don't
have enough RAM for two framebuffer copies at any resonable sizes.

The capture code, including single-shot capture, now take mp_obj_t in the
common-hal layer, instead of a buffer & length.  This was done for the
continuous capture mode because it has to identify & return to the user the
proper Python object representing the original buffer.  In the Espressif port,
it was convenient to implement single capture in terms of a multi-capture,
which is why I changed the singleshot routine's signature too.
2021-11-03 11:02:46 -05:00
..
asf4@84f56af132 update submodules to merge commits 2020-09-14 17:22:30 -05:00
asf4_conf Merge pull request #4716 from tyomitch/main 2021-05-08 08:47:29 -05:00
bindings/samd Convert more modules to use MP_REGISTER_MODULE 2021-10-05 16:58:24 +05:30
boards reenable RAINBOWIO on these boards 2021-11-01 12:52:13 -05:00
common-hal ParallelImageCapture: Add continuous capture on espressif 2021-11-03 11:02:46 -05:00
freetouch@b6859a349e
modules run code formatting script 2021-03-15 19:27:36 +05:30
peripherals@d3b20192cf improve SAMD audio DMA 2021-08-21 14:34:37 -04:00
sd_mmc codeformat: Fix filename matching 2021-04-30 10:48:08 -05:00
supervisor Merge pull request #5425 from maholli/samd-sleep 2021-10-25 14:42:12 -07:00
tools run code formatting script 2021-03-15 19:27:36 +05:30
.gitattributes
.gitignore
Makefile Always use python3 2021-10-15 15:11:21 -05:00
README.rst docs: Improve 5.0.x <-> main branch doc linkrot 2020-06-14 11:12:35 -05:00
audio_dma.c fix SAMD21 PDMIn DMA event use 2021-10-19 13:18:14 -04:00
audio_dma.h fix SAMD21 PDMIn DMA event use 2021-10-19 13:18:14 -04:00
background.c Remove OSError(0) and old network modules 2021-07-21 17:33:40 -07:00
background.h supervisor: factor supervisor_background_tasks from sundry ports 2020-07-15 11:49:44 -05:00
eic_handler.c working samd deep sleep timealarm and pinalarm (sketchy) 2021-09-29 11:44:15 -06:00
eic_handler.h reworked fake sleep. functional for pin and time 2021-10-09 11:44:10 -06:00
fatfs_port.c Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
ld_defines.c modifications by pre-commit 2021-03-15 18:11:00 -05:00
mpconfigport.h Add two space saving knobs 2021-08-31 13:02:34 -07:00
mpconfigport.mk Merge branch 'adafruit:main' into samd-sleep 2021-10-21 09:52:55 -07:00
mphalport.c Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
mphalport.h modifications by pre-commit 2021-03-15 18:11:00 -05:00
qstrdefsport.h Merge MicroPython 1.13 into CircuitPython 2021-05-04 18:06:33 -07:00
reset.c Add some NORETURN attributes 2020-09-28 18:55:56 -05:00
reset.h Add some NORETURN attributes 2020-09-28 18:55:56 -05:00
samd_peripherals_config.h Move pin struct to the peripherals library. 2018-08-02 13:59:05 -07:00
shared_timers.c Reset timers separate from pwmio 2021-08-11 09:58:31 -07:00
shared_timers.h Reset timers separate from pwmio 2021-08-11 09:58:31 -07:00
timer_handler.c modifications by pre-commit 2021-03-15 18:11:00 -05:00
timer_handler.h Reset timers separate from pwmio 2021-08-11 09:58:31 -07:00

README.rst

SAMD21 and SAMD51
==================

This port supports many development boards that utilize SAMD21 and SAMD51 chips. See
https://circuitpython.org/downloads for all supported boards.


Building
--------

For build instructions see this guide: https://learn.adafruit.com/building-circuitpython/


Debugging
---------

For debugging instructions see this guide: https://learn.adafruit.com/debugging-the-samd21-with-gdb


Port Specific modules
---------------------

.. toctree::
    ../../shared-bindings/samd/index