8000 Merge pull request #40 from adafruit/main · tannewt/circuitpython@cec921f · GitHub
[go: up one dir, main page]

Skip to content

Commit cec921f

Browse files
authored
Merge pull request micropython#40 from adafruit/main
Update from adafruit main
2 parents 6043fdf + 482e583 commit cec921f

File tree

169 files changed

+6419
-1624
lines changed

Some content is hidden

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

169 files changed

+6419
-1624
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ jobs:
304304
- "seeeduino_xiao"
305305
- "serpente"
306306
- "shirtty"
307+
- "silicognition-m4-shim"
307308
- "simmel"
308309
- "snekboard"
309310
- "sparkfun_lumidrive"
@@ -443,6 +444,7 @@ jobs:
443444
- "espressif_kaluga_1"
444445
- "espressif_saola_1_wroom"
445446
- "espressif_saola_1_wrover"
447+
- "lilygo_ttgo_t8_s2_st7789"
446448
- "microdev_micro_s2"
447449
- "muselab_nanoesp32_s2"
448450
- "targett_module_clip_wroom"
@@ -462,12 +464,12 @@ jobs:
462464
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
463465
- name: CircuitPython version
464466
run: git describe --dirty --tags
465-
- uses: actions/cache@v1
467+
- uses: actions/cache@v2
466468
name: Fetch IDF tool cache
467469
id: idf-cache
468470
with:
469471
path: ${{ github.workspace }}/.idf_tools
470-
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210121
472+
key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210128
471473
- name: Clone IDF submodules
472474
run: |
473475
(cd $IDF_PATH && git submodule update --init)

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
run: git submodule update --init extmod/ulab
2222
- name: set PY
2323
run: echo >>$GITHUB_ENV PY="$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
24-
- uses: actions/cache@v1
24+
- uses: actions/cache@v2
2525
with:
2626
path: ~/.cache/pre-commit
2727
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(BASEOPTS)
4040
# the i18n builder cannot share the environment and doctrees with the others
4141
I18NSPHINXOPTS = $(BASEOPTS)
4242

43-
TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/cxd56 ports/esp32s2 ports/mimxrt10xx ports/nrf ports/stm py shared-bindings shared-module supervisor
43+
TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/cxd56 ports/esp32s2 ports/mimxrt10xx ports/nrf ports/raspberrypi ports/stm py shared-bindings shared-module supervisor
4444
# Paths to exclude from TRANSLATE_SOURCES
4545
# Each must be preceded by "-path"; if any wildcards, enclose in quotes.
4646
# Separate by "-o" (Find's "or" operand)
4747
TRANSLATE_SOURCES_EXC = -path "ports/*/build-*" \
4848
-o -path "ports/*/build" \
49-
-o -path ports/esp32s2/esp-idf \
50-
-o -path ports/cxd56/spresense-exported-sdk \
51-
-o -path ports/stm/st_driver \
5249
-o -path ports/atmel-samd/asf4 \
50+
-o -path ports/cxd56/spresense-exported-sdk \
51+
-o -path ports/esp32s2/esp-idf \
5352
-o -path ports/mimxrt10xx/sdk \
53+
-o -path ports/raspberrypi/sdk \
54+
-o -path ports/stm/st_driver \
5455
-o -path lib/tinyusb \
5556
-o -path lib/lwip \
5657

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Behavior
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
128-
``samd.disable_autoreload()``)
128+
``supervisor.disable_autoreload()``)
129129
- Entering the REPL after the main code is finished requires a key press which enters the REPL and
130130
disables autoreload.
131131
- Main is one of these: ``code.txt``, ``code.py``, ``main.py``,

