diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5ccfb71c8..d809ba8cb6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,7 +37,7 @@ jobs: run: | sudo apt-get install -y eatmydata sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64 - pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid + pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid isort - name: Versions run: | gcc --version diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index 0d2c083a2f..9596a5904e 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit 0d2c083a2fb57a1562d4806775f45273abbfbfae +Subproject commit 9596a5904ed757e6fbffcf03e7aa77ae9ecf5223 diff --git a/locale/ID.po b/locale/ID.po index 9e10156e6a..c85b8edfe5 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2020-07-06 18:10+0000\n" "Last-Translator: oon arfiandwi \n" "Language-Team: LANGUAGE \n" @@ -111,6 +111,10 @@ msgstr "%q() mengambil posisi argumen %d tapi %d yang diberikan" msgid "'%q' argument required" msgstr "'%q' argumen dibutuhkan" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3137,7 +3141,7 @@ msgstr "struct: index keluar dari jangkauan" msgid "struct: no fields" msgstr "struct: tidak ada fields" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 95ebeb1db2..71c360889e 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-17 18:00-0700\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -110,6 +110,10 @@ msgstr "" msgid "'%q' argument required" msgstr "" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3120,7 +3124,7 @@ msgstr "" msgid "struct: no fields" msgstr "" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index d09cf1e94b..2cecbcc109 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2020-05-24 03:22+0000\n" "Last-Translator: dronecz \n" "Language-Team: LANGUAGE \n" @@ -111,6 +111,10 @@ msgstr "" msgid "'%q' argument required" msgstr "" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3106,7 +3110,7 @@ msgstr "" msgid "struct: no fields" msgstr "" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 1e168db528..014cd749f7 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2020-06-16 18:24+0000\n" "Last-Translator: Andreas Buchen \n" "Language: de_DE\n" @@ -110,6 +110,10 @@ msgstr "%q() nimmt %d Argumente ohne Keyword an, aber es wurden %d angegeben" msgid "'%q' argument required" msgstr "'%q' Argument erforderlich" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3190,7 +3194,7 @@ msgstr "struct: index außerhalb gültigen Bereichs" msgid "struct: no fields" msgstr "struct: keine Felder" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "substring nicht gefunden" diff --git a/locale/es.po b/locale/es.po index 0dd09a98df..2ebad85e90 100644 --- a/locale/es.po +++ b/locale/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2020-07-13 19:24+0000\n" "Last-Translator: Alvaro Figueroa \n" "Language-Team: \n" @@ -115,6 +115,10 @@ msgstr "%q() toma %d argumentos posicionales pero %d fueron dados" msgid "'%q' argument required" msgstr "argumento '%q' requerido" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3174,7 +3178,7 @@ msgstr "struct: index fuera de rango" msgid "struct: no fields" msgstr "struct: sin campos" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "substring no encontrado" diff --git a/locale/fil.po b/locale/fil.po index 1297ce186d..e359829309 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -106,6 +106,10 @@ msgstr "" msgid "'%q' argument required" msgstr "'%q' argument kailangan" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3153,7 +3157,7 @@ msgstr "struct: index hindi maabot" msgid "struct: no fields" msgstr "struct: walang fields" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "substring hindi nahanap" diff --git a/locale/fr.po b/locale/fr.po index 4582974d45..6dffd41eb5 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2020-06-05 17:29+0000\n" "Last-Translator: aberwag \n" "Language: fr\n" @@ -115,6 +115,10 @@ msgstr "%q() prend %d arguments positionnels mais %d ont été donnés" msgid "'%q' argument required" msgstr "'%q' argument requis" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3197,7 +3201,7 @@ msgstr "struct : index hors limites" msgid "struct: no fields" msgstr "struct : aucun champs" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "sous-chaîne non trouvée" diff --git a/locale/it_IT.po b/locale/it_IT.po index 2358433825..92b8fbaaa3 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -105,6 +105,10 @@ msgstr "%q() prende %d argomenti posizionali ma ne sono stati forniti %d" msgid "'%q' argument required" msgstr "'%q' argomento richiesto" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3160,7 +3164,7 @@ msgstr "struct: indice fuori intervallo" msgid "struct: no fields" msgstr "struct: nessun campo" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "sottostringa non trovata" diff --git a/locale/ko.po b/locale/ko.po index 6829f6819f..8aa96e9017 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2019-05-06 14:22-0700\n" "Last-Translator: \n" "Language-Team: LANGUAGE \n" @@ -105,6 +105,10 @@ msgstr "" msgid "'%q' argument required" msgstr "" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3103,7 +3107,7 @@ msgstr "" msgid "struct: no fields" msgstr "" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index d39d0bb189..253d18a04c 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2020-07-13 17:39+0000\n" "Last-Translator: _fonzlate \n" "Language-Team: none\n" @@ -111,6 +111,10 @@ msgstr "%q() verwacht %d positionele argumenten maar kreeg %d" msgid "'%q' argument required" msgstr "'%q' argument vereist" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3162,7 +3166,7 @@ msgstr "struct: index buiten bereik" msgid "struct: no fields" msgstr "struct: geen velden" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "deelreeks niet gevonden" diff --git a/locale/pl.po b/locale/pl.po index e8b7298a2a..b2b2d7a16d 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -105,6 +105,10 @@ msgstr "%q() bierze %d argumentów pozycyjnych, lecz podano %d" msgid "'%q' argument required" msgstr "'%q' wymaga argumentu" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3110,7 +3114,7 @@ msgstr "struct: indeks poza zakresem" msgid "struct: no fields" msgstr "struct: brak pól" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "brak pod-łańcucha" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 024608b3db..b7062f5f0a 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2020-07-09 17:23+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" @@ -111,6 +111,10 @@ msgstr "%q() recebe %d argumentos posicionais, porém %d foram informados" msgid "'%q' argument required" msgstr "'%q' argumento(s) requerido(s)" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3186,7 +3190,7 @@ msgstr "struct: índice fora do intervalo" msgid "struct: no fields" msgstr "struct: sem campos" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "a substring não foi encontrada" diff --git a/locale/sv.po b/locale/sv.po index b588cbea7e..ffec64bfea 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2020-07-13 17:39+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" @@ -111,6 +111,10 @@ msgstr "%q() kräver %d positionsargument men %d gavs" msgid "'%q' argument required" msgstr "'%q' argument krävs" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3155,7 +3159,7 @@ msgstr "struct: index utanför intervallet" msgid "struct: no fields" msgstr "struct: inga fält" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "det gick inte att hitta delsträng" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 0f6d55fd16..6c19fb67cd 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-07-07 14:38-0500\n" +"POT-Creation-Date: 2020-07-17 18:03-0700\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -111,6 +111,10 @@ msgstr "%q() cǎiyòng %d wèizhì cānshù, dàn gěi chū %d" msgid "'%q' argument required" msgstr "xūyào '%q' cānshù" +#: py/objarray.c +msgid "'%q' object is not bytes-like" +msgstr "" + #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" @@ -3140,7 +3144,7 @@ msgstr "jiégòu: suǒyǐn chāochū fànwéi" msgid "struct: no fields" msgstr "jiégòu: méiyǒu zìduàn" -#: py/objstr.c +#: py/objarray.c py/objstr.c msgid "substring not found" msgstr "wèi zhǎodào zi zìfú chuàn" diff --git a/main.c b/main.c index 5ad146c9ce..2fb4689136 100755 --- a/main.c +++ b/main.c @@ -101,6 +101,10 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) { } } +#if MICROPY_ENABLE_PYSTACK +static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)]); +#endif + void start_mp(supervisor_allocation* heap) { reset_status_led(); autoreload_stop(); @@ -129,6 +133,10 @@ void start_mp(supervisor_allocation* heap) { // Clear the readline history. It references the heap we're about to destroy. readline_init0(); + #if MICROPY_ENABLE_PYSTACK + mp_pystack_init(_pystack, _pystack + (sizeof(_pystack) / sizeof(size_t))); + #endif + #if MICROPY_ENABLE_GC gc_init(heap->ptr, heap->ptr + heap->length / 4); #endif diff --git a/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk b/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk index 28b1434fb7..34301da3f0 100644 --- a/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk +++ b/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk @@ -13,6 +13,4 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk index da5f1ffac8..619b7d6944 100755 --- a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk @@ -12,6 +12,7 @@ EXTERNAL_FLASH_DEVICES = "W25Q32JV_IQ" LONGINT_IMPL = MPZ CIRCUITPY_BITBANGIO = 0 +CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_VECTORIO = 0 diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk index 7a9e5a7808..13ae59de46 100755 --- a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk @@ -11,6 +11,4 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2 EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, S25FL064L" LONGINT_IMPL = MPZ -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index febd2a6c36..9c7fe3398a 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -13,7 +13,6 @@ LONGINT_IMPL = MPZ CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_NETWORK = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 CIRCUITPY_AUDIOMP3 = 0 diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk index b6490433e5..e0adc11b06 100644 --- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk @@ -10,38 +10,32 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -# TODO: Turn off analogio for now for space reasons, but restore it -# when frozen module gets smaller. -CIRCUITPY_ANALOGIO = 0 CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_AUDIOPWMIO = 0 +CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BITBANGIO = 0 +CIRCUITPY_BITBANG_APA102 = 0 CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_GAMEPADSHIFT = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 -CIRCUITPY_NETWORK = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_PS2IO = 0 +CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 +CIRCUITPY_SAMD = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_USB_MIDI = 0 -CIRCUITPY_AUDIOPWMIO = 0 -CIRCUITPY_AUDIOMP3 = 0 -CIRCUITPY_BITBANG_APA102 = 0 -CIRCUITPY_BLEIO = 0 -CIRCUITPY_GAMEPADSHIFT = 0 -CIRCUITPY_NETWORK = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_SAMD = 0 -CIRCUITPY_TOUCHIO = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_ANALOGIO = 1 CIRCUITPY_AUDIOMIXER = 1 CIRCUITPY_AUDIOIO = 1 CIRCUITPY_DISPLAYIO = 1 CIRCUITPY_GAMEPAD = 1 -CIRCUITPY_STAGE = 1 CIRCUITPY_MATH = 1 +CIRCUITPY_STAGE = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pewpew_m4 CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk index 13863e565f..567f1db205 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk @@ -12,6 +12,4 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = AT25SF041A LONGINT_IMPL = MPZ -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 CIRCUITPY_PS2IO = 1 diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.mk b/ports/atmel-samd/boards/uchip/mpconfigboard.mk index 196068a1e0..d08690a15a 100644 --- a/ports/atmel-samd/boards/uchip/mpconfigboard.mk +++ b/ports/atmel-samd/boards/uchip/mpconfigboard.mk @@ -10,9 +10,7 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -# Tweak inlining depending on language. -ifeq ($(TRANSLATION), zh_Latn_pinyin) +# Always use aggressive inlining CFLAGS_INLINE_LIMIT = 45 -else -CFLAGS_INLINE_LIMIT = 70 -endif + +SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk index e06a2af7ee..71586d6e05 100644 --- a/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk +++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk @@ -24,10 +24,13 @@ CIRCUITPY_BLEIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_NETWORK = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_USB_MIDI = 0 CIRCUITPY_RTC = 0 + +# Enable board-specific modules +USER_C_MODULES = boards/winterbloom_big_honking_button/usermods +CFLAGS += -DMODULE_BHB_ENABLED=1 diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c new file mode 100644 index 0000000000..54ce173d81 --- /dev/null +++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c @@ -0,0 +1,120 @@ +#include "py/obj.h" +#include "py/runtime.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "samd/pins.h" +#include "sam.h" + +STATIC mp_obj_t _bhb_read_adc(void); + +STATIC mp_obj_t _bhb_init_adc(void) { + claim_pin(&pin_PB08); + common_hal_never_reset_pin(&pin_PB08); + + /* Enable the APB clock for the ADC. */ + PM->APBCMASK.reg |= PM_APBCMASK_ADC; + + /* Enable GCLK0 for the ADC */ + GCLK->CLKCTRL.reg = GCLK_CLKCTRL_CLKEN | + GCLK_CLKCTRL_GEN_GCLK0 | + GCLK_CLKCTRL_ID_ADC; + + /* Wait for bus synchronization. */ + while (GCLK->STATUS.bit.SYNCBUSY) {}; + + uint32_t bias = (*((uint32_t *) ADC_FUSES_BIASCAL_ADDR) & ADC_FUSES_BIASCAL_Msk) >> ADC_FUSES_BIASCAL_Pos; + uint32_t linearity = (*((uint32_t *) ADC_FUSES_LINEARITY_0_ADDR) & ADC_FUSES_LINEARITY_0_Msk) >> ADC_FUSES_LINEARITY_0_Pos; + linearity |= ((*((uint32_t *) ADC_FUSES_LINEARITY_1_ADDR) & ADC_FUSES_LINEARITY_1_Msk) >> ADC_FUSES_LINEARITY_1_Pos) << 5; + + /* Wait for bus synchronization. */ + while (ADC->STATUS.bit.SYNCBUSY) {}; + + /* Write the calibration data. */ + ADC->CALIB.reg = ADC_CALIB_BIAS_CAL(bias) | ADC_CALIB_LINEARITY_CAL(linearity); + + /* Use the internal VCC reference. This is 1/2 of what's on VCCA. + since VCCA is 3.3v, this is 1.65v. + */ + ADC->REFCTRL.reg = ADC_REFCTRL_REFSEL_INTVCC1; + + /* Capture 64 samples. */ + ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_64 | ADC_AVGCTRL_ADJRES(4); + + /* Set the clock prescaler to 32, which is the same as the CircuitPython default. + Set the resolution to 16 for averaging + */ + ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV32 | + ADC_CTRLB_RESSEL_16BIT; + + /* Configure the input parameters. + + - GAIN_DIV2 means that the input voltage is halved. This is important + because the voltage reference is 1/2 of VCCA. So if you want to + measure 0-3.3v, you need to halve the input as well. + + - MUXNEG_GND means that the ADC should compare the input value to GND. + + - MUXPOS_PIN3 means that the ADC should read from AIN2, or PB08. + */ + ADC->INPUTCTRL.reg = ADC_INPUTCTRL_GAIN_DIV2 | + ADC_INPUTCTRL_MUXNEG_GND | + ADC_INPUTCTRL_MUXPOS_PIN2; + + + /* Set PB08 as an input pin. */ + PORT->Group[1].DIRCLR.reg = PORT_PB08; + + /* Enable the peripheral multiplexer for PB08. */ + PORT->Group[1].PINCFG[8].reg |= PORT_PINCFG_PMUXEN; + + /* Set PB08 to function B which is analog input. */ + PORT->Group[1].PMUX[4].reg |= PORT_PMUX_PMUXE_B; + + /* Wait for bus synchronization. */ + while (ADC->STATUS.bit.SYNCBUSY) {}; + + /* Enable the ADC. */ + ADC->CTRLA.bit.ENABLE = true; + + /* Make one read and throw it away, as per the datasheet. */ + _bhb_read_adc(); + + return mp_const_none; +} + +STATIC mp_obj_t _bhb_read_adc(void) { + /* Wait for bus synchronization. */ + while (ADC->STATUS.bit.SYNCBUSY) {}; + + /* Start the ADC using a software trigger. */ + ADC->SWTRIG.bit.START = true; + + /* Wait for the result ready flag to be set. */ + while (ADC->INTFLAG.bit.RESRDY == 0); + + /* Clear the flag. */ + ADC->INTFLAG.reg = ADC_INTFLAG_RESRDY; + + /* Read the value. */ + uint32_t result = ADC->RESULT.reg; + + return MP_OBJ_NEW_SMALL_INT(result); +} + + +STATIC MP_DEFINE_CONST_FUN_OBJ_0(_bhb_init_adc_obj, _bhb_init_adc); +STATIC MP_DEFINE_CONST_FUN_OBJ_0(_bhb_read_adc_obj, _bhb_read_adc); + +STATIC const mp_rom_map_elem_t _bhb_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__bhb) }, + { MP_ROM_QSTR(MP_QSTR_init_adc), MP_ROM_PTR(&_bhb_init_adc_obj) }, + { MP_ROM_QSTR(MP_QSTR_read_adc), MP_ROM_PTR(&_bhb_read_adc_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(_bhb_module_globals, _bhb_module_globals_table); + +const mp_obj_module_t _bhb_user_cmodule = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&_bhb_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR__bhb, _bhb_user_cmodule, MODULE_BHB_ENABLED); diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/micropython.mk b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/micropython.mk new file mode 100644 index 0000000000..9374ec34ea --- /dev/null +++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/micropython.mk @@ -0,0 +1,6 @@ +USERMODULES_DIR := $(USERMOD_DIR) + +# Add all C files to SRC_USERMOD. +SRC_USERMOD += $(USERMODULES_DIR)/bhb.c + +CFLAGS_USERMOD += -I$(USERMODULES_DIR) diff --git a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk index 11592073f9..9217cdf23d 100644 --- a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk +++ b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk @@ -23,7 +23,6 @@ CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_GAMEPAD = 0 CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_NETWORK = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index face79fad7..e4cf9ca833 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -54,8 +54,7 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 # The ifndef's allow overriding in mpconfigboard.mk. ifndef CIRCUITPY_NETWORK -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 +CIRCUITPY_NETWORK = 0 endif ifndef CIRCUITPY_PS2IO diff --git a/ports/nrf/boards/particle_argon/mpconfigboard.mk b/ports/nrf/boards/particle_argon/mpconfigboard.mk index 2ca08b9829..f8d3d2aca2 100644 --- a/ports/nrf/boards/particle_argon/mpconfigboard.mk +++ b/ports/nrf/boards/particle_argon/mpconfigboard.mk @@ -8,7 +8,3 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "MX25L3233F" - -# Support for the Ethernet FeatherWing -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 diff --git a/ports/nrf/boards/particle_boron/mpconfigboard.mk b/ports/nrf/boards/particle_boron/mpconfigboard.mk index f03f43a7bc..eada97a730 100644 --- a/ports/nrf/boards/particle_boron/mpconfigboard.mk +++ b/ports/nrf/boards/particle_boron/mpconfigboard.mk @@ -8,7 +8,3 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "MX25L3233F" - -# Support for the Ethernet FeatherWing -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.mk b/ports/nrf/boards/particle_xenon/mpconfigboard.mk index 44309bbca2..6062da378f 100644 --- a/ports/nrf/boards/particle_xenon/mpconfigboard.mk +++ b/ports/nrf/boards/particle_xenon/mpconfigboard.mk @@ -8,7 +8,3 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 1 EXTERNAL_FLASH_DEVICES = "MX25L3233F" - -# Support for the Ethernet FeatherWing -CIRCUITPY_NETWORK = 1 -MICROPY_PY_WIZNET5K = 5500 diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 3c2df37ffc..a1a7ec2389 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -119,6 +119,7 @@ #define MICROPY_QSTR_BYTES_IN_HASH (1) #define MICROPY_REPL_AUTO_INDENT (1) #define MICROPY_REPL_EVENT_DRIVEN (0) +#define MICROPY_ENABLE_PYSTACK (1) #define MICROPY_STACK_CHECK (1) #define MICROPY_STREAMS_NON_BLOCK (1) #ifndef MICROPY_USE_INTERNAL_PRINTF @@ -797,6 +798,10 @@ void supervisor_run_background_tasks_if_tick(void); #define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000 #endif +#ifndef CIRCUITPY_PYSTACK_SIZE +#define CIRCUITPY_PYSTACK_SIZE 1024 +#endif + #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" #define CIRCUITPY_VERBOSE_BLE 0 diff --git a/py/mpz.c b/py/mpz.c index 7800cdcc45..41b46f92ff 100644 --- a/py/mpz.c +++ b/py/mpz.c @@ -444,6 +444,10 @@ STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t * } ilen = id - oidig; + // check to prevent usb starvation + #ifdef RUN_BACKGROUND_TASKS + RUN_BACKGROUND_TASKS; + #endif } return ilen; diff --git a/py/objarray.c b/py/objarray.c index 7dfdc5b121..5d83f06977 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -400,6 +400,66 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) { STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend); #endif +#if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_CPYTHON_COMPAT +STATIC mp_obj_t buffer_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) { + mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_bytearray)); + const mp_obj_type_t *self_type = mp_obj_get_type(args[0]); + + mp_buffer_info_t haystack_bufinfo; + mp_get_buffer_raise(args[0], &haystack_bufinfo, MP_BUFFER_READ); + + mp_buffer_info_t needle_bufinfo; + mp_get_buffer_raise(args[1], &needle_bufinfo, MP_BUFFER_READ); + + if (mp_binary_get_size('@', needle_bufinfo.typecode, NULL) != 1) { + mp_raise_TypeError(translate("a bytes-like object is required")); + } + + const byte *start = haystack_bufinfo.buf; + const byte *end = ((const byte*)haystack_bufinfo.buf) + haystack_bufinfo.len; + if (n_args >= 3 && args[2] != mp_const_none) { + start += mp_get_index(self_type, haystack_bufinfo.len, args[2], true); + } + if (n_args >= 4 && args[3] != mp_const_none) { + end = ((const byte*)haystack_bufinfo.buf) + mp_get_index(self_type, haystack_bufinfo.len, args[3], true); + } + + const byte *p = NULL; + if (end >= start) { + p = find_subbytes(start, end - start, needle_bufinfo.buf, needle_bufinfo.len, direction); + } + + if (p == NULL) { + if (is_index) { + mp_raise_ValueError(translate("substring not found")); + } else { + return MP_OBJ_NEW_SMALL_INT(-1); + } + } + return MP_OBJ_NEW_SMALL_INT(p - (const byte*) haystack_bufinfo.buf); +} + +STATIC mp_obj_t buffer_find(size_t n_args, const mp_obj_t *args) { + return buffer_finder(n_args, args, 1, false); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(buffer_find_obj, 2, 4, buffer_find); + +STATIC mp_obj_t buffer_rfind(size_t n_args, const mp_obj_t *args) { + return buffer_finder(n_args, args, -1, false); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(buffer_rfind_obj, 2, 4, buffer_rfind); + +STATIC mp_obj_t buffer_index(size_t n_args, const mp_obj_t *args) { + return buffer_finder(n_args, args, 1, true); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(buffer_index_obj, 2, 4, buffer_index); + +STATIC mp_obj_t buffer_rindex(size_t n_args, const mp_obj_t *args) { + return buffer_finder(n_args, args, -1, true); +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(buffer_rindex_obj, 2, 4, buffer_rindex); +#endif + STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { if (value == MP_OBJ_NULL) { // delete item @@ -580,7 +640,13 @@ STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table); STATIC const mp_rom_map_elem_t bytearray_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) }, { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) }, + #if MICROPY_CPYTHON_COMPAT + { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&buffer_find_obj) }, + { MP_ROM_QSTR(MP_QSTR_rfind), MP_ROM_PTR(&buffer_rfind_obj) }, + { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&buffer_index_obj) }, + { MP_ROM_QSTR(MP_QSTR_rindex), MP_ROM_PTR(&buffer_rindex_obj) }, + { MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&array_decode_obj) }, #endif }; diff --git a/shared-bindings/network/__init__.c b/shared-bindings/network/__init__.c index 58aa13473e..4bd543a0a5 100644 --- a/shared-bindings/network/__init__.c +++ b/shared-bindings/network/__init__.c @@ -40,6 +40,9 @@ //| """Network Interface Management //| +//| .. warning:: This module is disabled in 6.x and will removed in 7.x. Please use networking +//| libraries instead. +//| //| This module provides a registry of configured NICs. //| It is used by the 'socket' module to look up a suitable //| NIC when a socket is created.""" diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c index 0ded0218bb..2485d8ef8c 100644 --- a/shared-bindings/socket/__init__.c +++ b/shared-bindings/socket/__init__.c @@ -39,6 +39,9 @@ //| """TCP, UDP and RAW socket support //| +//| .. warning:: This module is disabled in 6.x and will removed in 7.x. Please use networking +//| libraries instead. (Native networking will provide a socket compatible class.) +//| //| Create TCP, UDP and RAW sockets for communicating over the Internet.""" //| diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index 3443d9e426..1aca4611ea 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -49,20 +49,7 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar //| STATIC mp_obj_t vectorio_polygon_obj_get_points(mp_obj_t self_in) { vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t list = mp_obj_new_list(0, NULL); - - size_t len = 0; - mp_obj_t *items; - mp_obj_list_get(common_hal_vectorio_polygon_get_points(self), &len, &items); - - for (size_t i = 0; i < len; i += 2) { - mp_obj_t tuple[] = { items[i], items[i+1] }; - mp_obj_list_append( - list, - mp_obj_new_tuple(2, tuple) - ); - } - return list; + return common_hal_vectorio_polygon_get_points(self); } MP_DEFINE_CONST_FUN_OBJ_1(vectorio_polygon_get_points_obj, vectorio_polygon_obj_get_points); diff --git a/shared-bindings/wiznet/__init__.c b/shared-bindings/wiznet/__init__.c index bc7ff150fe..8df06b5467 100644 --- a/shared-bindings/wiznet/__init__.c +++ b/shared-bindings/wiznet/__init__.c @@ -35,7 +35,12 @@ #include "shared-module/network/__init__.h" -//| """Support for WizNet hardware, including the WizNet 5500 Ethernet adaptor.""" +//| """Support for WizNet hardware, including the WizNet 5500 Ethernet adaptor. +//| +//| +//| .. warning:: This module is disabled in 6.x and will removed in 7.x. Please use networking +//| libraries instead. +//| """ //| extern const mod_network_nic_type_t mod_network_nic_type_wiznet5k; diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index c898bbb98f..efc28470fb 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -190,9 +190,7 @@ void reset_displays(void) { common_hal_displayio_epaperdisplay_show(display, NULL); #if CIRCUITPY_FRAMEBUFFERIO } else if (displays[i].framebuffer_display.base.type == &framebufferio_framebufferdisplay_type) { - framebufferio_framebufferdisplay_obj_t* display = &displays[i].framebuffer_display; - display->auto_refresh = true; - common_hal_framebufferio_framebufferdisplay_show(display, NULL); + framebufferio_framebufferdisplay_reset(&displays[i].framebuffer_display); #endif } } diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c index 7d09e0baeb..2a90fa0d4a 100644 --- a/shared-module/framebufferio/FramebufferDisplay.c +++ b/shared-module/framebufferio/FramebufferDisplay.c @@ -318,3 +318,8 @@ void framebufferio_framebufferdisplay_collect_ptrs(framebufferio_framebufferdisp gc_collect_ptr(self->framebuffer); displayio_display_core_collect_ptrs(&self->core); } + +void framebufferio_framebufferdisplay_reset(framebufferio_framebufferdisplay_obj_t* self) { + common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, true); + common_hal_framebufferio_framebufferdisplay_show(self, NULL); +} diff --git a/shared-module/framebufferio/FramebufferDisplay.h b/shared-module/framebufferio/FramebufferDisplay.h index 1b68d2ab02..ca1ab984a3 100644 --- a/shared-module/framebufferio/FramebufferDisplay.h +++ b/shared-module/framebufferio/FramebufferDisplay.h @@ -55,6 +55,7 @@ typedef struct { void framebufferio_framebufferdisplay_background(framebufferio_framebufferdisplay_obj_t* self); void release_framebufferdisplay(framebufferio_framebufferdisplay_obj_t* self); void reset_framebufferdisplay(framebufferio_framebufferdisplay_obj_t* self); +void framebufferio_framebufferdisplay_reset(framebufferio_framebufferdisplay_obj_t* self); void framebufferio_framebufferdisplay_collect_ptrs(framebufferio_framebufferdisplay_obj_t* self); diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c index 0025d4bfc4..c44c13fd73 100644 --- a/shared-module/vectorio/Polygon.c +++ b/shared-module/vectorio/Polygon.c @@ -20,7 +20,7 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple size_t len = 0; mp_obj_t *items; mp_obj_list_get(points_tuple_list, &len, &items); - VECTORIO_POLYGON_DEBUG("polygon_points_list len: %d\n", len); + VECTORIO_POLYGON_DEBUG(" self.len: %d, len: %d, ", self->len, len); if ( len < 3 ) { mp_raise_TypeError_varg(translate("Polygon needs at least 3 points")); @@ -28,9 +28,11 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple if ( self->len < 2*len ) { if ( self->points_list != NULL ) { + VECTORIO_POLYGON_DEBUG("free(%d), ", sizeof(self->points_list)); gc_free( self->points_list ); } self->points_list = gc_alloc( 2 * len * sizeof(int), false, false ); + VECTORIO_POLYGON_DEBUG("alloc(%p, %d)", self->points_list, 2 * len * sizeof(int)); } self->len = 2*len; @@ -56,22 +58,35 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list) { - VECTORIO_POLYGON_DEBUG("%p polygon_construct\n", self); + VECTORIO_POLYGON_DEBUG("%p polygon_construct: ", self); self->points_list = NULL; self->len = 0; self->on_dirty.obj = NULL; _clobber_points_list( self, points_list ); + VECTORIO_POLYGON_DEBUG("\n"); } mp_obj_t common_hal_vectorio_polygon_get_points(vectorio_polygon_t *self) { - return self->points_list; + VECTORIO_POLYGON_DEBUG("%p common_hal_vectorio_polygon_get_points {len: %d, points_list: %p}\n", self, self->len, self->points_list); + mp_obj_t list = mp_obj_new_list(self->len/2, NULL); + + for (size_t i = 0; i < self->len; i += 2) { + mp_obj_t tuple[] = { mp_obj_new_int(self->points_list[i]), mp_obj_new_int(self->points_list[i+1]) }; + mp_obj_list_append( + list, + mp_obj_new_tuple(2, tuple) + ); + } + return list; } void common_hal_vectorio_polygon_set_points(vectorio_polygon_t *self, mp_obj_t points_list) { + VECTORIO_POLYGON_DEBUG("%p common_hal_vectorio_polygon_set_points: ", self); _clobber_points_list( self, points_list ); if (self->on_dirty.obj != NULL) { self->on_dirty.event(self->on_dirty.obj); } + VECTORIO_POLYGON_DEBUG("\n"); } void common_hal_vectorio_polygon_set_on_dirty(vectorio_polygon_t *self, vectorio_event_t notification) { diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index bfe8a7b259..81f46b3fa0 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -223,8 +223,8 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ pixel_to_get_x = (input_pixel.y - self->absolute_transform->dy * self->x - self->absolute_transform->y) / self->absolute_transform->dy; pixel_to_get_y = (input_pixel.x - self->absolute_transform->dx * self->y - self->absolute_transform->x) / self->absolute_transform->dx; } else { - pixel_to_get_x = (input_pixel.x - self->absolute_transform->dx * self->x) / self->absolute_transform->dx; - pixel_to_get_y = (input_pixel.y - self->absolute_transform->dy * self->y) / self->absolute_transform->dy; + pixel_to_get_x = (input_pixel.x - self->absolute_transform->dx * self->x - self->absolute_transform->x) / self->absolute_transform->dx; + pixel_to_get_y = (input_pixel.y - self->absolute_transform->dy * self->y - self->absolute_transform->y) / self->absolute_transform->dy; } VECTORIO_SHAPE_PIXEL_DEBUG(" get_pixel %p (%3d, %3d) -> ( %3d, %3d )", self->ishape.shape, input_pixel.x, input_pixel.y, pixel_to_get_x, pixel_to_get_y); #ifdef VECTORIO_PERF diff --git a/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c index d10579c4f9..8e12dd3625 100644 --- a/supervisor/shared/background_callback.c +++ b/supervisor/shared/background_callback.c @@ -24,6 +24,8 @@ * THE SOFTWARE. */ +#include + #include "py/gc.h" #include "py/mpconfig.h" #include "supervisor/background_callback.h" @@ -101,6 +103,12 @@ void background_callback_end_critical_section() { void background_callback_reset() { CALLBACK_CRITICAL_BEGIN; + background_callback_t *cb = (background_callback_t*)callback_head; + while(cb) { + background_callback_t *next = cb->next; + memset(cb, 0, sizeof(*cb)); + cb = next; + } callback_head = NULL; callback_tail = NULL; in_background_callback = false; diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index bc270030f3..4af59f78e3 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -66,7 +66,7 @@ static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks); -static background_callback_t callback; +static background_callback_t tick_callback; volatile uint64_t last_finished_tick = 0; @@ -119,7 +119,7 @@ void supervisor_tick(void) { #endif } #endif - background_callback_add(&callback, supervisor_background_tasks, NULL); + background_callback_add(&tick_callback, supervisor_background_tasks, NULL); } uint64_t supervisor_ticks_ms64() { diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 472be96d52..36b5ec05d6 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -64,8 +64,8 @@ void usb_init(void) { tusb_init(); #if MICROPY_KBD_EXCEPTION - // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() callback will be invoked when Ctrl+C is received - // This callback always got invoked regardless of mp_interrupt_char value since we only set it once here + // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() usb_callback will be invoked when Ctrl+C is received + // This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here tud_cdc_set_wanted_char(CHAR_CTRL_C); #endif @@ -83,14 +83,14 @@ void usb_background(void) { } } -static background_callback_t callback; +static background_callback_t usb_callback; static void usb_background_do(void* unused) { usb_background(); } void usb_irq_handler(void) { tud_int_handler(0); - background_callback_add(&callback, usb_background_do, NULL); + background_callback_add(&usb_callback, usb_background_do, NULL); } //--------------------------------------------------------------------+ diff --git a/tools/convert_release_notes.py b/tools/convert_release_notes.py index 4b16f005ec..797e71834b 100644 --- a/tools/convert_release_notes.py +++ b/tools/convert_release_notes.py @@ -4,13 +4,14 @@ import sys import mistune +import mistune.renderers print(sys.argv[1]) with open(sys.argv[1], "r") as source_file: source = source_file.read() -html = mistune.Markdown() +html = mistune.create_markdown() print() print("HTML") @@ -19,39 +20,39 @@ print("From the GitHub release page:\n
") print(html(source)) print("
") -class AdafruitBBCodeRenderer: - def __init__(self, **kwargs): - self.options = kwargs - +class AdafruitBBCodeRenderer(mistune.renderers.BaseRenderer): def placeholder(self): return '' def paragraph(self, text): return text + "\n\n" + def block_text(self, text): + return text + def text(self, text): return text def link(self, link, title, text): - return "[url={}]{}[/url]".format(link, text) + return "[url={}]{}[/url]".format(link, title) def autolink(self, link, is_email): if not is_email: return "[url={}]{}[/url]".format(link, link) return link - def header(self, text, level, raw): + def heading(self, text, level): return "[b][size=150]{}[/size][/b]\n".format(text) def codespan(self, text): return "[color=#E74C3C][size=95]{}[/size][/color]".format(text) - def list_item(self, text): + def list_item(self, text, level): return "[*]{}[/*]\n".format(text.strip()) - def list(self, body, ordered=True): + def list(self, text, ordered, level, start=None): ordered_indicator = "=" if ordered else "" - return "[list{}]\n{}[/list]".format(ordered_indicator, body) + return "[list{}]\n{}[/list]".format(ordered_indicator, text) def double_emphasis(self, text): return "[b]{}[/b]".format(text) @@ -59,7 +60,10 @@ class AdafruitBBCodeRenderer: def emphasis(self, text): return "[b]{}[/b]".format(text) -bbcode = mistune.Markdown(renderer=AdafruitBBCodeRenderer()) + def strong(self, text): + return "[i]{}[/i]".format(text) + +bbcode = mistune.create_markdown(renderer=AdafruitBBCodeRenderer()) print() print("BBCode") diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index b9366f6bab..e5da610352 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -2,24 +2,91 @@ # # SPDX-License-Identifier: MIT +import ast import os +import re import sys -import astroid import traceback -top_level = sys.argv[1].strip("/") -stub_directory = sys.argv[2] +import isort + + +IMPORTS_IGNORE = frozenset({'int', 'float', 'bool', 'str', 'bytes', 'tuple', 'list', 'set', 'dict', 'bytearray', 'file', 'buffer'}) +IMPORTS_TYPING = frozenset({'Any', 'Optional', 'Union', 'Tuple', 'List', 'Sequence'}) +IMPORTS_TYPESHED = frozenset({'ReadableBuffer', 'WritableBuffer'}) + + +def is_any(node): + node_type = type(node) + if node is None: + return True + if node_type == ast.Name and node.id == "Any": + return True + if (node_type == ast.Attribute and type(node.value) == ast.Name + and node.value.id == "typing" and node.attr == "Any"): + return True + return False + + +def report_missing_annotations(tree): + for node in ast.walk(tree): + node_type = type(node) + if node_type == ast.AnnAssign: + if is_any(node.annotation): + print(f"Missing attribute type on line {node.lineno}") + elif node_type == ast.arg: + if is_any(node.annotation) and node.arg != "self": + print(f"Missing argument type: {node.arg} on line {node.lineno}") + elif node_type == ast.FunctionDef: + if is_any(node.returns) and node.name != "__init__": + print(f"Missing return type: {node.name} on line {node.lineno}") + + +def extract_imports(tree): + modules = set() + typing = set() + typeshed = set() + + def collect_annotations(anno_tree): + if anno_tree is None: + return + for node in ast.walk(anno_tree): + node_type = type(node) + if node_type == ast.Name: + if node.id in IMPORTS_IGNORE: + continue + elif node.id in IMPORTS_TYPING: + typing.add(node.id) + elif node.id in IMPORTS_TYPESHED: + typeshed.add(node.id) + elif not node.id[0].isupper(): + modules.add(node.id) + + for node in ast.walk(tree): + node_type = type(node) + if (node_type == ast.AnnAssign) or (node_type == ast.arg): + collect_annotations(node.annotation) + elif node_type == ast.FunctionDef: + collect_annotations(node.returns) + + return { + "modules": sorted(modules), + "typing": sorted(typing), + "typeshed": sorted(typeshed), + } + def convert_folder(top_level, stub_directory): ok = 0 total = 0 filenames = sorted(os.listdir(top_level)) pyi_lines = [] + for filename in filenames: full_path = os.path.join(top_level, filename) file_lines = [] if os.path.isdir(full_path): - mok, mtotal = convert_folder(full_path, os.path.join(stub_directory, filename)) + (mok, mtotal) = convert_folder(full_path, os.path.join(stub_directory, filename)) ok += mok total += mtotal elif filename.endswith(".c"): @@ -44,44 +111,57 @@ def convert_folder(top_level, stub_directory): pyi_lines.extend(file_lines) if not pyi_lines: - return ok, total + return (ok, total) stub_filename = os.path.join(stub_directory, "__init__.pyi") print(stub_filename) stub_contents = "".join(pyi_lines) - os.makedirs(stub_directory, exist_ok=True) - with open(stub_filename, "w") as f: - f.write(stub_contents) # Validate that the module is a parseable stub. total += 1 try: - tree = astroid.parse(stub_contents) - for i in tree.body: - if 'name' in i.__dict__: - print(i.__dict__['name']) - for j in i.body: - if isinstance(j, astroid.scoped_nodes.FunctionDef): - if None in j.args.__dict__['annotations']: - print(f"Missing parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}\n") - if j.returns: - if 'Any' in j.returns.__dict__.values(): - print(f"Missing return type: {j.__dict__['name']} on line {j.__dict__['lineno']}") - elif isinstance(j, astroid.node_classes.AnnAssign): - if 'name' in j.__dict__['annotation'].__dict__: - if j.__dict__['annotation'].__dict__['name'] == 'Any': - print(f"missing attribute type on line {j.__dict__['lineno']}") - + tree = ast.parse(stub_contents) + imports = extract_imports(tree) + report_missing_annotations(tree) ok += 1 - except astroid.exceptions.AstroidSyntaxError as e: - e = e.__cause__ + except SyntaxError as e: traceback.print_exception(type(e), e, e.__traceback__) + return (ok, total) + + # Add import statements + import_lines = ["from __future__ import annotations"] + import_lines.extend(f"import {m}" for m in imports["modules"]) + import_lines.append("from typing import " + ", ".join(imports["typing"])) + import_lines.append("from _typeshed import " + ", ".join(imports["typeshed"])) + import_body = "\n".join(import_lines) + m = re.match(r'(\s*""".*?""")', stub_contents, flags=re.DOTALL) + if m: + stub_contents = m.group(1) + "\n\n" + import_body + "\n\n" + stub_contents[m.end():] + else: + stub_contents = import_body + "\n\n" + stub_contents + stub_contents = isort.code(stub_contents) + + # Adjust blank lines + stub_contents = re.sub(r"\n+class", "\n\n\nclass", stub_contents) + stub_contents = re.sub(r"\n+def", "\n\n\ndef", stub_contents) + stub_contents = re.sub(r"\n+^(\s+)def", lambda m: f"\n\n{m.group(1)}def", stub_contents, flags=re.M) + stub_contents = stub_contents.strip() + "\n" + + os.makedirs(stub_directory, exist_ok=True) + with open(stub_filename, "w") as f: + f.write(stub_contents) + print() - return ok, total + return (ok, total) -ok, total = convert_folder(top_level, stub_directory) -print(f"{ok} ok out of {total}") +if __name__ == "__main__": + top_level = sys.argv[1].strip("/") + stub_directory = sys.argv[2] -if ok != total: - sys.exit(total - ok) + (ok, total) = convert_folder(top_level, stub_directory) + + print(f"Parsing .pyi files: {total - ok} failed, {ok} passed") + + if ok != total: + sys.exit(total - ok)