Commit Graph

2525 Commits

Author SHA1 Message Date
Jeff Epler
9cdfba2e47
Simplify argument checking to reduce translated strings
Build size on proxlight trinkey m0 en_US:
Before:  2412 (en_US)  820 (ru)
After:   2544 (en_US)  984 (ru)
Savings: +132 (en_US) +164 (ru) bytes available flash
2022-11-07 12:37:11 -06:00
Jeff Epler
452ebe27ae
socketpool: make socket objects selectable
.. which will lead to them being usable in async contexts, pending
relevant changes in asyncio
2022-11-05 12:05:19 -05:00
Jeff Epler
1f6cd7bfac
This compatibility name has been removed in 8.x 2022-11-02 17:39:34 -05:00
Dan Halbert
9307b62ad5 wip 2022-10-27 22:42:04 -04:00
Dan Halbert
2bba6a68e8
Merge pull request #7130 from dhalbert/characteristic-descriptors-missing
add Characteristic.descriptors to locals dict
2022-10-26 18:09:04 -04:00
Dan Halbert
c52b5b64e5 add Characteristic.descriptors to locals dict 2022-10-26 12:34:33 -04:00
Dan Halbert
fed77e918a Fix formatting of "Limitations:" in a couple of modules
When "Limitations:" is in the class docstring, it is sometimes taken
as a class attribute name because of the colon. When exactly is not clear, but
changing embedded colons or various indentations fixes the problem.
2022-10-26 12:33:16 -04:00
microDev
8f0a674a1b
coproc module enhancements
- add light and pretend-to-deep sleep support
- check coproc running status
2022-10-22 19:08:49 +05:30
Kattni
a4238d815d
Merge pull request #7097 from dhalbert/document-limitations
catalog implementation limitations in documentation
2022-10-21 18:02:03 -04:00
Dan Halbert
01c15a1d1b catalog implementation limitations in documentation 2022-10-21 13:58:34 -04:00
microDev
b33a2b45dc
add coproc alarm 2022-10-20 18:38:20 +05:30
MicroDev
b5b649801b
Merge pull request #6902 from MicroDev1/coproc
Add `coproc` module
2022-10-20 12:51:59 +05:30
microDev
5232e3f6c3
add coproc module 2022-10-20 09:09:44 +05:30
Jeff Epler
de0dda989d
Ensure background tasks are serviced during a lengthy sendall 2022-10-19 11:18:29 -05:00
Jeff Epler
508c80da8d
socketpool: add sendall
The standard Python 'fix' for 'send()' returning prematurely is to
use the 'sendall()' method instead. However, this method was not
available.  adafruit_httpserver will probably need to code a version
of it for older versions or for Airlift, but when it's available
this code works (Tested on picow sending 8192 bytes) and may be more
efficient.

(implementing 'sendall' in python should take care to slice a memoryview
rather than the original buffer)
2022-10-17 19:42:09 -05:00
Jeff Epler
068b7c4af8
Use micropython #defines for stream polling operations
We adopted the file "py/ioctl.h" and the ioctl names beginning
with MP_IOCTL_POLL while micropython went with "py/stream.h" and
MP_STREAM_POLL.

Align with upstream.

Closes #6711
2022-10-14 12:15:30 -05:00
Dan Halbert
de7a9c38fc Merge remote-tracking branch 'adafruit/main' into add-os-utime-function 2022-10-13 14:15:13 -04:00
Dan Halbert
1569c7ed33
Merge pull request #7045 from jepler/smaller-microcontroller-temperature-samd
samd: Size-optimize the temperature code with an 0.5 to 2.0 degree relative additional error
2022-10-13 14:02:51 -04:00
Dan Halbert
ead03cd96f add caveat in documentation 2022-10-13 11:47:10 -04:00
Jeff Epler
febc7a8514
format_traceback: Return list, as documented, and compatible with CPython 2022-10-13 09:38:43 -05:00
Jeff Epler
448eb1b70b
Document the 3.10-style calling pattern 2022-10-13 09:38:42 -05:00
Jeff Epler
47759294e0
code changes for supporting 1-arg print_exception 2022-10-13 09:38:42 -05:00
Jeff Epler
fc991c262c
traceback: share more code between format & print exception 2022-10-13 09:38:42 -05:00
Dan Halbert
7e4b2a09eb
Merge pull request #7000 from MicroDev1/storage-extend
Add Storage Extension Support
2022-10-13 10:05:55 -04:00
microDev
728fea4ca4
add storage extension python api 2022-10-13 09:53:33 +05:30
Dan Halbert
4cd370ecf8 Merge remote-tracking branch 'adafruit/main' into add-os-utime-function 2022-10-10 17:51:59 -04:00
Jeff Epler
c98174eea5
Add support for SSL client certificate (load_cert_chain)
Tested with badssl.com:

 1. Get client certificates from https://badssl.com/download/
 2. Convert public portion with `openssl x509 -in badssl.com-client.pem -out CIRCUITPY/cert.pem`
 3. Convert private portion with `openssl rsa -in badssl.com-client.pem -out CIRCUITPY/privkey.pem` and the password `badssl.com`
 4. Put wifi settings in CIRCUITPY/.env
 5. Run the below Python script:

