Commit graph

36187 commits

Author SHA1 Message Date
3269dff9a9 SSLSocket: simplify code by using protocol read/write
this probably requires changes in wiznet so we can't do it right now
2024-06-13 11:32:25 -05:00
4d4d654677 MP3Decoder: set the nonblocking flag as needed
this makes SSL sockets (which return readable when not yet actually
readable) work better.
2024-06-13 11:11:17 -05:00
3215f6c4ff SSLSocket: handle exceptions during protocol read/write operations
These protocol operations should not raise exceptions, but sometimes
they do. Catch the exception and extract the errno value if available.

At the same time, harmonize the argument types for the underlying C
routines
2024-06-12 16:41:19 -05:00
49a612056e take micropython tricks for selectability of ssl sockets 2024-06-10 12:07:48 -05:00
7969638740 SSLSocket: Add stream protocol
including select. This assumes that the SSL layer is readable/writable
exactly when the underlying socket is readable/writable.
2024-06-07 14:49:35 -05:00
Scott Shawcroft
5d9129a716
Merge pull request #9314 from dhalbert/workflow-abs-path-fix-2
Further fix to use absolute paths in remote workflows
2024-06-07 10:24:51 -07:00
Scott Shawcroft
d9387bc654
Merge pull request #9300 from bill88t/nodemcu_esp32c2
Add NodeMcu ESP32-C2
2024-06-07 10:00:21 -07:00
Dan Halbert
e4f6656df6 Further fix to use absolute paths in remote workflows 2024-06-06 16:56:24 -04:00
Scott Shawcroft
6b3665a4d5
Merge pull request #9303 from dhalbert/picow-usb-host-off
picow: turn off CIRCUITPY_USB_HOST and CIRCUITPY_PICODVI
2024-06-06 13:05:57 -07:00
Bill Sideris
1790c75cf5
Update paperwork elsewhere too 2024-06-06 22:35:07 +03:00
Bill Sideris
24f91dbde7
Update paperwork 2024-06-06 22:32:42 +03:00
Scott Shawcroft
1aa17b39b6
Merge pull request #9284 from jepler/mp3-stream
MP3: Stream them
2024-06-06 12:15:30 -07:00
Scott Shawcroft
76cc0a14d6
Merge pull request #9311 from dhalbert/web-workflow-use-abs-path
Web workflow: use absolute paths to avoid paths being adjusted by current directory
2024-06-06 12:12:23 -07:00
Dan Halbert
6ec5d3fabe web_workflow.c: use absolute path 2024-06-05 23:29:47 -04:00
6c9eaf1415 MP3Decoder: better handle underflows of mp3 stream
* Don't consume in the case of "indata overflow".
   Doing so leaves us at a bad boundary within the MP3 data
   and can continue decoding from an inappropriate spot
   i.e., one that looks likede mp3 data but is NOT.

   because there are many crashing bugs in the helix mp3 library on
   invalid input data, we must do our best to avoid them, and this
   is one way to do that.

 * clear the output buffer in the case there's not a sync word in the
   buffer. this can also happen when too little data is available.

   this changes more "stuttering" conditions into "silent" conditions.

With these changes, I can get through 3+ plays of "idea.mp3" from a local
http server with long pauses (but not stuttering glitches or safe mode
crashes).

I was also able to play through 10+ minutes of http://ice2.somafm.com/dronezone-128-mp3
without crashing or "end of stream", though again there are pauses
due to packet loss.

I think this is good now, except for the problems that arise when
the socket layer doesn't deliver a fresh packet for a long time.
2024-06-05 14:52:07 -05:00
Bill Sideris
2af48f2e65
Merge branch 'main' into nodemcu_esp32c2 2024-06-05 21:38:44 +03:00
Bill Sideris
2d18769a3b
Update creator stuff 2024-06-05 21:34:59 +03:00
cb295c57d7 MP3Decoder: Make it possible to start in the middle of an MP3
You can now, e.g.,
```
with open("/whatever.mp3") as mp3_file:
    mp3_file.seek(16000*30)
    decoder.file = mp3_file
    i2s.play(decoder)
```
to start about 30 seconds into a 128kbit/s CBR track.

If a track is looped, the loop will start at the beginning.

This also changes the behavior if the track is started & stopped: it will
continue from where it left off, except if it had prevously run to
completion. To get other behavior, you can seek the file and then re-assign
the file property.
2024-06-05 10:33:40 -05:00
Dan Halbert
d86e072e54
Merge pull request #9292 from skerr92/rpga_feather
add odt rpga feather
2024-06-05 10:17:26 -04:00
Seth Kerr
5dcefaf551 add odt rpga feather 2024-06-05 07:58:25 -06:00
Dan Halbert
604b862949
Merge pull request #9307 from UnexpectedCircuitPython/um_feathers3_neo
Added new UM FeatherS3 Neo.
2024-06-04 21:17:48 -04:00
Seon Rozenblum
bb1f1abad4 Added new UM FeatherS3 Neo. 2024-06-05 10:19:18 +10:00
6f6b680c18 MP3Decoder: improve some comments 2024-06-04 12:24:34 -05:00
4465f85027 evo m51: disable MP3 playback
& sort block of configuration settings
2024-06-04 12:18:29 -05:00
f4993b9b8a monster m4sk: disable a bunch of non-applicable modules
this hardware lacks the necessary I/O to connect any of these buses.