WEBUSB_README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
3+
4+
SPDX-License-Identifier: MIT
5+
-->
6+
7+
# WebUSB Serial Support
8+
9+
To date, this has only been tested on one port (esp32s2), on one board (espressif_kaluga_1).
10+
11+
## What it does
12+
13+
If you have ever used CircuitPython on a platform with a graphical LCD display, you have probably
14+
already seen multiple "consoles" in use (although the LCD console is "output only").
15+
16+
New compile-time option CIRCUITPY_USB_VENDOR enables an additional "console" that can be used in
17+
parallel with the original (CDC) serial console.
18+
19+
Web pages that support the WebUSB standard can connect to the "vendor" interface and activate
20+
this WebUSB serial console at any time.
21+
22+
You can type into either console, and CircuitPython output is sent to all active consoles.
23+
24+
One example of a web page you can use to test drive this feature can be found at:
25+
26+
https://adafruit.github.io/Adafruit_TinyUSB_Arduino/examples/webusb-serial/index.html
27+
28+
## How to enable
29+
30+
Update your platform's mpconfigboard.mk file to enable and disable specific types of USB interfaces.
31+
32+
CIRCUITPY_USB_HID = xxx
33+
CIRCUITPY_USB_MIDI = xxx
34+
CIRCUITPY_USB_VENDOR = xxx
35+
36+
On at least some of the hardware platforms, the maximum number of USB endpoints is fixed.
37+
For example, on the ESP32S2, you must pick only one of the above 3 interfaces to be enabled.
38+
39+
Original espressif_kaluga_1 mpconfigboard.mk settings:
40+
41+
CIRCUITPY_USB_HID = 1
42+
CIRCUITPY_USB_MIDI = 0
43+
CIRCUITPY_USB_VENDOR = 0
44+
45+
Settings to enable WebUSB instead:
46+
47+
CIRCUITPY_USB_HID = 0
48+
CIRCUITPY_USB_MIDI = 0
49+
CIRCUITPY_USB_VENDOR = 1
50+
51+
Notice that to enable VENDOR on ESP32-S2, we had to give up HID. There may be platforms that can have both, or even all three.
52+
53+
## Implementation Notes
54+
55+
CircuitPython uses the tinyusb library.
56+
57+
The tinyusb library already has support for WebUSB serial.
58+
The tinyusb examples already include a "WebUSB serial" example.
59+
60+
Sidenote - The use of the term "vendor" instead of "WebUSB" was done to match tinyusb.
61+
62+
Basically, this feature was ported into CircuitPython by pulling code snippets out of the
63+
tinyusb example, and putting them where they best belonged in the CircuitPython codebase.
64+
65+
There was one complication:
66+
67+
tinyusb uses C preprocessor macros to define things like USB descriptors.
68+
69+
CircuitPython uses a Python program (tools/gen_usb_descriptor.py) to create USB descriptors (etc.)
70+
using "helper objects" from another repo (adafruit_usb_descriptor). This means some of the example
71+
code had to be adapted to the new programing model, and gen_usb_descriptor gained new command-line
72+
options to control the generated code.
73+
74+
The generated files go into the "build" directory, look for autogen_usb_descriptor.c and
75+
genhdr/autogen_usb_descriptor.h.
76+
77+
78+
Also worth pointing out - the re-use of the CDC connect/disconnect mechanism is not actually part
79+
of the WebUSB standard, it's more of "common idiom". We make use of it here because we need to know
80+
when we should be paying attention to the WebUSB serial interface, and when we should ignore it..
81+
82+
## Possible future work areas
83+
84+
The current code uses the existing Python infrastructure to create the Interface descriptor, but
85+
simply outputs the code snippets from the original tinyusb demo code to create the WEBUSB_URL,
86+
BOS, and MS_OS_20 descriptors. I suppose additional work could be done to add these to the
87+
adafruit_usb_descriptor project, and then gen_usb_descriptor.py could be modified to make use
88+
of them.
89+
90+
Program gen_usb_descriptor.py creates objects for most interface types, regardless of whether or
91+
not they are actually enabled. This increases the size of a generated string table. I made the
92+
new vendor-interface-related code not do this (because some of the ARM platforms would no longer
93+
build), but I did not go back and do this for the other interface types (CDC, MIDI, HID, etc.)
94+
Some FLASH savings are probably possible if this is done.

docs/design_guide.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,9 @@ properties.
520520
+-----------------------+-----------------------+-------------------------------------------------------------------------+
521521
| ``temperature`` | float | degrees centigrade |
522522
+-----------------------+-----------------------+-------------------------------------------------------------------------+
523-
| ``eCO2`` | float | equivalent CO2 in ppm |
523+
| ``CO2`` | float | measured CO2 in ppm |
524+
+-----------------------+-----------------------+-------------------------------------------------------------------------+
525+
| ``eCO2`` | float | equivalent/estimated CO2 in ppm (estimated from some other measurement) |
524526
+-----------------------+-----------------------+-------------------------------------------------------------------------+
525527
| ``TVOC`` | float | Total Volatile Organic Compounds in ppb |
526528
+-----------------------+-----------------------+-------------------------------------------------------------------------+

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Full Table of Contents
4646
../BUILDING
4747
../CODE_OF_CONDUCT
4848
../license.rst
49+
../WEBUSB_README
4950

5051
Indices and tables
5152
==================