```py
import os
import wifi
import socketpool
import ssl
import adafruit_requests

TEXT_URL = "https://client.badssl.com/"
wifi.radio.connect(os.getenv('WIFI_SSID'), os.getenv('WIFI_PASSWORD'))

pool = socketpool.SocketPool(wifi.radio)
context = ssl.create_default_context()
requests = adafruit_requests.Session(pool, context)

print(f"Fetching from {TEXT_URL} without certificate (should fail)")
response = requests.get(TEXT_URL)
print(f"{response.status_code=}, should be 400 Bad Request")
input("hit enter to continue\r")

print("Loading client certificate")
context.load_cert_chain("/cert.pem", "privkey.pem")
requests = adafruit_requests.Session(pool, context)

print(f"Fetching from {TEXT_URL} with certificate (should succeed)")
response = requests.get(TEXT_URL)
print(f"{response.status_code=}, should be 200 OK")
```
2022-10-10 15:10:53 -05:00
Dan Halbert
de95463deb
Merge pull request #7023 from dhalbert/wifi-scanning-fixes
update esp-idf; allow start/stop channels in wifi scanning
2022-10-10 13:54:54 -04:00
Dan Halbert
987030e706
Merge branch 'main' into add-os-utime-function 2022-10-07 22:45:51 -04:00
Dan Halbert
747dc7746d handle scan channel bounds but note they do nothing for RP2040 CYW43 2022-10-07 16:22:17 -04:00
Dan Halbert
21c0c4c1a6 update esp-idf; allow start/stop channels in wifi scanning 2022-10-07 15:29:09 -04:00
MicroDev
fc549fe345
Merge pull request #7014 from jepler/restore-nvm-module
restore nvm module
2022-10-08 00:12:41 +05:30
Dan Halbert
833f55922c
Remove multiterminal
This module has not been built in years, since the (removed) esp8266 port.
Delete the code, as it is not likely to be useful in its current form.

Closes: #7015
2022-10-06 14:02:47 -05:00
Jeff Epler
f431b2459c
restore nvm module 2022-10-06 13:18:19 -05:00
Jeff Epler
dcb650c513 pico w: add ssl module
Note: at this time, the ssl module on pico_w never verifies the server
certificate. This means it does not actually provide a higher security
level than regular socket / http protocols.
2022-10-05 13:12:43 -04:00
Dan Halbert
b3ca6fd011
Merge pull request #6995 from dhalbert/missing-support-matrix-modules
add missing native modules to support matrix
2022-10-04 20:49:29 -04:00
Dan Halbert
ed87579a65 add missing native modules to support matrix 2022-10-04 19:22:18 -04:00
Dan Halbert
1c2d2c9be4
Merge pull request #6980 from MicroDev1/supervisor
Implement certain supervisor functions as properties
2022-10-04 08:54:11 -04:00
MicroDev
4fd15acf77
implement suggested change
pass brightness value directly

Co-authored-by: Dan Halbert <halbert@halwitz.org>
2022-10-04 08:28:48 +05:30
Dan Halbert
6dc03ae3ce fix some dotenv parsing 2022-10-03 21:56:11 -04:00
Paulus H.J. Schulinck
89e0601a39 Update I2CTarget.c
Correction of the timeout value range needed to set the timeout to 'forever'.
The line 162 checks timeout for a value of 0 while the function definition defaults timeout to -1. In the current version of the code timeout is only checked for a value of 0 or in the 'else if' part for a value of > 0. So, values of <0 will not be taken in to account.  That is the reason of my modification.
2022-10-03 13:09:40 +01:00
Paulus H.J. Schulinck
041766351c Update I2CTarget.c
Correction in function request() doc function signature.
(after speaking with @jepler on Discord).

(@jepler: 'Circuitpython always has floats enabled')
2022-10-01 22:23:17 +01:00
Paulus H.J. Schulinck
d66eeaab26 Update I2CTarget.c
Modification of the doc text of function request().

