Commit graph

1609 commits

Author SHA1 Message Date
7d2e46aa19 Update adafruit_floppy 2024-04-02 14:57:20 -05:00
Fabien Chouteau
659c38562b shared-module/fourwire/FourWire.c: make the chip_select pin optional
If there's only one device on the bus, the chip_select pin of the
peripheral can be fixed in hardware, therefore lowering the number of
pins required on the microcontroller side.

This patch allows this by making the chip_select pin optional.
2024-03-30 11:04:18 +01:00
Dan Halbert
ec16f6d8ba
Merge pull request #8855 from xs5871/feature-better-keypad-debouncing
Add state integration based debouncing to the `keypad` module
2024-03-26 15:41:35 -04:00
e5f0579d6c SSLSocket: implement setsockopt (untested) 2024-03-25 09:24:57 -05:00
xs5871
3e184e994c
Add state integration based debouncing to the keypad module 2024-03-22 19:17:23 +00:00
KB Sriram
bed6483823 Set SPI clock line idle polarity for CPOL=1
Fixes https://github.com/adafruit/circuitpython/issues/9074
2024-03-21 22:50:01 -07:00
14a19726f0 Fix return value of accept()
The subscripting to get the `peer` object was wrong.
2024-03-21 14:06:37 -05:00
8c5d9d28d8 ssl: make bind & listen into void functions (they throw exceptions) 2024-03-21 14:06:32 -05:00
f960c5b7c1 SSLSocket: propagate any exception from socket.settimeout directly 2024-03-21 13:54:40 -05:00
b330989704 sslsocket: Simplify handling the timeout value
We're just going to pass it down to the underlying socket, so don't
parse it, multiply it, etc.
2024-03-21 13:54:40 -05:00
c793a021b8 ssl: work on anything implementing the socket protocol
In principle this allows core SSL code to be used with e.g., wiznet
or airlift sockets. It might actually be useful with wiznet ethernet devices
(it's probably not with airlift)
2024-03-21 13:54:40 -05:00
5973c4a86c socketpool: factor out constants
This header can be used by ssl even if there's no core socketpool
2024-03-21 13:54:40 -05:00
CDarius
bb683fa4cf Renamed module 'keypaddemux' in 'keypad_demux' and fix documentation 2024-03-19 09:59:02 +01:00
CDarius
f6033777c1 Merge branch 'main' into cardputer_keyboard 2024-03-19 09:09:51 +01:00
CDarius
88b4e38625 Moved DemuxKeyMatrix in the keypaddemux module 2024-03-18 17:11:34 +01:00
Dan Halbert
d1488313d5 Allow ctrl-c of adafruit_bus_device.spi_device lock hang 2024-03-15 18:40:34 -04:00
CDarius
c5c78d3235 Moved DemuxKeyMatrix from board specific to a shared module 2024-03-12 10:28:08 +01:00
Dan Halbert
9b6fd48029 shared-module/_bleio/ScanResults.c: make ScanEntry handling be atomic 2024-03-06 17:01:53 -05:00
3e029a9d0d ssl: Fix "timed out" exceptions
Incorrect error handling in send/recv would raise an OSError with
an incorrect (negative) code.

It's likely that this bug was always happening in the Pico W
implementation, which became the basis of the current shared
implementation.

Push handling of WANT_{READ,WRITE} down into mbedtls_raise_error
and use it in recv_into and send.

Tested by connecting to google.com:443, sending nothing, and trying
to read a byte:

```py
import socketpool, ssl, time, wifi
socket = socketpool.SocketPool(wifi.radio)
ctx = ssl.SSLContext()
with ctx.wrap_socket(socket.socket()) as ss:
    ss.connect(("google.com", 443))
    ss.settimeout(1)
    b = bytearray(1)
    try:
        t0 = time.monotonic()
        ss.recv_into(b)
    except Exception as ee:
        t1 = time.monotonic()
        exc = ee
        print(t1-t0)
        raise exc
```

As desired, an exception `OSError: [Errno 116] ETIMEDOUT` occurred
and the time delta value was 1.0 seconds.

(tested on pycamera)

Closes: #8988
2024-03-04 20:55:32 -06:00
Dan Halbert
b584642cfd
Merge pull request #8976 from tannewt/rp2_usb_host_keyboard
Provide language code to string descriptors
2024-03-04 16:55:21 -05:00
Mariusz Ćwikła
52c38c8914 usb_hid.set_interface_name: use port_malloc to allocate memory for interface name 2024-03-03 09:11:59 +01:00
Mariusz Ćwikła
898708a1cc usb_hid.set_interface_name 2024-02-28 16:34:34 +01:00
Scott Shawcroft
0cf3a66c81
Provide language code to string descriptors
This improves #8885 but doesn't fix the read error.
2024-02-23 15:51:12 -08:00
Scott Shawcroft
605c39c8db
Fix ssl.SSLSocket bind() error checking
Non-ssl sockets now return size_t error numbers, not bool.

Fixes #8947
2024-02-20 15:46:06 -08:00
Scott Shawcroft
9f3987aa3c
Require explicit socket port reuse
Doing it implicitly can lead to mistaken socket leaks and reuse.
It now matches CPython.

Fixes #8443
2024-02-16 14:31:19 -08:00
Scott Shawcroft
02a488649f
Merge pull request #8923 from jepler/groups-in-rom
displayio: add, check "readonly" flag for groups
2024-02-16 09:49:14 -08:00
3b445f167b Rename check_rom to check_readonly 2024-02-15 22:17:00 -06:00
d7dd571326 Rename the "in_rom" flag to "readonly" 2024-02-15 22:17:00 -06:00
b57c37cd34 espressif: Use mbedtls implementation of ssl module.
the mbedtls version is a bit different so there are some new #ifdefs
needed.

Tested with the ssl test from https://github.com/adafruit/circuitpython/issues/8910
on Adafruit MatrixPortal S3 (no pico w testing done)
2024-02-15 14:26:24 -06:00
9abe273afa mbedtls: move to shared-module
this enables the implementation to be shared among ports.
2024-02-15 13:30:09 -06:00
75ec56844c displayio: add, check "in rom" flag for groups
closes: #8873
2024-02-14 19:39:00 -06:00
58f28b82f5 Include header only when needed 2024-02-13 17:00:52 -06:00
b47033bbe2 include digitalio header where actually needed 2024-02-13 17:00:52 -06:00
0d1e4dbbb0 random: fix getrandbits(0)
this is defined by python (returns 0) and tested in a test
2024-02-13 17:00:52 -06:00
f7c4a220d0 Fix build bugs exposed by posix port 2024-02-13 17:00:52 -06:00
foamyguy
880aa9c304 swap order of size 2024-02-11 16:35:37 -06:00
Scott Shawcroft
ab1316cb0e
Merge pull request #8831 from jepler/q-and-d-uvc
Add UVCFramebuffer to allow CircuitPython to send video to a host computer
2024-01-31 15:13:16 -08:00
9b6f590742 remove comment that's not valuable 2024-01-31 12:39:13 -06:00
da5ba9a76a Rename & improve doc 2024-01-31 12:03:12 -06:00
1c95a85ceb Merge remote-tracking branch 'origin/main' into q-and-d-uvc 2024-01-31 08:27:13 -06:00
335dd66bcf Merge remote-tracking branch 'origin/8.2.x' into merge-82x-main 2024-01-30 14:31:41 -06:00
df1eadabe6 remove subdirectory non-existence check for better compatibility with 9.0 2024-01-30 13:49:39 -06:00
8b30494146 Fix copying B to G in bitmapfilter.blend 2024-01-30 10:45:56 -06:00
247125d64b Remove redundant check_matching_details calls 2024-01-29 11:15:45 -06:00
943825f8be Add bitmapfilter.blend
This can perform arbitrary channel mixing between two images.
Alpha blend & maximum functions are demonstrated in the test.
However, it should make most of the usual photo editing blends
possible. (for dissolve, fill a mask bitmap with random values,
which may be expensive to do from circuitpython code; we can
specifically accelerate it if we need to)
2024-01-29 11:15:35 -06:00
20a8cfe3ef Allow the framebuffer size of an rgbmatrix to be >65535 bytes 2024-01-27 09:08:55 -06:00
1af43c777b uvc: don't run the callback if uvc is off
this leaves the potential problem that the callback may run frequently
even if not streaming, can improve this later.
2024-01-26 09:30:22 -06:00
f2c40d77d2 uvc: remove traces of the bitmap mode of operation 2024-01-26 09:29:03 -06:00
906c604bba uvc: Fix endpoint counting. 2024-01-26 09:12:51 -06:00
Scott Shawcroft
461d1a9a85 Collect refresh sequence pointer
Otherwise it will be freed during a collect and potentially
overwritten. This is a bug in 8.x but isn't seen as early as in
9.x because 9.x will collect before expanding the split heap
further.

Fixes #8793
2024-01-25 15:00:35 -05:00
e47c58ae34 uvc: Add UVCFramebuffer
This replaces the earlier, Bitmap-based way of interacting with the
UVC framebuffer.

Typical usage:
```py
displayio.release_displays()
display = frambufferio.FramebufferDisplay(uvc.UVCFramebuffer())
```

This works on a MacroPad with a 128x128 framebuffer, but does not work
on a QT Py esp32s3.

On esp32s3, having the UVC-configuring line alone causes a hard-fault
at startup. However, disabling some other USB devices allows it to boot
and run code.py:
```py
import uvc
import usb_hid
import usb_midi

usb_hid.disable()
usb_midi.disable()

uvc.enable_framebuffer(64, 64)
```
however, as far as I can tell within qv4l2, the device never actually
transmits a frame of data (received frame count never increases).
I have not yet analyzed this failure in further detail.
2024-01-25 13:59:29 -06:00
Dan Halbert
a9f551cdd1
Merge pull request #8839 from tannewt/fix_epd_refresh
Collect refresh sequence pointer
2024-01-25 14:52:49 -05:00
Dan Halbert
370b011081
Merge pull request #8830 from dhalbert/hid-wakeup
shared-module/usb_hid: allow HID to wake sleeping host computer
2024-01-25 14:44:02 -05:00
763159457d Avoid pointer alignment error on espressif 2024-01-25 12:51:35 -06:00
d89ccbe9c8
Add swapbuffers
this still seems to encounter some tearing, but it's not clear to me
why. It reduces it greatly.
2024-01-25 12:42:25 -06:00
Scott Shawcroft
7eb78500bf
Collect refresh sequence pointer
Otherwise it will be freed during a collect and potentially
overwritten. This is a bug in 8.x but isn't seen as early as in
9.x because 9.x will collect before expanding the split heap
further.

Fixes #8793
2024-01-25 09:39:00 -08:00
8d6d559b02
uvc: make width, height boot configurable; disable by default 2024-01-24 10:32:23 -06:00
Dan Halbert
9aa73fd43f shared-module/usb_hid: allow HID to wake sleeping host computer 2024-01-24 11:12:49 -05:00
Scott Shawcroft
9538e0067b
Merge remote-tracking branch 'adafruit/main' into ww_sd_card 2024-01-22 17:14:06 -08:00
6b74263a71
uvc: Experimental module for USB video
This allows the CircuitPython device to act as a UVC video source.
2024-01-22 10:44:42 -06:00
ccc85f810c
bitmapfilter: factor out macros
.. they will be used in uvc to do rgb->yuyv conversion
2024-01-22 10:44:36 -06:00
6837e4f7b9
Merge pull request #8786 from jepler/bitmapfilter
Add "bitmapfilter"
2024-01-22 08:03:02 -06:00
Scott Shawcroft
61ec3280d1
Optimize error messages 2024-01-19 21:31:58 -08:00
Taylor Yu
e97b231f0a shared-module/usb_hid: fix keyboard descriptor
Adjust Report Count for the LED field of the Keyboard Report Descriptor
to be consistent with the number of usages.
2024-01-18 22:17:39 -06:00
Scott Shawcroft
234ce7cfa4
Fix move, mkdir and tweak dir listing
Makes sure mount point is a directory.

Fixes #8110 by making it explicit that progress is per-file.
2024-01-18 14:22:16 -08:00
Scott Shawcroft
25e862d110
Make SD cards available over web workflow
This changes storage.mount() to require that a mount point exist
on the parent file system.

A bug in background tasks is also fixed where the function
parameter is cleared on pending callbacks during "reset".

Disk usage is shown on the directory listing and changes based on
the mounted file system. Writable is also loaded per-directory.

Fixes #8108. Fixes #8690. Fixes #8107.
2024-01-16 14:12:16 -08:00
0c36c1558e
Remove morph9, we're tight on flash space as it is
.. and no specific use case for morph9 is known that can't be done
with mix+morph.

Saves ~1800 bytes on Memento
2024-01-15 14:08:13 -06:00
6dc33a8efb
optimize morph9
This reduces the time from about 133ms to about 122ms on my test
image on the memento pycamera

a similar change to morph did not produce a performance improvement,
so I didn't include it.
2024-01-14 11:17:55 -06:00
6e553e763c
Add, test morph9
morph9 is a form of morph which performs 9 different convolutions,
like a version of mix where each coefficient is a (2n+1)x(2n+1) matrix.

Most use cases are covered by morph-then-mix, but some advanced operations
may be more efficient to implement via morph9.
2024-01-12 17:32:45 -06:00
6d30ff527a
Add false_color 2024-01-12 10:48:26 -06:00
ff22baa37f
Add lookup table (LUT) 2024-01-11 14:40:01 -06:00
415432e942
Fix solarize to operate in YUV, add test 2024-01-11 14:37:36 -06:00
4cb193d9c9
bitmapfilter: Add solarize, add comments 2024-01-10 15:32:59 -06:00
7e1c05edf5
morph: accommodate fractional add values 2024-01-09 17:11:53 -06:00
36411203ff
Add bitmapfilter.mix
This allows operations between channels in an image. It can be used for
the following use cases:
 * Conversion to B&W or sepia
 * Adding color casts
 * Mixing or swapping arbitrary channels
 * Inverting or scaling arbitrary channels
2024-01-09 15:00:42 -06:00
7e23fac766
bitmapfilter: refine morph, add docs 2024-01-06 13:34:42 -06:00
75be426377
Add "bitmapfilter"
bitmapfilter.morph is taken from openmv's imlib.

It is substantially faster than blur/sharpen implemented in ulab,
by up to 10x. It also avoids making many allocations.
2024-01-05 14:16:00 -06:00
1bc616cfb5
Merge pull request #8749 from jepler/mbedtls-hashlib
Share the implementation of hashlib across ports
2024-01-04 10:34:22 -06:00
5dd689c38a
jpegio: add bitmaptools.blit like clipping to decode 2023-12-24 10:50:00 -06:00
8d288f9623
jpegio: split open & decode; add support for decoding from files; add test 2023-12-24 10:50:00 -06:00
fa1a2c02d3
Ensure the MBEDTLS_VERSION_NUMBER is defined 2023-12-22 19:44:21 -06:00
2768406ea6
Fix hashlib for espressif
due to mbedtls version skew, some macros need to be provided.

The espressif common-hal implementation is no longer needed.

The copyright of hashlib/__init__.h comes from micropython
extmod/modhashlib.c where I found the macro definitions.
2023-12-22 19:25:13 -06:00
080cc545b3
Share the implementation of hashlib across ports
.. many platforms can use mbedtls to implement hashlib.

Compile-tested with pico-w. Tested on feather rp2040 dvi.
2023-12-22 17:06:12 -06:00
Dan Halbert
7cc816c709 merge from 8.2.x 2023-12-22 15:32:35 -05:00
Dan Halbert
71c9689ffe refactor error messages to save space 2023-12-20 16:14:42 -05:00
Dan Halbert
b272b88cd1 Reject RLE-compressed BMP files 2023-12-20 11:25:09 -05:00
49e3f6b0e6
Improve based on review comments 2023-12-07 15:56:40 -06:00
bd86b44848
Add JpegDecoder 2023-12-05 12:11:53 -06:00
c92ad33a9c
synthio: allow negative amplitudes
Previously, negative amplitudes were clamped to zero.
Now, they are allowed to range from -ALMOST_ONE to +ALMOST_ONE.
This is useful in certain circumstances, such as using synthio
to create CV-like outputs that can be positive or negative, by
using the amplitude property of the note.
2023-11-21 08:54:07 -06:00
dcooperdalrymple
55db6b7947 Added SYNTHIO_WAVEFORM_SIZE definition, renamed 'loop_...' to 'waveform_loop_...', added 'ring_waveform_loop_...` parameters, and updated docstrings. 2023-11-20 09:50:03 -06:00
dcooperdalrymple
785ef5abd2 Add loop_start and loop_end properties to synthio.Note for waveshaping and sampling capabilities. 2023-11-17 17:41:49 -06:00
Scott Shawcroft
8137e2d6d2
Switch all ports to auto-growing split heap
This simplifies allocating outside of the VM because the VM doesn't
take up all remaining memory by default.

On ESP we delegate to the IDF for allocations. For all other ports,
we use TLSF to manage an outer "port" heap. The IDF uses TLSF
internally and we use their fork for the other ports.

This also removes the dynamic C stack sizing. It wasn't often used
and is not possible with a fixed outer heap.

Fixes #8512. Fixes #7334.
2023-11-01 15:24:16 -07:00
774f6ac6ab
Switch to using MP_ERROR_TEXT instead of translate, globally 2023-10-30 09:49:06 +01:00
Scott Shawcroft
523d95e192
Switch warnings to mp_rom_error_text_t 2023-10-27 09:31:20 -07:00
Dan Halbert
32b6ac79d5
Merge pull request #8519 from jepler/compressed-message-type
Rename compressed_string_t to mp_rom_error_text_t to match upstream
2023-10-27 10:53:44 -04:00
Scott Shawcroft
f439f02492
Add warnings and warn about displayio changes
Follow up to #8493
2023-10-25 15:45:45 -07:00
de541cf155
Fix pointer-ness, const-ness of compressed messages
micropython puts the pointer-ness into the typedef; we can put the
const-ness there too.

this reduces the delta to micropython; for instance, emitinlinextensa
and emitinlinethumb now match upstream.
2023-10-25 21:40:11 +02:00
Scott Shawcroft
9354c921c2
Merge pull request #8467 from pypewpew/qrio-find
Add qrio.QRDecoder.find() to locate codes without decoding
2023-10-25 11:51:06 -07:00
55874b6470
Rename compressed_string_t to mp_rom_error_text_t to match upstream 2023-10-25 08:14:13 +02:00
Scott Shawcroft
e1df598199
Split displayio hardware support from core
These are moved:
* Display -> busdisplay.BusDisplay
* FourWire -> fourwire.FourWire
* EPaperDisplay -> epaperdisplay.EPaperDisplay
* I2CDisplay -> i2cdisplaybus.I2CDisplayBus

`paralleldisplay` is now `paralleldisplaybus` (and registered as
`paralleldisplay` too).

Bus related helpers are split out of display_core into bus_core.
It is in still displayio since it is a dependency of both
busdisplay and epaperdisplay.

Fixes #7667
2023-10-24 15:43:34 -07:00