Skip to content

Commit 3d5c77c

Browse files
authored
Merge pull request #35 from adafruit/main
Update from adafruit/main
2 parents 3abc671 + e9fd689 commit 3d5c77c

File tree

480 files changed

+9272
-2260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

480 files changed

+9272
-2260
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
jobs:
1616
test:
17-
runs-on: ubuntu-18.04
17+
runs-on: ubuntu-20.04
1818
steps:
1919
- name: Dump GitHub context
2020
env:
@@ -119,6 +119,7 @@ jobs:
119119
zip -9r circuitpython-stubs.zip circuitpython-stubs
120120
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp circuitpython-stubs.zip s3://adafruit-circuit-python/bin/stubs/circuitpython-stubs-${{ env.CP_VERSION }}.zip --no-progress --region us-east-1
121121
env:
122+
AWS_PAGER: ''
122123
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
123124
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
124125
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
@@ -159,13 +160,14 @@ jobs:
159160
run: |
160161
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross/mpy-cross s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross-macos-catalina-${{ env.CP_VERSION }} --no-progress --region us-east-1
161162
env:
163+
AWS_PAGER: ''
162164
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
163165
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
164166
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
165167

166168

167169
build-arm:
168-
runs-on: ubuntu-18.04
170+
runs-on: ubuntu-20.04
169171
needs: test
170172
strategy:
171173
fail-fast: false
@@ -196,6 +198,8 @@ jobs:
196198
- "circuitplayground_express_displayio"
197199
- "clue_nrf52840_express"
198200
- "cp32-m4"
201+
- "cp_sapling_m0"
202+
- "cp_sapling_m0_spiflash"
199203
- "datalore_ip_m4"
200204
- "datum_distance"
201205
- "datum_imu"
@@ -315,7 +319,8 @@ jobs:
315319
- "teensy40"
316320
- "teensy41"
317321
- "teknikio_bluebird"
318-
- "thunderpack"
322+
- "thunderpack_v11"
323+
- "thunderpack_v12"
319324
- "tinkeringtech_scoutmakes_azul"
320325
- "trellis_m4_express"
321326
- "trinket_m0"
@@ -363,12 +368,13 @@ jobs:
363368
- name: Upload to S3
364369
run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
365370
env:
371+
AWS_PAGER: ''
366372
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
367373
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
368374
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
369375

370376
build-riscv:
371-
runs-on: ubuntu-18.04
377+
runs-on: ubuntu-20.04
372378
needs: test
373379
strategy:
374380
fail-fast: false
@@ -411,11 +417,12 @@ jobs:
411417
- name: Upload to S3
412418
run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
413419
env:
420+
AWS_PAGER: ''
414421
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
415422
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
416423
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
417424
build-xtensa:
418-
runs-on: ubuntu-latest
425+
runs-on: ubuntu-20.04
419426
needs: test
420427
strategy:
421428
fail-fast: false
@@ -505,6 +512,7 @@ jobs:
505512
- name: Upload to S3
506513
run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
507514
env:
515+
AWS_PAGER: ''
508516
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
509517
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
510518
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))

.github/workflows/create_website_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
website:
13-
runs-on: ubuntu-latest
13+
runs-on: ubuntu-20.04
1414
steps:
1515
- name: Dump GitHub context
1616
env:

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
pre-commit:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-20.04
1515
steps:
1616
- uses: actions/checkout@v1
1717
- uses: actions/setup-python@v1

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,7 @@
152152
url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git
153153
[submodule "ports/esp32s2/esp-idf"]
154154
path = ports/esp32s2/esp-idf
155-
url = https://github.com/espressif/esp-idf.git
155+
url = https://github.com/jepler/esp-idf.git
156+
[submodule "ports/esp32s2/certificates/nina-fw"]
157+
path = ports/esp32s2/certificates/nina-fw
158+
url = https://github.com/adafruit/nina-fw.git

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ update-frozen-libraries:
265265
@echo "Updating all frozen libraries to latest tagged version."
266266
cd frozen; for library in *; do cd $$library; ../../tools/git-checkout-latest-tag.sh; cd ..; done
267267

268-
one-of-each: samd21 samd51 esp32s2 litex mimxrt10xx nrf stm
268+
one-of-each: samd21 litex mimxrt10xx nrf stm
269269