1) The timout parameter is a keyword-only argument; so Added '*,' in the function signature;
2) for parameter timeout an integer is expected, not a float.
2022-10-01 21:56:07 +01:00
microDev
17ed2a6898
implement certain supervisor functions as properties
- disable_ble_workflow
- set_next_stack_limit
- set_rgb_status_brightness
2022-10-01 23:44:22 +05:30
Dan Halbert
f9e655da47
Merge pull request #6962 from dhalbert/espressif-deep-sleep-hold-pins
Espressif: do not hold pins during deep sleep if not necessary
2022-09-30 22:20:44 -04:00
Jeff Epler
907c5d387f
Tweak black_bindings
Originally, black_bindings found each contiguous "//|" block and sent
it to black independently. This was slower than it needed to be.

Instead, swap the comment prefix: when running black, take off
"//|" prefixes and put "##|" prefixes on all un-prefixed lines.
Then, after black is run, do the opposite operation

This more than doubles the overall speed of "pre-commit run --all",
from 3m20s to 55s CPU time on my local machine (32.5s to under 10s
"elapsed" time)

It also causes a small amount of churn in the bindings, because
black now sees enough context to know whether one 'def' follows another
or ends the 'def's in a 'class'. In the latter case, it adds an extra
newline, which becomes a "//|" line.

I'm less sure why a trailing comma was omitted before down in
rp2pio/StateMachine.c but let's roll with it.
2022-09-30 11:18:13 -05:00
Dan Halbert
9d1b12066d Espressif: do not hold pins during deep sleep if not necessary 2022-09-29 20:11:48 -04:00
Dan Halbert
db065a299f
Merge pull request #6933 from jepler/🥧🐮
Implement a useful subset of `wifi` and `socketpool` modules on 🥧🐮
2022-09-28 18:09:24 -04:00
Jeff Epler
d59774d750
don't use regcomp to check hostname validity 2022-09-28 15:11:55 -05:00
Jeff Epler
dbd7ce9fdc
restore checking hostname format on esp32 where it was checked before 2022-09-28 14:38:13 -05:00
Jeff Epler
bc63f9370a
comment why it's this way 2022-09-28 14:38:11 -05:00
Jeff Epler
ff7731491e
Implement enough of socketpool to do ntp and non-https requests 2022-09-28 10:06:34 -05:00
Jeff Epler
a7a1bd7880
Implement DNS resolution
```
>>> s = socketpool.SocketPool(wifi.radio)
>>> s.getaddrinfo("google.com", 80)
[(0, 0, 0, '', ('142.250.81.206', 80))]
```
2022-09-28 10:06:33 -05:00
Jeff Epler
6c3cdceb45
Implement scan, connect, ping
My pings go out, and then they come back

