From e2652f8aacf7bbde20ff6b4722df9ace6019b265 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 12 Oct 2021 12:34:14 +0530 Subject: [PATCH 01/84] add packet class --- py/circuitpy_defns.mk | 2 + shared-bindings/wifi/Packet.c | 70 +++++++++++++++++++++++++++++++++ shared-bindings/wifi/Packet.h | 41 +++++++++++++++++++ shared-bindings/wifi/__init__.c | 18 +++++---- 4 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 shared-bindings/wifi/Packet.c create mode 100644 shared-bindings/wifi/Packet.h diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 836f3c7af1..a03b629ca4 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -433,6 +433,7 @@ SRC_COMMON_HAL_ALL = \ watchdog/WatchDogMode.c \ watchdog/WatchDogTimer.c \ watchdog/__init__.c \ + wifi/Monitor.c \ wifi/Network.c \ wifi/Radio.c \ wifi/ScannedNetworks.c \ @@ -475,6 +476,7 @@ $(filter $(SRC_PATTERNS), \ paralleldisplay/ParallelBus.c \ supervisor/RunReason.c \ wifi/AuthMode.c \ + wifi/Packet.c \ ) SRC_BINDINGS_ENUMS += \ diff --git a/shared-bindings/wifi/Packet.c b/shared-bindings/wifi/Packet.c new file mode 100644 index 0000000000..d21c8b0639 --- /dev/null +++ b/shared-bindings/wifi/Packet.c @@ -0,0 +1,70 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/enum.h" + +#include "shared-bindings/wifi/Packet.h" + +MAKE_ENUM_VALUE(wifi_packet_type, packet, CH, PACKET_CH); +MAKE_ENUM_VALUE(wifi_packet_type, packet, LEN, PACKET_LEN); +MAKE_ENUM_VALUE(wifi_packet_type, packet, RAW, PACKET_RAW); +MAKE_ENUM_VALUE(wifi_packet_type, packet, RSSI, PACKET_RSSI); + +//| class Packet: +//| """The packet parameters.""" +//| +//| CH: object +//| """The packet's channel.""" +//| +//| LEN: object +//| """The packet's length.""" +//| +//| RAW: object +//| """The packet's payload.""" +//| +//| RSSI: object +//| """The packet's rssi.""" +//| +MAKE_ENUM_MAP(wifi_packet) { + MAKE_ENUM_MAP_ENTRY(packet, CH), + MAKE_ENUM_MAP_ENTRY(packet, LEN), + MAKE_ENUM_MAP_ENTRY(packet, RAW), + MAKE_ENUM_MAP_ENTRY(packet, RSSI), +}; +STATIC MP_DEFINE_CONST_DICT(wifi_packet_locals_dict, wifi_packet_locals_table); + +MAKE_PRINTER(wifi, wifi_packet); + +const mp_obj_type_t wifi_packet_type = { + { &mp_type_type }, + .name = MP_QSTR_Packet, + .print = wifi_packet_print, + .locals_dict = (mp_obj_t)&wifi_packet_locals_dict, + .flags = MP_TYPE_FLAG_EXTENDED, + MP_TYPE_EXTENDED_FIELDS( + .unary_op = mp_generic_unary_op, + ), +}; diff --git a/shared-bindings/wifi/Packet.h b/shared-bindings/wifi/Packet.h new file mode 100644 index 0000000000..09dfddfc98 --- /dev/null +++ b/shared-bindings/wifi/Packet.h @@ -0,0 +1,41 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_PACKET_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_PACKET_H + +#include "py/enum.h" + +typedef enum { + PACKET_CH, + PACKET_LEN, + PACKET_RAW, + PACKET_RSSI, +} wifi_packet_t; + +extern const mp_obj_type_t wifi_packet_type; + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_PACKET_H diff --git a/shared-bindings/wifi/__init__.c b/shared-bindings/wifi/__init__.c index ef72dced1f..399b47cc47 100644 --- a/shared-bindings/wifi/__init__.c +++ b/shared-bindings/wifi/__init__.c @@ -27,9 +27,10 @@ #include "py/objexcept.h" #include "py/runtime.h" #include "shared-bindings/wifi/__init__.h" -#include "shared-bindings/wifi/AuthMode.h" -#include "shared-bindings/wifi/Network.h" #include "shared-bindings/wifi/Radio.h" +#include "shared-bindings/wifi/Network.h" +#include "shared-bindings/wifi/AuthMode.h" +#include "shared-bindings/wifi/Packet.h" //| """ //| The `wifi` module provides necessary low-level functionality for managing @@ -51,16 +52,17 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(wifi___init___obj, wifi___init__); STATIC const mp_rom_map_elem_t wifi_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_wifi) }, - { MP_ROM_QSTR(MP_QSTR_Radio), MP_ROM_PTR(&wifi_radio_type) }, - { MP_ROM_QSTR(MP_QSTR_Network), MP_ROM_PTR(&wifi_network_type) }, - { MP_ROM_QSTR(MP_QSTR_AuthMode), MP_ROM_PTR(&wifi_authmode_type) }, - - // Properties - { MP_ROM_QSTR(MP_QSTR_radio), MP_ROM_PTR(&common_hal_wifi_radio_obj) }, // Initialization { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&wifi___init___obj) }, + { MP_ROM_QSTR(MP_QSTR_Radio), MP_ROM_PTR(&wifi_radio_type) }, + { MP_ROM_QSTR(MP_QSTR_Network), MP_ROM_PTR(&wifi_network_type) }, + { MP_ROM_QSTR(MP_QSTR_AuthMode), MP_ROM_PTR(&wifi_authmode_type) }, + { MP_ROM_QSTR(MP_QSTR_Packet), MP_ROM_PTR(&wifi_packet_type) }, + + // Properties + { MP_ROM_QSTR(MP_QSTR_radio), MP_ROM_PTR(&common_hal_wifi_radio_obj) }, }; STATIC MP_DEFINE_CONST_DICT(wifi_module_globals, wifi_module_globals_table); From c34b6f757fc385d99086bdd755f74ceabf613454 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 21 Oct 2021 11:45:11 -0500 Subject: [PATCH 02/84] Implement gifio.GifWriter This involves: * Adding a new "L8" colorspace for colorconverters * factoring out displayio_colorconverter_convert_pixel * Making a minimal "colorspace only" version of displayio for the unix port (testing purposes) * fixing an error message I only tested writing B&W animated images, with the following script: ```python import displayio import gifio with gifio.GifWriter("foo.gif", 64, 64, displayio.Colorspace.L8) as g: for i in range(0, 256, 14): data = bytes([i, 255-i] * 32 + [255-i, i] * 32) * 32 print("add_frame") g.add_frame(data) # expected to raise an error, buffer is not big enough with gifio.GifWriter("/dev/null", 64, 64, displayio.Colorspace.L8) as g: g.add_frame(bytes([3,3,3])) ``` --- locale/circuitpython.pot | 11 +- ports/unix/displayio_colorspace_only.c | 90 ++++++++ .../unix/variants/coverage/mpconfigvariant.mk | 5 + py/argcheck.c | 2 +- py/circuitpy_defns.mk | 6 + py/circuitpy_mpconfig.mk | 3 + shared-bindings/displayio/ColorConverter.c | 1 - shared-bindings/displayio/ColorConverter.h | 1 + shared-bindings/displayio/Colorspace.c | 77 +++++++ shared-bindings/displayio/__init__.c | 45 ---- shared-bindings/displayio/__init__.h | 3 +- shared-bindings/gifio/GifWriter.c | 157 ++++++++++++++ shared-bindings/gifio/GifWriter.h | 41 ++++ shared-bindings/gifio/__init__.c | 47 +++++ shared-bindings/gifio/__init__.h | 0 shared-module/displayio/ColorConverter.c | 32 ++- shared-module/gifio/GifWriter.c | 198 ++++++++++++++++++ shared-module/gifio/GifWriter.h | 40 ++++ shared-module/gifio/__init__.c | 0 shared-module/gifio/__init__.h | 0 20 files changed, 700 insertions(+), 59 deletions(-) create mode 100644 ports/unix/displayio_colorspace_only.c create mode 100644 shared-bindings/displayio/Colorspace.c create mode 100644 shared-bindings/gifio/GifWriter.c create mode 100644 shared-bindings/gifio/GifWriter.h create mode 100644 shared-bindings/gifio/__init__.c create mode 100644 shared-bindings/gifio/__init__.h create mode 100644 shared-module/gifio/GifWriter.c create mode 100644 shared-module/gifio/GifWriter.h create mode 100644 shared-module/gifio/__init__.c create mode 100644 shared-module/gifio/__init__.h diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index f1f747e7e6..bb5c2ee6b2 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -104,11 +104,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3073,6 +3073,7 @@ msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4330,6 +4331,10 @@ msgstr "" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/ports/unix/displayio_colorspace_only.c b/ports/unix/displayio_colorspace_only.c new file mode 100644 index 0000000000..40325ec76a --- /dev/null +++ b/ports/unix/displayio_colorspace_only.c @@ -0,0 +1,90 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/enum.h" +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/displayio/__init__.h" + +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB888, DISPLAYIO_COLORSPACE_RGB888); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAYIO_COLORSPACE_RGB565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAYIO_COLORSPACE_RGB555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565, DISPLAYIO_COLORSPACE_BGR565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555, DISPLAYIO_COLORSPACE_BGR555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, L8, DISPLAYIO_COLORSPACE_L8); + +//| class Colorspace: +//| """The colorspace for a `ColorConverter` to operate in""" +//| +//| RGB888: Colorspace +//| """The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)""" +//| +//| RGB565: Colorspace +//| """The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)""" +//| +//| RGB565_SWAPPED: Colorspace +//| """The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565""" +//| +//| RGB555: Colorspace +//| """The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)""" +//| +//| RGB555_SWAPPED: Colorspace +//| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555""" +//| +MAKE_ENUM_MAP(displayio_colorspace) { + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, L8), +}; +STATIC MP_DEFINE_CONST_DICT(displayio_colorspace_locals_dict, displayio_colorspace_locals_table); + +MAKE_PRINTER(displayio, displayio_colorspace); +MAKE_ENUM_TYPE(displayio, ColorSpace, displayio_colorspace); + +STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, + { MP_ROM_QSTR(MP_QSTR_Colorspace), MP_ROM_PTR(&displayio_colorspace_type) }, +}; +STATIC MP_DEFINE_CONST_DICT(displayio_module_globals, displayio_module_globals_table); + +const mp_obj_module_t displayio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&displayio_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module, CIRCUITPY_DISPLAYIO_COLORSPACE_ONLY); diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index e5d0f7e2d3..e614cd411e 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -27,5 +27,10 @@ SRC_C += $(SRC_QRIO) CFLAGS += -DCIRCUITPY_QRIO=1 $(BUILD)/lib/quirc/lib/%.o: CFLAGS += -Wno-shadow -Wno-sign-compare -include shared-module/qrio/quirc_alloc.h +SRC_GIFIO := $(patsubst ../../%,%,$(wildcard ../../shared-bindings/gifio/*.c ../../shared-module/gifio/*.c)) shared/runtime/context_manager_helpers.c displayio_colorspace_only.c shared-module/displayio/ColorConverter.c shared-bindings/util.c +SRC_C += $(SRC_GIFIO) + +CFLAGS += -DCIRCUITPY_GIFIO=1 -DCIRCUITPY_DISPLAYIO_COLORSPACE_ONLY=1 + SRC_C += coverage.c SRC_CXX += coveragecpp.cpp diff --git a/py/argcheck.c b/py/argcheck.c index aa88eeed6c..c2066a7c39 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -165,7 +165,7 @@ mp_int_t mp_arg_validate_int_min(mp_int_t i, mp_int_t min, qstr arg_name) { mp_int_t mp_arg_validate_int_max(mp_int_t i, mp_int_t max, qstr arg_name) { if (i > max) { - mp_raise_ValueError_varg(translate("%q must <= %d"), arg_name, max); + mp_raise_ValueError_varg(translate("%q must be <= %d"), arg_name, max); } return i; } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 7d2d128a73..ff2933caa4 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -197,6 +197,9 @@ endif ifeq ($(CIRCUITPY_GETPASS),1) SRC_PATTERNS += getpass/% endif +ifeq ($(CIRCUITPY_GIFIO),1) +SRC_PATTERNS += gifio/% +endif ifeq ($(CIRCUITPY_GNSS),1) SRC_PATTERNS += gnss/% endif @@ -465,6 +468,7 @@ $(filter $(SRC_PATTERNS), \ digitalio/Direction.c \ digitalio/DriveMode.c \ digitalio/Pull.c \ + displayio/Colorspace.c \ fontio/Glyph.c \ math/__init__.c \ microcontroller/ResetReason.c \ @@ -535,6 +539,8 @@ SRC_SHARED_MODULE_ALL = \ gamepadshift/GamePadShift.c \ gamepadshift/__init__.c \ getpass/__init__.c \ + gifio/__init__.c \ + gifio/GifWriter.c \ ipaddress/IPv4Address.c \ ipaddress/__init__.c \ keypad/__init__.c \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index be373b78a2..443bd41d8b 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -214,6 +214,9 @@ CFLAGS += -DCIRCUITPY_GAMEPADSHIFT=$(CIRCUITPY_GAMEPADSHIFT) CIRCUITPY_GETPASS ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_GETPASS=$(CIRCUITPY_GETPASS) +CIRCUITPY_GIFIO ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_GIFIO=$(CIRCUITPY_GIFIO) + CIRCUITPY_GNSS ?= 0 CFLAGS += -DCIRCUITPY_GNSS=$(CIRCUITPY_GNSS) diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index c093c70128..2f40d8bd36 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -33,7 +33,6 @@ #include "py/enum.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" diff --git a/shared-bindings/displayio/ColorConverter.h b/shared-bindings/displayio/ColorConverter.h index 018db92c96..12fa8da20f 100644 --- a/shared-bindings/displayio/ColorConverter.h +++ b/shared-bindings/displayio/ColorConverter.h @@ -36,6 +36,7 @@ extern const mp_obj_type_t displayio_colorconverter_type; void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t *self, bool dither, displayio_colorspace_t input_colorspace); void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, const _displayio_colorspace_t *colorspace, uint32_t input_color, uint32_t *output_color); +uint32_t displayio_colorconverter_convert_pixel(displayio_colorspace_t colorspace, uint32_t pixel); void common_hal_displayio_colorconverter_set_dither(displayio_colorconverter_t *self, bool dither); bool common_hal_displayio_colorconverter_get_dither(displayio_colorconverter_t *self); diff --git a/shared-bindings/displayio/Colorspace.c b/shared-bindings/displayio/Colorspace.c new file mode 100644 index 0000000000..3692dc29bc --- /dev/null +++ b/shared-bindings/displayio/Colorspace.c @@ -0,0 +1,77 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/enum.h" +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/displayio/__init__.h" + +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB888, DISPLAYIO_COLORSPACE_RGB888); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAYIO_COLORSPACE_RGB565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAYIO_COLORSPACE_RGB555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565, DISPLAYIO_COLORSPACE_BGR565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555, DISPLAYIO_COLORSPACE_BGR555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, L8, DISPLAYIO_COLORSPACE_L8); + +//| class Colorspace: +//| """The colorspace for a `ColorConverter` to operate in""" +//| +//| RGB888: Colorspace +//| """The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)""" +//| +//| RGB565: Colorspace +//| """The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)""" +//| +//| RGB565_SWAPPED: Colorspace +//| """The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565""" +//| +//| RGB555: Colorspace +//| """The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)""" +//| +//| RGB555_SWAPPED: Colorspace +//| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555""" +//| +MAKE_ENUM_MAP(displayio_colorspace) { + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, L8), +}; +STATIC MP_DEFINE_CONST_DICT(displayio_colorspace_locals_dict, displayio_colorspace_locals_table); + +MAKE_PRINTER(displayio, displayio_colorspace); +MAKE_ENUM_TYPE(displayio, ColorSpace, displayio_colorspace); diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 7ac2a84903..5588dc83e9 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -69,50 +69,6 @@ STATIC mp_obj_t displayio_release_displays(void) { } MP_DEFINE_CONST_FUN_OBJ_0(displayio_release_displays_obj, displayio_release_displays); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB888, DISPLAYIO_COLORSPACE_RGB888); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAYIO_COLORSPACE_RGB565); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB565_SWAPPED); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAYIO_COLORSPACE_RGB555); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565, DISPLAYIO_COLORSPACE_BGR565); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR565_SWAPPED); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555, DISPLAYIO_COLORSPACE_BGR555); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED); - -//| class Colorspace: -//| """The colorspace for a `ColorConverter` to operate in""" -//| -//| RGB888: Colorspace -//| """The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)""" -//| -//| RGB565: Colorspace -//| """The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)""" -//| -//| RGB565_SWAPPED: Colorspace -//| """The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565""" -//| -//| RGB555: Colorspace -//| """The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)""" -//| -//| RGB555_SWAPPED: Colorspace -//| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555""" -//| -MAKE_ENUM_MAP(displayio_colorspace) { - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565_SWAPPED), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555_SWAPPED), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565_SWAPPED), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555_SWAPPED), -}; -STATIC MP_DEFINE_CONST_DICT(displayio_colorspace_locals_dict, displayio_colorspace_locals_table); - -MAKE_PRINTER(displayio, displayio_colorspace); -MAKE_ENUM_TYPE(displayio, ColorSpace, displayio_colorspace); - STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, @@ -135,7 +91,6 @@ STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_release_displays), MP_ROM_PTR(&displayio_release_displays_obj) }, }; - STATIC MP_DEFINE_CONST_DICT(displayio_module_globals, displayio_module_globals_table); const mp_obj_module_t displayio_module = { diff --git a/shared-bindings/displayio/__init__.h b/shared-bindings/displayio/__init__.h index 938fcf3d98..b297e4d755 100644 --- a/shared-bindings/displayio/__init__.h +++ b/shared-bindings/displayio/__init__.h @@ -40,7 +40,7 @@ typedef enum { CHIP_SELECT_TOGGLE_EVERY_BYTE } display_chip_select_behavior_t; -typedef enum { +typedef enum displayio_colorspace { DISPLAYIO_COLORSPACE_RGB888, DISPLAYIO_COLORSPACE_RGB565, DISPLAYIO_COLORSPACE_RGB555, @@ -50,6 +50,7 @@ typedef enum { DISPLAYIO_COLORSPACE_BGR555, DISPLAYIO_COLORSPACE_BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED, + DISPLAYIO_COLORSPACE_L8, } displayio_colorspace_t; typedef bool (*display_bus_bus_reset)(mp_obj_t bus); diff --git a/shared-bindings/gifio/GifWriter.c b/shared-bindings/gifio/GifWriter.c new file mode 100644 index 0000000000..8c9a9a3f3b --- /dev/null +++ b/shared-bindings/gifio/GifWriter.c @@ -0,0 +1,157 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#if MICROPY_VFS +#include "extmod/vfs.h" +#endif +#include "py/runtime.h" +#include "shared-bindings/gifio/GifWriter.h" +#include "shared-module/gifio/GifWriter.h" +#include "shared/runtime/context_manager_helpers.h" + +//| class GifWriter: +//| def __init__(self, file: Union[Typing.IO.BinaryIO, str], width:int, height:int, colorspace: displayio.Colorspace, loop:bool=True) -> None: +//| """Construct a GifWriter object +//| +//| :param file: Either a file open in bytes mode, or the name of a file to open in bytes mode. +//| :param width: The width of the image. All frames must have the same width. +//| :param height: The height of the image. All frames must have the same height. +//| :param colorspace: The colorspace of the image. All frames must have the same colorspace. Only 1- and 2-byte colorspace are supported, not ``RGB888``. +//| """ +//| ... +//| +static mp_obj_t gifio_gifwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_file, ARG_width, ARG_height, ARG_colorspace, ARG_loop }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL} }, + { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = 0} }, + { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = 0} }, + { MP_QSTR_colorspace, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL} }, + { MP_QSTR_loop, MP_ARG_BOOL, { .u_bool = true } }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_obj_t file = args[ARG_file].u_obj; + bool own_file = false; + if (mp_obj_is_str(file)) { + file = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), file, MP_OBJ_NEW_QSTR(MP_QSTR_wb)); + own_file = true; + } + + gifio_gifwriter_t *self = m_new_obj(gifio_gifwriter_t); + self->base.type = &gifio_gifwriter_type; + shared_module_gifio_gifwriter_construct( + self, + file, + args[ARG_width].u_int, + args[ARG_height].u_int, + (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_colorspace].u_obj), + args[ARG_loop].u_bool, + own_file); + + return self; +} + + +//| def __enter__(self) -> GifWriter: +//| """No-op used by Context Managers.""" +//| ... +// Provided by context manager helper. + +//| def __exit__(self) -> None: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| +static mp_obj_t gifio_gifwriter___exit__(size_t n_args, const mp_obj_t *args) { + gifio_gifwriter_t *self = MP_OBJ_TO_PTR(args[0]); + shared_module_gifio_gifwriter_deinit(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gifio_gifwriter___exit___obj, 4, 4, gifio_gifwriter___exit__); + +//| def deinit(self) -> None: +//| """Close the underlying file.""" +//| ... +//| +static mp_obj_t gifio_gifwriter_deinit(mp_obj_t self_in) { + gifio_gifwriter_t *self = MP_OBJ_TO_PTR(self_in); + shared_module_gifio_gifwriter_deinit(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(gifio_gifwriter_deinit_obj, gifio_gifwriter_deinit); + +//| def add_frame(self, bitmap: ReadableBuffer, delay: float = 0.1) -> None: +//| """Add a frame to the GIF. +//| +//| :param bitmap: The frame data +//| :param delay: The frame delay in seconds. The GIF format rounds this to the nearest 1/100 second, and the largest permitted value is 655 seconds. +//| """ +//| ... +static mp_obj_t gifio_gifwriter_add_frame(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_bitmap, ARG_delay }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_bitmap, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL} }, + { MP_QSTR_delay, MP_ARG_OBJ, {.u_obj = NULL} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + gifio_gifwriter_t *self = MP_OBJ_TO_PTR(pos_args[0]); + shared_module_gifio_gifwriter_check_for_deinit(self); + + + mp_float_t delay = mp_arg_validate_obj_float_non_negative(args[ARG_delay].u_obj, MICROPY_FLOAT_CONST(0.1), MP_QSTR_delay); + if (delay > MICROPY_FLOAT_CONST(655.)) { + mp_raise_ValueError_varg(translate("%q must be <= %d"), MP_QSTR_delay, 655); + } + + int delay_centiseconds = (int)(delay * 100); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_bitmap].u_obj, &bufinfo, MP_BUFFER_READ); + shared_module_gifio_gifwriter_add_frame(self, &bufinfo, delay_centiseconds); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(gifio_gifwriter_add_frame_obj, 1, gifio_gifwriter_add_frame); + +STATIC const mp_rom_map_elem_t gifio_gifwriter_locals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_GifWriter) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&gifio_gifwriter___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&gifio_gifwriter_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR_add_frame), MP_ROM_PTR(&gifio_gifwriter_add_frame_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(gifio_gifwriter_locals, gifio_gifwriter_locals_table); + +const mp_obj_type_t gifio_gifwriter_type = { + { &mp_type_type }, + .name = MP_QSTR_GifWriter, + .make_new = gifio_gifwriter_make_new, + .locals_dict = (mp_obj_dict_t *)&gifio_gifwriter_locals, +}; diff --git a/shared-bindings/gifio/GifWriter.h b/shared-bindings/gifio/GifWriter.h new file mode 100644 index 0000000000..203169cd75 --- /dev/null +++ b/shared-bindings/gifio/GifWriter.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" + +#pragma once + +typedef struct gifio_gifwriter gifio_gifwriter_t; +typedef enum displayio_colorspace displayio_colorspace_t; + +extern const mp_obj_type_t gifio_gifwriter_type; + +void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool own_file); +void shared_module_gifio_gifwriter_check_for_deinit(gifio_gifwriter_t *self); +bool shared_module_gifio_gifwriter_deinited(gifio_gifwriter_t *self); +void shared_module_gifio_gifwriter_deinit(gifio_gifwriter_t *self); +void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_buffer_info_t *buf, int16_t delay); +void shared_module_gifio_gifwriter_close(gifio_gifwriter_t *self); diff --git a/shared-bindings/gifio/__init__.c b/shared-bindings/gifio/__init__.c new file mode 100644 index 0000000000..317eebce9b --- /dev/null +++ b/shared-bindings/gifio/__init__.c @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "py/obj.h" +#include "py/runtime.h" +#include "py/mphal.h" +#include "shared-bindings/gifio/GifWriter.h" +#include "shared-bindings/util.h" + +//| """Access GIF-format images +//| """ +//| +STATIC const mp_rom_map_elem_t gifio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gifio) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_GifWriter), MP_ROM_PTR(&gifio_gifwriter_type)}, +}; + +STATIC MP_DEFINE_CONST_DICT(gifio_module_globals, gifio_module_globals_table); + +const mp_obj_module_t gifio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&gifio_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_gifio, gifio_module, CIRCUITPY_GIFIO); diff --git a/shared-bindings/gifio/__init__.h b/shared-bindings/gifio/__init__.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c index be5b7d31a7..228d63d03b 100644 --- a/shared-module/displayio/ColorConverter.c +++ b/shared-module/displayio/ColorConverter.c @@ -145,15 +145,10 @@ void common_hal_displayio_colorconverter_make_opaque(displayio_colorconverter_t self->transparent_color = NO_TRANSPARENT_COLOR; } -void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t *colorspace, const displayio_input_pixel_t *input_pixel, displayio_output_pixel_t *output_color) { - uint32_t pixel = input_pixel->pixel; - if (self->transparent_color == pixel) { - output_color->opaque = false; - return; - } - - switch (self->input_colorspace) { +// Convert a single input pixel to RGB888 +uint32_t displayio_colorconverter_convert_pixel(displayio_colorspace_t colorspace, uint32_t pixel) { + switch (colorspace) { case DISPLAYIO_COLORSPACE_RGB565_SWAPPED: pixel = __builtin_bswap16(pixel); MP_FALLTHROUGH; @@ -198,10 +193,31 @@ void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _d } break; + default: case DISPLAYIO_COLORSPACE_RGB888: break; + + case DISPLAYIO_COLORSPACE_L8: { + uint32_t l8 = pixel & 0xff; + pixel = l8 * 0x010101; + } + break; } + return pixel; +} + +void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t *colorspace, const displayio_input_pixel_t *input_pixel, displayio_output_pixel_t *output_color) { + uint32_t pixel = input_pixel->pixel; + + if (self->transparent_color == pixel) { + output_color->opaque = false; + return; + } + + pixel = displayio_colorconverter_convert_pixel(self->input_colorspace, pixel); + + if (self->dither) { uint8_t randr = (displayio_colorconverter_dither_noise_2(input_pixel->tile_x,input_pixel->tile_y)); uint8_t randg = (displayio_colorconverter_dither_noise_2(input_pixel->tile_x + 33,input_pixel->tile_y)); diff --git a/shared-module/gifio/GifWriter.c b/shared-module/gifio/GifWriter.c new file mode 100644 index 0000000000..a428b17a97 --- /dev/null +++ b/shared-module/gifio/GifWriter.c @@ -0,0 +1,198 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * Copyright (c) 2013-2021 Ibrahim Abdelkader + * Copyright (c) 2013-2021 Kwabena W. Agyeman + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" + +#include "shared-module/gifio/GifWriter.h" +#include "shared-bindings/gifio/GifWriter.h" +#include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/util.h" + +#define BLOCK_SIZE (126) // (2^7) - 2 // (DO NOT CHANGE!) + +static void handle_error(const char *what, int error) { + if (error != 0) { + mp_raise_OSError(error); + } +} + +static void write_data(gifio_gifwriter_t *self, const void *data, size_t size) { + int error = 0; + self->file_proto->write(self->file, data, size, &error); + handle_error("write_data", error); +} + +static void write_byte(gifio_gifwriter_t *self, uint8_t value) { + write_data(self, &value, sizeof(value)); +} + +static void write_long(gifio_gifwriter_t *self, uint32_t value) { + write_data(self, &value, sizeof(value)); +} + +static void write_word(gifio_gifwriter_t *self, uint16_t value) { + write_data(self, &value, sizeof(value)); +} + +void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool own_file) { + self->file = file; + self->file_proto = mp_proto_get_or_throw(MP_QSTR_protocol_stream, file); + if (self->file_proto->is_text) { + mp_raise_TypeError(translate("file must be a file opened in byte mode")); + } + self->width = width; + self->height = height; + self->colorspace = colorspace; + self->own_file = own_file; + + write_data(self, "GIF89a", 6); + write_word(self, width); + write_word(self, height); + write_data(self, (uint8_t []) {0xF6, 0x00, 0x00}, 3); + + if (colorspace == DISPLAYIO_COLORSPACE_RGB888) { + mp_raise_TypeError(translate("unsupported colorspace for GifWriter")); + } + + bool color = (colorspace != DISPLAYIO_COLORSPACE_L8); + + if (color) { + for (int i = 0; i < 128; i++) { + int red = (int)(((((i & 0x60) >> 5) * 255) + 1.5) / 3); + int green = (int)(((((i & 0x1C) >> 2) * 255) + 3.5) / 7); + int blue = (int)((((i & 0x3) * 255) + 1.5) / 3); + write_data(self, (uint8_t []) {red, green, blue}, 3); + } + } else { + for (int i = 0; i < 128; i++) { + int gray = (int)(((i * 255) + 63.5) / 127); + write_data(self, (uint8_t []) {gray, gray, gray}, 3); + } + } + + if (loop) { + write_data(self, (uint8_t []) {'!', 0xFF, 0x0B}, 3); + write_data(self, "NETSCAPE2.0", 11); + write_data(self, (uint8_t []) {0x03, 0x01, 0x00, 0x00, 0x00}, 5); + } + + +} + +bool shared_module_gifio_gifwriter_deinited(gifio_gifwriter_t *self) { + return !self->file; +} + +void shared_module_gifio_gifwriter_check_for_deinit(gifio_gifwriter_t *self) { + if (shared_module_gifio_gifwriter_deinited(self)) { + raise_deinited_error(); + } +} + +void shared_module_gifio_gifwriter_deinit(gifio_gifwriter_t *self) { + if (!shared_module_gifio_gifwriter_deinited(self)) { + shared_module_gifio_gifwriter_close(self); + } +} + +void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_buffer_info_t *bufinfo, int16_t delay) { + if (delay) { + write_data(self, (uint8_t []) {'!', 0xF9, 0x04, 0x04}, 4); + write_word(self, delay); + write_word(self, 0); // end + } + + write_byte(self, 0x2C); + write_long(self, 0); + write_word(self, self->width); + write_word(self, self->height); + write_data(self, (uint8_t []) {0x00, 0x07}, 2); // 7-bits + + int pixel_count = self->width * self->height; + int blocks = (pixel_count + BLOCK_SIZE - 1) / BLOCK_SIZE; + + uint8_t block_data[2 + BLOCK_SIZE]; + block_data[1] = 0x80; + + if (self->colorspace == DISPLAYIO_COLORSPACE_L8) { + mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(pixel_count - 1), false); + + uint8_t *pixels = bufinfo->buf; + for (int i = 0; i < blocks; i++) { + assert(pixel_count >= 0); + int block_size = MIN(BLOCK_SIZE, pixel_count); + pixel_count -= block_size; + block_data[0] = 1 + block_size; + for (int j = 0; j < block_size; j++) { + block_data[j + 2] = (*pixels++) >> 1; + } + write_data(self, block_data, 2 + block_size); + } + } else { + mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(2 * pixel_count - 1), false); + + uint16_t *pixels = bufinfo->buf; + for (int i = 0; i < blocks; i++) { + int block_size = MIN(BLOCK_SIZE, pixel_count); + pixel_count -= block_size; + + block_data[0] = 1 + block_size; + for (int j = 0; j < block_size; j++) { + int pixel = displayio_colorconverter_convert_pixel(self->colorspace, (*pixels++)); + int red = (pixel >> (16 + 6)) & 0x3; + int green = (pixel >> (8 + 5)) & 0x7; + int blue = (pixel >> 6) & 0x3; + block_data[j + 2] = (red << 5) | (green << 2) | blue; + } + write_data(self, block_data, 2 + block_size); + } + } + + write_data(self, (uint8_t []) {0x01, 0x81, 0x00}, 3); // end code + + int error = 0; + self->file_proto->ioctl(self->file, MP_STREAM_FLUSH, 0, &error); + handle_error("flush", error); +} + +void shared_module_gifio_gifwriter_close(gifio_gifwriter_t *self) { + // we want to ensure the stream is closed even if the first write failed, so we don't use write_data + int error1 = 0; + self->file_proto->write(self->file, ";", 1, &error1); + + int error2 = 0; + if (self->own_file) { + self->file_proto->ioctl(self->file, MP_STREAM_CLOSE, 0, &error2); + } else { + self->file_proto->ioctl(self->file, MP_STREAM_FLUSH, 0, &error2); + } + self->file = NULL; + + handle_error("write", error1); + handle_error("close", error2); +} diff --git a/shared-module/gifio/GifWriter.h b/shared-module/gifio/GifWriter.h new file mode 100644 index 0000000000..e16de7c06b --- /dev/null +++ b/shared-module/gifio/GifWriter.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "py/obj.h" +#include "py/stream.h" +#include "shared-bindings/displayio/__init__.h" + +typedef struct gifio_gifwriter { + mp_obj_base_t base; + mp_obj_t *file; + const mp_stream_p_t *file_proto; + displayio_colorspace_t colorspace; + int width, height; + bool own_file; +} gifio_gifwriter_t; diff --git a/shared-module/gifio/__init__.c b/shared-module/gifio/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/gifio/__init__.h b/shared-module/gifio/__init__.h new file mode 100644 index 0000000000..e69de29bb2 From b0203381db3d3b13e03ae536dbc1c50b9400751a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 21 Oct 2021 15:11:48 -0500 Subject: [PATCH 03/84] Update module list in test --- tests/unix/extra_coverage.py.exp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 893a6b72c3..3a1e7f280b 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -31,13 +31,14 @@ mport builtins micropython _thread array binascii btree cexample cmath -collections cppexample errno ffi -framebuf gc hashlib json -math qrio re sys -termios ubinascii uctypes uerrno -uheapq uio ujson ulab -uos urandom ure uselect -ustruct utime utimeq uzlib +collections cppexample displayio errno +ffi framebuf gc gifio +hashlib json math qrio +re sys termios ubinascii +uctypes uerrno uheapq uio +ujson ulab uos urandom +ure uselect ustruct utime +utimeq uzlib ime utime utimeq From 081f636c1771f62af5dc5077db540896b30b378d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 21 Oct 2021 16:02:42 -0500 Subject: [PATCH 04/84] Fix typing --- shared-bindings/gifio/GifWriter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/gifio/GifWriter.c b/shared-bindings/gifio/GifWriter.c index 8c9a9a3f3b..6131550bf4 100644 --- a/shared-bindings/gifio/GifWriter.c +++ b/shared-bindings/gifio/GifWriter.c @@ -34,7 +34,7 @@ #include "shared/runtime/context_manager_helpers.h" //| class GifWriter: -//| def __init__(self, file: Union[Typing.IO.BinaryIO, str], width:int, height:int, colorspace: displayio.Colorspace, loop:bool=True) -> None: +//| def __init__(self, file: Union[typing.BinaryIO, str], width:int, height:int, colorspace: displayio.Colorspace, loop:bool=True) -> None: //| """Construct a GifWriter object //| //| :param file: Either a file open in bytes mode, or the name of a file to open in bytes mode. From 8c7760b1a619e52401a3c2714f1f7aa9c14431e5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 21 Oct 2021 16:05:48 -0500 Subject: [PATCH 05/84] don't include gifio on samd21 boards --- ports/atmel-samd/mpconfigport.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 818c9f111a..1652032311 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -49,6 +49,7 @@ CIRCUITPY_COUNTIO ?= 0 # Not enough RAM for framebuffers CIRCUITPY_FRAMEBUFFERIO ?= 0 CIRCUITPY_FREQUENCYIO ?= 0 +CIRCUITPY_GIFIO ?= 0 CIRCUITPY_I2CPERIPHERAL ?= 0 CIRCUITPY_JSON ?= 0 CIRCUITPY_KEYPAD ?= 0 From 3e020a73a8e17c82f7a51320a55c6310a283c926 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 21 Oct 2021 16:45:04 -0500 Subject: [PATCH 06/84] Disable gifio if no displayio & for small boards Technically all gifio needs from displayio is the definition of colorspaces, but let's just disable it for now. --- ports/atmel-samd/boards/pybadge/mpconfigboard.mk | 1 + ports/atmel-samd/boards/pygamer/mpconfigboard.mk | 1 + ports/stm/boards/espruino_pico/mpconfigboard.mk | 1 + ports/stm/boards/pyb_nano_v2/mpconfigboard.mk | 1 + py/circuitpy_mpconfig.mk | 4 ++++ 5 files changed, 8 insertions(+) diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk index b5fda72f90..7f4278c90d 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk @@ -12,6 +12,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_AESIO = 0 CIRCUITPY_GAMEPADSHIFT = 1 +CIRCUITPY_GIFIO = 0 CIRCUITPY_STAGE = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pybadge diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk index 5b5a84bb78..408efc9dc0 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk @@ -12,6 +12,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_AESIO = 0 CIRCUITPY_GAMEPADSHIFT = 1 +CIRCUITPY_GIFIO = 0 CIRCUITPY_STAGE = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pygamer diff --git a/ports/stm/boards/espruino_pico/mpconfigboard.mk b/ports/stm/boards/espruino_pico/mpconfigboard.mk index 851357b4d6..a078b4841a 100644 --- a/ports/stm/boards/espruino_pico/mpconfigboard.mk +++ b/ports/stm/boards/espruino_pico/mpconfigboard.mk @@ -23,6 +23,7 @@ CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_FRAMEBUFFERIO = 0 +CIRCUITPY_GIFIO = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_MIDI = 0 CIRCUITPY_MSGPACK = 0 diff --git a/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk index 9f6a02c8d0..74ce665a5b 100644 --- a/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk +++ b/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk @@ -17,6 +17,7 @@ LD_FILE = boards/STM32F411_fs.ld CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_KEYPAD = 0 +CIRCUITPY_GIFIO = 0 CIRCUITPY_MIDI = 0 CIRCUITPY_MSGPACK = 0 CIRCUITPY_BITMAPTOOLS = 0 diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 443bd41d8b..04f0778290 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -214,7 +214,11 @@ CFLAGS += -DCIRCUITPY_GAMEPADSHIFT=$(CIRCUITPY_GAMEPADSHIFT) CIRCUITPY_GETPASS ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_GETPASS=$(CIRCUITPY_GETPASS) +ifeq ($(CIRCUITPY_DISPLAYIO),1) CIRCUITPY_GIFIO ?= $(CIRCUITPY_FULL_BUILD) +else +CIRCUITPY_GIFIO ?= 0 +endif CFLAGS += -DCIRCUITPY_GIFIO=$(CIRCUITPY_GIFIO) CIRCUITPY_GNSS ?= 0 From 7d6ac96001a03ed090449cdda59c3291d4eef026 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Oct 2021 11:11:28 -0500 Subject: [PATCH 07/84] GifWriter: improve efficiency * Increase colorspace conversion efficiency. This not only avoids a function call, it avoids the time-consuming switch statement in conver_pixel (replacing it with a single conditional on the byteswap flag + accounting for BGR/RGB during palette creation) * Buffer all the bytes of a single frame together. By reducing low level write calls we get a decent speed increase even though it increases data-shuffling a bit. Together with some other changes that enable "double buffered" camera capture, this gets me to 8.8fps capturing QVGA (320x240) gifs and 11fps capturing 240x240 square gifs. --- shared-module/gifio/GifWriter.c | 95 +++++++++++++++++++++++---------- shared-module/gifio/GifWriter.h | 4 ++ 2 files changed, 70 insertions(+), 29 deletions(-) diff --git a/shared-module/gifio/GifWriter.c b/shared-module/gifio/GifWriter.c index a428b17a97..d5594538fe 100644 --- a/shared-module/gifio/GifWriter.c +++ b/shared-module/gifio/GifWriter.c @@ -26,6 +26,9 @@ * THE SOFTWARE. */ +#include + +#include "py/gc.h" #include "py/runtime.h" #include "shared-module/gifio/GifWriter.h" @@ -35,16 +38,30 @@ #define BLOCK_SIZE (126) // (2^7) - 2 // (DO NOT CHANGE!) -static void handle_error(const char *what, int error) { - if (error != 0) { - mp_raise_OSError(error); +static void handle_error(gifio_gifwriter_t *self) { + if (self->error != 0) { + mp_raise_OSError(self->error); } } -static void write_data(gifio_gifwriter_t *self, const void *data, size_t size) { +static void flush_data(gifio_gifwriter_t *self) { + if (self->cur == 0) { + return; + } int error = 0; - self->file_proto->write(self->file, data, size, &error); - handle_error("write_data", error); + self->file_proto->write(self->file, self->data, self->cur, &error); + self->cur = 0; + if (error != 0) { + self->error = error; + } +} + +// These "write" calls _MUST_ have enough buffer space available! This is +// ensured by allocating the proper buffer size in construct. +static void write_data(gifio_gifwriter_t *self, const void *data, size_t size) { + assert(self->cur + size <= self->size); + memcpy(self->data + self->cur, data, size); + self->cur += size; } static void write_byte(gifio_gifwriter_t *self, uint8_t value) { @@ -70,23 +87,44 @@ void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t * self->colorspace = colorspace; self->own_file = own_file; + size_t nblocks = (width * height + 125) / 126; + self->size = nblocks * 128 + 4; + self->data = gc_alloc(self->size, 0, false); + self->cur = 0; + self->error = 0; + write_data(self, "GIF89a", 6); write_word(self, width); write_word(self, height); write_data(self, (uint8_t []) {0xF6, 0x00, 0x00}, 3); - if (colorspace == DISPLAYIO_COLORSPACE_RGB888) { - mp_raise_TypeError(translate("unsupported colorspace for GifWriter")); + switch (colorspace) { + case DISPLAYIO_COLORSPACE_RGB565: + case DISPLAYIO_COLORSPACE_RGB565_SWAPPED: + case DISPLAYIO_COLORSPACE_BGR565: + case DISPLAYIO_COLORSPACE_BGR565_SWAPPED: + case DISPLAYIO_COLORSPACE_L8: + break; + + default: + mp_raise_TypeError(translate("unsupported colorspace for GifWriter")); } bool color = (colorspace != DISPLAYIO_COLORSPACE_L8); + bool bgr = (colorspace == DISPLAYIO_COLORSPACE_BGR565 || colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED); + self->byteswap = (colorspace == DISPLAYIO_COLORSPACE_RGB565_SWAPPED || colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED); + if (color) { for (int i = 0; i < 128; i++) { int red = (int)(((((i & 0x60) >> 5) * 255) + 1.5) / 3); int green = (int)(((((i & 0x1C) >> 2) * 255) + 3.5) / 7); int blue = (int)((((i & 0x3) * 255) + 1.5) / 3); - write_data(self, (uint8_t []) {red, green, blue}, 3); + if (bgr) { + write_data(self, (uint8_t []) {blue, red, green}, 3); + } else { + write_data(self, (uint8_t []) {red, green, blue}, 3); + } } } else { for (int i = 0; i < 128; i++) { @@ -101,7 +139,8 @@ void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t * write_data(self, (uint8_t []) {0x03, 0x01, 0x00, 0x00, 0x00}, 5); } - + flush_data(self); + handle_error(self); } bool shared_module_gifio_gifwriter_deinited(gifio_gifwriter_t *self) { @@ -163,10 +202,13 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b block_data[0] = 1 + block_size; for (int j = 0; j < block_size; j++) { - int pixel = displayio_colorconverter_convert_pixel(self->colorspace, (*pixels++)); - int red = (pixel >> (16 + 6)) & 0x3; - int green = (pixel >> (8 + 5)) & 0x7; - int blue = (pixel >> 6) & 0x3; + int pixel = *pixels++; + if (self->byteswap) { + pixel = __builtin_bswap16(pixel); + } + int red = (pixel >> (11 + (5 - 2))) & 0x3; + int green = (pixel >> (5 + (6 - 3))) & 0x7; + int blue = (pixel >> (0 + (5 - 2))) & 0x3; block_data[j + 2] = (red << 5) | (green << 2) | blue; } write_data(self, block_data, 2 + block_size); @@ -174,25 +216,20 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b } write_data(self, (uint8_t []) {0x01, 0x81, 0x00}, 3); // end code - - int error = 0; - self->file_proto->ioctl(self->file, MP_STREAM_FLUSH, 0, &error); - handle_error("flush", error); + flush_data(self); + handle_error(self); } void shared_module_gifio_gifwriter_close(gifio_gifwriter_t *self) { - // we want to ensure the stream is closed even if the first write failed, so we don't use write_data - int error1 = 0; - self->file_proto->write(self->file, ";", 1, &error1); + write_byte(self, ';'); + flush_data(self); - int error2 = 0; - if (self->own_file) { - self->file_proto->ioctl(self->file, MP_STREAM_CLOSE, 0, &error2); - } else { - self->file_proto->ioctl(self->file, MP_STREAM_FLUSH, 0, &error2); - } + int error = 0; + self->file_proto->ioctl(self->file, self->own_file ? MP_STREAM_CLOSE : MP_STREAM_FLUSH, 0, &error); self->file = NULL; - handle_error("write", error1); - handle_error("close", error2); + if (error != 0) { + self->error = error; + } + handle_error(self); } diff --git a/shared-module/gifio/GifWriter.h b/shared-module/gifio/GifWriter.h index e16de7c06b..e6676a84e0 100644 --- a/shared-module/gifio/GifWriter.h +++ b/shared-module/gifio/GifWriter.h @@ -36,5 +36,9 @@ typedef struct gifio_gifwriter { const mp_stream_p_t *file_proto; displayio_colorspace_t colorspace; int width, height; + int error; + uint8_t *data; + size_t cur, size; bool own_file; + bool byteswap; } gifio_gifwriter_t; From b881aec4c5c0b63532f48008d89e3945ccdf2a26 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Oct 2021 14:24:11 -0500 Subject: [PATCH 08/84] disable gifio on meowbit --- ports/stm/boards/meowbit_v121/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/stm/boards/meowbit_v121/mpconfigboard.mk b/ports/stm/boards/meowbit_v121/mpconfigboard.mk index ed96e99871..589f0bce10 100644 --- a/ports/stm/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm/boards/meowbit_v121/mpconfigboard.mk @@ -22,6 +22,7 @@ LD_FILE = boards/STM32F401xe_boot.ld CIRCUITPY_AESIO = 0 CIRCUITPY_BLEIO_HCI = 0 +CIRCUITPY_GIFIO = 0 CIRCUITPY_ULAB = 0 CIRCUITPY_STAGE = 1 From dc002261435272d9ca7b83f2516c3ac07957deef Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 27 Oct 2021 09:37:05 -0500 Subject: [PATCH 09/84] gifio: write block data directly into output buffer --- shared-module/gifio/GifWriter.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/shared-module/gifio/GifWriter.c b/shared-module/gifio/GifWriter.c index d5594538fe..5c3dbbfa24 100644 --- a/shared-module/gifio/GifWriter.c +++ b/shared-module/gifio/GifWriter.c @@ -175,8 +175,7 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b int pixel_count = self->width * self->height; int blocks = (pixel_count + BLOCK_SIZE - 1) / BLOCK_SIZE; - uint8_t block_data[2 + BLOCK_SIZE]; - block_data[1] = 0x80; + uint8_t *data = self->data + self->cur; if (self->colorspace == DISPLAYIO_COLORSPACE_L8) { mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(pixel_count - 1), false); @@ -186,11 +185,11 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b assert(pixel_count >= 0); int block_size = MIN(BLOCK_SIZE, pixel_count); pixel_count -= block_size; - block_data[0] = 1 + block_size; + *data++ = 1 + block_size; + *data++ = 0x80; for (int j = 0; j < block_size; j++) { - block_data[j + 2] = (*pixels++) >> 1; + *data++ = (*pixels++) >> 1; } - write_data(self, block_data, 2 + block_size); } } else { mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(2 * pixel_count - 1), false); @@ -200,7 +199,8 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b int block_size = MIN(BLOCK_SIZE, pixel_count); pixel_count -= block_size; - block_data[0] = 1 + block_size; + *data++ = 1 + block_size; + *data++ = 0x80; for (int j = 0; j < block_size; j++) { int pixel = *pixels++; if (self->byteswap) { @@ -209,12 +209,13 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b int red = (pixel >> (11 + (5 - 2))) & 0x3; int green = (pixel >> (5 + (6 - 3))) & 0x7; int blue = (pixel >> (0 + (5 - 2))) & 0x3; - block_data[j + 2] = (red << 5) | (green << 2) | blue; + *data++ = (red << 5) | (green << 2) | blue; } - write_data(self, block_data, 2 + block_size); } } + self->cur = data - self->data; + write_data(self, (uint8_t []) {0x01, 0x81, 0x00}, 3); // end code flush_data(self); handle_error(self); From ef4623dfae0b93de56c6106718f175faa7983c98 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 27 Oct 2021 09:37:47 -0500 Subject: [PATCH 10/84] gifio: Add dithered output It's not a great dither, but we're low on CPU time sooo --- shared-bindings/gifio/GifWriter.c | 10 ++++--- shared-bindings/gifio/GifWriter.h | 2 +- shared-module/gifio/GifWriter.c | 45 +++++++++++++++++++++++++++++-- shared-module/gifio/GifWriter.h | 1 + 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/shared-bindings/gifio/GifWriter.c b/shared-bindings/gifio/GifWriter.c index 6131550bf4..11dd43becd 100644 --- a/shared-bindings/gifio/GifWriter.c +++ b/shared-bindings/gifio/GifWriter.c @@ -34,24 +34,27 @@ #include "shared/runtime/context_manager_helpers.h" //| class GifWriter: -//| def __init__(self, file: Union[typing.BinaryIO, str], width:int, height:int, colorspace: displayio.Colorspace, loop:bool=True) -> None: +//| def __init__(self, file: Union[typing.BinaryIO, str], width:int, height:int, colorspace: displayio.Colorspace, loop:bool=True, dither:bool=False) -> None: //| """Construct a GifWriter object //| //| :param file: Either a file open in bytes mode, or the name of a file to open in bytes mode. //| :param width: The width of the image. All frames must have the same width. //| :param height: The height of the image. All frames must have the same height. -//| :param colorspace: The colorspace of the image. All frames must have the same colorspace. Only 1- and 2-byte colorspace are supported, not ``RGB888``. +//| :param colorspace: The colorspace of the image. All frames must have the same colorspace. The supported colorspaces are ``RGB565``, ``BGR565``, ``RGB565_SWAPPED``, ``BGR565_SWAPPED``, and ``L8`` (greyscale) +//| :param loop: If True, the GIF is marked for looping playback +//| :param dither: If True, and the image is in color, a simple ordered dither is applied. //| """ //| ... //| static mp_obj_t gifio_gifwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_file, ARG_width, ARG_height, ARG_colorspace, ARG_loop }; + enum { ARG_file, ARG_width, ARG_height, ARG_colorspace, ARG_loop, ARG_dither }; static const mp_arg_t allowed_args[] = { { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL} }, { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = 0} }, { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = 0} }, { MP_QSTR_colorspace, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL} }, { MP_QSTR_loop, MP_ARG_BOOL, { .u_bool = true } }, + { MP_QSTR_dither, MP_ARG_BOOL, { .u_bool = false } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -72,6 +75,7 @@ static mp_obj_t gifio_gifwriter_make_new(const mp_obj_type_t *type, size_t n_arg args[ARG_height].u_int, (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_colorspace].u_obj), args[ARG_loop].u_bool, + args[ARG_dither].u_bool, own_file); return self; diff --git a/shared-bindings/gifio/GifWriter.h b/shared-bindings/gifio/GifWriter.h index 203169cd75..601bd78679 100644 --- a/shared-bindings/gifio/GifWriter.h +++ b/shared-bindings/gifio/GifWriter.h @@ -33,7 +33,7 @@ typedef enum displayio_colorspace displayio_colorspace_t; extern const mp_obj_type_t gifio_gifwriter_type; -void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool own_file); +void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool dither, bool own_file); void shared_module_gifio_gifwriter_check_for_deinit(gifio_gifwriter_t *self); bool shared_module_gifio_gifwriter_deinited(gifio_gifwriter_t *self); void shared_module_gifio_gifwriter_deinit(gifio_gifwriter_t *self); diff --git a/shared-module/gifio/GifWriter.c b/shared-module/gifio/GifWriter.c index 5c3dbbfa24..608e522517 100644 --- a/shared-module/gifio/GifWriter.c +++ b/shared-module/gifio/GifWriter.c @@ -76,7 +76,7 @@ static void write_word(gifio_gifwriter_t *self, uint16_t value) { write_data(self, &value, sizeof(value)); } -void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool own_file) { +void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool dither, bool own_file) { self->file = file; self->file_proto = mp_proto_get_or_throw(MP_QSTR_protocol_stream, file); if (self->file_proto->is_text) { @@ -85,6 +85,7 @@ void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t * self->width = width; self->height = height; self->colorspace = colorspace; + self->dither = dither; self->own_file = own_file; size_t nblocks = (width * height + 125) / 126; @@ -159,6 +160,20 @@ void shared_module_gifio_gifwriter_deinit(gifio_gifwriter_t *self) { } } +static const uint8_t rb_bayer[4][4] = { + { 0, 33, 8, 42}, + {50, 16, 58, 25}, + {12, 46, 4, 37}, + {63, 29, 54, 21} +}; + +static const uint8_t g_bayer[4][4] = { + { 0, 16, 4, 20}, + {24, 8, 28, 12}, + { 6, 22, 2, 18}, + {31, 14, 26, 10} +}; + void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_buffer_info_t *bufinfo, int16_t delay) { if (delay) { write_data(self, (uint8_t []) {'!', 0xF9, 0x04, 0x04}, 4); @@ -191,7 +206,7 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b *data++ = (*pixels++) >> 1; } } - } else { + } else if (!self->dither) { mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(2 * pixel_count - 1), false); uint16_t *pixels = bufinfo->buf; @@ -212,6 +227,32 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b *data++ = (red << 5) | (green << 2) | blue; } } + } else { + mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(2 * pixel_count - 1), false); + + uint16_t *pixels = bufinfo->buf; + for (int i = 0; i < blocks; i++) { + int block_size = MIN(BLOCK_SIZE, pixel_count); + pixel_count -= block_size; + + *data++ = 1 + block_size; + *data++ = 0x80; + for (int j = 0; j < block_size; j++) { + int pixel = *pixels++; + if (self->byteswap) { + pixel = __builtin_bswap16(pixel); + } + int red = (pixel >> 8) & 0xf8; + int green = (pixel >> 3) & 0xfc; + int blue = (pixel << 3) & 0xf8; + + red = MAX(0, red - rb_bayer[i % 4][j % 4]); + green = MAX(0, green - g_bayer[i % 4][j % 4]); + blue = MAX(0, blue - rb_bayer[i % 4][j % 4]); + + *data++ = ((red >> 1) & 0x60) | ((green >> 3) & 0x1c) | (blue >> 6); + } + } } self->cur = data - self->data; diff --git a/shared-module/gifio/GifWriter.h b/shared-module/gifio/GifWriter.h index e6676a84e0..5ed57bb022 100644 --- a/shared-module/gifio/GifWriter.h +++ b/shared-module/gifio/GifWriter.h @@ -41,4 +41,5 @@ typedef struct gifio_gifwriter { size_t cur, size; bool own_file; bool byteswap; + bool dither; } gifio_gifwriter_t; From e7338765742e3ddec6da1305a48b4d89f1d2928d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 27 Oct 2021 16:52:48 -0500 Subject: [PATCH 11/84] dither in x/y, not i/j The easiest thing to implement was to use the i/j numbers, but they were not directly related to image x/y coordinates. This may slow things down a tiny little bit, but it looks much better. --- shared-module/gifio/GifWriter.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shared-module/gifio/GifWriter.c b/shared-module/gifio/GifWriter.c index 608e522517..f8c2c7d3ce 100644 --- a/shared-module/gifio/GifWriter.c +++ b/shared-module/gifio/GifWriter.c @@ -231,6 +231,7 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(2 * pixel_count - 1), false); uint16_t *pixels = bufinfo->buf; + int x = 0, y = 0; for (int i = 0; i < blocks; i++) { int block_size = MIN(BLOCK_SIZE, pixel_count); pixel_count -= block_size; @@ -246,9 +247,14 @@ void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_b int green = (pixel >> 3) & 0xfc; int blue = (pixel << 3) & 0xf8; - red = MAX(0, red - rb_bayer[i % 4][j % 4]); - green = MAX(0, green - g_bayer[i % 4][j % 4]); - blue = MAX(0, blue - rb_bayer[i % 4][j % 4]); + red = MAX(0, red - rb_bayer[x % 4][y % 4]); + green = MAX(0, green - g_bayer[x % 4][(y + 2) % 4]); + blue = MAX(0, blue - rb_bayer[(x + 2) % 4][y % 4]); + x++; + if (x == self->width) { + x = 0; + y++; + } *data++ = ((red >> 1) & 0x60) | ((green >> 3) & 0x1c) | (blue >> 6); } From 95172cf3ce58ef826b1886f683744b0d824f2533 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 2 Nov 2021 11:00:11 +0530 Subject: [PATCH 12/84] add monitor class Co-authored-by: anecdata <16617689+anecdata@users.noreply.github.com> --- locale/circuitpython.pot | 8 + ports/espressif/common-hal/wifi/Monitor.c | 166 +++++++++++++++++++++ ports/espressif/common-hal/wifi/Monitor.h | 41 +++++ ports/espressif/common-hal/wifi/__init__.c | 3 + py/circuitpy_mpconfig.h | 7 + shared-bindings/wifi/Monitor.c | 165 ++++++++++++++++++++ shared-bindings/wifi/Monitor.h | 48 ++++++ shared-bindings/wifi/__init__.c | 18 +-- shared-bindings/wifi/__init__.h | 2 - 9 files changed, 446 insertions(+), 12 deletions(-) create mode 100644 ports/espressif/common-hal/wifi/Monitor.c create mode 100644 ports/espressif/common-hal/wifi/Monitor.h create mode 100644 shared-bindings/wifi/Monitor.c create mode 100644 shared-bindings/wifi/Monitor.h diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 4b8a26a9ac..21e3b28557 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -148,6 +148,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3553,6 +3557,10 @@ msgstr "" msgid "module not found" msgstr "" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/ports/espressif/common-hal/wifi/Monitor.c b/ports/espressif/common-hal/wifi/Monitor.c new file mode 100644 index 0000000000..e6e7175c51 --- /dev/null +++ b/ports/espressif/common-hal/wifi/Monitor.c @@ -0,0 +1,166 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/mpstate.h" +#include "py/runtime.h" + +#include "shared-bindings/wifi/Monitor.h" +#include "shared-bindings/wifi/Packet.h" + +#include "esp_log.h" + +#define MONITOR_PAYLOAD_FCS_LEN (4) +#define MONITOR_QUEUE_TIMEOUT_TICK (0) + +typedef struct { + void *payload; + unsigned channel; + uint32_t length; + signed rssi; +} monitor_packet_t; + +static const char *TAG = "monitor"; + +static void wifi_monitor_cb(void *recv_buf, wifi_promiscuous_pkt_type_t type) { + wifi_promiscuous_pkt_t *pkt = (wifi_promiscuous_pkt_t *)recv_buf; + + // prepare packet + monitor_packet_t packet = { + .channel = pkt->rx_ctrl.channel, + .length = pkt->rx_ctrl.sig_len, + .rssi = pkt->rx_ctrl.rssi, + }; + + // for now, the monitor only dumps the length of the MISC type frame + if (type != WIFI_PKT_MISC && !pkt->rx_ctrl.rx_state) { + packet.length -= MONITOR_PAYLOAD_FCS_LEN; + packet.payload = malloc(packet.length); + if (packet.payload) { + memcpy(packet.payload, pkt->payload, packet.length); + wifi_monitor_obj_t *self = MP_STATE_VM(wifi_monitor_singleton); + if (self->queue) { + // send packet + if (xQueueSendFromISR(self->queue, &packet, NULL) != pdTRUE) { + self->loss++; + free(packet.payload); + ESP_LOGE(TAG, "packet queue full"); + } + } + } else { + ESP_LOGE(TAG, "not enough memory for packet"); + } + } +} + +void common_hal_wifi_monitor_construct(wifi_monitor_obj_t *self, uint8_t channel, size_t queue) { + const compressed_string_t *monitor_mode_init_error = translate("monitor init failed"); + + self->queue = xQueueCreate(queue, sizeof(monitor_packet_t)); + if (!self->queue) { + mp_raise_RuntimeError(monitor_mode_init_error); + } + + // start wifi promicuous mode + wifi_promiscuous_filter_t wifi_filter = { + .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT, + }; + esp_wifi_set_promiscuous_filter(&wifi_filter); + esp_wifi_set_promiscuous_rx_cb(wifi_monitor_cb); + if (esp_wifi_set_promiscuous(true) != ESP_OK) { + mp_raise_RuntimeError(monitor_mode_init_error); + } + esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE); + + self->channel = channel; + self->queue_length = queue; +} + +bool common_hal_wifi_monitor_deinited(void) { + bool enabled; + esp_wifi_get_promiscuous(&enabled); + return !enabled; +} + +void common_hal_wifi_monitor_deinit(wifi_monitor_obj_t *self) { + if (common_hal_wifi_monitor_deinited()) { + return; + } + + // disable wifi promiscuous mode + esp_wifi_set_promiscuous(false); + + // make sure to free all resources in the left items + UBaseType_t left_items = uxQueueMessagesWaiting(self->queue); + monitor_packet_t packet; + while (left_items--) { + xQueueReceive(self->queue, &packet, MONITOR_QUEUE_TIMEOUT_TICK); + free(packet.payload); + } + vQueueDelete(self->queue); + self->queue = NULL; +} + +void common_hal_wifi_monitor_set_channel(wifi_monitor_obj_t *self, uint8_t channel) { + self->channel = channel; + esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE); +} + +mp_obj_t common_hal_wifi_monitor_get_channel(wifi_monitor_obj_t *self) { + return MP_OBJ_NEW_SMALL_INT(self->channel); +} + +mp_obj_t common_hal_wifi_monitor_get_queue(wifi_monitor_obj_t *self) { + return mp_obj_new_int_from_uint(self->queue_length); +} + +mp_obj_t common_hal_wifi_monitor_get_loss(wifi_monitor_obj_t *self) { + size_t loss = self->loss; + self->loss = 0; + return mp_obj_new_int_from_uint(loss); +} + +mp_obj_t common_hal_wifi_monitor_get_packet(wifi_monitor_obj_t *self) { + monitor_packet_t packet; + + if (xQueueReceive(self->queue, &packet, MONITOR_QUEUE_TIMEOUT_TICK) != pdTRUE) { + return (mp_obj_t)&mp_const_empty_dict_obj; + } + + mp_obj_dict_t *dict = MP_OBJ_TO_PTR(mp_obj_new_dict(4)); + + mp_obj_dict_store(dict, cp_enum_find(&wifi_packet_type, PACKET_CH), MP_OBJ_NEW_SMALL_INT(packet.channel)); + + mp_obj_dict_store(dict, cp_enum_find(&wifi_packet_type, PACKET_LEN), MP_OBJ_NEW_SMALL_INT(packet.length)); + + mp_obj_dict_store(dict, cp_enum_find(&wifi_packet_type, PACKET_RAW), mp_obj_new_bytes(packet.payload, packet.length)); + free(packet.payload); + + mp_obj_dict_store(dict, cp_enum_find(&wifi_packet_type, PACKET_RSSI), MP_OBJ_NEW_SMALL_INT(packet.rssi)); + + return MP_OBJ_FROM_PTR(dict); +} diff --git a/ports/espressif/common-hal/wifi/Monitor.h b/ports/espressif/common-hal/wifi/Monitor.h new file mode 100644 index 0000000000..84eca71a36 --- /dev/null +++ b/ports/espressif/common-hal/wifi/Monitor.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WIFI_MONITOR_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WIFI_MONITOR_H + +#include "py/obj.h" +#include "components/esp_wifi/include/esp_wifi.h" + +typedef struct { + mp_obj_base_t base; + uint8_t channel; + size_t loss; + size_t queue_length; + QueueHandle_t queue; +} wifi_monitor_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_WIFI_MONITOR_H diff --git a/ports/espressif/common-hal/wifi/__init__.c b/ports/espressif/common-hal/wifi/__init__.c index 8d19a91cb2..c349ca4b39 100644 --- a/ports/espressif/common-hal/wifi/__init__.c +++ b/ports/espressif/common-hal/wifi/__init__.c @@ -27,8 +27,10 @@ #include "common-hal/wifi/__init__.h" #include "shared-bindings/ipaddress/IPv4Address.h" +#include "shared-bindings/wifi/Monitor.h" #include "shared-bindings/wifi/Radio.h" +#include "py/mpstate.h" #include "py/runtime.h" #include "components/esp_wifi/include/esp_wifi.h" @@ -158,6 +160,7 @@ void wifi_reset(void) { if (!wifi_inited) { return; } + common_hal_wifi_monitor_deinit(MP_STATE_VM(wifi_monitor_singleton)); wifi_radio_obj_t *radio = &common_hal_wifi_radio_obj; common_hal_wifi_radio_set_enabled(radio, false); ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 3608b9c71d..faa938a913 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -319,6 +319,12 @@ extern const struct _mp_obj_module_t nvm_module; #endif #endif +#if CIRCUITPY_WIFI +#define WIFI_MONITOR_ROOT_POINTERS mp_obj_t wifi_monitor_singleton; +#else +#define WIFI_MONITOR_ROOT_POINTERS +#endif + // Define certain native modules with weak links so they can be replaced with Python // implementations. This list may grow over time. @@ -442,6 +448,7 @@ struct _supervisor_allocation_node; KEYPAD_ROOT_POINTERS \ GAMEPAD_ROOT_POINTERS \ BOARD_UART_ROOT_POINTER \ + WIFI_MONITOR_ROOT_POINTERS \ MEMORYMONITOR_ROOT_POINTERS \ vstr_t *repl_line; \ mp_obj_t pew_singleton; \ diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c new file mode 100644 index 0000000000..3dde904741 --- /dev/null +++ b/shared-bindings/wifi/Monitor.c @@ -0,0 +1,165 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/mpstate.h" +#include "py/runtime.h" +#include "py/objproperty.h" + +#include "shared-bindings/util.h" +#include "shared-bindings/wifi/Packet.h" +#include "shared-bindings/wifi/Monitor.h" + +//| class Monitor: +//| """For monitoring WiFi packets.""" +//| + +//| def __init__(self, channel: Optional[int] = 1, queue: Optional[int] = 128) -> None: +//| """Initialize `wifi.Monitor` singleton. +//| +//| :param int channel: The WiFi channel to scan. +//| :param int queue: The queue size for buffering the packet. +//| +//| """ +//| ... +//| +STATIC mp_obj_t wifi_monitor_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_channel, ARG_queue }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 1} }, + { MP_QSTR_queue, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 128} }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + if (args[ARG_channel].u_int < 0 || args[ARG_channel].u_int > 11) { + mp_raise_ValueError_varg(translate("%q out of bounds"), MP_QSTR_channel); + } + + if (args[ARG_queue].u_int < 0) { + mp_raise_ValueError_varg(translate("%q out of bounds"), MP_QSTR_channel); + } + + wifi_monitor_obj_t *self = MP_STATE_VM(wifi_monitor_singleton); + if (common_hal_wifi_monitor_deinited()) { + self = m_new_obj(wifi_monitor_obj_t); + self->base.type = &wifi_monitor_type; + common_hal_wifi_monitor_construct(self, args[ARG_channel].u_int, args[ARG_queue].u_int); + MP_STATE_VM(wifi_monitor_singleton) = self; + } + + return MP_OBJ_FROM_PTR(self); +} + +//| channel: int +//| """The WiFi channel to scan.""" +//| +STATIC mp_obj_t wifi_monitor_obj_get_channel(mp_obj_t self_in) { + return common_hal_wifi_monitor_get_channel(self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_get_channel_obj, wifi_monitor_obj_get_channel); + +STATIC mp_obj_t wifi_monitor_obj_set_channel(mp_obj_t self_in, mp_obj_t channel) { + common_hal_wifi_monitor_set_channel(self_in, mp_obj_get_int(channel)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(wifi_monitor_set_channel_obj, wifi_monitor_obj_set_channel); + +const mp_obj_property_t wifi_monitor_channel_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&wifi_monitor_get_channel_obj, + (mp_obj_t)&wifi_monitor_set_channel_obj, + MP_ROM_NONE }, +}; + +//| queue: int +//| """The queue size for buffering the packet.""" +//| +STATIC mp_obj_t wifi_monitor_obj_get_queue(mp_obj_t self_in) { + return common_hal_wifi_monitor_get_queue(self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_get_queue_obj, wifi_monitor_obj_get_queue); + +const mp_obj_property_t wifi_monitor_queue_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&wifi_monitor_get_queue_obj, + MP_ROM_NONE, + MP_ROM_NONE }, +}; + +//| def deinit(self) -> None: +//| """De-initialize `wifi.Monitor` singleton.""" +//| ... +//| +STATIC mp_obj_t wifi_monitor_obj_deinit(mp_obj_t self_in) { + common_hal_wifi_monitor_deinit(self_in); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_deinit_obj, wifi_monitor_obj_deinit); + +STATIC void check_for_deinit(mp_obj_t self_in) { + if (common_hal_wifi_monitor_deinited()) { + raise_deinited_error(); + } +} + +//| def loss(self) -> int: +//| """Returns the packet loss count. The counter resets after each poll.""" +//| ... +//| +STATIC mp_obj_t wifi_monitor_obj_get_loss(mp_obj_t self_in) { + return common_hal_wifi_monitor_get_loss(self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_loss_obj, wifi_monitor_obj_get_loss); + +//| def packet(self) -> dict: +//| """Returns the monitor packet.""" +//| ... +//| +STATIC mp_obj_t wifi_monitor_obj_get_packet(mp_obj_t self_in) { + check_for_deinit(self_in); + return common_hal_wifi_monitor_get_packet(self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_packet_obj, wifi_monitor_obj_get_packet); + +STATIC const mp_rom_map_elem_t wifi_monitor_locals_dict_table[] = { + // properties + { MP_ROM_QSTR(MP_QSTR_channel), MP_ROM_PTR(&wifi_monitor_channel_obj) }, + { MP_ROM_QSTR(MP_QSTR_queue), MP_ROM_PTR(&wifi_monitor_queue_obj) }, + + // functions + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&wifi_monitor_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR_loss), MP_ROM_PTR(&wifi_monitor_loss_obj) }, + { MP_ROM_QSTR(MP_QSTR_packet), MP_ROM_PTR(&wifi_monitor_packet_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(wifi_monitor_locals_dict, wifi_monitor_locals_dict_table); + +const mp_obj_type_t wifi_monitor_type = { + .base = { &mp_type_type }, + .name = MP_QSTR_Monitor, + .make_new = wifi_monitor_make_new, + .locals_dict = (mp_obj_t)&wifi_monitor_locals_dict, +}; diff --git a/shared-bindings/wifi/Monitor.h b/shared-bindings/wifi/Monitor.h new file mode 100644 index 0000000000..b6b71c07a7 --- /dev/null +++ b/shared-bindings/wifi/Monitor.h @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_MONITOR_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_MONITOR_H + +#include "common-hal/wifi/Monitor.h" + +const mp_obj_type_t wifi_monitor_type; + +void common_hal_wifi_monitor_construct(wifi_monitor_obj_t *self, + uint8_t channel, size_t queue); +void common_hal_wifi_monitor_deinit(wifi_monitor_obj_t *self); +bool common_hal_wifi_monitor_deinited(void); + +void common_hal_wifi_monitor_set_channel(wifi_monitor_obj_t *self, uint8_t channel); +mp_obj_t common_hal_wifi_monitor_get_channel(wifi_monitor_obj_t *self); + +mp_obj_t common_hal_wifi_monitor_get_queue(wifi_monitor_obj_t *self); + +mp_obj_t common_hal_wifi_monitor_get_loss(wifi_monitor_obj_t *self); + +mp_obj_t common_hal_wifi_monitor_get_packet(wifi_monitor_obj_t *self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_MONITOR_H diff --git a/shared-bindings/wifi/__init__.c b/shared-bindings/wifi/__init__.c index 399b47cc47..0f9dee8462 100644 --- a/shared-bindings/wifi/__init__.c +++ b/shared-bindings/wifi/__init__.c @@ -24,13 +24,12 @@ * THE SOFTWARE. */ -#include "py/objexcept.h" -#include "py/runtime.h" #include "shared-bindings/wifi/__init__.h" -#include "shared-bindings/wifi/Radio.h" -#include "shared-bindings/wifi/Network.h" #include "shared-bindings/wifi/AuthMode.h" +#include "shared-bindings/wifi/Network.h" +#include "shared-bindings/wifi/Monitor.h" #include "shared-bindings/wifi/Packet.h" +#include "shared-bindings/wifi/Radio.h" //| """ //| The `wifi` module provides necessary low-level functionality for managing @@ -41,7 +40,6 @@ //| This object is the sole instance of `wifi.Radio`.""" //| - // Called when wifi is imported. STATIC mp_obj_t wifi___init__(void) { common_hal_wifi_init(); @@ -49,25 +47,25 @@ STATIC mp_obj_t wifi___init__(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(wifi___init___obj, wifi___init__); - STATIC const mp_rom_map_elem_t wifi_module_globals_table[] = { + // Name { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_wifi) }, // Initialization { MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&wifi___init___obj) }, - { MP_ROM_QSTR(MP_QSTR_Radio), MP_ROM_PTR(&wifi_radio_type) }, - { MP_ROM_QSTR(MP_QSTR_Network), MP_ROM_PTR(&wifi_network_type) }, + // Classes { MP_ROM_QSTR(MP_QSTR_AuthMode), MP_ROM_PTR(&wifi_authmode_type) }, + { MP_ROM_QSTR(MP_QSTR_Monitor), MP_ROM_PTR(&wifi_monitor_type) }, + { MP_ROM_QSTR(MP_QSTR_Network), MP_ROM_PTR(&wifi_network_type) }, { MP_ROM_QSTR(MP_QSTR_Packet), MP_ROM_PTR(&wifi_packet_type) }, + { MP_ROM_QSTR(MP_QSTR_Radio), MP_ROM_PTR(&wifi_radio_type) }, // Properties { MP_ROM_QSTR(MP_QSTR_radio), MP_ROM_PTR(&common_hal_wifi_radio_obj) }, }; - STATIC MP_DEFINE_CONST_DICT(wifi_module_globals, wifi_module_globals_table); - const mp_obj_module_t wifi_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&wifi_module_globals, diff --git a/shared-bindings/wifi/__init__.h b/shared-bindings/wifi/__init__.h index 124c0bc491..e626727e77 100644 --- a/shared-bindings/wifi/__init__.h +++ b/shared-bindings/wifi/__init__.h @@ -27,8 +27,6 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_WIFI___INIT___H #define MICROPY_INCLUDED_SHARED_BINDINGS_WIFI___INIT___H -#include "py/objlist.h" - #include "shared-bindings/wifi/Radio.h" extern wifi_radio_obj_t common_hal_wifi_radio_obj; From 4e207853f0b2b3712feecee3660c2edd257675e3 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 2 Nov 2021 11:11:11 +0530 Subject: [PATCH 13/84] rearrange hostname --- ports/espressif/common-hal/wifi/Radio.c | 26 +++---- ports/espressif/common-hal/wifi/Radio.h | 1 - shared-bindings/wifi/Radio.c | 90 +++++++++++++------------ shared-bindings/wifi/Radio.h | 1 + 4 files changed, 60 insertions(+), 58 deletions(-) diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 9d48ff1257..8acfe978a8 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -101,6 +101,19 @@ void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled) { } } +mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self) { + const char *hostname = NULL; + esp_netif_get_hostname(self->netif, &hostname); + if (hostname == NULL) { + return mp_const_none; + } + return mp_obj_new_str(hostname, strlen(hostname)); +} + +void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) { + esp_netif_set_hostname(self->netif, hostname); +} + mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) { uint8_t mac[MAC_ADDRESS_LENGTH]; esp_wifi_get_mac(ESP_IF_WIFI_STA, mac); @@ -142,19 +155,6 @@ void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self) { self->current_scan = NULL; } -mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self) { - const char *hostname = NULL; - esp_netif_get_hostname(self->netif, &hostname); - if (hostname == NULL) { - return mp_const_none; - } - return mp_obj_new_str(hostname, strlen(hostname)); -} - -void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) { - esp_netif_set_hostname(self->netif, hostname); -} - void common_hal_wifi_radio_start_station(wifi_radio_obj_t *self) { set_mode_station(self, true); } diff --git a/ports/espressif/common-hal/wifi/Radio.h b/ports/espressif/common-hal/wifi/Radio.h index 3f53329324..3c0828bf0b 100644 --- a/ports/espressif/common-hal/wifi/Radio.h +++ b/ports/espressif/common-hal/wifi/Radio.h @@ -57,7 +57,6 @@ typedef struct { uint8_t retries_left; uint8_t starting_retries; uint8_t last_disconnect_reason; - wifi_config_t ap_config; esp_netif_ip_info_t ap_ip_info; esp_netif_t *ap_netif; diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 0983706919..9f6c62fce9 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -74,6 +74,47 @@ const mp_obj_property_t wifi_radio_enabled_obj = { MP_ROM_NONE }, }; +//| hostname: ReadableBuffer +//| """Hostname for wifi interface. When the hostname is altered after interface started/connected +//| the changes would only be reflected once the interface restarts/reconnects.""" +//| +STATIC mp_obj_t wifi_radio_get_hostname(mp_obj_t self_in) { + wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); + return common_hal_wifi_radio_get_hostname(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_hostname_obj, wifi_radio_get_hostname); + +STATIC mp_obj_t wifi_radio_set_hostname(mp_obj_t self_in, mp_obj_t hostname_in) { + mp_buffer_info_t hostname; + mp_get_buffer_raise(hostname_in, &hostname, MP_BUFFER_READ); + + if (hostname.len < 1 || hostname.len > 253) { + mp_raise_ValueError(translate("Hostname must be between 1 and 253 characters")); + } + + #ifndef CONFIG_IDF_TARGET_ESP32C3 + regex_t regex; // validate hostname according to RFC 1123 + regcomp(®ex,"^(([a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])\\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])$", REG_EXTENDED | REG_ICASE | REG_NOSUB); + if (regexec(®ex, hostname.buf, 0, NULL, 0)) { + mp_raise_ValueError(translate("invalid hostname")); + } + regfree(®ex); + #endif + + wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_wifi_radio_set_hostname(self, hostname.buf); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_hostname_obj, wifi_radio_set_hostname); + +const mp_obj_property_t wifi_radio_hostname_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&wifi_radio_get_hostname_obj, + (mp_obj_t)&wifi_radio_set_hostname_obj, + MP_ROM_NONE}, +}; + //| mac_address: bytes //| """MAC address of the wifi radio station. (read-only)""" //| @@ -132,47 +173,6 @@ STATIC mp_obj_t wifi_radio_stop_scanning_networks(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_scanning_networks_obj, wifi_radio_stop_scanning_networks); -//| hostname: ReadableBuffer -//| """Hostname for wifi interface. When the hostname is altered after interface started/connected -//| the changes would only be reflected once the interface restarts/reconnects.""" -//| -STATIC mp_obj_t wifi_radio_get_hostname(mp_obj_t self_in) { - wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); - return common_hal_wifi_radio_get_hostname(self); -} -MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_hostname_obj, wifi_radio_get_hostname); - -STATIC mp_obj_t wifi_radio_set_hostname(mp_obj_t self_in, mp_obj_t hostname_in) { - mp_buffer_info_t hostname; - mp_get_buffer_raise(hostname_in, &hostname, MP_BUFFER_READ); - - if (hostname.len < 1 || hostname.len > 253) { - mp_raise_ValueError(translate("Hostname must be between 1 and 253 characters")); - } - - #ifndef CONFIG_IDF_TARGET_ESP32C3 - regex_t regex; // validate hostname according to RFC 1123 - regcomp(®ex,"^(([a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])\\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])$", REG_EXTENDED | REG_ICASE | REG_NOSUB); - if (regexec(®ex, hostname.buf, 0, NULL, 0)) { - mp_raise_ValueError(translate("invalid hostname")); - } - regfree(®ex); - #endif - - wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_wifi_radio_set_hostname(self, hostname.buf); - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_hostname_obj, wifi_radio_set_hostname); - -const mp_obj_property_t wifi_radio_hostname_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&wifi_radio_get_hostname_obj, - (mp_obj_t)&wifi_radio_set_hostname_obj, - MP_ROM_NONE}, -}; - //| def start_station(self) -> None: //| """Starts a Station.""" //| ... @@ -503,18 +503,20 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_ping_obj, 1, wifi_radio_ping); STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_enabled), MP_ROM_PTR(&wifi_radio_enabled_obj) }, + + { MP_ROM_QSTR(MP_QSTR_hostname), MP_ROM_PTR(&wifi_radio_hostname_obj) }, + { MP_ROM_QSTR(MP_QSTR_mac_address), MP_ROM_PTR(&wifi_radio_mac_address_obj) }, { MP_ROM_QSTR(MP_QSTR_mac_address_ap), MP_ROM_PTR(&wifi_radio_mac_address_ap_obj) }, { MP_ROM_QSTR(MP_QSTR_start_scanning_networks), MP_ROM_PTR(&wifi_radio_start_scanning_networks_obj) }, { MP_ROM_QSTR(MP_QSTR_stop_scanning_networks), MP_ROM_PTR(&wifi_radio_stop_scanning_networks_obj) }, - { MP_ROM_QSTR(MP_QSTR_hostname), MP_ROM_PTR(&wifi_radio_hostname_obj) }, - { MP_ROM_QSTR(MP_QSTR_start_station), MP_ROM_PTR(&wifi_radio_start_station_obj) }, { MP_ROM_QSTR(MP_QSTR_stop_station), MP_ROM_PTR(&wifi_radio_stop_station_obj) }, - { MP_ROM_QSTR(MP_QSTR_stop_ap), MP_ROM_PTR(&wifi_radio_stop_ap_obj) }, + { MP_ROM_QSTR(MP_QSTR_start_ap), MP_ROM_PTR(&wifi_radio_start_ap_obj) }, + { MP_ROM_QSTR(MP_QSTR_stop_ap), MP_ROM_PTR(&wifi_radio_stop_ap_obj) }, { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&wifi_radio_connect_obj) }, // { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) }, diff --git a/shared-bindings/wifi/Radio.h b/shared-bindings/wifi/Radio.h index 5716d155f4..eeeffa2f94 100644 --- a/shared-bindings/wifi/Radio.h +++ b/shared-bindings/wifi/Radio.h @@ -85,6 +85,7 @@ extern void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self) extern void common_hal_wifi_radio_start_station(wifi_radio_obj_t *self); extern void common_hal_wifi_radio_stop_station(wifi_radio_obj_t *self); + extern void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, uint8_t authmode); extern void common_hal_wifi_radio_stop_ap(wifi_radio_obj_t *self); From 41dcfda5939d36a463afe3b89363a7b61b896b7c Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Tue, 2 Nov 2021 12:24:48 +0530 Subject: [PATCH 14/84] update wifi_monitor_make_new and arg parsing --- shared-bindings/wifi/Monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index 3dde904741..0ddc8db4fd 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -45,7 +45,7 @@ //| """ //| ... //| -STATIC mp_obj_t wifi_monitor_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t wifi_monitor_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_channel, ARG_queue }; static const mp_arg_t allowed_args[] = { { MP_QSTR_channel, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 1} }, @@ -53,7 +53,7 @@ STATIC mp_obj_t wifi_monitor_make_new(const mp_obj_type_t *type, size_t n_args, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); if (args[ARG_channel].u_int < 0 || args[ARG_channel].u_int > 11) { mp_raise_ValueError_varg(translate("%q out of bounds"), MP_QSTR_channel); From a8614a61dcf8c4b2f323140f629aa11a7c9bb267 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 27 Oct 2021 16:10:20 -0500 Subject: [PATCH 15/84] ParallelImageCapture: Add continuous capture on espressif By having a pair of buffers, the capture hardware can fill one buffer while Python code (including displayio, etc) operates on the other buffer. This increases the responsiveness of camera-using code. On the Kaluga it makes the following improvements: * 320x240 viewfinder at 30fps instead of 15fps using directio * 240x240 animated gif capture at 10fps instead of 7.5fps As discussed at length on Discord, the "usual end user" code will look like this: camera = ... with camera.continuous_capture(buffer1, buffer2) as capture: for frame in capture: # Do something with frame However, rather than presenting a context manager, the core code consists of three new functions to start & stop continuous capture, and to get the next frame. The reason is twofold. First, it's simply easier to implement the context manager object in pure Python. Second, for more advanced usage, the context manager may be too limiting, and it's easier to iterate on the right design in Python code. In particular, I noticed that adapting the JPEG-capturing programs to use continuous capture mode needed a change in program structure. The camera app was structured as ```python while True: if shutter button was just pressed: capture a jpeg frame else: update the viewfinder ``` However, "capture a jpeg frame" needs to (A) switch the camera settings and (B) capture into a different, larger buffer then (C) return to the earlier settings. This can't be done during continuous capture mode. So just restructuring it as follows isn't going to work: ```python with camera.continuous_capture(buffer1, buffer2) as capture: for frame in capture: if shutter button was just pressed: capture a jpeg frame, without disturbing continuous capture mode else: update the viewfinder ``` The continuous mode is only implemented in the espressif port; others will throw an exception if the associated methods are invoked. It's not impossible to implement there, just not a priority, since these micros don't have enough RAM for two framebuffer copies at any resonable sizes. The capture code, including single-shot capture, now take mp_obj_t in the common-hal layer, instead of a buffer & length. This was done for the continuous capture mode because it has to identify & return to the user the proper Python object representing the original buffer. In the Espressif port, it was convenient to implement single capture in terms of a multi-capture, which is why I changed the singleshot routine's signature too. --- locale/circuitpython.pot | 17 +++- .../imagecapture/ParallelImageCapture.c | 10 +-- .../imagecapture/ParallelImageCapture.c | 82 +++++++++++++++---- .../imagecapture/ParallelImageCapture.h | 3 + .../imagecapture/ParallelImageCapture.c | 7 +- py/circuitpy_defns.mk | 2 + .../imagecapture/ParallelImageCapture.c | 58 +++++++++++-- .../imagecapture/ParallelImageCapture.h | 5 +- .../imagecapture/ParallelImageCapture.c | 44 ++++++++++ 9 files changed, 197 insertions(+), 31 deletions(-) create mode 100644 shared-module/imagecapture/ParallelImageCapture.c diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index f1f747e7e6..1d7fc6854d 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -347,6 +347,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -625,6 +626,10 @@ msgstr "" msgid "Buffer too short by %d bytes" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1587,6 +1592,10 @@ msgstr "" msgid "No available clocks" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "" @@ -1607,6 +1616,7 @@ msgstr "" msgid "No hardware support on clk pin" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1727,7 +1737,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1822,6 +1831,7 @@ msgstr "" msgid "Permission denied" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2175,6 +2185,10 @@ msgstr "" msgid "The sample's signedness does not match the mixer's" msgstr "" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3880,6 +3894,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c b/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c index acc172fa22..8e41f50d8d 100644 --- a/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c @@ -151,14 +151,14 @@ static void setup_dma(DmacDescriptor *descriptor, size_t count, uint32_t *buffer descriptor->DESCADDR.reg = 0; } -#include - -void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize) { +void common_hal_imagecapture_parallelimagecapture_singleshot_capture(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_RW); uint8_t dma_channel = dma_allocate_channel(); - uint32_t *dest = buffer; - size_t count = bufsize / 4; // PCC receives 4 bytes (2 pixels) at a time + uint32_t *dest = bufinfo.buf; + size_t count = bufinfo.len / 4; // PCC receives 4 bytes (2 pixels) at a time turn_on_event_system(); diff --git a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c index 6d347080bd..b167b5c734 100644 --- a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c @@ -79,6 +79,11 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle } void common_hal_imagecapture_parallelimagecapture_deinit(imagecapture_parallelimagecapture_obj_t *self) { + cam_deinit(); + + self->buffer1 = NULL; + self->buffer2 = NULL; + reset_pin_number(self->data_clock); self->data_clock = NO_PIN; @@ -102,28 +107,73 @@ bool common_hal_imagecapture_parallelimagecapture_deinited(imagecapture_parallel return self->data_clock == NO_PIN; } -void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize) { - size_t size = bufsize / 2; // count is in pixels - if (size != self->config.size || buffer != self->config.frame1_buffer) { - cam_deinit(); - self->config.size = bufsize / 2; // count is in pixels(?) - self->config.frame1_buffer = buffer; - - cam_init(&self->config); - cam_start(); - } else { - cam_give(buffer); +void common_hal_imagecapture_parallelimagecapture_continuous_capture_start(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer1, mp_obj_t buffer2) { + if (buffer1 == self->buffer1 && buffer2 == self->buffer2) { + return; } + mp_buffer_info_t bufinfo1, bufinfo2 = {}; + mp_get_buffer_raise(buffer1, &bufinfo1, MP_BUFFER_RW); + if (buffer2 != mp_const_none) { + mp_get_buffer_raise(buffer2, &bufinfo2, MP_BUFFER_RW); + if (bufinfo1.len != bufinfo2.len) { + mp_raise_ValueError(translate("Buffers must be same size")); + } + } + + self->buffer1 = buffer1; + self->buffer2 = buffer2; + + + cam_deinit(); + self->config.size = bufinfo1.len / 2; // count is in pixels + self->config.frame1_buffer = bufinfo1.buf; + self->config.frame2_buffer = bufinfo2.buf; + self->buffer_to_give = NULL; + + cam_init(&self->config); + cam_start(); +} + +void common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(imagecapture_parallelimagecapture_obj_t *self) { + cam_deinit(); + self->buffer1 = self->buffer2 = NULL; + self->buffer_to_give = NULL; +} + +STATIC void common_hal_imagecapture_parallelimagecapture_continuous_capture_give_frame(imagecapture_parallelimagecapture_obj_t *self) { + if (self->buffer_to_give) { + cam_give(self->buffer_to_give); + self->buffer_to_give = NULL; + } +} + +mp_obj_t common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(imagecapture_parallelimagecapture_obj_t *self) { + if (self->buffer1 == NULL) { + mp_raise_RuntimeError(translate("No capture in progress")); + } + common_hal_imagecapture_parallelimagecapture_continuous_capture_give_frame(self); + while (!cam_ready()) { RUN_BACKGROUND_TASKS; if (mp_hal_is_interrupted()) { - self->config.size = 0; // force re-init next time - cam_stop(); - return; + return mp_const_none; } } - uint8_t *unused; - cam_take(&unused); // this just "returns" buffer + cam_take(&self->buffer_to_give); + + if (self->buffer_to_give == self->config.frame1_buffer) { + return self->buffer1; + } + if (self->buffer_to_give == self->config.frame2_buffer) { + return self->buffer2; + } + + return mp_const_none; // should be unreachable +} + +void common_hal_imagecapture_parallelimagecapture_singleshot_capture(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer) { + common_hal_imagecapture_parallelimagecapture_continuous_capture_start(self, buffer, mp_const_none); + common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(self); } diff --git a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.h b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.h index 4dd65bc904..45f7a2734e 100644 --- a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.h +++ b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.h @@ -26,6 +26,7 @@ #pragma once +#include "py/obj.h" #include "shared-bindings/imagecapture/ParallelImageCapture.h" #include "cam.h" @@ -36,4 +37,6 @@ struct imagecapture_parallelimagecapture_obj { gpio_num_t vertical_sync; gpio_num_t horizontal_reference; uint8_t data_count; + mp_obj_t buffer1, buffer2; + uint8_t *buffer_to_give; }; diff --git a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c index 1a294f6886..280c87e234 100644 --- a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c @@ -137,7 +137,10 @@ bool common_hal_imagecapture_parallelimagecapture_deinited(imagecapture_parallel return common_hal_rp2pio_statemachine_deinited(&self->state_machine); } -void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize) { +void common_hal_imagecapture_parallelimagecapture_singleshot_capture(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_RW); + PIO pio = self->state_machine.pio; uint sm = self->state_machine.state_machine; uint8_t offset = rp2pio_statemachine_program_offset(&self->state_machine); @@ -149,7 +152,7 @@ void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_paralleli pio_sm_exec(pio, sm, pio_encode_jmp(offset)); pio_sm_set_enabled(pio, sm, true); - common_hal_rp2pio_statemachine_readinto(&self->state_machine, buffer, bufsize, 4); + common_hal_rp2pio_statemachine_readinto(&self->state_machine, bufinfo.buf, bufinfo.len, 4); pio_sm_set_enabled(pio, sm, false); } diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 7d2d128a73..bcbe6a9cfb 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -466,6 +466,7 @@ $(filter $(SRC_PATTERNS), \ digitalio/DriveMode.c \ digitalio/Pull.c \ fontio/Glyph.c \ + imagecapture/ParallelImageCapture.c \ math/__init__.c \ microcontroller/ResetReason.c \ microcontroller/RunMode.c \ @@ -535,6 +536,7 @@ SRC_SHARED_MODULE_ALL = \ gamepadshift/GamePadShift.c \ gamepadshift/__init__.c \ getpass/__init__.c \ + imagecapture/ParallelImageCapture.c \ ipaddress/IPv4Address.c \ ipaddress/__init__.c \ keypad/__init__.c \ diff --git a/shared-bindings/imagecapture/ParallelImageCapture.c b/shared-bindings/imagecapture/ParallelImageCapture.c index e999fba850..071501919f 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.c +++ b/shared-bindings/imagecapture/ParallelImageCapture.c @@ -25,6 +25,7 @@ */ #include "py/obj.h" +#include "py/objproperty.h" #include "py/runtime.h" #include "shared/runtime/context_manager_helpers.h" @@ -82,19 +83,61 @@ STATIC mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t * return self; } -//| def capture(self, buffer: WriteableBuffer, width: int, height: int, bpp: int=16) -> None: -//| """Capture a single frame into the given buffer""" +//| def capture(self, buffer: WriteableBuffer) -> WriteableBuffer: +//| """Capture a single frame into the given buffer. +//| +//| This will stop a continuous-mode capture, if one is in progress.""" //| ... //| STATIC mp_obj_t imagecapture_parallelimagecapture_capture(mp_obj_t self_in, mp_obj_t buffer) { imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_RW); - common_hal_imagecapture_parallelimagecapture_capture(self, bufinfo.buf, bufinfo.len); + common_hal_imagecapture_parallelimagecapture_singleshot_capture(self, buffer); + + return buffer; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(imagecapture_parallelimagecapture_capture_obj, imagecapture_parallelimagecapture_capture); + +//| def continuous_capture_start(self, buffer1: WriteableBuffer, buffer2: WriteableBuffer) -> None: +//| """Begin capturing into the given buffers in the background. +//| +//| Call `continuous_capture_get_frame` to get the next available +//| frame, and `continuous_capture_stop` to stop capturing.""" +//| ... +//| +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_start(mp_obj_t self_in, mp_obj_t buffer1, mp_obj_t buffer2) { + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; + common_hal_imagecapture_parallelimagecapture_continuous_capture_start(self, buffer1, buffer2); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(imagecapture_parallelimagecapture_capture_obj, imagecapture_parallelimagecapture_capture); +STATIC MP_DEFINE_CONST_FUN_OBJ_3(imagecapture_parallelimagecapture_continuous_capture_start_obj, imagecapture_parallelimagecapture_continuous_capture_start); + +//| def continuous_capture_get_frame(self) -> WritableBuffer: +//| """Return the next available frame, one of the two buffers passed to `continuous_capture_start`""" +//| ... +//| +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_get_frame(mp_obj_t self_in) { + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; + return common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(self); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_capture_get_frame_obj, imagecapture_parallelimagecapture_continuous_capture_get_frame); + + + +//| def continuous_capture_stop(self) -> None: +//| """Stop continuous capture""" +//| ... +//| +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_stop(mp_obj_t self_in) { + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; + common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_capture_stop_obj, imagecapture_parallelimagecapture_continuous_capture_stop); + + + //| def deinit(self) -> None: //| """Deinitialize this instance""" @@ -134,6 +177,9 @@ STATIC const mp_rom_map_elem_t imagecapture_parallelimagecapture_locals_dict_tab { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&imagecapture_parallelimagecapture___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_capture), MP_ROM_PTR(&imagecapture_parallelimagecapture_capture_obj) }, + { MP_ROM_QSTR(MP_QSTR_continuous_capture_start), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_start_obj) }, + { MP_ROM_QSTR(MP_QSTR_continuous_capture_stop), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_stop_obj) }, + { MP_ROM_QSTR(MP_QSTR_continuous_capture_get_frame), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_get_frame_obj) }, }; STATIC MP_DEFINE_CONST_DICT(imagecapture_parallelimagecapture_locals_dict, imagecapture_parallelimagecapture_locals_dict_table); diff --git a/shared-bindings/imagecapture/ParallelImageCapture.h b/shared-bindings/imagecapture/ParallelImageCapture.h index bcd827aa23..72ddc23f65 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.h +++ b/shared-bindings/imagecapture/ParallelImageCapture.h @@ -40,4 +40,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle const mcu_pin_obj_t *horizontal_sync); void common_hal_imagecapture_parallelimagecapture_deinit(imagecapture_parallelimagecapture_obj_t *self); bool common_hal_imagecapture_parallelimagecapture_deinited(imagecapture_parallelimagecapture_obj_t *self); -void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize); +void common_hal_imagecapture_parallelimagecapture_singleshot_capture(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer); +void common_hal_imagecapture_parallelimagecapture_continuous_capture_start(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer1, mp_obj_t buffer2); +void common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(imagecapture_parallelimagecapture_obj_t *self); +mp_obj_t common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(imagecapture_parallelimagecapture_obj_t *self); diff --git a/shared-module/imagecapture/ParallelImageCapture.c b/shared-module/imagecapture/ParallelImageCapture.c new file mode 100644 index 0000000000..346bc76479 --- /dev/null +++ b/shared-module/imagecapture/ParallelImageCapture.c @@ -0,0 +1,44 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/imagecapture/ParallelImageCapture.h" +#include "py/runtime.h" + +// If the continuous-capture mode isn't supported, then this default (weak) implementation will raise exceptions for you +__attribute__((weak)) +void common_hal_imagecapture_parallelimagecapture_continuous_capture_start(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer1, mp_obj_t buffer2) { + mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); +} + +__attribute__((weak)) +void common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(imagecapture_parallelimagecapture_obj_t *self) { + mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); +} + +__attribute__((weak)) +mp_obj_t common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(imagecapture_parallelimagecapture_obj_t *self) { + mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); +} From 0ac6adb460a93b8e8ca0eed8e43f7fe5cbccac8e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 3 Nov 2021 14:14:55 -0500 Subject: [PATCH 16/84] spelling --- shared-bindings/imagecapture/ParallelImageCapture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/imagecapture/ParallelImageCapture.c b/shared-bindings/imagecapture/ParallelImageCapture.c index 071501919f..6ab595eb5d 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.c +++ b/shared-bindings/imagecapture/ParallelImageCapture.c @@ -112,7 +112,7 @@ STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_start(mp_ob } STATIC MP_DEFINE_CONST_FUN_OBJ_3(imagecapture_parallelimagecapture_continuous_capture_start_obj, imagecapture_parallelimagecapture_continuous_capture_start); -//| def continuous_capture_get_frame(self) -> WritableBuffer: +//| def continuous_capture_get_frame(self) -> WriteableBuffer: //| """Return the next available frame, one of the two buffers passed to `continuous_capture_start`""" //| ... //| From 1e3215f4eeeabd56af336efd83126b08e61dff67 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 3 Nov 2021 16:29:05 -0500 Subject: [PATCH 17/84] Corrected number of serial bytes returned --- ports/mimxrt10xx/common-hal/busio/UART.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index 2a6a3110cb..16c4ba77e4 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -345,7 +345,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // if we timed out, stop the transfer if (self->rx_ongoing) { + uint32_t recvd = 0; + LPUART_TransferGetReceiveCount(self->uart, &self->handle, &recvd); LPUART_TransferAbortReceive(self->uart, &self->handle); + return recvd; } // No data left, we got it all @@ -355,7 +358,11 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // The only place we can reliably tell how many bytes have been received is from the current // wp in the handle (because the abort nukes rxDataSize, and reading it before abort is a race.) - return self->handle.rxData - data; + if (self->handle.rxData > data) { + return self->handle.rxData - data; + } else { + return len; + } } // Write characters. From d5f0323ff76030c052d89ef91fe75e1310610277 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 4 Nov 2021 09:10:11 +0530 Subject: [PATCH 18/84] increase wifi channel limit Co-authored-by: anecdata <16617689+anecdata@users.noreply.github.com> --- shared-bindings/wifi/Monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index 0ddc8db4fd..8f1c9e2d90 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -55,7 +55,7 @@ STATIC mp_obj_t wifi_monitor_make_new(const mp_obj_type_t *type, size_t n_args, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - if (args[ARG_channel].u_int < 0 || args[ARG_channel].u_int > 11) { + if (args[ARG_channel].u_int < 0 || args[ARG_channel].u_int > 13) { mp_raise_ValueError_varg(translate("%q out of bounds"), MP_QSTR_channel); } From b435e7b56a6a31900251a17f0bbe8a15d032fca0 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 4 Nov 2021 16:14:18 +0530 Subject: [PATCH 19/84] update wifi monitor - rename loss method to lost - add method to get queued packet count Co-authored-by: anecdata <16617689+anecdata@users.noreply.github.com> --- ports/espressif/common-hal/wifi/Monitor.c | 14 +++++--- ports/espressif/common-hal/wifi/Monitor.h | 2 +- shared-bindings/wifi/Monitor.c | 39 ++++++++++++++--------- shared-bindings/wifi/Monitor.h | 4 ++- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/ports/espressif/common-hal/wifi/Monitor.c b/ports/espressif/common-hal/wifi/Monitor.c index e6e7175c51..b0ce341d71 100644 --- a/ports/espressif/common-hal/wifi/Monitor.c +++ b/ports/espressif/common-hal/wifi/Monitor.c @@ -66,7 +66,7 @@ static void wifi_monitor_cb(void *recv_buf, wifi_promiscuous_pkt_type_t type) { if (self->queue) { // send packet if (xQueueSendFromISR(self->queue, &packet, NULL) != pdTRUE) { - self->loss++; + self->lost++; free(packet.payload); ESP_LOGE(TAG, "packet queue full"); } @@ -138,10 +138,14 @@ mp_obj_t common_hal_wifi_monitor_get_queue(wifi_monitor_obj_t *self) { return mp_obj_new_int_from_uint(self->queue_length); } -mp_obj_t common_hal_wifi_monitor_get_loss(wifi_monitor_obj_t *self) { - size_t loss = self->loss; - self->loss = 0; - return mp_obj_new_int_from_uint(loss); +mp_obj_t common_hal_wifi_monitor_get_lost(wifi_monitor_obj_t *self) { + size_t lost = self->lost; + self->lost = 0; + return mp_obj_new_int_from_uint(lost); +} + +mp_obj_t common_hal_wifi_monitor_get_queued(wifi_monitor_obj_t *self) { + return mp_obj_new_int_from_uint(uxQueueMessagesWaiting(self->queue)); } mp_obj_t common_hal_wifi_monitor_get_packet(wifi_monitor_obj_t *self) { diff --git a/ports/espressif/common-hal/wifi/Monitor.h b/ports/espressif/common-hal/wifi/Monitor.h index 84eca71a36..e4e50dddc1 100644 --- a/ports/espressif/common-hal/wifi/Monitor.h +++ b/ports/espressif/common-hal/wifi/Monitor.h @@ -33,7 +33,7 @@ typedef struct { mp_obj_base_t base; uint8_t channel; - size_t loss; + size_t lost; size_t queue_length; QueueHandle_t queue; } wifi_monitor_obj_t; diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index 8f1c9e2d90..a9998e7410 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -120,27 +120,35 @@ STATIC mp_obj_t wifi_monitor_obj_deinit(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_deinit_obj, wifi_monitor_obj_deinit); -STATIC void check_for_deinit(mp_obj_t self_in) { - if (common_hal_wifi_monitor_deinited()) { - raise_deinited_error(); - } -} - -//| def loss(self) -> int: +//| def lost(self) -> int: //| """Returns the packet loss count. The counter resets after each poll.""" //| ... //| -STATIC mp_obj_t wifi_monitor_obj_get_loss(mp_obj_t self_in) { - return common_hal_wifi_monitor_get_loss(self_in); +STATIC mp_obj_t wifi_monitor_obj_get_lost(mp_obj_t self_in) { + return common_hal_wifi_monitor_get_lost(self_in); } -MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_loss_obj, wifi_monitor_obj_get_loss); +MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_lost_obj, wifi_monitor_obj_get_lost); + +//| def queued(self) -> int: +//| """Returns the packet queued count.""" +//| ... +//| +STATIC mp_obj_t wifi_monitor_obj_get_queued(mp_obj_t self_in) { + if (common_hal_wifi_monitor_deinited()) { + return mp_obj_new_int_from_uint(0); + } + return common_hal_wifi_monitor_get_queued(self_in); +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_queued_obj, wifi_monitor_obj_get_queued); //| def packet(self) -> dict: //| """Returns the monitor packet.""" //| ... //| STATIC mp_obj_t wifi_monitor_obj_get_packet(mp_obj_t self_in) { - check_for_deinit(self_in); + if (common_hal_wifi_monitor_deinited()) { + raise_deinited_error(); + } return common_hal_wifi_monitor_get_packet(self_in); } MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_packet_obj, wifi_monitor_obj_get_packet); @@ -148,12 +156,13 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_packet_obj, wifi_monitor_obj_get_packet); STATIC const mp_rom_map_elem_t wifi_monitor_locals_dict_table[] = { // properties { MP_ROM_QSTR(MP_QSTR_channel), MP_ROM_PTR(&wifi_monitor_channel_obj) }, - { MP_ROM_QSTR(MP_QSTR_queue), MP_ROM_PTR(&wifi_monitor_queue_obj) }, + { MP_ROM_QSTR(MP_QSTR_queue), MP_ROM_PTR(&wifi_monitor_queue_obj) }, // functions - { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&wifi_monitor_deinit_obj) }, - { MP_ROM_QSTR(MP_QSTR_loss), MP_ROM_PTR(&wifi_monitor_loss_obj) }, - { MP_ROM_QSTR(MP_QSTR_packet), MP_ROM_PTR(&wifi_monitor_packet_obj) }, + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&wifi_monitor_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR_lost), MP_ROM_PTR(&wifi_monitor_lost_obj) }, + { MP_ROM_QSTR(MP_QSTR_queued), MP_ROM_PTR(&wifi_monitor_queued_obj) }, + { MP_ROM_QSTR(MP_QSTR_packet), MP_ROM_PTR(&wifi_monitor_packet_obj) }, }; STATIC MP_DEFINE_CONST_DICT(wifi_monitor_locals_dict, wifi_monitor_locals_dict_table); diff --git a/shared-bindings/wifi/Monitor.h b/shared-bindings/wifi/Monitor.h index b6b71c07a7..38c52a05e7 100644 --- a/shared-bindings/wifi/Monitor.h +++ b/shared-bindings/wifi/Monitor.h @@ -41,7 +41,9 @@ mp_obj_t common_hal_wifi_monitor_get_channel(wifi_monitor_obj_t *self); mp_obj_t common_hal_wifi_monitor_get_queue(wifi_monitor_obj_t *self); -mp_obj_t common_hal_wifi_monitor_get_loss(wifi_monitor_obj_t *self); +mp_obj_t common_hal_wifi_monitor_get_lost(wifi_monitor_obj_t *self); + +mp_obj_t common_hal_wifi_monitor_get_queued(wifi_monitor_obj_t *self); mp_obj_t common_hal_wifi_monitor_get_packet(wifi_monitor_obj_t *self); From f498cfa5387b10629be45954e35c332812b4911b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Nov 2021 08:39:26 -0500 Subject: [PATCH 20/84] clarify that ParallelImageCapture holds references to the buffers until capture_stop --- .../imagecapture/ParallelImageCapture.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/shared-bindings/imagecapture/ParallelImageCapture.c b/shared-bindings/imagecapture/ParallelImageCapture.c index 6ab595eb5d..a98c72e208 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.c +++ b/shared-bindings/imagecapture/ParallelImageCapture.c @@ -97,11 +97,15 @@ STATIC mp_obj_t imagecapture_parallelimagecapture_capture(mp_obj_t self_in, mp_o } STATIC MP_DEFINE_CONST_FUN_OBJ_2(imagecapture_parallelimagecapture_capture_obj, imagecapture_parallelimagecapture_capture); -//| def continuous_capture_start(self, buffer1: WriteableBuffer, buffer2: WriteableBuffer) -> None: +//| def continuous_capture_start(self, buffer1: WriteableBuffer, buffer2: WriteableBuffer, /) -> None: //| """Begin capturing into the given buffers in the background. //| //| Call `continuous_capture_get_frame` to get the next available -//| frame, and `continuous_capture_stop` to stop capturing.""" +//| frame, and `continuous_capture_stop` to stop capturing. +//| +//| Until `continuous_capture_stop` (or `deinit`) is called, the +//| `ParallelImageCapture` object keeps references to ``buffer1`` and +//| ``buffer2``, so the objects will not be garbage collected.""" //| ... //| STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_start(mp_obj_t self_in, mp_obj_t buffer1, mp_obj_t buffer2) { @@ -125,7 +129,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_ca //| def continuous_capture_stop(self) -> None: -//| """Stop continuous capture""" +//| """Stop continuous capture. +//| +//| Calling this method also causes the object to release its +//| references to the buffers passed to `continuous_capture_start`, +//| potentially allowing the objects to be garbage collected.""" //| ... //| STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_stop(mp_obj_t self_in) { From 7f9fa8c20163d93099d9396991083cd9fa94f354 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Thu, 4 Nov 2021 21:33:40 +0100 Subject: [PATCH 21/84] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 17 ++++++++++++++++- locale/cs.po | 17 ++++++++++++++++- locale/de_DE.po | 17 ++++++++++++++++- locale/el.po | 17 ++++++++++++++++- locale/en_GB.po | 17 ++++++++++++++++- locale/es.po | 17 ++++++++++++++++- locale/fil.po | 17 ++++++++++++++++- locale/fr.po | 17 ++++++++++++++++- locale/hi.po | 17 ++++++++++++++++- locale/it_IT.po | 17 ++++++++++++++++- locale/ja.po | 17 ++++++++++++++++- locale/ko.po | 17 ++++++++++++++++- locale/nl.po | 17 ++++++++++++++++- locale/pl.po | 17 ++++++++++++++++- locale/pt_BR.po | 17 ++++++++++++++++- locale/sv.po | 17 ++++++++++++++++- locale/zh_Latn_pinyin.po | 17 ++++++++++++++++- 17 files changed, 272 insertions(+), 17 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index de3ab8abc3..8df69bdff3 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -354,6 +354,7 @@ msgstr "pow() 3-arg tidak didukung" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -634,6 +635,10 @@ msgstr "Penyangga harus memiliki panjang setidaknya 1" msgid "Buffer too short by %d bytes" msgstr "Buffer terlalu pendek untuk %d byte" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1607,6 +1612,10 @@ msgstr "Tidak ada pin TX" msgid "No available clocks" msgstr "Tidak ada clocks yang tersedia" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Tidak ada koneksi: panjang tidak dapat ditentukan" @@ -1627,6 +1636,7 @@ msgstr "Tidak ada perangkat keras acak yang tersedia" msgid "No hardware support on clk pin" msgstr "Tidak ada dukungan perangkat keras pada pin clk" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1750,7 +1760,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1849,6 +1858,7 @@ msgstr "Periferal sedang digunakan" msgid "Permission denied" msgstr "Izin ditolak" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2209,6 +2219,10 @@ msgstr "Tingkat sampel dari sampel tidak cocok dengan mixer" msgid "The sample's signedness does not match the mixer's" msgstr "signedness dari sampel tidak cocok dengan mixer" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3917,6 +3931,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/cs.po b/locale/cs.po index 6ca4f3dc4b..1e351aa3ec 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -350,6 +350,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -628,6 +629,10 @@ msgstr "" msgid "Buffer too short by %d bytes" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1590,6 +1595,10 @@ msgstr "" msgid "No available clocks" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "" @@ -1610,6 +1619,7 @@ msgstr "" msgid "No hardware support on clk pin" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1730,7 +1740,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1825,6 +1834,7 @@ msgstr "" msgid "Permission denied" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2178,6 +2188,10 @@ msgstr "" msgid "The sample's signedness does not match the mixer's" msgstr "" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3883,6 +3897,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/de_DE.po b/locale/de_DE.po index ee8fa06cd7..0e66aa0f11 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -356,6 +356,7 @@ msgstr "3-arg pow() wird nicht unterstützt" msgid "64 bit types" msgstr "64 bit Typen" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -636,6 +637,10 @@ msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" msgid "Buffer too short by %d bytes" msgstr "Puffer um %d Bytes zu kurz" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1608,6 +1613,10 @@ msgstr "Kein TX Pin" msgid "No available clocks" msgstr "Keine Taktgeber verfügbar" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Keine Verbindung: Länge kann nicht bestimmt werden" @@ -1628,6 +1637,7 @@ msgstr "Kein hardware random verfügbar" msgid "No hardware support on clk pin" msgstr "Keine Hardwareunterstützung am clk Pin" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1752,7 +1762,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1849,6 +1858,7 @@ msgstr "" msgid "Permission denied" msgstr "Zugang verweigert" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2209,6 +2219,10 @@ msgid "The sample's signedness does not match the mixer's" msgstr "" "Die Art des Vorzeichens des Samples stimmt nicht mit dem des Mixers überein" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3946,6 +3960,7 @@ msgstr "pow() drittes Argument darf nicht 0 sein" msgid "pow() with 3 arguments requires integers" msgstr "pow() mit 3 Argumenten erfordert Integer" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/el.po b/locale/el.po index aa90435bd0..5772201fe4 100644 --- a/locale/el.po +++ b/locale/el.po @@ -347,6 +347,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -625,6 +626,10 @@ msgstr "" msgid "Buffer too short by %d bytes" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1587,6 +1592,10 @@ msgstr "" msgid "No available clocks" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "" @@ -1607,6 +1616,7 @@ msgstr "" msgid "No hardware support on clk pin" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1727,7 +1737,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1822,6 +1831,7 @@ msgstr "" msgid "Permission denied" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2175,6 +2185,10 @@ msgstr "" msgid "The sample's signedness does not match the mixer's" msgstr "" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3880,6 +3894,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/en_GB.po b/locale/en_GB.po index 48e25493cc..aac0bb6186 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -356,6 +356,7 @@ msgstr "3-arg pow() not supported" msgid "64 bit types" msgstr "64 bit types" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -636,6 +637,10 @@ msgstr "Buffer must be at least length 1" msgid "Buffer too short by %d bytes" msgstr "Buffer too short by %d bytes" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1602,6 +1607,10 @@ msgstr "No TX pin" msgid "No available clocks" msgstr "No available clocks" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "No connection: length cannot be determined" @@ -1622,6 +1631,7 @@ msgstr "No hardware random available" msgid "No hardware support on clk pin" msgstr "No hardware support on clk pin" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1744,7 +1754,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "Only connectable advertisements can be directed" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "Only edge detection is available on this hardware" @@ -1843,6 +1852,7 @@ msgstr "Peripheral in use" msgid "Permission denied" msgstr "Permission denied" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "Pin cannot wake from Deep Sleep" @@ -2206,6 +2216,10 @@ msgstr "The sample's sample rate does not match the mixer's" msgid "The sample's signedness does not match the mixer's" msgstr "The sample's signedness does not match the mixer's" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3917,6 +3931,7 @@ msgstr "pow() 3rd argument cannot be 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() with 3 arguments requires integers" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/es.po b/locale/es.po index 6875e827f3..68fa901f89 100644 --- a/locale/es.po +++ b/locale/es.po @@ -358,6 +358,7 @@ msgstr "pow() con 3 argumentos no soportado" msgid "64 bit types" msgstr "tipos de 64 bit" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -641,6 +642,10 @@ msgstr "Buffer debe ser de longitud 1 como minimo" msgid "Buffer too short by %d bytes" msgstr "Búffer muy corto por %d bytes" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1624,6 +1629,10 @@ msgstr "Sin pin TX" msgid "No available clocks" msgstr "Relojes no disponibles" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Sin conexión: no se puede determinar la longitud" @@ -1644,6 +1653,7 @@ msgstr "No hay hardware random disponible" msgid "No hardware support on clk pin" msgstr "Sin soporte de hardware en el pin clk" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1768,7 +1778,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "Solo se puede dirigir a los anuncios conectables" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "Este hardware solo tiene capacidad para detección de borde" @@ -1867,6 +1876,7 @@ msgstr "Periférico en uso" msgid "Permission denied" msgstr "Permiso denegado" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "El Pin no se puede despertar de un sueño profundo" @@ -2235,6 +2245,10 @@ msgstr "El sample rate del sample no iguala al del mixer" msgid "The sample's signedness does not match the mixer's" msgstr "El signo del sample no iguala al del mixer" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3963,6 +3977,7 @@ msgstr "el 3er argumento de pow() no puede ser 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() con 3 argumentos requiere enteros" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/fil.po b/locale/fil.po index 962c4c80c5..20f52780c1 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -351,6 +351,7 @@ msgstr "3-arg pow() hindi suportado" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -632,6 +633,10 @@ msgstr "Buffer dapat ay hindi baba sa 1 na haba" msgid "Buffer too short by %d bytes" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1602,6 +1607,10 @@ msgstr "Walang TX pin" msgid "No available clocks" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "" @@ -1622,6 +1631,7 @@ msgstr "Walang magagamit na hardware random" msgid "No hardware support on clk pin" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1745,7 +1755,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1841,6 +1850,7 @@ msgstr "" msgid "Permission denied" msgstr "Walang pahintulot" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2195,6 +2205,10 @@ msgstr "Ang sample rate ng sample ay hindi tugma sa mixer" msgid "The sample's signedness does not match the mixer's" msgstr "Ang signedness ng sample hindi tugma sa mixer" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3921,6 +3935,7 @@ msgstr "pow() 3rd argument ay hindi maaring 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() na may 3 argumento kailangan ng integers" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/fr.po b/locale/fr.po index ab25fea5be..ed03aff738 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -358,6 +358,7 @@ msgstr "pow() non supporté avec 3 paramètres" msgid "64 bit types" msgstr "types à 64 bit" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -642,6 +643,10 @@ msgstr "Le tampon doit être de longueur au moins 1" msgid "Buffer too short by %d bytes" msgstr "Tampon trop court de %d octets" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1632,6 +1637,10 @@ msgstr "Pas de broche TX" msgid "No available clocks" msgstr "Pas d'horloge disponible" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Pas de connexion : la longueur ne peut pas être déterminée" @@ -1652,6 +1661,7 @@ msgstr "Aucunes source de valeurs aléatoire matérielle disponible" msgid "No hardware support on clk pin" msgstr "Pas de support matériel sur la broche clk" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1776,7 +1786,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1877,6 +1886,7 @@ msgstr "Périphérique en utilisation" msgid "Permission denied" msgstr "Permission refusée" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2237,6 +2247,10 @@ msgstr "L'échantillonage de l'échantillon ne correspond pas à celui du mixer" msgid "The sample's signedness does not match the mixer's" msgstr "Le signe de l'échantillon ne correspond pas à celui du mixer" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3973,6 +3987,7 @@ msgstr "le 3e argument de pow() ne peut être 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() avec 3 arguments nécessite des entiers" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/hi.po b/locale/hi.po index d179941c2e..b585507a3b 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -347,6 +347,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -625,6 +626,10 @@ msgstr "" msgid "Buffer too short by %d bytes" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1587,6 +1592,10 @@ msgstr "" msgid "No available clocks" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "" @@ -1607,6 +1616,7 @@ msgstr "" msgid "No hardware support on clk pin" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1727,7 +1737,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1822,6 +1831,7 @@ msgstr "" msgid "Permission denied" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2175,6 +2185,10 @@ msgstr "" msgid "The sample's signedness does not match the mixer's" msgstr "" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3880,6 +3894,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/it_IT.po b/locale/it_IT.po index acc0ecbfaa..86fda99477 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -358,6 +358,7 @@ msgstr "pow() con tre argmomenti non supportata" msgid "64 bit types" msgstr "Tipo 64 bits" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -640,6 +641,10 @@ msgstr "Il buffer deve essere lungo almeno 1" msgid "Buffer too short by %d bytes" msgstr "Buffer troppo piccolo di %d bytes" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1613,6 +1618,10 @@ msgstr "Nessun pin TX" msgid "No available clocks" msgstr "Nessun orologio a disposizione" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "" @@ -1633,6 +1642,7 @@ msgstr "Nessun generatore hardware di numeri casuali disponibile" msgid "No hardware support on clk pin" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1757,7 +1767,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1857,6 +1866,7 @@ msgstr "" msgid "Permission denied" msgstr "Permesso negato" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2214,6 +2224,10 @@ msgstr "" msgid "The sample's signedness does not match the mixer's" msgstr "" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3943,6 +3957,7 @@ msgstr "il terzo argomento di pow() non può essere 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() con 3 argomenti richiede interi" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/ja.po b/locale/ja.po index 1906649af0..6e1f3454ae 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -352,6 +352,7 @@ msgstr "引数3つのpow()は非対応" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -632,6 +633,10 @@ msgstr "バッファ長は少なくとも1以上でなければなりません" msgid "Buffer too short by %d bytes" msgstr "バッファが %d バイト足りません" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1598,6 +1603,10 @@ msgstr "TXピンがありません" msgid "No available clocks" msgstr "利用できるクロックがありません" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "接続なし: 長さが決定できません" @@ -1618,6 +1627,7 @@ msgstr "利用可能なハードウェア乱数なし" msgid "No hardware support on clk pin" msgstr "clkピンにハードウェア対応がありません" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1740,7 +1750,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1836,6 +1845,7 @@ msgstr "" msgid "Permission denied" msgstr "パーミッション拒否" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2189,6 +2199,10 @@ msgstr "サンプルレートがサンプルとミキサーで一致しません msgid "The sample's signedness does not match the mixer's" msgstr "符号の有無がサンプルとミキサーで一致しません" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3902,6 +3916,7 @@ msgstr "pow()の3つ目の引数は0にできません" msgid "pow() with 3 arguments requires integers" msgstr "pow()の第3引数には整数が必要" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/ko.po b/locale/ko.po index fdb3dd08b1..ad4ee0a2e2 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -348,6 +348,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -628,6 +629,10 @@ msgstr "잘못된 크기의 버퍼. >1 여야합니다" msgid "Buffer too short by %d bytes" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1590,6 +1595,10 @@ msgstr "" msgid "No available clocks" msgstr "" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "" @@ -1610,6 +1619,7 @@ msgstr "" msgid "No hardware support on clk pin" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1730,7 +1740,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1825,6 +1834,7 @@ msgstr "" msgid "Permission denied" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2178,6 +2188,10 @@ msgstr "" msgid "The sample's signedness does not match the mixer's" msgstr "" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3884,6 +3898,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/nl.po b/locale/nl.po index 7dd3f70e6c..b513129c33 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -350,6 +350,7 @@ msgstr "3-arg pow() niet ondersteund" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -630,6 +631,10 @@ msgstr "Buffer moet op zijn minst lengte 1 zijn" msgid "Buffer too short by %d bytes" msgstr "Buffer is %d bytes te klein" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1599,6 +1604,10 @@ msgstr "Geen TX pin" msgid "No available clocks" msgstr "Geen klokken beschikbaar" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Geen verbinding: lengte kan niet worden bepaald" @@ -1619,6 +1628,7 @@ msgstr "Geen hardware random beschikbaar" msgid "No hardware support on clk pin" msgstr "Geen hardware ondersteuning beschikbaar op clk pin" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1743,7 +1753,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1843,6 +1852,7 @@ msgstr "" msgid "Permission denied" msgstr "Toegang geweigerd" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2201,6 +2211,10 @@ msgstr "De sample's sample rate komt niet overeen met die van de mixer" msgid "The sample's signedness does not match the mixer's" msgstr "De sample's signature komt niet overeen met die van de mixer" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3921,6 +3935,7 @@ msgstr "derde argument van pow() mag geen 0 zijn" msgid "pow() with 3 arguments requires integers" msgstr "pow() met 3 argumenten vereist integers" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/pl.po b/locale/pl.po index aec6c68841..b5124d367b 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -352,6 +352,7 @@ msgstr "3-argumentowy pow() jest niewspierany" msgid "64 bit types" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -632,6 +633,10 @@ msgstr "Bufor musi mieć długość 1 lub więcej" msgid "Buffer too short by %d bytes" msgstr "Bufor za krótki o %d bajtów" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1598,6 +1603,10 @@ msgstr "Brak nóżki TX" msgid "No available clocks" msgstr "Brak wolnych zegarów" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Brak połączenia: nie można ustalić długości" @@ -1618,6 +1627,7 @@ msgstr "Brak generatora liczb losowych" msgid "No hardware support on clk pin" msgstr "" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1738,7 +1748,6 @@ msgstr "Wspierane są tylko nieskompresowane pliki BMP: wielkość nagłówka %d msgid "Only connectable advertisements can be directed" msgstr "" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "" @@ -1833,6 +1842,7 @@ msgstr "" msgid "Permission denied" msgstr "Odmowa dostępu" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "" @@ -2186,6 +2196,10 @@ msgstr "Sample rate nie pasuje do miksera" msgid "The sample's signedness does not match the mixer's" msgstr "Znak nie pasuje do miksera" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3893,6 +3907,7 @@ msgstr "trzeci argument pow() nie może być 0" msgid "pow() with 3 arguments requires integers" msgstr "trzyargumentowe pow() wymaga liczb całkowitych" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 5fe47d0a2c..d059b2d80a 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -360,6 +360,7 @@ msgstr "3-arg pow() não compatível" msgid "64 bit types" msgstr "Tipos 64 bit" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -645,6 +646,10 @@ msgstr "O comprimento do buffer deve ter pelo menos 1" msgid "Buffer too short by %d bytes" msgstr "O buffer é muito curto em %d bytes" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1623,6 +1628,10 @@ msgstr "Nenhum pino TX" msgid "No available clocks" msgstr "Nenhum clock disponível" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Sem conexão: o comprimento não pode ser determinado" @@ -1643,6 +1652,7 @@ msgstr "Nenhum hardware aleatório está disponível" msgid "No hardware support on clk pin" msgstr "Sem suporte de hardware no pino de clock" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1768,7 +1778,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "Somente anúncios conectáveis podem ser direcionados" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "Apenas a detecção de borda está disponível neste hardware" @@ -1869,6 +1878,7 @@ msgstr "O periférico está em uso" msgid "Permission denied" msgstr "Permissão negada" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "O pinto não pode acordar do deep sleep" @@ -2240,6 +2250,10 @@ msgstr "A taxa de amostragem da amostra não coincide com a do mixer" msgid "The sample's signedness does not match the mixer's" msgstr "A amostragem \"signedness\" não coincide com a do mixer" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3983,6 +3997,7 @@ msgstr "O terceiro argumento pow() não pode ser 0" msgid "pow() with 3 arguments requires integers" msgstr "o pow() com 3 argumentos requer números inteiros" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/sv.po b/locale/sv.po index fdbcc586b4..0fe5dfeec4 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -355,6 +355,7 @@ msgstr "3-arguments pow() stöds inte" msgid "64 bit types" msgstr "64-bitars typer" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -635,6 +636,10 @@ msgstr "Bufferten måste ha minst längd 1" msgid "Buffer too short by %d bytes" msgstr "Buffert är %d bytes för kort" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1607,6 +1612,10 @@ msgstr "Ingen TX-pinne" msgid "No available clocks" msgstr "Inga tillgängliga klockor" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Ingen anslutning: längden kan inte bestämmas" @@ -1627,6 +1636,7 @@ msgstr "Ingen hårdvaru-random tillgänglig" msgid "No hardware support on clk pin" msgstr "Inget hårdvarustöd på clk-pinne" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1750,7 +1760,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "Endast anslutningsbara annonseringar kan dirigeras" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "Endast kantdetektering är tillgänglig för denna hårdvara" @@ -1849,6 +1858,7 @@ msgstr "Periferi i bruk" msgid "Permission denied" msgstr "Åtkomst nekad" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "Pinnen kan inte väcka från djup sömn" @@ -2215,6 +2225,10 @@ msgstr "Samplingens frekvens matchar inte mixerns" msgid "The sample's signedness does not match the mixer's" msgstr "Samplingens signerad/osignerad stämmer inte med mixern" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3941,6 +3955,7 @@ msgstr "pow() 3: e argument kan inte vara 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() med 3 argument kräver heltal" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 05b5641158..6c8e8bb4b7 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -357,6 +357,7 @@ msgstr "bù zhīchí 3-arg pow()" msgid "64 bit types" msgstr "64 wèi lèi xíng" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" @@ -637,6 +638,10 @@ msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" msgid "Buffer too short by %d bytes" msgstr "Huǎn chōng qū tài duǎn , àn %d zì jié" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -1610,6 +1615,10 @@ msgstr "Wèi zhǎodào TX yǐn jiǎo" msgid "No available clocks" msgstr "Méiyǒu kěyòng de shízhōng" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Wú liánjiē: Wúfǎ quèdìng chángdù" @@ -1630,6 +1639,7 @@ msgstr "Méiyǒu kěyòng de yìngjiàn suíjī" msgid "No hardware support on clk pin" msgstr "Shízhōng yǐn jiǎo wú yìngjiàn zhīchí" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" @@ -1753,7 +1763,6 @@ msgstr "" msgid "Only connectable advertisements can be directed" msgstr "zhǐ yǒu kě lián jiē de guǎng gào cái néng bèi yǐn dǎo" -#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Only edge detection is available on this hardware" msgstr "cǐ yìng jiàn shàng jǐn tí gòng biān yuán jiǎn cè" @@ -1851,6 +1860,7 @@ msgstr "shǐ yòng zhōng de wài shè" msgid "Permission denied" msgstr "Quánxiàn bèi jùjué" +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" msgstr "yǐn jiǎo wú fǎ cóng shēn dù shuì mián zhōng huàn xǐng" @@ -2216,6 +2226,10 @@ msgstr "Yàngběn de yàngběn sùdù yǔ hǔn yīn qì de xiāngchà bù pǐpè msgid "The sample's signedness does not match the mixer's" msgstr "Yàngběn de qiānmíng yǔ hǔn yīn qì de qiānmíng bù pǐpèi" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -3940,6 +3954,7 @@ msgstr "pow() 3 cān shǔ bùnéng wéi 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h From 115402f4b82ef914226b5fd471de0b0f96b7d81b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 4 Nov 2021 21:14:39 -0500 Subject: [PATCH 22/84] Ask readthedocs to use python3.9 for building --- .readthedocs.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 3f66351ce7..770888b79e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,6 +8,11 @@ version: 2 +build: + os: ubuntu-20.04 + tools: + python: "3.9" + submodules: include: - extmod/ulab @@ -16,6 +21,5 @@ formats: - pdf python: - version: 3 install: - requirements: docs/requirements.txt From 6d7e6dfabdfec0e21e4c5e040a536b60cbecea47 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Thu, 4 Nov 2021 21:09:13 +0000 Subject: [PATCH 23/84] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1010 of 1010 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index d059b2d80a..1f7f0c3eb9 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-10-23 07:37+0000\n" +"PO-Revision-Date: 2021-11-05 04:07+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -648,7 +648,7 @@ msgstr "O buffer é muito curto em %d bytes" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "Buffers must be same size" -msgstr "" +msgstr "Os buffers devem ter o mesmo tamanho" #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c @@ -1630,7 +1630,7 @@ msgstr "Nenhum clock disponível" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "No capture in progress" -msgstr "" +msgstr "Não há nenhuma captura em andamento" #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" @@ -2252,7 +2252,7 @@ msgstr "A amostragem \"signedness\" não coincide com a do mixer" #: shared-module/imagecapture/ParallelImageCapture.c msgid "This microcontroller does not support continuous capture." -msgstr "" +msgstr "Este microcontrolador não tem suporte para captura contínua." #: shared-module/paralleldisplay/ParallelBus.c msgid "" From 9db5d57e50d5d537bed357939fb7ef1f64b72b6c Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Thu, 4 Nov 2021 21:31:23 +0000 Subject: [PATCH 24/84] Translated using Weblate (Swedish) Currently translated at 100.0% (1010 of 1010 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 0fe5dfeec4..e13fb1c2fa 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-10-23 07:37+0000\n" +"PO-Revision-Date: 2021-11-05 04:07+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -638,7 +638,7 @@ msgstr "Buffert är %d bytes för kort" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "Buffers must be same size" -msgstr "" +msgstr "Buffertarna måste ha samma storlek" #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c @@ -1614,7 +1614,7 @@ msgstr "Inga tillgängliga klockor" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "No capture in progress" -msgstr "" +msgstr "Ingen insamling pågår" #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" @@ -2227,7 +2227,7 @@ msgstr "Samplingens signerad/osignerad stämmer inte med mixern" #: shared-module/imagecapture/ParallelImageCapture.c msgid "This microcontroller does not support continuous capture." -msgstr "" +msgstr "Den här mikrokontrollern stöder inte kontinuerlig insamling." #: shared-module/paralleldisplay/ParallelBus.c msgid "" From f7ba0d23de241fca052e0ddbc1c7891192fbd19c Mon Sep 17 00:00:00 2001 From: hexthat Date: Fri, 5 Nov 2021 00:19:06 +0000 Subject: [PATCH 25/84] Translated using Weblate (Chinese (Pinyin)) Currently translated at 100.0% (1010 of 1010 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 6c8e8bb4b7..15d0d303f6 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-10-31 11:37+0000\n" +"PO-Revision-Date: 2021-11-05 04:07+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -640,7 +640,7 @@ msgstr "Huǎn chōng qū tài duǎn , àn %d zì jié" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "Buffers must be same size" -msgstr "" +msgstr "huǎn chōng qì bì xū dà xiǎo xiāng tóng" #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c @@ -1617,7 +1617,7 @@ msgstr "Méiyǒu kěyòng de shízhōng" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "No capture in progress" -msgstr "" +msgstr "zhèng zài jìn xíng zhōng de wèi bǔ huò" #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" @@ -2228,7 +2228,7 @@ msgstr "Yàngběn de qiānmíng yǔ hǔn yīn qì de qiānmíng bù pǐpèi" #: shared-module/imagecapture/ParallelImageCapture.c msgid "This microcontroller does not support continuous capture." -msgstr "" +msgstr "cǐ wēi kòng zhì qì bù zhī chí lián xù bǔ huò." #: shared-module/paralleldisplay/ParallelBus.c msgid "" From 2ec2761ce04df4a607a04dd375abf1db82e2fe8f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 3 Nov 2021 08:35:50 -0500 Subject: [PATCH 26/84] bitmaptools: add alphablend This blends two "565"-format bitmaps, including byteswapped ones. All the bitmaps have to have the same memory format. The routine takes about 63ms on a Kaluga when operating on 320x240 bitmaps. Of course, displaying the bitmap also takes time. There's untested code for the L8 (8-bit greyscale) case. This can be enabled once gifio is merged. --- locale/circuitpython.pot | 16 +++++ shared-bindings/bitmaptools/__init__.c | 86 +++++++++++++++++++++++++- shared-bindings/bitmaptools/__init__.h | 3 + shared-module/bitmaptools/__init__.c | 64 +++++++++++++++++++ 4 files changed, 166 insertions(+), 3 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 1d7fc6854d..b4bcf35427 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -552,6 +552,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1071,6 +1075,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "" @@ -2390,6 +2402,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "" diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index ad814e8881..2c853ccb2a 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -244,6 +244,85 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom); // requires at least 2 arguments (destination bitmap and source bitmap) +//| +//| def alphablend(dest_bitmap, source_bitmap_1, source_bitmap_2, colorspace: displayio.Colorspace, factor1: float=.5, factor2: float=None): +//| """Alpha blend the two source bitmaps into the destination. +//| +//| It is permitted for the destination bitmap to be one of the two +//| source bitmaps. +//| +//| :param bitmap dest_bitmap: Destination bitmap that will be written into +//| :param bitmap source_bitmap_1: The first source bitmap +//| :param bitmap source_bitmap_2: The second source bitmap +//| :param float factor1: The proportion of bitmap 1 to mix in +//| :param float factor2: The proportion of bitmap 2 to mix in. If specified as `None`, ``1-factor1`` is used. Usually the proportions should sum to 1. +//| :param displayio.Colorspace colorspace: The colorspace of the bitmaps. They must all have the same colorspace. Only the following colorspaces are permitted: ``L8``, ``RGB565``, ``RGB565_SWAPPED``, ``BGR565`` and ``BGR565_SWAPPED``. +//| +//| For the L8 colorspace, the bitmaps must have a bits-per-value of 8. +//| For the RGB colorspaces, they must have a bits-per-value of 16.""" +//| + +STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum {ARG_dest_bitmap, ARG_source_bitmap_1, ARG_source_bitmap_2, ARG_colorspace, ARG_factor_1, ARG_factor_2}; + + static const mp_arg_t allowed_args[] = { + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, + {MP_QSTR_source_bitmap_1, MP_ARG_REQUIRED | MP_ARG_OBJ}, + {MP_QSTR_source_bitmap_2, MP_ARG_REQUIRED | MP_ARG_OBJ}, + {MP_QSTR_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ}, + {MP_QSTR_factor_1, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE}}, + {MP_QSTR_factor_2, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE}}, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + displayio_bitmap_t *destination = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_dest_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_dest_bitmap)); // the destination bitmap + displayio_bitmap_t *source1 = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_source_bitmap_1].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap_1)); // the first source bitmap + displayio_bitmap_t *source2 = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_source_bitmap_2].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap_2)); // the second source bitmap + + float factor1 = (args[ARG_factor_1].u_obj == mp_const_none) ? .5f : mp_obj_float_get(args[ARG_factor_1].u_obj); + float factor2 = (args[ARG_factor_2].u_obj == mp_const_none) ? 1 - factor1 : mp_obj_float_get(args[ARG_factor_2].u_obj); + + displayio_colorspace_t colorspace = (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_colorspace].u_obj); + + if (destination->width != source1->width + || destination->height != source1->height + || destination->bits_per_value != source1->bits_per_value + || destination->width != source2->width + || destination->height != source2->height + || destination->bits_per_value != source2->bits_per_value + ) { + mp_raise_ValueError(translate("Bitmap size and bits per value must match")); + } + + switch (colorspace) { + #if 0 + case DISPLAYIO_COLORSPACE_L8: + if (destination->bits_per_value != 8) { + mp_raise_ValueError(translate("For L8 colorspace, input bitmap must have 8 bits per pixel")); + } + break; + #endif + + case DISPLAYIO_COLORSPACE_RGB565: + case DISPLAYIO_COLORSPACE_RGB565_SWAPPED: + case DISPLAYIO_COLORSPACE_BGR565: + case DISPLAYIO_COLORSPACE_BGR565_SWAPPED: + if (destination->bits_per_value != 16) { + mp_raise_ValueError(translate("For RGB colorspaces, input bitmap must have 16 bits per pixel")); + } + break; + + default: + mp_raise_ValueError(translate("Unsupported colorspace")); + } + + common_hal_bitmaptools_alphablend(destination, source1, source2, colorspace, factor1, factor2); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_alphablend_obj, 0, bitmaptools_alphablend); + //| //| def fill_region( //| dest_bitmap: displayio.Bitmap, @@ -276,7 +355,7 @@ STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_a mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - displayio_bitmap_t *destination = MP_OBJ_TO_PTR(args[ARG_dest_bitmap].u_obj); // the destination bitmap + displayio_bitmap_t *destination = MP_OBJ_TO_PTR(args[ARG_dest_bitmap].u_obj); // the destination bitmap uint32_t value, color_depth; value = args[ARG_value].u_int; @@ -327,7 +406,7 @@ STATIC mp_obj_t bitmaptools_obj_boundary_fill(size_t n_args, const mp_obj_t *pos mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - displayio_bitmap_t *destination = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_dest_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_dest_bitmap)); // the destination bitmap + displayio_bitmap_t *destination = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_dest_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_dest_bitmap)); // the destination bitmap uint32_t fill_color_value, color_depth; fill_color_value = args[ARG_fill_color_value].u_int; @@ -391,7 +470,7 @@ STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_arg mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - displayio_bitmap_t *destination = MP_OBJ_TO_PTR(args[ARG_dest_bitmap].u_obj); // the destination bitmap + displayio_bitmap_t *destination = MP_OBJ_TO_PTR(args[ARG_dest_bitmap].u_obj); // the destination bitmap uint32_t value, color_depth; value = args[ARG_value].u_int; @@ -573,6 +652,7 @@ STATIC const mp_rom_map_elem_t bitmaptools_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&bitmaptools_readinto_obj) }, { MP_ROM_QSTR(MP_QSTR_rotozoom), MP_ROM_PTR(&bitmaptools_rotozoom_obj) }, { MP_ROM_QSTR(MP_QSTR_arrayblit), MP_ROM_PTR(&bitmaptools_arrayblit_obj) }, + { MP_ROM_QSTR(MP_QSTR_alphablend), MP_ROM_PTR(&bitmaptools_alphablend_obj) }, { MP_ROM_QSTR(MP_QSTR_fill_region), MP_ROM_PTR(&bitmaptools_fill_region_obj) }, { MP_ROM_QSTR(MP_QSTR_boundary_fill), MP_ROM_PTR(&bitmaptools_boundary_fill_obj) }, { MP_ROM_QSTR(MP_QSTR_draw_line), MP_ROM_PTR(&bitmaptools_draw_line_obj) }, diff --git a/shared-bindings/bitmaptools/__init__.h b/shared-bindings/bitmaptools/__init__.h index 6415b20258..31f0a1078c 100644 --- a/shared-bindings/bitmaptools/__init__.h +++ b/shared-bindings/bitmaptools/__init__.h @@ -28,6 +28,7 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H #include "shared-module/displayio/Bitmap.h" +#include "shared-bindings/displayio/__init__.h" #include "py/obj.h" #include "extmod/vfs_fat.h" @@ -58,4 +59,6 @@ void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination, void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_word, bool swap_bytes, bool reverse_rows); void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int element_size, int x1, int y1, int x2, int y2, bool skip_specified, uint32_t skip_index); +void common_hal_bitmaptools_alphablend(displayio_bitmap_t *destination, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, float factor1, float factor2); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index b6e0764fdb..ed186c2c1b 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -602,3 +602,67 @@ void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *f } } } + +void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, float factor1, float factor2) { + displayio_area_t a = {0, 0, dest->width, dest->height}; + displayio_bitmap_set_dirty_area(dest, &a); + + int ifactor1 = (int)(factor1 * 256); + int ifactor2 = (int)(factor2 * 256); + + #if 0 + if (colorspace == DISPLAYIO_COLORSPACE_L8) { + for (int y = 0; y < dest->height; y++) { + uint8_t *dptr = (uint8_t *)(dest->data + y * dest->stride); + uint8_t *sptr1 = (uint8_t *)(source1->data + y * source1->stride); + uint8_t *sptr2 = (uint8_t *)(source2->data + y * source2->stride); + for (int x = 0; x < dest->width; x++) { + // This is round(l1*f1 + l2*f2) & clip to range in fixed-point + int pixel = (*sptr1++ *ifactor1 + *sptr2++ *ifactor2 + 128) / 256; + *dptr++ = MIN(255, MAX(0, pixel)); + } + } + } else + #endif + { + bool swap = (colorspace == DISPLAYIO_COLORSPACE_RGB565_SWAPPED) || (colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED); + for (int y = 0; y < dest->height; y++) { + uint16_t *dptr = (uint16_t *)(dest->data + y * dest->stride); + uint16_t *sptr1 = (uint16_t *)(source1->data + y * source1->stride); + uint16_t *sptr2 = (uint16_t *)(source2->data + y * source2->stride); + for (int x = 0; x < dest->width; x++) { + int spix1 = *sptr1++; + int spix2 = *sptr2++; + + if (swap) { + spix1 = __builtin_bswap16(spix1); + spix2 = __builtin_bswap16(spix2); + } + const int r_mask = 0xf800; // (or b mask, if BGR) + const int g_mask = 0x07e0; + const int b_mask = 0x001f; // (or r mask, if BGR) + + // This is round(r1*f1 + r2*f2) & clip to range in fixed-point + // but avoiding shifting it down to start at bit 0 + int r = ((spix1 & r_mask) * ifactor1 + + (spix2 & r_mask) * ifactor2 + r_mask / 2) / 256; + r = MIN(r_mask, MAX(0, r)) & r_mask; + + // ditto + int g = ((spix1 & g_mask) * ifactor1 + + (spix2 & g_mask) * ifactor2 + g_mask / 2) / 256; + g = MIN(g_mask, MAX(0, g)) & g_mask; + + int b = ((spix1 & b_mask) * ifactor1 + + (spix2 & b_mask) * ifactor2 + b_mask / 2) / 256; + b = MIN(b_mask, MAX(0, b)) & b_mask; + + uint16_t pixel = r | g | b; + if (swap) { + pixel = __builtin_bswap16(pixel); + } + *dptr++ = pixel; + } + } + } +} From 4ed1249927ec1c5d24f492e24395be6c4f846d8a Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Fri, 5 Nov 2021 16:24:32 +0100 Subject: [PATCH 27/84] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 11 ++++++++--- locale/cs.po | 11 ++++++++--- locale/de_DE.po | 11 ++++++++--- locale/el.po | 11 ++++++++--- locale/en_GB.po | 16 ++++++++++++---- locale/es.po | 16 ++++++++++++---- locale/fil.po | 11 ++++++++--- locale/fr.po | 11 ++++++++--- locale/hi.po | 11 ++++++++--- locale/it_IT.po | 11 ++++++++--- locale/ja.po | 11 ++++++++--- locale/ko.po | 11 ++++++++--- locale/nl.po | 11 ++++++++--- locale/pl.po | 11 ++++++++--- locale/pt_BR.po | 16 ++++++++++++---- locale/sv.po | 16 ++++++++++++---- locale/zh_Latn_pinyin.po | 16 ++++++++++++---- 17 files changed, 156 insertions(+), 56 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 8df69bdff3..b4daf25377 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -111,11 +111,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3123,6 +3123,7 @@ msgstr "argumen posisi ekstra telah diberikan" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4382,6 +4383,10 @@ msgstr "" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/cs.po b/locale/cs.po index 1e351aa3ec..e74c2df01d 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -107,11 +107,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3090,6 +3090,7 @@ msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4348,6 +4349,10 @@ msgstr "" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/de_DE.po b/locale/de_DE.po index 0e66aa0f11..c18d04a79d 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -112,11 +112,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3141,6 +3141,7 @@ msgstr "Es wurden zusätzliche Argumente ohne Schlüsselwort angegeben" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein" @@ -4416,6 +4417,10 @@ msgstr "nicht unterstützter Thumb-Befehl '%s' mit %d Argumenten" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "nicht unterstützte Xtensa-Anweisung '%s' mit %d Argumenten" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/el.po b/locale/el.po index 5772201fe4..c32bd93adc 100644 --- a/locale/el.po +++ b/locale/el.po @@ -104,11 +104,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3087,6 +3087,7 @@ msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4345,6 +4346,10 @@ msgstr "" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/en_GB.po b/locale/en_GB.po index aac0bb6186..abe6762e2d 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -112,14 +112,14 @@ msgstr "%q length must be %d-%d" msgid "%q length must be >= 1" msgstr "%q length must be >= 1" -#: py/argcheck.c -msgid "%q must <= %d" -msgstr "%q must <= %d" - #: py/argcheck.c msgid "%q must be %d-%d" msgstr "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" +msgstr "" + #: py/argcheck.c msgid "%q must be >= %d" msgstr "%q must be >= %d" @@ -3124,6 +3124,7 @@ msgstr "extra positional arguments given" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "file must be a file opened in byte mode" @@ -4384,6 +4385,10 @@ msgstr "unsupported Thumb instruction '%s' with %d arguments" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "unsupported Xtensa instruction '%s' with %d arguments" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" @@ -4495,6 +4500,9 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "%q must <= %d" +#~ msgstr "%q must <= %d" + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/es.po b/locale/es.po index 68fa901f89..498144d4f7 100644 --- a/locale/es.po +++ b/locale/es.po @@ -114,14 +114,14 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: py/argcheck.c -msgid "%q must <= %d" -msgstr "%q debe ser <= %d" - #: py/argcheck.c msgid "%q must be %d-%d" msgstr "%q debe ser %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" +msgstr "" + #: py/argcheck.c msgid "%q must be >= %d" msgstr "%q debe ser >= %d" @@ -3163,6 +3163,7 @@ msgstr "argumento posicional adicional dado" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "el archivo deberia ser una archivo abierto en modo byte" @@ -4431,6 +4432,10 @@ msgstr "instrucción de tipo Thumb no admitida '%s' con %d argumentos" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "instrucción Xtensa '%s' con %d argumentos no soportada" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" @@ -4542,6 +4547,9 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "%q must <= %d" +#~ msgstr "%q debe ser <= %d" + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/fil.po b/locale/fil.po index 20f52780c1..3912d17949 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -105,11 +105,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3121,6 +3121,7 @@ msgstr "dagdag na positional argument na ibinigay" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "file ay dapat buksan sa byte mode" @@ -4390,6 +4391,10 @@ msgstr "hindi sinusuportahan ang thumb instruktion '%s' sa %d argumento" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "hindi sinusuportahan ang instruction ng Xtensa '%s' sa %d argumento" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/fr.po b/locale/fr.po index ed03aff738..553a0a1d0b 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -115,11 +115,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3170,6 +3170,7 @@ msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "le fichier doit être un fichier ouvert en mode 'byte'" @@ -4441,6 +4442,10 @@ msgstr "instruction Thumb '%s' non supportée avec %d paramètres" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "instruction Xtensa '%s' non supportée avec %d paramètres" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/hi.po b/locale/hi.po index b585507a3b..ca925a4a4c 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -104,11 +104,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3087,6 +3087,7 @@ msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4345,6 +4346,10 @@ msgstr "" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/it_IT.po b/locale/it_IT.po index 86fda99477..994e262359 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -113,11 +113,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3138,6 +3138,7 @@ msgstr "argomenti posizonali extra dati" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4412,6 +4413,10 @@ msgstr "istruzione '%s' Xtensa non supportata con %d argomenti" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "istruzione '%s' Xtensa non supportata con %d argomenti" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/ja.po b/locale/ja.po index 6e1f3454ae..254cce04ed 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -109,11 +109,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3106,6 +3106,7 @@ msgstr "余分な位置引数が与えられました" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "fileはバイトモードで開かれたファイルでなければなりません" @@ -4368,6 +4369,10 @@ msgstr "" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/ko.po b/locale/ko.po index ad4ee0a2e2..6f90d39388 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -105,11 +105,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3091,6 +3091,7 @@ msgstr "" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "" @@ -4349,6 +4350,10 @@ msgstr "" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/nl.po b/locale/nl.po index b513129c33..c3e81ff8d4 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -107,11 +107,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3123,6 +3123,7 @@ msgstr "extra positionele argumenten gegeven" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "bestand moet een bestand zijn geopend in byte modus" @@ -4388,6 +4389,10 @@ msgstr "niet ondersteunde Thumb instructie '%s' met %d argumenten" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "niet ondersteunde Xtensa instructie '%s' met %d argumenten" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/pl.po b/locale/pl.po index b5124d367b..d29e59a939 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -109,11 +109,11 @@ msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c -msgid "%q must <= %d" +msgid "%q must be %d-%d" msgstr "" -#: py/argcheck.c -msgid "%q must be %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" msgstr "" #: py/argcheck.c @@ -3099,6 +3099,7 @@ msgstr "nadmiarowe argumenty pozycyjne" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "file musi być otwarte w trybie bajtowym" @@ -4359,6 +4360,10 @@ msgstr "zła instrukcja Thumb '%s' z %d argumentami" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "zła instrukcja Xtensa '%s' z %d argumentami" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 1f7f0c3eb9..147fd6a8e6 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -112,14 +112,14 @@ msgstr "o comprimento %q deve ser %d-%d" msgid "%q length must be >= 1" msgstr "o comprimento %q deve ser >=1" -#: py/argcheck.c -msgid "%q must <= %d" -msgstr "o %q deve ser <= %d" - #: py/argcheck.c msgid "%q must be %d-%d" msgstr "o %q deve ser %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" +msgstr "" + #: py/argcheck.c msgid "%q must be >= %d" msgstr "o %q deve ser >= %d" @@ -3179,6 +3179,7 @@ msgstr "argumentos extra posicionais passados" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "o arquivo deve ser um arquivo aberto no modo byte" @@ -4450,6 +4451,10 @@ msgstr "instrução Thumb '%s' não compatível com argumentos %d" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "instrução Xtensa '%s' não compatível com argumentos %d" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" @@ -4561,6 +4566,9 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "%q must <= %d" +#~ msgstr "o %q deve ser <= %d" + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/sv.po b/locale/sv.po index e13fb1c2fa..42a79a01ea 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -111,14 +111,14 @@ msgstr "längden på %q måste vara %d-%d" msgid "%q length must be >= 1" msgstr "längden på %q måste vara >= 1" -#: py/argcheck.c -msgid "%q must <= %d" -msgstr "%q måste vara <=%d" - #: py/argcheck.c msgid "%q must be %d-%d" msgstr "%q måste vara %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" +msgstr "" + #: py/argcheck.c msgid "%q must be >= %d" msgstr "%q måste vara >= %d" @@ -3144,6 +3144,7 @@ msgstr "extra positions-argument angivna" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "filen måste vara en fil som öppnats i byte-läge" @@ -4408,6 +4409,10 @@ msgstr "Thumb-instruktion '%s' med %d argument stöd inte" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "Xtensa-instruktion '%s' med %d argument stöds inte" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" @@ -4519,6 +4524,9 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "%q must <= %d" +#~ msgstr "%q måste vara <=%d" + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 15d0d303f6..e221a2c131 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -113,14 +113,14 @@ msgstr "%q cháng dù bì xū wéi %d-%d" msgid "%q length must be >= 1" msgstr "%q cháng dù bì xū >= 1" -#: py/argcheck.c -msgid "%q must <= %d" -msgstr "%q bì xū <= %d" - #: py/argcheck.c msgid "%q must be %d-%d" msgstr "%q bì xū wéi %d-%d" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" +msgstr "" + #: py/argcheck.c msgid "%q must be >= %d" msgstr "%q bì xū >= %d" @@ -3146,6 +3146,7 @@ msgstr "gěi chūle éwài de wèizhì cānshù" #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c msgid "file must be a file opened in byte mode" msgstr "wénjiàn bìxū shì zài zì jié móshì xià dǎkāi de wénjiàn" @@ -4407,6 +4408,10 @@ msgstr "bù zhīchí de Thumb zhǐshì '%s', shǐyòng %d cānshù" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "bù zhīchí de Xtensa zhǐlìng '%s', shǐyòng %d cānshù" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" @@ -4518,6 +4523,9 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "%q must <= %d" +#~ msgstr "%q bì xū <= %d" + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" From d532ad388be447855a9a2e0cc7a3dc8769111e67 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 Nov 2021 11:23:27 -0500 Subject: [PATCH 28/84] disable framebufferio so bitmaptools can fit --- ports/atmel-samd/boards/pybadge/mpconfigboard.mk | 1 + ports/atmel-samd/boards/pygamer/mpconfigboard.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk index b5fda72f90..fa1266834d 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk @@ -11,6 +11,7 @@ EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ CIRCUITPY_AESIO = 0 +CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk index 5b5a84bb78..c1a33807c8 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk @@ -11,6 +11,7 @@ EXTERNAL_FLASH_DEVICES = GD25Q64C LONGINT_IMPL = MPZ CIRCUITPY_AESIO = 0 +CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_GAMEPADSHIFT = 1 CIRCUITPY_STAGE = 1 From dfafab675f74d083e4a8885dba1a1e28cd519504 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 Nov 2021 11:26:07 -0500 Subject: [PATCH 29/84] Enable L8 mode for alphablend --- shared-bindings/bitmaptools/__init__.c | 2 -- shared-module/bitmaptools/__init__.c | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 2c853ccb2a..76842e9c59 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -296,13 +296,11 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, } switch (colorspace) { - #if 0 case DISPLAYIO_COLORSPACE_L8: if (destination->bits_per_value != 8) { mp_raise_ValueError(translate("For L8 colorspace, input bitmap must have 8 bits per pixel")); } break; - #endif case DISPLAYIO_COLORSPACE_RGB565: case DISPLAYIO_COLORSPACE_RGB565_SWAPPED: diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index ed186c2c1b..7d024c2290 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -610,7 +610,6 @@ void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitma int ifactor1 = (int)(factor1 * 256); int ifactor2 = (int)(factor2 * 256); - #if 0 if (colorspace == DISPLAYIO_COLORSPACE_L8) { for (int y = 0; y < dest->height; y++) { uint8_t *dptr = (uint8_t *)(dest->data + y * dest->stride); @@ -622,9 +621,7 @@ void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitma *dptr++ = MIN(255, MAX(0, pixel)); } } - } else - #endif - { + } else { bool swap = (colorspace == DISPLAYIO_COLORSPACE_RGB565_SWAPPED) || (colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED); for (int y = 0; y < dest->height; y++) { uint16_t *dptr = (uint16_t *)(dest->data + y * dest->stride); From 43b593725ba5b7ccb6601ac1a03091c230242198 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 Nov 2021 11:38:48 -0500 Subject: [PATCH 30/84] atmel-samd: Fix converting watchdog seconds to cycles It's intended that the actual timeout always be at least the requested timeout. However, due to multiplying by the wrong factor to get from seconds to cycles, a timeout request of e.g., 8.1s (which is less than 8.192s) would give an actual timeout of 8, not 16 as it should. --- ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c index 29ac643d1c..329242887c 100644 --- a/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c +++ b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c @@ -70,7 +70,7 @@ void setup_wdt(watchdog_watchdogtimer_obj_t *self, int setting) { } void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_float_t new_timeout) { - int wdt_cycles = (int)(new_timeout * 1000); + int wdt_cycles = (int)(new_timeout * 1024); if (wdt_cycles < 8) { wdt_cycles = 8; } From 02573676e7c1de1f977159b5a04e14a6134fc1b8 Mon Sep 17 00:00:00 2001 From: lady ada Date: Fri, 5 Nov 2021 12:43:44 -0400 Subject: [PATCH 31/84] add KB2040 and fix Trinkey QT2040 pid --- .../boards/adafruit_kb2040/board.c | 43 ++++++++++++++++++ .../boards/adafruit_kb2040/mpconfigboard.h | 10 +++++ .../boards/adafruit_kb2040/mpconfigboard.mk | 9 ++++ .../adafruit_kb2040/pico-sdk-configboard.h | 4 ++ .../raspberrypi/boards/adafruit_kb2040/pins.c | 45 +++++++++++++++++++ .../adafruit_qt2040_trinkey/mpconfigboard.mk | 2 +- 6 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 ports/raspberrypi/boards/adafruit_kb2040/board.c create mode 100644 ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h create mode 100644 ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.mk create mode 100644 ports/raspberrypi/boards/adafruit_kb2040/pico-sdk-configboard.h create mode 100644 ports/raspberrypi/boards/adafruit_kb2040/pins.c diff --git a/ports/raspberrypi/boards/adafruit_kb2040/board.c b/ports/raspberrypi/boards/adafruit_kb2040/board.c new file mode 100644 index 0000000000..eac54ce460 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/board.c @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +#include "shared-bindings/microcontroller/Pin.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h new file mode 100644 index 0000000000..c01f713e48 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h @@ -0,0 +1,10 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit KB2040" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO17) + +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO12) +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO13) + +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) diff --git a/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.mk new file mode 100644 index 0000000000..f9e1e2cf15 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x239A +USB_PID = 0x8106 +USB_PRODUCT = "KB2040" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_kb2040/pico-sdk-configboard.h b/ports/raspberrypi/boards/adafruit_kb2040/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/adafruit_kb2040/pins.c b/ports/raspberrypi/boards/adafruit_kb2040/pins.c new file mode 100644 index 0000000000..0bd2dda728 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/pins.c @@ -0,0 +1,45 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/mpconfigboard.mk index da4706a177..5f07632b4f 100644 --- a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/mpconfigboard.mk +++ b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x8106 +USB_PID = 0x810A USB_PRODUCT = "QT2040 Trinkey" USB_MANUFACTURER = "Adafruit" From a555475e658afb3c2f3ef8e2506e395fdafb8001 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Fri, 5 Nov 2021 17:53:36 +0000 Subject: [PATCH 32/84] Translated using Weblate (Swedish) Currently translated at 100.0% (1011 of 1011 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 42a79a01ea..28635a1dfa 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-05 04:07+0000\n" +"PO-Revision-Date: 2021-11-05 18:37+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -117,7 +117,7 @@ msgstr "%q måste vara %d-%d" #: py/argcheck.c shared-bindings/gifio/GifWriter.c msgid "%q must be <= %d" -msgstr "" +msgstr "%q måste vara <= %d" #: py/argcheck.c msgid "%q must be >= %d" @@ -4411,7 +4411,7 @@ msgstr "Xtensa-instruktion '%s' med %d argument stöds inte" #: shared-module/gifio/GifWriter.c msgid "unsupported colorspace for GifWriter" -msgstr "" +msgstr "färgrymd stöds inte för GifWriter" #: py/objstr.c #, c-format From 4f62b540a273282f7824405b958de820fc265a01 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 Nov 2021 15:18:41 -0500 Subject: [PATCH 33/84] Disable bitmaptools on thunderpack_v11 --- ports/stm/boards/thunderpack_v11/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/stm/boards/thunderpack_v11/mpconfigboard.mk b/ports/stm/boards/thunderpack_v11/mpconfigboard.mk index 9aa50c0225..5b5c098e16 100644 --- a/ports/stm/boards/thunderpack_v11/mpconfigboard.mk +++ b/ports/stm/boards/thunderpack_v11/mpconfigboard.mk @@ -17,6 +17,7 @@ LD_COMMON = boards/common_nvm.ld LD_FILE = boards/STM32F411_nvm.ld CIRCUITPY_AESIO = 0 +CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_VECTORIO = 0 CIRCUITPY_ULAB = 0 From 6790f95953089fc7ea630160dab4d08547c8bb69 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 5 Nov 2021 15:19:01 -0500 Subject: [PATCH 34/84] Fix disabling of FRAMEBUFFERIO on atmel-samd .. this needs to imply the disabling of RGBMATRIX too --- ports/atmel-samd/mpconfigport.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 1652032311..dcbac19711 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -103,8 +103,8 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 CIRCUITPY_ALARM ?= 0 CIRCUITPY_PS2IO ?= 1 CIRCUITPY_SAMD ?= 1 -CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FRAMEBUFFERIO) CIRCUITPY_WATCHDOG ?= 1 endif # samd51 @@ -122,8 +122,8 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 CIRCUITPY_PS2IO ?= 1 CIRCUITPY_SAMD ?= 1 -CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FRAMEBUFFERIO) endif # same51 ###################################################################### From a0074c36d88cc3bb5a26fe9c5767ddc94132e6a8 Mon Sep 17 00:00:00 2001 From: EmergReanimator Date: Sun, 7 Nov 2021 14:19:01 +0100 Subject: [PATCH 35/84] Improved accuracy of common_hal_mcu_delay_us of STM port. SysTick Current Value Register must be cleared before enabling. --- ports/stm/common-hal/microcontroller/__init__.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/stm/common-hal/microcontroller/__init__.c b/ports/stm/common-hal/microcontroller/__init__.c index 28e06c9135..3bb850f5d3 100644 --- a/ports/stm/common-hal/microcontroller/__init__.c +++ b/ports/stm/common-hal/microcontroller/__init__.c @@ -41,13 +41,14 @@ #include "supervisor/shared/safe_mode.h" void common_hal_mcu_delay_us(uint32_t delay) { - uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq() / 1000000; + uint32_t ticks_per_us = HAL_RCC_GetSysClockFreq() / 1000000UL; delay *= ticks_per_us; + SysTick->VAL = 0UL; SysTick->LOAD = delay; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; while ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0) { } - SysTick->CTRL = 0; + SysTick->CTRL = 0UL; } volatile uint32_t nesting_count = 0; From f1ea57e0327ada81e14e23f2d2ad295849ff3589 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Fri, 5 Nov 2021 20:46:45 +0000 Subject: [PATCH 36/84] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1011 of 1011 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 147fd6a8e6..658c7da332 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-05 04:07+0000\n" +"PO-Revision-Date: 2021-11-07 16:53+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -118,7 +118,7 @@ msgstr "o %q deve ser %d-%d" #: py/argcheck.c shared-bindings/gifio/GifWriter.c msgid "%q must be <= %d" -msgstr "" +msgstr "%q deve ser <= %d" #: py/argcheck.c msgid "%q must be >= %d" @@ -4453,7 +4453,7 @@ msgstr "instrução Xtensa '%s' não compatível com argumentos %d" #: shared-module/gifio/GifWriter.c msgid "unsupported colorspace for GifWriter" -msgstr "" +msgstr "espaço de cores não compatível com GifWriter" #: py/objstr.c #, c-format From c607efe55749185affa3abe8c64978107945f19d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 8 Nov 2021 08:18:31 -0600 Subject: [PATCH 37/84] main.c: Fix safe mode Back in #5536 I modified how boot_out.txt got written. However, I broke USB enumeration in the safe-mode case. This fixes it so that a safe-mode board still connects on USB with all defaults. (tested on a macropad) --- main.c | 84 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/main.c b/main.c index 32ece4bbea..e1b9a39452 100755 --- a/main.c +++ b/main.c @@ -645,10 +645,6 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { && safe_mode == NO_SAFE_MODE && MP_STATE_VM(vfs_mount_table) != NULL; - if (!ok_to_run) { - return; - } - static const char * const boot_py_filenames[] = STRING_LIST("boot.py", "boot.txt"); // Do USB setup even if boot.py is not run. @@ -661,54 +657,56 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { usb_set_defaults(); #endif - #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - vstr_t boot_text; - vstr_init(&boot_text, 512); - boot_output = &boot_text; - #endif - - // Write version info - mp_printf(&mp_plat_print, "%s\nBoard ID:%s\n", MICROPY_FULL_VERSION_INFO, CIRCUITPY_BOARD_ID); - pyexec_result_t result = {0, MP_OBJ_NULL, 0}; - bool found_boot = maybe_run_list(boot_py_filenames, &result); - (void) found_boot; + if (ok_to_run) { + #ifdef CIRCUITPY_BOOT_OUTPUT_FILE + vstr_t boot_text; + vstr_init(&boot_text, 512); + boot_output = &boot_text; + #endif + + // Write version info + mp_printf(&mp_plat_print, "%s\nBoard ID:%s\n", MICROPY_FULL_VERSION_INFO, CIRCUITPY_BOARD_ID); + + bool found_boot = maybe_run_list(boot_py_filenames, &result); + (void) found_boot; - #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - // Get the base filesystem. - fs_user_mount_t *vfs = (fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj; - FATFS *fs = &vfs->fatfs; + #ifdef CIRCUITPY_BOOT_OUTPUT_FILE + // Get the base filesystem. + fs_user_mount_t *vfs = (fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj; + FATFS *fs = &vfs->fatfs; - boot_output = NULL; - bool write_boot_output = (common_hal_mcu_processor_get_reset_reason() == RESET_REASON_POWER_ON); - FIL boot_output_file; - if (f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) { - char *file_contents = m_new(char, boot_text.alloc); - UINT chars_read; - if (f_read(&boot_output_file, file_contents, 1+boot_text.len, &chars_read) == FR_OK) { - write_boot_output = - (chars_read != boot_text.len) || (memcmp(boot_text.buf, file_contents, chars_read) != 0); + boot_output = NULL; + bool write_boot_output = (common_hal_mcu_processor_get_reset_reason() == RESET_REASON_POWER_ON); + FIL boot_output_file; + if (f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) { + char *file_contents = m_new(char, boot_text.alloc); + UINT chars_read; + if (f_read(&boot_output_file, file_contents, 1+boot_text.len, &chars_read) == FR_OK) { + write_boot_output = + (chars_read != boot_text.len) || (memcmp(boot_text.buf, file_contents, chars_read) != 0); + } + // no need to f_close the file } - // no need to f_close the file - } - if (write_boot_output) { - // Wait 1 second before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, - // in case power is momentary or will fail shortly due to, say a low, battery. - mp_hal_delay_ms(1000); + if (write_boot_output) { + // Wait 1 second before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, + // in case power is momentary or will fail shortly due to, say a low, battery. + mp_hal_delay_ms(1000); - // USB isn't up, so we can write the file. - // operating at the oofatfs (f_open) layer means the usb concurrent write permission - // is not even checked! - f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); - UINT chars_written; - f_write(&boot_output_file, boot_text.buf, boot_text.len, &chars_written); - f_close(&boot_output_file); - filesystem_flush(); + // USB isn't up, so we can write the file. + // operating at the oofatfs (f_open) layer means the usb concurrent write permission + // is not even checked! + f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); + UINT chars_written; + f_write(&boot_output_file, boot_text.buf, boot_text.len, &chars_written); + f_close(&boot_output_file); + filesystem_flush(); + } + #endif } - #endif #if CIRCUITPY_USB // Some data needs to be carried over from the USB settings in boot.py From 2bcfb152836faeae99fb8e2f9da587f3f1faa397 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 8 Nov 2021 08:21:43 -0600 Subject: [PATCH 38/84] Add main.c to codeformat --- main.c | 87 +++++++++++++++++++++++---------------------- tools/codeformat.py | 1 + 2 files changed, 45 insertions(+), 43 deletions(-) mode change 100755 => 100644 main.c diff --git a/main.c b/main.c old mode 100755 new mode 100644 index e1b9a39452..94e4988e00 --- a/main.c +++ b/main.c @@ -117,12 +117,12 @@ static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t) #endif static void reset_devices(void) { -#if CIRCUITPY_BLEIO_HCI + #if CIRCUITPY_BLEIO_HCI bleio_reset(); -#endif + #endif } -STATIC void start_mp(supervisor_allocation* heap) { +STATIC void start_mp(supervisor_allocation *heap) { autoreload_stop(); supervisor_workflow_reset(); @@ -135,13 +135,13 @@ STATIC void start_mp(supervisor_allocation* heap) { } -#if MICROPY_MAX_STACK_USAGE + #if MICROPY_MAX_STACK_USAGE // _ezero (same as _ebss) is an int, so start 4 bytes above it. if (stack_get_bottom() != NULL) { mp_stack_set_bottom(stack_get_bottom()); mp_stack_fill_with_sentinel(); } -#endif + #endif // Sync the file systems in case any used RAM from the GC to cache. As soon // as we re-init the GC all bets are off on the cache. @@ -201,8 +201,8 @@ STATIC void stop_mp(void) { // Look for the first file that exists in the list of filenames, using mp_import_stat(). // Return its index. If no file found, return -1. -STATIC const char* first_existing_file_in_list(const char * const * filenames) { - for (int i = 0; filenames[i] != (char*)""; i++) { +STATIC const char *first_existing_file_in_list(const char *const *filenames) { + for (int i = 0; filenames[i] != (char *)""; i++) { mp_import_stat_t stat = mp_import_stat(filenames[i]); if (stat == MP_IMPORT_STAT_FILE) { return filenames[i]; @@ -211,8 +211,8 @@ STATIC const char* first_existing_file_in_list(const char * const * filenames) { return NULL; } -STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec_result) { - const char* filename = first_existing_file_in_list(filenames); +STATIC bool maybe_run_list(const char *const *filenames, pyexec_result_t *exec_result) { + const char *filename = first_existing_file_in_list(filenames); if (filename == NULL) { return false; } @@ -226,10 +226,10 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec } STATIC void count_strn(void *data, const char *str, size_t len) { - *(size_t*)data += len; + *(size_t *)data += len; } -STATIC void cleanup_after_vm(supervisor_allocation* heap, mp_obj_t exception) { +STATIC void cleanup_after_vm(supervisor_allocation *heap, mp_obj_t exception) { // Get the traceback of any exception from this run off the heap. // MP_OBJ_SENTINEL means "this run does not contribute to traceback storage, don't touch it" // MP_OBJ_NULL (=0) means "this run completed successfully, clear any stored traceback" @@ -249,13 +249,12 @@ STATIC void cleanup_after_vm(supervisor_allocation* heap, mp_obj_t exception) { // making it fail, but at this point I believe they are not worth spending code on. if (prev_traceback_allocation != NULL) { vstr_t vstr; - vstr_init_fixed_buf(&vstr, traceback_len, (char*)prev_traceback_allocation->ptr); + vstr_init_fixed_buf(&vstr, traceback_len, (char *)prev_traceback_allocation->ptr); mp_print_t print = {&vstr, (mp_print_strn_t)vstr_add_strn}; mp_obj_print_exception(&print, exception); - ((char*)prev_traceback_allocation->ptr)[traceback_len] = '\0'; + ((char *)prev_traceback_allocation->ptr)[traceback_len] = '\0'; } - } - else { + } else { prev_traceback_allocation = NULL; } } @@ -335,17 +334,17 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { uint8_t next_code_stickiness_situation = SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET; if (safe_mode == NO_SAFE_MODE) { - static const char * const supported_filenames[] = STRING_LIST( + static const char *const supported_filenames[] = STRING_LIST( "code.txt", "code.py", "main.py", "main.txt"); #if CIRCUITPY_FULL_BUILD - static const char * const double_extension_filenames[] = STRING_LIST( + static const char *const double_extension_filenames[] = STRING_LIST( "code.txt.py", "code.py.txt", "code.txt.txt","code.py.py", "main.txt.py", "main.py.txt", "main.txt.txt","main.py.py"); #endif stack_resize(); filesystem_flush(); - supervisor_allocation* heap = allocate_remaining_memory(); + supervisor_allocation *heap = allocate_remaining_memory(); // Prepare the VM state. Includes an alarm check/reset for sleep. start_mp(heap); @@ -356,14 +355,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // Check if a different run file has been allocated if (next_code_allocation) { - ((next_code_info_t*)next_code_allocation->ptr)->options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET; - next_code_options = ((next_code_info_t*)next_code_allocation->ptr)->options; - if (((next_code_info_t*)next_code_allocation->ptr)->filename[0] != '\0') { - const char* next_list[] = {((next_code_info_t*)next_code_allocation->ptr)->filename, ""}; + ((next_code_info_t *)next_code_allocation->ptr)->options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET; + next_code_options = ((next_code_info_t *)next_code_allocation->ptr)->options; + if (((next_code_info_t *)next_code_allocation->ptr)->filename[0] != '\0') { + const char *next_list[] = {((next_code_info_t *)next_code_allocation->ptr)->filename, ""}; // This is where the user's python code is actually executed: found_main = maybe_run_list(next_list, &result); if (!found_main) { - serial_write(((next_code_info_t*)next_code_allocation->ptr)->filename); + serial_write(((next_code_info_t *)next_code_allocation->ptr)->filename); serial_write_compressed(translate(" not found.\n")); } } @@ -374,14 +373,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { found_main = maybe_run_list(supported_filenames, &result); // If that didn't work, double check the extensions #if CIRCUITPY_FULL_BUILD - if (!found_main){ + if (!found_main) { found_main = maybe_run_list(double_extension_filenames, &result); if (found_main) { serial_write_compressed(translate("WARNING: Your code filename has two extensions\n")); } } #else - (void) found_main; + (void)found_main; #endif } @@ -400,7 +399,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // the options because it can be treated like any other reason-for-stickiness bit. The // source is different though: it comes from the options that will apply to the next run, // while the rest of next_code_options is what applied to this run. - if (next_code_allocation != NULL && (((next_code_info_t*)next_code_allocation->ptr)->options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET)) { + if (next_code_allocation != NULL && (((next_code_info_t *)next_code_allocation->ptr)->options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET)) { next_code_options |= SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET; } @@ -562,7 +561,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { } #if !CIRCUITPY_STATUS_LED - port_interrupt_after_ticks(time_to_epaper_refresh); + port_interrupt_after_ticks(time_to_epaper_refresh); #endif #endif @@ -645,17 +644,17 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { && safe_mode == NO_SAFE_MODE && MP_STATE_VM(vfs_mount_table) != NULL; - static const char * const boot_py_filenames[] = STRING_LIST("boot.py", "boot.txt"); + static const char *const boot_py_filenames[] = STRING_LIST("boot.py", "boot.txt"); // Do USB setup even if boot.py is not run. - supervisor_allocation* heap = allocate_remaining_memory(); + supervisor_allocation *heap = allocate_remaining_memory(); start_mp(heap); -#if CIRCUITPY_USB + #if CIRCUITPY_USB // Set up default USB values after boot.py VM starts but before running boot.py. usb_set_defaults(); -#endif + #endif pyexec_result_t result = {0, MP_OBJ_NULL, 0}; @@ -670,12 +669,12 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { mp_printf(&mp_plat_print, "%s\nBoard ID:%s\n", MICROPY_FULL_VERSION_INFO, CIRCUITPY_BOARD_ID); bool found_boot = maybe_run_list(boot_py_filenames, &result); - (void) found_boot; + (void)found_boot; #ifdef CIRCUITPY_BOOT_OUTPUT_FILE // Get the base filesystem. - fs_user_mount_t *vfs = (fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj; + fs_user_mount_t *vfs = (fs_user_mount_t *)MP_STATE_VM(vfs_mount_table)->obj; FATFS *fs = &vfs->fatfs; boot_output = NULL; @@ -684,7 +683,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { if (f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) { char *file_contents = m_new(char, boot_text.alloc); UINT chars_read; - if (f_read(&boot_output_file, file_contents, 1+boot_text.len, &chars_read) == FR_OK) { + if (f_read(&boot_output_file, file_contents, 1 + boot_text.len, &chars_read) == FR_OK) { write_boot_output = (chars_read != boot_text.len) || (memcmp(boot_text.buf, file_contents, chars_read) != 0); } @@ -708,7 +707,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { #endif } -#if CIRCUITPY_USB + #if CIRCUITPY_USB // Some data needs to be carried over from the USB settings in boot.py // to the next VM, while the heap is still available. // Its size can vary, so save it temporarily on the stack, @@ -717,21 +716,21 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { size_t size = usb_boot_py_data_size(); uint8_t usb_boot_py_data[size]; usb_get_boot_py_data(usb_boot_py_data, size); -#endif + #endif cleanup_after_vm(heap, result.exception); -#if CIRCUITPY_USB + #if CIRCUITPY_USB // Now give back the data we saved from the heap going away. usb_return_boot_py_data(usb_boot_py_data, size); -#endif + #endif } STATIC int run_repl(void) { int exit_code = PYEXEC_FORCED_EXIT; stack_resize(); filesystem_flush(); - supervisor_allocation* heap = allocate_remaining_memory(); + supervisor_allocation *heap = allocate_remaining_memory(); start_mp(heap); #if CIRCUITPY_USB @@ -876,7 +875,7 @@ void gc_collect(void) { // This collects root pointers from the VFS mount table. Some of them may // have lost their references in the VM even though they are mounted. - gc_collect_root((void**)&MP_STATE_VM(vfs_mount_table), sizeof(mp_vfs_mount_t) / sizeof(mp_uint_t)); + gc_collect_root((void **)&MP_STATE_VM(vfs_mount_table), sizeof(mp_vfs_mount_t) / sizeof(mp_uint_t)); background_callback_gc_collect(); @@ -906,18 +905,20 @@ void gc_collect(void) { // This naively collects all object references from an approximate stack // range. - gc_collect_root((void**)sp, ((uint32_t)port_stack_get_top() - sp) / sizeof(uint32_t)); + gc_collect_root((void **)sp, ((uint32_t)port_stack_get_top() - sp) / sizeof(uint32_t)); gc_collect_end(); } void NORETURN nlr_jump_fail(void *val) { reset_into_safe_mode(MICROPY_NLR_JUMP_FAIL); - while (true) {} + while (true) { + } } void NORETURN __fatal_error(const char *msg) { reset_into_safe_mode(MICROPY_FATAL_ERROR); - while (true) {} + while (true) { + } } #ifndef NDEBUG diff --git a/tools/codeformat.py b/tools/codeformat.py index 1a7ea14c09..c98b34b17a 100644 --- a/tools/codeformat.py +++ b/tools/codeformat.py @@ -38,6 +38,7 @@ import subprocess # Relative to top-level repo dir. PATHS = [ # C + "main.c", "devices/**/*.[ch]", "drivers/bus/*.[ch]", "extmod/*.[ch]", From eaf8bc0abe323c7ee2c0ee855eb191718bf14f6d Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 29 Oct 2021 14:01:47 -0500 Subject: [PATCH 39/84] bitmaptools: add dither This can convert a BGR565_SWAPPED bitmap to B&W in about 82ms on esp32-s2. --- locale/circuitpython.pot | 20 +++ shared-bindings/bitmaptools/__init__.c | 90 ++++++++++- shared-bindings/bitmaptools/__init__.h | 9 ++ shared-module/bitmaptools/__init__.c | 201 ++++++++++++++++++++++++- 4 files changed, 317 insertions(+), 3 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index e39fef97e7..79b0464e3d 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -2611,6 +2611,10 @@ msgstr "" msgid "binary op %q not implemented" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4102,6 +4106,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "" @@ -4350,6 +4366,10 @@ msgstr "" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index ad814e8881..69e2a35b01 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -25,11 +25,14 @@ */ #include "shared-bindings/displayio/Bitmap.h" +#include "shared-bindings/displayio/Palette.h" +#include "shared-bindings/displayio/ColorConverter.h" #include "shared-bindings/bitmaptools/__init__.h" #include #include "py/binary.h" +#include "py/enum.h" #include "py/obj.h" #include "py/runtime.h" @@ -565,9 +568,92 @@ STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp return mp_const_none; } - MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_readinto_obj, 0, bitmaptools_readinto); +//| class DitherAlgorithm: +//| """Identifies the algorith for dither to use""" +//| +//| Atkinson: object +//| """The classic Atkinson dither, often associated with the Hypercard esthetic""" +//| +//| FloydStenberg: object +//| """The Floyd-Stenberg dither""" +//| +MAKE_ENUM_VALUE(bitmaptools_dither_algorithm_type, dither_algorithm, Atkinson, DITHER_ALGORITHM_ATKINSON); +MAKE_ENUM_VALUE(bitmaptools_dither_algorithm_type, dither_algorithm, FloydStenberg, DITHER_ALGORITHM_ATKINSON); + +MAKE_ENUM_MAP(bitmaptools_dither_algorithm) { + MAKE_ENUM_MAP_ENTRY(dither_algorithm, Atkinson), + MAKE_ENUM_MAP_ENTRY(dither_algorithm, FloydStenberg), +}; +STATIC MP_DEFINE_CONST_DICT(bitmaptools_dither_algorithm_locals_dict, bitmaptools_dither_algorithm_locals_table); + +MAKE_PRINTER(bitmaptools, bitmaptools_dither_algorithm); + +MAKE_ENUM_TYPE(bitmaptools, DitherAlgorithm, bitmaptools_dither_algorithm); + +//| def dither(dest_bitmap: displayio.Bitmap, source_bitmapp: displayio.Bitmap, source_colorspace: displayio.Colorspace, algorithm: DitherAlgorithm=DitherAlgorithm.Atkinson) -> None: +//| """Convert the input image into a 2-level output image using the given dither algorithm. +//| +//| :param bitmap dest_bitmap: Destination bitmap. It must have a value_count of 2 or 65536. The stored values are 0 and the maximum pixel value. +//| :param bitmap source_bitmap: Source bitmap that contains the graphical region to be dithered. It must have a value_count of 65536. +//| :param colorspace: The colorspace of the image. The supported colorspaces are ``RGB565``, ``BGR565``, ``RGB565_SWAPPED``, and ``BGR565_SWAPPED`` +//| :param algorithm: The dither algorithm to use, one of the `DitherAlgorithm `values. +//| """ +//| ... +//| +STATIC mp_obj_t bitmaptools_dither(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_dest_bitmap, ARG_source_bitmap, ARG_source_colorspace, ARG_algorithm }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_source_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_algorithm, MP_ARG_OBJ, { .u_obj = MP_ROM_PTR((void *)&dither_algorithm_Atkinson_obj) } }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + displayio_bitmap_t *source_bitmap = mp_arg_validate_type(args[ARG_source_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap); + displayio_bitmap_t *dest_bitmap = mp_arg_validate_type(args[ARG_dest_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_dest_bitmap); + bitmaptools_dither_algorithm_t algorithm = cp_enum_value(&bitmaptools_dither_algorithm_type, args[ARG_algorithm].u_obj); + displayio_colorspace_t colorspace = cp_enum_value(&displayio_colorspace_type, args[ARG_source_colorspace].u_obj); + + if (source_bitmap->width != dest_bitmap->width || source_bitmap->height != dest_bitmap->height) { + mp_raise_TypeError(translate("bitmap sizes must match")); + } + + if (dest_bitmap->bits_per_value != 16 && dest_bitmap->bits_per_value != 1) { + mp_raise_TypeError(translate("source_bitmap must have value_count of 2 or 65536")); + } + + + switch (colorspace) { + case DISPLAYIO_COLORSPACE_RGB565: + case DISPLAYIO_COLORSPACE_RGB565_SWAPPED: + case DISPLAYIO_COLORSPACE_BGR565: + case DISPLAYIO_COLORSPACE_BGR565_SWAPPED: + if (source_bitmap->bits_per_value != 16) { + mp_raise_TypeError(translate("source_bitmap must have value_count of 65536")); + } + break; + + case DISPLAYIO_COLORSPACE_L8: + if (source_bitmap->bits_per_value != 8) { + mp_raise_TypeError(translate("source_bitmap must have value_count of 8")); + } + break; + + default: + mp_raise_TypeError(translate("unsupported colorspace for dither")); + } + + + common_hal_bitmaptools_dither(dest_bitmap, source_bitmap, colorspace, algorithm); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_dither_obj, 0, bitmaptools_dither); + + STATIC const mp_rom_map_elem_t bitmaptools_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bitmaptools) }, { MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&bitmaptools_readinto_obj) }, @@ -576,6 +662,8 @@ STATIC const mp_rom_map_elem_t bitmaptools_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_fill_region), MP_ROM_PTR(&bitmaptools_fill_region_obj) }, { MP_ROM_QSTR(MP_QSTR_boundary_fill), MP_ROM_PTR(&bitmaptools_boundary_fill_obj) }, { MP_ROM_QSTR(MP_QSTR_draw_line), MP_ROM_PTR(&bitmaptools_draw_line_obj) }, + { MP_ROM_QSTR(MP_QSTR_dither), MP_ROM_PTR(&bitmaptools_dither_obj) }, + { MP_ROM_QSTR(MP_QSTR_DitherAlgorithm), MP_ROM_PTR(&bitmaptools_dither_algorithm_type) }, }; STATIC MP_DEFINE_CONST_DICT(bitmaptools_module_globals, bitmaptools_module_globals_table); diff --git a/shared-bindings/bitmaptools/__init__.h b/shared-bindings/bitmaptools/__init__.h index 6415b20258..fb9d783e55 100644 --- a/shared-bindings/bitmaptools/__init__.h +++ b/shared-bindings/bitmaptools/__init__.h @@ -28,9 +28,17 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H #include "shared-module/displayio/Bitmap.h" +#include "shared-module/displayio/Palette.h" +#include "shared-bindings/displayio/ColorConverter.h" #include "py/obj.h" #include "extmod/vfs_fat.h" +typedef enum { + DITHER_ALGORITHM_ATKINSON, DITHER_ALGORITHM_FLOYD_STENBERG, +} bitmaptools_dither_algorithm_t; + +extern const mp_obj_type_t bitmaptools_dither_algorithm_type; + void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16_t oy, int16_t dest_clip0_x, int16_t dest_clip0_y, int16_t dest_clip1_x, int16_t dest_clip1_y, @@ -57,5 +65,6 @@ void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination, void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_word, bool swap_bytes, bool reverse_rows); void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int element_size, int x1, int y1, int x2, int y2, bool skip_specified, uint32_t skip_index); +void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bitmap_t *source_bitmap, displayio_colorspace_t colorspace, bitmaptools_dither_algorithm_t algorithm); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index b6e0764fdb..c75bc599cb 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -26,13 +26,17 @@ #include "shared-bindings/bitmaptools/__init__.h" #include "shared-bindings/displayio/Bitmap.h" +#include "shared-bindings/displayio/Palette.h" +#include "shared-bindings/displayio/ColorConverter.h" #include "shared-module/displayio/Bitmap.h" #include "py/runtime.h" #include "py/mperrno.h" -#include "math.h" -#include "stdlib.h" +#include +#include +#include +#include void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16_t oy, int16_t dest_clip0_x, int16_t dest_clip0_y, @@ -602,3 +606,196 @@ void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *f } } } + +typedef struct { + uint8_t count; // The number of items in terms[] + uint8_t mx; // the maximum of the absolute value of the dx values + uint8_t dl; // the scaled dither value applied to the pixel at distance [1,0] + struct { // dl is the scaled dither values applied to the pixel at [dx,dy] + int8_t dx, dy, dl; + } terms[]; +} bitmaptools_dither_algorithm_info_t; + +static bitmaptools_dither_algorithm_info_t atkinson = { + 4, 2, 256 / 8, { + {2, 0, 256 / 8}, + {-1, 1, 256 / 8}, + {0, 1, 256 / 8}, + {0, 2, 256 / 8}, + } +}; + +static bitmaptools_dither_algorithm_info_t floyd_stenberg = { + 3, 1, 7 * 256 / 16, + { + {-1, 1, 3 * 256 / 16}, + {0, 1, 5 * 256 / 16}, + {1, 1, 1 * 256 / 16}, + } +}; + +bitmaptools_dither_algorithm_info_t *algorithms[] = { + [DITHER_ALGORITHM_ATKINSON] = &atkinson, + [DITHER_ALGORITHM_FLOYD_STENBERG] = &floyd_stenberg, +}; + +enum { + SWAP_BYTES = 1 << 0, + SWAP_RB = 1 << 1, +}; + +STATIC void fill_row(displayio_bitmap_t *bitmap, int swap, int16_t *luminance_data, int y, int mx) { + if (y >= bitmap->height) { + return; + } + + // zero out padding area + for (int i = 0; i < mx; i++) { + luminance_data[-mx + i] = 0; + luminance_data[bitmap->width + i] = 0; + } + + if (bitmap->bits_per_value == 8) { + uint8_t *pixel_data = (uint8_t *)(bitmap->data + bitmap->stride * y); + for (int x = 0; x < bitmap->width; x++) { + *luminance_data++ = *pixel_data++; + } + } else { + uint16_t *pixel_data = (uint16_t *)(bitmap->data + bitmap->stride * y); + for (int x = 0; x < bitmap->width; x++) { + uint16_t pixel = *pixel_data++; + if (swap & SWAP_BYTES) { + pixel = __builtin_bswap16(pixel); + } + int r = (pixel >> 8) & 0xf8; + int g = (pixel >> 3) & 0xfc; + int b = (pixel << 3) & 0xf8; + + if (swap & SWAP_RB) { + uint8_t tmp = r; + r = b; + b = tmp; + } + + // ideal coefficients are around .299, .587, .114 (according to + // ppmtopnm), this differs from the 'other' luma-converting + // function in circuitpython (why?) + + // we correct for the fact that the input ranges are 0..0xf8 (or + // 0xfc) rather than 0x00..0xff + // Check: (0xf8 * 78 + 0xfc * 154 + 0xf8 * 29) // 256 == 255 + *luminance_data++ = (r * 78 + g * 154 + b * 29) / 256; + } + } +} + +static void write_pixels(displayio_bitmap_t *bitmap, int y, bool *data) { + if (bitmap->bits_per_value == 1) { + uint32_t *pixel_data = (uint32_t *)(bitmap->data + bitmap->stride * y); + for (int i = 0; i < bitmap->stride; i++) { + uint32_t p = 0; + for (int j = 0; j < 32; i++) { + p = (p << 1); + if (*data++) { + p |= 1; + } + } + *pixel_data++ = p; + } + } else { + uint16_t *pixel_data = (uint16_t *)(bitmap->data + bitmap->stride * y); + for (int i = 0; i < bitmap->width; i++) { + *pixel_data++ = *data++ ? 65535 : 0; + } + } +} + +void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bitmap_t *source_bitmap, displayio_colorspace_t colorspace, bitmaptools_dither_algorithm_t algorithm) { + int height = dest_bitmap->height, width = dest_bitmap->width; + + int swap = 0; + if (colorspace == DISPLAYIO_COLORSPACE_RGB565_SWAPPED || colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED) { + swap |= SWAP_BYTES; + } + if (colorspace == DISPLAYIO_COLORSPACE_BGR565 || colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED) { + swap |= SWAP_RB; + } + + bitmaptools_dither_algorithm_info_t *info = algorithms[algorithm]; + // rowdata holds 3 rows of data. Each one is larger than the input + // bitmap's width, beacuse `mx` extra pixels are allocated at the start and + // end of the row so that no conditionals are needed when storing the error data. + int16_t rowdata[(width + 2 * info->mx) * 3]; + int16_t *rows[3] = { + rowdata + info->mx, rowdata + width + info->mx * 3, rowdata + 2 * width + info->mx * 5 + }; + // out holds one output row of pixels, and is padded to be a multiple of 32 so that the 1bpp storage loop can be simplified + bool out[(width + 31) / 32 * 32]; + + fill_row(source_bitmap, swap, rows[0], 0, info->mx); + fill_row(source_bitmap, swap, rows[1], 1, info->mx); + fill_row(source_bitmap, swap, rows[2], 2, info->mx); + + int16_t err = 0; + + for (int y = 0; y < height; y++) { + + // Serpentine dither. Going left-to-right... + for (int x = 0; x < width; x++) { + int32_t pixel_in = rows[0][x] + err; + bool pixel_out = pixel_in >= 128; + out[x] = pixel_out; + + err = pixel_in - (pixel_out ? 255 : 0); + + for (int i = 0; i < info->count; i++) { + int x1 = x + info->terms[i].dx; + int dy = info->terms[i].dy; + + rows[dy][x1] = ((info->terms[i].dl * err) >> 8) + rows[dy][x1]; + } + err = err * info->dl >> 8; + } + write_pixels(dest_bitmap, y, out); + + // Cycle the rows by shuffling pointers, this is faster than copying the data. + int16_t *tmp = rows[0]; + rows[0] = rows[1]; + rows[1] = rows[2]; + rows[2] = tmp; + + fill_row(source_bitmap, swap, rows[2], y + 2, info->mx); + + y++; + if (y == height) { + break; + } + + // Serpentine dither. Going right-to-left... + for (int x = width; x--;) { + int16_t pixel_in = rows[0][x] + err; + bool pixel_out = pixel_in >= 128; + out[x] = pixel_out; + err = pixel_in - (pixel_out ? 255 : 0); + + for (int i = 0; i < info->count; i++) { + int x1 = x - info->terms[i].dx; + int dy = info->terms[i].dy; + + rows[dy][x1] = ((info->terms[i].dl * err) >> 8) + rows[dy][x1]; + } + err = err * info->dl >> 8; + } + write_pixels(dest_bitmap, y, out); + + tmp = rows[0]; + rows[0] = rows[1]; + rows[1] = rows[2]; + rows[2] = tmp; + + fill_row(source_bitmap, swap, rows[2], y + 2, info->mx); + } + + displayio_area_t a = { 0, 0, width, height }; + displayio_bitmap_set_dirty_area(dest_bitmap, &a); +} From b453d18579e1cfb53268bf1f423098d04cd1987c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 8 Nov 2021 10:36:39 -0600 Subject: [PATCH 40/84] ColorConverter: fix a docstring --- shared-bindings/displayio/ColorConverter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 2f40d8bd36..f2ca006ced 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -39,7 +39,7 @@ //| class ColorConverter: //| """Converts one color format to another.""" //| -//| def __init__(self, *, colorspace: Colorspace=Colorspace.RGB888, dither: bool = False) -> None: +//| def __init__(self, *, input_colorspace: Colorspace=Colorspace.RGB888, dither: bool = False) -> None: //| """Create a ColorConverter object to convert color formats. //| //| :param Colorspace colorspace: The source colorspace, one of the Colorspace constants From 6351de6ad11c97a5d3e66493fb0572bbbc2a62c1 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 8 Nov 2021 10:38:05 -0600 Subject: [PATCH 41/84] espressif: Allow -DENABLE_JTAG=0 to force JTAG off With the Kaluga devkit, the camera interferes with the JTAG function. However, having DEBUG turned on e.g., to get extended debug information on the UART debug connection remains useful. Now, by arranging to add to CFLAGS += -DDEBUG -DENABLE_JTAG=0, this configuration is easy to achieve. --- ports/espressif/supervisor/port.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ports/espressif/supervisor/port.c b/ports/espressif/supervisor/port.c index 2aa9bdef4f..7425bb615e 100644 --- a/ports/espressif/supervisor/port.c +++ b/ports/espressif/supervisor/port.c @@ -127,7 +127,11 @@ safe_mode_t port_init(void) { heap = NULL; never_reset_module_internal_pins(); - #if defined(DEBUG) + #ifndef DEBUG + #define DEBUG (0) + #endif + + #if DEBUG // debug UART #ifdef CONFIG_IDF_TARGET_ESP32C3 common_hal_never_reset_pin(&pin_GPIO20); @@ -138,7 +142,11 @@ safe_mode_t port_init(void) { #endif #endif - #if defined(DEBUG) || defined(ENABLE_JTAG) + #ifndef ENABLE_JTAG + #define ENABLE_JTAG (defined(DEBUG) && DEBUG) + #endif + + #if ENABLE_JTAG // JTAG #ifdef CONFIG_IDF_TARGET_ESP32C3 common_hal_never_reset_pin(&pin_GPIO4); From 13d05aa229491996040c9152f0b83cf11359ff1a Mon Sep 17 00:00:00 2001 From: Reza Almanda Date: Mon, 8 Nov 2021 01:48:47 +0000 Subject: [PATCH 42/84] Translated using Weblate (Indonesian) Currently translated at 44.3% (448 of 1011 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/id/ --- locale/ID.po | 53 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index b4daf25377..b653bb9998 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-04-28 16:11+0000\n" +"PO-Revision-Date: 2021-11-08 18:50+0000\n" "Last-Translator: Reza Almanda \n" "Language-Team: LANGUAGE \n" "Language: ID\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.7-dev\n" +"X-Generator: Weblate 4.9-dev\n" #: main.c msgid "" @@ -52,11 +52,11 @@ msgstr " File \"%q\", baris %d" #: py/builtinhelp.c msgid " is of type %q\n" -msgstr "" +msgstr " adalah tipe %q\n" #: main.c msgid " not found.\n" -msgstr "" +msgstr " tidak ketemu.\n" #: main.c msgid " output:\n" @@ -72,14 +72,15 @@ msgstr "%%c harus int atau char" msgid "" "%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" +"%d pin alamat, %d rgb pin dan %d ubin menunjukkan ketinggian %d, bukan %d" #: shared-bindings/microcontroller/Pin.c msgid "%q and %q contain duplicate pins" -msgstr "" +msgstr "%q dan %q berisi pin duplikat" #: shared-bindings/microcontroller/Pin.c msgid "%q contains duplicate pins" -msgstr "" +msgstr "%q berisi pin duplikat" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -104,23 +105,23 @@ msgstr "indeks %q harus bilangan bulat, bukan %s" #: py/argcheck.c msgid "%q length must be %d-%d" -msgstr "" +msgstr "%q panjang harus %d-%d" #: shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" -msgstr "" +msgstr "%q panjang harus >= 1" #: py/argcheck.c msgid "%q must be %d-%d" -msgstr "" +msgstr "%q harus %d-%d" #: py/argcheck.c shared-bindings/gifio/GifWriter.c msgid "%q must be <= %d" -msgstr "" +msgstr "%q harus <= %d" #: py/argcheck.c msgid "%q must be >= %d" -msgstr "" +msgstr "%q harus >= %d" #: py/argcheck.c shared-bindings/memorymonitor/AllocationAlarm.c msgid "%q must be >= 0" @@ -136,7 +137,7 @@ msgstr "%q harus >= 1" #: py/argcheck.c msgid "%q must be a string" -msgstr "" +msgstr "%q harus berupa string" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -145,15 +146,15 @@ msgstr "%q harus berupa tuple dengan panjang 2" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c #: shared-module/vectorio/VectorShape.c msgid "%q must be between %d and %d" -msgstr "" +msgstr "%q harus antara %d dan %d" #: py/argcheck.c msgid "%q must be of type %q" -msgstr "" +msgstr "%q harus bertipe %q" #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" -msgstr "" +msgstr "%q harus pangkat 2" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c @@ -178,12 +179,12 @@ msgstr "%q() mengambil posisi argumen %d tapi %d yang diberikan" #: shared-bindings/usb_hid/Device.c msgid "%q, %q, and %q must all be the same length" -msgstr "" +msgstr "%q, %q, dan %q semuanya harus memiliki panjang yang sama" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c #, c-format msgid "%s error 0x%x" -msgstr "" +msgstr "%s kesalahan 0x%x" #: py/argcheck.c msgid "'%q' argument required" @@ -199,7 +200,7 @@ msgstr "Objek '%q' bukan merupakan iterator" #: py/objtype.c py/runtime.c shared-module/atexit/__init__.c msgid "'%q' object is not callable" -msgstr "" +msgstr "Objek '%q' tidak dapat dipanggil" #: py/runtime.c msgid "'%q' object is not iterable" @@ -248,7 +249,7 @@ msgstr "'%s' mengharapkan {r0, r1, ...}" #: py/emitinlinextensa.c #, c-format msgid "'%s' integer %d isn't within range %d..%d" -msgstr "" +msgstr "'%s' integer %d tidak berada dalam jangkauan %d..%d" #: py/emitinlinethumb.c #, c-format @@ -4464,27 +4465,27 @@ msgstr "" #: extmod/ulab/code/numpy/vector.c msgid "wrong output type" -msgstr "" +msgstr "tipe output salah" #: shared-module/displayio/Shape.c msgid "x value out of bounds" -msgstr "" +msgstr "nilai x di luar batas" #: ports/espressif/common-hal/audiobusio/__init__.c msgid "xTaskCreate failed" -msgstr "" +msgstr "xTaskCreate gagal" #: shared-bindings/displayio/Shape.c msgid "y should be an int" -msgstr "" +msgstr "y harus menjadi int" #: shared-module/displayio/Shape.c msgid "y value out of bounds" -msgstr "" +msgstr "Nilai y di luar batas" #: py/objrange.c msgid "zero step" -msgstr "" +msgstr "nol langkah" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be an ndarray" @@ -4496,7 +4497,7 @@ msgstr "zi harus berjenis float" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of shape (n_section, 2)" -msgstr "" +msgstr "Zi harus berbentuk (n_section, 2)" #, c-format #~ msgid "" From e119c8860071ecf6e11a508ec048f1f0428abdad Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Mon, 8 Nov 2021 19:50:11 +0100 Subject: [PATCH 43/84] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 16 ++++++++++++++++ locale/cs.po | 16 ++++++++++++++++ locale/de_DE.po | 16 ++++++++++++++++ locale/el.po | 16 ++++++++++++++++ locale/en_GB.po | 16 ++++++++++++++++ locale/es.po | 16 ++++++++++++++++ locale/fil.po | 16 ++++++++++++++++ locale/fr.po | 16 ++++++++++++++++ locale/hi.po | 16 ++++++++++++++++ locale/it_IT.po | 16 ++++++++++++++++ locale/ja.po | 16 ++++++++++++++++ locale/ko.po | 16 ++++++++++++++++ locale/nl.po | 16 ++++++++++++++++ locale/pl.po | 16 ++++++++++++++++ locale/pt_BR.po | 16 ++++++++++++++++ locale/sv.po | 16 ++++++++++++++++ locale/zh_Latn_pinyin.po | 16 ++++++++++++++++ 17 files changed, 272 insertions(+) diff --git a/locale/ID.po b/locale/ID.po index b653bb9998..1cd42f5b5e 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -562,6 +562,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "Kedalaman bit harus kelipatan 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1090,6 +1094,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "" @@ -2427,6 +2439,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Baudrate tidak didukung" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Tipe bus tampilan tidak didukung" diff --git a/locale/cs.po b/locale/cs.po index e74c2df01d..739fedf413 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -555,6 +555,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1074,6 +1078,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "" @@ -2393,6 +2405,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index c18d04a79d..51253dd20e 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -563,6 +563,10 @@ msgstr "Bittiefe muss zwischen 1 und 6 liegen, nicht %d" msgid "Bit depth must be multiple of 8." msgstr "Bit depth muss ein Vielfaches von 8 sein." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1087,6 +1091,14 @@ msgstr "Filter zu komplex" msgid "Firmware image is invalid" msgstr "Firmware Image ist ungültig" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "Format nicht unterstützt" @@ -2429,6 +2441,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Baudrate wird nicht unterstützt" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Nicht unterstützter display bus type" diff --git a/locale/el.po b/locale/el.po index c32bd93adc..5584485cea 100644 --- a/locale/el.po +++ b/locale/el.po @@ -552,6 +552,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1071,6 +1075,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "" @@ -2390,6 +2402,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index abe6762e2d..d60c8fc6fe 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -563,6 +563,10 @@ msgstr "Bit depth must be from 1 to 6 inclusive, not %d" msgid "Bit depth must be multiple of 8." msgstr "Bit depth must be multiple of 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1084,6 +1088,14 @@ msgstr "Filters too complex" msgid "Firmware image is invalid" msgstr "Firmware image is invalid" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "Format not supported" @@ -2423,6 +2435,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Unsupported baudrate" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Unsupported display bus type" diff --git a/locale/es.po b/locale/es.po index 498144d4f7..3a7e7e0882 100644 --- a/locale/es.po +++ b/locale/es.po @@ -567,6 +567,10 @@ msgstr "Bit depth tiene que ser de 1 a 6 inclusivo, no %d" msgid "Bit depth must be multiple of 8." msgstr "Bits depth debe ser múltiplo de 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1094,6 +1098,14 @@ msgstr "Filtros muy complejos" msgid "Firmware image is invalid" msgstr "La imagen de firmware es inválida" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "Sin capacidades para el formato" @@ -2454,6 +2466,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Baudrate no soportado" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Sin capacidad de bus tipo display" diff --git a/locale/fil.po b/locale/fil.po index 3912d17949..25ceee357e 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -559,6 +559,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "Bit depth ay dapat multiple ng 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1084,6 +1088,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "" @@ -2411,6 +2423,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Hindi supportadong baudrate" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c #, fuzzy msgid "Unsupported display bus type" diff --git a/locale/fr.po b/locale/fr.po index 553a0a1d0b..4d7a92f54d 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -569,6 +569,10 @@ msgstr "Bit depth doit être entre 1 et 6 inclusivement, et non %d" msgid "Bit depth must be multiple of 8." msgstr "La profondeur de bit doit être un multiple de 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1101,6 +1105,14 @@ msgstr "Filtres trop complexe" msgid "Firmware image is invalid" msgstr "Image du microprogramme est invalide" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "Format non supporté" @@ -2458,6 +2470,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Débit en bauds non supporté" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Type de bus d'affichage non supporté" diff --git a/locale/hi.po b/locale/hi.po index ca925a4a4c..519f2abad6 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -552,6 +552,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1071,6 +1075,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "" @@ -2390,6 +2402,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 994e262359..4267ab0d71 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -567,6 +567,10 @@ msgstr "La profondità dei bit deve essere inclusiva da 1 a 6, non %d" msgid "Bit depth must be multiple of 8." msgstr "La profondità di bit deve essere un multiplo di 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1091,6 +1095,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "" @@ -2430,6 +2442,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "baudrate non supportato" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c #, fuzzy msgid "Unsupported display bus type" diff --git a/locale/ja.po b/locale/ja.po index 254cce04ed..b6e8cdc496 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -559,6 +559,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "ビット深度は8の倍数でなければなりません" +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1080,6 +1084,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "非対応の形式" @@ -2405,6 +2417,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "非対応のbaudrate" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 6f90d39388..e4d47e792d 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -555,6 +555,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1074,6 +1078,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "" @@ -2394,6 +2406,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index c3e81ff8d4..548bb9ea1e 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -557,6 +557,10 @@ msgstr "Bitdiepte moet tussen 1 en 6 liggen, niet %d" msgid "Bit depth must be multiple of 8." msgstr "Bit diepte moet een meervoud van 8 zijn." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1080,6 +1084,14 @@ msgstr "Filters zijn te complex" msgid "Firmware image is invalid" msgstr "Firmware image is ongeldig" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "Formaat wordt niet ondersteund" @@ -2418,6 +2430,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Niet-ondersteunde baudsnelheid" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Niet-ondersteund beeldscherm bus type" diff --git a/locale/pl.po b/locale/pl.po index d29e59a939..da11fc50ed 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -559,6 +559,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "Głębia musi być wielokrotnością 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1080,6 +1084,14 @@ msgstr "" msgid "Firmware image is invalid" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "Nie wspierany format" @@ -2401,6 +2413,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Zła szybkość transmisji" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Zły typ magistrali wyświetlaczy" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 658c7da332..efb56e23f3 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -570,6 +570,10 @@ msgstr "A profundidade dos bits deve ser de 1 até 6 inclusive, porém não %d" msgid "Bit depth must be multiple of 8." msgstr "A profundidade de bits deve ser o múltiplo de 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "" @@ -1098,6 +1102,14 @@ msgstr "Os filtros são muito complexos" msgid "Firmware image is invalid" msgstr "A imagem do firmware é invalida" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "O formato não é suportado" @@ -2462,6 +2474,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Taxa de transmissão não suportada" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Não há suporte para o tipo do display bus" diff --git a/locale/sv.po b/locale/sv.po index 28635a1dfa..faced4a454 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -562,6 +562,10 @@ msgstr "Bitdjup måste vara inom 1 till 6, inte %d" msgid "Bit depth must be multiple of 8." msgstr "Bitdjup måste vara multipel av 8." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "Startenheten måste vara den första enheten (gränssnitt #0)." @@ -1086,6 +1090,14 @@ msgstr "Filter för komplexa" msgid "Firmware image is invalid" msgstr "Firmware-avbilden är ogiltig" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "Formatet stöds inte" @@ -2434,6 +2446,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Baudrate stöd inte" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Busstyp för display stöds inte" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index e221a2c131..d48d7e3824 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -564,6 +564,10 @@ msgstr "wèi shēn dù bì xū bāo hán 1 dào 6, ér bù shì %d" msgid "Bit depth must be multiple of 8." msgstr "Bǐtè shēndù bìxū shì 8 bèi yǐshàng." +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." msgstr "yǐn dǎo shè bèi bì xū shì dì yī tái shè bèi (jiē kǒu #0)." @@ -1086,6 +1090,14 @@ msgstr "guò lǜ qì tài fù zá" msgid "Firmware image is invalid" msgstr "gù jiàn yìng xiàng wú xiào" +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" msgstr "Bù zhīyuán géshì" @@ -2435,6 +2447,10 @@ msgstr "" msgid "Unsupported baudrate" msgstr "Bù zhīchí de baudrate" +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" msgstr "Bù zhīchí de gōnggòng qìchē lèixíng" From ff9b10c7b62b9a96a9b73e01095a293103a1045f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 8 Nov 2021 16:46:44 -0600 Subject: [PATCH 44/84] fix doc build problems --- shared-bindings/bitmaptools/__init__.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 9268d56d77..99039ba1ba 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -650,10 +650,10 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_readinto_obj, 0, bitmaptools_readinto); //| class DitherAlgorithm: //| """Identifies the algorith for dither to use""" //| -//| Atkinson: object +//| Atkinson: "DitherAlgorithm" //| """The classic Atkinson dither, often associated with the Hypercard esthetic""" //| -//| FloydStenberg: object +//| FloydStenberg: "DitherAlgorithm" //| """The Floyd-Stenberg dither""" //| MAKE_ENUM_VALUE(bitmaptools_dither_algorithm_type, dither_algorithm, Atkinson, DITHER_ALGORITHM_ATKINSON); @@ -675,7 +675,7 @@ MAKE_ENUM_TYPE(bitmaptools, DitherAlgorithm, bitmaptools_dither_algorithm); //| :param bitmap dest_bitmap: Destination bitmap. It must have a value_count of 2 or 65536. The stored values are 0 and the maximum pixel value. //| :param bitmap source_bitmap: Source bitmap that contains the graphical region to be dithered. It must have a value_count of 65536. //| :param colorspace: The colorspace of the image. The supported colorspaces are ``RGB565``, ``BGR565``, ``RGB565_SWAPPED``, and ``BGR565_SWAPPED`` -//| :param algorithm: The dither algorithm to use, one of the `DitherAlgorithm `values. +//| :param algorithm: The dither algorithm to use, one of the `DitherAlgorithm` values. //| """ //| ... //| From 20cbd5e635bc8f045f743b67716c50284859431b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 8 Nov 2021 18:58:33 -0600 Subject: [PATCH 45/84] Disable bitmapio on some boards where it no longer fits --- ports/stm/boards/meowbit_v121/mpconfigboard.mk | 1 + ports/stm/boards/thunderpack_v12/mpconfigboard.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/ports/stm/boards/meowbit_v121/mpconfigboard.mk b/ports/stm/boards/meowbit_v121/mpconfigboard.mk index 589f0bce10..15ae33c4c8 100644 --- a/ports/stm/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm/boards/meowbit_v121/mpconfigboard.mk @@ -21,6 +21,7 @@ LD_FILE = boards/STM32F401xe_boot.ld # LD_FILE = boards/STM32F401xe_fs.ld CIRCUITPY_AESIO = 0 +CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_GIFIO = 0 CIRCUITPY_ULAB = 0 diff --git a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk index 1c09fe64c1..16a0c60f2a 100644 --- a/ports/stm/boards/thunderpack_v12/mpconfigboard.mk +++ b/ports/stm/boards/thunderpack_v12/mpconfigboard.mk @@ -12,6 +12,7 @@ SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C CIRCUITPY_NVM = 1 +CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BLEIO_HCI = 0 MCU_SERIES = F4 From cba6a684bc4968ff4fec1d7e367d9422a46ccd8c Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Tue, 9 Nov 2021 01:13:57 +0000 Subject: [PATCH 46/84] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1015 of 1015 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index efb56e23f3..1997f80715 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-07 16:53+0000\n" +"PO-Revision-Date: 2021-11-09 17:54+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -572,7 +572,7 @@ msgstr "A profundidade de bits deve ser o múltiplo de 8." #: shared-bindings/bitmaptools/__init__.c msgid "Bitmap size and bits per value must match" -msgstr "" +msgstr "O tamanho do bitmap e os bits por valor devem coincidir" #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." @@ -1104,11 +1104,11 @@ msgstr "A imagem do firmware é invalida" #: shared-bindings/bitmaptools/__init__.c msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" -msgstr "" +msgstr "Para o espaço de cor L8, o bitmap da entrada deve ter 8 bits por pixel" #: shared-bindings/bitmaptools/__init__.c msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" -msgstr "" +msgstr "Para espaços de cor RGB, o bitmap da entrada deve ter 16 bits por pixel" #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" @@ -2476,7 +2476,7 @@ msgstr "Taxa de transmissão não suportada" #: shared-bindings/bitmaptools/__init__.c msgid "Unsupported colorspace" -msgstr "" +msgstr "Espaço de cor não compatível" #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" From 77cb2a15d0609680e99aa2159de63b16781a627c Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Tue, 9 Nov 2021 09:51:41 +0000 Subject: [PATCH 47/84] Translated using Weblate (Swedish) Currently translated at 100.0% (1015 of 1015 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index faced4a454..ad76230a61 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-05 18:37+0000\n" +"PO-Revision-Date: 2021-11-09 17:54+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -564,7 +564,7 @@ msgstr "Bitdjup måste vara multipel av 8." #: shared-bindings/bitmaptools/__init__.c msgid "Bitmap size and bits per value must match" -msgstr "" +msgstr "Bitmappstorlek och bitar per värde måste överensstämma" #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." @@ -1092,11 +1092,11 @@ msgstr "Firmware-avbilden är ogiltig" #: shared-bindings/bitmaptools/__init__.c msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" -msgstr "" +msgstr "För L8-färgrymden måste indatabitmappen ha 8 bitar per pixel" #: shared-bindings/bitmaptools/__init__.c msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" -msgstr "" +msgstr "För RGB-färgrymder måste indatabitmappen ha 16 bitar per pixel" #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" @@ -2448,7 +2448,7 @@ msgstr "Baudrate stöd inte" #: shared-bindings/bitmaptools/__init__.c msgid "Unsupported colorspace" -msgstr "" +msgstr "Färgrymd stöds inte" #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" From 2ce13c8c7b64c3250c9962c2f6d6fed2b00e21f1 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 9 Nov 2021 18:54:04 +0100 Subject: [PATCH 48/84] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 20 ++++++++++++++++++++ locale/cs.po | 20 ++++++++++++++++++++ locale/de_DE.po | 20 ++++++++++++++++++++ locale/el.po | 20 ++++++++++++++++++++ locale/en_GB.po | 20 ++++++++++++++++++++ locale/es.po | 20 ++++++++++++++++++++ locale/fil.po | 20 ++++++++++++++++++++ locale/fr.po | 20 ++++++++++++++++++++ locale/hi.po | 20 ++++++++++++++++++++ locale/it_IT.po | 20 ++++++++++++++++++++ locale/ja.po | 20 ++++++++++++++++++++ locale/ko.po | 20 ++++++++++++++++++++ locale/nl.po | 20 ++++++++++++++++++++ locale/pl.po | 20 ++++++++++++++++++++ locale/pt_BR.po | 23 ++++++++++++++++++++++- locale/sv.po | 20 ++++++++++++++++++++ locale/zh_Latn_pinyin.po | 20 ++++++++++++++++++++ 17 files changed, 342 insertions(+), 1 deletion(-) diff --git a/locale/ID.po b/locale/ID.po index 1cd42f5b5e..393b70bd1c 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -2664,6 +2664,10 @@ msgstr "typecode buruk" msgid "binary op %q not implemented" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4156,6 +4160,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "" @@ -4404,6 +4420,10 @@ msgstr "" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/cs.po b/locale/cs.po index 739fedf413..74ef37ac14 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -2630,6 +2630,10 @@ msgstr "" msgid "binary op %q not implemented" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4121,6 +4125,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "" @@ -4369,6 +4385,10 @@ msgstr "" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/de_DE.po b/locale/de_DE.po index 51253dd20e..17c0838e44 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -2669,6 +2669,10 @@ msgstr "Falscher Typcode" msgid "binary op %q not implemented" msgstr "Der binäre Operator %q ist nicht implementiert" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "bits müssen 32 oder kleiner sein" @@ -4186,6 +4190,18 @@ msgstr "" msgid "source palette too large" msgstr "Quell-Palette zu groß" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "start/end Indizes" @@ -4437,6 +4453,10 @@ msgstr "nicht unterstützte Xtensa-Anweisung '%s' mit %d Argumenten" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/el.po b/locale/el.po index 5584485cea..61a5d6a641 100644 --- a/locale/el.po +++ b/locale/el.po @@ -2627,6 +2627,10 @@ msgstr "" msgid "binary op %q not implemented" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4118,6 +4122,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "" @@ -4366,6 +4382,10 @@ msgstr "" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/en_GB.po b/locale/en_GB.po index d60c8fc6fe..e57c17b9fc 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -2661,6 +2661,10 @@ msgstr "bad typecode" msgid "binary op %q not implemented" msgstr "binary op %q not implemented" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "bits must be 32 or less" @@ -4157,6 +4161,18 @@ msgstr "sosfilt requires iterable arguments" msgid "source palette too large" msgstr "source palette too large" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "start/end indices" @@ -4405,6 +4421,10 @@ msgstr "unsupported Xtensa instruction '%s' with %d arguments" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/es.po b/locale/es.po index 3a7e7e0882..a1af9c8baf 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2696,6 +2696,10 @@ msgstr "typecode erroneo" msgid "binary op %q not implemented" msgstr "operacion binaria %q no implementada" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "los bits deben ser 32 o menos" @@ -4203,6 +4207,18 @@ msgstr "sosfilt requiere argumentos iterables" msgid "source palette too large" msgstr "paleta fuente muy larga" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "índices inicio/final" @@ -4452,6 +4468,10 @@ msgstr "instrucción Xtensa '%s' con %d argumentos no soportada" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/fil.po b/locale/fil.po index 25ceee357e..c2a0f26c75 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -2649,6 +2649,10 @@ msgstr "masamang typecode" msgid "binary op %q not implemented" msgstr "binary op %q hindi implemented" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4161,6 +4165,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "start/end indeks" @@ -4411,6 +4427,10 @@ msgstr "hindi sinusuportahan ang instruction ng Xtensa '%s' sa %d argumento" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/fr.po b/locale/fr.po index 4d7a92f54d..65a9389cff 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -2699,6 +2699,10 @@ msgstr "mauvais code type" msgid "binary op %q not implemented" msgstr "opération binaire '%q' non implémentée" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4213,6 +4217,18 @@ msgstr "sosfilt nécessite des argument itératifs" msgid "source palette too large" msgstr "la palette source est trop grande" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "indices de début/fin" @@ -4462,6 +4478,10 @@ msgstr "instruction Xtensa '%s' non supportée avec %d paramètres" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/hi.po b/locale/hi.po index 519f2abad6..57b6249fcf 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -2627,6 +2627,10 @@ msgstr "" msgid "binary op %q not implemented" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4118,6 +4122,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "" @@ -4366,6 +4382,10 @@ msgstr "" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/it_IT.po b/locale/it_IT.po index 4267ab0d71..bfcb00932a 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -2668,6 +2668,10 @@ msgstr "" msgid "binary op %q not implemented" msgstr "operazione binaria %q non implementata" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4183,6 +4187,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "" @@ -4433,6 +4449,10 @@ msgstr "istruzione '%s' Xtensa non supportata con %d argomenti" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/ja.po b/locale/ja.po index b6e8cdc496..4c67ef0f65 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -2642,6 +2642,10 @@ msgstr "不正なtypecode" msgid "binary op %q not implemented" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4141,6 +4145,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "" @@ -4389,6 +4405,10 @@ msgstr "" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/ko.po b/locale/ko.po index e4d47e792d..1865940dde 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -2631,6 +2631,10 @@ msgstr "" msgid "binary op %q not implemented" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4122,6 +4126,18 @@ msgstr "" msgid "source palette too large" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "" @@ -4370,6 +4386,10 @@ msgstr "" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/nl.po b/locale/nl.po index 548bb9ea1e..40df1bb2ab 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -2659,6 +2659,10 @@ msgstr "verkeerde typecode" msgid "binary op %q not implemented" msgstr "binaire op %q niet geïmplementeerd" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4161,6 +4165,18 @@ msgstr "sosfilt vereist itereerbare argumenten" msgid "source palette too large" msgstr "bronpalet te groot" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "start/stop indices" @@ -4409,6 +4425,10 @@ msgstr "niet ondersteunde Xtensa instructie '%s' met %d argumenten" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/pl.po b/locale/pl.po index da11fc50ed..a95a0ff24c 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -2638,6 +2638,10 @@ msgstr "zły typecode" msgid "binary op %q not implemented" msgstr "brak dwu-argumentowego operatora %q" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "" @@ -4132,6 +4136,18 @@ msgstr "" msgid "source palette too large" msgstr "źródłowa paleta jest zbyt duża" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "początkowe/końcowe indeksy" @@ -4380,6 +4396,10 @@ msgstr "zła instrukcja Xtensa '%s' z %d argumentami" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 1997f80715..c17c9eb8c0 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -1108,7 +1108,8 @@ msgstr "Para o espaço de cor L8, o bitmap da entrada deve ter 8 bits por pixel" #: shared-bindings/bitmaptools/__init__.c msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" -msgstr "Para espaços de cor RGB, o bitmap da entrada deve ter 16 bits por pixel" +msgstr "" +"Para espaços de cor RGB, o bitmap da entrada deve ter 16 bits por pixel" #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" @@ -2710,6 +2711,10 @@ msgstr "typecode incorreto" msgid "binary op %q not implemented" msgstr "a operação binário %q não foi implementada" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "bits deve ser 32 ou menos" @@ -4223,6 +4228,18 @@ msgstr "o sosfilt requer que os argumentos sejam iteráveis" msgid "source palette too large" msgstr "a paleta de origem é muito grande" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "os índices de início/fim" @@ -4471,6 +4488,10 @@ msgstr "instrução Xtensa '%s' não compatível com argumentos %d" msgid "unsupported colorspace for GifWriter" msgstr "espaço de cores não compatível com GifWriter" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/sv.po b/locale/sv.po index ad76230a61..339cd61b4a 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -2679,6 +2679,10 @@ msgstr "Ogiltig typkod" msgid "binary op %q not implemented" msgstr "binär op %q är inte implementerad" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "bits måste vara 32 eller färre" @@ -4181,6 +4185,18 @@ msgstr "sosfilt kräver iterable argument" msgid "source palette too large" msgstr "källpalett för stor" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "start-/slutindex" @@ -4429,6 +4445,10 @@ msgstr "Xtensa-instruktion '%s' med %d argument stöds inte" msgid "unsupported colorspace for GifWriter" msgstr "färgrymd stöds inte för GifWriter" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index d48d7e3824..073004fee5 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -2680,6 +2680,10 @@ msgstr "cuòwù de dàimǎ lèixíng" msgid "binary op %q not implemented" msgstr "èrjìnzhì bǎn qián bǎn %q wèi zhíxíng" +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + #: extmod/modurandom.c msgid "bits must be 32 or less" msgstr "wèi bì xū shì 32 huò gèng shǎo" @@ -4180,6 +4184,18 @@ msgstr "sosfilt xūyào diédài cānshù" msgid "source palette too large" msgstr "yuán miànbǎn tài dà" +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + #: py/objstr.c msgid "start/end indices" msgstr "kāishǐ/jiéshù zhǐshù" @@ -4428,6 +4444,10 @@ msgstr "bù zhīchí de Xtensa zhǐlìng '%s', shǐyòng %d cānshù" msgid "unsupported colorspace for GifWriter" msgstr "" +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" From 63fbf9818652277174065090c189fe2702db0cc9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 9 Nov 2021 20:04:34 -0600 Subject: [PATCH 49/84] Enable -Wmissing-prototypes for atmel-samd --- devices/ble_hci/common-hal/_bleio/att.c | 1 + .../_bleio/hci_include/att_internal.h | 1 + main.c | 4 +-- ports/atmel-samd/Makefile | 32 +++++++++++-------- ports/atmel-samd/supervisor/port.c | 2 +- shared-module/usb_cdc/Serial.c | 1 + shared-module/usb_midi/PortIn.c | 1 + shared-module/usb_midi/PortOut.c | 1 + supervisor/shared/background_callback.c | 1 + .../shared/external_flash/external_flash.c | 4 +-- supervisor/shared/external_flash/qspi_flash.c | 1 + supervisor/shared/flash.c | 9 +++--- supervisor/shared/micropython.c | 1 + supervisor/shared/stack.c | 2 +- supervisor/shared/tick.c | 3 +- supervisor/shared/workflow.c | 2 ++ 16 files changed, 42 insertions(+), 24 deletions(-) diff --git a/devices/ble_hci/common-hal/_bleio/att.c b/devices/ble_hci/common-hal/_bleio/att.c index 5767045481..b0fc884e00 100644 --- a/devices/ble_hci/common-hal/_bleio/att.c +++ b/devices/ble_hci/common-hal/_bleio/att.c @@ -26,6 +26,7 @@ // Zephyr include files to define HCI communication values and structs. // #include "hci_include/hci.h" // #include "hci_include/hci_err.h" +#include "hci_include/att_internal.h" #include "hci_include/l2cap_internal.h" #include "py/obj.h" diff --git a/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h b/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h index 820246dec1..af8695da98 100644 --- a/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h +++ b/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h @@ -8,6 +8,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#pragma once #include // for __packed diff --git a/main.c b/main.c index 94e4988e00..a189add5e2 100644 --- a/main.c +++ b/main.c @@ -915,13 +915,13 @@ void NORETURN nlr_jump_fail(void *val) { } } -void NORETURN __fatal_error(const char *msg) { +#ifndef NDEBUG +static void NORETURN __fatal_error(const char *msg) { reset_into_safe_mode(MICROPY_FATAL_ERROR); while (true) { } } -#ifndef NDEBUG void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) { mp_printf(&mp_plat_print, "Assertion '%s' failed, at file %s:%d\n", expr, file, line); __fatal_error("Assertion failed"); diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 7b61bae267..721cfd4f0a 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -158,7 +158,7 @@ else endif endif -CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) +CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes ifeq ($(CHIP_FAMILY), samd21) CFLAGS += \ @@ -291,19 +291,9 @@ $(BUILD)/asf4/$(CHIP_FAMILY)/hpl/sdhc/hpl_sdhc.o: CFLAGS += -Wno-cast-align -Wno endif SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF)) +$(patsubst $(SRC_ASF),%.c,%.o): CFLAGS += -Wno-missing-prototypes -SRC_C += \ - audio_dma.c \ - background.c \ - bindings/samd/Clock.c \ - bindings/samd/__init__.c \ - boards/$(BOARD)/board.c \ - boards/$(BOARD)/pins.c \ - eic_handler.c \ - fatfs_port.c \ - freetouch/adafruit_ptc.c \ - lib/tinyusb/src/portable/microchip/samd/dcd_samd.c \ - mphalport.c \ +SRC_PERIPHERALS := \ peripherals/samd/$(PERIPHERALS_CHIP_FAMILY)/adc.c \ peripherals/samd/$(PERIPHERALS_CHIP_FAMILY)/cache.c \ peripherals/samd/$(PERIPHERALS_CHIP_FAMILY)/clocks.c \ @@ -319,8 +309,24 @@ SRC_C += \ peripherals/samd/external_interrupts.c \ peripherals/samd/sercom.c \ peripherals/samd/timers.c \ + +$(patsubst $(SRC_PERIPHERALS),%.c,%.o): CFLAGS += -Wno-missing-prototypes + +SRC_C += \ + audio_dma.c \ + background.c \ + bindings/samd/Clock.c \ + bindings/samd/__init__.c \ + boards/$(BOARD)/board.c \ + boards/$(BOARD)/pins.c \ + eic_handler.c \ + fatfs_port.c \ + freetouch/adafruit_ptc.c \ + lib/tinyusb/src/portable/microchip/samd/dcd_samd.c \ + mphalport.c \ reset.c \ timer_handler.c \ + $(SRC_PERIPHERALS) \ # This is an OR because it filters to any 1s and then checks to see if it is not # empty. diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index d2211d4c8f..5038d2550c 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -556,7 +556,7 @@ uint64_t port_get_raw_ticks(uint8_t *subticks) { return overflow_count + current_ticks / 16; } -void evsyshandler_common(void) { +static void evsyshandler_common(void) { #ifdef SAMD21 if (_tick_event_channel < EVSYS_SYNCH_NUM && event_interrupt_active(_tick_event_channel)) { supervisor_tick(); diff --git a/shared-module/usb_cdc/Serial.c b/shared-module/usb_cdc/Serial.c index 3b402bf70c..7f1bc75a53 100644 --- a/shared-module/usb_cdc/Serial.c +++ b/shared-module/usb_cdc/Serial.c @@ -25,6 +25,7 @@ */ #include "shared/runtime/interrupt_char.h" +#include "shared-bindings/usb_cdc/Serial.h" #include "shared-module/usb_cdc/Serial.h" #include "supervisor/shared/tick.h" diff --git a/shared-module/usb_midi/PortIn.c b/shared-module/usb_midi/PortIn.c index e00a5124cf..b16b77cf97 100644 --- a/shared-module/usb_midi/PortIn.c +++ b/shared-module/usb_midi/PortIn.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "shared-bindings/usb_midi/PortIn.h" #include "shared-module/usb_midi/PortIn.h" #include "supervisor/shared/translate.h" #include "tusb.h" diff --git a/shared-module/usb_midi/PortOut.c b/shared-module/usb_midi/PortOut.c index f453a67671..4005d8b77d 100644 --- a/shared-module/usb_midi/PortOut.c +++ b/shared-module/usb_midi/PortOut.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "shared-bindings/usb_midi/PortOut.h" #include "shared-module/usb_midi/PortOut.h" #include "supervisor/shared/translate.h" #include "tusb.h" diff --git a/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c index a59a6e85f5..e53edb506f 100644 --- a/supervisor/shared/background_callback.c +++ b/supervisor/shared/background_callback.c @@ -30,6 +30,7 @@ #include "py/mpconfig.h" #include "supervisor/background_callback.h" #include "supervisor/linker.h" +#include "supervisor/port.h" #include "supervisor/shared/tick.h" #include "shared-bindings/microcontroller/__init__.h" diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 56a7f25b30..33d618276c 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -495,7 +495,7 @@ static int32_t convert_block_to_flash_addr(uint32_t block) { return -1; } -bool external_flash_read_block(uint8_t *dest, uint32_t block) { +static bool external_flash_read_block(uint8_t *dest, uint32_t block) { int32_t address = convert_block_to_flash_addr(block); if (address == -1) { // bad block number @@ -524,7 +524,7 @@ bool external_flash_read_block(uint8_t *dest, uint32_t block) { return read_flash(address, dest, FILESYSTEM_BLOCK_SIZE); } -bool external_flash_write_block(const uint8_t *data, uint32_t block) { +static bool external_flash_write_block(const uint8_t *data, uint32_t block) { // Non-MBR block, copy to cache int32_t address = convert_block_to_flash_addr(block); if (address == -1) { diff --git a/supervisor/shared/external_flash/qspi_flash.c b/supervisor/shared/external_flash/qspi_flash.c index dc16f3465b..293654ba79 100644 --- a/supervisor/shared/external_flash/qspi_flash.c +++ b/supervisor/shared/external_flash/qspi_flash.c @@ -27,6 +27,7 @@ #include "supervisor/spi_flash_api.h" #include "supervisor/shared/external_flash/common_commands.h" +#include "supervisor/shared/external_flash/qspi_flash.h" void check_quad_enable(const external_flash_device *device) { if (device->quad_enable_bit_mask == 0x00) { diff --git a/supervisor/shared/flash.c b/supervisor/shared/flash.c index bc7c1876dc..d96d433813 100644 --- a/supervisor/shared/flash.c +++ b/supervisor/shared/flash.c @@ -28,6 +28,7 @@ #include "extmod/vfs_fat.h" #include "py/runtime.h" #include "lib/oofatfs/ff.h" +#include "supervisor/flash.h" #include "supervisor/shared/tick.h" #define VFS_INDEX 0 @@ -46,7 +47,7 @@ STATIC mp_obj_t supervisor_flash_obj_make_new(const mp_obj_type_t *type, size_t return (mp_obj_t)&supervisor_flash_obj; } -uint32_t flash_get_block_count(void) { +static uint32_t flash_get_block_count(void) { return PART1_START_BLOCK + supervisor_flash_get_block_count(); } @@ -86,7 +87,7 @@ static void build_partition(uint8_t *buf, int boot, int type, uint32_t start_blo buf[15] = num_blocks >> 24; } -mp_uint_t flash_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks) { +static mp_uint_t flash_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks) { if (block_num == 0) { // fake the MBR so we can decide on our own partition table @@ -114,7 +115,7 @@ mp_uint_t flash_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_bloc volatile bool filesystem_dirty = false; -mp_uint_t flash_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks) { +static mp_uint_t flash_write_blocks(const uint8_t *src, uint32_t block_num, uint32_t num_blocks) { if (block_num == 0) { if (num_blocks > 1) { return 1; // error @@ -160,7 +161,7 @@ STATIC mp_obj_t supervisor_flash_obj_writeblocks(mp_obj_t self, mp_obj_t block_n } STATIC MP_DEFINE_CONST_FUN_OBJ_3(supervisor_flash_obj_writeblocks_obj, supervisor_flash_obj_writeblocks); -bool flash_ioctl(size_t cmd, mp_int_t *out_value) { +static bool flash_ioctl(size_t cmd, mp_int_t *out_value) { *out_value = 0; switch (cmd) { case MP_BLOCKDEV_IOCTL_INIT: diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c index 6c850f9b00..ebc0aef2d1 100644 --- a/supervisor/shared/micropython.c +++ b/supervisor/shared/micropython.c @@ -29,6 +29,7 @@ #include "supervisor/serial.h" #include "lib/oofatfs/ff.h" #include "py/mpconfig.h" +#include "py/mphal.h" #include "py/mpstate.h" #include "py/runtime.h" #include "py/stream.h" diff --git a/supervisor/shared/stack.c b/supervisor/shared/stack.c index f3077b46c3..d1dc66d18c 100644 --- a/supervisor/shared/stack.c +++ b/supervisor/shared/stack.c @@ -43,7 +43,7 @@ static size_t stack_length = 0; #define EXCEPTION_STACK_SIZE 1024 -void allocate_stack(void) { +static void allocate_stack(void) { if (port_has_fixed_stack()) { stack_limit = port_stack_get_limit(); diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 4ce884d7e1..40c1ef11e3 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -27,6 +27,7 @@ #include "supervisor/shared/tick.h" #include "shared/runtime/interrupt_char.h" +#include "py/mphal.h" #include "py/mpstate.h" #include "py/runtime.h" #include "supervisor/linker.h" @@ -63,7 +64,7 @@ static background_callback_t tick_callback; volatile uint64_t last_finished_tick = 0; -void supervisor_background_tasks(void *unused) { +static void supervisor_background_tasks(void *unused) { port_start_background_task(); assert_heap_ok(); diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c index 4986c09570..650be39673 100644 --- a/supervisor/shared/workflow.c +++ b/supervisor/shared/workflow.c @@ -26,6 +26,8 @@ #include #include "py/mpconfig.h" +#include "supervisor/workflow.h" +#include "supervisor/shared/workflow.h" #include "tusb.h" void supervisor_workflow_reset(void) { From fea781207b197c3d4d65fd2926ff94420572a0f0 Mon Sep 17 00:00:00 2001 From: Wellington Terumi Uemura Date: Wed, 10 Nov 2021 09:51:58 +0000 Subject: [PATCH 50/84] Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (1020 of 1020 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/ --- locale/pt_BR.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/locale/pt_BR.po b/locale/pt_BR.po index c17c9eb8c0..610dd1659d 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-09 17:54+0000\n" +"PO-Revision-Date: 2021-11-10 09:53+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -2713,7 +2713,7 @@ msgstr "a operação binário %q não foi implementada" #: shared-bindings/bitmaptools/__init__.c msgid "bitmap sizes must match" -msgstr "" +msgstr "os tamanhos do bitmap devem coincidir" #: extmod/modurandom.c msgid "bits must be 32 or less" @@ -4230,15 +4230,15 @@ msgstr "a paleta de origem é muito grande" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 2 or 65536" -msgstr "" +msgstr "o source_bitmap deve ter o value_count de 2 ou 65536" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 65536" -msgstr "" +msgstr "o source_bitmap deve ter o value_count de 65536" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 8" -msgstr "" +msgstr "o source_bitmap deve ter o value_count de 8" #: py/objstr.c msgid "start/end indices" @@ -4490,7 +4490,7 @@ msgstr "espaço de cores não compatível com GifWriter" #: shared-bindings/bitmaptools/__init__.c msgid "unsupported colorspace for dither" -msgstr "" +msgstr "espaço de cor não compatível para dither" #: py/objstr.c #, c-format From 6d2f4f59f82b09445ea32367e10918ae13b4b9e0 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:12:42 +0530 Subject: [PATCH 51/84] refactor traceback handling --- py/mpstate.h | 4 ---- py/objexcept.c | 29 +++++++++++++++-------------- py/runtime.c | 6 ++---- py/scheduler.c | 2 +- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/py/mpstate.h b/py/mpstate.h index 2f9dafd925..964a04f300 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -140,14 +140,10 @@ typedef struct _mp_state_vm_t { #if MICROPY_KBD_EXCEPTION // exception object of type KeyboardInterrupt mp_obj_exception_t mp_kbd_exception; - // traceback object to store traceback - mp_obj_traceback_t mp_kbd_traceback; #endif // exception object of type ReloadException mp_obj_exception_t mp_reload_exception; - // traceback object to store traceback - mp_obj_traceback_t mp_reload_traceback; // dictionary with loaded modules (may be exposed as sys.modules) mp_obj_dict_t mp_loaded_modules_dict; diff --git a/py/objexcept.c b/py/objexcept.c index c7e5cb7675..b8d7692b18 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -166,15 +166,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, siz // Populate the exception object o_exc->base.type = type; - - // Try to allocate memory for the traceback, with fallback to emergency traceback object - o_exc->traceback = m_new_obj_maybe(mp_obj_traceback_t); - if (o_exc->traceback == NULL) { - o_exc->traceback = &MP_STATE_VM(mp_emergency_traceback_obj); - } - - // Populate the traceback object - *o_exc->traceback = mp_const_empty_traceback_obj; + o_exc->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; mp_obj_tuple_t *o_tuple; if (n_args == 0) { @@ -228,7 +220,7 @@ void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { // store/delete attribute if (attr == MP_QSTR___traceback__) { if (dest[1] == mp_const_none) { - self->traceback->data = NULL; + self->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; } else { if (!mp_obj_is_type(dest[1], &mp_type_traceback)) { mp_raise_TypeError(MP_ERROR_TEXT("invalid traceback")); @@ -244,7 +236,7 @@ void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } else if (attr == MP_QSTR_value && self->base.type == &mp_type_StopIteration) { dest[0] = mp_obj_exception_get_value(self_in); } else if (attr == MP_QSTR___traceback__) { - dest[0] = (self->traceback->data) ? MP_OBJ_FROM_PTR(self->traceback) : mp_const_none; + dest[0] = (self->traceback) ? MP_OBJ_FROM_PTR(self->traceback) : mp_const_none; #if MICROPY_CPYTHON_COMPAT } else if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(self->base.type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { if (attr == MP_QSTR_errno) { @@ -552,14 +544,23 @@ bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type) { void mp_obj_exception_clear_traceback(mp_obj_t self_in) { mp_obj_exception_t *self = get_native_exception(self_in); - // just set the traceback to the null object + // just set the traceback to the empty traceback object // we don't want to call any memory management functions here - self->traceback->data = NULL; + self->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; } void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block) { mp_obj_exception_t *self = get_native_exception(self_in); + // Try to allocate memory for the traceback, with fallback to emergency traceback object + + if (self->traceback == NULL || self->traceback == (mp_obj_traceback_t *)&mp_const_empty_traceback_obj) { + self->traceback = m_new_obj_maybe(mp_obj_traceback_t); + if (self->traceback == NULL) { + self->traceback = &MP_STATE_VM(mp_emergency_traceback_obj); + } + } + // append this traceback info to traceback data // if memory allocation fails (eg because gc is locked), just return @@ -613,7 +614,7 @@ void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qs void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values) { mp_obj_exception_t *self = get_native_exception(self_in); - if (self->traceback->data == NULL) { + if (self->traceback == NULL) { *n = 0; *values = NULL; } else { diff --git a/py/runtime.c b/py/runtime.c index ac02f7074c..1554a70231 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -80,14 +80,12 @@ void mp_init(void) { // initialise the exception object for raising KeyboardInterrupt MP_STATE_VM(mp_kbd_exception).base.type = &mp_type_KeyboardInterrupt; MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj; - MP_STATE_VM(mp_kbd_exception).traceback = &MP_STATE_VM(mp_kbd_traceback); - *MP_STATE_VM(mp_kbd_exception).traceback = mp_const_empty_traceback_obj; + MP_STATE_VM(mp_kbd_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; #endif MP_STATE_VM(mp_reload_exception).base.type = &mp_type_ReloadException; MP_STATE_VM(mp_reload_exception).args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj; - MP_STATE_VM(mp_reload_exception).traceback = &MP_STATE_VM(mp_reload_traceback); - *MP_STATE_VM(mp_reload_exception).traceback = mp_const_empty_traceback_obj; + MP_STATE_VM(mp_reload_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; // call port specific initialization if any #ifdef MICROPY_PORT_INIT_FUNC diff --git a/py/scheduler.c b/py/scheduler.c index 8e150f41ed..1fd5daeab1 100644 --- a/py/scheduler.c +++ b/py/scheduler.c @@ -42,7 +42,7 @@ void MICROPY_WRAP_MP_SCHED_EXCEPTION(mp_sched_exception)(mp_obj_t exc) { #if MICROPY_KBD_EXCEPTION // This function may be called asynchronously at any time so only do the bare minimum. void MICROPY_WRAP_MP_SCHED_KEYBOARD_INTERRUPT(mp_sched_keyboard_interrupt)(void) { - MP_STATE_VM(mp_kbd_exception).traceback->data = NULL; + MP_STATE_VM(mp_kbd_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; mp_sched_exception(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); } #endif From 53a68f7ce6cd04c87b82df3103cf7660d363bcd4 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 10 Nov 2021 20:24:46 +0530 Subject: [PATCH 52/84] turn off `onewireio` on `arduino_nano_33_iot` --- ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk index a61e321b29..c940bc02ef 100644 --- a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk @@ -10,4 +10,5 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 +CIRCUITPY_ONEWIREIO = 0 CIRCUITPY_RAINBOWIO = 0 From d174b38ac092673dd4e1a4a13adcea5cdb270526 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 1 Nov 2021 16:02:11 -0400 Subject: [PATCH 53/84] enable running asyncio --- extmod/moduselect.c | 13 +++++++++---- py/circuitpy_mpconfig.h | 7 +++++++ py/circuitpy_mpconfig.mk | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/extmod/moduselect.c b/extmod/moduselect.c index 1b9617fca9..c8f5e57363 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -150,7 +150,7 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { mp_map_deinit(&poll_map); return mp_obj_new_tuple(3, list_array); } - MICROPY_EVENT_POLL_HOOK + RUN_BACKGROUND_TASKS; } } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select); @@ -229,7 +229,7 @@ STATIC mp_uint_t poll_poll_internal(uint n_args, const mp_obj_t *args) { if (n_ready > 0 || (timeout != (mp_uint_t)-1 && mp_hal_ticks_ms() - start_tick >= timeout)) { break; } - MICROPY_EVENT_POLL_HOOK + RUN_BACKGROUND_TASKS; } return n_ready; @@ -318,10 +318,13 @@ STATIC MP_DEFINE_CONST_DICT(poll_locals_dict, poll_locals_dict_table); STATIC const mp_obj_type_t mp_type_poll = { { &mp_type_type }, + .flags = MP_TYPE_FLAG_EXTENDED, .name = MP_QSTR_poll, - .getiter = mp_identity_getiter, - .iternext = poll_iternext, .locals_dict = (void *)&poll_locals_dict, + MP_TYPE_EXTENDED_FIELDS( + .getiter = mp_identity_getiter, + .iternext = poll_iternext, + ), }; // poll() @@ -354,4 +357,6 @@ const mp_obj_module_t mp_module_uselect = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; +MP_REGISTER_MODULE(MP_QSTR_select, mp_module_uselect, MICROPY_PY_USELECT); + #endif // MICROPY_PY_USELECT diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 3c6d5c6110..ad5797b4d8 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -45,6 +45,13 @@ // free bytes. // #define MICROPY_ALLOC_PARSE_RULE_INIT (64) +// These critical-section macros are used only a few places in MicroPython, but +// we need to provide actual implementations. +extern void common_hal_mcu_disable_interrupts(void); +extern void common_hal_mcu_enable_interrupts(void); +#define MICROPY_BEGIN_ATOMIC_SECTION() (common_hal_mcu_disable_interrupts(), 0) +#define MICROPY_END_ATOMIC_SECTION(state) ((void)state, common_hal_mcu_enable_interrupts()) + // Sorted alphabetically for easy finding. // // default is 128; consider raising to reduce fragmentation. diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 04f0778290..ccb9daf5eb 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -36,6 +36,20 @@ CFLAGS += -DCIRCUITPY_FULL_BUILD=$(CIRCUITPY_FULL_BUILD) MICROPY_PY_ASYNC_AWAIT ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT) +# uasyncio +# By default, include uasyncio if async/await are available. +MICROPY_PY_UASYNCIO ?= $(MICROPY_PY_ASYNC_AWAIT) +CFLAGS += -DMICROPY_PY_UASYNCIO=$(MICROPY_PY_UASYNCIO) + +# uasyncio normally needs select +MICROPY_PY_USELECT ?= $(MICROPY_PY_UASYNCIO) +CFLAGS += -DMICROPY_PY_USELECT=$(MICROPY_PY_USELECT) + +# enable select.select if select is enabled. +MICROPY_PY_USELECT_SELECT ?= $(MICROPY_PY_USELECT) +CFLAGS += -DMICROPY_PY_USELECT_SELECT=$(MICROPY_PY_USELECT_SELECT) + + CIRCUITPY_AESIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO) From 621953c9609f458611e9d7d72f05e4bd840eaa37 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Nov 2021 08:42:21 -0600 Subject: [PATCH 54/84] Additional missing-prototypes fixes I think this correctly enables missing-prototypes in atmel-samd and raspberrypi ports. --- .../common-hal/_bleio/CharacteristicBuffer.c | 1 + .../ble_hci/common-hal/_bleio/Connection.h | 1 + devices/ble_hci/common-hal/_bleio/att.c | 127 +----------------- ports/atmel-samd/Makefile | 4 +- .../atmel-samd/common-hal/audiobusio/PDMIn.c | 3 - ports/atmel-samd/common-hal/busio/__init__.c | 1 + ports/atmel-samd/common-hal/countio/Counter.c | 1 + .../common-hal/microcontroller/Processor.c | 1 + ports/atmel-samd/common-hal/nvm/ByteArray.c | 7 +- ports/atmel-samd/common-hal/os/__init__.c | 4 +- ports/atmel-samd/common-hal/ps2io/Ps2.c | 6 +- .../atmel-samd/common-hal/pulseio/PulseOut.c | 2 +- ports/atmel-samd/common-hal/pwmio/PWMOut.c | 2 +- .../common-hal/rotaryio/IncrementalEncoder.c | 1 + ports/atmel-samd/common-hal/rtc/RTC.c | 1 + .../common-hal/watchdog/WatchDogTimer.c | 2 +- ports/raspberrypi/Makefile | 2 +- .../bindings/rp2pio/StateMachine.c | 2 +- .../boards/adafruit_macropad_rp2040/board.c | 1 + .../common-hal/alarm/SleepMemory.c | 1 + .../common-hal/alarm/pin/PinAlarm.c | 2 +- .../common-hal/alarm/time/TimeAlarm.c | 2 +- .../common-hal/analogio/AnalogIn.c | 1 + .../raspberrypi/common-hal/audiobusio/PDMIn.c | 4 - .../raspberrypi/common-hal/countio/Counter.c | 2 +- .../raspberrypi/common-hal/countio/Counter.h | 2 +- .../imagecapture/ParallelImageCapture.c | 2 +- .../common-hal/microcontroller/Processor.c | 1 + ports/raspberrypi/common-hal/nvm/ByteArray.c | 7 +- ports/raspberrypi/common-hal/os/__init__.c | 4 +- .../raspberrypi/common-hal/pulseio/PulseIn.c | 3 +- .../raspberrypi/common-hal/pulseio/PulseIn.h | 2 +- .../raspberrypi/common-hal/pulseio/PulseOut.c | 2 +- .../common-hal/rotaryio/IncrementalEncoder.c | 1 + .../common-hal/rp2pio/StateMachine.c | 4 +- ports/raspberrypi/common-hal/rtc/RTC.c | 1 + ports/raspberrypi/supervisor/internal_flash.c | 1 + ports/raspberrypi/supervisor/port.c | 1 + py/circuitpy_defns.mk | 3 +- shared-bindings/_bleio/CharacteristicBuffer.h | 2 +- shared-bindings/_bleio/ScanEntry.h | 2 +- shared-bindings/_eve/__init__.h | 2 + shared-bindings/alarm/__init__.c | 2 +- shared-bindings/alarm/time/TimeAlarm.c | 3 +- shared-bindings/board/__init__.h | 4 + shared-bindings/busio/UART.c | 2 +- shared-bindings/os/__init__.c | 18 +-- shared-bindings/sdcardio/SDCard.c | 10 +- shared-bindings/sdioio/SDCard.c | 4 +- shared-bindings/storage/__init__.c | 10 +- shared-bindings/time/__init__.c | 2 +- shared-module/_bleio/ScanEntry.c | 1 + shared-module/_eve/__init__.c | 1 + shared-module/adafruit_pixelbuf/PixelBuf.c | 8 +- shared-module/audiocore/WaveFile.c | 8 -- shared-module/audiomixer/MixerVoice.c | 1 + shared-module/audiomp3/MP3Decoder.c | 4 - shared-module/bitmaptools/__init__.c | 11 -- shared-module/board/__init__.c | 2 + shared-module/displayio/EPaperDisplay.c | 8 +- shared-module/displayio/TileGrid.c | 4 +- shared-module/keypad/EventQueue.c | 1 + shared-module/msgpack/__init__.c | 2 + shared-module/random/__init__.c | 1 + shared-module/rotaryio/IncrementalEncoder.c | 1 + shared-module/sdcardio/SDCard.c | 7 +- .../sharpdisplay/SharpMemoryFramebuffer.c | 10 +- shared-module/struct/__init__.c | 9 +- shared-module/terminalio/Terminal.c | 1 + shared-module/time/__init__.c | 1 + shared-module/vectorio/Rectangle.c | 5 - shared/runtime/interrupt_char.c | 1 + shared/runtime/sys_stdio_mphal.c | 2 +- 73 files changed, 123 insertions(+), 242 deletions(-) diff --git a/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c b/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c index bb6b8788b6..0d87f03ae3 100644 --- a/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c +++ b/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c @@ -33,6 +33,7 @@ #include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/CharacteristicBuffer.h" #include "supervisor/shared/tick.h" #include "common-hal/_bleio/CharacteristicBuffer.h" diff --git a/devices/ble_hci/common-hal/_bleio/Connection.h b/devices/ble_hci/common-hal/_bleio/Connection.h index 2933bb87a5..185a8b3517 100644 --- a/devices/ble_hci/common-hal/_bleio/Connection.h +++ b/devices/ble_hci/common-hal/_bleio/Connection.h @@ -85,5 +85,6 @@ typedef struct { uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self); mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *connection); bleio_connection_internal_t *bleio_conn_handle_to_connection(uint16_t conn_handle); +void bleio_connection_clear(bleio_connection_internal_t *self); #endif // MICROPY_INCLUDED_BLE_HCI_COMMON_HAL_CONNECTION_H diff --git a/devices/ble_hci/common-hal/_bleio/att.c b/devices/ble_hci/common-hal/_bleio/att.c index b0fc884e00..ff3294a865 100644 --- a/devices/ble_hci/common-hal/_bleio/att.c +++ b/devices/ble_hci/common-hal/_bleio/att.c @@ -857,20 +857,6 @@ STATIC void process_find_info_req(uint16_t conn_handle, uint16_t mtu, uint8_t dl } } -int att_find_info_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint8_t response_buffer[]) { - struct __packed req { - struct bt_att_hdr h; - struct bt_att_find_info_req r; - } req = { { - .code = BT_ATT_OP_FIND_INFO_REQ, - }, { - .start_handle = start_handle, - .end_handle = end_handle, - }}; - - return send_req_wait_for_rsp(conn_handle, sizeof(req), (uint8_t *)&req, response_buffer); -} - STATIC void process_find_info_rsp(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) { if (dlen < 2) { return; // invalid, drop @@ -925,7 +911,7 @@ STATIC void process_find_type_req(uint16_t conn_handle, uint16_t mtu, uint8_t dl } } -void process_read_group_req(uint16_t conn_handle, uint16_t mtu, uint8_t dlen, uint8_t data[]) { +STATIC void process_read_group_req(uint16_t conn_handle, uint16_t mtu, uint8_t dlen, uint8_t data[]) { struct bt_att_read_group_req *req = (struct bt_att_read_group_req *)data; uint16_t type_uuid = req->uuid[0] | (req->uuid[1] << 8); @@ -1009,25 +995,6 @@ void process_read_group_req(uint16_t conn_handle, uint16_t mtu, uint8_t dlen, ui } } -int att_read_group_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid, uint8_t response_buffer[]) { - - typedef struct __packed { - struct bt_att_hdr h; - struct bt_att_read_group_req r; - } req_t; - - uint8_t req_bytes[sizeof(req_t) + sizeof(uuid)]; - req_t *req = (req_t *)req_bytes; - - req->h.code = BT_ATT_OP_READ_GROUP_REQ; - req->r.start_handle = start_handle; - req->r.end_handle = end_handle; - req->r.uuid[0] = uuid & 0xff; - req->r.uuid[1] = uuid >> 8; - - return send_req_wait_for_rsp(conn_handle, sizeof(req_bytes), req_bytes, response_buffer); -} - STATIC void process_read_group_rsp(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) { if (dlen < 2) { return; // invalid, drop @@ -1305,24 +1272,6 @@ STATIC void process_read_type_req(uint16_t conn_handle, uint16_t mtu, uint8_t dl } } -int att_read_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint16_t type, uint8_t response_buffer[]) { - typedef struct __packed { - struct bt_att_hdr h; - struct bt_att_read_type_req r; - } req_t; - - uint8_t req_bytes[sizeof(req_t) + sizeof(type)]; - req_t *req = (req_t *)req_bytes; - - req->h.code = BT_ATT_OP_READ_TYPE_REQ; - req->r.start_handle = start_handle; - req->r.end_handle = end_handle; - req->r.uuid[0] = type & 0xff; - req->r.uuid[1] = type >> 8; - - return send_req_wait_for_rsp(conn_handle, sizeof(req_bytes), req_bytes, response_buffer); -} - STATIC void process_read_type_rsp(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) { if (dlen < 1) { return; // invalid, drop @@ -1713,77 +1662,3 @@ void att_process_data(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) { break; } } - -// FIX Do we need all of these? -void check_att_err(uint8_t err) { - const compressed_string_t *msg = NULL; - switch (err) { - case 0: - return; - case BT_ATT_ERR_INVALID_HANDLE: - msg = translate("Invalid handle"); - break; - case BT_ATT_ERR_READ_NOT_PERMITTED: - msg = translate("Read not permitted"); - break; - case BT_ATT_ERR_WRITE_NOT_PERMITTED: - msg = translate("Write not permitted"); - break; - case BT_ATT_ERR_INVALID_PDU: - msg = translate("Invalid PDU"); - break; - case BT_ATT_ERR_NOT_SUPPORTED: - msg = translate("Not supported"); - break; - case BT_ATT_ERR_INVALID_OFFSET: - msg = translate("Invalid offset"); - break; - case BT_ATT_ERR_PREPARE_QUEUE_FULL: - msg = translate("Prepare queue full"); - break; - case BT_ATT_ERR_ATTRIBUTE_NOT_FOUND: - msg = translate("Attribute not found"); - break; - case BT_ATT_ERR_ATTRIBUTE_NOT_LONG: - msg = translate("Attribute not long"); - break; - case BT_ATT_ERR_ENCRYPTION_KEY_SIZE: - msg = translate("Encryption key size"); - break; - case BT_ATT_ERR_INVALID_ATTRIBUTE_LEN: - msg = translate("Invalid attribute length"); - break; - case BT_ATT_ERR_UNLIKELY: - msg = translate("Unlikely"); - break; - case BT_ATT_ERR_UNSUPPORTED_GROUP_TYPE: - msg = translate("Unsupported group type"); - break; - case BT_ATT_ERR_INSUFFICIENT_RESOURCES: - msg = translate("Insufficient resources"); - break; - case BT_ATT_ERR_DB_OUT_OF_SYNC: - msg = translate("DB out of sync"); - break; - case BT_ATT_ERR_VALUE_NOT_ALLOWED: - msg = translate("Value not allowed"); - break; - } - if (msg) { - mp_raise_bleio_BluetoothError(msg); - } - - switch (err) { - case BT_ATT_ERR_AUTHENTICATION: - msg = translate("Insufficient authentication"); - break; - case BT_ATT_ERR_INSUFFICIENT_ENCRYPTION: - msg = translate("Insufficient encryption"); - break; - } - if (msg) { - mp_raise_bleio_SecurityError(msg); - } - - mp_raise_bleio_BluetoothError(translate("Unknown ATT error: 0x%02x"), err); -} diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 721cfd4f0a..045f3741eb 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -291,7 +291,7 @@ $(BUILD)/asf4/$(CHIP_FAMILY)/hpl/sdhc/hpl_sdhc.o: CFLAGS += -Wno-cast-align -Wno endif SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF)) -$(patsubst $(SRC_ASF),%.c,%.o): CFLAGS += -Wno-missing-prototypes +$(patsubst %.c,$(BUILD)/%.o,$(SRC_ASF)): CFLAGS += -Wno-missing-prototypes SRC_PERIPHERALS := \ peripherals/samd/$(PERIPHERALS_CHIP_FAMILY)/adc.c \ @@ -310,7 +310,7 @@ SRC_PERIPHERALS := \ peripherals/samd/sercom.c \ peripherals/samd/timers.c \ -$(patsubst $(SRC_PERIPHERALS),%.c,%.o): CFLAGS += -Wno-missing-prototypes +$(patsubst %.c,$(BUILD)/%.o,$(SRC_PERIPHERALS)): CFLAGS += -Wno-missing-prototypes SRC_C += \ audio_dma.c \ diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index e00d69c848..e6363395a6 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -485,6 +485,3 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se return values_output; } - -void common_hal_audiobusio_pdmin_record_to_file(audiobusio_pdmin_obj_t* self, uint8_t* buffer, uint32_t length) { -} diff --git a/ports/atmel-samd/common-hal/busio/__init__.c b/ports/atmel-samd/common-hal/busio/__init__.c index 8ec549e931..8d1f085ffa 100644 --- a/ports/atmel-samd/common-hal/busio/__init__.c +++ b/ports/atmel-samd/common-hal/busio/__init__.c @@ -25,6 +25,7 @@ */ #include "samd/sercom.h" +#include "common-hal/busio/__init__.h" static bool never_reset_sercoms[SERCOM_INST_NUM]; diff --git a/ports/atmel-samd/common-hal/countio/Counter.c b/ports/atmel-samd/common-hal/countio/Counter.c index 4531a4ed8c..e4df55eba6 100644 --- a/ports/atmel-samd/common-hal/countio/Counter.c +++ b/ports/atmel-samd/common-hal/countio/Counter.c @@ -1,5 +1,6 @@ #include "common-hal/countio/Counter.h" +#include "shared-bindings/countio/Counter.h" #include "atmel_start_pins.h" diff --git a/ports/atmel-samd/common-hal/microcontroller/Processor.c b/ports/atmel-samd/common-hal/microcontroller/Processor.c index e9831c953a..29d6612ad8 100644 --- a/ports/atmel-samd/common-hal/microcontroller/Processor.c +++ b/ports/atmel-samd/common-hal/microcontroller/Processor.c @@ -65,6 +65,7 @@ #include "py/mphal.h" #include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" #include "samd/adc.h" diff --git a/ports/atmel-samd/common-hal/nvm/ByteArray.c b/ports/atmel-samd/common-hal/nvm/ByteArray.c index 9d711d3413..e6f77bb048 100644 --- a/ports/atmel-samd/common-hal/nvm/ByteArray.c +++ b/ports/atmel-samd/common-hal/nvm/ByteArray.c @@ -25,6 +25,7 @@ */ #include "common-hal/nvm/ByteArray.h" +#include "shared-bindings/nvm/ByteArray.h" #include "hal_flash.h" @@ -33,11 +34,11 @@ #include #include -uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { +uint32_t common_hal_nvm_bytearray_get_length(const nvm_bytearray_obj_t *self) { return self->len; } -bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, +bool common_hal_nvm_bytearray_set_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) { // We don't use features that use any advanced NVMCTRL features so we can fake the descriptor // whenever we need it instead of storing it long term. @@ -49,7 +50,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, } // NVM memory is memory mapped so reading it is easy. -void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, +void common_hal_nvm_bytearray_get_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint32_t len, uint8_t *values) { memcpy(values, self->start_address + start_index, len); } diff --git a/ports/atmel-samd/common-hal/os/__init__.c b/ports/atmel-samd/common-hal/os/__init__.c index 6c554bff30..f0e20bdfcf 100644 --- a/ports/atmel-samd/common-hal/os/__init__.c +++ b/ports/atmel-samd/common-hal/os/__init__.c @@ -30,6 +30,8 @@ #include "py/objtuple.h" #include "py/qstr.h" +#include "shared-bindings/os/__init__.h" + #ifdef SAM_D5X_E5X #include "hal/include/hal_rand_sync.h" #endif @@ -66,7 +68,7 @@ mp_obj_t common_hal_os_uname(void) { return (mp_obj_t)&os_uname_info_obj; } -bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { +bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #ifdef SAM_D5X_E5X hri_mclk_set_APBCMASK_TRNG_bit(MCLK); struct rand_sync_desc random; diff --git a/ports/atmel-samd/common-hal/ps2io/Ps2.c b/ports/atmel-samd/common-hal/ps2io/Ps2.c index f07cadf417..6e2fb58e51 100644 --- a/ports/atmel-samd/common-hal/ps2io/Ps2.c +++ b/ports/atmel-samd/common-hal/ps2io/Ps2.c @@ -26,6 +26,7 @@ */ #include "common-hal/ps2io/Ps2.h" +#include "shared-bindings/ps2io/Ps2.h" #include @@ -302,11 +303,6 @@ uint16_t common_hal_ps2io_ps2_get_len(ps2io_ps2_obj_t *self) { return self->bufcount; } -bool common_hal_ps2io_ps2_get_paused(ps2io_ps2_obj_t *self) { - uint32_t mask = 1 << self->channel; - return (EIC->INTENSET.reg & (mask << EIC_INTENSET_EXTINT_Pos)) == 0; -} - int16_t common_hal_ps2io_ps2_popleft(ps2io_ps2_obj_t *self) { common_hal_mcu_disable_interrupts(); if (self->bufcount <= 0) { diff --git a/ports/atmel-samd/common-hal/pulseio/PulseOut.c b/ports/atmel-samd/common-hal/pulseio/PulseOut.c index b72e0d1f43..b0407a1136 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseOut.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseOut.c @@ -59,7 +59,7 @@ static void turn_off(__IO PORT_PINCFG_Type *pincfg) { pincfg->reg = PORT_PINCFG_RESETVALUE; } -void pulse_finish(void) { +STATIC void pulse_finish(void) { pulse_index++; if (active_pincfg == NULL) { diff --git a/ports/atmel-samd/common-hal/pwmio/PWMOut.c b/ports/atmel-samd/common-hal/pwmio/PWMOut.c index fa6a2d3f47..eaec10463d 100644 --- a/ports/atmel-samd/common-hal/pwmio/PWMOut.c +++ b/ports/atmel-samd/common-hal/pwmio/PWMOut.c @@ -91,7 +91,7 @@ static uint8_t tcc_channel(const pin_timer_t *t) { return t->wave_output % tcc_cc_num[t->index]; } -bool channel_ok(const pin_timer_t *t) { +STATIC bool channel_ok(const pin_timer_t *t) { uint8_t channel_bit = 1 << tcc_channel(t); return (!t->is_tc && ((tcc_channels[t->index] & channel_bit) == 0)) || t->is_tc; diff --git a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c index dc9cf65334..856fe04dbc 100644 --- a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -25,6 +25,7 @@ */ #include "common-hal/rotaryio/IncrementalEncoder.h" +#include "shared-bindings/rotaryio/IncrementalEncoder.h" #include "shared-module/rotaryio/IncrementalEncoder.h" #include "atmel_start_pins.h" diff --git a/ports/atmel-samd/common-hal/rtc/RTC.c b/ports/atmel-samd/common-hal/rtc/RTC.c index 65d7d94220..e2a67bd174 100644 --- a/ports/atmel-samd/common-hal/rtc/RTC.c +++ b/ports/atmel-samd/common-hal/rtc/RTC.c @@ -35,6 +35,7 @@ #include "py/runtime.h" #include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" +#include "shared-bindings/rtc/RTC.h" #include "supervisor/port.h" #include "supervisor/shared/translate.h" diff --git a/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c index 329242887c..2091b7d302 100644 --- a/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c +++ b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c @@ -50,7 +50,7 @@ mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) { return self->timeout; } -void setup_wdt(watchdog_watchdogtimer_obj_t *self, int setting) { +STATIC void setup_wdt(watchdog_watchdogtimer_obj_t *self, int setting) { OSC32KCTRL->OSCULP32K.bit.EN1K = 1; // Enable out 1K (for WDT) // disable watchdog for config diff --git a/ports/raspberrypi/Makefile b/ports/raspberrypi/Makefile index 2739bf6547..28e28d6269 100644 --- a/ports/raspberrypi/Makefile +++ b/ports/raspberrypi/Makefile @@ -132,7 +132,7 @@ endif # Remove -Wno-stringop-overflow after we can test with CI's GCC 10. Mac's looks weird. DISABLE_WARNINGS = -Wno-stringop-overflow -Wno-unused-function -Wno-unused-variable -Wno-strict-overflow -Wno-cast-align -Wno-strict-prototypes -Wno-nested-externs -Wno-double-promotion -Wno-sign-compare -CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) +CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $(DISABLE_WARNINGS) -Werror=missing-prototypes CFLAGS += \ -march=armv6-m \ diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 39b975ff8d..61e526b226 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -617,7 +617,7 @@ const mp_obj_type_t rp2pio_statemachine_type = { .locals_dict = (mp_obj_dict_t *)&rp2pio_statemachine_locals_dict, }; -rp2pio_statemachine_obj_t *validate_obj_is_statemachine(mp_obj_t obj) { +static rp2pio_statemachine_obj_t *validate_obj_is_statemachine(mp_obj_t obj) { if (!mp_obj_is_type(obj, &rp2pio_statemachine_type)) { mp_raise_TypeError_varg(translate("Expected a %q"), rp2pio_statemachine_type.name); } diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c index 1e16629f30..2d452244f7 100644 --- a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c @@ -31,6 +31,7 @@ #include "shared-bindings/busio/SPI.h" #include "shared-bindings/microcontroller/Pin.h" #include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "supervisor/board.h" #include "supervisor/shared/board.h" displayio_fourwire_obj_t board_display_obj; diff --git a/ports/raspberrypi/common-hal/alarm/SleepMemory.c b/ports/raspberrypi/common-hal/alarm/SleepMemory.c index b8fcdfbccf..c1765296dc 100644 --- a/ports/raspberrypi/common-hal/alarm/SleepMemory.c +++ b/ports/raspberrypi/common-hal/alarm/SleepMemory.c @@ -28,6 +28,7 @@ #include "py/runtime.h" #include "common-hal/alarm/SleepMemory.h" +#include "shared-bindings/alarm/SleepMemory.h" void alarm_sleep_memory_reset(void) { } diff --git a/ports/raspberrypi/common-hal/alarm/pin/PinAlarm.c b/ports/raspberrypi/common-hal/alarm/pin/PinAlarm.c index 276e2e409a..53cbfca57b 100644 --- a/ports/raspberrypi/common-hal/alarm/pin/PinAlarm.c +++ b/ports/raspberrypi/common-hal/alarm/pin/PinAlarm.c @@ -42,7 +42,7 @@ STATIC bool _pinalarm_set = false; #define GPIO_IRQ_ALL_EVENTS 0x15u -void gpio_callback(uint gpio, uint32_t events) { +STATIC void gpio_callback(uint gpio, uint32_t events) { alarm_triggered_pins |= (1 << gpio); woke_up = true; diff --git a/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c b/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c index 65c2b680d8..16ac8fc31e 100644 --- a/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c +++ b/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -37,7 +37,7 @@ STATIC bool woke_up = false; STATIC bool _timealarm_set = false; -void timer_callback(void) { +STATIC void timer_callback(void) { woke_up = true; } diff --git a/ports/raspberrypi/common-hal/analogio/AnalogIn.c b/ports/raspberrypi/common-hal/analogio/AnalogIn.c index 7db2956b03..1d77630063 100644 --- a/ports/raspberrypi/common-hal/analogio/AnalogIn.c +++ b/ports/raspberrypi/common-hal/analogio/AnalogIn.c @@ -25,6 +25,7 @@ */ #include "common-hal/analogio/AnalogIn.h" +#include "shared-bindings/analogio/AnalogIn.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" diff --git a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c index 323a3dfbc8..f2775c2543 100644 --- a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c +++ b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c @@ -171,7 +171,3 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t *se return output_count; } - -void common_hal_audiobusio_pdmin_record_to_file(audiobusio_pdmin_obj_t *self, uint8_t *buffer, uint32_t length) { - -} diff --git a/ports/raspberrypi/common-hal/countio/Counter.c b/ports/raspberrypi/common-hal/countio/Counter.c index 3d2d291b99..bbf71f996e 100644 --- a/ports/raspberrypi/common-hal/countio/Counter.c +++ b/ports/raspberrypi/common-hal/countio/Counter.c @@ -95,7 +95,7 @@ void common_hal_countio_counter_reset(countio_counter_obj_t *self) { self->count = 0; } -void counter_interrupt_handler() { +void counter_interrupt_handler(void) { uint32_t mask = pwm_get_irq_status_mask(); uint8_t i = 1, pos = 1; diff --git a/ports/raspberrypi/common-hal/countio/Counter.h b/ports/raspberrypi/common-hal/countio/Counter.h index 78e00e0dd2..7469dd2d00 100644 --- a/ports/raspberrypi/common-hal/countio/Counter.h +++ b/ports/raspberrypi/common-hal/countio/Counter.h @@ -14,7 +14,7 @@ typedef struct { } countio_counter_obj_t; -void counter_interrupt_handler(); +void counter_interrupt_handler(void); void reset_countio(void); diff --git a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c index 280c87e234..9eabc9f967 100644 --- a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c @@ -68,7 +68,7 @@ /* .wrap */ \ } -mcu_pin_obj_t *pin_from_number(uint8_t number) { +STATIC mcu_pin_obj_t *pin_from_number(uint8_t number) { const mp_map_t *mcu_map = &mcu_pin_globals.map; for (uint8_t i = 0; i < mcu_map->alloc; i++) { mp_obj_t val = mcu_map->table[i].value; diff --git a/ports/raspberrypi/common-hal/microcontroller/Processor.c b/ports/raspberrypi/common-hal/microcontroller/Processor.c index 68518d75b3..8c5bc7ba75 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Processor.c +++ b/ports/raspberrypi/common-hal/microcontroller/Processor.c @@ -29,6 +29,7 @@ #include "py/mphal.h" #include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" #include "src/rp2_common/hardware_adc/include/hardware/adc.h" diff --git a/ports/raspberrypi/common-hal/nvm/ByteArray.c b/ports/raspberrypi/common-hal/nvm/ByteArray.c index 94d98d686f..6908cbeabf 100644 --- a/ports/raspberrypi/common-hal/nvm/ByteArray.c +++ b/ports/raspberrypi/common-hal/nvm/ByteArray.c @@ -25,6 +25,7 @@ */ #include "common-hal/nvm/ByteArray.h" +#include "shared-bindings/nvm/ByteArray.h" #include @@ -36,7 +37,7 @@ static const uint32_t flash_binary_start = (uint32_t)&__flash_binary_start; #define RMV_OFFSET(addr) addr - flash_binary_start -uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { +uint32_t common_hal_nvm_bytearray_get_length(const nvm_bytearray_obj_t *self) { return self->len; } @@ -63,12 +64,12 @@ static void erase_and_write_sector(uint32_t address, uint32_t len, uint8_t *byte flash_range_program(RMV_OFFSET(CIRCUITPY_INTERNAL_NVM_START_ADDR), buffer, FLASH_SECTOR_SIZE); } -void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, +void common_hal_nvm_bytearray_get_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint32_t len, uint8_t *values) { memcpy(values, self->start_address + start_index, len); } -bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, +bool common_hal_nvm_bytearray_set_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) { uint8_t values_in[len]; common_hal_nvm_bytearray_get_bytes(self, start_index, len, values_in); diff --git a/ports/raspberrypi/common-hal/os/__init__.c b/ports/raspberrypi/common-hal/os/__init__.c index 25fe317abe..805418288a 100644 --- a/ports/raspberrypi/common-hal/os/__init__.c +++ b/ports/raspberrypi/common-hal/os/__init__.c @@ -30,6 +30,8 @@ #include "py/objtuple.h" #include "py/qstr.h" +#include "shared-bindings/os/__init__.h" + #include "lib/crypto-algorithms/sha256.h" #include "hardware/structs/rosc.h" @@ -104,7 +106,7 @@ static void get_random_bits(BYTE out[SHA256_BLOCK_SIZE]) { sha256_final(&context, out); } -bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { +bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #define ROSC_POWER_SAVE (1) // assume ROSC is not necessarily active all the time #if ROSC_POWER_SAVE uint32_t old_rosc_ctrl = rosc_hw->ctrl; diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.c b/ports/raspberrypi/common-hal/pulseio/PulseIn.c index 53dfa008b8..9d3f614987 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.c @@ -121,7 +121,8 @@ void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) { self->level_count = 0; self->buf_index = 0; } -void common_hal_pulseio_pulsein_interrupt(pulseio_pulsein_obj_t *self) { +void common_hal_pulseio_pulsein_interrupt(void *self_in) { + pulseio_pulsein_obj_t *self = self_in; uint32_t rxfifo = 0; diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.h b/ports/raspberrypi/common-hal/pulseio/PulseIn.h index 5386220911..f2c4fc0d06 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.h +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.h @@ -48,6 +48,6 @@ typedef struct { } pulseio_pulsein_obj_t; void pulsein_reset(void); -void common_hal_pulseio_pulsein_interrupt(); +void common_hal_pulseio_pulsein_interrupt(void *); #endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H diff --git a/ports/raspberrypi/common-hal/pulseio/PulseOut.c b/ports/raspberrypi/common-hal/pulseio/PulseOut.c index 2b4ab7185c..7704fdff6f 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseOut.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseOut.c @@ -41,7 +41,7 @@ volatile alarm_id_t cur_alarm = 0; -void pulse_finish(pulseio_pulseout_obj_t *self) { +static void pulse_finish(pulseio_pulseout_obj_t *self) { self->pulse_index++; // Turn pwm pin off by switching the GPIO mux to SIO (the cpu manual // control). diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c index 649c9421e0..1105d357c5 100644 --- a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c @@ -28,6 +28,7 @@ #include #include "common-hal/rotaryio/IncrementalEncoder.h" +#include "shared-bindings/rotaryio/IncrementalEncoder.h" #include "shared-module/rotaryio/IncrementalEncoder.h" #include "bindings/rp2pio/__init__.h" #include "bindings/rp2pio/StateMachine.h" diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index 27672f0de0..4479006d4e 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -70,7 +70,7 @@ static void rp2pio_statemachine_set_pull(uint32_t pull_pin_up, uint32_t pull_pin } } -void _reset_statemachine(PIO pio, uint8_t sm, bool leave_pins) { +STATIC void _reset_statemachine(PIO pio, uint8_t sm, bool leave_pins) { uint8_t pio_index = pio_get_index(pio); uint32_t program_id = _current_program_id[pio_index][sm]; if (program_id == 0) { @@ -587,7 +587,7 @@ bool common_hal_rp2pio_statemachine_deinited(rp2pio_statemachine_obj_t *self) { return self->state_machine == NUM_PIO_STATE_MACHINES; } -enum dma_channel_transfer_size _stride_to_dma_size(uint8_t stride) { +STATIC enum dma_channel_transfer_size _stride_to_dma_size(uint8_t stride) { switch (stride) { case 4: return DMA_SIZE_32; diff --git a/ports/raspberrypi/common-hal/rtc/RTC.c b/ports/raspberrypi/common-hal/rtc/RTC.c index 8647fc246c..9bd10abf70 100644 --- a/ports/raspberrypi/common-hal/rtc/RTC.c +++ b/ports/raspberrypi/common-hal/rtc/RTC.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ #include "shared-bindings/rtc/RTC.h" +#include "common-hal/rtc/RTC.h" #include diff --git a/ports/raspberrypi/supervisor/internal_flash.c b/ports/raspberrypi/supervisor/internal_flash.c index fa18f24fe0..c128cb74b2 100644 --- a/ports/raspberrypi/supervisor/internal_flash.c +++ b/ports/raspberrypi/supervisor/internal_flash.c @@ -39,6 +39,7 @@ #include "lib/oofatfs/ff.h" #include "shared-bindings/microcontroller/__init__.h" +#include "supervisor/flash.h" #include "supervisor/usb.h" #include "src/rp2040/hardware_structs/include/hardware/structs/sio.h" diff --git a/ports/raspberrypi/supervisor/port.c b/ports/raspberrypi/supervisor/port.c index fca6d6554c..5041250c0a 100644 --- a/ports/raspberrypi/supervisor/port.c +++ b/ports/raspberrypi/supervisor/port.c @@ -248,6 +248,7 @@ void port_idle_until_interrupt(void) { /** * \brief Default interrupt handler for unused IRQs. */ +extern void HardFault_Handler(void); // provide a prototype to avoid a missing-prototypes diagnostic __attribute__((used)) void HardFault_Handler(void) { #ifdef ENABLE_MICRO_TRACE_BUFFER // Turn off the micro trace buffer so we don't fill it up in the infinite diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index c258317d18..d4980d78fe 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -635,7 +635,7 @@ ifeq ($(CIRCUITPY_RGBMATRIX),1) SRC_MOD += $(addprefix lib/protomatter/src/, \ core.c \ ) -$(BUILD)/lib/protomatter/src/core.o: CFLAGS += -include "shared-module/rgbmatrix/allocator.h" -DCIRCUITPY -Wno-missing-braces +$(BUILD)/lib/protomatter/src/core.o: CFLAGS += -include "shared-module/rgbmatrix/allocator.h" -DCIRCUITPY -Wno-missing-braces -Wno-missing-prototypes endif # All possible sources are listed here, and are filtered by SRC_PATTERNS. @@ -685,6 +685,7 @@ $(addprefix lib/,\ libm/wf_tgamma.c \ ) endif +$(patsubst %.c,$(BUILD)/%.o,$(SRC_LIBM)): CFLAGS += -Wno-missing-prototypes endif SRC_CIRCUITPY_COMMON = \ diff --git a/shared-bindings/_bleio/CharacteristicBuffer.h b/shared-bindings/_bleio/CharacteristicBuffer.h index 1fd9dd838c..de85f019bc 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.h +++ b/shared-bindings/_bleio/CharacteristicBuffer.h @@ -44,7 +44,7 @@ uint32_t common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer uint32_t common_hal_bleio_characteristic_buffer_rx_characters_available(bleio_characteristic_buffer_obj_t *self); void common_hal_bleio_characteristic_buffer_clear_rx_buffer(bleio_characteristic_buffer_obj_t *self); bool common_hal_bleio_characteristic_buffer_deinited(bleio_characteristic_buffer_obj_t *self); -int common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self); +void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self); bool common_hal_bleio_characteristic_buffer_connected(bleio_characteristic_buffer_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTICBUFFER_H diff --git a/shared-bindings/_bleio/ScanEntry.h b/shared-bindings/_bleio/ScanEntry.h index 35473fd50e..b376433027 100644 --- a/shared-bindings/_bleio/ScanEntry.h +++ b/shared-bindings/_bleio/ScanEntry.h @@ -39,6 +39,6 @@ mp_obj_t common_hal_bleio_scanentry_get_advertisement_bytes(bleio_scanentry_obj_ mp_int_t common_hal_bleio_scanentry_get_rssi(bleio_scanentry_obj_t *self); bool common_hal_bleio_scanentry_get_connectable(bleio_scanentry_obj_t *self); bool common_hal_bleio_scanentry_get_scan_response(bleio_scanentry_obj_t *self); -bool common_hal_bleio_scanentry_matches(bleio_scanentry_obj_t *self, uint8_t *prefixes, size_t prefixes_len, bool match_all); +bool common_hal_bleio_scanentry_matches(bleio_scanentry_obj_t *self, const uint8_t *prefixes, size_t prefixes_len, bool match_all); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H diff --git a/shared-bindings/_eve/__init__.h b/shared-bindings/_eve/__init__.h index 883b1a15bf..96a10f010b 100644 --- a/shared-bindings/_eve/__init__.h +++ b/shared-bindings/_eve/__init__.h @@ -27,6 +27,8 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS__EVE___INIT___H #define MICROPY_INCLUDED_SHARED_BINDINGS__EVE___INIT___H +#include "shared-module/_eve/__init__.h" + void common_hal__eve_flush(common_hal__eve_t *eve); void common_hal__eve_add(common_hal__eve_t *eve, size_t len, void *buf); void common_hal__eve_Vertex2f(common_hal__eve_t *eve, mp_float_t x, mp_float_t y); diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 5d3c1a15f0..4160f6a334 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -70,7 +70,7 @@ // wake_alarm is implemented as a dictionary entry, so there's no code here. -void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { +STATIC void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { for (size_t i = 0; i < n_args; i++) { if (mp_obj_is_type(objs[i], &alarm_pin_pinalarm_type) || mp_obj_is_type(objs[i], &alarm_time_timealarm_type) || diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 2fdd6218bb..bd7502e891 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -29,8 +29,9 @@ #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/time/__init__.h" #include "shared-bindings/alarm/time/TimeAlarm.h" +#include "shared-bindings/rtc/__init__.h" +#include "shared-bindings/time/__init__.h" #include "supervisor/shared/translate.h" diff --git a/shared-bindings/board/__init__.h b/shared-bindings/board/__init__.h index 837608fa9e..bc4d7df61f 100644 --- a/shared-bindings/board/__init__.h +++ b/shared-bindings/board/__init__.h @@ -47,6 +47,10 @@ mp_obj_t common_hal_board_get_uart(void); mp_obj_t common_hal_board_create_uart(void); MP_DECLARE_CONST_FUN_OBJ_0(board_uart_obj); +mp_obj_t board_i2c(void); +mp_obj_t board_spi(void); +mp_obj_t board_uart(void); + #define CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS \ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_board) }, \ { MP_ROM_QSTR(MP_QSTR_board_id), MP_ROM_PTR(&board_module_id_obj) }, diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index a46ab6826e..90cd7c3aa6 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -152,7 +152,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, si #if CIRCUITPY_BUSIO_UART // Helper to ensure we have the native super class instead of a subclass. -busio_uart_obj_t *native_uart(mp_obj_t uart_obj) { +STATIC busio_uart_obj_t *native_uart(mp_obj_t uart_obj) { mp_obj_t native_uart = mp_obj_cast_to_native_base(uart_obj, &busio_uart_type); if (native_uart == MP_OBJ_NULL) { mp_raise_ValueError_varg(translate("Must be a %q subclass."), MP_QSTR_UART); diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index fc246582fd..02efd41988 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -68,7 +68,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname); //| """Change current directory.""" //| ... //| -mp_obj_t os_chdir(mp_obj_t path_in) { +STATIC mp_obj_t os_chdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_chdir(path); return mp_const_none; @@ -79,7 +79,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_chdir_obj, os_chdir); //| """Get the current directory.""" //| ... //| -mp_obj_t os_getcwd(void) { +STATIC mp_obj_t os_getcwd(void) { return common_hal_os_getcwd(); } MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd); @@ -88,7 +88,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd); //| """With no argument, list the current directory. Otherwise list the given directory.""" //| ... //| -mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) { const char *path; if (n_args == 1) { path = mp_obj_str_get_str(args[0]); @@ -103,7 +103,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_listdir_obj, 0, 1, os_listdir); //| """Create a new directory.""" //| ... //| -mp_obj_t os_mkdir(mp_obj_t path_in) { +STATIC mp_obj_t os_mkdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_mkdir(path); return mp_const_none; @@ -114,7 +114,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir); //| """Remove a file.""" //| ... //| -mp_obj_t os_remove(mp_obj_t path_in) { +STATIC mp_obj_t os_remove(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_remove(path); return mp_const_none; @@ -125,7 +125,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_remove_obj, os_remove); //| """Remove a directory.""" //| ... //| -mp_obj_t os_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) { +STATIC mp_obj_t os_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) { const char *old_path = mp_obj_str_get_str(old_path_in); const char *new_path = mp_obj_str_get_str(new_path_in); common_hal_os_rename(old_path, new_path); @@ -137,7 +137,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(os_rename_obj, os_rename); //| """Rename a file.""" //| ... //| -mp_obj_t os_rmdir(mp_obj_t path_in) { +STATIC mp_obj_t os_rmdir(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); common_hal_os_rmdir(path); return mp_const_none; @@ -153,7 +153,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir); //| which is the number of seconds corresponding to 1999-12-31.""" //| ... //| -mp_obj_t os_stat(mp_obj_t path_in) { +STATIC mp_obj_t os_stat(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); return common_hal_os_stat(path); } @@ -180,7 +180,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(os_stat_obj, os_stat); //| in a port-specific implementation.""" //| ... //| -mp_obj_t os_statvfs(mp_obj_t path_in) { +STATIC mp_obj_t os_statvfs(mp_obj_t path_in) { const char *path = mp_obj_str_get_str(path_in); return common_hal_os_statvfs(path); } diff --git a/shared-bindings/sdcardio/SDCard.c b/shared-bindings/sdcardio/SDCard.c index 14cf5f5b0d..757a1b8532 100644 --- a/shared-bindings/sdcardio/SDCard.c +++ b/shared-bindings/sdcardio/SDCard.c @@ -106,7 +106,7 @@ STATIC mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_arg //| //| :return: The number of 512-byte blocks, as a number""" //| -mp_obj_t sdcardio_sdcard_count(mp_obj_t self_in) { +STATIC mp_obj_t sdcardio_sdcard_count(mp_obj_t self_in) { sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; return mp_obj_new_int_from_ull(common_hal_sdcardio_sdcard_get_blockcount(self)); } @@ -117,7 +117,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_count_obj, sdcardio_sdcard_count); //| //| :return: None""" //| -mp_obj_t sdcardio_sdcard_deinit(mp_obj_t self_in) { +STATIC mp_obj_t sdcardio_sdcard_deinit(mp_obj_t self_in) { sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; common_hal_sdcardio_sdcard_deinit(self); return mp_const_none; @@ -135,7 +135,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_deinit_obj, sdcardio_sdcard_deinit); //| :return: None""" //| -mp_obj_t sdcardio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { +STATIC mp_obj_t sdcardio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_WRITE); @@ -154,7 +154,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(sdcardio_sdcard_readblocks_obj, sdcardio_sdcard_readbl //| //| :return: None""" //| ... -mp_obj_t sdcardio_sdcard_sync(mp_obj_t self_in) { +STATIC mp_obj_t sdcardio_sdcard_sync(mp_obj_t self_in) { sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; int result = common_hal_sdcardio_sdcard_sync(self); if (result < 0) { @@ -176,7 +176,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_sync_obj, sdcardio_sdcard_sync); //| :return: None""" //| -mp_obj_t sdcardio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { +STATIC mp_obj_t sdcardio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index e03d180d7a..ba45af4576 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -168,7 +168,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_count_obj, sdioio_sdcard_count); //| :param ~_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512. //| //| :return: None""" -mp_obj_t sdioio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { +STATIC mp_obj_t sdioio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_WRITE); @@ -191,7 +191,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(sdioio_sdcard_readblocks_obj, sdioio_sdcard_readblocks //| //| :return: None""" //| -mp_obj_t sdioio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { +STATIC mp_obj_t sdioio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index c5769b56b5..3c957468da 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -54,7 +54,7 @@ //| """ //| ... //| -mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_filesystem, ARG_mount_path, ARG_readonly }; static const mp_arg_t allowed_args[] = { { MP_QSTR_filesystem, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -91,7 +91,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 0, storage_mount); //| This is the CircuitPython analog to the UNIX ``umount`` command.""" //| ... //| -mp_obj_t storage_umount(mp_obj_t mnt_in) { +STATIC mp_obj_t storage_umount(mp_obj_t mnt_in) { if (mp_obj_is_str(mnt_in)) { common_hal_storage_umount_path(mp_obj_str_get_str(mnt_in)); } else { @@ -113,7 +113,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount); //| filesystem will be corrupted.""" //| ... //| -mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_mount_path, ARG_readonly, ARG_disable_concurrent_write_protection }; static const mp_arg_t allowed_args[] = { { MP_QSTR_mount_path, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -136,7 +136,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 0, storage_remount); //| """Retrieves the mount object associated with the mount path""" //| ... //| -mp_obj_t storage_getmount(const mp_obj_t mnt_in) { +STATIC mp_obj_t storage_getmount(const mp_obj_t mnt_in) { return common_hal_storage_getmount(mp_obj_str_get_str(mnt_in)); } MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount); @@ -156,7 +156,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount); //| ... //| -mp_obj_t storage_erase_filesystem(void) { +STATIC mp_obj_t storage_erase_filesystem(void) { common_hal_storage_erase_filesystem(); return mp_const_none; } diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 971d381ede..4b090fc34e 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -93,7 +93,7 @@ STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep); #if MICROPY_PY_COLLECTIONS -mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_check_num(n_args, n_kw, 1, 1, false); size_t len; mp_obj_t *items; diff --git a/shared-module/_bleio/ScanEntry.c b/shared-module/_bleio/ScanEntry.c index 065d23d4f4..7a57d8aedc 100644 --- a/shared-module/_bleio/ScanEntry.c +++ b/shared-module/_bleio/ScanEntry.c @@ -29,6 +29,7 @@ #include #include "shared-bindings/_bleio/Address.h" +#include "shared-bindings/_bleio/ScanEntry.h" #include "shared-module/_bleio/Address.h" #include "shared-module/_bleio/ScanEntry.h" diff --git a/shared-module/_eve/__init__.c b/shared-module/_eve/__init__.c index 0df77b65cb..a39e6f9ee8 100644 --- a/shared-module/_eve/__init__.c +++ b/shared-module/_eve/__init__.c @@ -27,6 +27,7 @@ #include #include #include "py/runtime.h" +#include "shared-bindings/_eve/__init__.h" #include "shared-module/_eve/__init__.h" STATIC void write(common_hal__eve_t *eve, size_t len, void *buf) { diff --git a/shared-module/adafruit_pixelbuf/PixelBuf.c b/shared-module/adafruit_pixelbuf/PixelBuf.c index 378efbfde5..bfeab4ae04 100644 --- a/shared-module/adafruit_pixelbuf/PixelBuf.c +++ b/shared-module/adafruit_pixelbuf/PixelBuf.c @@ -140,7 +140,7 @@ void common_hal_adafruit_pixelbuf_pixelbuf_set_brightness(mp_obj_t self_in, mp_f } } -uint8_t _pixelbuf_get_as_uint8(mp_obj_t obj) { +STATIC uint8_t _pixelbuf_get_as_uint8(mp_obj_t obj) { if (mp_obj_is_small_int(obj)) { return MP_OBJ_SMALL_INT_VALUE(obj); } else if (mp_obj_is_int(obj)) { @@ -152,7 +152,7 @@ uint8_t _pixelbuf_get_as_uint8(mp_obj_t obj) { translate("can't convert %q to %q"), mp_obj_get_type_qstr(obj), MP_QSTR_int); } -void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t *self, mp_obj_t color, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *w) { +STATIC void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t *self, mp_obj_t color, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *w) { pixelbuf_byteorder_details_t *byteorder = &self->byteorder; // w is shared between white in NeoPixels and brightness in dotstars (so that DotStars can have // per-pixel brightness). Set the defaults here in case it isn't set below. @@ -197,7 +197,7 @@ void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t *self, mp_obj_t color, uint8_ } } -void _pixelbuf_set_pixel_color(pixelbuf_pixelbuf_obj_t *self, size_t index, uint8_t r, uint8_t g, uint8_t b, uint8_t w) { +STATIC void _pixelbuf_set_pixel_color(pixelbuf_pixelbuf_obj_t *self, size_t index, uint8_t r, uint8_t g, uint8_t b, uint8_t w) { // DotStars don't have white, instead they have 5 bit brightness so pack it into w. Shift right // by three to leave the top five bits. if (self->bytes_per_pixel == 4 && self->byteorder.is_dotstar) { @@ -235,7 +235,7 @@ void _pixelbuf_set_pixel_color(pixelbuf_pixelbuf_obj_t *self, size_t index, uint } } -void _pixelbuf_set_pixel(pixelbuf_pixelbuf_obj_t *self, size_t index, mp_obj_t value) { +STATIC void _pixelbuf_set_pixel(pixelbuf_pixelbuf_obj_t *self, size_t index, mp_obj_t value) { uint8_t r; uint8_t g; uint8_t b; diff --git a/shared-module/audiocore/WaveFile.c b/shared-module/audiocore/WaveFile.c index 14c92ca411..0cceb979a6 100644 --- a/shared-module/audiocore/WaveFile.c +++ b/shared-module/audiocore/WaveFile.c @@ -160,14 +160,6 @@ uint8_t common_hal_audioio_wavefile_get_channel_count(audioio_wavefile_obj_t *se return self->channel_count; } -bool audioio_wavefile_samples_signed(audioio_wavefile_obj_t *self) { - return self->bits_per_sample > 8; -} - -uint32_t audioio_wavefile_max_buffer_length(audioio_wavefile_obj_t *self) { - return 512; -} - void audioio_wavefile_reset_buffer(audioio_wavefile_obj_t *self, bool single_channel_output, uint8_t channel) { diff --git a/shared-module/audiomixer/MixerVoice.c b/shared-module/audiomixer/MixerVoice.c index 34fa907a5b..bb58b0c111 100644 --- a/shared-module/audiomixer/MixerVoice.c +++ b/shared-module/audiomixer/MixerVoice.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ #include "shared-bindings/audiomixer/Mixer.h" +#include "shared-bindings/audiomixer/MixerVoice.h" #include "shared-module/audiomixer/MixerVoice.h" #include diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c index cc755d7d2f..5e1bce5924 100644 --- a/shared-module/audiomp3/MP3Decoder.c +++ b/shared-module/audiomp3/MP3Decoder.c @@ -290,10 +290,6 @@ uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t *se return self->channel_count; } -bool audiomp3_mp3file_samples_signed(audiomp3_mp3file_obj_t *self) { - return true; -} - void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t *self, bool single_channel_output, uint8_t channel) { diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index a9cb3ae978..0c577f0194 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -219,17 +219,6 @@ void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16 } } -int16_t constrain(int16_t input, int16_t min, int16_t max) { - // constrain the input between the min and max values - if (input < min) { - return min; - } - if (input > max) { - return max; - } - return input; -} - void common_hal_bitmaptools_fill_region(displayio_bitmap_t *destination, int16_t x1, int16_t y1, int16_t x2, int16_t y2, diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 05900040d8..19d9e7ece0 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -24,7 +24,9 @@ * THE SOFTWARE. */ +#include "shared-bindings/board/__init__.h" #include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/board/__init__.h" #include "supervisor/shared/translate.h" #include "mpconfigboard.h" #include "py/runtime.h" diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index 675691ed00..7d8fc0d26d 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -103,7 +103,7 @@ bool common_hal_displayio_epaperdisplay_show(displayio_epaperdisplay_obj_t *self return displayio_display_core_show(&self->core, root_group); } -const displayio_area_t *displayio_epaperdisplay_get_refresh_areas(displayio_epaperdisplay_obj_t *self) { +STATIC const displayio_area_t *displayio_epaperdisplay_get_refresh_areas(displayio_epaperdisplay_obj_t *self) { if (self->core.full_refresh) { self->core.area.next = NULL; return &self->core.area; @@ -172,7 +172,7 @@ void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisp self->milliseconds_per_frame = seconds_per_frame * 1000; } -void displayio_epaperdisplay_start_refresh(displayio_epaperdisplay_obj_t *self) { +STATIC void displayio_epaperdisplay_start_refresh(displayio_epaperdisplay_obj_t *self) { // run start sequence self->core.bus_reset(self->core.bus); @@ -192,7 +192,7 @@ uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaper return self->milliseconds_per_frame - elapsed_time; } -void displayio_epaperdisplay_finish_refresh(displayio_epaperdisplay_obj_t *self) { +STATIC void displayio_epaperdisplay_finish_refresh(displayio_epaperdisplay_obj_t *self) { // Actually refresh the display now that all pixel RAM has been updated. displayio_display_core_begin_transaction(&self->core); self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, &self->refresh_display_command, 1); @@ -230,7 +230,7 @@ uint16_t common_hal_displayio_epaperdisplay_get_rotation(displayio_epaperdisplay } -bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t *self, const displayio_area_t *area) { +STATIC bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t *self, const displayio_area_t *area) { uint16_t buffer_size = 128; // In uint32_ts displayio_area_t clipped; diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index 430cbc8409..044674f415 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -104,7 +104,7 @@ bool displayio_tilegrid_get_previous_area(displayio_tilegrid_t *self, displayio_ return true; } -void _update_current_x(displayio_tilegrid_t *self) { +STATIC void _update_current_x(displayio_tilegrid_t *self) { uint16_t width; if (self->transpose_xy) { width = self->pixel_height; @@ -137,7 +137,7 @@ void _update_current_x(displayio_tilegrid_t *self) { } } -void _update_current_y(displayio_tilegrid_t *self) { +STATIC void _update_current_y(displayio_tilegrid_t *self) { uint16_t height; if (self->transpose_xy) { height = self->pixel_width; diff --git a/shared-module/keypad/EventQueue.c b/shared-module/keypad/EventQueue.c index ddd1cd0e87..eeeceb78cf 100644 --- a/shared-module/keypad/EventQueue.c +++ b/shared-module/keypad/EventQueue.c @@ -25,6 +25,7 @@ */ #include "shared-bindings/keypad/Event.h" +#include "shared-bindings/keypad/EventQueue.h" #include "shared-bindings/supervisor/__init__.h" #include "shared-module/keypad/EventQueue.h" diff --git a/shared-module/msgpack/__init__.c b/shared-module/msgpack/__init__.c index 1e865385d7..7a6892c51f 100644 --- a/shared-module/msgpack/__init__.c +++ b/shared-module/msgpack/__init__.c @@ -38,6 +38,8 @@ #include "supervisor/shared/translate.h" #include "shared-bindings/msgpack/ExtType.h" +#include "shared-bindings/msgpack/__init__.h" +#include "shared-module/msgpack/__init__.h" //////////////////////////////////////////////////////////////// // stream management diff --git a/shared-module/random/__init__.c b/shared-module/random/__init__.c index 95ac3bc659..438eb24696 100644 --- a/shared-module/random/__init__.c +++ b/shared-module/random/__init__.c @@ -30,6 +30,7 @@ #include "py/runtime.h" #include "shared-bindings/os/__init__.h" +#include "shared-bindings/random/__init__.h" #include "shared-bindings/time/__init__.h" // Yasmarang random number generator diff --git a/shared-module/rotaryio/IncrementalEncoder.c b/shared-module/rotaryio/IncrementalEncoder.c index 89dea01cfe..27b9cdb64d 100644 --- a/shared-module/rotaryio/IncrementalEncoder.c +++ b/shared-module/rotaryio/IncrementalEncoder.c @@ -25,6 +25,7 @@ */ #if CIRCUITPY_ROTARYIO && CIRCUITPY_ROTARYIO_SOFTENCODER +#include "shared-bindings/rotaryio/IncrementalEncoder.h" #include "shared-module/rotaryio/IncrementalEncoder.h" #include "common-hal/rotaryio/IncrementalEncoder.h" diff --git a/shared-module/sdcardio/SDCard.c b/shared-module/sdcardio/SDCard.c index f5ab97ebe5..9cbbf40819 100644 --- a/shared-module/sdcardio/SDCard.c +++ b/shared-module/sdcardio/SDCard.c @@ -28,6 +28,7 @@ #include "shared-bindings/busio/SPI.h" #include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/sdcardio/SDCard.h" #include "shared-bindings/time/__init__.h" #include "shared-bindings/util.h" #include "shared-module/sdcardio/SDCard.h" @@ -325,7 +326,7 @@ void common_hal_sdcardio_sdcard_deinit(sdcardio_sdcard_obj_t *self) { common_hal_digitalio_digitalinout_deinit(&self->cs); } -void common_hal_sdcardio_check_for_deinit(sdcardio_sdcard_obj_t *self) { +STATIC void common_hal_sdcardio_check_for_deinit(sdcardio_sdcard_obj_t *self) { if (!self->bus) { raise_deinited_error(); } @@ -336,7 +337,7 @@ int common_hal_sdcardio_sdcard_get_blockcount(sdcardio_sdcard_obj_t *self) { return self->sectors; } -int readinto(sdcardio_sdcard_obj_t *self, void *buf, size_t size) { +STATIC int readinto(sdcardio_sdcard_obj_t *self, void *buf, size_t size) { uint8_t aux[2] = {0, 0}; while (aux[0] != 0xfe) { common_hal_busio_spi_read(self->bus, aux, 1, 0xff); @@ -349,7 +350,7 @@ int readinto(sdcardio_sdcard_obj_t *self, void *buf, size_t size) { return 0; } -int readblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) { +STATIC int readblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) { uint32_t nblocks = buf->len / 512; if (nblocks == 1) { // Use CMD17 to read a single block diff --git a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c index 14f4908222..9012a5ac89 100644 --- a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c @@ -53,19 +53,19 @@ int common_hal_sharpdisplay_framebuffer_get_height(sharpdisplay_framebuffer_obj_ return self->height; } -int common_hal_sharpdisplay_framebuffer_get_row_stride(sharpdisplay_framebuffer_obj_t *self) { +STATIC int common_hal_sharpdisplay_framebuffer_get_row_stride(sharpdisplay_framebuffer_obj_t *self) { return (self->width + 7) / 8 + 2; } -int common_hal_sharpdisplay_framebuffer_get_first_pixel_offset(sharpdisplay_framebuffer_obj_t *self) { +STATIC int common_hal_sharpdisplay_framebuffer_get_first_pixel_offset(sharpdisplay_framebuffer_obj_t *self) { return 2; } -bool common_hal_sharpdisplay_framebuffer_get_reverse_pixels_in_byte(sharpdisplay_framebuffer_obj_t *self) { +STATIC bool common_hal_sharpdisplay_framebuffer_get_reverse_pixels_in_byte(sharpdisplay_framebuffer_obj_t *self) { return true; } -bool common_hal_sharpdisplay_framebuffer_get_pixels_in_byte_share_row(sharpdisplay_framebuffer_obj_t *self) { +STATIC bool common_hal_sharpdisplay_framebuffer_get_pixels_in_byte_share_row(sharpdisplay_framebuffer_obj_t *self) { return true; } @@ -143,7 +143,7 @@ void common_hal_sharpdisplay_framebuffer_construct(sharpdisplay_framebuffer_obj_ common_hal_sharpdisplay_framebuffer_get_bufinfo(self, NULL); } -void common_hal_sharpdisplay_framebuffer_swapbuffers(sharpdisplay_framebuffer_obj_t *self, uint8_t *dirty_row_bitmask) { +STATIC void common_hal_sharpdisplay_framebuffer_swapbuffers(sharpdisplay_framebuffer_obj_t *self, uint8_t *dirty_row_bitmask) { // claim SPI bus if (!common_hal_busio_spi_try_lock(self->bus)) { return; diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c index b3b0096174..a0abd16408 100644 --- a/shared-module/struct/__init__.c +++ b/shared-module/struct/__init__.c @@ -32,8 +32,9 @@ #include "py/binary.h" #include "py/parsenum.h" #include "supervisor/shared/translate.h" +#include "shared-bindings/struct/__init__.h" -void struct_validate_format(char fmt) { +STATIC void struct_validate_format(char fmt) { #if MICROPY_NONSTANDARD_TYPECODES if (fmt == 'S' || fmt == 'O') { mp_raise_RuntimeError(translate("'S' and 'O' are not supported format types")); @@ -41,7 +42,7 @@ void struct_validate_format(char fmt) { #endif } -char get_fmt_type(const char **fmt) { +STATIC char get_fmt_type(const char **fmt) { char t = **fmt; switch (t) { case '!': @@ -60,7 +61,7 @@ char get_fmt_type(const char **fmt) { return t; } -mp_uint_t get_fmt_num(const char **p) { +STATIC mp_uint_t get_fmt_num(const char **p) { const char *num = *p; uint len = 1; while (unichar_isdigit(*++num)) { @@ -71,7 +72,7 @@ mp_uint_t get_fmt_num(const char **p) { return val; } -mp_uint_t calcsize_items(const char *fmt) { +STATIC mp_uint_t calcsize_items(const char *fmt) { mp_uint_t cnt = 0; while (*fmt) { int num = 1; diff --git a/shared-module/terminalio/Terminal.c b/shared-module/terminalio/Terminal.c index 48010aa650..f0a69bde39 100644 --- a/shared-module/terminalio/Terminal.c +++ b/shared-module/terminalio/Terminal.c @@ -28,6 +28,7 @@ #include "shared-module/fontio/BuiltinFont.h" #include "shared-bindings/displayio/TileGrid.h" +#include "shared-bindings/terminalio/Terminal.h" void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, displayio_tilegrid_t *tilegrid, const fontio_builtinfont_t *font) { self->cursor_x = 0; diff --git a/shared-module/time/__init__.c b/shared-module/time/__init__.c index c79a5f3ae7..b4575b18a2 100644 --- a/shared-module/time/__init__.c +++ b/shared-module/time/__init__.c @@ -27,6 +27,7 @@ #include "py/mphal.h" #include "supervisor/port.h" #include "supervisor/shared/tick.h" +#include "shared-bindings/time/__init__.h" uint64_t common_hal_time_monotonic_ms(void) { return supervisor_ticks_ms64(); diff --git a/shared-module/vectorio/Rectangle.c b/shared-module/vectorio/Rectangle.c index 2471daa608..bcaa0092f8 100644 --- a/shared-module/vectorio/Rectangle.c +++ b/shared-module/vectorio/Rectangle.c @@ -28,11 +28,6 @@ void common_hal_vectorio_rectangle_get_area(void *rectangle, displayio_area_t *o } -uint32_t common_hal_vectorio_rectangle_get_height(void *rectangle) { - vectorio_rectangle_t *self = rectangle; - return self->height; -} - mp_obj_t common_hal_vectorio_rectangle_get_draw_protocol(void *rectangle) { vectorio_rectangle_t *self = rectangle; return self->draw_protocol_instance; diff --git a/shared/runtime/interrupt_char.c b/shared/runtime/interrupt_char.c index 4ac099f41e..21e5a06358 100644 --- a/shared/runtime/interrupt_char.c +++ b/shared/runtime/interrupt_char.c @@ -26,6 +26,7 @@ #include "py/obj.h" #include "py/mpstate.h" +#include "shared/runtime/interrupt_char.h" #if MICROPY_KBD_EXCEPTION diff --git a/shared/runtime/sys_stdio_mphal.c b/shared/runtime/sys_stdio_mphal.c index 228529ce3d..580d97f614 100644 --- a/shared/runtime/sys_stdio_mphal.c +++ b/shared/runtime/sys_stdio_mphal.c @@ -52,7 +52,7 @@ typedef struct _sys_stdio_obj_t { STATIC const sys_stdio_obj_t stdio_buffer_obj; #endif -void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { sys_stdio_obj_t *self = MP_OBJ_TO_PTR(self_in); mp_printf(print, "", self->fd); } From afd035eb56c56443492c3913a0ba0b1ebee99a8c Mon Sep 17 00:00:00 2001 From: lady ada Date: Wed, 10 Nov 2021 12:05:16 -0500 Subject: [PATCH 55/84] remove old nopsram version --- .../adafruit_feather_esp32s2_nopsram/board.c | 52 --------------- .../mpconfigboard.h | 46 ------------- .../mpconfigboard.mk | 24 ------- .../adafruit_feather_esp32s2_nopsram/pins.c | 66 ------------------- .../sdkconfig | 0 5 files changed, 188 deletions(-) delete mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_nopsram/board.c delete mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h delete mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk delete mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_nopsram/pins.c delete mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_nopsram/sdkconfig diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/board.c deleted file mode 100644 index e40b6335bc..0000000000 --- a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/board.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "supervisor/board.h" -#include "mpconfigboard.h" -#include "shared-bindings/microcontroller/Pin.h" - -void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - - // Debug UART - #ifdef DEBUG - common_hal_never_reset_pin(&pin_GPIO43); - common_hal_never_reset_pin(&pin_GPIO44); - #endif /* DEBUG */ -} - -bool board_requests_safe_mode(void) { - return false; -} - -void reset_board(void) { - -} - -void board_deinit(void) { -} diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h deleted file mode 100644 index d2cd01a681..0000000000 --- a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// Micropython setup - -#define MICROPY_HW_BOARD_NAME "Feather ESP32S2 without PSRAM" -#define MICROPY_HW_MCU_NAME "ESP32S2" - -#define MICROPY_HW_NEOPIXEL (&pin_GPIO33) -#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO21) - -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) - -#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") - -#define AUTORESET_DELAY_MS 500 - -#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4) -#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3) - -#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) -#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) -#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk b/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk deleted file mode 100644 index 0360849ac4..0000000000 --- a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk +++ /dev/null @@ -1,24 +0,0 @@ -USB_VID = 0x239A -USB_PID = 0x8FFF -USB_PRODUCT = "Feather ESP32S2 no PSRAM" -USB_MANUFACTURER = "Adafruit" - -IDF_TARGET = esp32s2 - -INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = MPZ - -# The default queue depth of 16 overflows on release builds, -# so increase it to 32. -CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 - -CIRCUITPY_ESP_FLASH_MODE=dio -CIRCUITPY_ESP_FLASH_FREQ=40m -CIRCUITPY_ESP_FLASH_SIZE=4MB - -CIRCUITPY_MODULE=wroom - -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/pins.c deleted file mode 100644 index 6d0167f5c2..0000000000 --- a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/pins.c +++ /dev/null @@ -1,66 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_module_globals_table[] = { - CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, - - { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) }, - - { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO4) }, - - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, - - { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, - - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, - - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, - { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_GPIO13) }, - - { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO14) }, - - { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO15) }, - - { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO16) }, - - { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) }, - - { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, - - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) }, - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) }, - - { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, - - { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, - - { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, - - - { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO38) }, - - { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO39) }, - - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/sdkconfig b/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/sdkconfig deleted file mode 100644 index e69de29bb2..0000000000 From c9475adb00b082f2e0444cbb262647fd1009d076 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Nov 2021 11:07:45 -0600 Subject: [PATCH 56/84] Enable -Werror=missing-prototypes on espressif port --- ports/espressif/Makefile | 2 +- ports/espressif/background.c | 1 + ports/espressif/bindings/espidf/__init__.c | 10 +--------- ports/espressif/cam.c | 6 +++--- ports/espressif/common-hal/alarm/SleepMemory.c | 1 + ports/espressif/common-hal/alarm/pin/PinAlarm.c | 2 +- ports/espressif/common-hal/alarm/time/TimeAlarm.c | 2 +- ports/espressif/common-hal/alarm/touch/TouchAlarm.c | 2 +- ports/espressif/common-hal/analogio/AnalogIn.c | 1 + ports/espressif/common-hal/canio/CAN.c | 4 ++-- ports/espressif/common-hal/canio/Listener.c | 2 +- ports/espressif/common-hal/countio/Counter.c | 1 + ports/espressif/common-hal/microcontroller/Processor.c | 1 + ports/espressif/common-hal/nvm/ByteArray.c | 7 ++++--- ports/espressif/common-hal/os/__init__.c | 2 ++ ports/espressif/common-hal/ps2io/Ps2.c | 1 + ports/espressif/common-hal/pulseio/PulseIn.c | 1 + ports/espressif/common-hal/pulseio/PulseOut.c | 1 + .../espressif/common-hal/rotaryio/IncrementalEncoder.c | 1 + ports/espressif/common-hal/ssl/__init__.c | 1 + ports/espressif/common-hal/watchdog/WatchDogTimer.c | 1 + ports/espressif/common-hal/wifi/__init__.c | 1 + ports/espressif/mphalport.c | 4 +++- ports/espressif/supervisor/internal_flash.c | 1 + ports/espressif/supervisor/port.c | 3 ++- ports/espressif/supervisor/usb.c | 2 +- shared-module/canio/Match.c | 1 + shared-module/canio/Message.c | 1 + 28 files changed, 38 insertions(+), 25 deletions(-) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 9a928b40f4..7a034c9d2a 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -150,7 +150,7 @@ endif # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk CFLAGS += $(OPTIMIZATION_FLAGS) -CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) +CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes ifeq ($(IDF_TARGET_ARCH),xtensa) CFLAGS += -mlongcalls diff --git a/ports/espressif/background.c b/ports/espressif/background.c index 80b60bebe3..37fe3d5be0 100644 --- a/ports/espressif/background.c +++ b/ports/espressif/background.c @@ -26,6 +26,7 @@ #include "py/runtime.h" #include "supervisor/filesystem.h" +#include "supervisor/port.h" #include "supervisor/shared/stack.h" #include "freertos/FreeRTOS.h" diff --git a/ports/espressif/bindings/espidf/__init__.c b/ports/espressif/bindings/espidf/__init__.c index 9076294d53..4f7da39540 100644 --- a/ports/espressif/bindings/espidf/__init__.c +++ b/ports/espressif/bindings/espidf/__init__.c @@ -82,15 +82,7 @@ STATIC mp_obj_t espidf_erase_nvs(void) { MP_DEFINE_CONST_FUN_OBJ_0(espidf_erase_nvs_obj, espidf_erase_nvs); -//| class IDFError(OSError): -//| """Raised for certain generic ESP IDF errors.""" -//| ... -//| -NORETURN void mp_raise_espidf_IDFError(void) { - nlr_raise(mp_obj_new_exception(&mp_type_espidf_IDFError)); -} - -void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { +STATIC void espidf_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; bool is_subclass = kind & PRINT_EXC_SUBCLASS; if (!is_subclass && (k == PRINT_EXC)) { diff --git a/ports/espressif/cam.c b/ports/espressif/cam.c index e435993c6d..146df43a41 100644 --- a/ports/espressif/cam.c +++ b/ports/espressif/cam.c @@ -69,7 +69,7 @@ typedef struct { static cam_obj_t *cam_obj = NULL; -void IRAM_ATTR cam_isr(void *arg) { +static void IRAM_ATTR cam_isr(void *arg) { cam_event_t cam_event = {0}; BaseType_t HPTaskAwoken = pdFALSE; typeof(I2S0.int_st) int_st = I2S0.int_st; @@ -85,7 +85,7 @@ void IRAM_ATTR cam_isr(void *arg) { } } -void IRAM_ATTR cam_vsync_isr(void *arg) { +static void IRAM_ATTR cam_vsync_isr(void *arg) { cam_event_t cam_event = {0}; BaseType_t HPTaskAwoken = pdFALSE; /*!< filter */ @@ -392,7 +392,7 @@ void cam_give(uint8_t *buffer) { } } -void cam_dma_config(const cam_config_t *config) { +static void cam_dma_config(const cam_config_t *config) { int cnt = 0; if (config->mode.jpeg) { diff --git a/ports/espressif/common-hal/alarm/SleepMemory.c b/ports/espressif/common-hal/alarm/SleepMemory.c index b25bf28d25..764125ddb2 100644 --- a/ports/espressif/common-hal/alarm/SleepMemory.c +++ b/ports/espressif/common-hal/alarm/SleepMemory.c @@ -29,6 +29,7 @@ #include "py/runtime.h" #include "common-hal/alarm/SleepMemory.h" +#include "shared-bindings/alarm/SleepMemory.h" #include "esp_log.h" #include "esp_sleep.h" diff --git a/ports/espressif/common-hal/alarm/pin/PinAlarm.c b/ports/espressif/common-hal/alarm/pin/PinAlarm.c index 970094783e..754902f678 100644 --- a/ports/espressif/common-hal/alarm/pin/PinAlarm.c +++ b/ports/espressif/common-hal/alarm/pin/PinAlarm.c @@ -72,7 +72,7 @@ gpio_isr_handle_t gpio_interrupt_handle; // Low and high are relative to pin number. 32+ is high. <32 is low. static volatile uint32_t pin_31_0_status = 0; static volatile uint32_t pin_63_32_status = 0; -void gpio_interrupt(void *arg) { +STATIC void gpio_interrupt(void *arg) { (void)arg; gpio_ll_get_intr_status(&GPIO, xPortGetCoreID(), (uint32_t *)&pin_31_0_status); diff --git a/ports/espressif/common-hal/alarm/time/TimeAlarm.c b/ports/espressif/common-hal/alarm/time/TimeAlarm.c index 0fb29a3ed4..256d96a75f 100644 --- a/ports/espressif/common-hal/alarm/time/TimeAlarm.c +++ b/ports/espressif/common-hal/alarm/time/TimeAlarm.c @@ -63,7 +63,7 @@ esp_timer_handle_t pretend_sleep_timer; STATIC bool woke_up = false; // This is run in the timer task. We use it to wake the main CircuitPython task. -void timer_callback(void *arg) { +STATIC void timer_callback(void *arg) { (void)arg; woke_up = true; xTaskNotifyGive(circuitpython_task); diff --git a/ports/espressif/common-hal/alarm/touch/TouchAlarm.c b/ports/espressif/common-hal/alarm/touch/TouchAlarm.c index e005999ee5..6ae2421e4c 100644 --- a/ports/espressif/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/espressif/common-hal/alarm/touch/TouchAlarm.c @@ -75,7 +75,7 @@ mp_obj_t alarm_touch_touchalarm_create_wakeup_alarm(void) { } // This is used to wake the main CircuitPython task. -void touch_interrupt(void *arg) { +STATIC void touch_interrupt(void *arg) { (void)arg; woke_up = true; BaseType_t task_wakeup; diff --git a/ports/espressif/common-hal/analogio/AnalogIn.c b/ports/espressif/common-hal/analogio/AnalogIn.c index add4c3e14e..df39b30c63 100644 --- a/ports/espressif/common-hal/analogio/AnalogIn.c +++ b/ports/espressif/common-hal/analogio/AnalogIn.c @@ -25,6 +25,7 @@ */ #include "common-hal/analogio/AnalogIn.h" +#include "shared-bindings/analogio/AnalogIn.h" #include "py/mperrno.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" diff --git a/ports/espressif/common-hal/canio/CAN.c b/ports/espressif/common-hal/canio/CAN.c index 720034755b..eebf064f44 100644 --- a/ports/espressif/common-hal/canio/CAN.c +++ b/ports/espressif/common-hal/canio/CAN.c @@ -38,7 +38,7 @@ STATIC bool reserved_can; -twai_timing_config_t get_t_config(int baudrate) { +STATIC twai_timing_config_t get_t_config(int baudrate) { switch (baudrate) { case 1000000: { // TWAI_TIMING_CONFIG_abc expands to a C designated initializer list @@ -204,7 +204,7 @@ static void can_restart(void) { } while (port_get_raw_ticks(NULL) < deadline && (info.state == TWAI_STATE_BUS_OFF || info.state == TWAI_STATE_RECOVERING)); } -void canio_maybe_auto_restart(canio_can_obj_t *self) { +STATIC void canio_maybe_auto_restart(canio_can_obj_t *self) { if (self->auto_restart) { can_restart(); } diff --git a/ports/espressif/common-hal/canio/Listener.c b/ports/espressif/common-hal/canio/Listener.c index 8100261743..eccddf6243 100644 --- a/ports/espressif/common-hal/canio/Listener.c +++ b/ports/espressif/common-hal/canio/Listener.c @@ -78,7 +78,7 @@ STATIC void install_all_match_filter(canio_listener_obj_t *self) { } __attribute__((noinline,optimize("O0"))) -void set_filters(canio_listener_obj_t *self, size_t nmatch, canio_match_obj_t **matches) { +STATIC void set_filters(canio_listener_obj_t *self, size_t nmatch, canio_match_obj_t **matches) { twai_ll_enter_reset_mode(&TWAI); if (!nmatch) { diff --git a/ports/espressif/common-hal/countio/Counter.c b/ports/espressif/common-hal/countio/Counter.c index bdc8b290fe..418a8ae4d4 100644 --- a/ports/espressif/common-hal/countio/Counter.c +++ b/ports/espressif/common-hal/countio/Counter.c @@ -25,6 +25,7 @@ */ #include "common-hal/countio/Counter.h" +#include "shared-bindings/countio/Counter.h" #include "common-hal/microcontroller/Pin.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/microcontroller/Processor.c b/ports/espressif/common-hal/microcontroller/Processor.c index 5f956b4412..c50c6fbf7a 100644 --- a/ports/espressif/common-hal/microcontroller/Processor.c +++ b/ports/espressif/common-hal/microcontroller/Processor.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/Processor.h" #include "shared-bindings/microcontroller/ResetReason.h" #include "supervisor/shared/translate.h" diff --git a/ports/espressif/common-hal/nvm/ByteArray.c b/ports/espressif/common-hal/nvm/ByteArray.c index 6eeed72e2e..a17e368249 100644 --- a/ports/espressif/common-hal/nvm/ByteArray.c +++ b/ports/espressif/common-hal/nvm/ByteArray.c @@ -27,13 +27,14 @@ #include #include "common-hal/nvm/ByteArray.h" +#include "shared-bindings/nvm/ByteArray.h" #include "bindings/espidf/__init__.h" #include "py/runtime.h" #include "py/gc.h" #include "nvs_flash.h" -uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { +uint32_t common_hal_nvm_bytearray_get_length(const nvm_bytearray_obj_t *self) { return self->len; } @@ -75,7 +76,7 @@ static esp_err_t get_bytes(nvs_handle_t handle, uint8_t **buf_out) { return result; } -bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, +bool common_hal_nvm_bytearray_set_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) { // start nvs @@ -122,7 +123,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, return true; } -void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, +void common_hal_nvm_bytearray_get_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint32_t len, uint8_t *values) { // start nvs diff --git a/ports/espressif/common-hal/os/__init__.c b/ports/espressif/common-hal/os/__init__.c index b77898016f..1dcd3e46e0 100644 --- a/ports/espressif/common-hal/os/__init__.c +++ b/ports/espressif/common-hal/os/__init__.c @@ -30,6 +30,8 @@ #include "py/objtuple.h" #include "py/qstr.h" +#include "shared-bindings/os/__init__.h" + #include "esp_system.h" STATIC const qstr os_uname_info_fields[] = { diff --git a/ports/espressif/common-hal/ps2io/Ps2.c b/ports/espressif/common-hal/ps2io/Ps2.c index f4845b0fa8..2b6dc52967 100644 --- a/ports/espressif/common-hal/ps2io/Ps2.c +++ b/ports/espressif/common-hal/ps2io/Ps2.c @@ -25,6 +25,7 @@ */ #include "common-hal/ps2io/Ps2.h" +#include "shared-bindings/ps2io/Ps2.h" #include "supervisor/port.h" #include "shared-bindings/microcontroller/__init__.h" diff --git a/ports/espressif/common-hal/pulseio/PulseIn.c b/ports/espressif/common-hal/pulseio/PulseIn.c index 4b314e2f8d..3f5457f84b 100644 --- a/ports/espressif/common-hal/pulseio/PulseIn.c +++ b/ports/espressif/common-hal/pulseio/PulseIn.c @@ -25,6 +25,7 @@ */ #include "common-hal/pulseio/PulseIn.h" +#include "shared-bindings/pulseio/PulseIn.h" #include "shared-bindings/microcontroller/__init__.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/pulseio/PulseOut.c b/ports/espressif/common-hal/pulseio/PulseOut.c index 1cb02089e7..993fd9452c 100644 --- a/ports/espressif/common-hal/pulseio/PulseOut.c +++ b/ports/espressif/common-hal/pulseio/PulseOut.c @@ -25,6 +25,7 @@ */ #include "common-hal/pulseio/PulseOut.h" +#include "shared-bindings/pulseio/PulseOut.h" #include "shared-bindings/pwmio/PWMOut.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c index b36c79b4f6..676e99289d 100644 --- a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c @@ -25,6 +25,7 @@ */ #include "common-hal/rotaryio/IncrementalEncoder.h" +#include "shared-bindings/rotaryio/IncrementalEncoder.h" #include "common-hal/microcontroller/Pin.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/ssl/__init__.c b/ports/espressif/common-hal/ssl/__init__.c index a0886adda7..61ea32f395 100644 --- a/ports/espressif/common-hal/ssl/__init__.c +++ b/ports/espressif/common-hal/ssl/__init__.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "shared-bindings/ssl/__init__.h" #include "shared-bindings/ssl/SSLContext.h" #include "components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h" diff --git a/ports/espressif/common-hal/watchdog/WatchDogTimer.c b/ports/espressif/common-hal/watchdog/WatchDogTimer.c index 729ab5815a..159c99458f 100644 --- a/ports/espressif/common-hal/watchdog/WatchDogTimer.c +++ b/ports/espressif/common-hal/watchdog/WatchDogTimer.c @@ -32,6 +32,7 @@ #include "esp_task_wdt.h" +extern void esp_task_wdt_isr_user_handler(void); void esp_task_wdt_isr_user_handler(void) { mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&mp_watchdog_timeout_exception)); MP_STATE_THREAD(mp_pending_exception) = &mp_watchdog_timeout_exception; diff --git a/ports/espressif/common-hal/wifi/__init__.c b/ports/espressif/common-hal/wifi/__init__.c index 8d19a91cb2..a39103ce0a 100644 --- a/ports/espressif/common-hal/wifi/__init__.c +++ b/ports/espressif/common-hal/wifi/__init__.c @@ -25,6 +25,7 @@ */ #include "common-hal/wifi/__init__.h" +#include "shared-bindings/wifi/__init__.h" #include "shared-bindings/ipaddress/IPv4Address.h" #include "shared-bindings/wifi/Radio.h" diff --git a/ports/espressif/mphalport.c b/ports/espressif/mphalport.c index 632e18039a..f22856f0a4 100644 --- a/ports/espressif/mphalport.c +++ b/ports/espressif/mphalport.c @@ -39,6 +39,8 @@ #include "components/esp_rom/include/esp32s2/rom/ets_sys.h" #endif +#include "supervisor/cpu.h" + void mp_hal_delay_us(mp_uint_t delay) { ets_delay_us(delay); } @@ -48,7 +50,7 @@ void mp_hal_delay_us(mp_uint_t delay) { extern void xthal_window_spill(void); #endif -mp_uint_t cpu_get_regs_and_sp(mp_uint_t *regs, uint8_t reg_count) { +mp_uint_t cpu_get_regs_and_sp(mp_uint_t *regs) { // xtensa has more registers than an instruction can address. The 16 that // can be addressed are called the "window". When a function is called or // returns the window rotates. This allows for more efficient function calls diff --git a/ports/espressif/supervisor/internal_flash.c b/ports/espressif/supervisor/internal_flash.c index 8f3d917765..2f17b48f0c 100644 --- a/ports/espressif/supervisor/internal_flash.c +++ b/ports/espressif/supervisor/internal_flash.c @@ -39,6 +39,7 @@ #include "components/spi_flash/include/esp_partition.h" +#include "supervisor/flash.h" #include "supervisor/usb.h" STATIC const esp_partition_t *_partition; diff --git a/ports/espressif/supervisor/port.c b/ports/espressif/supervisor/port.c index 7425bb615e..30106075e7 100644 --- a/ports/espressif/supervisor/port.c +++ b/ports/espressif/supervisor/port.c @@ -93,7 +93,7 @@ TaskHandle_t circuitpython_task = NULL; extern void esp_restart(void) NORETURN; -void tick_timer_cb(void *arg) { +STATIC void tick_timer_cb(void *arg) { supervisor_tick(); // CircuitPython's VM is run in a separate FreeRTOS task from timer callbacks. So, we have to @@ -360,6 +360,7 @@ void port_idle_until_interrupt(void) { // Wrap main in app_main that the IDF expects. extern void main(void); +extern void app_main(void); void app_main(void) { main(); } diff --git a/ports/espressif/supervisor/usb.c b/ports/espressif/supervisor/usb.c index fa9d09fa44..2137a7b0a4 100644 --- a/ports/espressif/supervisor/usb.c +++ b/ports/espressif/supervisor/usb.c @@ -62,7 +62,7 @@ StaticTask_t usb_device_taskdef; // USB Device Driver task // This top level thread process all usb events and invoke callbacks -void usb_device_task(void *param) { +STATIC void usb_device_task(void *param) { (void)param; // RTOS forever loop diff --git a/shared-module/canio/Match.c b/shared-module/canio/Match.c index b4e8616e9b..ae8fd40893 100644 --- a/shared-module/canio/Match.c +++ b/shared-module/canio/Match.c @@ -25,6 +25,7 @@ */ #include "shared-module/canio/Match.h" +#include "shared-bindings/canio/Match.h" void common_hal_canio_match_construct(canio_match_obj_t *self, int id, int mask, bool extended) { self->id = id; diff --git a/shared-module/canio/Message.c b/shared-module/canio/Message.c index 08e4d9fda7..7c0dcf739a 100644 --- a/shared-module/canio/Message.c +++ b/shared-module/canio/Message.c @@ -25,6 +25,7 @@ */ #include "shared-module/canio/Message.h" +#include "shared-bindings/canio/Message.h" #include From 9e799a7c7482b06e82683fba1be43f6c0812790c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Nov 2021 11:26:54 -0600 Subject: [PATCH 57/84] -Werror=missing-prototypes for nRF --- ports/nrf/Makefile | 15 +++++++++++---- ports/nrf/background.c | 3 ++- .../nrf/common-hal/_bleio/CharacteristicBuffer.c | 1 + ports/nrf/common-hal/_bleio/UUID.c | 1 + ports/nrf/common-hal/_bleio/bonding.h | 5 +++++ ports/nrf/common-hal/alarm/SleepMemory.c | 1 + ports/nrf/common-hal/alarm/__init__.c | 2 +- ports/nrf/common-hal/analogio/AnalogIn.c | 1 + ports/nrf/common-hal/audiobusio/I2SOut.c | 2 +- ports/nrf/common-hal/audiobusio/PDMIn.c | 1 + ports/nrf/common-hal/countio/Counter.c | 1 + ports/nrf/common-hal/microcontroller/Processor.c | 1 + ports/nrf/common-hal/neopixel_write/__init__.c | 1 + ports/nrf/common-hal/nvm/ByteArray.c | 7 ++++--- ports/nrf/common-hal/os/__init__.c | 4 +++- ports/nrf/common-hal/pwmio/PWMOut.c | 4 ++-- .../nrf/common-hal/rotaryio/IncrementalEncoder.c | 1 + ports/nrf/common-hal/rtc/RTC.c | 2 ++ ports/nrf/device/nrf52/startup_nrf52840.c | 2 ++ ports/nrf/fatfs_port.c | 1 + ports/nrf/peripherals/nrf/cache.c | 1 + ports/nrf/peripherals/nrf/nrf52840/power.c | 1 + ports/nrf/sd_mutex.c | 1 + ports/nrf/supervisor/port.c | 8 +++++--- ports/nrf/supervisor/qspi_flash.c | 3 ++- ports/nrf/supervisor/qspi_flash.h | 1 + ports/nrf/supervisor/usb.c | 1 + supervisor/shared/bluetooth/file_transfer.c | 3 ++- supervisor/shared/bluetooth/serial.c | 1 + 29 files changed, 58 insertions(+), 18 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index acd1509297..04a648a4e2 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -101,7 +101,7 @@ endif # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk CFLAGS += $(OPTIMIZATION_FLAGS) -CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) +CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) -Werror=missing-prototypes # Nordic Softdevice SDK header files contains inline assembler that has # broken constraints. As a result the IPA-modref pass, introduced in gcc-11, @@ -173,25 +173,32 @@ SRC_C += \ bluetooth/ble_drv.c \ common-hal/_bleio/bonding.c \ nrfx/mdk/system_$(MCU_SUB_VARIANT).c \ + sd_mutex.c \ + +SRC_PERIPHERALS := \ peripherals/nrf/cache.c \ peripherals/nrf/clocks.c \ peripherals/nrf/$(MCU_CHIP)/pins.c \ peripherals/nrf/$(MCU_CHIP)/power.c \ peripherals/nrf/nvm.c \ peripherals/nrf/timers.c \ - sd_mutex.c +$(patsubst %.c,$(BUILD)/%.o,$(SRC_PERIPHERALS)): CFLAGS += -Wno-missing-prototypes + +SRC_C += $(SRC_PERIPHERALS) ifneq ($(CIRCUITPY_USB),0) # USB source files for nrf52840 ifeq ($(MCU_SUB_VARIANT),nrf52840) -SRC_C += \ +SRC_DCD = \ lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c endif ifeq ($(MCU_SUB_VARIANT),nrf52833) -SRC_C += \ +SRC_DCD += \ lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c endif +SRC_C += $(SRC_DCD) +$(patsubst %.c,$(BUILD)/%.o,$(SRC_DCD)): CFLAGS += -Wno-missing-prototypes endif # CIRCUITPY_USB SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \ diff --git a/ports/nrf/background.c b/ports/nrf/background.c index f4d6b0f79f..f0822de521 100644 --- a/ports/nrf/background.c +++ b/ports/nrf/background.c @@ -26,8 +26,9 @@ #include "py/runtime.h" #include "supervisor/filesystem.h" -#include "supervisor/usb.h" +#include "supervisor/port.h" #include "supervisor/shared/stack.h" +#include "supervisor/usb.h" #if CIRCUITPY_DISPLAYIO #include "shared-module/displayio/__init__.h" diff --git a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c index d45bd89f3d..df389df0f8 100644 --- a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c +++ b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c @@ -39,6 +39,7 @@ #include "shared-bindings/_bleio/Connection.h" #include "supervisor/shared/tick.h" #include "common-hal/_bleio/CharacteristicBuffer.h" +#include "shared-bindings/_bleio/CharacteristicBuffer.h" // Push all the data onto the ring buffer. When the buffer is full, new bytes will be dropped. STATIC void write_to_ringbuf(bleio_characteristic_buffer_obj_t *self, uint8_t *data, uint16_t len) { diff --git a/ports/nrf/common-hal/_bleio/UUID.c b/ports/nrf/common-hal/_bleio/UUID.c index a55d874f22..2d94b4c0ce 100644 --- a/ports/nrf/common-hal/_bleio/UUID.c +++ b/ports/nrf/common-hal/_bleio/UUID.c @@ -30,6 +30,7 @@ #include "py/runtime.h" #include "common-hal/_bleio/UUID.h" +#include "shared-bindings/_bleio/UUID.h" #include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/Adapter.h" diff --git a/ports/nrf/common-hal/_bleio/bonding.h b/ports/nrf/common-hal/_bleio/bonding.h index 228082ec30..0884fe8c13 100644 --- a/ports/nrf/common-hal/_bleio/bonding.h +++ b/ports/nrf/common-hal/_bleio/bonding.h @@ -85,4 +85,9 @@ const ble_gap_enc_key_t *bonding_load_peer_encryption_key(bool is_central, const size_t bonding_load_identities(bool is_central, const ble_gap_id_key_t **keys, size_t max_length); size_t bonding_peripheral_bond_count(void); +#if BONDING_DEBUG +void bonding_print_block(bonding_block_t *); +void bonding_print_keys(bonding_keys_t *); +#endif + #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_BONDING_H diff --git a/ports/nrf/common-hal/alarm/SleepMemory.c b/ports/nrf/common-hal/alarm/SleepMemory.c index 40ce1f1a75..c63cbb7af5 100644 --- a/ports/nrf/common-hal/alarm/SleepMemory.c +++ b/ports/nrf/common-hal/alarm/SleepMemory.c @@ -28,6 +28,7 @@ #include "py/runtime.h" #include "common-hal/alarm/__init__.h" #include "common-hal/alarm/SleepMemory.h" +#include "shared-bindings/alarm/SleepMemory.h" #include "nrf_power.h" __attribute__((section(".uninitialized"))) static uint8_t _sleepmem[SLEEP_MEMORY_LENGTH]; diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 5006d726f0..92dac1c789 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -147,7 +147,7 @@ STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t // TODO: this handles all possible types of wakeup, which is redundant with main. // revise to extract all parts essential to enabling sleep wakeup, but leave the // alarm/non-alarm sorting to the existing main loop. -void system_on_idle_until_alarm(int64_t timediff_ms, bool wake_from_serial, uint32_t prescaler) { +STATIC void system_on_idle_until_alarm(int64_t timediff_ms, bool wake_from_serial, uint32_t prescaler) { bool have_timeout = false; uint64_t start_tick = 0, end_tick = 0; int64_t tickdiff; diff --git a/ports/nrf/common-hal/analogio/AnalogIn.c b/ports/nrf/common-hal/analogio/AnalogIn.c index 2f7bede165..c64e51ec09 100644 --- a/ports/nrf/common-hal/analogio/AnalogIn.c +++ b/ports/nrf/common-hal/analogio/AnalogIn.c @@ -26,6 +26,7 @@ */ #include "common-hal/analogio/AnalogIn.h" +#include "shared-bindings/analogio/AnalogIn.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index 8626ce714d..6e68583a03 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -91,7 +91,7 @@ static void calculate_ratio_info(uint32_t target_sample_rate, struct frequency_i / target_sample_rate; } -void choose_i2s_clocking(audiobusio_i2sout_obj_t *self, uint32_t sample_rate) { +STATIC void choose_i2s_clocking(audiobusio_i2sout_obj_t *self, uint32_t sample_rate) { struct frequency_info best = {0, 0, 0, 1.0}; for (size_t ri = 0; ri < sizeof(ratios) / sizeof(ratios[0]); ri++) { if (NRF_I2S->CONFIG.SWIDTH == I2S_CONFIG_SWIDTH_SWIDTH_16Bit diff --git a/ports/nrf/common-hal/audiobusio/PDMIn.c b/ports/nrf/common-hal/audiobusio/PDMIn.c index c34a4ebba9..9c9afbcb50 100644 --- a/ports/nrf/common-hal/audiobusio/PDMIn.c +++ b/ports/nrf/common-hal/audiobusio/PDMIn.c @@ -25,6 +25,7 @@ */ #include "common-hal/audiobusio/PDMIn.h" +#include "shared-bindings/audiobusio/PDMIn.h" #include "shared-bindings/microcontroller/Pin.h" #include "py/runtime.h" diff --git a/ports/nrf/common-hal/countio/Counter.c b/ports/nrf/common-hal/countio/Counter.c index 452c9d9c83..b2296a7dcc 100644 --- a/ports/nrf/common-hal/countio/Counter.c +++ b/ports/nrf/common-hal/countio/Counter.c @@ -1,5 +1,6 @@ #include "common-hal/countio/Counter.h" +#include "shared-bindings/countio/Counter.h" #include "py/runtime.h" diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index f01b22fb47..fa2dfad6a4 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -27,6 +27,7 @@ #include "py/runtime.h" #include "common-hal/microcontroller/Processor.h" +#include "shared-bindings/microcontroller/Processor.h" #include "common-hal/alarm/__init__.h" #include "shared-bindings/microcontroller/ResetReason.h" diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index c8aa44cd12..6f012fa35b 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -27,6 +27,7 @@ #include "py/mphal.h" #include "py/mpstate.h" #include "shared-bindings/neopixel_write/__init__.h" +#include "common-hal/neopixel_write/__init__.h" #include "supervisor/port.h" #include "nrf_pwm.h" diff --git a/ports/nrf/common-hal/nvm/ByteArray.c b/ports/nrf/common-hal/nvm/ByteArray.c index 5af2cc5636..539f66a5b1 100644 --- a/ports/nrf/common-hal/nvm/ByteArray.c +++ b/ports/nrf/common-hal/nvm/ByteArray.c @@ -26,13 +26,14 @@ #include "py/runtime.h" #include "common-hal/nvm/ByteArray.h" +#include "shared-bindings/nvm/ByteArray.h" #include #include #include "peripherals/nrf/nvm.h" -uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) { +uint32_t common_hal_nvm_bytearray_get_length(const nvm_bytearray_obj_t *self) { return self->len; } @@ -50,7 +51,7 @@ static bool write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_ } } -bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, +bool common_hal_nvm_bytearray_set_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) { uint32_t address = (uint32_t)self->start_address + start_index; @@ -70,7 +71,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, return true; } -void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, +void common_hal_nvm_bytearray_get_bytes(const nvm_bytearray_obj_t *self, uint32_t start_index, uint32_t len, uint8_t *values) { memcpy(values, self->start_address + start_index, len); } diff --git a/ports/nrf/common-hal/os/__init__.c b/ports/nrf/common-hal/os/__init__.c index 5a0f10596c..caddcdc2e2 100644 --- a/ports/nrf/common-hal/os/__init__.c +++ b/ports/nrf/common-hal/os/__init__.c @@ -29,6 +29,8 @@ #include "py/objstr.h" #include "py/objtuple.h" +#include "shared-bindings/os/__init__.h" + #ifdef BLUETOOTH_SD #include "nrf_sdm.h" #endif @@ -61,7 +63,7 @@ mp_obj_t common_hal_os_uname(void) { return (mp_obj_t)&os_uname_info_obj; } -bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { +bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #ifdef BLUETOOTH_SD uint8_t sd_en = 0; (void)sd_softdevice_is_enabled(&sd_en); diff --git a/ports/nrf/common-hal/pwmio/PWMOut.c b/ports/nrf/common-hal/pwmio/PWMOut.c index 6dd4a153b8..76c8c4e6d4 100644 --- a/ports/nrf/common-hal/pwmio/PWMOut.c +++ b/ports/nrf/common-hal/pwmio/PWMOut.c @@ -86,7 +86,7 @@ void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) { } } -void reset_single_pwmout(uint8_t i) { +STATIC void reset_single_pwmout(uint8_t i) { NRF_PWM_Type *pwm = pwms[i]; pwm->ENABLE = 0; @@ -122,7 +122,7 @@ void pwmout_reset(void) { // Find the smallest prescaler value that will allow the divisor to be in range. // This allows the most accuracy. -bool convert_frequency(uint32_t frequency, uint16_t *countertop, nrf_pwm_clk_t *base_clock) { +STATIC bool convert_frequency(uint32_t frequency, uint16_t *countertop, nrf_pwm_clk_t *base_clock) { uint32_t divisor = 1; // Use a 32-bit number so we don't overflow the uint16_t; uint32_t tentative_countertop; diff --git a/ports/nrf/common-hal/rotaryio/IncrementalEncoder.c b/ports/nrf/common-hal/rotaryio/IncrementalEncoder.c index 425da9e6de..51e83b56af 100644 --- a/ports/nrf/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/nrf/common-hal/rotaryio/IncrementalEncoder.c @@ -26,6 +26,7 @@ #include "common-hal/rotaryio/IncrementalEncoder.h" #include "shared-module/rotaryio/IncrementalEncoder.h" +#include "shared-bindings/rotaryio/IncrementalEncoder.h" #include "nrfx_gpiote.h" #include "py/runtime.h" diff --git a/ports/nrf/common-hal/rtc/RTC.c b/ports/nrf/common-hal/rtc/RTC.c index 074079cd6b..0b7115a14f 100644 --- a/ports/nrf/common-hal/rtc/RTC.c +++ b/ports/nrf/common-hal/rtc/RTC.c @@ -30,6 +30,8 @@ #include "py/runtime.h" #include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" +#include "common-hal/rtc/RTC.h" +#include "shared-bindings/rtc/RTC.h" #include "supervisor/port.h" #include "supervisor/shared/translate.h" diff --git a/ports/nrf/device/nrf52/startup_nrf52840.c b/ports/nrf/device/nrf52/startup_nrf52840.c index 67380303d6..b6ef3c54ab 100644 --- a/ports/nrf/device/nrf52/startup_nrf52840.c +++ b/ports/nrf/device/nrf52/startup_nrf52840.c @@ -40,12 +40,14 @@ typedef void (*func)(void); extern void _start(void) __attribute__((noreturn)); extern void SystemInit(void); +extern void Default_Handler(void); void Default_Handler(void) { while (1) { ; } } +extern void Reset_Handler(void); void Reset_Handler(void) { uint32_t *p_src = &_sidata; uint32_t *p_dest = &_sdata; diff --git a/ports/nrf/fatfs_port.c b/ports/nrf/fatfs_port.c index 5882864bbe..38c2d923b8 100644 --- a/ports/nrf/fatfs_port.c +++ b/ports/nrf/fatfs_port.c @@ -29,6 +29,7 @@ #include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/RTC.h" #include "shared-bindings/time/__init__.h" +#include "supervisor/fatfs_port.h" DWORD _time_override = 0; DWORD get_fattime(void) { diff --git a/ports/nrf/peripherals/nrf/cache.c b/ports/nrf/peripherals/nrf/cache.c index 02e11c4613..6eb590d770 100644 --- a/ports/nrf/peripherals/nrf/cache.c +++ b/ports/nrf/peripherals/nrf/cache.c @@ -25,6 +25,7 @@ */ #include "nrfx.h" +#include "peripherals/nrf/cache.h" // Turn off cache and invalidate all data in it. void nrf_peripherals_disable_and_clear_cache(void) { diff --git a/ports/nrf/peripherals/nrf/nrf52840/power.c b/ports/nrf/peripherals/nrf/nrf52840/power.c index 192a49acca..e1573bd602 100644 --- a/ports/nrf/peripherals/nrf/nrf52840/power.c +++ b/ports/nrf/peripherals/nrf/nrf52840/power.c @@ -26,6 +26,7 @@ #include "nrfx.h" #include "hal/nrf_nvmc.h" +#include "peripherals/nrf/power.h" void nrf_peripherals_power_init(void) { // Set GPIO reference voltage to 3.3V if it isn't already. REGOUT0 will get reset to 0xfffffff diff --git a/ports/nrf/sd_mutex.c b/ports/nrf/sd_mutex.c index 2ae490288d..f94feb951b 100644 --- a/ports/nrf/sd_mutex.c +++ b/ports/nrf/sd_mutex.c @@ -27,6 +27,7 @@ #include "py/mpconfig.h" #include "py/runtime.h" #include "nrf_soc.h" +#include "sd_mutex.h" void sd_mutex_acquire_check(nrf_mutex_t *p_mutex) { uint32_t err_code = sd_mutex_acquire(p_mutex); diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 17e9817b5c..a1eb973b83 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -46,6 +46,7 @@ #include "common-hal/microcontroller/Pin.h" #include "common-hal/_bleio/__init__.h" +#include "common-hal/alarm/time/TimeAlarm.h" #include "common-hal/analogio/AnalogIn.h" #include "common-hal/busio/I2C.h" #include "common-hal/busio/SPI.h" @@ -97,7 +98,7 @@ static volatile struct { uint32_t suffix; } overflow_tracker __attribute__((section(".uninitialized"))); -void rtc_handler(nrfx_rtc_int_type_t int_type) { +STATIC void rtc_handler(nrfx_rtc_int_type_t int_type) { if (int_type == NRFX_RTC_INT_OVERFLOW) { // Our RTC is 24 bits and we're clocking it at 32.768khz which is 32 (2 ** 5) subticks per // tick. @@ -116,7 +117,7 @@ void rtc_handler(nrfx_rtc_int_type_t int_type) { } } -void tick_init(void) { +STATIC void tick_init(void) { if (!nrf_clock_lf_is_running(NRF_CLOCK)) { nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART); } @@ -137,7 +138,7 @@ void tick_init(void) { } } -void tick_uninit(void) { +STATIC void tick_uninit(void) { nrfx_rtc_counter_clear(&rtc_instance); nrfx_rtc_disable(&rtc_instance); nrfx_rtc_uninit(&rtc_instance); @@ -400,6 +401,7 @@ void port_idle_until_interrupt(void) { } +extern void HardFault_Handler(void); void HardFault_Handler(void) { reset_into_safe_mode(HARD_CRASH); while (true) { diff --git a/ports/nrf/supervisor/qspi_flash.c b/ports/nrf/supervisor/qspi_flash.c index 632fe4d212..df80671e64 100644 --- a/ports/nrf/supervisor/qspi_flash.c +++ b/ports/nrf/supervisor/qspi_flash.c @@ -26,6 +26,7 @@ */ #include "supervisor/spi_flash_api.h" +#include "supervisor/qspi_flash.h" #include #include @@ -69,7 +70,7 @@ void qspi_disable(void) { } } -void qspi_enable(void) { +STATIC void qspi_enable(void) { if (NRF_QSPI->ENABLE) { return; } diff --git a/ports/nrf/supervisor/qspi_flash.h b/ports/nrf/supervisor/qspi_flash.h index 527f3cec39..185a155be0 100644 --- a/ports/nrf/supervisor/qspi_flash.h +++ b/ports/nrf/supervisor/qspi_flash.h @@ -1,2 +1,3 @@ extern void qspi_flash_enter_sleep(void); extern void qspi_flash_exit_sleep(void); +extern void qspi_disable(void); diff --git a/ports/nrf/supervisor/usb.c b/ports/nrf/supervisor/usb.c index 6031cced50..8651b008f0 100644 --- a/ports/nrf/supervisor/usb.c +++ b/ports/nrf/supervisor/usb.c @@ -91,6 +91,7 @@ void init_usb_hardware(void) { } } +extern void USBD_IRQHandler(void); void USBD_IRQHandler(void) { usb_irq_handler(); } diff --git a/supervisor/shared/bluetooth/file_transfer.c b/supervisor/shared/bluetooth/file_transfer.c index d1841c87d0..bf42326275 100644 --- a/supervisor/shared/bluetooth/file_transfer.c +++ b/supervisor/shared/bluetooth/file_transfer.c @@ -44,6 +44,7 @@ #include "supervisor/fatfs_port.h" #include "supervisor/shared/autoreload.h" +#include "supervisor/shared/bluetooth/file_transfer.h" #include "supervisor/shared/bluetooth/file_transfer_protocol.h" #include "supervisor/shared/tick.h" #include "supervisor/usb.h" @@ -136,7 +137,7 @@ void supervisor_start_bluetooth_file_transfer(void) { // FATFS has a two second timestamp resolution but the BLE API allows for nanosecond resolution. // This function truncates the time the time to a resolution storable by FATFS and fills in the // FATFS encoded version into fattime. -uint64_t truncate_time(uint64_t input_time, DWORD *fattime) { +STATIC uint64_t truncate_time(uint64_t input_time, DWORD *fattime) { timeutils_struct_time_t tm; uint64_t seconds_since_epoch = timeutils_seconds_since_epoch_from_nanoseconds_since_1970(input_time); timeutils_seconds_since_epoch_to_struct_time(seconds_since_epoch, &tm); diff --git a/supervisor/shared/bluetooth/serial.c b/supervisor/shared/bluetooth/serial.c index 018acd5f4a..2edf3c784f 100644 --- a/supervisor/shared/bluetooth/serial.c +++ b/supervisor/shared/bluetooth/serial.c @@ -35,6 +35,7 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" #include "shared-module/storage/__init__.h" +#include "supervisor/shared/bluetooth/serial.h" #include "common-hal/_bleio/__init__.h" From a62675a81a83d4c2dcb91b74da3a2e394cd8f8cb Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Wed, 10 Nov 2021 22:33:44 +0530 Subject: [PATCH 58/84] fix wifi reset and monitor deinit routine --- ports/espressif/common-hal/wifi/Monitor.c | 3 +-- ports/espressif/common-hal/wifi/__init__.c | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/espressif/common-hal/wifi/Monitor.c b/ports/espressif/common-hal/wifi/Monitor.c index b0ce341d71..b37219d67b 100644 --- a/ports/espressif/common-hal/wifi/Monitor.c +++ b/ports/espressif/common-hal/wifi/Monitor.c @@ -102,8 +102,7 @@ void common_hal_wifi_monitor_construct(wifi_monitor_obj_t *self, uint8_t channel bool common_hal_wifi_monitor_deinited(void) { bool enabled; - esp_wifi_get_promiscuous(&enabled); - return !enabled; + return (esp_wifi_get_promiscuous(&enabled) == ESP_ERR_WIFI_NOT_INIT) ? true : !enabled; } void common_hal_wifi_monitor_deinit(wifi_monitor_obj_t *self) { diff --git a/ports/espressif/common-hal/wifi/__init__.c b/ports/espressif/common-hal/wifi/__init__.c index c349ca4b39..c926802bae 100644 --- a/ports/espressif/common-hal/wifi/__init__.c +++ b/ports/espressif/common-hal/wifi/__init__.c @@ -174,6 +174,7 @@ void wifi_reset(void) { radio->netif = NULL; esp_netif_destroy(radio->ap_netif); radio->ap_netif = NULL; + wifi_inited = false; } void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t *esp_ip_address) { From 017b52c4554a150aa9d2425e9b01d93e5ad83db0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Nov 2021 12:11:06 -0600 Subject: [PATCH 59/84] further raspberrypi fixes --- ports/raspberrypi/Makefile | 1 + ports/raspberrypi/stage2.c.jinja | 1 + 2 files changed, 2 insertions(+) diff --git a/ports/raspberrypi/Makefile b/ports/raspberrypi/Makefile index 28e28d6269..b63b26d58d 100644 --- a/ports/raspberrypi/Makefile +++ b/ports/raspberrypi/Makefile @@ -187,6 +187,7 @@ SRC_SDK := \ src/rp2_common/pico_unique_id/unique_id.c \ SRC_SDK := $(addprefix sdk/, $(SRC_SDK)) +$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK)): CFLAGS += -Wno-missing-prototypes SRC_C += \ boards/$(BOARD)/board.c \ diff --git a/ports/raspberrypi/stage2.c.jinja b/ports/raspberrypi/stage2.c.jinja index 13de7bff9f..4c001525dc 100644 --- a/ports/raspberrypi/stage2.c.jinja +++ b/ports/raspberrypi/stage2.c.jinja @@ -46,6 +46,7 @@ static uint8_t read_flash_sreg(uint8_t status_command); // This must be the first defined function so that it is placed at the start of // memory where the bootloader jumps to! +extern void _stage2_boot(void); void __attribute__((section(".entry._stage2_boot"), used)) _stage2_boot(void) { uint32_t lr; asm ("MOV %0, LR\n" : "=r" (lr) ); From 5cba23e04dfc05dda60a84c026be864df866c186 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Nov 2021 12:22:07 -0600 Subject: [PATCH 60/84] More missing-prototypes fixes --- ports/atmel-samd/supervisor/port.c | 1 + ports/espressif/modules/none.c | 2 ++ supervisor/supervisor.mk | 3 +++ 3 files changed, 6 insertions(+) diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 5038d2550c..ccff352443 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -109,6 +109,7 @@ #include "shared-bindings/rtc/__init__.h" #include "shared_timers.h" #include "reset.h" +#include "common-hal/pulseio/PulseIn.h" #include "supervisor/background_callback.h" #include "supervisor/shared/safe_mode.h" diff --git a/ports/espressif/modules/none.c b/ports/espressif/modules/none.c index 9b5433bd9d..aa751bf3f4 100644 --- a/ports/espressif/modules/none.c +++ b/ports/espressif/modules/none.c @@ -24,5 +24,7 @@ * THE SOFTWARE. */ +#include "modules/module.h" + void never_reset_module_internal_pins(void) { } diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 6789ab32ea..3270f76ed1 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -137,6 +137,9 @@ else endif endif +SRC_TINYUSB = $(filter lib/tinyusb/%.c, $(SRC_SUPERVISOR)) +$(patsubst %.c,$(BUILD)/%.o,$(SRC_TINYUSB)): CFLAGS += -Wno-missing-prototypes + SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o)) ifeq ($(CIRCUITPY_DISPLAYIO), 1) From ebc8359c67d8989dfeb196b9a86b0d4c8c593173 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Nov 2021 12:47:55 -0600 Subject: [PATCH 61/84] disable missing-prototypes diagnostics in yet another tinyusb file --- ports/atmel-samd/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 045f3741eb..9c4bc7a14d 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -328,6 +328,8 @@ SRC_C += \ timer_handler.c \ $(SRC_PERIPHERALS) \ +$(BUILD)/lib/tinyusb/src/portable/microchip/samd/dcd_samd.o: CFLAGS += -Wno-missing-prototypes + # This is an OR because it filters to any 1s and then checks to see if it is not # empty. ifneq (,$(filter 1,$(CIRCUITPY_PWMIO) $(CIRCUITPY_AUDIOIO) $(CIRCUITPY_RGBMATRIX))) From b01e2d66746415ee2c2ccb7dfa136bc67a5186c2 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 1 Nov 2021 16:02:11 -0400 Subject: [PATCH 62/84] enable running asyncio --- extmod/moduselect.c | 13 +++++++++---- py/circuitpy_mpconfig.h | 7 +++++++ py/circuitpy_mpconfig.mk | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/extmod/moduselect.c b/extmod/moduselect.c index 1b9617fca9..c8f5e57363 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -150,7 +150,7 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { mp_map_deinit(&poll_map); return mp_obj_new_tuple(3, list_array); } - MICROPY_EVENT_POLL_HOOK + RUN_BACKGROUND_TASKS; } } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select); @@ -229,7 +229,7 @@ STATIC mp_uint_t poll_poll_internal(uint n_args, const mp_obj_t *args) { if (n_ready > 0 || (timeout != (mp_uint_t)-1 && mp_hal_ticks_ms() - start_tick >= timeout)) { break; } - MICROPY_EVENT_POLL_HOOK + RUN_BACKGROUND_TASKS; } return n_ready; @@ -318,10 +318,13 @@ STATIC MP_DEFINE_CONST_DICT(poll_locals_dict, poll_locals_dict_table); STATIC const mp_obj_type_t mp_type_poll = { { &mp_type_type }, + .flags = MP_TYPE_FLAG_EXTENDED, .name = MP_QSTR_poll, - .getiter = mp_identity_getiter, - .iternext = poll_iternext, .locals_dict = (void *)&poll_locals_dict, + MP_TYPE_EXTENDED_FIELDS( + .getiter = mp_identity_getiter, + .iternext = poll_iternext, + ), }; // poll() @@ -354,4 +357,6 @@ const mp_obj_module_t mp_module_uselect = { .globals = (mp_obj_dict_t *)&mp_module_select_globals, }; +MP_REGISTER_MODULE(MP_QSTR_select, mp_module_uselect, MICROPY_PY_USELECT); + #endif // MICROPY_PY_USELECT diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 3c6d5c6110..ad5797b4d8 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -45,6 +45,13 @@ // free bytes. // #define MICROPY_ALLOC_PARSE_RULE_INIT (64) +// These critical-section macros are used only a few places in MicroPython, but +// we need to provide actual implementations. +extern void common_hal_mcu_disable_interrupts(void); +extern void common_hal_mcu_enable_interrupts(void); +#define MICROPY_BEGIN_ATOMIC_SECTION() (common_hal_mcu_disable_interrupts(), 0) +#define MICROPY_END_ATOMIC_SECTION(state) ((void)state, common_hal_mcu_enable_interrupts()) + // Sorted alphabetically for easy finding. // // default is 128; consider raising to reduce fragmentation. diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 04f0778290..ccb9daf5eb 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -36,6 +36,20 @@ CFLAGS += -DCIRCUITPY_FULL_BUILD=$(CIRCUITPY_FULL_BUILD) MICROPY_PY_ASYNC_AWAIT ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT) +# uasyncio +# By default, include uasyncio if async/await are available. +MICROPY_PY_UASYNCIO ?= $(MICROPY_PY_ASYNC_AWAIT) +CFLAGS += -DMICROPY_PY_UASYNCIO=$(MICROPY_PY_UASYNCIO) + +# uasyncio normally needs select +MICROPY_PY_USELECT ?= $(MICROPY_PY_UASYNCIO) +CFLAGS += -DMICROPY_PY_USELECT=$(MICROPY_PY_USELECT) + +# enable select.select if select is enabled. +MICROPY_PY_USELECT_SELECT ?= $(MICROPY_PY_USELECT) +CFLAGS += -DMICROPY_PY_USELECT_SELECT=$(MICROPY_PY_USELECT_SELECT) + + CIRCUITPY_AESIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_AESIO=$(CIRCUITPY_AESIO) From 58485bc0b1e47e6ef13691a7629356c2a24ca16d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 10 Nov 2021 15:58:42 -0500 Subject: [PATCH 63/84] Switch SAMD51 and SAME51 back to -Os from -O2 The SAMx51 builds were getting very close to full on larger translations. This PR adds 1400 bytes of enabled features, and pushed some over the edge. --- ports/atmel-samd/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 721cfd4f0a..c828a78df5 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -94,14 +94,14 @@ endif ifeq ($(CHIP_FAMILY), samd51) PERIPHERALS_CHIP_FAMILY=sam_d5x_e5x -OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions +OPTIMIZATION_FLAGS ?= -Os # TinyUSB defines CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024 endif ifeq ($(CHIP_FAMILY), same51) PERIPHERALS_CHIP_FAMILY=sam_d5x_e5x -OPTIMIZATION_FLAGS ?= -O2 -fno-inline-functions +OPTIMIZATION_FLAGS ?= -Os # TinyUSB defines CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAME5X -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024 endif From d30c3ba4c6f27e01267335d14b76051d2977037b Mon Sep 17 00:00:00 2001 From: ladyada Date: Wed, 10 Nov 2021 17:23:29 -0500 Subject: [PATCH 64/84] nu board w tft --- .../adafruit_feather_esp32s2_tft/board.c | 116 ++++++++++++++++++ .../mpconfigboard.h | 49 ++++++++ .../mpconfigboard.mk | 20 +++ .../adafruit_feather_esp32s2_tft/pins.c | 73 +++++++++++ .../adafruit_feather_esp32s2_tft/sdkconfig | 33 +++++ 5 files changed, 291 insertions(+) create mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c create mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h create mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.mk create mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c create mode 100644 ports/espressif/boards/adafruit_feather_esp32s2_tft/sdkconfig diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c new file mode 100644 index 0000000000..f704801581 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c @@ -0,0 +1,116 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" + +/* +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 150, // SWRESET + 0x11, 0 | DELAY, 255, // SLPOUT + 0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order. + 0x3a, 1, 0x55, // COLMOD - 16bit color + 0x21, 0 | DELAY, 10, // _INVON + 0x13, 0 | DELAY, 10, // _NORON + 0x29, 0 | DELAY, 255, // _DISPON +}; + +*/ + +void board_init(void) { + // USB + common_hal_never_reset_pin(&pin_GPIO19); + common_hal_never_reset_pin(&pin_GPIO20); + + + /* + busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL); + common_hal_busio_spi_never_reset(spi); + + displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + common_hal_displayio_fourwire_construct(bus, + spi, + &pin_GPIO40, // TFT_DC Command or data + &pin_GPIO42, // TFT_CS Chip select + &pin_GPIO41, // TFT_RST Reset + 4000000, // Baudrate + 0, // Polarity + 0); // Phase + + displayio_display_obj_t* display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct(display, + bus, + 240, // Width (after rotation) + 135, // Height (after rotation) + 0, // column start + 0, // row start + 0, // rotation + 16, // Color depth + false, // Grayscale + false, // Pixels in a byte share a row. Only used for depth < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO7, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false); // not SH1107 + */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h new file mode 100644 index 0000000000..b850b85e01 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "Adafruit Feather ESP32-S2 TFT" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO33) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO34) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO41) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO42) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO2) +#define DEFAULT_UART_BUS_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.mk b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.mk new file mode 100644 index 0000000000..0f099f8b22 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.mk @@ -0,0 +1,20 @@ +USB_VID = 0x239A +USB_PID = 0x8110 + +USB_PRODUCT = "Feather ESP32-S2 TFT" +USB_MANUFACTURER = "Adafruit" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=4MB + +CIRCUITPY_MODULE=wroom diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c new file mode 100644 index 0000000000..efb545241f --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c @@ -0,0 +1,73 @@ +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_R2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO45) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } + + // { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/sdkconfig b/ports/espressif/boards/adafruit_feather_esp32s2_tft/sdkconfig new file mode 100644 index 0000000000..9d8bbde967 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/sdkconfig @@ -0,0 +1,33 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=2097152 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config From e7d9dc323bc6c8ce197086a0445c4f50a767fb20 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 10 Nov 2021 21:12:41 -0500 Subject: [PATCH 65/84] shrink kicksat-sprite, simmel, pyb_nano_v2 --- ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk | 2 ++ ports/nrf/boards/simmel/mpconfigboard.mk | 2 ++ ports/stm/boards/pyb_nano_v2/mpconfigboard.mk | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index b9622c2faf..11afb2acdc 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -12,6 +12,8 @@ LONGINT_IMPL = MPZ # Not needed. CIRCUITPY_AESIO = 0 CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_AUDIOMIXER = 0 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_DISPLAYIO = 0 diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index df67271445..67f5dfbd6d 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -12,6 +12,7 @@ INTERNAL_FLASH_FILESYSTEM = 1 CIRCUITPY_ALARM = 0 CIRCUITPY_AESIO = 1 +CIRCUITPY_AUDIOMIXER = 0 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BUSDEVICE = 0 @@ -25,6 +26,7 @@ CIRCUITPY_KEYPAD = 0 CIRCUITPY_MSGPACK = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 CIRCUITPY_NVM = 0 +CIRCUITPY_ONEWIREIO = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 1 diff --git a/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk index 74ce665a5b..29bfd62620 100644 --- a/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk +++ b/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk @@ -16,9 +16,9 @@ LD_FILE = boards/STM32F411_fs.ld # Too big for the flash CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_AUDIOPWMIO = 0 -CIRCUITPY_KEYPAD = 0 -CIRCUITPY_GIFIO = 0 -CIRCUITPY_MIDI = 0 -CIRCUITPY_MSGPACK = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BUSDEVICE = 0 +CIRCUITPY_GIFIO = 0 +CIRCUITPY_KEYPAD = 0 +CIRCUITPY_MSGPACK = 0 +CIRCUITPY_ONEWIREIO = 0 From 340d6b9213597e3bb7359cc30905848925753cc7 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Nov 2021 12:47:55 -0600 Subject: [PATCH 66/84] more missing-prototypes fixes --- ports/atmel-samd/common-hal/alarm/SleepMemory.c | 1 + ports/atmel-samd/supervisor/internal_flash.c | 8 ++------ ports/espressif/boards/ai_thinker_esp32-c3s/board.c | 1 + ports/espressif/boards/microdev_micro_c3/board.c | 3 +++ ports/nrf/device/nrf52/startup_nrf52833.c | 2 ++ .../boards/jpconstantineau_encoderpad_rp2040/board.c | 1 + shared-module/gamepadshift/GamePadShift.c | 1 + 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ports/atmel-samd/common-hal/alarm/SleepMemory.c b/ports/atmel-samd/common-hal/alarm/SleepMemory.c index cb3b1b3aa9..8ad3577564 100644 --- a/ports/atmel-samd/common-hal/alarm/SleepMemory.c +++ b/ports/atmel-samd/common-hal/alarm/SleepMemory.c @@ -28,6 +28,7 @@ #include "py/runtime.h" #include "common-hal/alarm/SleepMemory.h" +#include "shared-bindings/alarm/SleepMemory.h" #include "shared-bindings/nvm/ByteArray.h" void alarm_sleep_memory_reset(void) { diff --git a/ports/atmel-samd/supervisor/internal_flash.c b/ports/atmel-samd/supervisor/internal_flash.c index afac001232..3e57e21d91 100644 --- a/ports/atmel-samd/supervisor/internal_flash.c +++ b/ports/atmel-samd/supervisor/internal_flash.c @@ -78,10 +78,6 @@ void port_internal_flash_flush(void) { void supervisor_flash_release_cache(void) { } -void flash_flush(void) { - supervisor_flash_flush(); -} - static int32_t convert_block_to_flash_addr(uint32_t block) { if (0 <= block && block < INTERNAL_FLASH_PART1_NUM_BLOCKS) { // a block in partition 1 @@ -91,7 +87,7 @@ static int32_t convert_block_to_flash_addr(uint32_t block) { return -1; } -bool supervisor_flash_read_block(uint8_t *dest, uint32_t block) { +STATIC bool supervisor_flash_read_block(uint8_t *dest, uint32_t block) { // non-MBR block, get data from flash memory int32_t src = convert_block_to_flash_addr(block); if (src == -1) { @@ -102,7 +98,7 @@ bool supervisor_flash_read_block(uint8_t *dest, uint32_t block) { return error_code == ERR_NONE; } -bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) { +STATIC bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) { // non-MBR block, copy to cache int32_t dest = convert_block_to_flash_addr(block); if (dest == -1) { diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c index 3d392892e3..83ef690007 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c @@ -26,6 +26,7 @@ */ #include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" void board_init(void) { diff --git a/ports/espressif/boards/microdev_micro_c3/board.c b/ports/espressif/boards/microdev_micro_c3/board.c index 183740a7c3..7ffd406cfe 100644 --- a/ports/espressif/boards/microdev_micro_c3/board.c +++ b/ports/espressif/boards/microdev_micro_c3/board.c @@ -25,6 +25,7 @@ */ #include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" void board_init(void) { // USB @@ -54,5 +55,7 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } +#if CIRCUITPY_ALARM void board_deinit(void) { } +#endif diff --git a/ports/nrf/device/nrf52/startup_nrf52833.c b/ports/nrf/device/nrf52/startup_nrf52833.c index ad60839520..67abf71ce4 100644 --- a/ports/nrf/device/nrf52/startup_nrf52833.c +++ b/ports/nrf/device/nrf52/startup_nrf52833.c @@ -39,6 +39,8 @@ typedef void (*func)(void); extern void _start(void) __attribute__((noreturn)); extern void SystemInit(void); +extern void Default_Handler(void); +extern void Reset_Handler(void); void Default_Handler(void) { while (1) { diff --git a/ports/raspberrypi/boards/jpconstantineau_encoderpad_rp2040/board.c b/ports/raspberrypi/boards/jpconstantineau_encoderpad_rp2040/board.c index 57866b00ab..831bf96cdf 100644 --- a/ports/raspberrypi/boards/jpconstantineau_encoderpad_rp2040/board.c +++ b/ports/raspberrypi/boards/jpconstantineau_encoderpad_rp2040/board.c @@ -28,6 +28,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" #include "supervisor/shared/board.h" +#include "supervisor/board.h" void board_init(void) { } diff --git a/shared-module/gamepadshift/GamePadShift.c b/shared-module/gamepadshift/GamePadShift.c index 6efa0ea5cf..0fb7d1e8d3 100644 --- a/shared-module/gamepadshift/GamePadShift.c +++ b/shared-module/gamepadshift/GamePadShift.c @@ -26,6 +26,7 @@ #include "py/mpstate.h" #include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/gamepadshift/GamePadShift.h" #include "shared-module/gamepadshift/GamePadShift.h" #include "supervisor/shared/tick.h" From f058c5ec8c5ebade25ac98f646ffa3c91c709823 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 10 Nov 2021 23:05:06 -0500 Subject: [PATCH 67/84] fix kicksat-sprite --- ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index 11afb2acdc..dd6b811f5b 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -13,6 +13,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_AESIO = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOMIXER = 0 CIRCUITPY_AUDIOMP3 = 0 CIRCUITPY_BLEIO_HCI = 0 From bcec249091b1bd3fa1207b51fa2d2bdf456b13ae Mon Sep 17 00:00:00 2001 From: lady ada Date: Wed, 10 Nov 2021 23:13:22 -0500 Subject: [PATCH 68/84] displaaaaaaaaay --- .../adafruit_feather_esp32s2_tft/board.c | 126 +++++++++++------- .../adafruit_feather_esp32s2_tft/pins.c | 2 +- 2 files changed, 82 insertions(+), 46 deletions(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c index f704801581..b82021d89d 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c @@ -32,22 +32,42 @@ #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" -/* displayio_fourwire_obj_t board_display_obj; #define DELAY 0x80 +// display init sequence according to LilyGO example app uint8_t display_init_sequence[] = { - 0x01, 0 | DELAY, 150, // SWRESET - 0x11, 0 | DELAY, 255, // SLPOUT - 0x36, 1, 0x00, // _MADCTL bottom to top refresh in vsync aligned order. - 0x3a, 1, 0x55, // COLMOD - 16bit color - 0x21, 0 | DELAY, 10, // _INVON - 0x13, 0 | DELAY, 10, // _NORON - 0x29, 0 | DELAY, 255, // _DISPON + // sw reset + 0x01, 0 | DELAY, 150, + // sleep out + 0x11, 0 | DELAY, 255, + // normal display mode on + 0x13, 0, + // display and color format settings + 0x36, 1, 0x08, + 0xB6, 2, 0x0A, 0x82, + 0x3A, 1 | DELAY, 0x55, 10, + // ST7789V frame rate setting + 0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33, + // voltages: VGH / VGL + 0xB7, 1, 0x35, + // ST7789V power setting + 0xBB, 1, 0x28, + 0xC0, 1, 0x0C, + 0xC2, 2, 0x01, 0xFF, + 0xC3, 1, 0x10, + 0xC4, 1, 0x20, + 0xC6, 1, 0x0F, + 0xD0, 2, 0xA4, 0xA1, + // ST7789V gamma setting + 0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17, + 0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E, + 0x21, 0, + // display on + 0x29, 0 | DELAY, 255, }; -*/ void board_init(void) { // USB @@ -55,53 +75,69 @@ void board_init(void) { common_hal_never_reset_pin(&pin_GPIO20); - /* - busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL); + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + + common_hal_busio_spi_construct( + spi, + &pin_GPIO36, // CLK + &pin_GPIO35, // MOSI + NULL // MISO not connected + ); + common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; bus->base.type = &displayio_fourwire_type; - common_hal_displayio_fourwire_construct(bus, - spi, - &pin_GPIO40, // TFT_DC Command or data - &pin_GPIO42, // TFT_CS Chip select - &pin_GPIO41, // TFT_RST Reset - 4000000, // Baudrate - 0, // Polarity - 0); // Phase + common_hal_displayio_fourwire_construct( + bus, + spi, + &pin_GPIO39, // DC + &pin_GPIO21, // CS + &pin_GPIO40, // RST + 40000000, // baudrate + 0, // polarity + 0 // phase + ); displayio_display_obj_t* display = &displays[0].display; display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + + // workaround as board_init() is called before reset_port() in main.c + pwmout_reset(); + + + common_hal_displayio_display_construct( + display, bus, - 240, // Width (after rotation) - 135, // Height (after rotation) - 0, // column start - 0, // row start - 0, // rotation - 16, // Color depth - false, // Grayscale - false, // Pixels in a byte share a row. Only used for depth < 8 - 1, // bytes per cell. Only valid for depths < 8 - false, // reverse_pixels_in_byte. Only valid for depths < 8 - true, // reverse_pixels_in_word - MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command - MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command - MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + 240, // width (after rotation) + 135, // height (after rotation) + 52, // column start + 40, // row start + 90, // rotation + 16, // color depth + false, // grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command + MIPI_COMMAND_WRITE_MEMORY_START, // write memory command display_init_sequence, sizeof(display_init_sequence), - &pin_GPIO7, // backlight pin + &pin_GPIO45, // backlight pin NO_BRIGHTNESS_COMMAND, - 1.0f, // brightness (ignored) - true, // auto_brightness - false, // single_byte_bounds - false, // data_as_commands - true, // auto_refresh - 60, // native_frames_per_second - true, // backlight_on_high - false); // not SH1107 - */ + 1.0f, // brightness (ignored) + false, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false // SH1107_addressing + ); + + common_hal_never_reset_pin(&pin_GPIO45); // backlight pin } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c index efb545241f..ba5afa128c 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c @@ -68,6 +68,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } - // { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 25ff6b080eb27b3d3ecee12df3077edad831efca Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 11 Nov 2021 08:36:01 -0600 Subject: [PATCH 69/84] ble_hci: instead of deleting code, disable unused function warnings --- devices/ble_hci/common-hal/_bleio/att.c | 133 +++++++++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) diff --git a/devices/ble_hci/common-hal/_bleio/att.c b/devices/ble_hci/common-hal/_bleio/att.c index ff3294a865..abfe7429f4 100644 --- a/devices/ble_hci/common-hal/_bleio/att.c +++ b/devices/ble_hci/common-hal/_bleio/att.c @@ -1,6 +1,12 @@ // Derived from ArduinoBLE. // Copyright 2020 Dan Halbert for Adafruit Industries +// Some functions here are unused now, but may be used in the future. +// Don't warn or error about this, and depend on the compiler & linker to +// eliminate the associated code. +#pragma GCC diagnostic ignored "-Wunused" +#pragma GCC diagnostic ignored "-Wunused-function" + /* This file is part of the ArduinoBLE library. Copyright (c) 2018 Arduino SA. All rights reserved. @@ -857,6 +863,20 @@ STATIC void process_find_info_req(uint16_t conn_handle, uint16_t mtu, uint8_t dl } } +static int att_find_info_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint8_t response_buffer[]) { + struct __packed req { + struct bt_att_hdr h; + struct bt_att_find_info_req r; + } req = { { + .code = BT_ATT_OP_FIND_INFO_REQ, + }, { + .start_handle = start_handle, + .end_handle = end_handle, + }}; + + return send_req_wait_for_rsp(conn_handle, sizeof(req), (uint8_t *)&req, response_buffer); +} + STATIC void process_find_info_rsp(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) { if (dlen < 2) { return; // invalid, drop @@ -911,7 +931,7 @@ STATIC void process_find_type_req(uint16_t conn_handle, uint16_t mtu, uint8_t dl } } -STATIC void process_read_group_req(uint16_t conn_handle, uint16_t mtu, uint8_t dlen, uint8_t data[]) { +static void process_read_group_req(uint16_t conn_handle, uint16_t mtu, uint8_t dlen, uint8_t data[]) { struct bt_att_read_group_req *req = (struct bt_att_read_group_req *)data; uint16_t type_uuid = req->uuid[0] | (req->uuid[1] << 8); @@ -995,6 +1015,25 @@ STATIC void process_read_group_req(uint16_t conn_handle, uint16_t mtu, uint8_t d } } +static int att_read_group_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid, uint8_t response_buffer[]) { + + typedef struct __packed { + struct bt_att_hdr h; + struct bt_att_read_group_req r; + } req_t; + + uint8_t req_bytes[sizeof(req_t) + sizeof(uuid)]; + req_t *req = (req_t *)req_bytes; + + req->h.code = BT_ATT_OP_READ_GROUP_REQ; + req->r.start_handle = start_handle; + req->r.end_handle = end_handle; + req->r.uuid[0] = uuid & 0xff; + req->r.uuid[1] = uuid >> 8; + + return send_req_wait_for_rsp(conn_handle, sizeof(req_bytes), req_bytes, response_buffer); +} + STATIC void process_read_group_rsp(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) { if (dlen < 2) { return; // invalid, drop @@ -1272,6 +1311,24 @@ STATIC void process_read_type_req(uint16_t conn_handle, uint16_t mtu, uint8_t dl } } +static int att_read_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint16_t type, uint8_t response_buffer[]) { + typedef struct __packed { + struct bt_att_hdr h; + struct bt_att_read_type_req r; + } req_t; + + uint8_t req_bytes[sizeof(req_t) + sizeof(type)]; + req_t *req = (req_t *)req_bytes; + + req->h.code = BT_ATT_OP_READ_TYPE_REQ; + req->r.start_handle = start_handle; + req->r.end_handle = end_handle; + req->r.uuid[0] = type & 0xff; + req->r.uuid[1] = type >> 8; + + return send_req_wait_for_rsp(conn_handle, sizeof(req_bytes), req_bytes, response_buffer); +} + STATIC void process_read_type_rsp(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) { if (dlen < 1) { return; // invalid, drop @@ -1662,3 +1719,77 @@ void att_process_data(uint16_t conn_handle, uint8_t dlen, uint8_t data[]) { break; } } + +// FIX Do we need all of these? +static void check_att_err(uint8_t err) { + const compressed_string_t *msg = NULL; + switch (err) { + case 0: + return; + case BT_ATT_ERR_INVALID_HANDLE: + msg = translate("Invalid handle"); + break; + case BT_ATT_ERR_READ_NOT_PERMITTED: + msg = translate("Read not permitted"); + break; + case BT_ATT_ERR_WRITE_NOT_PERMITTED: + msg = translate("Write not permitted"); + break; + case BT_ATT_ERR_INVALID_PDU: + msg = translate("Invalid PDU"); + break; + case BT_ATT_ERR_NOT_SUPPORTED: + msg = translate("Not supported"); + break; + case BT_ATT_ERR_INVALID_OFFSET: + msg = translate("Invalid offset"); + break; + case BT_ATT_ERR_PREPARE_QUEUE_FULL: + msg = translate("Prepare queue full"); + break; + case BT_ATT_ERR_ATTRIBUTE_NOT_FOUND: + msg = translate("Attribute not found"); + break; + case BT_ATT_ERR_ATTRIBUTE_NOT_LONG: + msg = translate("Attribute not long"); + break; + case BT_ATT_ERR_ENCRYPTION_KEY_SIZE: + msg = translate("Encryption key size"); + break; + case BT_ATT_ERR_INVALID_ATTRIBUTE_LEN: + msg = translate("Invalid attribute length"); + break; + case BT_ATT_ERR_UNLIKELY: + msg = translate("Unlikely"); + break; + case BT_ATT_ERR_UNSUPPORTED_GROUP_TYPE: + msg = translate("Unsupported group type"); + break; + case BT_ATT_ERR_INSUFFICIENT_RESOURCES: + msg = translate("Insufficient resources"); + break; + case BT_ATT_ERR_DB_OUT_OF_SYNC: + msg = translate("DB out of sync"); + break; + case BT_ATT_ERR_VALUE_NOT_ALLOWED: + msg = translate("Value not allowed"); + break; + } + if (msg) { + mp_raise_bleio_BluetoothError(msg); + } + + switch (err) { + case BT_ATT_ERR_AUTHENTICATION: + msg = translate("Insufficient authentication"); + break; + case BT_ATT_ERR_INSUFFICIENT_ENCRYPTION: + msg = translate("Insufficient encryption"); + break; + } + if (msg) { + mp_raise_bleio_SecurityError(msg); + } + + mp_raise_bleio_BluetoothError(translate("Unknown ATT error: 0x%02x"), err); +} From cd6599ce651572c2f698948ed639334d96fb6191 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 11 Nov 2021 08:42:30 -0600 Subject: [PATCH 70/84] A few more missing-prototypes fixes --- ports/atmel-samd/boards/pewpew_m4/board.c | 2 +- ports/atmel-samd/common-hal/canio/Listener.c | 2 +- ports/espressif/boards/ai_thinker_esp32-c3s/board.c | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c index 6ce97f7b3f..5e339d88cb 100644 --- a/ports/atmel-samd/boards/pewpew_m4/board.c +++ b/ports/atmel-samd/boards/pewpew_m4/board.c @@ -50,7 +50,7 @@ typedef struct { #define DELAY 0x80 -uint32_t lookupCfg(uint32_t key, uint32_t defl) { +STATIC uint32_t lookupCfg(uint32_t key, uint32_t defl) { const uint32_t *ptr = UF2_BINFO->config_data; if (!ptr || (((uint32_t)ptr) & 3) || *ptr != CFG_MAGIC0) { // no config data! diff --git a/ports/atmel-samd/common-hal/canio/Listener.c b/ports/atmel-samd/common-hal/canio/Listener.c index e171ae5193..5cdfafe9c0 100644 --- a/ports/atmel-samd/common-hal/canio/Listener.c +++ b/ports/atmel-samd/common-hal/canio/Listener.c @@ -195,7 +195,7 @@ STATIC void install_extended_filter(CanMramXidfe *extended, int id1, int id2, in #define NO_ID (-1) -void set_filters(canio_listener_obj_t *self, size_t nmatch, canio_match_obj_t **matches) { +STATIC void set_filters(canio_listener_obj_t *self, size_t nmatch, canio_match_obj_t **matches) { int fifo = self->fifo_idx; if (!nmatch) { diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c index 83ef690007..820228ef98 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c @@ -52,6 +52,3 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } - -void board_deinit(void) { -} From 0ba47ed11540eb0363f769822786928df6b180c1 Mon Sep 17 00:00:00 2001 From: lady ada Date: Thu, 11 Nov 2021 11:43:44 -0500 Subject: [PATCH 71/84] comma on --- ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c index ba5afa128c..8d888ebfe7 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c @@ -66,7 +66,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} }; From e8e7e0a66ed2ae1b1b2d152978fc42cec6447810 Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Thu, 11 Nov 2021 14:53:53 +0000 Subject: [PATCH 72/84] Translated using Weblate (Swedish) Currently translated at 100.0% (1020 of 1020 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 339cd61b4a..15eabd382b 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-09 17:54+0000\n" +"PO-Revision-Date: 2021-11-11 18:10+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.9-dev\n" +"X-Generator: Weblate 4.9.1-dev\n" #: main.c msgid "" @@ -2681,7 +2681,7 @@ msgstr "binär op %q är inte implementerad" #: shared-bindings/bitmaptools/__init__.c msgid "bitmap sizes must match" -msgstr "" +msgstr "bitmappsstorlekar måste matcha" #: extmod/modurandom.c msgid "bits must be 32 or less" @@ -4187,15 +4187,15 @@ msgstr "källpalett för stor" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 2 or 65536" -msgstr "" +msgstr "source_bitmap måste ha value_count av 2 eller 65536" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 65536" -msgstr "" +msgstr "source_bitmap måste ha value_count av 65536" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 8" -msgstr "" +msgstr "source_bitmap måste ha value_count av 8" #: py/objstr.c msgid "start/end indices" @@ -4447,7 +4447,7 @@ msgstr "färgrymd stöds inte för GifWriter" #: shared-bindings/bitmaptools/__init__.c msgid "unsupported colorspace for dither" -msgstr "" +msgstr "färgrymd stöds inte för dither" #: py/objstr.c #, c-format From 90d5a905675d5a83e7458e8a7aa2c3b0b8f1a700 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Thu, 11 Nov 2021 19:10:47 +0100 Subject: [PATCH 73/84] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 8 ++++++++ locale/cs.po | 8 ++++++++ locale/de_DE.po | 8 ++++++++ locale/el.po | 8 ++++++++ locale/en_GB.po | 8 ++++++++ locale/es.po | 8 ++++++++ locale/fil.po | 8 ++++++++ locale/fr.po | 8 ++++++++ locale/hi.po | 8 ++++++++ locale/it_IT.po | 8 ++++++++ locale/ja.po | 8 ++++++++ locale/ko.po | 8 ++++++++ locale/nl.po | 8 ++++++++ locale/pl.po | 8 ++++++++ locale/pt_BR.po | 8 ++++++++ locale/sv.po | 8 ++++++++ locale/zh_Latn_pinyin.po | 8 ++++++++ 17 files changed, 136 insertions(+) diff --git a/locale/ID.po b/locale/ID.po index 393b70bd1c..82a85af5c0 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -156,6 +156,10 @@ msgstr "%q harus bertipe %q" msgid "%q must be power of 2" msgstr "%q harus pangkat 2" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3607,6 +3611,10 @@ msgstr "" msgid "module not found" msgstr "modul tidak ditemukan" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index 74ef37ac14..f9d4df2cbc 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -151,6 +151,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3573,6 +3577,10 @@ msgstr "" msgid "module not found" msgstr "" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 17c0838e44..85643b1335 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -156,6 +156,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3632,6 +3636,10 @@ msgstr "" msgid "module not found" msgstr "Modul nicht gefunden" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "mehr Freiheitsgrade als Datenpunkte" diff --git a/locale/el.po b/locale/el.po index 61a5d6a641..ec3365d0a6 100644 --- a/locale/el.po +++ b/locale/el.po @@ -148,6 +148,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3570,6 +3574,10 @@ msgstr "" msgid "module not found" msgstr "" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index e57c17b9fc..01698f9688 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -157,6 +157,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "%q must be power of 2" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3607,6 +3611,10 @@ msgstr "mode must be complete, or reduced" msgid "module not found" msgstr "module not found" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "more degrees of freedom than data points" diff --git a/locale/es.po b/locale/es.po index a1af9c8baf..87223418d3 100644 --- a/locale/es.po +++ b/locale/es.po @@ -159,6 +159,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3650,6 +3654,10 @@ msgstr "" msgid "module not found" msgstr "módulo no encontrado" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "más grados de libertad que los puntos de datos" diff --git a/locale/fil.po b/locale/fil.po index c2a0f26c75..52d414351d 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -150,6 +150,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3609,6 +3613,10 @@ msgstr "" msgid "module not found" msgstr "module hindi nakita" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index 65a9389cff..fa72516685 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -159,6 +159,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "%q doit être une puissance de 2" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3658,6 +3662,10 @@ msgstr "" msgid "module not found" msgstr "module introuvable" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "plus de degrés de liberté que de points de données" diff --git a/locale/hi.po b/locale/hi.po index 57b6249fcf..366e402a0a 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -148,6 +148,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3570,6 +3574,10 @@ msgstr "" msgid "module not found" msgstr "" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index bfcb00932a..68f1678bc3 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -158,6 +158,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3627,6 +3631,10 @@ msgstr "" msgid "module not found" msgstr "modulo non trovato" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index 4c67ef0f65..a510414d24 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -153,6 +153,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3590,6 +3594,10 @@ msgstr "" msgid "module not found" msgstr "モジュールが見つかりません" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index 1865940dde..2cc9677a5c 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -149,6 +149,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3574,6 +3578,10 @@ msgstr "" msgid "module not found" msgstr "" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index 40df1bb2ab..dfd8c260c4 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -151,6 +151,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3610,6 +3614,10 @@ msgstr "" msgid "module not found" msgstr "module niet gevonden" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "meer vrijheidsgraden dan datapunten" diff --git a/locale/pl.po b/locale/pl.po index a95a0ff24c..7ea754e29a 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -153,6 +153,10 @@ msgstr "" msgid "%q must be power of 2" msgstr "" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3582,6 +3586,10 @@ msgstr "" msgid "module not found" msgstr "brak modułu" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 610dd1659d..3dd92c6607 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -157,6 +157,10 @@ msgstr "%q deve ser do tipo %q" msgid "%q must be power of 2" msgstr "%q deve ser a potência de 2" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3669,6 +3673,10 @@ msgstr "o modo deve ser completo ou reduzido" msgid "module not found" msgstr "o módulo não foi encontrado" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "mais graus de liberdade do que pontos de dados" diff --git a/locale/sv.po b/locale/sv.po index 15eabd382b..a5d8d2cac7 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -156,6 +156,10 @@ msgstr "%q måste vara av typen %q" msgid "%q must be power of 2" msgstr "%q måste vara en potens av 2" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3630,6 +3634,10 @@ msgstr "mode måste vara complete, eller reduced" msgid "module not found" msgstr "modulen hittades inte" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "fler frihetsgrader än datapunkter" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 073004fee5..4cdd23ce65 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -158,6 +158,10 @@ msgstr "%q bì xū shì lèi xíng %q" msgid "%q must be power of 2" msgstr "%q bì xū shì 2 de gōng lǜ" +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "" + #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -3630,6 +3634,10 @@ msgstr "mó shì bì xū wán chéng huò jiǎn shǎo" msgid "module not found" msgstr "zhǎo bù dào mókuài" +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" msgstr "bǐ shùjù diǎn gèng duō de zìyóu dù" From 104af801b7d0e15e415ee4c88705159f49eb5325 Mon Sep 17 00:00:00 2001 From: lady ada Date: Thu, 11 Nov 2021 21:39:23 -0500 Subject: [PATCH 74/84] fix speed by not rotating --- .../espressif/boards/adafruit_feather_esp32s2_tft/board.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c index b82021d89d..adc4ae1b01 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c @@ -45,7 +45,7 @@ uint8_t display_init_sequence[] = { // normal display mode on 0x13, 0, // display and color format settings - 0x36, 1, 0x08, + 0x36, 1, 0x60, 0xB6, 2, 0x0A, 0x82, 0x3A, 1 | DELAY, 0x55, 10, // ST7789V frame rate setting @@ -111,9 +111,9 @@ void board_init(void) { bus, 240, // width (after rotation) 135, // height (after rotation) - 52, // column start - 40, // row start - 90, // rotation + 40, // column start + 52, // row start + 0, // rotation 16, // color depth false, // grayscale false, // pixels in a byte share a row. Only valid for depths < 8 From ac1ca57a17184fdc5b0ef104143e92bbe5ce9514 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Fri, 12 Nov 2021 18:32:44 +0530 Subject: [PATCH 75/84] fix traceback object init --- py/objexcept.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/py/objexcept.c b/py/objexcept.c index b8d7692b18..1dd72db42b 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -553,7 +553,6 @@ void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qs mp_obj_exception_t *self = get_native_exception(self_in); // Try to allocate memory for the traceback, with fallback to emergency traceback object - if (self->traceback == NULL || self->traceback == (mp_obj_traceback_t *)&mp_const_empty_traceback_obj) { self->traceback = m_new_obj_maybe(mp_obj_traceback_t); if (self->traceback == NULL) { @@ -561,9 +560,11 @@ void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qs } } - // append this traceback info to traceback data - // if memory allocation fails (eg because gc is locked), just return + // populate traceback object + *self->traceback = mp_const_empty_traceback_obj; + // append the provided traceback info to traceback data + // if memory allocation fails (eg because gc is locked), just return if (self->traceback->data == NULL) { self->traceback->data = m_new_maybe(size_t, TRACEBACK_ENTRY_LEN); if (self->traceback->data == NULL) { From b5dd8891e2f047c5950112a36ace000e90e5084a Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Fri, 12 Nov 2021 20:00:02 +0530 Subject: [PATCH 76/84] turn off `onewireio` on `feather_m0_adalogger` --- ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk index 62336ecf50..e17cb8b3a1 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk @@ -9,3 +9,5 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 + +CIRCUITPY_ONEWIREIO = 0 From a1069ebcc2fa3c67e5679a42a1ac2407e7431188 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 12 Nov 2021 10:15:12 -0600 Subject: [PATCH 77/84] check size of integers if possible --- py/circuitpy_mpconfig.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index a17d0183b1..5105be4d95 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -176,6 +176,10 @@ extern void common_hal_mcu_enable_interrupts(void); #define INT_FMT "%d" typedef int mp_int_t; // must be pointer size typedef unsigned mp_uint_t; // must be pointer size +#if __GNUC__ >= 10 // on recent gcc versions we can check that this is so +_Static_assert(sizeof(mp_int_t) == sizeof(void *)); +_Static_assert(sizeof(mp_uint_t) == sizeof(void *)); +#endif typedef long mp_off_t; #define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) From c6dbc7df3a053c4bc40bb9945d12746fb9a8f4f2 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 12 Nov 2021 10:30:40 -0600 Subject: [PATCH 78/84] Add displayio bitmaps to unix build --- ...ayio_colorspace_only.c => displayio_min.c} | 4 +- .../unix/variants/coverage/mpconfigvariant.mk | 16 +- py/circuitpy_defns.mk | 1 + shared-bindings/displayio/Bitmap.c | 7 +- shared-bindings/displayio/area.c | 0 shared-module/displayio/Bitmap.c | 8 +- shared-module/displayio/__init__.c | 158 +++-------------- shared-module/displayio/area.c | 161 ++++++++++++++++++ shared-module/displayio/area.h | 5 +- 9 files changed, 215 insertions(+), 145 deletions(-) rename ports/unix/{displayio_colorspace_only.c => displayio_min.c} (97%) create mode 100644 shared-bindings/displayio/area.c create mode 100644 shared-module/displayio/area.c diff --git a/ports/unix/displayio_colorspace_only.c b/ports/unix/displayio_min.c similarity index 97% rename from ports/unix/displayio_colorspace_only.c rename to ports/unix/displayio_min.c index 40325ec76a..debca1e088 100644 --- a/ports/unix/displayio_colorspace_only.c +++ b/ports/unix/displayio_min.c @@ -29,6 +29,7 @@ #include "py/runtime.h" #include "shared-bindings/displayio/__init__.h" +#include "shared-bindings/displayio/Bitmap.h" MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB888, DISPLAYIO_COLORSPACE_RGB888); MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAYIO_COLORSPACE_RGB565); @@ -78,6 +79,7 @@ MAKE_ENUM_TYPE(displayio, ColorSpace, displayio_colorspace); STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, + { MP_ROM_QSTR(MP_QSTR_Bitmap), MP_ROM_PTR(&displayio_bitmap_type) }, { MP_ROM_QSTR(MP_QSTR_Colorspace), MP_ROM_PTR(&displayio_colorspace_type) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_module_globals, displayio_module_globals_table); @@ -87,4 +89,4 @@ const mp_obj_module_t displayio_module = { .globals = (mp_obj_dict_t *)&displayio_module_globals, }; -MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module, CIRCUITPY_DISPLAYIO_COLORSPACE_ONLY); +MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module, CIRCUITPY_DISPLAYIO_UNIX); diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index e614cd411e..5465e50cfc 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -27,10 +27,20 @@ SRC_C += $(SRC_QRIO) CFLAGS += -DCIRCUITPY_QRIO=1 $(BUILD)/lib/quirc/lib/%.o: CFLAGS += -Wno-shadow -Wno-sign-compare -include shared-module/qrio/quirc_alloc.h -SRC_GIFIO := $(patsubst ../../%,%,$(wildcard ../../shared-bindings/gifio/*.c ../../shared-module/gifio/*.c)) shared/runtime/context_manager_helpers.c displayio_colorspace_only.c shared-module/displayio/ColorConverter.c shared-bindings/util.c -SRC_C += $(SRC_GIFIO) +SRC_BITMAP := \ + $(patsubst ../../%,%,$(wildcard ../../shared-bindings/gifio/*.c ../../shared-module/gifio/*.c)) \ + shared/runtime/context_manager_helpers.c \ + displayio_min.c \ + shared-bindings/displayio/Bitmap.c \ + shared-module/displayio/area.c \ + shared-module/displayio/Bitmap.c \ + shared-module/displayio/ColorConverter.c \ + shared-bindings/util.c \ -CFLAGS += -DCIRCUITPY_GIFIO=1 -DCIRCUITPY_DISPLAYIO_COLORSPACE_ONLY=1 +$(info $(SRC_BITMAP)) +SRC_C += $(SRC_BITMAP) + +CFLAGS += -DCIRCUITPY_GIFIO=1 -DCIRCUITPY_DISPLAYIO_UNIX=1 SRC_C += coverage.c SRC_CXX += coveragecpp.cpp diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index fec2512baf..68b529a05f 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -534,6 +534,7 @@ SRC_SHARED_MODULE_ALL = \ displayio/Palette.c \ displayio/Shape.c \ displayio/TileGrid.c \ + displayio/area.c \ displayio/__init__.c \ fontio/BuiltinFont.c \ fontio/__init__.c \ diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 5a1e12189a..f042ae27e2 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -33,7 +33,6 @@ #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" @@ -206,9 +205,9 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_x, ARG_y, ARG_source, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_index}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, + {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0} }, + {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0} }, + {MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, {MP_QSTR_x1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, {MP_QSTR_y1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, {MP_QSTR_x2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->width diff --git a/shared-bindings/displayio/area.c b/shared-bindings/displayio/area.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index e218049b6c..a18ba7a48a 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -113,7 +113,7 @@ void displayio_bitmap_set_dirty_area(displayio_bitmap_t *self, const displayio_a displayio_area_t area = *dirty_area; displayio_area_canon(&area); displayio_area_union(&area, &self->dirty_area, &area); - displayio_area_t bitmap_area = {0, 0, self->width, self->height}; + displayio_area_t bitmap_area = {0, 0, self->width, self->height, NULL}; displayio_area_compute_overlap(&area, &bitmap_area, &self->dirty_area); } @@ -160,7 +160,7 @@ void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16 dirty_y_max = self->height; } - displayio_area_t a = { x, y, dirty_x_max, dirty_y_max}; + displayio_area_t a = { x, y, dirty_x_max, dirty_y_max, NULL}; displayio_bitmap_set_dirty_area(self, &a); bool x_reverse = false; @@ -199,7 +199,7 @@ void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16 void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *self, int16_t x, int16_t y, uint32_t value) { // update the dirty region - displayio_area_t a = {x, y, x + 1, y + 1}; + displayio_area_t a = {x, y, x + 1, y + 1, NULL}; displayio_bitmap_set_dirty_area(self, &a); // write the pixel @@ -221,7 +221,7 @@ void displayio_bitmap_finish_refresh(displayio_bitmap_t *self) { } void common_hal_displayio_bitmap_fill(displayio_bitmap_t *self, uint32_t value) { - displayio_area_t a = {0, 0, self->width, self->height}; + displayio_area_t a = {0, 0, self->width, self->height, NULL}; displayio_bitmap_set_dirty_area(self, &a); // build the packed word diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index e4a4965368..eff86b81df 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -1,3 +1,29 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + #include @@ -249,138 +275,6 @@ void displayio_gc_collect(void) { } } -void displayio_area_copy(const displayio_area_t *src, displayio_area_t *dst) { - dst->x1 = src->x1; - dst->y1 = src->y1; - dst->x2 = src->x2; - dst->y2 = src->y2; -} - -void displayio_area_scale(displayio_area_t *area, uint16_t scale) { - area->x1 *= scale; - area->y1 *= scale; - area->x2 *= scale; - area->y2 *= scale; -} - -void displayio_area_shift(displayio_area_t *area, int16_t dx, int16_t dy) { - area->x1 += dx; - area->y1 += dy; - area->x2 += dx; - area->y2 += dy; -} - -bool displayio_area_compute_overlap(const displayio_area_t *a, - const displayio_area_t *b, - displayio_area_t *overlap) { - overlap->x1 = a->x1; - if (b->x1 > overlap->x1) { - overlap->x1 = b->x1; - } - overlap->x2 = a->x2; - if (b->x2 < overlap->x2) { - overlap->x2 = b->x2; - } - if (overlap->x1 >= overlap->x2) { - return false; - } - overlap->y1 = a->y1; - if (b->y1 > overlap->y1) { - overlap->y1 = b->y1; - } - overlap->y2 = a->y2; - if (b->y2 < overlap->y2) { - overlap->y2 = b->y2; - } - if (overlap->y1 >= overlap->y2) { - return false; - } - return true; -} - -bool displayio_area_empty(const displayio_area_t *a) { - return (a->x1 == a->x2) || (a->y1 == a->y2); -} - -void displayio_area_canon(displayio_area_t *a) { - if (a->x1 > a->x2) { - int16_t t = a->x1; - a->x1 = a->x2; - a->x2 = t; - } - if (a->y1 > a->y2) { - int16_t t = a->y1; - a->y1 = a->y2; - a->y2 = t; - } -} - -void displayio_area_union(const displayio_area_t *a, - const displayio_area_t *b, - displayio_area_t *u) { - - if (displayio_area_empty(a)) { - displayio_area_copy(b, u); - return; - } - if (displayio_area_empty(b)) { - displayio_area_copy(a, u); - return; - } - u->x1 = MIN(a->x1, b->x1); - u->y1 = MIN(a->y1, b->y1); - u->x2 = MAX(a->x2, b->x2); - u->y2 = MAX(a->y2, b->y2); -} - -uint16_t displayio_area_width(const displayio_area_t *area) { - return area->x2 - area->x1; -} - -uint16_t displayio_area_height(const displayio_area_t *area) { - return area->y2 - area->y1; -} - -uint32_t displayio_area_size(const displayio_area_t *area) { - return displayio_area_width(area) * displayio_area_height(area); -} - -bool displayio_area_equal(const displayio_area_t *a, const displayio_area_t *b) { - return a->x1 == b->x1 && - a->y1 == b->y1 && - a->x2 == b->x2 && - a->y2 == b->y2; -} - -// Original and whole must be in the same coordinate space. -void displayio_area_transform_within(bool mirror_x, bool mirror_y, bool transpose_xy, - const displayio_area_t *original, - const displayio_area_t *whole, - displayio_area_t *transformed) { - if (mirror_x) { - transformed->x1 = whole->x1 + (whole->x2 - original->x2); - transformed->x2 = whole->x2 - (original->x1 - whole->x1); - } else { - transformed->x1 = original->x1; - transformed->x2 = original->x2; - } - if (mirror_y) { - transformed->y1 = whole->y1 + (whole->y2 - original->y2); - transformed->y2 = whole->y2 - (original->y1 - whole->y1); - } else { - transformed->y1 = original->y1; - transformed->y2 = original->y2; - } - if (transpose_xy) { - int16_t y1 = transformed->y1; - int16_t y2 = transformed->y2; - transformed->y1 = whole->y1 + (transformed->x1 - whole->x1); - transformed->y2 = whole->y1 + (transformed->x2 - whole->x1); - transformed->x2 = whole->x1 + (y2 - whole->y1); - transformed->x1 = whole->x1 + (y1 - whole->y1); - } -} - primary_display_t *allocate_display(void) { for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { mp_const_obj_t display_type = displays[i].display.base.type; diff --git a/shared-module/displayio/area.c b/shared-module/displayio/area.c new file mode 100644 index 0000000000..6d0f94d9cc --- /dev/null +++ b/shared-module/displayio/area.c @@ -0,0 +1,161 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-module/displayio/area.h" + +#include "py/misc.h" + +void displayio_area_copy(const displayio_area_t *src, displayio_area_t *dst) { + dst->x1 = src->x1; + dst->y1 = src->y1; + dst->x2 = src->x2; + dst->y2 = src->y2; +} + +void displayio_area_scale(displayio_area_t *area, uint16_t scale) { + area->x1 *= scale; + area->y1 *= scale; + area->x2 *= scale; + area->y2 *= scale; +} + +void displayio_area_shift(displayio_area_t *area, int16_t dx, int16_t dy) { + area->x1 += dx; + area->y1 += dy; + area->x2 += dx; + area->y2 += dy; +} + +bool displayio_area_compute_overlap(const displayio_area_t *a, + const displayio_area_t *b, + displayio_area_t *overlap) { + overlap->x1 = a->x1; + if (b->x1 > overlap->x1) { + overlap->x1 = b->x1; + } + overlap->x2 = a->x2; + if (b->x2 < overlap->x2) { + overlap->x2 = b->x2; + } + if (overlap->x1 >= overlap->x2) { + return false; + } + overlap->y1 = a->y1; + if (b->y1 > overlap->y1) { + overlap->y1 = b->y1; + } + overlap->y2 = a->y2; + if (b->y2 < overlap->y2) { + overlap->y2 = b->y2; + } + if (overlap->y1 >= overlap->y2) { + return false; + } + return true; +} + +bool displayio_area_empty(const displayio_area_t *a) { + return (a->x1 == a->x2) || (a->y1 == a->y2); +} + +void displayio_area_canon(displayio_area_t *a) { + if (a->x1 > a->x2) { + int16_t t = a->x1; + a->x1 = a->x2; + a->x2 = t; + } + if (a->y1 > a->y2) { + int16_t t = a->y1; + a->y1 = a->y2; + a->y2 = t; + } +} + +void displayio_area_union(const displayio_area_t *a, + const displayio_area_t *b, + displayio_area_t *u) { + + if (displayio_area_empty(a)) { + displayio_area_copy(b, u); + return; + } + if (displayio_area_empty(b)) { + displayio_area_copy(a, u); + return; + } + u->x1 = MIN(a->x1, b->x1); + u->y1 = MIN(a->y1, b->y1); + u->x2 = MAX(a->x2, b->x2); + u->y2 = MAX(a->y2, b->y2); +} + +uint16_t displayio_area_width(const displayio_area_t *area) { + return area->x2 - area->x1; +} + +uint16_t displayio_area_height(const displayio_area_t *area) { + return area->y2 - area->y1; +} + +uint32_t displayio_area_size(const displayio_area_t *area) { + return displayio_area_width(area) * displayio_area_height(area); +} + +bool displayio_area_equal(const displayio_area_t *a, const displayio_area_t *b) { + return a->x1 == b->x1 && + a->y1 == b->y1 && + a->x2 == b->x2 && + a->y2 == b->y2; +} + +// Original and whole must be in the same coordinate space. +void displayio_area_transform_within(bool mirror_x, bool mirror_y, bool transpose_xy, + const displayio_area_t *original, + const displayio_area_t *whole, + displayio_area_t *transformed) { + if (mirror_x) { + transformed->x1 = whole->x1 + (whole->x2 - original->x2); + transformed->x2 = whole->x2 - (original->x1 - whole->x1); + } else { + transformed->x1 = original->x1; + transformed->x2 = original->x2; + } + if (mirror_y) { + transformed->y1 = whole->y1 + (whole->y2 - original->y2); + transformed->y2 = whole->y2 - (original->y1 - whole->y1); + } else { + transformed->y1 = original->y1; + transformed->y2 = original->y2; + } + if (transpose_xy) { + int16_t y1 = transformed->y1; + int16_t y2 = transformed->y2; + transformed->y1 = whole->y1 + (transformed->x1 - whole->x1); + transformed->y2 = whole->y1 + (transformed->x2 - whole->x1); + transformed->x2 = whole->x1 + (y2 - whole->y1); + transformed->x1 = whole->x1 + (y1 - whole->y1); + } +} diff --git a/shared-module/displayio/area.h b/shared-module/displayio/area.h index 6a8ad6ceb0..47cb48bcdd 100644 --- a/shared-module/displayio/area.h +++ b/shared-module/displayio/area.h @@ -27,7 +27,10 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_AREA_H #define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_AREA_H -// Implementations are in __init__.c +#include +#include + +// Implementations are in area.c typedef struct _displayio_area_t displayio_area_t; struct _displayio_area_t { From d55388a17ddb9ec2e4685507339d12a077f82c78 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 12 Nov 2021 10:41:46 -0600 Subject: [PATCH 79/84] Add bitmaptools to unix build --- .../unix/variants/coverage/mpconfigvariant.mk | 4 +- shared-bindings/bitmaptools/__init__.c | 75 ++++++++++--------- shared-bindings/bitmaptools/__init__.h | 6 +- shared-module/bitmaptools/__init__.c | 56 +++++++------- 4 files changed, 75 insertions(+), 66 deletions(-) diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index 5465e50cfc..69996b2839 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -35,12 +35,14 @@ SRC_BITMAP := \ shared-module/displayio/area.c \ shared-module/displayio/Bitmap.c \ shared-module/displayio/ColorConverter.c \ + shared-bindings/bitmaptools/__init__.c \ + shared-module/bitmaptools/__init__.c \ shared-bindings/util.c \ $(info $(SRC_BITMAP)) SRC_C += $(SRC_BITMAP) -CFLAGS += -DCIRCUITPY_GIFIO=1 -DCIRCUITPY_DISPLAYIO_UNIX=1 +CFLAGS += -DCIRCUITPY_GIFIO=1 -DCIRCUITPY_DISPLAYIO_UNIX=1 -DCIRCUITPY_BITMAPTOOLS=1 SRC_C += coverage.c SRC_CXX += coveragecpp.cpp diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 99039ba1ba..def72b53a0 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -36,6 +36,13 @@ #include "py/obj.h" #include "py/runtime.h" +#if MICROPY_VFS +#include "extmod/vfs.h" +#endif +#if MICROPY_VFS_POSIX +#include "extmod/vfs_posix.h" +#endif + //| """Collection of bitmap manipulation tools""" //| @@ -154,8 +161,8 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args ARG_angle, ARG_scale, ARG_skip_index}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, - {MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, + {MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, {MP_QSTR_ox, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to destination->width / 2 {MP_QSTR_oy, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to destination->height / 2 @@ -207,13 +214,13 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args args[ARG_source_clip1].u_obj, &source_clip1_x, &source_clip1_y); // Confirm the angle value - float angle = 0.0; + mp_float_t angle = 0.0; if (args[ARG_angle].u_obj != mp_const_none) { angle = mp_obj_get_float(args[ARG_angle].u_obj); } // Confirm the scale value - float scale = 1.0; + mp_float_t scale = 1.0; if (args[ARG_scale].u_obj != mp_const_none) { scale = mp_obj_get_float(args[ARG_scale].u_obj); } @@ -269,10 +276,10 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, enum {ARG_dest_bitmap, ARG_source_bitmap_1, ARG_source_bitmap_2, ARG_colorspace, ARG_factor_1, ARG_factor_2}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, - {MP_QSTR_source_bitmap_1, MP_ARG_REQUIRED | MP_ARG_OBJ}, - {MP_QSTR_source_bitmap_2, MP_ARG_REQUIRED | MP_ARG_OBJ}, - {MP_QSTR_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = NULL}}, + {MP_QSTR_source_bitmap_1, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = NULL}}, + {MP_QSTR_source_bitmap_2, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = NULL}}, + {MP_QSTR_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = NULL}}, {MP_QSTR_factor_1, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE}}, {MP_QSTR_factor_2, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE}}, }; @@ -283,8 +290,8 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, displayio_bitmap_t *source1 = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_source_bitmap_1].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap_1)); // the first source bitmap displayio_bitmap_t *source2 = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_source_bitmap_2].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap_2)); // the second source bitmap - float factor1 = (args[ARG_factor_1].u_obj == mp_const_none) ? .5f : mp_obj_float_get(args[ARG_factor_1].u_obj); - float factor2 = (args[ARG_factor_2].u_obj == mp_const_none) ? 1 - factor1 : mp_obj_float_get(args[ARG_factor_2].u_obj); + mp_float_t factor1 = (args[ARG_factor_1].u_obj == mp_const_none) ? MICROPY_FLOAT_CONST(.5) : mp_obj_float_get(args[ARG_factor_1].u_obj); + mp_float_t factor2 = (args[ARG_factor_2].u_obj == mp_const_none) ? 1 - factor1 : mp_obj_float_get(args[ARG_factor_2].u_obj); displayio_colorspace_t colorspace = (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_colorspace].u_obj); @@ -346,12 +353,12 @@ STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_a enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, - {MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, + {MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -398,10 +405,10 @@ STATIC mp_obj_t bitmaptools_obj_boundary_fill(size_t n_args, const mp_obj_t *pos enum {ARG_dest_bitmap, ARG_x, ARG_y, ARG_fill_color_value, ARG_replaced_color_value}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, - {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_fill_color_value, MP_ARG_REQUIRED | MP_ARG_INT}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, + {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_fill_color_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, {MP_QSTR_replaced_color_value, MP_ARG_INT, {.u_int = INT_MAX} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -461,12 +468,12 @@ STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_arg enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, - {MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT}, - {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, + {MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -532,8 +539,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_line_obj, 0, bitmaptools_obj_draw_li STATIC mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_data, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_index }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, + { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, { MP_QSTR_x1, MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_y1, MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_x2, MP_ARG_INT, {.u_int = -1} }, @@ -598,9 +605,9 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_arrayblit_obj, 0, bitmaptools_arrayblit); STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_file, ARG_bits_per_pixel, ARG_element_size, ARG_reverse_pixels_in_element, ARG_swap_bytes_in_element, ARG_reverse_rows }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_file, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_bits_per_pixel, MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, + { MP_QSTR_file, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, + { MP_QSTR_bits_per_pixel, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0} }, { MP_QSTR_element_size, MP_ARG_INT, { .u_int = 1 } }, { MP_QSTR_reverse_pixels_in_element, MP_ARG_BOOL, { .u_bool = false } }, { MP_QSTR_swap_bytes_in_element, MP_ARG_BOOL, { .u_bool = false } }, @@ -682,9 +689,9 @@ MAKE_ENUM_TYPE(bitmaptools, DitherAlgorithm, bitmaptools_dither_algorithm); STATIC mp_obj_t bitmaptools_dither(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_dest_bitmap, ARG_source_bitmap, ARG_source_colorspace, ARG_algorithm }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_source_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, + { MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, + { MP_QSTR_source_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, { MP_QSTR_algorithm, MP_ARG_OBJ, { .u_obj = MP_ROM_PTR((void *)&dither_algorithm_Atkinson_obj) } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; diff --git a/shared-bindings/bitmaptools/__init__.h b/shared-bindings/bitmaptools/__init__.h index 4d13ccf523..5f13776bc0 100644 --- a/shared-bindings/bitmaptools/__init__.h +++ b/shared-bindings/bitmaptools/__init__.h @@ -46,8 +46,8 @@ void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16 displayio_bitmap_t *source, int16_t px, int16_t py, int16_t source_clip0_x, int16_t source_clip0_y, int16_t source_clip1_x, int16_t source_clip1_y, - float angle, - float scale, + mp_float_t angle, + mp_float_t scale, uint32_t skip_index, bool skip_index_none); void common_hal_bitmaptools_fill_region(displayio_bitmap_t *destination, @@ -68,6 +68,6 @@ void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *f void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int element_size, int x1, int y1, int x2, int y2, bool skip_specified, uint32_t skip_index); void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bitmap_t *source_bitmap, displayio_colorspace_t colorspace, bitmaptools_dither_algorithm_t algorithm); -void common_hal_bitmaptools_alphablend(displayio_bitmap_t *destination, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, float factor1, float factor2); +void common_hal_bitmaptools_alphablend(displayio_bitmap_t *destination, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, mp_float_t factor1, mp_float_t factor2); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 0c577f0194..a0aa71a14e 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -44,8 +44,8 @@ void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16 displayio_bitmap_t *source, int16_t px, int16_t py, int16_t source_clip0_x, int16_t source_clip0_y, int16_t source_clip1_x, int16_t source_clip1_y, - float angle, - float scale, + mp_float_t angle, + mp_float_t scale, uint32_t skip_index, bool skip_index_none) { // Copies region from source to the destination bitmap, including rotation, @@ -105,10 +105,10 @@ void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16 int16_t maxx = dest_clip0_x; int16_t maxy = dest_clip0_y; - float sinAngle = sinf(angle); - float cosAngle = cosf(angle); + mp_float_t sinAngle = MICROPY_FLOAT_C_FUN(sin)(angle); + mp_float_t cosAngle = MICROPY_FLOAT_C_FUN(cos)(angle); - float dx, dy; + mp_float_t dx, dy; /* Compute the position of where each corner on the source bitmap will be on the destination to get a bounding box for scanning */ @@ -186,27 +186,27 @@ void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16 maxy = dest_clip1_y - 1; } - float dvCol = cosAngle / scale; - float duCol = sinAngle / scale; + mp_float_t dvCol = cosAngle / scale; + mp_float_t duCol = sinAngle / scale; - float duRow = dvCol; - float dvRow = -duCol; + mp_float_t duRow = dvCol; + mp_float_t dvRow = -duCol; - float startu = px - (ox * dvCol + oy * duCol); - float startv = py - (ox * dvRow + oy * duRow); + mp_float_t startu = px - (ox * dvCol + oy * duCol); + mp_float_t startv = py - (ox * dvRow + oy * duRow); - float rowu = startu + miny * duCol; - float rowv = startv + miny * dvCol; + mp_float_t rowu = startu + miny * duCol; + mp_float_t rowv = startv + miny * dvCol; - displayio_area_t dirty_area = {minx, miny, maxx + 1, maxy + 1}; + displayio_area_t dirty_area = {minx, miny, maxx + 1, maxy + 1, NULL}; displayio_bitmap_set_dirty_area(self, &dirty_area); for (y = miny; y <= maxy; y++) { - float u = rowu + minx * duRow; - float v = rowv + minx * dvRow; + mp_float_t u = rowu + minx * duRow; + mp_float_t v = rowv + minx * dvRow; for (x = minx; x <= maxx; x++) { if (u >= source_clip0_x && u < source_clip1_x && v >= source_clip0_y && v < source_clip1_y) { - uint32_t c = common_hal_displayio_bitmap_get_pixel(source, u, v); + uint32_t c = common_hal_displayio_bitmap_get_pixel(source, (int)u, (int)v); if ((skip_index_none) || (c != skip_index)) { displayio_bitmap_write_pixel(self, x, y, c); } @@ -227,10 +227,10 @@ void common_hal_bitmaptools_fill_region(displayio_bitmap_t *destination, // // input checks should ensure that x1 < x2 and y1 < y2 and are within the bitmap region - displayio_area_t area = { x1, y1, x2, y2 }; + displayio_area_t area = { x1, y1, x2, y2, NULL }; displayio_area_canon(&area); - displayio_area_t bitmap_area = { 0, 0, destination->width, destination->height }; + displayio_area_t bitmap_area = { 0, 0, destination->width, destination->height, NULL }; displayio_area_compute_overlap(&area, &bitmap_area, &area); // update the dirty rectangle @@ -378,7 +378,7 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination, } // set dirty the area so displayio will draw - displayio_area_t area = { minx, miny, maxx + 1, maxy + 1}; + displayio_area_t area = { minx, miny, maxx + 1, maxy + 1, NULL}; displayio_bitmap_set_dirty_area(destination, &area); } @@ -408,8 +408,8 @@ void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination, ybb0 = y1; ybb1 = y0 + 1; } - displayio_area_t area = { xbb0, ybb0, xbb1, ybb1 }; - displayio_area_t bitmap_area = { 0, 0, destination->width, destination->height }; + displayio_area_t area = { xbb0, ybb0, xbb1, ybb1, NULL }; + displayio_area_t bitmap_area = { 0, 0, destination->width, destination->height, NULL }; displayio_area_compute_overlap(&area, &bitmap_area, &area); displayio_bitmap_set_dirty_area(destination, &area); @@ -460,7 +460,7 @@ void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination, dx = x1 - x0; dy = abs(y1 - y0); - float err = dx / 2; + mp_float_t err = dx / 2; if (y0 < y1) { ystep = 1; @@ -509,14 +509,14 @@ void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int } } } - displayio_area_t area = { x1, y1, x2, y2 }; + displayio_area_t area = { x1, y1, x2, y2, NULL }; displayio_bitmap_set_dirty_area(self, &area); } void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_element, bool swap_bytes, bool reverse_rows) { uint32_t mask = (1 << common_hal_displayio_bitmap_get_bits_per_value(self)) - 1; - displayio_area_t a = {0, 0, self->width, self->height}; + displayio_area_t a = {0, 0, self->width, self->height, NULL}; displayio_bitmap_set_dirty_area(self, &a); size_t elements_per_row = (self->width * bits_per_pixel + element_size * 8 - 1) / (element_size * 8); @@ -785,12 +785,12 @@ void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bi fill_row(source_bitmap, swap, rows[2], y + 2, info->mx); } - displayio_area_t a = { 0, 0, width, height }; + displayio_area_t a = { 0, 0, width, height, NULL }; displayio_bitmap_set_dirty_area(dest_bitmap, &a); } -void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, float factor1, float factor2) { - displayio_area_t a = {0, 0, dest->width, dest->height}; +void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, mp_float_t factor1, mp_float_t factor2) { + displayio_area_t a = {0, 0, dest->width, dest->height, NULL}; displayio_bitmap_set_dirty_area(dest, &a); int ifactor1 = (int)(factor1 * 256); From 167665f8b78829c60d7c2eddf4f73eb997ff94a7 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 12 Nov 2021 11:03:45 -0600 Subject: [PATCH 80/84] fix build --- shared-bindings/bitmaptools/__init__.c | 2 +- tests/unix/extra_coverage.py.exp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index def72b53a0..1db0a20629 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -39,7 +39,7 @@ #if MICROPY_VFS #include "extmod/vfs.h" #endif -#if MICROPY_VFS_POSIX +#if defined(MICROPY_VFS_POSIX) && MICROPY_VFS_POSIX #include "extmod/vfs_posix.h" #endif diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 3a1e7f280b..4be6b20d5d 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -30,15 +30,15 @@ ame__ mport builtins micropython _thread array -binascii btree cexample cmath -collections cppexample displayio errno -ffi framebuf gc gifio -hashlib json math qrio -re sys termios ubinascii -uctypes uerrno uheapq uio -ujson ulab uos urandom -ure uselect ustruct utime -utimeq uzlib +binascii bitmaptools btree cexample +cmath collections cppexample displayio +errno ffi framebuf gc +gifio hashlib json math +qrio re sys termios +ubinascii uctypes uerrno uheapq +uio ujson ulab uos +urandom ure uselect ustruct +utime utimeq uzlib ime utime utimeq From 8871338f5302dee423ef5b0462551270486c7247 Mon Sep 17 00:00:00 2001 From: Paul Leung Date: Fri, 12 Nov 2021 11:35:54 +0000 Subject: [PATCH 81/84] Translated using Weblate (Chinese (Pinyin)) Currently translated at 99.9% (1021 of 1022 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 4cdd23ce65..a2b4761cce 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,15 +7,15 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-05 04:07+0000\n" -"Last-Translator: hexthat \n" +"PO-Revision-Date: 2021-11-12 18:46+0000\n" +"Last-Translator: Paul Leung \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.9-dev\n" +"X-Generator: Weblate 4.9.1-dev\n" #: main.c msgid "" @@ -119,7 +119,7 @@ msgstr "%q bì xū wéi %d-%d" #: py/argcheck.c shared-bindings/gifio/GifWriter.c msgid "%q must be <= %d" -msgstr "" +msgstr "%q bì xū <= %d" #: py/argcheck.c msgid "%q must be >= %d" @@ -160,7 +160,7 @@ msgstr "%q bì xū shì 2 de gōng lǜ" #: shared-bindings/wifi/Monitor.c msgid "%q out of bounds" -msgstr "" +msgstr "%q chāo chū jiè xiàn" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c @@ -569,8 +569,9 @@ msgid "Bit depth must be multiple of 8." msgstr "Bǐtè shēndù bìxū shì 8 bèi yǐshàng." #: shared-bindings/bitmaptools/__init__.c +#, fuzzy msgid "Bitmap size and bits per value must match" -msgstr "" +msgstr "wèi tú dà xiǎo hé měi gè zhí de bǐ tè wèi bì xū pǐ pèi" #: supervisor/shared/safe_mode.c msgid "Boot device must be first device (interface #0)." @@ -2453,7 +2454,7 @@ msgstr "Bù zhīchí de baudrate" #: shared-bindings/bitmaptools/__init__.c msgid "Unsupported colorspace" -msgstr "" +msgstr "bú zhī chí de sè cǎi kōng jiān" #: shared-module/displayio/display_core.c msgid "Unsupported display bus type" @@ -2686,7 +2687,7 @@ msgstr "èrjìnzhì bǎn qián bǎn %q wèi zhíxíng" #: shared-bindings/bitmaptools/__init__.c msgid "bitmap sizes must match" -msgstr "" +msgstr "wèi tú dà xiǎo bì xū pǐ pèi" #: extmod/modurandom.c msgid "bits must be 32 or less" @@ -3587,7 +3588,7 @@ msgstr "jǔzhèn bùshì zhèngdìng de" #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format msgid "max_length must be 0-%d when fixed_length is %s" -msgstr "Dāng gùdìng chángdù wèi %s shí, zuìdà chángdù bìxū wèi 0-%d" +msgstr "dāng fixed_length de zhí wéi %s shí, max_length bì xū wéi 0-%d" #: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c msgid "max_length must be >= 0" @@ -3636,7 +3637,7 @@ msgstr "zhǎo bù dào mókuài" #: ports/espressif/common-hal/wifi/Monitor.c msgid "monitor init failed" -msgstr "" +msgstr "jiān shì qì chū shǐ huà shī bài" #: extmod/ulab/code/numpy/poly.c msgid "more degrees of freedom than data points" @@ -4450,11 +4451,11 @@ msgstr "bù zhīchí de Xtensa zhǐlìng '%s', shǐyòng %d cānshù" #: shared-module/gifio/GifWriter.c msgid "unsupported colorspace for GifWriter" -msgstr "" +msgstr "GifWriter bú zhī chí cǐ sè cǎi kōng jiān" #: shared-bindings/bitmaptools/__init__.c msgid "unsupported colorspace for dither" -msgstr "" +msgstr "dither bú zhī chí cǐ sè cǎi kōng jiān" #: py/objstr.c #, c-format From 839db7791f589061adda9279f10dc3b5b5992f9e Mon Sep 17 00:00:00 2001 From: River Wang Date: Fri, 12 Nov 2021 17:25:07 +0000 Subject: [PATCH 82/84] Translated using Weblate (Chinese (Pinyin)) Currently translated at 99.9% (1021 of 1022 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index a2b4761cce..1bbecc7499 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -8,7 +8,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" "PO-Revision-Date: 2021-11-12 18:46+0000\n" -"Last-Translator: Paul Leung \n" +"Last-Translator: River Wang \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" "MIME-Version: 1.0\n" @@ -31,7 +31,7 @@ msgid "" "Code stopped by auto-reload.\n" msgstr "" "\n" -"zì dòng chóng xīn jiā zǎi tíng zhǐ de dài mǎ.\n" +"dàimǎ de yùnxíng yīnwéi zìdòng chóngxīn jiāzǎi ér tíngzhǐ.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -49,7 +49,7 @@ msgstr " Wénjiàn \"%q\"" #: py/obj.c msgid " File \"%q\", line %d" -msgstr " Wénjiàn \"%q\", dì %d xíng" +msgstr " Wénjiàn \"%q\", dì %d háng" #: py/builtinhelp.c msgid " is of type %q\n" @@ -1009,7 +1009,7 @@ msgstr "FFT jǐn wéi ndarrays dìng yì" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "FFT is implemented for linear arrays only" -msgstr "FFT jǐn shì yòng yú xiàn xìng zhèn liè" +msgstr "FFT jǐn shì yòng yú yī wéi shù zǔ" #: ports/espressif/common-hal/ssl/SSLSocket.c msgid "Failed SSL handshake" @@ -1098,10 +1098,13 @@ msgstr "gù jiàn yìng xiàng wú xiào" #: shared-bindings/bitmaptools/__init__.c msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" msgstr "" +"zài L8 sè yù zhōng, měi gè shū rù de xiàng sù bì xū shì 8 wèi (8 bit) shù jù" #: shared-bindings/bitmaptools/__init__.c msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" msgstr "" +"zài GRB sè yù zhōng, měi gè shū rù de xiàng sù bì xū shì 16 wèi (16 bit) shù " +"jù" #: ports/cxd56/common-hal/camera/Camera.c msgid "Format not supported" @@ -2309,7 +2312,7 @@ msgstr "bù kě yòng chù mō bào jǐng qì" #: py/obj.c msgid "Traceback (most recent call last):\n" -msgstr "Traceback (Zuìjìn yīcì dǎ diànhuà):\n" +msgstr "Traceback (Zuìjìn yīcì diàoyòng zhǐlìng):\n" #: shared-bindings/time/__init__.c msgid "Tuple or struct_time argument required" @@ -2353,7 +2356,7 @@ msgstr "USB cuò wù" #: shared-bindings/_bleio/UUID.c msgid "UUID integer value must be 0-0xffff" -msgstr "UUID zhěngshù zhí bìxū wèi 0-0xffff" +msgstr "UUID de zhí bì xū shì 0-0xffff fàn wéi nèi de zhěng shù" #: shared-bindings/_bleio/UUID.c msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" @@ -2386,11 +2389,11 @@ msgstr "Wúfǎ zhǎodào miǎnfèi de GCLK" #: py/parse.c msgid "Unable to init parser" -msgstr "Wúfǎ chūshǐ jiěxī qì" +msgstr "Wúfǎ chūshǐhuà jiěxī qì" #: shared-module/displayio/OnDiskBitmap.c msgid "Unable to read color palette data" -msgstr "Wúfǎ dòu qǔ sè tiáo shùjù" +msgstr "Wúfǎ dúqǔ tiáosèbǎn shùjù" #: shared-bindings/nvm/ByteArray.c msgid "Unable to write to nvm." @@ -4196,14 +4199,17 @@ msgstr "yuán miànbǎn tài dà" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 2 or 65536" msgstr "" +"yuán wèi tú (source_bitmap) de zhí de shù mù (value_count) bì xū shì 2 huò " +"zhě 65536" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 65536" msgstr "" +"yuán wèi tú (source_bitmap) de zhí de shù mù (value_count) bì xū shì 65536" #: shared-bindings/bitmaptools/__init__.c msgid "source_bitmap must have value_count of 8" -msgstr "" +msgstr "yuán wèi tú (source_bitmap) de zhí de shù mù (value_count) bì xū shì 8" #: py/objstr.c msgid "start/end indices" From 6afe7321511179e42ee41ccbb90401fd91c0e6fb Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 12 Nov 2021 13:09:33 -0600 Subject: [PATCH 83/84] changes in ports/unix don't trigger any board builds --- tools/ci_set_matrix.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index f4c036ca2a..e9aafc22cc 100644 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -76,7 +76,8 @@ def set_boards_to_build(build_all): port_matches = port_pattern.search(p) if port_matches: port = port_matches.group(1) - boards_to_build.update(port_to_boards[port]) + if port != "unix": + boards_to_build.update(port_to_boards[port]) continue # Otherwise build it all From 06bb6ea5a2f1f39d10e16f5c6fd31c173a0871c0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 12 Nov 2021 13:21:53 -0600 Subject: [PATCH 84/84] use MP_OBJ_NULL in preference to 0 --- shared-bindings/bitmaptools/__init__.c | 52 +++++++++++++------------- shared-bindings/canio/CAN.c | 4 +- shared-bindings/displayio/Bitmap.c | 6 +-- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 1db0a20629..b13d279fa3 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -161,8 +161,8 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args ARG_angle, ARG_scale, ARG_skip_index}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, - {MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, {MP_QSTR_ox, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to destination->width / 2 {MP_QSTR_oy, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to destination->height / 2 @@ -353,12 +353,12 @@ STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_a enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, - {MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -405,10 +405,10 @@ STATIC mp_obj_t bitmaptools_obj_boundary_fill(size_t n_args, const mp_obj_t *pos enum {ARG_dest_bitmap, ARG_x, ARG_y, ARG_fill_color_value, ARG_replaced_color_value}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, - {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_fill_color_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_fill_color_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, {MP_QSTR_replaced_color_value, MP_ARG_INT, {.u_int = INT_MAX} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -468,12 +468,12 @@ STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_arg enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0}}, - {MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, - {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0}}, + {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_x1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_y1, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_x2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_y2, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, + {MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL}}, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -539,8 +539,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_line_obj, 0, bitmaptools_obj_draw_li STATIC mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_data, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_index }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, - { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, + { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_x1, MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_y1, MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_x2, MP_ARG_INT, {.u_int = -1} }, @@ -605,9 +605,9 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_arrayblit_obj, 0, bitmaptools_arrayblit); STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bitmap, ARG_file, ARG_bits_per_pixel, ARG_element_size, ARG_reverse_pixels_in_element, ARG_swap_bytes_in_element, ARG_reverse_rows }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, - { MP_QSTR_file, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, - { MP_QSTR_bits_per_pixel, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0} }, + { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_file, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_bits_per_pixel, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_element_size, MP_ARG_INT, { .u_int = 1 } }, { MP_QSTR_reverse_pixels_in_element, MP_ARG_BOOL, { .u_bool = false } }, { MP_QSTR_swap_bytes_in_element, MP_ARG_BOOL, { .u_bool = false } }, @@ -689,9 +689,9 @@ MAKE_ENUM_TYPE(bitmaptools, DitherAlgorithm, bitmaptools_dither_algorithm); STATIC mp_obj_t bitmaptools_dither(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_dest_bitmap, ARG_source_bitmap, ARG_source_colorspace, ARG_algorithm }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, - { MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, - { MP_QSTR_source_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, + { MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_source_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_algorithm, MP_ARG_OBJ, { .u_obj = MP_ROM_PTR((void *)&dither_algorithm_Atkinson_obj) } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index 1efd3a0930..6a2320c719 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -240,8 +240,8 @@ STATIC mp_obj_t canio_can_listen(size_t n_args, const mp_obj_t *pos_args, mp_map enum { ARG_matches, ARG_timeout, NUM_ARGS }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_matches, MP_ARG_OBJ, {.u_obj = 0} }, - { MP_QSTR_timeout, MP_ARG_OBJ, {.u_obj = 0} }, + { MP_QSTR_matches, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_timeout, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index f042ae27e2..526d378812 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -205,9 +205,9 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_x, ARG_y, ARG_source, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_index}; static const mp_arg_t allowed_args[] = { - {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0} }, - {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = 0} }, - {MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = 0} }, + {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL} }, + {MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT, {.u_obj = MP_OBJ_NULL} }, + {MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, {MP_QSTR_x1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, {MP_QSTR_y1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, {MP_QSTR_x2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->width