270270
samd21:
271271
$(MAKE) -C ports/atmel-samd BOARD=trinket_m0

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ Behavior
114114
finishes or is interrupted. After it is done running, the vm and
115115
hardware is reinitialized. **This means you cannot read state from**
116116
``code.py`` **in the REPL anymore.** CircuitPython's goal for this
117-
change includes reduce confusion about pins and memory being used.
117+
change includes reducing confusion about pins and memory being used.
118118
- After ``code.py`` the REPL can be entered by pressing any key. It no
119119
longer shares state with ``code.py`` so it is a fresh vm.
120120
- Autoreload state will be maintained across reload.
121121
- Adds a safe mode that does not run user code after a hard crash or
122122
brown out. The hope is that this will make it easier to fix code that
123123
causes nasty crashes by making it available through mass storage
124-
after the crash. A reset (the button) is needed after its fixed to
124+
after the crash. A reset (the button) is needed after it's fixed to
125125
get back into normal mode.
126126
- RGB status LED indicating CircuitPython state, and errors through a sequence of colored flashes.
127127
- Re-runs ``code.py`` or other main file after file system writes over USB mass storage. (Disable with

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
"ports/atmel-samd/tools",
173173
"ports/cxd56/mkspk",
174174
"ports/cxd56/spresense-exported-sdk",
175+
"ports/esp32s2/certificates",
175176
"ports/esp32s2/esp-idf",
176177
"ports/esp32s2/peripherals",
177178
"ports/litex/hw",

docs/design_guide.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ SPI Example
421421
"""Widget's one register."""
422422
with self.spi_device as spi:
423423
spi.write(b'0x00')
424-
i2c.readinto(self.buf)
424+
spi.readinto(self.buf)
425425
return self.buf[0]
426426
427427
Use composition
@@ -462,7 +462,7 @@ like properties for state even if it sacrifices a bit of speed.
462462
Avoid allocations in drivers
463463
--------------------------------------------------------------------------------
464464

465-
Although Python doesn't require managing memory, its still a good practice for
465+
Although Python doesn't require managing memory, it's still a good practice for
466466
library writers to think about memory allocations. Avoid them in drivers if
467467
you can because you never know how much something will be called. Fewer
468468
allocations means less time spent cleaning up. So, where you can, prefer
@@ -471,7 +471,7 @@ object with methods that read or write into the buffer instead of creating new
471471
objects. Unified hardware API classes such as `busio.SPI` are design to read and
472472
write to subsections of buffers.
473473

474-
Its ok to allocate an object to return to the user. Just beware of causing more
474+
It's ok to allocate an object to return to the user. Just beware of causing more
475475
than one allocation per call due to internal logic.
476476

477477
**However**, this is a memory tradeoff so do not do it for large or rarely used
@@ -580,4 +580,4 @@ MicroPython compatibility
580580
--------------------------------------------------------------------------------
581581

582582
Keeping compatibility with MicroPython isn't a high priority. It should be done
583-
when its not in conflict with any of the above goals.
583+
when it's not in conflict with any of the above goals.

docs/drivers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Adafruit CircuitPython Library Bundle
1212
We provide a bundle of all our libraries to ease installation of drivers and
1313
their dependencies. The bundle is primarily geared to the Adafruit Express line
1414
of boards which feature a relatively large external flash. With Express boards,
15-
its easy to copy them all onto the filesystem. However, if you don't have
15+
it's easy to copy them all onto the filesystem. However, if you don't have
1616
enough space simply copy things over as they are needed.
1717

1818
- The Adafruit bundles are available on GitHub: <https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases>.

docs/library/hashlib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ be implemented:
2020
* SHA1 - A previous generation algorithm. Not recommended for new usages,
2121
but SHA1 is a part of number of Internet standards and existing
2222
applications, so boards targeting network connectivity and
23-
interoperatiability will try to provide this.
23+
interoperability will try to provide this.
2424

2525
* MD5 - A legacy algorithm, not considered cryptographically secure. Only
26-
selected boards, targeting interoperatibility with legacy applications,
26+
selected boards, targeting interoperability with legacy applications,
2727
will offer this.
2828

2929
Constructors

docs/library/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ standard Python library.
2121
You may need to change your code later if you rely
2222
on any non-standard functionality they currently provide.
2323

24-
CircuitPython's goal long-term goalis that code written in CircuitPython
24+
CircuitPython's long-term goal is that code written in CircuitPython
2525
using Python standard libraries will be runnable on CPython without changes.
2626

2727
Some libraries below are not enabled on CircuitPython builds with
@@ -69,7 +69,7 @@ CircuitPython/MicroPython-specific libraries
6969
--------------------------------------------
7070

7171
Functionality specific to the CircuitPython/MicroPython implementation is available in
72-
the following libraries. These libraries may change signficantly or be removed in future
72+
the following libraries. These libraries may change significantly or be removed in future
7373
versions of CircuitPython.
7474

7575
.. toctree::

docs/library/network.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ parameter should be `id`.
7171
(password) required to access said service. There can be further
7272
arbitrary keyword-only parameters, depending on the networking medium
7373
type and/or particular device. Parameters can be used to: a)
74-
specify alternative service identifer types; b) provide additional
74+
specify alternative service identifier types; b) provide additional
7575
connection parameters. For various medium types, there are different
7676
sets of predefined/recommended parameters, among them:
7777