```py
import os
import wifi
import ipaddress

wifi.radio.connect(os.getenv('WIFI_SSID'), os.getenv('WIFI_PASSWORD'))
ipv4 = ipaddress.ip_address("8.8.4.4")
print("Ping google.com: %f ms" % (wifi.radio.ping(ipv4)*1000))
```
2022-09-28 10:06:33 -05:00
Jeff Epler
346fff2e7c
cyw43 basic gpio support, hwaddr in boot_out 2022-09-28 10:06:33 -05:00
Jeff Epler
b2cc8d2aad
run black_bindings across all bindings 2022-09-27 15:21:42 -05:00
Jeff Epler
4e96667d50
Manual fix for oddball cases 2022-09-27 15:19:32 -05:00
Jeff Epler
c415c13517
mend broken doc block
Since black_bindings.py will pass each contiguous
"//|"-block to black independently, they must each be a fully
formed Python item.
2022-09-27 15:19:31 -05:00
Jeff Epler
da4f2db1df
Add missing type annotations
These are treated as warnings by extract_pyi, so they don't stop
the build process.
2022-09-27 09:10:55 -05:00
Dan Halbert
a7b10d41b4
Merge pull request #6522 from jepler/must-be-int
Improve argument checking & reduce strings to translate
2022-09-25 17:55:56 -04:00
Dan Halbert
c291a02bcc
Merge pull request #6943 from snkYmkrct/main
Support for opening a file by name in MP3Decoder
2022-09-25 17:53:51 -04:00
snkYmkrct
d7ea1c39c6 Minor update to MP3Decoder documentation 2022-09-25 13:34:50 +02:00
snkYmkrct
ee6bd09438 Rename method, and remove redundant checks 2022-09-25 10:42:49 +02:00
Neradoc
5346b89b08 don't use @property in docs, just document as a property 2022-09-25 07:18:18 +02:00
Neradoc
2dbcd760fc usb_cdc.Serial.readinto has no nbytes parameter 2022-09-25 05:06:45 +02:00
snkYmkrct
a7406ec098 Support for opening a file by name in MP3Decoder 2022-09-23 19:20:44 +02:00
Jeff Epler
4f75d09e86
Get rid of an unneeded message 2022-09-22 11:56:57 -05:00
Jeff Epler
8227903b61
Use validation functions 2022-09-22 08:39:34 -05:00
Jeff Epler
ef35ca1d3e
vectorio: Simplify argument checking of x/y values 2022-09-22 08:39:33 -05:00
Jeff Epler
267ec1dc4f
unify some 'must/should be an int' messages 2022-09-22 08:39:32 -05:00
Isaac Benitez
71d649613f Updated utime() to take a 2-tuple instead of a plain int 2022-09-22 00:56:44 -07:00
Dan Halbert
e045415f59
Merge pull request #6247 from s-ol/descriptor-override
Add supervisor.set_usb_identification(manufacturer, product, vid, pid) function
2022-09-21 09:20:55 -04:00
snkYmkrct
9c5abb6d7a Change the examples in documentation 2022-09-21 12:52:17 +02:00
snkYmkrct
bb40b5c98e Correction 2022-09-21 08:24:01 +02:00
snkYmkrct
129c5de670 Made requested changes in the documentation 2022-09-21 08:24:01 +02:00
snkYmkrct
21551a82e3 Change to allow WaveFile and MP3Decoder to accept a file path 2022-09-21 08:24:01 +02:00
Dan Halbert
9aca092900 squeeze the usb identification code; manufacturer was being copied to product 2022-09-20 20:23:17 -04:00
Dan Halbert
c567b43441 add CIRCUITPY_USB_IDENTIFICATION to turn off on smallest builds 2022-09-20 14:32:38 -04:00
Dan Halbert
adf15faa8f merge from main; throw NotImplementedError if CIRCUITPY_USB not set 2022-09-20 13:18:32 -04:00
Isaac Benitez
5a21c30ab2 Added utime() to the os librady 2022-09-18 18:43:27 -07:00
Dan Halbert
6f8fe1b3e1 touch up analogbufio ValueError msg; consolidate with another message 2022-09-16 11:17:13 -04:00
Dan Halbert
8a568d18b5
Merge pull request #6757 from latkinso42/adcdma
analogbufio
2022-09-16 08:32:24 -04:00
MicroDev
4a69dfa50c
Merge pull request #6907 from dhalbert/preserve-pins-on-deep-sleep
allow preserving pin state during deep sleep
2022-09-16 17:52:04 +05:30
Dan Halbert
7914870f9a
Merge pull request #6908 from dhalbert/nrf-busio-none-empty-uart-read
nrf: return None when UART.read() reads nothing
2022-09-15 22:12:06 -04:00
Dan Halbert
6bb47038d5 Merge remote-tracking branch 'adafruit/main' into adcdma 2022-09-15 20:42:51 -04:00
Dan Halbert
3abfd212ec nrf: return None when UART.read() reads nothing 2022-09-15 19:40:02 -04:00
Dan Halbert
60f43b1703 allow preserving pin state during deep sleep 2022-09-15 17:35:14 -04:00
TimonPeng
1cc4d63c52 Fix bindings typing 2022-09-16 00:02:17 +08:00
Dan Halbert
87d120678c
Merge pull request #6890 from jepler/fontio
Give fontio its own enable
2022-09-14 14:22:46 -04:00
Alec Delaney
129e38096e Add information to aesio 2022-09-12 21:15:07 -04:00
Alec Delaney
b90a3160d4 Add information on canio 2022-09-12 21:09:07 -04:00
Alec Delaney
a7c7d1428a Add information for countio 2022-09-12 20:46:29 -04:00
Alec Delaney
fcdb988fa1 Add information for audioio 2022-09-12 20:36:51 -04:00
Alec Delaney
5a1223fea8 Add info for rotaryio 2022-09-12 20:07:37 -04:00
Jeff Epler
56112e00a1 Give fontio its own enable
.. the default is intended to be the equivalent of the original,
implementing `DISPLAYIO && TERMINALIO`.

This is a possible alternative to #6889, if I understand the intent.
2022-09-11 08:09:14 -05:00
Lee Atkinson
f279a2dbb2
Merge branch 'adafruit:main' into adcdma 2022-09-08 11:46:01 -04:00
Dan Halbert
dd37c81136
Merge pull request #6847 from dhalbert/status-bar-control
Allow enabling and disabling of status bar
2022-09-08 10:48:36 -04:00
latkinso42
c1f57c6ceb Pushing for resolution 2022-09-07 18:53:35 -04:00
latkinso42
a87d3bd89e Bad quotes 2022-09-06 19:40:20 -04:00
latkinso42
51dab921ea Bad object reference 2022-09-06 19:09:00 -04:00