docs/library/uerrno.rst renamed to docs/library/errno.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
:mod:`uerrno` -- system error codes
1+
:mod:`errno` -- system error codes
22
===================================
33

4-
.. include:: ../templates/unsupported_in_circuitpython.inc
5-
6-
.. module:: uerrno
4+
.. module:: errno
75
:synopsis: system error codes
86

97
|see_cpython_module| :mod:`cpython:errno`.
@@ -22,13 +20,13 @@ Constants
2220
try:
2321
os.mkdir("my_dir")
2422
except OSError as exc:
25-
if exc.args[0] == uerrno.EEXIST:
23+
if exc.args[0] == errno.EEXIST:
2624
print("Directory already exists")
2725

2826
.. data:: errorcode
2927

3028
Dictionary mapping numeric error codes to strings with symbolic error
3129
code (see above)::
3230

33-
>>> print(uerrno.errorcode[uerrno.EEXIST])
31+
>>> print(errno.errorcode[uerrno.EEXIST])
3432
EEXIST

docs/library/esp.rst

Lines changed: 0 additions & 85 deletions
This file was deleted.

docs/library/index.rst

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,21 @@ MicroPython libraries
66
Python standard libraries and micro-libraries
77
---------------------------------------------
88

9-
These libraries are inherited from MicroPython.
10-
They are similar to the standard Python libraries with the same name
11-
or with the "u" prefix dropped.
9+
The libraries below are inherited from MicroPython.
10+
They are similar to the standard Python libraries with the same name.
1211
They implement a subset of or a variant of the corresponding
1312
standard Python library.
1413

15-
.. warning::
16-
17-
Though these MicroPython-based libraries are available in CircuitPython,
18-
their functionality may change in the future, perhaps significantly.
19-
As CircuitPython continues to develop, new versions of these libraries will
20-
be created that are more compliant with the standard Python libraries.
21-
You may need to change your code later if you rely
22-
on any non-standard functionality they currently provide.
23-
2414
CircuitPython's long-term goal is that code written in CircuitPython
2515
using Python standard libraries will be runnable on CPython without changes.
2616

27-
Some libraries below are not enabled on CircuitPython builds with
17+
These libraries are not enabled on CircuitPython builds with
2818
limited flash memory, usually on non-Express builds:
29-
``uerrno``, ``ure``.
30-
31-
Some libraries are not currently enabled in any CircuitPython build, but may be in the future:
32-
``uio``, ``ujson``, ``uzlib``.
19+
``binascii``, ``errno``, ``json``, ``re``.
3320

34-
Some libraries are only enabled only WiFi-capable ports (ESP8266, nRF)
35-
because they are typically used for network software:
36-
``binascii``, ``hashlib``, ``uheapq``, ``uselect``, ``ussl``.
37-
Not all of these are enabled on all WiFi-capable ports.
21+
These libraries are not currently enabled in any CircuitPython build, but may be in the future,
22+
with the ``u`` prefix dropped:
23+
``uctypes``, ``uhashlib``, ``uzlib``.
3824

3925
.. toctree::
4026
:maxdepth: 1
@@ -44,13 +30,14 @@ Not all of these are enabled on all WiFi-capable ports.
4430
array.rst
4531
binascii.rst
4632
collections.rst
33+
errno.rst
4734
gc.rst
4835
hashlib.rst
36+
io.rst
37+
json.rst
38+
re.rst
4939
sys.rst
50-
uerrno.rst
51-
uio.rst
52-
ujson.rst
53-
ure.rst
40+
uctypes.rst
5441
uselect.rst
5542
usocket.rst
5643
ussl.rst
@@ -59,8 +46,8 @@ Not all of these are enabled on all WiFi-capable ports.
5946
Omitted functions in the ``string`` library
6047
-------------------------------------------
6148

62-
A few string operations are not enabled on CircuitPython
63-
M0 non-Express builds, due to limited flash memory:
49+
A few string operations are not enabled on small builds
50+
(usually non-Express), due to limited flash memory:
6451
``string.center()``, ``string.partition()``, ``string.splitlines()``,
6552
``string.reversed()``.
6653

@@ -78,15 +65,3 @@ versions of CircuitPython.
7865
btree.rst
7966
framebuf.rst
8067
micropython.rst
81-
network.rst
82-
uctypes.rst
83-
84-
Libraries specific to the ESP8266
85-
---------------------------------
86-
87-
The following libraries are specific to the ESP8266.
88-
89-
.. toctree::
90-
:maxdepth: 2
91-
92-
esp.rst

0 commit comments

Comments
 (0)
0