docs/porting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ request a safe mode state which prevents the supervisor from running user code
106106
while still allowing access to the REPL and other resources.
107107

108108
The core port initialization and reset methods are defined in
109-
``supervisor/port.c`` and should be the first to be implemented. Its required
109+
``supervisor/port.c`` and should be the first to be implemented. It's required
110110
that they be implemented in the ``supervisor`` directory within the port
111111
directory. That way, they are always in the expected place.
112112

docs/troubleshooting.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ When CircuitPython restarts it will create a fresh empty ``CIRCUITPY`` filesyste
1313

1414
This often happens on Windows when the ``CIRCUITPY`` disk is not safely ejected
1515
before being reset by the button or being disconnected from USB. This can also
16-
happen on Linux and Mac OSX but its less likely.
16+
happen on Linux and Mac OSX but it's less likely.
1717

1818
.. caution:: To erase and re-create ``CIRCUITPY`` (for example, to correct a corrupted filesystem),
1919
follow one of the procedures below. It's important to note that **any files stored on the**
@@ -43,7 +43,7 @@ ValueError: Incompatible ``.mpy`` file.
4343

4444
This error occurs when importing a module that is stored as a ``mpy`` binary file
4545
(rather than a ``py`` text file) that was generated by a different version of
46-
CircuitPython than the one its being loaded into. Most versions are compatible
46+
CircuitPython than the one it's being loaded into. Most versions are compatible
4747
but, rarely they aren't. In particular, the ``mpy`` binary format changed between
4848
CircuitPython versions 1.x and 2.x, and will change again between 2.x and 3.x.
4949

extmod/machine_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
STATIC uintptr_t machine_mem_get_addr(mp_obj_t addr_o, uint align) {
2222
uintptr_t addr = mp_obj_int_get_truncated(addr_o);
2323
if ((addr & (align - 1)) != 0) {
24-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("address %08x is not aligned to %d bytes"), addr, align));
24+
mp_raise_ValueError_varg(translate("address %08x is not aligned to %d bytes"), addr, align);
2525
}
2626
return addr;
2727
}

extmod/moduheapq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush);
6262
STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
6363
mp_obj_list_t *heap = get_heap(heap_in);
6464
if (heap->len == 0) {
65-
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("empty heap")));
65+
mp_raise_IndexError(translate("empty heap"));
6666
}
6767
mp_obj_t item = heap->items[0];
6868
heap->len -= 1;

extmod/modujson.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ typedef struct _ujson_stream_t {
5757
int errcode;
5858
mp_obj_t python_readinto[2 + 1];
5959
mp_obj_array_t bytearray_obj;
60+
size_t start;
61+
size_t end;
6062
byte cur;
6163
} ujson_stream_t;
6264

@@ -77,28 +79,44 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) {
7779
return s->cur;
7880
}
7981