(re)enable synthio, it should fit now.
2024-06-04 12:18:04 -05:00
Dan Halbert
90cce2f36b
Merge pull request #9299 from tannewt/time_to_refresh
Make time_to_refresh return 0 correctly
2024-06-04 12:34:56 -04:00
Dan Halbert
597d5ccd2a
Merge pull request #9297 from weblate/weblate-circuitpython-main
Translations update from Hosted Weblate
2024-06-04 12:33:35 -04:00
Dan Halbert
46b172e168 picow: turn off CIRCUITPY_USB_HOST and CIRCUITPY_PICODVI 2024-06-04 12:31:57 -04:00
Hosted Weblate
1a8f3e22bf
Merge remote-tracking branch 'origin/main' 2024-06-04 18:27:58 +02:00
Scott Shawcroft
4cb4abf56a
Merge pull request #9296 from squix78/pendrive-s3
Add support for ThingPulse Pendrive S3
2024-06-04 09:27:54 -07:00
Bill Sideris
ccdcecc252
Initial nodemcu_esp32c2 board configuration (dupe creator id) 2024-06-04 15:56:27 +03:00
Daniel Eichhorn
3855d82f86
Use PID allocated in Espressif Repository 2024-06-04 07:37:39 +02:00
Daniel Eichhorn
d7975afa83
Merge branch 'adafruit:main' into pendrive-s3 2024-06-04 07:34:24 +02:00
Scott Shawcroft
254cac059e
Make time_to_refresh return 0 correctly
Redo Feather C6 pinout so it include standard D# labels for feathers

Fixes #9244
2024-06-03 15:33:11 -07:00
f81a3aed68 MP3Decoder: avoid all blocking reads in background
This gets MP3 playback of a soma.fm stream working for up to a minute
at a time, though it's still vulnerable to network glitches.

 * the buffer can empty, in which case a single block of audio
   plays repeatedly in max headroom stutter fashion
 * the server eventually (after 1 to 5 5 minutes) stops getting packets
   at all. At this point stream playback stops, with the internal error
   indicating a problem MP3 decoding (which doesn't quite make sense):
   -9, ERR_MP3_INVALID_HUFFCODES.
 * other combinations of audiomixer buffer & mp3 buffer might give
   different results
```py
import time

import adafruit_connection_manager
import adafruit_requests
import audiobusio
import audiomixer
import audiomp3
import board
import wifi

pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
requests = adafruit_requests.Session(pool, ssl_context)

# todo: parse PLS files like https://somafm.com/nossl/dronezone.pls
# todo: figure out why https URLs don't work at all (missing select?)
# STREAMING_URL = "http://ice2.somafm.com/dronezone-128-mp3"
STREAMING_URL = "http://ice4.somafm.com/tikitime-128-mp3"


def get_mp3_stream():
    if STREAMING_URL.startswith("http:") or STREAMING_URL.startswith("https:"):
        return requests.get(STREAMING_URL, headers={"connection": "close"}).socket
    return open(STREAMING_URL, "rb")


mixer_buffer_size = 1152 * 2
mp3_buffer = bytearray(32768)

with audiobusio.I2SOut(
    bit_clock=board.D12, word_select=board.D13, data=board.D11
) as i2s, get_mp3_stream() as stream, audiomp3.MP3Decoder(
    stream, mp3_buffer
) as sample, audiomixer.Mixer(
    channel_count=2, sample_rate=44100, buffer_size=mixer_buffer_size
) as m:

    v = m.voice[0]
    print(sample)

    i2s.play(m)

    v.play(sample, loop=False)
    while v.playing:
        time.sleep(0.1)
```
2024-06-03 15:49:14 -05:00
Hosted Weblate
c2b374c7f8
Merge remote-tracking branch 'origin/main' 2024-06-03 22:19:29 +02:00
Dan Halbert
b1e4bc3073
Merge pull request #9298 from tyeth/correct-branch-logic-custom-builds
Correct custom board build branch logic
2024-06-03 16:19:24 -04:00
tyeth
d687580c3d Correct custom board build branch logic 2024-06-03 20:07:08 +01:00
Hosted Weblate
6f6821d61a
Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: CircuitPython/main
Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/
2024-06-03 19:22:08 +02:00
Scott Shawcroft
dc3edf4e24
Merge pull request #9277 from Sola85/improve_espulp
Fix "espulp module broken in CircuitPython 9"
2024-06-03 10:21:56 -07:00
Dan Halbert
8db7a85756
Merge pull request #9295 from dhalbert/pypi-uncrustify
Use micropython-uncrustify from pypi instead of apt package
2024-06-03 11:33:50 -04:00
Dan Halbert
b2a350e49f
Merge pull request #9293 from tyeth/custom_builds_for_forks_and_branches
Custom builds for forks and branches
2024-06-03 11:33:34 -04:00
Dan Halbert
13b31ca8c7 requirements-dev.txt: silabs needs setuptools 2024-06-02 15:00:51 -04:00
Daniel Eichhorn
3cbad86140 Use unique PID 2024-06-02 19:15:53 +02:00
Daniel Eichhorn
089b3862e4 Add support for ThingPulse Pendrive S3 2024-06-02 17:59:40 +02:00
Dan Halbert
a63470aa9a Use micropython-uncrustify from pypi instead of apt package 2024-06-02 09:55:08 -04:00
Dan Halbert
c581eb91a4
Merge pull request #9294 from bablokb/code_cleanup
remove definition of board_display_obj
2024-06-02 09:02:44 -04:00
Tyeth Gundry
5d1a8964bb Add branch + fork compatibility 2024-06-01 23:57:21 +01:00
Tobias Schmale
55028d0a2d espulp: improve error messages 2024-06-01 16:06:45 +00:00
Bernhard Bablok
2ddae3d96c removed definition of board_display_obj 2024-06-01 16:58:15 +02:00