82+
// We read from an object's `readinto` method in chunks larger than the json
83+
// parser needs to reduce the number of function calls done.
84+
85+
#define CIRCUITPY_JSON_READ_CHUNK_SIZE 64
86+
8087
STATIC mp_uint_t ujson_python_readinto(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
88+
(void) size; // Ignore size because we know it's always 1.
8189
ujson_stream_t* s = obj;
82-
s->bytearray_obj.items = buf;
83-
s->bytearray_obj.len = size;
84-
*errcode = 0;
85-
mp_obj_t ret = mp_call_method_n_kw(1, 0, s->python_readinto);
86-
if (ret == mp_const_none) {
87-
*errcode = MP_EAGAIN;
88-
return MP_STREAM_ERROR;
90+
91+
if (s->start == s->end) {
92+
*errcode = 0;
93+
mp_obj_t ret = mp_call_method_n_kw(1, 0, s->python_readinto);
94+
if (ret == mp_const_none) {
95+
*errcode = MP_EAGAIN;
96+
return MP_STREAM_ERROR;
97+
}
98+
s->start = 0;
99+
s->end = mp_obj_get_int(ret);
89100
}
90-
return mp_obj_get_int(ret);
101+
102+
*((uint8_t *)buf) = ((uint8_t*) s->bytearray_obj.items)[s->start];
103+
s->start++;
104+
return 1;
91105
}
92106

93107
STATIC mp_obj_t _mod_ujson_load(mp_obj_t stream_obj, bool return_first_json) {
94108
const mp_stream_p_t *stream_p = mp_proto_get(MP_QSTR_protocol_stream, stream_obj);
95109
ujson_stream_t s;
110+
uint8_t character_buffer[CIRCUITPY_JSON_READ_CHUNK_SIZE];
96111
if (stream_p == NULL) {
112+
s.start = 0;
113+
s.end = 0;
97114
mp_load_method(stream_obj, MP_QSTR_readinto, s.python_readinto);
98115
s.bytearray_obj.base.type = &mp_type_bytearray;
99116
s.bytearray_obj.typecode = BYTEARRAY_TYPECODE;
117+
s.bytearray_obj.len = CIRCUITPY_JSON_READ_CHUNK_SIZE;
100118
s.bytearray_obj.free = 0;
101-
// len and items are set at read time
119+
s.bytearray_obj.items = character_buffer;
102120
s.python_readinto[2] = MP_OBJ_FROM_PTR(&s.bytearray_obj);
103121
s.stream_obj = &s;
104122
s.read = ujson_python_readinto;

extmod/modure.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) {
4343
mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in);
4444
mp_int_t no = mp_obj_get_int(no_in);
4545
if (no < 0 || no >= self->num_matches) {
46-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, no_in));
46+
mp_raise_arg1(&mp_type_IndexError, no_in);
4747
}
4848

4949
const char *start = self->caps[no * 2];
@@ -82,7 +82,7 @@ STATIC void match_span_helper(size_t n_args, const mp_obj_t *args, mp_obj_t span
8282
if (n_args == 2) {
8383
no = mp_obj_get_int(args[1]);
8484
if (no < 0 || no >= self->num_matches) {
85-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, args[1]));
85+
mp_raise_arg1(&mp_type_IndexError, args[1]);
8686
}
8787
}
8888

@@ -326,7 +326,7 @@ STATIC mp_obj_t re_sub_helper(mp_obj_t self_in, size_t n_args, const mp_obj_t *a
326326
}
327327

328328
if (match_no >= (unsigned int)match->num_matches) {
329-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no)));
329+
mp_raise_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no));
330330
}
331331

332332
const char *start_match = match->caps[match_no * 2];

extmod/moduzlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
179179
return res;
180180

181181
error:
182-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st)));
182+
mp_raise_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st));
183183
}
184184
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress);
185185

extmod/ulab

Submodule ulab updated 81 files

extmod/vfs_posix_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef struct _mp_obj_vfs_posix_file_t {
2424
#ifdef MICROPY_CPYTHON_COMPAT
2525
STATIC void check_fd_is_open(const mp_obj_vfs_posix_file_t *o) {
2626
if (o->fd < 0) {
27-
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, translate("I/O operation on closed file")));
27+
mp_raise_ValueError(translate("I/O operation on closed file"));
2828
}
2929
}
3030
#else

lib/tinyusb

Submodule tinyusb updated 226 files

0 commit comments

Comments
 (0)