From ea0e2f80b7612d7d3119355a455667b3c4beb6d7 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Mon, 4 Jan 2021 23:11:25 -0600 Subject: [PATCH 01/53] Changing to duck-typing --- .../adafruit_bus_device/I2CDevice.c | 79 +++++++++---------- .../adafruit_bus_device/I2CDevice.h | 4 +- shared-module/adafruit_bus_device/I2CDevice.c | 67 +++++++++++----- shared-module/adafruit_bus_device/I2CDevice.h | 2 +- 4 files changed, 88 insertions(+), 64 deletions(-) diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/I2CDevice.c index a4c04e198c..d3b6fbec44 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/I2CDevice.c @@ -31,6 +31,7 @@ #include "shared-bindings/adafruit_bus_device/I2CDevice.h" #include "shared-bindings/util.h" #include "shared-module/adafruit_bus_device/I2CDevice.h" +#include "shared-bindings/busio/I2C.h" #include "lib/utils/buffer_helper.h" #include "lib/utils/context_manager_helpers.h" @@ -76,7 +77,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type 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); - busio_i2c_obj_t* i2c = args[ARG_i2c].u_obj; + mp_obj_t* i2c = args[ARG_i2c].u_obj; common_hal_adafruit_bus_device_i2cdevice_construct(MP_OBJ_TO_PTR(self), i2c, args[ARG_device_address].u_int); if (args[ARG_probe].u_bool == true) { @@ -107,7 +108,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit___obj, 4, 4, adafruit_bus_device_i2cdevice_obj___exit__); -//| def readinto(self, buf: WriteableBuffer, *, start: int = 0, end: int = 0) -> None: +//| def readinto(self, buf: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: //| """Read into ``buf`` from the device. The number of bytes read will be the //| length of ``buf``. //| If ``start`` or ``end`` is provided, then the buffer will be sliced @@ -118,22 +119,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit_ //| :param int end: Index to write up to but not include; if None, use ``len(buf)``""" //| ... //| -STATIC void readinto(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); - - size_t length = bufinfo.len; - normalize_buffer_bounds(&start, end, &length); - if (length == 0) { - mp_raise_ValueError(translate("Buffer must be at least length 1")); - } - - uint8_t status = common_hal_adafruit_bus_device_i2cdevice_readinto(MP_OBJ_TO_PTR(self), ((uint8_t*)bufinfo.buf) + start, length); - if (status != 0) { - mp_raise_OSError(status); - } -} - STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -147,12 +132,21 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o 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); - readinto(self, args[ARG_buffer].u_obj, args[ARG_start].u_int, args[ARG_end].u_int); + mp_obj_t dest[8]; + mp_load_method(self->i2c, MP_QSTR_readfrom_into, dest); + dest[2] = mp_obj_new_int_from_ull(self->device_address); + dest[3] = args[ARG_buffer].u_obj; + dest[4] = mp_obj_new_str("start", 5); + dest[5] = mp_obj_new_int(args[ARG_start].u_int); + dest[6] = mp_obj_new_str("end", 3); + dest[7] = mp_obj_new_int(args[ARG_end].u_int); + mp_call_method_n_kw(2, 2, dest); + return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 2, adafruit_bus_device_i2cdevice_readinto); -//| def write(self, buf: ReadableBuffer, *, start: int = 0, end: int = 0) -> None: +//| def write(self, buf: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: //| """Write the bytes from ``buffer`` to the device, then transmit a stop bit. //| If ``start`` or ``end`` is provided, then the buffer will be sliced //| as if ``buffer[start:end]``. This will not cause an allocation like @@ -163,22 +157,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 2, //| """ //| ... //| -STATIC void write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, int32_t start, mp_int_t end, bool transmit_stop_bit) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); - - size_t length = bufinfo.len; - normalize_buffer_bounds(&start, end, &length); - if (length == 0) { - mp_raise_ValueError(translate("Buffer must be at least length 1")); - } - - uint8_t status = common_hal_adafruit_bus_device_i2cdevice_write(MP_OBJ_TO_PTR(self), ((uint8_t*)bufinfo.buf) + start, length, transmit_stop_bit); - if (status != 0) { - mp_raise_OSError(status); - } -} - STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -191,13 +169,22 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_ 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); - write(self, args[ARG_buffer].u_obj, args[ARG_start].u_int, args[ARG_end].u_int, true); + mp_obj_t dest[8]; + mp_load_method(self->i2c, MP_QSTR_writeto, dest); + dest[2] = mp_obj_new_int_from_ull(self->device_address); + dest[3] = args[ARG_buffer].u_obj; + dest[4] = mp_obj_new_str("start", 5); + dest[5] = mp_obj_new_int(args[ARG_start].u_int); + dest[6] = mp_obj_new_str("end", 3); + dest[7] = mp_obj_new_int(args[ARG_end].u_int); + mp_call_method_n_kw(2, 2, dest); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 2, adafruit_bus_device_i2cdevice_write); -//| def write_then_readinto(self, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: int = 0, in_start: int = 0, in_end: int = 0) -> None: +//| def write_then_readinto(self, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: //| """Write the bytes from ``out_buffer`` to the device, then immediately //| reads into ``in_buffer`` from the device. The number of bytes read //| will be the length of ``in_buffer``. @@ -233,9 +220,21 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args, 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); - write(self, args[ARG_out_buffer].u_obj, args[ARG_out_start].u_int, args[ARG_out_end].u_int, false); + mp_obj_t dest[13]; + mp_load_method(self->i2c, MP_QSTR_writeto_then_readfrom, dest); + dest[2] = mp_obj_new_int_from_ull(self->device_address); + dest[3] = args[ARG_out_buffer].u_obj; + dest[4] = args[ARG_in_buffer].u_obj; + dest[5] = mp_obj_new_str("out_start", 9); + dest[6] = mp_obj_new_int(args[ARG_out_start].u_int); + dest[7] = mp_obj_new_str("out_end", 7); + dest[8] = mp_obj_new_int(args[ARG_out_end].u_int); + dest[9] = mp_obj_new_str("in_start", 8); + dest[10] = mp_obj_new_int(args[ARG_in_start].u_int); + dest[11] = mp_obj_new_str("in_end", 6); + dest[12] = mp_obj_new_int(args[ARG_in_end].u_int); - readinto(self, args[ARG_in_buffer].u_obj, args[ARG_in_start].u_int, args[ARG_in_end].u_int); + mp_call_method_n_kw(3, 4, dest); return mp_const_none; } diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.h b/shared-bindings/adafruit_bus_device/I2CDevice.h index cf7b1321a0..82ef1feb80 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.h +++ b/shared-bindings/adafruit_bus_device/I2CDevice.h @@ -43,9 +43,7 @@ extern const mp_obj_type_t adafruit_bus_device_i2cdevice_type; // Initializes the hardware peripheral. -extern void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address); -extern uint8_t common_hal_adafruit_bus_device_i2cdevice_readinto(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length); -extern uint8_t common_hal_adafruit_bus_device_i2cdevice_write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length, bool transmit_stop_bit); +extern void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t *i2c, uint8_t device_address); extern void common_hal_adafruit_bus_device_i2cdevice_lock(adafruit_bus_device_i2cdevice_obj_t *self); extern void common_hal_adafruit_bus_device_i2cdevice_unlock(adafruit_bus_device_i2cdevice_obj_t *self); extern void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_device_i2cdevice_obj_t *self); diff --git a/shared-module/adafruit_bus_device/I2CDevice.c b/shared-module/adafruit_bus_device/I2CDevice.c index 83abe80d64..53811d4910 100644 --- a/shared-module/adafruit_bus_device/I2CDevice.c +++ b/shared-module/adafruit_bus_device/I2CDevice.c @@ -31,48 +31,75 @@ #include "py/runtime.h" #include "lib/utils/interrupt_char.h" -void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cdevice_obj_t *self, busio_i2c_obj_t *i2c, uint8_t device_address) { +void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t *i2c, uint8_t device_address) { self->i2c = i2c; self->device_address = device_address; } void common_hal_adafruit_bus_device_i2cdevice_lock(adafruit_bus_device_i2cdevice_obj_t *self) { - bool success = common_hal_busio_i2c_try_lock(self->i2c); + mp_obj_t dest[2]; + mp_load_method(self->i2c, MP_QSTR_try_lock, dest); - while (!success) { + mp_obj_t success = mp_call_method_n_kw(0, 0, dest); + + while (!mp_obj_is_true(success)) { RUN_BACKGROUND_TASKS; if (mp_hal_is_interrupted()) { break; } - success = common_hal_busio_i2c_try_lock(self->i2c); + success = mp_call_method_n_kw(0, 0, dest); } } void common_hal_adafruit_bus_device_i2cdevice_unlock(adafruit_bus_device_i2cdevice_obj_t *self) { - common_hal_busio_i2c_unlock(self->i2c); -} - -uint8_t common_hal_adafruit_bus_device_i2cdevice_readinto(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length) { - return common_hal_busio_i2c_read(self->i2c, self->device_address, buffer, length); -} - -uint8_t common_hal_adafruit_bus_device_i2cdevice_write(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t buffer, size_t length, bool transmit_stop_bit) { - return common_hal_busio_i2c_write(self->i2c, self->device_address, buffer, length, transmit_stop_bit); + mp_obj_t dest[2]; + mp_load_method(self->i2c, MP_QSTR_unlock, dest); + mp_call_method_n_kw(0, 0, dest); } void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_device_i2cdevice_obj_t *self) { common_hal_adafruit_bus_device_i2cdevice_lock(self); - mp_buffer_info_t bufinfo; - mp_obj_t buffer = mp_obj_new_bytearray_of_zeros(1); + mp_buffer_info_t write_bufinfo; + mp_obj_t write_buffer = mp_obj_new_bytearray_of_zeros(0); + mp_get_buffer_raise(write_buffer, &write_bufinfo, MP_BUFFER_READ); - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); + mp_obj_t dest[4]; - uint8_t status = common_hal_adafruit_bus_device_i2cdevice_readinto(self, (uint8_t*)bufinfo.buf, 1); - if (status != 0) { - common_hal_adafruit_bus_device_i2cdevice_unlock(self); - mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); + /* catch exceptions that may be thrown while probing for the device */ + nlr_buf_t write_nlr; + if (nlr_push(&write_nlr) == 0) { + mp_load_method(self->i2c, MP_QSTR_writeto, dest); + dest[2] = mp_obj_new_int_from_ull(self->device_address); + dest[3] = write_buffer; + mp_call_method_n_kw(2, 0, dest); + nlr_pop(); + } else { + /* some OS's don't like writing an empty bytestring... retry by reading a byte */ + mp_buffer_info_t read_bufinfo; + mp_obj_t read_buffer = mp_obj_new_bytearray_of_zeros(1); + mp_get_buffer_raise(read_buffer, &read_bufinfo, MP_BUFFER_WRITE); + + mp_load_method(self->i2c, MP_QSTR_readfrom_into, dest); + dest[2] = mp_obj_new_int_from_ull(self->device_address); + dest[3] = read_buffer; + + nlr_buf_t read_nlr; + if (nlr_push(&read_nlr) == 0) { + mp_call_method_n_kw(2, 0, dest); + nlr_pop(); + } else { + /* At this point we tried two methods and only got exceptions */ + if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)read_nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { + common_hal_adafruit_bus_device_i2cdevice_unlock(self); + mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); + } + else { + /* In case we receive an unrelated exception pass it up */ + nlr_raise(MP_OBJ_FROM_PTR(read_nlr.ret_val)); + } + } } common_hal_adafruit_bus_device_i2cdevice_unlock(self); diff --git a/shared-module/adafruit_bus_device/I2CDevice.h b/shared-module/adafruit_bus_device/I2CDevice.h index d06adb9f50..b76bafb2c1 100644 --- a/shared-module/adafruit_bus_device/I2CDevice.h +++ b/shared-module/adafruit_bus_device/I2CDevice.h @@ -32,7 +32,7 @@ typedef struct { mp_obj_base_t base; - busio_i2c_obj_t *i2c; + mp_obj_t *i2c; uint8_t device_address; } adafruit_bus_device_i2cdevice_obj_t; From b609bc012434e1a8753196b2d020a3d05faf7948 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Tue, 5 Jan 2021 16:29:37 -0600 Subject: [PATCH 02/53] Removed unused include --- shared-bindings/adafruit_bus_device/I2CDevice.c | 1 - 1 file changed, 1 deletion(-) diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/I2CDevice.c index d3b6fbec44..f76cfb0e11 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/I2CDevice.c @@ -31,7 +31,6 @@ #include "shared-bindings/adafruit_bus_device/I2CDevice.h" #include "shared-bindings/util.h" #include "shared-module/adafruit_bus_device/I2CDevice.h" -#include "shared-bindings/busio/I2C.h" #include "lib/utils/buffer_helper.h" #include "lib/utils/context_manager_helpers.h" From d3995eaf9748f641355a92c2929f3330a027b586 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 9 Jan 2021 10:07:08 -0600 Subject: [PATCH 03/53] Fixes from draft PR --- .../adafruit_bus_device/I2CDevice.c | 17 +++++----- shared-module/adafruit_bus_device/I2CDevice.c | 33 +++++-------------- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/I2CDevice.c index f76cfb0e11..15e8cc7063 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/I2CDevice.c @@ -135,9 +135,10 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o mp_load_method(self->i2c, MP_QSTR_readfrom_into, dest); dest[2] = mp_obj_new_int_from_ull(self->device_address); dest[3] = args[ARG_buffer].u_obj; - dest[4] = mp_obj_new_str("start", 5); + //dest[4] = mp_obj_new_str("start", 5); + dest[4] = MP_OBJ_NEW_QSTR(MP_QSTR_start); dest[5] = mp_obj_new_int(args[ARG_start].u_int); - dest[6] = mp_obj_new_str("end", 3); + dest[6] = MP_OBJ_NEW_QSTR(MP_QSTR_end); dest[7] = mp_obj_new_int(args[ARG_end].u_int); mp_call_method_n_kw(2, 2, dest); @@ -172,9 +173,9 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_ mp_load_method(self->i2c, MP_QSTR_writeto, dest); dest[2] = mp_obj_new_int_from_ull(self->device_address); dest[3] = args[ARG_buffer].u_obj; - dest[4] = mp_obj_new_str("start", 5); + dest[4] = MP_OBJ_NEW_QSTR(MP_QSTR_start); dest[5] = mp_obj_new_int(args[ARG_start].u_int); - dest[6] = mp_obj_new_str("end", 3); + dest[6] = MP_OBJ_NEW_QSTR(MP_QSTR_end); dest[7] = mp_obj_new_int(args[ARG_end].u_int); mp_call_method_n_kw(2, 2, dest); @@ -224,13 +225,13 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args, dest[2] = mp_obj_new_int_from_ull(self->device_address); dest[3] = args[ARG_out_buffer].u_obj; dest[4] = args[ARG_in_buffer].u_obj; - dest[5] = mp_obj_new_str("out_start", 9); + dest[5] = MP_OBJ_NEW_QSTR(MP_QSTR_out_start); dest[6] = mp_obj_new_int(args[ARG_out_start].u_int); - dest[7] = mp_obj_new_str("out_end", 7); + dest[7] = MP_OBJ_NEW_QSTR(MP_QSTR_out_end); dest[8] = mp_obj_new_int(args[ARG_out_end].u_int); - dest[9] = mp_obj_new_str("in_start", 8); + dest[9] = MP_OBJ_NEW_QSTR(MP_QSTR_in_start); dest[10] = mp_obj_new_int(args[ARG_in_start].u_int); - dest[11] = mp_obj_new_str("in_end", 6); + dest[11] = MP_OBJ_NEW_QSTR(MP_QSTR_in_end); dest[12] = mp_obj_new_int(args[ARG_in_end].u_int); mp_call_method_n_kw(3, 4, dest); diff --git a/shared-module/adafruit_bus_device/I2CDevice.c b/shared-module/adafruit_bus_device/I2CDevice.c index 53811d4910..792ab7183c 100644 --- a/shared-module/adafruit_bus_device/I2CDevice.c +++ b/shared-module/adafruit_bus_device/I2CDevice.c @@ -68,37 +68,22 @@ void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_devi mp_obj_t dest[4]; /* catch exceptions that may be thrown while probing for the device */ - nlr_buf_t write_nlr; - if (nlr_push(&write_nlr) == 0) { + nlr_buf_t nlr; + if (nlr_push(&nlr) == 0) { mp_load_method(self->i2c, MP_QSTR_writeto, dest); dest[2] = mp_obj_new_int_from_ull(self->device_address); dest[3] = write_buffer; mp_call_method_n_kw(2, 0, dest); nlr_pop(); } else { - /* some OS's don't like writing an empty bytestring... retry by reading a byte */ - mp_buffer_info_t read_bufinfo; - mp_obj_t read_buffer = mp_obj_new_bytearray_of_zeros(1); - mp_get_buffer_raise(read_buffer, &read_bufinfo, MP_BUFFER_WRITE); + common_hal_adafruit_bus_device_i2cdevice_unlock(self); - mp_load_method(self->i2c, MP_QSTR_readfrom_into, dest); - dest[2] = mp_obj_new_int_from_ull(self->device_address); - dest[3] = read_buffer; - - nlr_buf_t read_nlr; - if (nlr_push(&read_nlr) == 0) { - mp_call_method_n_kw(2, 0, dest); - nlr_pop(); - } else { - /* At this point we tried two methods and only got exceptions */ - if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)read_nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { - common_hal_adafruit_bus_device_i2cdevice_unlock(self); - mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); - } - else { - /* In case we receive an unrelated exception pass it up */ - nlr_raise(MP_OBJ_FROM_PTR(read_nlr.ret_val)); - } + if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { + mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); + } + else { + /* In case we receive an unrelated exception pass it up */ + nlr_raise(MP_OBJ_FROM_PTR(nlr.ret_val)); } } From f50c9f4145bbf6409f909a7d0cb83786db905bf8 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 16 Jan 2021 14:18:46 -0600 Subject: [PATCH 04/53] Reenabling busdevice in core --- py/circuitpy_mpconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index d0145a90f3..5df48debeb 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -100,7 +100,7 @@ CFLAGS += -DCIRCUITPY_BLEIO=$(CIRCUITPY_BLEIO) CIRCUITPY_BOARD ?= 1 CFLAGS += -DCIRCUITPY_BOARD=$(CIRCUITPY_BOARD) -CIRCUITPY_BUSDEVICE = 0 +CIRCUITPY_BUSDEVICE ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_BUSDEVICE=$(CIRCUITPY_BUSDEVICE) CIRCUITPY_BUILTINS_POW3 ?= $(CIRCUITPY_FULL_BUILD) From 49e059cdaf8cedccf175cf00d8286788c2077ac1 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sat, 16 Jan 2021 16:37:42 -0600 Subject: [PATCH 05/53] Removing frozen libraries --- ports/atmel-samd/boards/8086_commander/mpconfigboard.mk | 1 - .../atmel-samd/boards/circuitplayground_express/mpconfigboard.mk | 1 - .../boards/circuitplayground_express_crickit/mpconfigboard.mk | 1 - .../boards/circuitplayground_express_displayio/mpconfigboard.mk | 1 - .../boards/feather_m0_express_crickit/mpconfigboard.mk | 1 - ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk | 1 - ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk | 1 - ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk | 1 - ports/atmel-samd/boards/pycubed/mpconfigboard.mk | 1 - ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk | 1 - ports/atmel-samd/boards/sam32/mpconfigboard.mk | 1 - ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk | 1 - ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk | 1 - 13 files changed, 13 deletions(-) diff --git a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk index b5a4bc735f..f976dfe787 100644 --- a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk +++ b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk @@ -22,7 +22,6 @@ CIRCUITPY_GAMEPAD = 1 CIRCUITPY_BUSDEVICE = 1 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD #FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ADXL34x diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk index 505f5c145d..0b150a5fbe 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk @@ -22,7 +22,6 @@ SUPEROPT_GC = 0 CFLAGS_INLINE_LIMIT = 55 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index c3be33134c..35b6f12293 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -26,7 +26,6 @@ CFLAGS_INLINE_LIMIT = 50 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Crickit FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index 51e9b05af2..f754f3513c 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -27,7 +27,6 @@ SUPEROPT_GC = 0 CFLAGS_INLINE_LIMIT = 55 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk index f06163b84a..309563ff49 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk @@ -21,7 +21,6 @@ CFLAGS_INLINE_LIMIT = 50 CIRCUITPY_MSGPACK = 0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Crickit FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Motor FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk index 6e089bb90d..6ea21ed82e 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk @@ -28,5 +28,4 @@ CFLAGS_INLINE_LIMIT = 35 SUPEROPT_GC = 0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM69 diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk index 383b6a6df4..76a6be2e34 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk @@ -29,5 +29,4 @@ CFLAGS_INLINE_LIMIT = 35 SUPEROPT_GC = 0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM9x diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index 1931ceb9a8..2b211abd4e 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -27,7 +27,6 @@ CFLAGS_INLINE_LIMIT = 55 SUPEROPT_GC = 0 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk index b7b8073ab9..a82362b8d2 100644 --- a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk @@ -21,7 +21,6 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk index f49bb3fef0..3bf42d7054 100644 --- a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk @@ -21,7 +21,6 @@ CIRCUITPY_GAMEPAD = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.mk b/ports/atmel-samd/boards/sam32/mpconfigboard.mk index 1dc686ef8a..9ac24a014c 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.mk @@ -13,5 +13,4 @@ LONGINT_IMPL = MPZ CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_USTACK = 1 -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk index 3562228c71..d6f333b5be 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk @@ -24,4 +24,3 @@ CIRCUITPY_TOUCHIO=0 CIRCUITPY_BUSDEVICE=1 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice diff --git a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk index 53908293f5..fd2fa044a8 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk @@ -27,5 +27,4 @@ CIRCUITPY_COUNTIO=0 CIRCUITPY_BUSDEVICE=1 # Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD From 41b9196167576c9a593d51e601edd51cba5b72c4 Mon Sep 17 00:00:00 2001 From: gamblor21 Date: Sun, 17 Jan 2021 00:00:06 -0600 Subject: [PATCH 06/53] Disabling in more small boards --- ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk | 1 + ports/atmel-samd/boards/serpente/mpconfigboard.mk | 1 + ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk | 1 + ports/atmel-samd/boards/ugame10/mpconfigboard.mk | 1 + ports/nrf/boards/pca10100/mpconfigboard.mk | 1 + ports/stm/boards/espruino_pico/mpconfigboard.mk | 1 + 6 files changed, 6 insertions(+) diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk index 178258b6cd..2ace30fb53 100755 --- a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk @@ -16,6 +16,7 @@ CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 MICROPY_PY_ASYNC_AWAIT = 0 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/serpente/mpconfigboard.mk b/ports/atmel-samd/boards/serpente/mpconfigboard.mk index 6e953adf72..09036875f1 100644 --- a/ports/atmel-samd/boards/serpente/mpconfigboard.mk +++ b/ports/atmel-samd/boards/serpente/mpconfigboard.mk @@ -14,6 +14,7 @@ LONGINT_IMPL = NONE CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_GAMEPAD = 0 +CIRCUITPY_BUSDEVICE = 0 SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk index e71bb07395..2e15bc042a 100755 --- a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk @@ -14,6 +14,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_VECTORIO = 0 +CIRCUITPY_BUSDEVICE = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk index b1242d206e..640d421e81 100644 --- a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk @@ -28,6 +28,7 @@ CIRCUITPY_RTC = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_BUSDEVICE = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/ugame10 diff --git a/ports/nrf/boards/pca10100/mpconfigboard.mk b/ports/nrf/boards/pca10100/mpconfigboard.mk index 76d15e6081..c8cba2877c 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.mk +++ b/ports/nrf/boards/pca10100/mpconfigboard.mk @@ -25,6 +25,7 @@ CIRCUITPY_RTC = 1 CIRCUITPY_SDCARDIO = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_ULAB = 0 +CIRCUITPY_BUSDEVICE = 0 MICROPY_PY_ASYNC_AWAIT = 0 SUPEROPT_GC = 0 diff --git a/ports/stm/boards/espruino_pico/mpconfigboard.mk b/ports/stm/boards/espruino_pico/mpconfigboard.mk index 14f9323fde..81c3772e72 100644 --- a/ports/stm/boards/espruino_pico/mpconfigboard.mk +++ b/ports/stm/boards/espruino_pico/mpconfigboard.mk @@ -20,5 +20,6 @@ LD_FILE = boards/STM32F401xd_fs.ld # lto for this port, and if other stuff hasn't been added in the # meantime CIRCUITPY_ULAB = 0 +CIRCUITPY_BUSDEVICE = 0 SUPEROPT_GC = 0 From 811a34fc3db4761d4bb184b545f8930df02d296e Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Fri, 22 Jan 2021 14:42:09 -0600 Subject: [PATCH 07/53] Add initial ParallelBus support for ESP32-S2 --- .../common-hal/displayio/ParallelBus.c | 162 +++++++++++++++++- .../common-hal/displayio/ParallelBus.h | 9 + 2 files changed, 164 insertions(+), 7 deletions(-) diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.c b/ports/esp32s2/common-hal/displayio/ParallelBus.c index d0c98f3611..d734c030f9 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.c +++ b/ports/esp32s2/common-hal/displayio/ParallelBus.c @@ -33,35 +33,183 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/microcontroller/__init__.h" +/* +* Current pin limitations: +* data0 pin must be byte aligned and use pin numbers < 32 (data0 options: 0, 8, 16 or 24) +* write pin must be pin number < 32. +* +* Future extensions: +* 1. Allow data0 pin numbers >= 32. +* 2. Allow write pin numbers >= 32. +*/ + void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self, const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select, const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) { - mp_raise_NotImplementedError(translate("ParallelBus not yet supported")); + + uint8_t data_pin = data0->number; + if ( (data_pin % 8 != 0) && (data_pin >= 32) ) { + mp_raise_ValueError(translate("Data 0 pin must be byte aligned and < 32")); + } + + for (uint8_t i = 0; i < 8; i++) { + if (!pin_number_is_free(data_pin + i)) { + mp_raise_ValueError_varg(translate("Bus pin %d is already in use"), i); + } + } + + if (write->number >= 32) { + mp_raise_ValueError(translate("Write pin must be < 32")); + } + + gpio_dev_t *g = &GPIO; /* this is the GPIO registers, see "extern gpio_dev_t GPIO" from file:gpio_struct.h */ + + /* Setup the pins as "Simple GPIO outputs" see section 19.3.3 of the ESP32-S2 Reference Manual */ + /* Enable pins with "enable_w1ts" */ + + for (uint8_t i = 0; i < 8; i++) { + g->enable_w1ts = (0x1 << (data_pin + i)); + g->func_out_sel_cfg[data_pin + i].val= 256; /* setup output pin for simple GPIO Output, (0x100 = 256) */ + + } + + /* I think there is a limitation of the ESP32-S2 that does not allow single-byte writes into + the GPIO registers. See section 10.3.3 regarding "non-aligned writes" into the registers. + If a method for writing single-byte writes is uncovered, this code can be modified to provide + single-byte access into the output register */ + + self->bus = (uint32_t*) &g->out; //pointer to GPIO output register (for pins 0-31) + + /* SNIP - common setup of command, chip select, write and read pins, same as from SAMD and NRF ports */ + self->command.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->command, command); + common_hal_digitalio_digitalinout_switch_to_output(&self->command, true, DRIVE_MODE_PUSH_PULL); + + self->chip_select.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->chip_select, chip_select); + common_hal_digitalio_digitalinout_switch_to_output(&self->chip_select, true, DRIVE_MODE_PUSH_PULL); + + self->write.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->write, write); + common_hal_digitalio_digitalinout_switch_to_output(&self->write, true, DRIVE_MODE_PUSH_PULL); + + self->read.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->read, read); + common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); + + self->data0_pin = data_pin; + self->write_group = &GPIO; + /* Should modify the .h structure definitions if want to allow a write pin >= 32. + If so, consider putting separate "clear_write" and "set_write" pointers into the .h in place of "write_group" + to select between out_w1tc/out1_w1tc (clear) and out_w1ts/out1_w1ts (set) registers. */ + + self->write_mask = 1 << (write->number % 32); /* the write pin triggers the LCD to latch the data */ + /* Note: As currently written for the ESP32-S2 port, the write pin must be a pin number less than 32 + This could be updated to accommodate 32 and higher by using the different construction of the + address for writing to output pins >= 32, see related note above for 'self->write_group' */ + + /* SNIP - common setup of the reset pin, same as from SAMD and NRF ports */ + self->reset.base.type = &mp_type_NoneType; + if (reset != NULL) { + self->reset.base.type = &digitalio_digitalinout_type; + common_hal_digitalio_digitalinout_construct(&self->reset, reset); + common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL); + never_reset_pin_number(reset->number); + common_hal_displayio_parallelbus_reset(self); + } + + never_reset_pin_number(command->number); + never_reset_pin_number(chip_select->number); + never_reset_pin_number(write->number); + never_reset_pin_number(read->number); + for (uint8_t i = 0; i < 8; i++) { + never_reset_pin_number(data_pin + i); + } + } void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t* self) { + /* SNIP - same as from SAMD and NRF ports */ + for (uint8_t i = 0; i < 8; i++) { + reset_pin_number(self->data0_pin + i); + } + reset_pin_number(self->command.pin->number); + reset_pin_number(self->chip_select.pin->number); + reset_pin_number(self->write.pin->number); + reset_pin_number(self->read.pin->number); + reset_pin_number(self->reset.pin->number); } bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) { - return false; + /* SNIP - same as from SAMD and NRF ports */ + displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj); + if (self->reset.base.type == &mp_type_NoneType) { + return false; + } + + common_hal_digitalio_digitalinout_set_value(&self->reset, false); + common_hal_mcu_delay_us(4); + common_hal_digitalio_digitalinout_set_value(&self->reset, true); + return true; + } bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) { - return false; + /* SNIP - same as from SAMD and NRF ports */ + return true; } bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) { - - return false; + /* SNIP - same as from SAMD and NRF ports */ + displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj); + common_hal_digitalio_digitalinout_set_value(&self->chip_select, false); + return true; } void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, - display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { + display_chip_select_behavior_t chip_select, const uint8_t *data, uint32_t data_length) { + displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj); + common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA); + + /* Currently the write pin number must be < 32. + Future: To accommodate write pin numbers >= 32, will need to update to choose a different register + for set/reset (out1_w1tc and out1_w1ts) */ + + uint32_t* clear_write = (uint32_t*) &self->write_group->out_w1tc; + uint32_t* set_write = (uint32_t*) &self->write_group->out_w1ts; + uint32_t mask = self->write_mask; + + /* Setup structures for data writing. The ESP32-S2 port differs from the SAMD and NRF ports + because I have not found a way to write a single byte into the ESP32-S2 registers. + For the ESP32-S2, I create a 32-bit data_buffer that is used to transfer the data bytes. */ + + *clear_write = mask; // Clear the write pin to prepare the registers before storing register settings into data_buffer + uint32_t data_buffer = *self->bus; // store the initial output register values into the data output buffer + uint8_t* data_address = ((uint8_t*) &data_buffer) + (self->data0_pin / 8); /* address inside data_buffer where + each data byte will be written (as offset by (data0_pin/8) number of bytes) */ + + for (uint32_t i = 0; i < data_length; i++) { + + /* Question: Is there a faster way of stuffing the data byte into the data_buffer, is bit arithmetic + faster than writing to the byte address? */ + + /* Note: May be able to eliminate either the clear_write or set_write since the data buffer + can be written with the write pin cleared or set already, and depending upon whether the display + latches the data on the rising or falling edge of the write pin. Remember: This method + will require the write pin to be controlled by the same GPIO register as the data pins. */ + + *clear_write = mask; // clear the write pin (See comment above, this may not be necessary). + *(data_address) = data[i]; // stuff the data byte into the data_buffer at the correct offset byte location + *self->bus = data_buffer; // write the data to the output register + *set_write = mask; // set the write pin + } } void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) { - + /* SNIP - same as from SAMD and NRF ports */ + displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj); + common_hal_digitalio_digitalinout_set_value(&self->chip_select, true); } diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.h b/ports/esp32s2/common-hal/displayio/ParallelBus.h index cd636921d9..20fc2f1bc7 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.h +++ b/ports/esp32s2/common-hal/displayio/ParallelBus.h @@ -31,6 +31,15 @@ typedef struct { mp_obj_base_t base; + uint32_t* bus; // pointer where 8 bits of data are written to the display + digitalio_digitalinout_obj_t command; + digitalio_digitalinout_obj_t chip_select; + digitalio_digitalinout_obj_t reset; + digitalio_digitalinout_obj_t write; // write pin, must be a pin number < 32 currently + digitalio_digitalinout_obj_t read; + uint8_t data0_pin; // pin number for the lowest number pin. Must be 0, 8, 16 or 24 with current + gpio_dev_t* write_group; // pointer to the write group for setting/clearing the write bit to latch the data on the LCD + uint32_t write_mask; // bit mask for the single bit for the write pin, currently write pin must be a pin number < 32 } displayio_parallelbus_obj_t; #endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELBUS_H From dff3423c231c07751175ded39a18beef28aecd4f Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 22 Jan 2021 15:52:46 -0800 Subject: [PATCH 08/53] Change from fixed-point integer arguments to floating point in EVE API functions Changed calls: PointSize(), LineWidth(), VertexTranslateX() and VertexTranslateY() Units for all the above are now pixels, not fixed-point integers. This matches OpenGL. Docstrings updated accordingly --- shared-bindings/_eve/__init__.c | 150 ++++++++++++++++---------------- shared-bindings/_eve/__init__.h | 8 +- shared-module/_eve/__init__.c | 20 +++-- 3 files changed, 92 insertions(+), 86 deletions(-) diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 0f628b6fb0..c043aa5fae 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -604,22 +604,6 @@ STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); -//| def LineWidth(self, width: int) -> None: -//| """Set the width of rasterized lines -//| -//| :param int width: line width in :math:`1/16` pixel. Range 0-4095. The initial value is 16 -//| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" -//| ... -//| - -STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { - uint32_t width = mp_obj_get_int_truncated(a0); - common_hal__eve_LineWidth(EVEHAL(self), width); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); - //| def Macro(self, m: int) -> None: //| """Execute a single command from a macro register //| @@ -662,22 +646,6 @@ STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource); -//| def PointSize(self, size: int) -> None: -//| """Set the radius of rasterized points -//| -//| :param int size: point radius in :math:`1/16` pixel. Range 0-8191. The initial value is 16 -//| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" -//| ... -//| - -STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { - uint32_t size = mp_obj_get_int_truncated(a0); - common_hal__eve_PointSize(EVEHAL(self), size); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); - //| def RestoreContext(self) -> None: //| """Restore the current graphics context from the context stack""" //| ... @@ -836,48 +804,6 @@ STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); -//| def VertexTranslateX(self, x: int) -> None: -//| """Set the vertex transformation's x translation component -//| -//| :param int x: signed x-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0 -//| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" -//| ... -//| - -STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { - uint32_t x = mp_obj_get_int_truncated(a0); - common_hal__eve_VertexTranslateX(EVEHAL(self), x); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); - -//| def VertexTranslateY(self, y: int) -> None: -//| """Set the vertex transformation's y translation component -//| -//| :param int y: signed y-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0 -//| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" -//| ... -//| - - -STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { - uint32_t y = mp_obj_get_int_truncated(a0); - common_hal__eve_VertexTranslateY(EVEHAL(self), y); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); - -//| def VertexFormat(self, frac: int) -> None: -//| """Set the precision of vertex2f coordinates -//| -//| :param int frac: Number of fractional bits in X,Y coordinates, 0-4. Range 0-7. The initial value is 4 -//| -//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" -//| ... -//| - STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { uint32_t frac = mp_obj_get_int_truncated(a0); common_hal__eve_VertexFormat(EVEHAL(self), frac); @@ -975,6 +901,82 @@ STATIC mp_obj_t _vertex2f(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { } STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); +//| def LineWidth(self, width: float) -> None: +//| """Set the width of rasterized lines +//| +//| :param float width: line width in pixels. Range 0-511. The initial value is 1 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... +//| + +STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { + mp_float_t width = mp_obj_get_float(a0); + common_hal__eve_LineWidth(EVEHAL(self), width); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); + +//| def PointSize(self, size: float) -> None: +//| """Set the diameter of rasterized points +//| +//| :param float size: point diameter in pixels. Range 0-1023. The initial value is 1 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... +//| + +STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { + mp_float_t size = mp_obj_get_float(a0); + common_hal__eve_PointSize(EVEHAL(self), size); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); + +//| def VertexTranslateX(self, x: float) -> None: +//| """Set the vertex transformation's x translation component +//| +//| :param float x: signed x-coordinate in pixels. Range ±4095. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... +//| + +STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { + mp_float_t x = mp_obj_get_float(a0); + common_hal__eve_VertexTranslateX(EVEHAL(self), x); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); + +//| def VertexTranslateY(self, y: float) -> None: +//| """Set the vertex transformation's y translation component +//| +//| :param float y: signed y-coordinate in pixels. Range ±4095. The initial value is 0 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... +//| + + +STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { + mp_float_t y = mp_obj_get_float(a0); + common_hal__eve_VertexTranslateY(EVEHAL(self), y); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); + +//| def VertexFormat(self, frac: int) -> None: +//| """Set the precision of vertex2f coordinates +//| +//| :param int frac: Number of fractional bits in X,Y coordinates, 0-4. Range 0-7. The initial value is 4 +//| +//| This value is part of the graphics context and is saved and restored by :meth:`SaveContext` and :meth:`RestoreContext`.""" +//| ... +//| + +//} + // Append an object x to the FIFO #define ADD_X(self, x) \ common_hal__eve_add(EVEHAL(self), sizeof(x), &(x)); diff --git a/shared-bindings/_eve/__init__.h b/shared-bindings/_eve/__init__.h index 759a629bbd..883b1a15bf 100644 --- a/shared-bindings/_eve/__init__.h +++ b/shared-bindings/_eve/__init__.h @@ -61,11 +61,11 @@ void common_hal__eve_ColorRGB(common_hal__eve_t *eve, uint32_t red, uint32_t gre void common_hal__eve_Display(common_hal__eve_t *eve); void common_hal__eve_End(common_hal__eve_t *eve); void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest); -void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width); +void common_hal__eve_LineWidth(common_hal__eve_t *eve, mp_float_t width); void common_hal__eve_Macro(common_hal__eve_t *eve, uint32_t m); void common_hal__eve_Nop(common_hal__eve_t *eve); void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr); -void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size); +void common_hal__eve_PointSize(common_hal__eve_t *eve, mp_float_t size); void common_hal__eve_RestoreContext(common_hal__eve_t *eve); void common_hal__eve_Return(common_hal__eve_t *eve); void common_hal__eve_SaveContext(common_hal__eve_t *eve); @@ -76,8 +76,8 @@ void common_hal__eve_StencilMask(common_hal__eve_t *eve, uint32_t mask); void common_hal__eve_StencilOp(common_hal__eve_t *eve, uint32_t sfail, uint32_t spass); void common_hal__eve_TagMask(common_hal__eve_t *eve, uint32_t mask); void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s); -void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x); -void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y); +void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, mp_float_t x); +void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, mp_float_t y); void common_hal__eve_VertexFormat(common_hal__eve_t *eve, uint32_t frac); void common_hal__eve_Vertex2ii(common_hal__eve_t *eve, uint32_t x, uint32_t y, uint32_t handle, uint32_t cell); diff --git a/shared-module/_eve/__init__.c b/shared-module/_eve/__init__.c index d95c777dc4..579729d42c 100644 --- a/shared-module/_eve/__init__.c +++ b/shared-module/_eve/__init__.c @@ -226,8 +226,9 @@ void common_hal__eve_Jump(common_hal__eve_t *eve, uint32_t dest) { } -void common_hal__eve_LineWidth(common_hal__eve_t *eve, uint32_t width) { - C4(eve, ((14 << 24) | ((width & 4095)))); +void common_hal__eve_LineWidth(common_hal__eve_t *eve, mp_float_t width) { + int16_t iw = (int)(8 * width); + C4(eve, ((14 << 24) | ((iw & 4095)))); } @@ -246,8 +247,9 @@ void common_hal__eve_PaletteSource(common_hal__eve_t *eve, uint32_t addr) { } -void common_hal__eve_PointSize(common_hal__eve_t *eve, uint32_t size) { - C4(eve, ((13 << 24) | ((size & 8191)))); +void common_hal__eve_PointSize(common_hal__eve_t *eve, mp_float_t size) { + int16_t is = (int)(8 * size); + C4(eve, ((13 << 24) | ((is & 8191)))); } @@ -301,13 +303,15 @@ void common_hal__eve_Tag(common_hal__eve_t *eve, uint32_t s) { } -void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, uint32_t x) { - C4(eve, ((43 << 24) | (((x) & 131071)))); +void common_hal__eve_VertexTranslateX(common_hal__eve_t *eve, mp_float_t x) { + int16_t ix = (int)(16 * x); + C4(eve, ((43 << 24) | (ix & 131071))); } -void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, uint32_t y) { - C4(eve, ((44 << 24) | (((y) & 131071)))); +void common_hal__eve_VertexTranslateY(common_hal__eve_t *eve, mp_float_t y) { + int16_t iy = (int)(16 * y); + C4(eve, ((44 << 24) | (iy & 131071))); } From 34aa01c5f9c45a85f4c6c73bc4e094a717b68451 Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Fri, 22 Jan 2021 22:29:51 -0600 Subject: [PATCH 09/53] Remove redundant clear_write, add make translate --- locale/circuitpython.pot | 10 ++++++- .../common-hal/displayio/ParallelBus.c | 28 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 434684e137..4dfce747d7 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -527,6 +527,7 @@ msgid "Buffer too short by %d bytes" msgstr "" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -796,6 +797,10 @@ msgstr "" msgid "Data 0 pin must be byte aligned" msgstr "" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned and < 32" +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -1564,7 +1569,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" @@ -2136,6 +2140,10 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Write pin must be < 32" +msgstr "" + #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.c b/ports/esp32s2/common-hal/displayio/ParallelBus.c index d734c030f9..04e24b2914 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.c +++ b/ports/esp32s2/common-hal/displayio/ParallelBus.c @@ -177,19 +177,33 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt Future: To accommodate write pin numbers >= 32, will need to update to choose a different register for set/reset (out1_w1tc and out1_w1ts) */ + // **** Bit shifting trial + // uint32_t* output_register = self->bus; + // const uint8_t bit_shift=self->data0_pin; + uint32_t* clear_write = (uint32_t*) &self->write_group->out_w1tc; uint32_t* set_write = (uint32_t*) &self->write_group->out_w1ts; - uint32_t mask = self->write_mask; + + const uint32_t mask = self->write_mask; + /* Setup structures for data writing. The ESP32-S2 port differs from the SAMD and NRF ports because I have not found a way to write a single byte into the ESP32-S2 registers. For the ESP32-S2, I create a 32-bit data_buffer that is used to transfer the data bytes. */ *clear_write = mask; // Clear the write pin to prepare the registers before storing register settings into data_buffer - uint32_t data_buffer = *self->bus; // store the initial output register values into the data output buffer + + const uint32_t data_buffer = *self->bus; // store the initial output register values into the data output buffer uint8_t* data_address = ((uint8_t*) &data_buffer) + (self->data0_pin / 8); /* address inside data_buffer where each data byte will be written (as offset by (data0_pin/8) number of bytes) */ + // *** Bit shifting trial + // *data_address = 0; //clear the 8 data bits + + //mp_printf(&mp_plat_print, "\n\ndata_buffer: %x\n", data_buffer); + //mp_printf(&mp_plat_print, "data[0]: %x\n", data[0]); + //mp_printf(&mp_plat_print, "data_buffer[0]: %x\n\n", (data_buffer | (((uint32_t) data[0]) << self->data0_pin))); + for (uint32_t i = 0; i < data_length; i++) { /* Question: Is there a faster way of stuffing the data byte into the data_buffer, is bit arithmetic @@ -200,9 +214,17 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt latches the data on the rising or falling edge of the write pin. Remember: This method will require the write pin to be controlled by the same GPIO register as the data pins. */ - *clear_write = mask; // clear the write pin (See comment above, this may not be necessary). + // Can ignore this line if the write pin is in the same register as the data pins + // *clear_write = mask; // clear the write pin (See comment above, this may not be necessary). + + // *** Original code *(data_address) = data[i]; // stuff the data byte into the data_buffer at the correct offset byte location *self->bus = data_buffer; // write the data to the output register + + // *** Bit shifting trial - didn't have much improvement in performance + // *output_register = (data_buffer | (((uint32_t) data[i]) << bit_shift)); + + *set_write = mask; // set the write pin } From 10965e59896b9fd7b1261792d5ed450beae6c1eb Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Sat, 23 Jan 2021 11:30:17 -0600 Subject: [PATCH 10/53] Delete unnecessary comments --- .../common-hal/displayio/ParallelBus.c | 90 ++++++++----------- 1 file changed, 39 insertions(+), 51 deletions(-) diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.c b/ports/esp32s2/common-hal/displayio/ParallelBus.c index 04e24b2914..b644610f21 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.c +++ b/ports/esp32s2/common-hal/displayio/ParallelBus.c @@ -34,20 +34,18 @@ #include "shared-bindings/microcontroller/__init__.h" /* -* Current pin limitations: -* data0 pin must be byte aligned and use pin numbers < 32 (data0 options: 0, 8, 16 or 24) -* write pin must be pin number < 32. -* -* Future extensions: -* 1. Allow data0 pin numbers >= 32. -* 2. Allow write pin numbers >= 32. -*/ + * + * Current pin limitations for ESP32-S2 ParallelBus: + * 1. data0 pin must be byte aligned (data0 pin options: 0, 8, 16 or 24) + * 2. The 8 data lines must use pin numbers < 32 + * 3. The write pin must be pin number < 32. + * + */ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self, const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select, const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) { - uint8_t data_pin = data0->number; if ( (data_pin % 8 != 0) && (data_pin >= 32) ) { mp_raise_ValueError(translate("Data 0 pin must be byte aligned and < 32")); @@ -63,10 +61,10 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel mp_raise_ValueError(translate("Write pin must be < 32")); } - gpio_dev_t *g = &GPIO; /* this is the GPIO registers, see "extern gpio_dev_t GPIO" from file:gpio_struct.h */ + gpio_dev_t *g = &GPIO; // this is the GPIO registers, see "extern gpio_dev_t GPIO" from file:gpio_struct.h - /* Setup the pins as "Simple GPIO outputs" see section 19.3.3 of the ESP32-S2 Reference Manual */ - /* Enable pins with "enable_w1ts" */ + // Setup the pins as "Simple GPIO outputs" see section 19.3.3 of the ESP32-S2 Reference Manual + // Enable pins with "enable_w1ts" for (uint8_t i = 0; i < 8; i++) { g->enable_w1ts = (0x1 << (data_pin + i)); @@ -74,10 +72,11 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel } - /* I think there is a limitation of the ESP32-S2 that does not allow single-byte writes into - the GPIO registers. See section 10.3.3 regarding "non-aligned writes" into the registers. - If a method for writing single-byte writes is uncovered, this code can be modified to provide - single-byte access into the output register */ + /* From my understanding, there is a limitation of the ESP32-S2 that does not allow single-byte writes + * into the GPIO registers. See section 10.3.3 regarding "non-aligned writes" into the registers. + * If a method for writing single-byte writes is uncovered, this code can be modified to provide + * single-byte access into the output register + */ self->bus = (uint32_t*) &g->out; //pointer to GPIO output register (for pins 0-31) @@ -100,14 +99,16 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel self->data0_pin = data_pin; self->write_group = &GPIO; - /* Should modify the .h structure definitions if want to allow a write pin >= 32. - If so, consider putting separate "clear_write" and "set_write" pointers into the .h in place of "write_group" - to select between out_w1tc/out1_w1tc (clear) and out_w1ts/out1_w1ts (set) registers. */ + /* If we want to allow a write pin >= 32, should consider putting separate "clear_write" and + * "set_write" pointers into the .h in place of "write_group" + * to select between out_w1tc/out1_w1tc (clear) and out_w1ts/out1_w1ts (set) registers. + */ self->write_mask = 1 << (write->number % 32); /* the write pin triggers the LCD to latch the data */ /* Note: As currently written for the ESP32-S2 port, the write pin must be a pin number less than 32 - This could be updated to accommodate 32 and higher by using the different construction of the - address for writing to output pins >= 32, see related note above for 'self->write_group' */ + * This could be updated to accommodate 32 and higher by using the different construction of the + * address for writing to output pins >= 32, see related note above for 'self->write_group' + */ /* SNIP - common setup of the reset pin, same as from SAMD and NRF ports */ self->reset.base.type = &mp_type_NoneType; @@ -174,57 +175,44 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA); /* Currently the write pin number must be < 32. - Future: To accommodate write pin numbers >= 32, will need to update to choose a different register - for set/reset (out1_w1tc and out1_w1ts) */ - - // **** Bit shifting trial - // uint32_t* output_register = self->bus; - // const uint8_t bit_shift=self->data0_pin; + * Future: To accommodate write pin numbers >= 32, will need to update to choose the correct register + * for the write pin set/clear (out_w1ts/out1_w1ts and out_w1tc/out1_w1tc) + */ uint32_t* clear_write = (uint32_t*) &self->write_group->out_w1tc; uint32_t* set_write = (uint32_t*) &self->write_group->out_w1ts; const uint32_t mask = self->write_mask; - /* Setup structures for data writing. The ESP32-S2 port differs from the SAMD and NRF ports - because I have not found a way to write a single byte into the ESP32-S2 registers. - For the ESP32-S2, I create a 32-bit data_buffer that is used to transfer the data bytes. */ + * because I have not found a way to write a single byte into the ESP32-S2 registers. + * For the ESP32-S2, I create a 32-bit data_buffer that is used to transfer the data bytes. + */ - *clear_write = mask; // Clear the write pin to prepare the registers before storing register settings into data_buffer + *clear_write = mask; // Clear the write pin to prepare the registers before storing the + // register value into data_buffer const uint32_t data_buffer = *self->bus; // store the initial output register values into the data output buffer uint8_t* data_address = ((uint8_t*) &data_buffer) + (self->data0_pin / 8); /* address inside data_buffer where - each data byte will be written (as offset by (data0_pin/8) number of bytes) */ - - // *** Bit shifting trial - // *data_address = 0; //clear the 8 data bits - - //mp_printf(&mp_plat_print, "\n\ndata_buffer: %x\n", data_buffer); - //mp_printf(&mp_plat_print, "data[0]: %x\n", data[0]); - //mp_printf(&mp_plat_print, "data_buffer[0]: %x\n\n", (data_buffer | (((uint32_t) data[0]) << self->data0_pin))); + * each data byte will be written to the data pin registers + */ for (uint32_t i = 0; i < data_length; i++) { /* Question: Is there a faster way of stuffing the data byte into the data_buffer, is bit arithmetic - faster than writing to the byte address? */ + * faster than writing to the byte address? + */ - /* Note: May be able to eliminate either the clear_write or set_write since the data buffer - can be written with the write pin cleared or set already, and depending upon whether the display - latches the data on the rising or falling edge of the write pin. Remember: This method - will require the write pin to be controlled by the same GPIO register as the data pins. */ + /* Note: If the write pin and data pins are controlled by the same GPIO register, we can eliminate + * the "clear_write" step below, since the write pin is cleared when the data_buffer is written + * to the bus. + * Remember: This method requires the write pin to be controlled by the same GPIO register as the data pins. + */ - // Can ignore this line if the write pin is in the same register as the data pins // *clear_write = mask; // clear the write pin (See comment above, this may not be necessary). - // *** Original code *(data_address) = data[i]; // stuff the data byte into the data_buffer at the correct offset byte location *self->bus = data_buffer; // write the data to the output register - - // *** Bit shifting trial - didn't have much improvement in performance - // *output_register = (data_buffer | (((uint32_t) data[i]) << bit_shift)); - - *set_write = mask; // set the write pin } From abd9f7894df4118dc70dca0f1fa3aa3c0349edae Mon Sep 17 00:00:00 2001 From: David Glaude Date: Sun, 24 Jan 2021 12:53:06 +0100 Subject: [PATCH 11/53] Permit Gameduino 3X Dazzler support on that board. Totally untested, change request based on change made in #2581. It might be my first PR in CircuitPython core... Maybe this should be confirmed by @jamesbowman Those are the two boards that seems supported: * Metro M4 Express * Metro nRF52840 Express The only Metro that this PR concern: * Metro M4 AirLift Lite Other Metro I found and are maybe not supported: * Metro ESP32-S2 * Metro M0 Express * Metro M7 1011 --- ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk index 4895cda77b..58d4e49805 100644 --- a/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m4_airlift_lite/mpconfigboard.mk @@ -10,3 +10,5 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICE_COUNT = 3 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ + +CIRCUITPY__EVE = 1 From 69869e1439a1ebad383b75b28e7e88f21ccab732 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 24 Jan 2021 22:49:28 -0500 Subject: [PATCH 12/53] CIRCUITPY_* switches for JSON, RE, etc. Doc cleanup --- docs/library/{uerrno.rst => errno.rst} | 10 +-- docs/library/index.rst | 51 ++++--------- docs/library/{uio.rst => io.rst} | 6 +- docs/library/{ujson.rst => json.rst} | 6 +- docs/library/{ure.rst => re.rst} | 8 +- docs/shared_bindings_matrix.py | 4 +- .../mpconfigboard.h | 3 +- ports/atmel-samd/mpconfigport.h | 7 -- ports/atmel-samd/mpconfigport.mk | 52 ++++--------- ports/esp32s2/mpconfigport.h | 1 - ports/litex/mpconfigport.h | 2 - ports/mimxrt10xx/mpconfigport.h | 2 - ports/nrf/mpconfigport.h | 3 - ports/raspberrypi/mpconfigport.h | 4 +- ports/stm/mpconfigport.h | 2 - py/circuitpy_mpconfig.h | 73 ++++++++++--------- py/circuitpy_mpconfig.mk | 12 +++ shared-bindings/support_matrix.rst | 4 +- 18 files changed, 96 insertions(+), 154 deletions(-) rename docs/library/{uerrno.rst => errno.rst} (76%) rename docs/library/{uio.rst => io.rst} (97%) rename docs/library/{ujson.rst => json.rst} (87%) rename docs/library/{ure.rst => re.rst} (94%) diff --git a/docs/library/uerrno.rst b/docs/library/errno.rst similarity index 76% rename from docs/library/uerrno.rst rename to docs/library/errno.rst index 72f71f0aac..96777b2052 100644 --- a/docs/library/uerrno.rst +++ b/docs/library/errno.rst @@ -1,9 +1,7 @@ -:mod:`uerrno` -- system error codes +:mod:`errno` -- system error codes =================================== -.. include:: ../templates/unsupported_in_circuitpython.inc - -.. module:: uerrno +.. module:: errno :synopsis: system error codes |see_cpython_module| :mod:`cpython:errno`. @@ -22,7 +20,7 @@ Constants try: os.mkdir("my_dir") except OSError as exc: - if exc.args[0] == uerrno.EEXIST: + if exc.args[0] == errno.EEXIST: print("Directory already exists") .. data:: errorcode @@ -30,5 +28,5 @@ Constants Dictionary mapping numeric error codes to strings with symbolic error code (see above):: - >>> print(uerrno.errorcode[uerrno.EEXIST]) + >>> print(errno.errorcode[uerrno.EEXIST]) EEXIST diff --git a/docs/library/index.rst b/docs/library/index.rst index e913872421..94bd8a6569 100644 --- a/docs/library/index.rst +++ b/docs/library/index.rst @@ -7,34 +7,20 @@ Python standard libraries and micro-libraries --------------------------------------------- These libraries are inherited from MicroPython. -They are similar to the standard Python libraries with the same name -or with the "u" prefix dropped. +They are similar to the standard Python libraries with the same name. They implement a subset of or a variant of the corresponding standard Python library. -.. warning:: - - Though these MicroPython-based libraries are available in CircuitPython, - their functionality may change in the future, perhaps significantly. - As CircuitPython continues to develop, new versions of these libraries will - be created that are more compliant with the standard Python libraries. - You may need to change your code later if you rely - on any non-standard functionality they currently provide. - CircuitPython's long-term goal is that code written in CircuitPython using Python standard libraries will be runnable on CPython without changes. -Some libraries below are not enabled on CircuitPython builds with +These libraries are not enabled on CircuitPython builds with limited flash memory, usually on non-Express builds: -``uerrno``, ``ure``. +``binascii``, ``errno``, ``json``, ``re``. -Some libraries are not currently enabled in any CircuitPython build, but may be in the future: -``uio``, ``ujson``, ``uzlib``. - -Some libraries are only enabled only WiFi-capable ports (ESP8266, nRF) -because they are typically used for network software: -``binascii``, ``hashlib``, ``uheapq``, ``uselect``, ``ussl``. -Not all of these are enabled on all WiFi-capable ports. +These libraries are not currently enabled in any CircuitPython build, but may be in the future, +with the ``u`` prefix dropped: +``uctypes`, ``uhashlib``, ``uio``, ``uzlib``. .. toctree:: :maxdepth: 1 @@ -44,13 +30,14 @@ Not all of these are enabled on all WiFi-capable ports. array.rst binascii.rst collections.rst + errno.rst gc.rst hashlib.rst + io.rst + json.rst + re.rst sys.rst - uerrno.rst - uio.rst - ujson.rst - ure.rst + uctypes.rst uselect.rst usocket.rst ussl.rst @@ -59,8 +46,8 @@ Not all of these are enabled on all WiFi-capable ports. Omitted functions in the ``string`` library ------------------------------------------- -A few string operations are not enabled on CircuitPython -M0 non-Express builds, due to limited flash memory: +A few string operations are not enabled on small builds +(usually non-Express), due to limited flash memory: ``string.center()``, ``string.partition()``, ``string.splitlines()``, ``string.reversed()``. @@ -78,15 +65,3 @@ versions of CircuitPython. btree.rst framebuf.rst micropython.rst - network.rst - uctypes.rst - -Libraries specific to the ESP8266 ---------------------------------- - -The following libraries are specific to the ESP8266. - -.. toctree:: - :maxdepth: 2 - - esp.rst diff --git a/docs/library/uio.rst b/docs/library/io.rst similarity index 97% rename from docs/library/uio.rst rename to docs/library/io.rst index d1f7c111fa..37e3eb7c94 100644 --- a/docs/library/uio.rst +++ b/docs/library/io.rst @@ -1,9 +1,7 @@ -:mod:`uio` -- input/output streams +:mod:`io` -- input/output streams ================================== -.. include:: ../templates/unsupported_in_circuitpython.inc - -.. module:: uio +.. module:: io :synopsis: input/output streams |see_cpython_module| :mod:`cpython:io`. diff --git a/docs/library/ujson.rst b/docs/library/json.rst similarity index 87% rename from docs/library/ujson.rst rename to docs/library/json.rst index 4ed91f053a..21574e556b 100644 --- a/docs/library/ujson.rst +++ b/docs/library/json.rst @@ -1,9 +1,7 @@ -:mod:`ujson` -- JSON encoding and decoding +:mod:`json` -- JSON encoding and decoding ========================================== -.. include:: ../templates/unsupported_in_circuitpython.inc - -.. module:: ujson +.. module:: json :synopsis: JSON encoding and decoding |see_cpython_module| :mod:`cpython:json`. diff --git a/docs/library/ure.rst b/docs/library/re.rst similarity index 94% rename from docs/library/ure.rst rename to docs/library/re.rst index 4af182b016..bdcc9f52c1 100644 --- a/docs/library/ure.rst +++ b/docs/library/re.rst @@ -1,9 +1,7 @@ -:mod:`ure` -- simple regular expressions +:mod:`re` -- simple regular expressions ======================================== -.. include:: ../templates/unsupported_in_circuitpython.inc - -.. module:: ure +.. module:: re :synopsis: regular expressions |see_cpython_module| :mod:`cpython:re`. @@ -77,7 +75,7 @@ Regex objects ------------- Compiled regular expression. Instances of this class are created using -`ure.compile()`. +`re.compile()`. .. method:: regex.match(string) regex.search(string) diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index f38c0b64a0..ca6ddd3ed7 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -30,7 +30,7 @@ import sys from concurrent.futures import ThreadPoolExecutor -SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'stm'] +SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'raspberrypi', 'stm'] def get_circuitpython_root_dir(): """ The path to the root './circuitpython' directory @@ -44,7 +44,7 @@ def get_shared_bindings(): """ Get a list of modules in shared-bindings based on folder names """ shared_bindings_dir = get_circuitpython_root_dir() / "shared-bindings" - return [item.name for item in shared_bindings_dir.iterdir()] + ["ulab"] + return [item.name for item in shared_bindings_dir.iterdir()] + ["binascii", "errno", "json", "re", "ulab"] def read_mpconfig(): diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index 4b0c324faa..fc189e6627 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -44,4 +44,5 @@ #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 -#define MICROPY_PY_URE 0 +// Can't fit. +#define CIRCUITPY_RE 0 diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index bce89e0b99..d2a529485e 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -45,11 +45,7 @@ #define MICROPY_PY_BUILTINS_COMPLEX (0) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_FUNCTION_ATTRS (0) -// MICROPY_PY_UJSON depends on MICROPY_PY_IO -#define MICROPY_PY_IO (0) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) -#define MICROPY_PY_UBINASCII (0) -#define MICROPY_PY_UJSON (0) #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) #define MICROPY_PY_UERRNO_LIST \ X(EPERM) \ @@ -84,9 +80,6 @@ #define SPI_FLASH_MAX_BAUDRATE 24000000 #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) #define MICROPY_PY_FUNCTION_ATTRS (1) -// MICROPY_PY_UJSON depends on MICROPY_PY_IO -#define MICROPY_PY_IO (1) -#define MICROPY_PY_UJSON (1) // MICROPY_PY_UERRNO_LIST - Use the default #endif // SAM_D5X_E5X diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 17e3995bf5..fb9cdf2e66 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -20,26 +20,16 @@ endif # Put samd21-only choices here. ifeq ($(CHIP_FAMILY),samd21) -# frequencyio not yet verified as working on SAMD21, though make it possible to override. -ifndef CIRCUITPY_AUDIOMIXER -CIRCUITPY_AUDIOMIXER = 0 -endif -ifndef CIRCUITPY_AUDIOMP3 -CIRCUITPY_AUDIOMP3 = 0 -endif +# The ?='s allow overriding in mpconfigboard.mk. -ifndef CIRCUITPY_BUILTINS_POW3 -CIRCUITPY_BUILTINS_POW3 = 0 -endif - -ifndef CIRCUITPY_FREQUENCYIO -CIRCUITPY_FREQUENCYIO = 0 -endif - -ifndef CIRCUITPY_TOUCHIO_USE_NATIVE -CIRCUITPY_TOUCHIO_USE_NATIVE = 1 -endif +CIRCUITPY_AUDIOMIXER ?= 0 +CIRCUITPY_BINASCII ?= 0 +CIRCUITPY_AUDIOMP3 ?= 0 +CIRCUITPY_BUILTINS_POW3 ?= 0 +CIRCUITPY_FREQUENCYIO ?= 0 +CIRCUITPY_JSON ?= 0 +CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1 # No room for HCI _bleio on SAMD21. CIRCUITPY_BLEIO_HCI = 0 @@ -71,27 +61,13 @@ ifeq ($(CHIP_FAMILY),samd51) # No native touchio on SAMD51. CIRCUITPY_TOUCHIO_USE_NATIVE = 0 -# The ifndef's allow overriding in mpconfigboard.mk. +# The ?='s allow overriding in mpconfigboard.mk. -ifndef CIRCUITPY_NETWORK -CIRCUITPY_NETWORK = 0 -endif - -ifndef CIRCUITPY_PS2IO -CIRCUITPY_PS2IO = 1 -endif - -ifndef CIRCUITPY_SAMD -CIRCUITPY_SAMD = 1 -endif - -ifndef CIRCUITPY_RGBMATRIX -CIRCUITPY_RGBMATRIX = $(CIRCUITPY_FULL_BUILD) -endif - -ifndef CIRCUITPY_FRAMEBUFFERIO -CIRCUITPY_FRAMEBUFFERIO = $(CIRCUITPY_FULL_BUILD) -endif +CIRCUITPY_NETWORK ?= 0 +CIRCUITPY_PS2IO ?= 1 +CIRCUITPY_SAMD ?= 1 +CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) endif # samd51 diff --git a/ports/esp32s2/mpconfigport.h b/ports/esp32s2/mpconfigport.h index 9c0fd9da3e..0cf695bc98 100644 --- a/ports/esp32s2/mpconfigport.h +++ b/ports/esp32s2/mpconfigport.h @@ -30,7 +30,6 @@ #define MICROPY_NLR_THUMB (0) -#define MICROPY_PY_UJSON (1) #define MICROPY_USE_INTERNAL_PRINTF (0) #define MICROPY_PY_SYS_PLATFORM "Espressif ESP32-S2" diff --git a/ports/litex/mpconfigport.h b/ports/litex/mpconfigport.h index a7caf8526c..5f739e49ea 100644 --- a/ports/litex/mpconfigport.h +++ b/ports/litex/mpconfigport.h @@ -31,8 +31,6 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (0) #define MICROPY_NLR_THUMB (0) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) -#define MICROPY_PY_UBINASCII (1) -#define MICROPY_PY_UJSON (1) #include "py/circuitpy_mpconfig.h" diff --git a/ports/mimxrt10xx/mpconfigport.h b/ports/mimxrt10xx/mpconfigport.h index 7496256d03..51e0ef9ff5 100644 --- a/ports/mimxrt10xx/mpconfigport.h +++ b/ports/mimxrt10xx/mpconfigport.h @@ -41,8 +41,6 @@ extern uint8_t _ld_default_stack_size; #define CIRCUITPY_DEFAULT_STACK_SIZE ((uint32_t) &_ld_default_stack_size) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) #define MICROPY_PY_FUNCTION_ATTRS (0) -#define MICROPY_PY_IO (1) -#define MICROPY_PY_UJSON (1) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 4ed42cd829..3ac41a5e47 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -35,11 +35,8 @@ #include "peripherals/nrf/nvm.h" // for FLASH_PAGE_SIZE #define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_IO (1) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) #define MICROPY_PY_SYS_STDIO_BUFFER (1) -#define MICROPY_PY_UBINASCII (1) -#define MICROPY_PY_UJSON (1) // 24kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024) diff --git a/ports/raspberrypi/mpconfigport.h b/ports/raspberrypi/mpconfigport.h index 3fdc8febbf..75cbd1ba85 100644 --- a/ports/raspberrypi/mpconfigport.h +++ b/ports/raspberrypi/mpconfigport.h @@ -27,7 +27,9 @@ #ifndef __INCLUDED_MPCONFIGPORT_H #define __INCLUDED_MPCONFIGPORT_H -#define MICROPY_PY_UJSON (1) +#define CIRCUITPY_BINASCII (1) +#define CIRCUITPY_ERRNO (1) +#define CIRCUITPY_JSON (1) #define CIRCUITPY_INTERNAL_NVM_SIZE 0 diff --git a/ports/stm/mpconfigport.h b/ports/stm/mpconfigport.h index 9489b47657..7cdab04f62 100644 --- a/ports/stm/mpconfigport.h +++ b/ports/stm/mpconfigport.h @@ -31,9 +31,7 @@ #include #define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_IO (1) #define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) -#define MICROPY_PY_UJSON (1) extern uint8_t _ld_default_stack_size; diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 35f1227a9e..c193e61c49 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -195,21 +195,14 @@ typedef long mp_off_t; #define MICROPY_PY_BUILTINS_STR_CENTER (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_PARTITION (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_SPLITLINES (CIRCUITPY_FULL_BUILD) -#define MICROPY_PY_UERRNO (CIRCUITPY_FULL_BUILD) #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (CIRCUITPY_FULL_BUILD) #endif -#ifndef MICROPY_PY_UBINASCII -#define MICROPY_PY_UBINASCII (CIRCUITPY_FULL_BUILD) -#endif // Opposite setting is deliberate. -#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_FULL_BUILD) -#ifndef MICROPY_PY_URE -#define MICROPY_PY_URE (CIRCUITPY_FULL_BUILD) -#endif -#define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_FULL_BUILD) -#define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_FULL_BUILD) -#define MICROPY_PY_URE_SUB (CIRCUITPY_FULL_BUILD) +#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_RE) +#define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_RE) +#define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_RE) +#define MICROPY_PY_URE_SUB (CIRCUITPY_RE) // LONGINT_IMPL_xxx are defined in the Makefile. // @@ -301,6 +294,13 @@ extern const struct _mp_obj_module_t audiopwmio_module; #define AUDIOPWMIO_MODULE #endif +#if CIRCUITPY_BINASCII +#define MICROPY_PY_UBINASCII CIRCUITPY_BINASCII +#define BINASCII_MODULE { MP_ROM_QSTR(MP_QSTR_binascii), MP_ROM_PTR(&mp_module_ubinascii) }, +#else +#define BINASCII_MODULE +#endif + #if CIRCUITPY_BITBANGIO #define BITBANGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_bitbangio), (mp_obj_t)&bitbangio_module }, extern const struct _mp_obj_module_t bitbangio_module; @@ -399,6 +399,13 @@ extern const struct _mp_obj_module_t terminalio_module; #define TERMINALIO_MODULE #endif +#if CIRCUITPY_ERRNO +#define MICROPY_PY_UERRNO (1) +#define ERRNO_MODULE { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, +#else +#define ERRNO_MODULE +#endif + #if CIRCUITPY_ESPIDF extern const struct _mp_obj_module_t espidf_module; #define ESPIDF_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_espidf),(mp_obj_t)&espidf_module }, @@ -470,6 +477,18 @@ extern const struct _mp_obj_module_t ipaddress_module; #define IPADDRESS_MODULE #endif +#if CIRCUITPY_JSON +#define MICROPY_PY_UJSON (1) +#define MICROPY_PY_IO (1) +#define JSON_MODULE { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, +#else +#ifndef MICROPY_PY_IO +// We don't need MICROPY_PY_IO unless someone else wants it. +#define MICROPY_PY_IO (0) +#endif +#define JSON_MODULE +#endif + #if CIRCUITPY_MATH extern const struct _mp_obj_module_t math_module; #define MATH_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module }, @@ -588,6 +607,13 @@ extern const struct _mp_obj_module_t random_module; #define RANDOM_MODULE #endif +#if CIRCUITPY_RE +#define MICROPY_PY_URE (1) +#define RE_MODULE { MP_ROM_QSTR(MP_QSTR_re), MP_ROM_PTR(&mp_module_ure) }, +#else +#define RE_MODULE +#endif + #if CIRCUITPY_RGBMATRIX extern const struct _mp_obj_module_t rgbmatrix_module; #define RGBMATRIX_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_rgbmatrix),(mp_obj_t)&rgbmatrix_module }, @@ -730,25 +756,6 @@ extern const struct _mp_obj_module_t ustack_module; #define USTACK_MODULE #endif -// These modules are not yet in shared-bindings, but we prefer the non-uxxx names. -#if MICROPY_PY_UBINASCII -#define BINASCII_MODULE { MP_ROM_QSTR(MP_QSTR_binascii), MP_ROM_PTR(&mp_module_ubinascii) }, -#else -#define BINASCII_MODULE -#endif - -#if MICROPY_PY_UERRNO -#define ERRNO_MODULE { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, -#else -#define ERRNO_MODULE -#endif - -#if MICROPY_PY_UJSON -#define JSON_MODULE { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, -#else -#define JSON_MODULE -#endif - #if defined(CIRCUITPY_ULAB) && CIRCUITPY_ULAB // ulab requires reverse special methods #if defined(MICROPY_PY_REVERSE_SPECIAL_METHODS) && !MICROPY_PY_REVERSE_SPECIAL_METHODS @@ -760,12 +767,6 @@ extern const struct _mp_obj_module_t ustack_module; #define ULAB_MODULE #endif -#if MICROPY_PY_URE -#define RE_MODULE { MP_ROM_QSTR(MP_QSTR_re), MP_ROM_PTR(&mp_module_ure) }, -#else -#define RE_MODULE -#endif - // This is not a top-level module; it's microcontroller.watchdog. #if CIRCUITPY_WATCHDOG extern const struct _mp_obj_module_t watchdog_module; diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 9c9b17f4b7..141ad05f82 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -86,6 +86,9 @@ endif endif CFLAGS += -DCIRCUITPY_AUDIOMP3=$(CIRCUITPY_AUDIOMP3) +CIRCUITPY_BINASCII ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_BINASCII=$(CIRCUITPY_BINASCII) + CIRCUITPY_BITBANGIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_BITBANGIO=$(CIRCUITPY_BITBANGIO) @@ -124,6 +127,9 @@ CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO) +CIRCUITPY_ERRNO ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_ERRNO=$(CIRCUITPY_ERRNO) + # CIRCUITPY_ESPIDF is handled in the esp32s2 tree. # Only for ESP32S chips. # Assume not a ESP build. @@ -158,6 +164,9 @@ CFLAGS += -DCIRCUITPY_I2CPERIPHERAL=$(CIRCUITPY_I2CPERIPHERAL) CIRCUITPY_IPADDRESS ?= $(CIRCUITPY_WIFI) CFLAGS += -DCIRCUITPY_IPADDRESS=$(CIRCUITPY_IPADDRESS) +CIRCUITPY_JSON ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_JSON=$(CIRCUITPY_JSON) + CIRCUITPY_MATH ?= 1 CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH) @@ -204,6 +213,9 @@ CFLAGS += -DCIRCUITPY_PWMIO=$(CIRCUITPY_PWMIO) CIRCUITPY_RANDOM ?= 1 CFLAGS += -DCIRCUITPY_RANDOM=$(CIRCUITPY_RANDOM) +CIRCUITPY_RE ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_RE=$(CIRCUITPY_RE) + # CIRCUITPY_RP2PIO is handled in the raspberrypi tree. # Only for rp2 chips. # Assume not a rp2 build. diff --git a/shared-bindings/support_matrix.rst b/shared-bindings/support_matrix.rst index 1b75e02567..a2fb7987d2 100644 --- a/shared-bindings/support_matrix.rst +++ b/shared-bindings/support_matrix.rst @@ -1,7 +1,7 @@ .. _module-support-matrix: -Support Matrix -=============== +Module Support Matrix - Which Modules Are Available on Which Boards +=================================================================== The following table lists the available built-in modules for each CircuitPython capable board. From 34d63debd5c339a37009b961b9b51defcdf540ae Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 25 Jan 2021 08:21:55 -0500 Subject: [PATCH 13/53] Remove obsolete esp.rst, network.rst --- docs/library/esp.rst | 85 ------------ docs/library/network.rst | 278 --------------------------------------- 2 files changed, 363 deletions(-) delete mode 100644 docs/library/esp.rst delete mode 100644 docs/library/network.rst diff --git a/docs/library/esp.rst b/docs/library/esp.rst deleted file mode 100644 index 125aaa890f..0000000000 --- a/docs/library/esp.rst +++ /dev/null @@ -1,85 +0,0 @@ -:mod:`esp` --- functions related to the ESP8266 -=============================================== - -.. include:: ../templates/unsupported_in_circuitpython.inc - -.. module:: esp - :synopsis: functions related to the ESP8266 - -The ``esp`` module contains specific functions related to the ESP8266 module. - - -Functions ---------- - -.. function:: sleep_type([sleep_type]) - - Get or set the sleep type. - - If the *sleep_type* parameter is provided, sets the sleep type to its - value. If the function is called without parameters, returns the current - sleep type. - - The possible sleep types are defined as constants: - - * ``SLEEP_NONE`` -- all functions enabled, - * ``SLEEP_MODEM`` -- modem sleep, shuts down the WiFi Modem circuit. - * ``SLEEP_LIGHT`` -- light sleep, shuts down the WiFi Modem circuit - and suspends the processor periodically. - - The system enters the set sleep mode automatically when possible. - -.. function:: deepsleep(time=0) - - Enter deep sleep. - - The whole module powers down, except for the RTC clock circuit, which can - be used to restart the module after the specified time if the pin 16 is - connected to the reset pin. Otherwise the module will sleep until manually - reset. - -.. function:: flash_id() - - Read the device ID of the flash memory. - -.. function:: flash_read(byte_offset, length_or_buffer) - -.. function:: flash_write(byte_offset, bytes) - -.. function:: flash_erase(sector_no) - -.. function:: set_native_code_location(start, length) - - Set the location that native code will be placed for execution after it is - compiled. Native code is emitted when the ``@micropython.native``, - ``@micropython.viper`` and ``@micropython.asm_xtensa`` decorators are applied - to a function. The ESP8266 must execute code from either iRAM or the lower - 1MByte of flash (which is memory mapped), and this function controls the - location. - - If *start* and *length* are both ``None`` then the native code location is - set to the unused portion of memory at the end of the iRAM1 region. The - size of this unused portion depends on the firmware and is typically quite - small (around 500 bytes), and is enough to store a few very small - functions. The advantage of using this iRAM1 region is that it does not - get worn out by writing to it. - - If neither *start* nor *length* are ``None`` then they should be integers. - *start* should specify the byte offset from the beginning of the flash at - which native code should be stored. *length* specifies how many bytes of - flash from *start* can be used to store native code. *start* and *length* - should be multiples of the sector size (being 4096 bytes). The flash will - be automatically erased before writing to it so be sure to use a region of - flash that is not otherwise used, for example by the firmware or the - filesystem. - - When using the flash to store native code *start+length* must be less - than or equal to 1MByte. Note that the flash can be worn out if repeated - erasures (and writes) are made so use this feature sparingly. - In particular, native code needs to be recompiled and rewritten to flash - on each boot (including wake from deepsleep). - - In both cases above, using iRAM1 or flash, if there is no more room left - in the specified region then the use of a native decorator on a function - will lead to `MemoryError` exception being raised during compilation of - that function. diff --git a/docs/library/network.rst b/docs/library/network.rst deleted file mode 100644 index 3bd41150d5..0000000000 --- a/docs/library/network.rst +++ /dev/null @@ -1,278 +0,0 @@ -**************************************** -:mod:`network` --- network configuration -**************************************** - -.. include:: ../templates/unsupported_in_circuitpython.inc - -.. module:: network - :noindex: - :synopsis: network configuration - -This module provides network drivers and routing configuration. To use this -module, a MicroPython variant/build with network capabilities must be installed. -Network drivers for specific hardware are available within this module and are -used to configure hardware network interface(s). Network services provided -by configured interfaces are then available for use via the :mod:`usocket` -module. - -For example:: - - # connect/ show IP config a specific network interface - # see below for examples of specific drivers - import network - import utime - nic = network.Driver(...) - if not nic.isconnected(): - nic.connect() - print("Waiting for connection...") - while not nic.isconnected(): - utime.sleep(1) - print(nic.ifconfig()) - - # now use usocket as usual - import usocket as socket - addr = socket.getaddrinfo('micropython.org', 80)[0][-1] - s = socket.socket() - s.connect(addr) - s.send(b'GET / HTTP/1.1\r\nHost: micropython.org\r\n\r\n') - data = s.recv(1000) - s.close() - -Common network adapter interface -================================ - -This section describes an (implied) abstract base class for all network -interface classes implemented by ``MicroPython ports `` -for different hardware. This means that MicroPython does not actually -provide ``AbstractNIC`` class, but any actual NIC class, as described -in the following sections, implements methods as described here. - -.. class:: AbstractNIC(id=None, ...) - -Instantiate a network interface object. Parameters are network interface -dependent. If there are more than one interface of the same type, the first -parameter should be `id`. - - .. method:: active([is_active]) - - Activate ("up") or deactivate ("down") the network interface, if - a boolean argument is passed. Otherwise, query current state if - no argument is provided. Most other methods require an active - interface (behavior of calling them on inactive interface is - undefined). - - .. method:: connect([service_id, key=None, \*, ...]) - - Connect the interface to a network. This method is optional, and - available only for interfaces which are not "always connected". - If no parameters are given, connect to the default (or the only) - service. If a single parameter is given, it is the primary identifier - of a service to connect to. It may be accompanied by a key - (password) required to access said service. There can be further - arbitrary keyword-only parameters, depending on the networking medium - type and/or particular device. Parameters can be used to: a) - specify alternative service identifier types; b) provide additional - connection parameters. For various medium types, there are different - sets of predefined/recommended parameters, among them: - - * WiFi: *bssid* keyword to connect to a specific BSSID (MAC address) - - .. method:: disconnect() - - Disconnect from network. - - .. method:: isconnected() - - Returns ``True`` if connected to network, otherwise returns ``False``. - - .. method:: scan(\*, ...) - - Scan for the available network services/connections. Returns a - list of tuples with discovered service parameters. For various - network media, there are different variants of predefined/ - recommended tuple formats, among them: - - * WiFi: (ssid, bssid, channel, RSSI, authmode, hidden). There - may be further fields, specific to a particular device. - - The function may accept additional keyword arguments to filter scan - results (e.g. scan for a particular service, on a particular channel, - for services of a particular set, etc.), and to affect scan - duration and other parameters. Where possible, parameter names - should match those in connect(). - - .. method:: status() - - Return detailed status of the interface, values are dependent - on the network medium/technology. - - .. method:: ifconfig([(ip, subnet, gateway, dns)]) - - Get/set IP-level network interface parameters: IP address, subnet mask, - gateway and DNS server. When called with no arguments, this method returns - a 4-tuple with the above information. To set the above values, pass a - 4-tuple with the required information. For example:: - - nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) - - .. method:: config('param') - config(param=value, ...) - - Get or set general network interface parameters. These methods allow to work - with additional parameters beyond standard IP configuration (as dealt with by - `ifconfig()`). These include network-specific and hardware-specific - parameters and status values. For setting parameters, the keyword argument - syntax should be used, and multiple parameters can be set at once. For - querying, a parameter name should be quoted as a string, and only one - parameter can be queried at a time:: - - # Set WiFi access point name (formally known as ESSID) and WiFi channel - ap.config(essid='My AP', channel=11) - # Query params one by one - print(ap.config('essid')) - print(ap.config('channel')) - # Extended status information also available this way - print(sta.config('rssi')) - -.. _network.WLAN: - -Functions -========= - -.. function:: phy_mode([mode]) - - Get or set the PHY mode. - - If the *mode* parameter is provided, sets the mode to its value. If - the function is called without parameters, returns the current mode. - - The possible modes are defined as constants: - * ``MODE_11B`` -- IEEE 802.11b, - * ``MODE_11G`` -- IEEE 802.11g, - * ``MODE_11N`` -- IEEE 802.11n. - -class WLAN -========== - -This class provides a driver for WiFi network processor in the ESP8266. Example usage:: - - import network - # enable station interface and connect to WiFi access point - nic = network.WLAN(network.STA_IF) - nic.active(True) - nic.connect('your-ssid', 'your-password') - # now use sockets as usual - -Constructors ------------- -.. class:: WLAN(interface_id) - -Create a WLAN network interface object. Supported interfaces are -``network.STA_IF`` (station aka client, connects to upstream WiFi access -points) and ``network.AP_IF`` (access point, allows other WiFi clients to -connect). Availability of the methods below depends on interface type. -For example, only STA interface may `connect()` to an access point. - -Methods -------- - -.. method:: wlan.active([is_active]) - - Activate ("up") or deactivate ("down") network interface, if boolean - argument is passed. Otherwise, query current state if no argument is - provided. Most other methods require active interface. - -.. method:: wlan.connect(ssid=None, password=None, \*, bssid=None) - - Connect to the specified wireless network, using the specified password. - If *bssid* is given then the connection will be restricted to the - access-point with that MAC address (the *ssid* must also be specified - in this case). - -.. method:: wlan.disconnect() - - Disconnect from the currently connected wireless network. - -.. method:: wlan.scan() - - Scan for the available wireless networks. - - Scanning is only possible on STA interface. Returns list of tuples with - the information about WiFi access points: - - (ssid, bssid, channel, RSSI, authmode, hidden) - - *bssid* is hardware address of an access point, in binary form, returned as - bytes object. You can use `binascii.hexlify()` to convert it to ASCII form. - - There are five values for authmode: - - * 0 -- open - * 1 -- WEP - * 2 -- WPA-PSK - * 3 -- WPA2-PSK - * 4 -- WPA/WPA2-PSK - - and two for hidden: - - * 0 -- visible - * 1 -- hidden - -.. method:: wlan.status() - - Return the current status of the wireless connection. - - The possible statuses are defined as constants: - - * ``STAT_IDLE`` -- no connection and no activity, - * ``STAT_CONNECTING`` -- connecting in progress, - * ``STAT_WRONG_PASSWORD`` -- failed due to incorrect password, - * ``STAT_NO_AP_FOUND`` -- failed because no access point replied, - * ``STAT_CONNECT_FAIL`` -- failed due to other problems, - * ``STAT_GOT_IP`` -- connection successful. - -.. method:: wlan.isconnected() - - In case of STA mode, returns ``True`` if connected to a WiFi access - point and has a valid IP address. In AP mode returns ``True`` when a - station is connected. Returns ``False`` otherwise. - -.. method:: wlan.ifconfig([(ip, subnet, gateway, dns)]) - - Get/set IP-level network interface parameters: IP address, subnet mask, - gateway and DNS server. When called with no arguments, this method returns - a 4-tuple with the above information. To set the above values, pass a - 4-tuple with the required information. For example:: - - nic.ifconfig(('192.168.0.4', '255.255.255.0', '192.168.0.1', '8.8.8.8')) - -.. method:: wlan.config('param') - wlan.config(param=value, ...) - - Get or set general network interface parameters. These methods allow to work - with additional parameters beyond standard IP configuration (as dealt with by - `wlan.ifconfig()`). These include network-specific and hardware-specific - parameters. For setting parameters, keyword argument syntax should be used, - multiple parameters can be set at once. For querying, parameters name should - be quoted as a string, and only one parameter can be queries at time:: - - # Set WiFi access point name (formally known as ESSID) and WiFi channel - ap.config(essid='My AP', channel=11) - # Query params one by one - print(ap.config('essid')) - print(ap.config('channel')) - - Following are commonly supported parameters (availability of a specific parameter - depends on network technology type, driver, and ``MicroPython port``). - - ============= =========== - Parameter Description - ============= =========== - mac MAC address (bytes) - essid WiFi access point name (string) - channel WiFi channel (integer) - hidden Whether ESSID is hidden (boolean) - authmode Authentication mode supported (enumeration, see module constants) - password Access password (string) - dhcp_hostname The DHCP hostname to use - ============= =========== From 1e97d384ff469731832147f7dc07aa1f358cd572 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 25 Jan 2021 11:02:32 -0500 Subject: [PATCH 14/53] add GP15 --- ports/raspberrypi/boards/raspberry_pi_pico/pins.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/raspberrypi/boards/raspberry_pi_pico/pins.c b/ports/raspberrypi/boards/raspberry_pi_pico/pins.c index 38ec75c4ad..913676ad26 100644 --- a/ports/raspberrypi/boards/raspberry_pi_pico/pins.c +++ b/ports/raspberrypi/boards/raspberry_pi_pico/pins.c @@ -16,6 +16,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) }, { MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, { MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) }, { MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) }, From 69c71bd52238bda5c021a825849ce28229a33e0f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 25 Jan 2021 11:54:10 -0500 Subject: [PATCH 15/53] fix some build errors --- .../circuitplayground_express_displayio/mpconfigboard.h | 3 --- .../circuitplayground_express_displayio/mpconfigboard.mk | 1 + ports/raspberrypi/mpconfigport.h | 4 ---- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index fc189e6627..1586a32890 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -43,6 +43,3 @@ // USB is always used internally so skip the pin objects for it. #define IGNORE_PIN_PA24 1 #define IGNORE_PIN_PA25 1 - -// Can't fit. -#define CIRCUITPY_RE 0 diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index 51e9b05af2..d3ce35f6d9 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -18,6 +18,7 @@ CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 CIRCUITPY_MSGPACK = 0 CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_RE = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 # So not all of displayio, sorry! diff --git a/ports/raspberrypi/mpconfigport.h b/ports/raspberrypi/mpconfigport.h index 75cbd1ba85..7431519317 100644 --- a/ports/raspberrypi/mpconfigport.h +++ b/ports/raspberrypi/mpconfigport.h @@ -27,10 +27,6 @@ #ifndef __INCLUDED_MPCONFIGPORT_H #define __INCLUDED_MPCONFIGPORT_H -#define CIRCUITPY_BINASCII (1) -#define CIRCUITPY_ERRNO (1) -#define CIRCUITPY_JSON (1) - #define CIRCUITPY_INTERNAL_NVM_SIZE 0 #define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024) From c5992a3101bc7f4d94ac52934b8ca63148f193eb Mon Sep 17 00:00:00 2001 From: Kamil Tomaszewski Date: Mon, 25 Jan 2021 17:59:40 +0100 Subject: [PATCH 16/53] spresense: update Spresense SDK to 2.0.2 --- ports/cxd56/README.md | 2 +- ports/cxd56/configs/circuitpython/defconfig | 1 + ports/cxd56/spresense-exported-sdk | 2 +- ports/cxd56/supervisor/internal_flash.c | 16 ++++++++-------- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ports/cxd56/README.md b/ports/cxd56/README.md index 7fa439aacb..c399b8a4d7 100644 --- a/ports/cxd56/README.md +++ b/ports/cxd56/README.md @@ -75,7 +75,7 @@ Bootloader information: * You have to accept the End User License Agreement to be able to download and use the Spresense bootloader binary. -Download the spresense binaries zip archive from: [Spresense firmware v2-0-000](https://developer.sony.com/file/download/download-spresense-firmware-v2-0-000) +Download the spresense binaries zip archive from: [Spresense firmware v2-0-002](https://developer.sony.com/file/download/download-spresense-firmware-v2-0-002) Extract spresense binaries in your PC to ports/spresense/spresense-exported-sdk/firmware/ diff --git a/ports/cxd56/configs/circuitpython/defconfig b/ports/cxd56/configs/circuitpython/defconfig index a97f821dfa..096b53b800 100644 --- a/ports/cxd56/configs/circuitpython/defconfig +++ b/ports/cxd56/configs/circuitpython/defconfig @@ -165,6 +165,7 @@ CONFIG_USBDEV=y CONFIG_USBDEV_DMA=y CONFIG_USBDEV_DUALSPEED=y CONFIG_USEC_PER_TICK=1000 +CONFIG_USERMAIN_STACKSIZE=8192 CONFIG_USER_ENTRYPOINT="spresense_main" CONFIG_VIDEO_ISX012=y CONFIG_VIDEO_STREAM=y diff --git a/ports/cxd56/spresense-exported-sdk b/ports/cxd56/spresense-exported-sdk index 752c4cd56d..2ec2a15383 160000 --- a/ports/cxd56/spresense-exported-sdk +++ b/ports/cxd56/spresense-exported-sdk @@ -1 +1 @@ -Subproject commit 752c4cd56dd0a270a559c28272ceb61ddcb7806c +Subproject commit 2ec2a1538362696118dc3fdf56f33dacaf8f4067 diff --git a/ports/cxd56/supervisor/internal_flash.c b/ports/cxd56/supervisor/internal_flash.c index 2726fa4a23..9c103fb19e 100644 --- a/ports/cxd56/supervisor/internal_flash.c +++ b/ports/cxd56/supervisor/internal_flash.c @@ -30,10 +30,10 @@ /* Prototypes for Remote API */ -int FM_RawWrite(uint32_t offset, const void *buf, uint32_t size); -int FM_RawVerifyWrite(uint32_t offset, const void *buf, uint32_t size); -int FM_RawRead(uint32_t offset, void *buf, uint32_t size); -int FM_RawEraseSector(uint32_t sector); +int fw_fm_rawwrite(uint32_t offset, const void *buf, uint32_t size); +int fw_fm_rawverifywrite(uint32_t offset, const void *buf, uint32_t size); +int fw_fm_rawread(uint32_t offset, void *buf, uint32_t size); +int fw_fm_rawerasesector(uint32_t sector); #define CXD56_SPIFLASHSIZE (16 * 1024 * 1024) @@ -64,8 +64,8 @@ void port_internal_flash_flush(void) { return; } - FM_RawEraseSector(flash_sector); - FM_RawWrite(flash_sector << SECTOR_SHIFT, flash_cache, SECTOR_SIZE); + fw_fm_rawerasesector(flash_sector); + fw_fm_rawwrite(flash_sector << SECTOR_SHIFT, flash_cache, SECTOR_SIZE); flash_sector = NO_SECTOR; } @@ -73,7 +73,7 @@ void port_internal_flash_flush(void) { mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { supervisor_flash_flush(); - if (FM_RawRead(block << PAGE_SHIFT, dest, num_blocks << PAGE_SHIFT) < 0) { + if (fw_fm_rawread(block << PAGE_SHIFT, dest, num_blocks << PAGE_SHIFT) < 0) { return 1; } @@ -92,7 +92,7 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32 if (sector != flash_sector) { supervisor_flash_flush(); - if (FM_RawRead(sector << SECTOR_SHIFT, flash_cache, SECTOR_SIZE) < 0) { + if (fw_fm_rawread(sector << SECTOR_SHIFT, flash_cache, SECTOR_SIZE) < 0) { return 1; } From 30a1c52e757622969dedf03c988c59a35b4a1302 Mon Sep 17 00:00:00 2001 From: Kamil Tomaszewski Date: Mon, 25 Jan 2021 18:05:48 +0100 Subject: [PATCH 17/53] Update TinyUSB --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 388abe9d9c..045674745a 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 388abe9d9cc0a7c360fd902e01461a53bb7b3f42 +Subproject commit 045674745afa59028fbeed6dac5cb5a9c4a6033e From d6c04e85d01b38eb8bd0371bf6ca997c39c2ae8c Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl Date: Sun, 24 Jan 2021 19:18:22 +0000 Subject: [PATCH 18/53] Translated using Weblate (Swedish) Currently translated at 100.0% (923 of 923 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/sv/ --- locale/sv.po | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/locale/sv.po b/locale/sv.po index 0fe05421be..c3b55d5a03 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-01-17 12:55+0000\n" +"PO-Revision-Date: 2021-01-25 19:32+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -52,7 +52,7 @@ msgstr " Fil \"%q\", rad %d" #: py/builtinhelp.c msgid " is of type %q\n" -msgstr "" +msgstr " är av typen %q\n" #: main.c msgid " output:\n" @@ -872,7 +872,7 @@ msgstr "Fel i regex" #: shared-bindings/socketpool/Socket.c msgid "Error: Failure to bind" -msgstr "" +msgstr "Fel: Bind misslyckades" #: py/enum.c shared-bindings/_bleio/__init__.c shared-bindings/aesio/aes.c #: shared-bindings/busio/SPI.c shared-bindings/microcontroller/Pin.c @@ -1268,7 +1268,7 @@ msgstr "Ogiltig storlek" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Invalid socket for TLS" -msgstr "" +msgstr "Ogiltig socket för TLS" #: ports/esp32s2/bindings/espidf/__init__.c ports/esp32s2/esp_error.c msgid "Invalid state" @@ -1276,7 +1276,7 @@ msgstr "Ogiltigt tillstånd" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Invalid use of TLS Socket" -msgstr "" +msgstr "Ogiltig användning av TLS Socket" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" @@ -1296,7 +1296,7 @@ msgstr "Ogiltig word-/bitlängd" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Issue setting SO_REUSEADDR" -msgstr "" +msgstr "Misslyckades att sätta SO_REUSEADDR" #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" @@ -3375,7 +3375,7 @@ msgstr "antal punkter måste vara minst 2" #: py/builtinhelp.c msgid "object " -msgstr "" +msgstr "objekt " #: py/obj.c msgid "object '%q' is not a tuple or list" @@ -3996,7 +3996,7 @@ msgstr "width måste vara större än noll" #: ports/esp32s2/common-hal/wifi/Radio.c msgid "wifi is not enabled" -msgstr "" +msgstr "wifi är inte aktiverat" #: shared-bindings/_bleio/Adapter.c msgid "window must be <= interval" From 2a55ff73b15242cc165d303552a5c21392a9a072 Mon Sep 17 00:00:00 2001 From: hexthat Date: Sat, 23 Jan 2021 20:58:17 +0000 Subject: [PATCH 19/53] Translated using Weblate (Chinese (Pinyin)) Currently translated at 100.0% (923 of 923 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/zh_Latn/ --- locale/zh_Latn_pinyin.po | 104 +++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 1d869a0f20..c2ff040449 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-01-21 22:25+0000\n" +"PO-Revision-Date: 2021-01-25 19:32+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -53,7 +53,7 @@ msgstr " Wénjiàn \"%q\", dì %d xíng" #: py/builtinhelp.c msgid " is of type %q\n" -msgstr "" +msgstr " shì %q lèi xíng\n" #: main.c msgid " output:\n" @@ -871,7 +871,7 @@ msgstr "Zhèngzé biǎodá shì cuòwù" #: shared-bindings/socketpool/Socket.c msgid "Error: Failure to bind" -msgstr "" +msgstr "cuò wù: bǎng dìng shī bài" #: py/enum.c shared-bindings/_bleio/__init__.c shared-bindings/aesio/aes.c #: shared-bindings/busio/SPI.c shared-bindings/microcontroller/Pin.c @@ -1267,7 +1267,7 @@ msgstr "dà xiǎo wú xiào" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Invalid socket for TLS" -msgstr "" +msgstr "TLS de chā zuò wú xiào" #: ports/esp32s2/bindings/espidf/__init__.c ports/esp32s2/esp_error.c msgid "Invalid state" @@ -1275,7 +1275,7 @@ msgstr "wú xiào zhuàng tài" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Invalid use of TLS Socket" -msgstr "" +msgstr "TLS tào jiē zì de wú xiào shǐ yòng" #: shared-bindings/audiomixer/Mixer.c msgid "Invalid voice" @@ -1295,7 +1295,7 @@ msgstr "Wúxiào de zì/wèi chángdù" #: ports/esp32s2/common-hal/socketpool/Socket.c msgid "Issue setting SO_REUSEADDR" -msgstr "" +msgstr "wèn tí shè zhì SO_REUSEADDR" #: shared-bindings/aesio/aes.c msgid "Key must be 16, 24, or 32 bytes long" @@ -2356,7 +2356,7 @@ msgstr "huǎnchōng qū bìxū shì zì jié lèi duìxiàng" #: extmod/ulab/code/ulab_create.c msgid "buffer size must be a multiple of element size" -msgstr "" +msgstr "huǎn chōng qū dà xiǎo bì xū shì yuán sù dà xiǎo de bèi shù" #: shared-module/struct/__init__.c msgid "buffer size must match format" @@ -2525,7 +2525,7 @@ msgstr "wúfǎ cóng shǒudòng zìduàn guīgé qiēhuàn dào zìdòng zìduà #: extmod/ulab/code/ndarray_operators.c msgid "cannot cast output with casting rule" -msgstr "" +msgstr "wú fǎ shǐ yòng qiáng zhì zhuǎn huàn guī zé qiáng zhì zhuǎn huàn shū chū" #: py/objtype.c msgid "cannot create '%q' instances" @@ -2565,7 +2565,7 @@ msgstr "quānzi zhǐ néng zài yī wèi jiāzhǎng zhōng zhùcè" #: shared-bindings/msgpack/ExtType.c msgid "code outside range 0~127" -msgstr "" +msgstr "dài mǎ chāo chū fàn wéi 0~127" #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" @@ -2632,7 +2632,7 @@ msgstr "wúfǎ quèdìng SD kǎ bǎnběn" #: extmod/ulab/code/numerical/numerical.c msgid "cross is defined for 1D arrays of length 3" -msgstr "" +msgstr "duì yú cháng dù wéi 3 de 1D shù zǔ dìng yì cross" #: extmod/ulab/code/approx/approx.c msgid "data must be iterable" @@ -2644,7 +2644,7 @@ msgstr "shùjù chángdù bìxū xiāngděng" #: extmod/ulab/code/ndarray.c msgid "data type not understood" -msgstr "" +msgstr "wèi lǐ jiě de shù jù lèi xíng" #: py/parsenum.c msgid "decimal numbers not supported" @@ -2656,7 +2656,7 @@ msgstr "mòrèn 'except' bìxū shì zuìhòu yīgè" #: shared-bindings/msgpack/__init__.c msgid "default is not a function" -msgstr "" +msgstr "mò rèn zhí bú shì hán shù" #: shared-bindings/audiobusio/PDMIn.c msgid "" @@ -2683,7 +2683,7 @@ msgstr "bùtóng de cānshù bìxū shì ndarray" #: extmod/ulab/code/numerical/numerical.c msgid "differentiation order out of range" -msgstr "" +msgstr "chā yì shùn xù fàn wéi" #: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c #: shared-bindings/math/__init__.c @@ -2716,7 +2716,7 @@ msgstr "jiéwěi_x yīnggāi shì yīgè zhěngshù" #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" -msgstr "" +msgstr "epoch_time bǎn bù zhī chí cǐ bǎn běn" #: ports/nrf/common-hal/busio/UART.c #, c-format @@ -2761,7 +2761,7 @@ msgstr "qídài guānjiàn: Zìdiǎn de jiàzhí" #: shared-bindings/msgpack/__init__.c msgid "ext_hook is not a function" -msgstr "" +msgstr "ext_hook bú shì hán shù" #: py/argcheck.c msgid "extra keyword arguments given" @@ -2810,7 +2810,7 @@ msgstr "dì yīgè cānshù bìxū shì yī gè hánshù" #: extmod/ulab/code/ulab_create.c msgid "first argument must be a tuple of ndarrays" -msgstr "" +msgstr "dì yī gè cān shù bì xū shì yí gè yuán zǔ ndarrays" #: extmod/ulab/code/ndarray.c msgid "first argument must be an iterable" @@ -2867,7 +2867,7 @@ msgstr "hánshù zài jiàngé mòwěi jùyǒu xiāngtóng de fúhào" #: extmod/ulab/code/ndarray.c msgid "function is defined for ndarrays only" -msgstr "" +msgstr "hán shù jǐn wéi ndarrays dìng yì" #: py/argcheck.c #, c-format @@ -2963,11 +2963,11 @@ msgstr "nèi lián jíhé bìxū shì yīgè hánshù" #: extmod/ulab/code/ndarray.c msgid "input and output shapes are not compatible" -msgstr "" +msgstr "shū rù hé shū chū xíng zhuàng bù jiān róng" #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer, a tuple, or a list" -msgstr "" +msgstr "shū rù cān shù bì xū shì zhěng shù, yuán zǔ huò liè biǎo" #: extmod/ulab/code/fft/fft.c msgid "input array length must be power of 2" @@ -2975,7 +2975,7 @@ msgstr "shūrù shùzǔ de chángdù bìxū shì 2 de mì" #: extmod/ulab/code/ulab_create.c msgid "input arrays are not compatible" -msgstr "" +msgstr "shū rù shù zǔ bù jiān róng" #: extmod/ulab/code/poly/poly.c msgid "input data must be an iterable" @@ -2991,19 +2991,19 @@ msgstr "shūrù jǔzhèn shì qíyì de" #: extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" -msgstr "" +msgstr "shū rù bì xū shì mì jí de ndarray" #: extmod/ulab/code/ulab_create.c msgid "input must be a tensor of rank 2" -msgstr "" +msgstr "shū rù bì xū shì děng jí 2 de zhāng liàng" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" -msgstr "" +msgstr "shū rù bì xū shì ndarray" #: extmod/ulab/code/filter/filter.c msgid "input must be one-dimensional" -msgstr "" +msgstr "shū rù bì xū shì yì wéi de" #: extmod/ulab/code/linalg/linalg.c msgid "input must be square matrix" @@ -3019,7 +3019,7 @@ msgstr "shūrù xiàngliàng de chángdù bìxū xiāngděng" #: extmod/ulab/code/poly/poly.c msgid "inputs are not iterable" -msgstr "" +msgstr "shū rù bù kě yí dòng" #: py/parsenum.c msgid "int() arg 2 must be >= 2 and <= 36" @@ -3093,7 +3093,7 @@ msgstr "wúxiào de hàomǎ yǔfǎ" #: ports/esp32s2/common-hal/alarm/pin/__init__.c msgid "io must be rtc io" -msgstr "" +msgstr "IO bì xū shì RTC IO" #: py/objtype.c msgid "issubclass() arg 1 must be a class" @@ -3192,11 +3192,11 @@ msgstr "Dāng gùdìng chángdù wèi %s shí, zuìdà chángdù bìxū wèi 0-% #: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c msgid "max_length must be >= 0" -msgstr "" +msgstr "zuì dà cháng dù bì xū >= 0" #: extmod/ulab/code/ndarray.c msgid "maximum number of dimensions is 4" -msgstr "" +msgstr "zuì dà chǐ cùn shù wéi 4" #: py/runtime.c msgid "maximum recursion depth exceeded" @@ -3212,7 +3212,7 @@ msgstr "maxiter yìng wéi > 0" #: extmod/ulab/code/numerical/numerical.c msgid "median argument must be an ndarray" -msgstr "" +msgstr "zhōng wèi shù cān shù bì xū shì ndarray" #: py/runtime.c #, c-format @@ -3298,7 +3298,7 @@ msgstr "zhǎo bù dào fēi běndì de bǎng dìng" #: shared-module/msgpack/__init__.c msgid "no default packer" -msgstr "" +msgstr "wú mò rèn bāo zhuāng jī" #: py/builtinimport.c msgid "no module named '%q'" @@ -3339,15 +3339,15 @@ msgstr "guānjiàn zì cānshù zhīhòu de fēi guānjiàn zì cānshù" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "non-zero timeout must be > 0.01" -msgstr "" +msgstr "fēi líng chāo shí bì xū > 0.01" #: shared-bindings/_bleio/Adapter.c msgid "non-zero timeout must be >= interval" -msgstr "" +msgstr "fēi líng chāo shí bì xū wéi >= jiàn gé" #: extmod/ulab/code/linalg/linalg.c msgid "norm is defined for 1D and 2D arrays" -msgstr "" +msgstr "wéi 1D hé 2D shù zǔ dìng yì guī fàn" #: shared-bindings/_bleio/UUID.c msgid "not a 128-bit UUID" @@ -3367,7 +3367,7 @@ msgstr "diǎnshù bìxū zhìshǎo wèi 2" #: py/builtinhelp.c msgid "object " -msgstr "" +msgstr "duì xiàng " #: py/obj.c msgid "object '%q' is not a tuple or list" @@ -3419,15 +3419,15 @@ msgstr "jīshù zìfú chuàn" #: extmod/ulab/code/ulab_create.c msgid "offset is too large" -msgstr "" +msgstr "piān yí tài dà" #: shared-bindings/dualbank/__init__.c msgid "offset must be >= 0" -msgstr "" +msgstr "piān yí liàng bì xū >= 0" #: extmod/ulab/code/ulab_create.c msgid "offset must be non-negative and no greater than buffer length" -msgstr "" +msgstr "piān yí liàng bì xū wéi fēi fù shù qiě bù dà yú huǎn chōng qū cháng dù" #: py/objstr.c py/objstrunicode.c msgid "offset out of bounds" @@ -3453,7 +3453,7 @@ msgstr "cāozuò shǔ bùnéng yīqǐ guǎngbò" #: extmod/ulab/code/ndarray.c msgid "operation is implemented for 1D Boolean arrays only" -msgstr "" +msgstr "jǐn duì 1D bù ěr shù zǔ shí xiàn cāo zuò" #: extmod/ulab/code/numerical/numerical.c msgid "operation is not implemented on ndarrays" @@ -3593,7 +3593,7 @@ msgstr "qǐngqiú chángdù %d dàn duìxiàng chángdù %d" #: extmod/ulab/code/ndarray_operators.c msgid "results cannot be cast to specified type" -msgstr "" +msgstr "wú fǎ jiāng jié guǒ qiáng zhì zhuǎn huàn dào zhǐ dìng lèi xíng" #: py/compile.c msgid "return annotation must be an identifier" @@ -3615,7 +3615,7 @@ msgstr "rgb_pins[%d] yǔ shízhōng bùzài tóng yīgè duānkǒu shàng" #: extmod/ulab/code/numerical/numerical.c msgid "roll argument must be an ndarray" -msgstr "" +msgstr "gǔn dòng cān shù bì xū shì ndarray" #: py/objstr.c msgid "rsplit(None,n)" @@ -3643,11 +3643,11 @@ msgstr "bù zhīchí jiǎoběn biānyì" #: extmod/ulab/code/ndarray.c msgid "shape must be a tuple" -msgstr "" +msgstr "xíng zhuàng bì xū shì yí gè yuán zǔ" #: shared-module/msgpack/__init__.c msgid "short read" -msgstr "" +msgstr "duǎn dú" #: py/objstr.c msgid "sign not allowed in string format specifier" @@ -3780,7 +3780,7 @@ msgstr "Chāo shí shíjiān bìxū wèi 0.0 Dào 100.0 Miǎo" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "timeout must be < 655.35 secs" -msgstr "" +msgstr "chāo shí bì xū < 655.35 miǎo" #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "timeout must be >= 0.0" @@ -3800,7 +3800,7 @@ msgstr "time_t shíjiān chuō chāochū píngtái fànwéi" #: extmod/ulab/code/ndarray.c msgid "tobytes can be invoked for dense arrays only" -msgstr "" +msgstr "tobytes zhǐ néng duì mì jí shù zǔ diào yòng" #: shared-module/struct/__init__.c msgid "too many arguments provided with the given format" @@ -3808,7 +3808,7 @@ msgstr "tígōng jǐ dìng géshì de cānshù tài duō" #: extmod/ulab/code/ulab_create.c msgid "too many dimensions" -msgstr "" +msgstr "chǐ cùn tài duō" #: extmod/ulab/code/ndarray.c msgid "too many indices" @@ -3821,7 +3821,7 @@ msgstr "dǎkāi tài duō zhí (yùqí %d)" #: extmod/ulab/code/approx/approx.c msgid "trapz is defined for 1D arrays" -msgstr "" +msgstr "wéi 1D shù zǔ dìng yì xiàn jǐng" #: extmod/ulab/code/approx/approx.c msgid "trapz is defined for 1D arrays of equal length" @@ -3829,7 +3829,7 @@ msgstr "Trapz shì wèi děng zhǎng de 1D shùzǔ dìngyì de" #: ports/esp32s2/common-hal/alarm/pin/__init__.c msgid "trigger level must be 0 or 1" -msgstr "" +msgstr "chù fā jí bié bì xū wéi 0 huò 1" #: py/obj.c msgid "tuple/list has wrong length" @@ -3971,7 +3971,7 @@ msgstr "xiàngliàng bìxū jùyǒu xiāngtóng de chángdù" #: ports/esp32s2/common-hal/alarm/pin/__init__.c msgid "wakeup conflict" -msgstr "" +msgstr "huàn xǐng chōng tū" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" @@ -3987,7 +3987,7 @@ msgstr "kuāndù bìxū dàyú líng" #: ports/esp32s2/common-hal/wifi/Radio.c msgid "wifi is not enabled" -msgstr "" +msgstr "wèi qǐ yòng WIFI" #: shared-bindings/_bleio/Adapter.c msgid "window must be <= interval" @@ -3995,11 +3995,11 @@ msgstr "Chuāngkǒu bìxū shì <= jiàngé" #: extmod/ulab/code/numerical/numerical.c msgid "wrong axis index" -msgstr "" +msgstr "cuò wù de zhóu suǒ yǐn" #: extmod/ulab/code/ulab_create.c msgid "wrong axis specified" -msgstr "" +msgstr "zhǐ dìng de zhóu cuò wù" #: extmod/ulab/code/vector/vectorise.c msgid "wrong input type" @@ -4027,7 +4027,7 @@ msgstr "x zhí chāochū biānjiè" #: ports/esp32s2/common-hal/audiobusio/__init__.c msgid "xTaskCreate failed" -msgstr "" +msgstr "xTaskCreate shī bài" #: shared-bindings/displayio/Shape.c msgid "y should be an int" From 0fa5aa359df3827a90be6c4e82719bb2ed8713e7 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 25 Jan 2021 16:07:01 -0500 Subject: [PATCH 20/53] Stop treating pin 15 specially. --- ports/raspberrypi/common-hal/microcontroller/Pin.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/ports/raspberrypi/common-hal/microcontroller/Pin.c b/ports/raspberrypi/common-hal/microcontroller/Pin.c index 90c3274067..6e531560e2 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Pin.c +++ b/ports/raspberrypi/common-hal/microcontroller/Pin.c @@ -63,12 +63,7 @@ void never_reset_pin_number(uint8_t pin_number) { } void reset_pin_number(uint8_t pin_number) { - if (pin_number >= 32 -#if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX - // Pin 15 is used for Errata so we don't mess with it. - || pin_number == 15 -#endif - ) { + if (pin_number >= 32) { return; } @@ -142,12 +137,7 @@ bool pin_number_is_free(uint8_t pin_number) { if (pin_number >= 30) { return false; } -#if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX - // Pin 15 is used for Errata so we don't mess with it. - if (pin_number == 15) { - return true; - } -#endif + uint32_t pad_state = padsbank0_hw->io[pin_number]; return (pad_state & PADS_BANK0_GPIO0_IE_BITS) == 0 && (pad_state & PADS_BANK0_GPIO0_OD_BITS) != 0; From 41400124301a4099bbe1f72fedc7cbd233602b7b Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Mon, 25 Jan 2021 16:25:56 -0600 Subject: [PATCH 21/53] Allow pins >= 32, allow write pin on different register than data pins --- locale/circuitpython.pot | 6 +- .../common-hal/displayio/ParallelBus.c | 100 +++++++++++------- .../common-hal/displayio/ParallelBus.h | 10 +- 3 files changed, 66 insertions(+), 50 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 4dfce747d7..f5c3da62cb 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -798,7 +798,7 @@ msgid "Data 0 pin must be byte aligned" msgstr "" #: ports/esp32s2/common-hal/displayio/ParallelBus.c -msgid "Data 0 pin must be byte aligned and < 32" +msgid "Data 0 pin must be byte aligned." msgstr "" #: shared-module/audiocore/WaveFile.c @@ -2140,10 +2140,6 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" -#: ports/esp32s2/common-hal/displayio/ParallelBus.c -msgid "Write pin must be < 32" -msgstr "" - #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.c b/ports/esp32s2/common-hal/displayio/ParallelBus.c index b644610f21..273a3a7ad0 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.c +++ b/ports/esp32s2/common-hal/displayio/ParallelBus.c @@ -36,9 +36,7 @@ /* * * Current pin limitations for ESP32-S2 ParallelBus: - * 1. data0 pin must be byte aligned (data0 pin options: 0, 8, 16 or 24) - * 2. The 8 data lines must use pin numbers < 32 - * 3. The write pin must be pin number < 32. + * - data0 pin must be byte aligned (data0 pin options: 0, 8, 16 or 24) * */ @@ -48,7 +46,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel uint8_t data_pin = data0->number; if ( (data_pin % 8 != 0) && (data_pin >= 32) ) { - mp_raise_ValueError(translate("Data 0 pin must be byte aligned and < 32")); + mp_raise_ValueError(translate("Data 0 pin must be byte aligned.")); } for (uint8_t i = 0; i < 8; i++) { @@ -57,10 +55,6 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel } } - if (write->number >= 32) { - mp_raise_ValueError(translate("Write pin must be < 32")); - } - gpio_dev_t *g = &GPIO; // this is the GPIO registers, see "extern gpio_dev_t GPIO" from file:gpio_struct.h // Setup the pins as "Simple GPIO outputs" see section 19.3.3 of the ESP32-S2 Reference Manual @@ -74,11 +68,14 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel /* From my understanding, there is a limitation of the ESP32-S2 that does not allow single-byte writes * into the GPIO registers. See section 10.3.3 regarding "non-aligned writes" into the registers. - * If a method for writing single-byte writes is uncovered, this code can be modified to provide - * single-byte access into the output register */ - self->bus = (uint32_t*) &g->out; //pointer to GPIO output register (for pins 0-31) + + if (data_pin < 31) { + self->bus = (uint32_t*) &g->out; //pointer to GPIO output register (for pins 0-31) + } else { + self->bus = (uint32_t*) &g->out1.val; //pointer to GPIO output register (for pins >= 32) + } /* SNIP - common setup of command, chip select, write and read pins, same as from SAMD and NRF ports */ self->command.base.type = &digitalio_digitalinout_type; @@ -98,17 +95,38 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel common_hal_digitalio_digitalinout_switch_to_output(&self->read, true, DRIVE_MODE_PUSH_PULL); self->data0_pin = data_pin; - self->write_group = &GPIO; - /* If we want to allow a write pin >= 32, should consider putting separate "clear_write" and - * "set_write" pointers into the .h in place of "write_group" - * to select between out_w1tc/out1_w1tc (clear) and out_w1ts/out1_w1ts (set) registers. - */ + + if (write->number < 32) { + self->write_clear_register = (uint32_t*) &g->out_w1tc; + self->write_set_register = (uint32_t*) &g->out_w1ts; + } else { + self->write_clear_register = (uint32_t*) &g->out1_w1tc.val; + self->write_set_register = (uint32_t*) &g->out1_w1ts.val; + } + + // Check to see if the data and write pins are on the same register: + if ( ( ((self->data0_pin < 32) && (write->number < 32)) ) || + ( ((self->data0_pin > 31) && (write->number > 31)) ) ) { + self->data_write_same_register = true; // data pins and write pin are on the same register + } else { + self->data_write_same_register = false; // data pins and write pins are on different registers + } + + + mp_printf(&mp_plat_print, "write_clear: %x, write_set: %x\n", self->write_clear_register, self->write_set_register); self->write_mask = 1 << (write->number % 32); /* the write pin triggers the LCD to latch the data */ - /* Note: As currently written for the ESP32-S2 port, the write pin must be a pin number less than 32 - * This could be updated to accommodate 32 and higher by using the different construction of the - * address for writing to output pins >= 32, see related note above for 'self->write_group' - */ + mp_printf(&mp_plat_print, "write_mask: %x\n", self->write_mask); + + mp_printf(&mp_plat_print, "out1 register: %x\n", g->out1.val); + mp_printf(&mp_plat_print, "clear a bit\n"); + *self->write_clear_register = self->write_mask; + mp_printf(&mp_plat_print, "out1 register: %x\n", g->out1.val); + mp_printf(&mp_plat_print, "write a bit\n"); + *self->write_set_register = self->write_mask; + mp_printf(&mp_plat_print, "out1 register: %x\n", g->out1.val); + + *self->write_clear_register = self->write_mask; /* SNIP - common setup of the reset pin, same as from SAMD and NRF ports */ self->reset.base.type = &mp_type_NoneType; @@ -174,13 +192,8 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj); common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA); - /* Currently the write pin number must be < 32. - * Future: To accommodate write pin numbers >= 32, will need to update to choose the correct register - * for the write pin set/clear (out_w1ts/out1_w1ts and out_w1tc/out1_w1tc) - */ - - uint32_t* clear_write = (uint32_t*) &self->write_group->out_w1tc; - uint32_t* set_write = (uint32_t*) &self->write_group->out_w1ts; + uint32_t* clear_write = self->write_clear_register; + uint32_t* set_write = self->write_set_register; const uint32_t mask = self->write_mask; @@ -197,24 +210,29 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt * each data byte will be written to the data pin registers */ - for (uint32_t i = 0; i < data_length; i++) { - /* Question: Is there a faster way of stuffing the data byte into the data_buffer, is bit arithmetic - * faster than writing to the byte address? - */ + if ( self->data_write_same_register ) { // data and write pins are on the same register + for (uint32_t i = 0; i < data_length; i++) { - /* Note: If the write pin and data pins are controlled by the same GPIO register, we can eliminate - * the "clear_write" step below, since the write pin is cleared when the data_buffer is written - * to the bus. - * Remember: This method requires the write pin to be controlled by the same GPIO register as the data pins. - */ + /* Note: If the write pin and data pins are controlled by the same GPIO register, we can eliminate + * the "clear_write" step below, since the write pin is cleared when the data_buffer is written + * to the bus. + */ - // *clear_write = mask; // clear the write pin (See comment above, this may not be necessary). + *(data_address) = data[i]; // stuff the data byte into the data_buffer at the correct offset byte location + *self->bus = data_buffer; // write the data to the output register + *set_write = mask; // set the write pin + } + } + else { // data and write pins are on different registers + for (uint32_t i = 0; i < data_length; i++) { + *clear_write = mask; // clear the write pin (See comment above, this may not be necessary). + *(data_address) = data[i]; // stuff the data byte into the data_buffer at the correct offset byte location + *self->bus = data_buffer; // write the data to the output register + *set_write = mask; // set the write pin - *(data_address) = data[i]; // stuff the data byte into the data_buffer at the correct offset byte location - *self->bus = data_buffer; // write the data to the output register - *set_write = mask; // set the write pin - } + } + } } diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.h b/ports/esp32s2/common-hal/displayio/ParallelBus.h index 20fc2f1bc7..84302118bd 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.h +++ b/ports/esp32s2/common-hal/displayio/ParallelBus.h @@ -35,11 +35,13 @@ typedef struct { digitalio_digitalinout_obj_t command; digitalio_digitalinout_obj_t chip_select; digitalio_digitalinout_obj_t reset; - digitalio_digitalinout_obj_t write; // write pin, must be a pin number < 32 currently + digitalio_digitalinout_obj_t write; digitalio_digitalinout_obj_t read; - uint8_t data0_pin; // pin number for the lowest number pin. Must be 0, 8, 16 or 24 with current - gpio_dev_t* write_group; // pointer to the write group for setting/clearing the write bit to latch the data on the LCD - uint32_t write_mask; // bit mask for the single bit for the write pin, currently write pin must be a pin number < 32 + uint8_t data0_pin; // pin number for the lowest number data pin. Must be 8-bit aligned + bool data_write_same_register; // if data and write pins are in the sare + uint32_t* write_set_register; // pointer to the write group for setting the write bit to latch the data on the LCD + uint32_t* write_clear_register; // pointer to the write group for clearing the write bit to latch the data on the LCD + uint32_t write_mask; // bit mask for the single bit for the write pin register } displayio_parallelbus_obj_t; #endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELBUS_H From 61850acd143d9f8732d0ce48dc51eac9fb7e4c4c Mon Sep 17 00:00:00 2001 From: Kevin Matocha Date: Mon, 25 Jan 2021 16:51:12 -0600 Subject: [PATCH 22/53] Fixed bug in pin error handling, deleted debug prints --- .../common-hal/displayio/ParallelBus.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.c b/ports/esp32s2/common-hal/displayio/ParallelBus.c index 273a3a7ad0..f77b37b57c 100644 --- a/ports/esp32s2/common-hal/displayio/ParallelBus.c +++ b/ports/esp32s2/common-hal/displayio/ParallelBus.c @@ -34,10 +34,8 @@ #include "shared-bindings/microcontroller/__init__.h" /* - * * Current pin limitations for ESP32-S2 ParallelBus: - * - data0 pin must be byte aligned (data0 pin options: 0, 8, 16 or 24) - * + * - data0 pin must be byte aligned */ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self, @@ -45,7 +43,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) { uint8_t data_pin = data0->number; - if ( (data_pin % 8 != 0) && (data_pin >= 32) ) { + if (data_pin % 8 != 0) { mp_raise_ValueError(translate("Data 0 pin must be byte aligned.")); } @@ -113,20 +111,7 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel } - mp_printf(&mp_plat_print, "write_clear: %x, write_set: %x\n", self->write_clear_register, self->write_set_register); - self->write_mask = 1 << (write->number % 32); /* the write pin triggers the LCD to latch the data */ - mp_printf(&mp_plat_print, "write_mask: %x\n", self->write_mask); - - mp_printf(&mp_plat_print, "out1 register: %x\n", g->out1.val); - mp_printf(&mp_plat_print, "clear a bit\n"); - *self->write_clear_register = self->write_mask; - mp_printf(&mp_plat_print, "out1 register: %x\n", g->out1.val); - mp_printf(&mp_plat_print, "write a bit\n"); - *self->write_set_register = self->write_mask; - mp_printf(&mp_plat_print, "out1 register: %x\n", g->out1.val); - - *self->write_clear_register = self->write_mask; /* SNIP - common setup of the reset pin, same as from SAMD and NRF ports */ self->reset.base.type = &mp_type_NoneType; From be4cfdd3d6d08796757a4582061e819e3f903ce4 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 25 Jan 2021 17:23:57 -0500 Subject: [PATCH 23/53] Use TOTAL_GPIO_COUNT instead of magic number 30 --- ports/raspberrypi/common-hal/microcontroller/Pin.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ports/raspberrypi/common-hal/microcontroller/Pin.c b/ports/raspberrypi/common-hal/microcontroller/Pin.c index 6e531560e2..ca5cf5a045 100644 --- a/ports/raspberrypi/common-hal/microcontroller/Pin.c +++ b/ports/raspberrypi/common-hal/microcontroller/Pin.c @@ -26,6 +26,7 @@ #include "py/runtime.h" +#include "common-hal/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/rgb_led_status.h" @@ -46,7 +47,7 @@ bool speaker_enable_in_use; STATIC uint32_t never_reset_pins; void reset_all_pins(void) { - for (size_t i = 0; i < 30; i++) { + for (size_t i = 0; i < TOTAL_GPIO_COUNT; i++) { if ((never_reset_pins & (1 << i)) != 0) { continue; } @@ -55,7 +56,7 @@ void reset_all_pins(void) { } void never_reset_pin_number(uint8_t pin_number) { - if (pin_number >= 32) { + if (pin_number >= TOTAL_GPIO_COUNT) { return; } @@ -63,7 +64,7 @@ void never_reset_pin_number(uint8_t pin_number) { } void reset_pin_number(uint8_t pin_number) { - if (pin_number >= 32) { + if (pin_number >= TOTAL_GPIO_COUNT) { return; } @@ -134,7 +135,7 @@ void claim_pin(const mcu_pin_obj_t* pin) { } bool pin_number_is_free(uint8_t pin_number) { - if (pin_number >= 30) { + if (pin_number >= TOTAL_GPIO_COUNT) { return false; } From a9f339b4619a55cf5748124180e43afca32d8fb7 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 25 Jan 2021 22:40:31 -0500 Subject: [PATCH 24/53] typo in circuitpy_mpconfig.h; forgot cxd56 port --- docs/shared_bindings_matrix.py | 2 +- py/circuitpy_mpconfig.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index ca6ddd3ed7..e62b1d2186 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -30,7 +30,7 @@ import sys from concurrent.futures import ThreadPoolExecutor -SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'raspberrypi', 'stm'] +SUPPORTED_PORTS = ['atmel-samd', 'cxd56', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'raspberrypi', 'stm'] def get_circuitpython_root_dir(): """ The path to the root './circuitpython' directory diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index c193e61c49..7c77683918 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -199,7 +199,7 @@ typedef long mp_off_t; #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (CIRCUITPY_FULL_BUILD) #endif // Opposite setting is deliberate. -#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_RE) +#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_FULL_BUILD) #define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_RE) #define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_RE) #define MICROPY_PY_URE_SUB (CIRCUITPY_RE) From 5b4249e365f620f7732ff2079fe345eda5074cbf Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 25 Jan 2021 23:06:47 -0500 Subject: [PATCH 25/53] fix doc typos --- docs/library/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/library/index.rst b/docs/library/index.rst index 94bd8a6569..181ff0109a 100644 --- a/docs/library/index.rst +++ b/docs/library/index.rst @@ -6,7 +6,7 @@ MicroPython libraries Python standard libraries and micro-libraries --------------------------------------------- -These libraries are inherited from MicroPython. +The libraries below are inherited from MicroPython. They are similar to the standard Python libraries with the same name. They implement a subset of or a variant of the corresponding standard Python library. @@ -20,7 +20,7 @@ limited flash memory, usually on non-Express builds: These libraries are not currently enabled in any CircuitPython build, but may be in the future, with the ``u`` prefix dropped: -``uctypes`, ``uhashlib``, ``uio``, ``uzlib``. +``uctypes``, ``uhashlib``, ``uzlib``. .. toctree:: :maxdepth: 1 From 0ba49d7303ef40abc73d281d1cfe867a6db3a748 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Mon, 25 Jan 2021 23:20:37 -0500 Subject: [PATCH 26/53] typo; thanks @Neradoc --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 19992d284b..f14cf41ff3 100644 --- a/README.rst +++ b/README.rst @@ -125,7 +125,7 @@ Behavior get back into normal mode. - RGB status LED indicating CircuitPython state, and errors through a sequence of colored flashes. - Re-runs ``code.py`` or other main file after file system writes over USB mass storage. (Disable with - ``samd.disable_autoreload()``) + ``supervisor.disable_autoreload()``) - Entering the REPL after the main code is finished requires a key press which enters the REPL and disables autoreload. - Main is one of these: ``code.txt``, ``code.py``, ``main.py``, From da6869dbd5366c0f3d186b32a2b058585b0c5192 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 26 Jan 2021 08:37:05 -0500 Subject: [PATCH 27/53] Set MICROPY_PY_UERRNO_ERRORCODE correctly --- py/circuitpy_mpconfig.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 7c77683918..ee23c71569 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -198,8 +198,6 @@ typedef long mp_off_t; #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (CIRCUITPY_FULL_BUILD) #endif -// Opposite setting is deliberate. -#define MICROPY_PY_UERRNO_ERRORCODE (!CIRCUITPY_FULL_BUILD) #define MICROPY_PY_URE_MATCH_GROUPS (CIRCUITPY_RE) #define MICROPY_PY_URE_MATCH_SPAN_START_END (CIRCUITPY_RE) #define MICROPY_PY_URE_SUB (CIRCUITPY_RE) @@ -401,9 +399,12 @@ extern const struct _mp_obj_module_t terminalio_module; #if CIRCUITPY_ERRNO #define MICROPY_PY_UERRNO (1) +// Uses about 80 bytes. +#define MICROPY_PY_UERRNO_ERRORCODE (1) #define ERRNO_MODULE { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, #else #define ERRNO_MODULE +# #endif #if CIRCUITPY_ESPIDF From 51f054440516d21bd2e8d07a3e6f1f8e3acfbd55 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 09:19:44 -0600 Subject: [PATCH 28/53] protmatter: Update to version that supports tiling --- lib/protomatter | 2 +- shared-bindings/rgbmatrix/RGBMatrix.c | 27 ++++++++++++++++++--------- shared-bindings/rgbmatrix/RGBMatrix.h | 2 +- shared-module/rgbmatrix/RGBMatrix.c | 5 +++-- shared-module/rgbmatrix/RGBMatrix.h | 1 + 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/protomatter b/lib/protomatter index 902c16f491..5e925cea7a 160000 --- a/lib/protomatter +++ b/lib/protomatter @@ -1 +1 @@ -Subproject commit 902c16f49197a8baf5e71ec924a812a86e733a74 +Subproject commit 5e925cea7a55273e375a6129761cb29b4e750d4f diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 5f5ea4fae7..ad693066cd 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -24,6 +24,8 @@ * THE SOFTWARE. */ +#include + #include "py/obj.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -132,11 +134,11 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ } } -//| def __init__(self, *, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: Sequence[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0) -> None: +//| def __init__(self, *, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: Sequence[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0, tile: int = 1, serpentine: bool = False) -> None: //| """Create a RGBMatrix object with the given attributes. The height of -//| the display is determined by the number of rgb and address pins: -//| len(rgb_pins) // 3 * 2 ** len(address_pins). With 6 RGB pins and 4 -//| address lines, the display will be 32 pixels tall. If the optional height +//| the display is determined by the number of rgb and address pins and the number of tiles: +//| ``len(rgb_pins) // 3 * 2 ** len(address_pins) * abs(tile)``. With 6 RGB pins, 4 +//| address lines, and a single matrix, the display will be 32 pixels tall. If the optional height //| parameter is specified and is not 0, it is checked against the calculated //| height. //| @@ -172,7 +174,7 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ STATIC mp_obj_t rgbmatrix_rgbmatrix_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_width, ARG_bit_depth, ARG_rgb_list, ARG_addr_list, - ARG_clock_pin, ARG_latch_pin, ARG_output_enable_pin, ARG_doublebuffer, ARG_framebuffer, ARG_height }; + ARG_clock_pin, ARG_latch_pin, ARG_output_enable_pin, ARG_doublebuffer, ARG_framebuffer, ARG_height, ARG_tile, ARG_serpentine }; static const mp_arg_t allowed_args[] = { { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, { MP_QSTR_bit_depth, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, @@ -184,6 +186,8 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_doublebuffer, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = true } }, { MP_QSTR_framebuffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, { MP_QSTR_height, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, + { MP_QSTR_tile, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 1 } }, + { MP_QSTR_serpentine, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, }; 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); @@ -210,15 +214,20 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n mp_raise_ValueError_varg(translate("Must use a multiple of 6 rgb pins, not %d"), rgb_count); } - // TODO(@jepler) Use fewer than all rows of pixels if height < computed_height + int tile = args[ARG_tile].u_int; + if (args[ARG_height].u_int != 0) { - int computed_height = (rgb_count / 3) << (addr_count); + int computed_height = (rgb_count / 3) << (addr_count) * abs(tile); if (computed_height != args[ARG_height].u_int) { mp_raise_ValueError_varg( - translate("%d address pins and %d rgb pins indicate a height of %d, not %d"), addr_count, rgb_count, computed_height, args[ARG_height].u_int); + translate("%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"), addr_count, rgb_count, tile, computed_height, args[ARG_height].u_int); } } + if (args[ARG_serpentine].u_bool) { + tile = -tile; + } + if (args[ARG_width].u_int <= 0) { mp_raise_ValueError(translate("width must be greater than zero")); } @@ -239,7 +248,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n addr_count, addr_pins, clock_pin, latch_pin, output_enable_pin, args[ARG_doublebuffer].u_bool, - framebuffer, NULL); + framebuffer, tile, NULL); claim_and_never_reset_pins(args[ARG_rgb_list].u_obj); claim_and_never_reset_pins(args[ARG_addr_list].u_obj); diff --git a/shared-bindings/rgbmatrix/RGBMatrix.h b/shared-bindings/rgbmatrix/RGBMatrix.h index bfe37c3404..3e8a4db5f3 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.h +++ b/shared-bindings/rgbmatrix/RGBMatrix.h @@ -31,7 +31,7 @@ extern const mp_obj_type_t rgbmatrix_RGBMatrix_type; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, void* timer); +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, void* timer); void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t*); void rgbmatrix_rgbmatrix_collect_ptrs(rgbmatrix_rgbmatrix_obj_t*); void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, mp_obj_t framebuffer); diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index a09767b622..95a7eda75d 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -42,7 +42,7 @@ extern Protomatter_core *_PM_protoPtr; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, void *timer) { +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, void *timer) { self->width = width; self->bit_depth = bit_depth; self->rgb_count = rgb_count; @@ -53,6 +53,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i self->oe_pin = oe_pin; self->latch_pin = latch_pin; self->doublebuffer = doublebuffer; + self->tile = tile; self->timer = timer ? timer : common_hal_rgbmatrix_timer_allocate(); if (self->timer == NULL) { @@ -95,7 +96,7 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, self->rgb_count/6, self->rgb_pins, self->addr_count, self->addr_pins, self->clock_pin, self->latch_pin, self->oe_pin, - self->doublebuffer, self->timer); + self->doublebuffer, self->tile, self->timer); if (stat == PROTOMATTER_OK) { _PM_protoPtr = &self->protomatter; diff --git a/shared-module/rgbmatrix/RGBMatrix.h b/shared-module/rgbmatrix/RGBMatrix.h index 6dbc6fd41e..7fce73c8b1 100644 --- a/shared-module/rgbmatrix/RGBMatrix.h +++ b/shared-module/rgbmatrix/RGBMatrix.h @@ -44,4 +44,5 @@ typedef struct { bool core_is_initialized; bool paused; bool doublebuffer; + int8_t tile; } rgbmatrix_rgbmatrix_obj_t; From f154ee855d2e307f3ff24f25f138faa6e5210ad6 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 26 Jan 2021 10:23:37 -0500 Subject: [PATCH 29/53] shrink simmel --- ports/nrf/boards/simmel/mpconfigboard.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 4eb6c98c7e..032caac408 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -13,11 +13,13 @@ INTERNAL_FLASH_FILESYSTEM = 1 CIRCUITPY_AESIO = 1 CIRCUITPY_AUDIOMP3 = 0 +CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_BUSIO = 1 CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_ERRNO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 -CIRCUITPY_MSGPACK = 0 CIRCUITPY_GAMEPAD = 0 +CIRCUITPY_MSGPACK = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 CIRCUITPY_NVM = 0 CIRCUITPY_PIXELBUF = 0 @@ -28,7 +30,6 @@ CIRCUITPY_SDCARDIO = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_ULAB = 0 CIRCUITPY_WATCHDOG = 1 -CIRCUITPY_BUSDEVICE = 0 # Enable micropython.native #CIRCUITPY_ENABLE_MPY_NATIVE = 1 From 365fafb32bc2e395b1d50e75c1a7160ee31eefcd Mon Sep 17 00:00:00 2001 From: "Ryan A. Pavlik" Date: Tue, 26 Jan 2021 10:36:40 -0600 Subject: [PATCH 30/53] Update design_guide.rst Add CO2 as a member name, and clarify the description of eCO2. --- docs/design_guide.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 75825893a9..7a8c76b507 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -520,7 +520,9 @@ properties. +-----------------------+-----------------------+-------------------------------------------------------------------------+ | ``temperature`` | float | degrees centigrade | +-----------------------+-----------------------+-------------------------------------------------------------------------+ -| ``eCO2`` | float | equivalent CO2 in ppm | +| ``CO2`` | float | measured CO2 in ppm | ++-----------------------+-----------------------+-------------------------------------------------------------------------+ +| ``eCO2`` | float | equivalent/estimated CO2 in ppm (estimated from some other measurement) | +-----------------------+-----------------------+-------------------------------------------------------------------------+ | ``TVOC`` | float | Total Volatile Organic Compounds in ppb | +-----------------------+-----------------------+-------------------------------------------------------------------------+ From b42e94ee2cf9b1d35ddabe36292a980bf0ed0c4f Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 26 Jan 2021 08:48:30 -0800 Subject: [PATCH 31/53] Raise an error on UART use --- ports/raspberrypi/common-hal/busio/UART.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index 71da6cadd5..f9a75b4996 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -54,6 +54,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop, mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer, bool sigint_enabled) { + mp_raise_NotImplementedError(translate("UART not yet supported")); // Sercom* sercom = NULL; // uint8_t sercom_index = 255; // Unset index From 345c2ae8a95f63834aea4f7ee5f1288fbc84e279 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 11:04:18 -0600 Subject: [PATCH 32/53] make translate --- locale/circuitpython.pot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 3ffc31cc6c..b896688b51 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -58,7 +58,8 @@ msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -516,7 +517,6 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" From 368977fb906e6561bd67977a47dc0b415547cc33 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 14:33:48 -0600 Subject: [PATCH 33/53] RGBMatrix: Additional tile tweaks * Introduce explicit serpentine: bool argument instead of using negative numbers (thanks, ghost of @tannewt sitting on one shoulder) * Fix several calculations of height Testing performed (matrixportal): * set up a serpentine 64x64 virtual display with 2 64x32 tiles * tried all 4 rotations * looked at output of REPL --- shared-bindings/rgbmatrix/RGBMatrix.c | 17 ++++++++--------- shared-bindings/rgbmatrix/RGBMatrix.h | 2 +- shared-module/rgbmatrix/RGBMatrix.c | 10 ++++++---- shared-module/rgbmatrix/RGBMatrix.h | 1 + 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index ad693066cd..7218b2a9ea 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -24,8 +24,6 @@ * THE SOFTWARE. */ -#include - #include "py/obj.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -216,18 +214,19 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n int tile = args[ARG_tile].u_int; + if (tile < 0) { + mp_raise_ValueError_varg( + translate("tile must be greater than or equal to zero")); + } + if (args[ARG_height].u_int != 0) { - int computed_height = (rgb_count / 3) << (addr_count) * abs(tile); + int computed_height = (rgb_count / 3) * (1 << (addr_count)) * tile; if (computed_height != args[ARG_height].u_int) { mp_raise_ValueError_varg( translate("%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"), addr_count, rgb_count, tile, computed_height, args[ARG_height].u_int); } } - if (args[ARG_serpentine].u_bool) { - tile = -tile; - } - if (args[ARG_width].u_int <= 0) { mp_raise_ValueError(translate("width must be greater than zero")); } @@ -237,7 +236,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; if (framebuffer == mp_const_none) { int width = args[ARG_width].u_int; - int bufsize = 2 * width * rgb_count / 3 * (1 << addr_count); + int bufsize = 2 * width * rgb_count / 3 * (1 << addr_count) * tile; framebuffer = mp_obj_new_bytearray_of_zeros(bufsize); } @@ -248,7 +247,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n addr_count, addr_pins, clock_pin, latch_pin, output_enable_pin, args[ARG_doublebuffer].u_bool, - framebuffer, tile, NULL); + framebuffer, tile, args[ARG_serpentine].u_bool, NULL); claim_and_never_reset_pins(args[ARG_rgb_list].u_obj); claim_and_never_reset_pins(args[ARG_addr_list].u_obj); diff --git a/shared-bindings/rgbmatrix/RGBMatrix.h b/shared-bindings/rgbmatrix/RGBMatrix.h index 3e8a4db5f3..4eb3c04b27 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.h +++ b/shared-bindings/rgbmatrix/RGBMatrix.h @@ -31,7 +31,7 @@ extern const mp_obj_type_t rgbmatrix_RGBMatrix_type; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, void* timer); +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, bool serpentine, void* timer); void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t*); void rgbmatrix_rgbmatrix_collect_ptrs(rgbmatrix_rgbmatrix_obj_t*); void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, mp_obj_t framebuffer); diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index 95a7eda75d..4318604c64 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -42,7 +42,7 @@ extern Protomatter_core *_PM_protoPtr; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, void *timer) { +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, bool serpentine, void *timer) { self->width = width; self->bit_depth = bit_depth; self->rgb_count = rgb_count; @@ -54,6 +54,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i self->latch_pin = latch_pin; self->doublebuffer = doublebuffer; self->tile = tile; + self->serpentine = serpentine; self->timer = timer ? timer : common_hal_rgbmatrix_timer_allocate(); if (self->timer == NULL) { @@ -61,7 +62,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i } self->width = width; - self->bufsize = 2 * width * rgb_count / 3 * (1 << addr_count); + self->bufsize = 2 * width * rgb_count / 3 * (1 << addr_count) * tile; common_hal_rgbmatrix_rgbmatrix_reconstruct(self, framebuffer); } @@ -96,7 +97,8 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, self->rgb_count/6, self->rgb_pins, self->addr_count, self->addr_pins, self->clock_pin, self->latch_pin, self->oe_pin, - self->doublebuffer, self->tile, self->timer); + self->doublebuffer, self->serpentine ? -self->tile : self->tile, + self->timer); if (stat == PROTOMATTER_OK) { _PM_protoPtr = &self->protomatter; @@ -210,7 +212,7 @@ int common_hal_rgbmatrix_rgbmatrix_get_width(rgbmatrix_rgbmatrix_obj_t* self) { } int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t* self) { - int computed_height = (self->rgb_count / 3) << (self->addr_count); + int computed_height = (self->rgb_count / 3) * (1 << (self->addr_count)) * self->tile; return computed_height; } diff --git a/shared-module/rgbmatrix/RGBMatrix.h b/shared-module/rgbmatrix/RGBMatrix.h index 7fce73c8b1..4a0e9235e7 100644 --- a/shared-module/rgbmatrix/RGBMatrix.h +++ b/shared-module/rgbmatrix/RGBMatrix.h @@ -44,5 +44,6 @@ typedef struct { bool core_is_initialized; bool paused; bool doublebuffer; + bool serpentine; int8_t tile; } rgbmatrix_rgbmatrix_obj_t; From 20c9f25a654df33e4fb719edfeaad8c4d4396f5e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 14:35:26 -0600 Subject: [PATCH 34/53] rgbmatrix: Eliminate some duplicated height-calculating code This was hard to write, so let's have it written in 2 places instead of 4. --- shared-bindings/rgbmatrix/RGBMatrix.c | 4 ++-- shared-module/rgbmatrix/RGBMatrix.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 7218b2a9ea..3b2039e4d1 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -219,8 +219,8 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n translate("tile must be greater than or equal to zero")); } + int computed_height = (rgb_count / 3) * (1 << (addr_count)) * tile; if (args[ARG_height].u_int != 0) { - int computed_height = (rgb_count / 3) * (1 << (addr_count)) * tile; if (computed_height != args[ARG_height].u_int) { mp_raise_ValueError_varg( translate("%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"), addr_count, rgb_count, tile, computed_height, args[ARG_height].u_int); @@ -236,7 +236,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; if (framebuffer == mp_const_none) { int width = args[ARG_width].u_int; - int bufsize = 2 * width * rgb_count / 3 * (1 << addr_count) * tile; + int bufsize = 2 * width * computed_height; framebuffer = mp_obj_new_bytearray_of_zeros(bufsize); } diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index 4318604c64..b8db0d8939 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -62,7 +62,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i } self->width = width; - self->bufsize = 2 * width * rgb_count / 3 * (1 << addr_count) * tile; + self->bufsize = 2 * width * common_hal_rgbmatrix_rgbmatrix_get_height(self); common_hal_rgbmatrix_rgbmatrix_reconstruct(self, framebuffer); } From 1c10ec99a774538e0e39414beb99ca3f0a0b5694 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 15:04:45 -0600 Subject: [PATCH 35/53] make translate --- locale/circuitpython.pot | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index b896688b51..4d8aceb85e 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -3710,6 +3710,10 @@ msgstr "" msgid "threshold must be in the range 0-65536" msgstr "" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than or equal to zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" From 85508d7cc17b96b4cb3ac41fbf03b0371f1b441d Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Tue, 26 Jan 2021 22:08:06 +0100 Subject: [PATCH 36/53] 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 | 6 +++++- locale/cs.po | 6 +++++- locale/de_DE.po | 6 +++++- locale/el.po | 6 +++++- locale/es.po | 6 +++++- locale/fil.po | 6 +++++- locale/fr.po | 6 +++++- locale/hi.po | 6 +++++- locale/it_IT.po | 6 +++++- locale/ja.po | 6 +++++- locale/ko.po | 6 +++++- locale/nl.po | 6 +++++- locale/pl.po | 6 +++++- locale/pt_BR.po | 6 +++++- locale/sv.po | 6 +++++- locale/zh_Latn_pinyin.po | 9 +++++++-- 16 files changed, 82 insertions(+), 17 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index 7ae5b50bd4..b4385c7418 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -538,6 +538,7 @@ msgid "Buffer too short by %d bytes" msgstr "Buffer terlalu pendek untuk %d byte" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -818,6 +819,10 @@ msgstr "DAC sudah digunakan" msgid "Data 0 pin must be byte aligned" msgstr "Data 0 pin harus byte disejajarkan" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Potongan data harus mengikuti fmt chunk" @@ -1613,7 +1618,6 @@ msgstr "" "Frekuensi PWM tidak dapat ditulis ketika variabel_frequency Salah pada " "konstruksi." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/cs.po b/locale/cs.po index d7ab891b6e..8e187440f3 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -534,6 +534,7 @@ msgid "Buffer too short by %d bytes" msgstr "" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -803,6 +804,10 @@ msgstr "" msgid "Data 0 pin must be byte aligned" msgstr "" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -1587,7 +1592,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/de_DE.po b/locale/de_DE.po index 25321f63eb..c6c8e14ad4 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -539,6 +539,7 @@ msgid "Buffer too short by %d bytes" msgstr "Buffer um %d Bytes zu kurz" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -815,6 +816,10 @@ msgstr "DAC wird schon benutzt" msgid "Data 0 pin must be byte aligned" msgstr "Data 0 pin muss am Byte ausgerichtet sein" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Dem fmt Block muss ein Datenblock folgen" @@ -1612,7 +1617,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "Die PWM-Frequenz ist nicht schreibbar wenn variable_Frequenz = False." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/el.po b/locale/el.po index 104dff4ee5..cf1ae7cffb 100644 --- a/locale/el.po +++ b/locale/el.po @@ -531,6 +531,7 @@ msgid "Buffer too short by %d bytes" msgstr "" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -800,6 +801,10 @@ msgstr "" msgid "Data 0 pin must be byte aligned" msgstr "" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -1584,7 +1589,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/es.po b/locale/es.po index 58634a597e..6c24698401 100644 --- a/locale/es.po +++ b/locale/es.po @@ -543,6 +543,7 @@ msgid "Buffer too short by %d bytes" msgstr "Búffer muy corto por %d bytes" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -818,6 +819,10 @@ msgstr "DAC ya está siendo utilizado" msgid "Data 0 pin must be byte aligned" msgstr "El pin Data 0 debe estar alineado a bytes" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Trozo de datos debe seguir fmt chunk" @@ -1613,7 +1618,6 @@ msgstr "" "La frecuencia de PWM no se puede escribir variable_frequency es False en la " "construcción." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/fil.po b/locale/fil.po index cd59ad213d..f277c784c5 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -536,6 +536,7 @@ msgid "Buffer too short by %d bytes" msgstr "" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, fuzzy, c-format msgid "Bus pin %d is already in use" @@ -809,6 +810,10 @@ msgstr "Ginagamit na ang DAC" msgid "Data 0 pin must be byte aligned" msgstr "graphic ay dapat 2048 bytes ang haba" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Dapat sunurin ng Data chunk ang fmt chunk" @@ -1603,7 +1608,6 @@ msgid "" msgstr "" "PWM frequency hindi writable kapag variable_frequency ay False sa pag buo." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/fr.po b/locale/fr.po index 1c47148259..979fb201b3 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -548,6 +548,7 @@ msgid "Buffer too short by %d bytes" msgstr "Tampon trop court de %d octets" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -831,6 +832,10 @@ msgstr "DAC déjà utilisé" msgid "Data 0 pin must be byte aligned" msgstr "La broche 'Data 0' doit être aligné sur l'octet" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Un bloc de données doit suivre un bloc fmt" @@ -1631,7 +1636,6 @@ msgstr "" "La fréquence de PWM n'est pas modifiable quand variable_frequency est False " "à la construction." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/hi.po b/locale/hi.po index f9fa68f5c8..902cd25564 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -531,6 +531,7 @@ msgid "Buffer too short by %d bytes" msgstr "" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -800,6 +801,10 @@ msgstr "" msgid "Data 0 pin must be byte aligned" msgstr "" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -1584,7 +1589,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/it_IT.po b/locale/it_IT.po index e6402f9294..58784a0631 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -536,6 +536,7 @@ msgid "Buffer too short by %d bytes" msgstr "" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, fuzzy, c-format msgid "Bus pin %d is already in use" @@ -810,6 +811,10 @@ msgstr "DAC già in uso" msgid "Data 0 pin must be byte aligned" msgstr "graphic deve essere lunga 2048 byte" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -1612,7 +1617,6 @@ msgstr "" "frequenza PWM frequency non è scrivibile quando variable_frequency è " "impostato nel costruttore a False." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/ja.po b/locale/ja.po index 42c882e9a4..4169131d40 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -538,6 +538,7 @@ msgid "Buffer too short by %d bytes" msgstr "バッファが %d バイト足りません" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -811,6 +812,10 @@ msgstr "DACはすでに使用中" msgid "Data 0 pin must be byte aligned" msgstr "Data 0 ピンは、バイト整列されていなければなりません" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "fmtチャンクの後にdataチャンクが続かなければなりません" @@ -1600,7 +1605,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "PWM周波数は生成時のvariable_frequencyがFalseのとき書き換え不可" -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/ko.po b/locale/ko.po index 97de46fcd5..13a1ea5d16 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -534,6 +534,7 @@ msgid "Buffer too short by %d bytes" msgstr "" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -803,6 +804,10 @@ msgstr "DAC가 현재 사용 중입니다" msgid "Data 0 pin must be byte aligned" msgstr "" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -1587,7 +1592,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "" -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/nl.po b/locale/nl.po index 58cc8e6030..c1c0eef266 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -536,6 +536,7 @@ msgid "Buffer too short by %d bytes" msgstr "Buffer is %d bytes te klein" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -811,6 +812,10 @@ msgstr "DAC al in gebruik" msgid "Data 0 pin must be byte aligned" msgstr "Data 0 pin moet byte uitgelijnd zijn" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Data chunk moet gevolgd worden door fmt chunk" @@ -1607,7 +1612,6 @@ msgstr "" "PWM frequentie is niet schrijfbaar wanneer de variable_frequency False is " "tijdens constructie." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/pl.po b/locale/pl.po index 14a57b4ea2..a6bb1c2165 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -538,6 +538,7 @@ msgid "Buffer too short by %d bytes" msgstr "Bufor za krótki o %d bajtów" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -811,6 +812,10 @@ msgstr "DAC w użyciu" msgid "Data 0 pin must be byte aligned" msgstr "Nóżka data 0 musi być wyrównana do bajtu" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Fragment danych musi następować po fragmencie fmt" @@ -1598,7 +1603,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "Nie można zmienić częstotliwości PWM gdy variable_frequency=False." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 92d46a4cf9..84b3f55e54 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -548,6 +548,7 @@ msgid "Buffer too short by %d bytes" msgstr "O buffer é muito curto em %d bytes" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -827,6 +828,10 @@ msgstr "DAC em uso" msgid "Data 0 pin must be byte aligned" msgstr "O pino de dados 0 deve ser alinhado por bytes" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Pedaço de dados deve seguir o pedaço de cortes" @@ -1623,7 +1628,6 @@ msgstr "" "A frequência do PWM não pode ser gravada quando variable_frequency for False " "na construção." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/sv.po b/locale/sv.po index c3b55d5a03..f7d7c0108f 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -540,6 +540,7 @@ msgid "Buffer too short by %d bytes" msgstr "Buffert är %d bytes för kort" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -816,6 +817,10 @@ msgstr "DAC används redan" msgid "Data 0 pin must be byte aligned" msgstr "Datapinne 0 måste vara bytejusterad" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Datasegmentet måste följa fmt-segmentet" @@ -1610,7 +1615,6 @@ msgstr "" "PWM-frekvensen är inte skrivbar när variable_frequency är falsk vid " "skapandet." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index c2ff040449..1bfa43b8d6 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -542,6 +542,7 @@ msgid "Buffer too short by %d bytes" msgstr "Huǎn chōng qū tài duǎn , àn %d zì jié" #: ports/atmel-samd/common-hal/displayio/ParallelBus.c +#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/nrf/common-hal/displayio/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" @@ -815,6 +816,10 @@ msgstr "Fā yuán huì yǐjīng shǐyòng" msgid "Data 0 pin must be byte aligned" msgstr "Shùjù 0 de yǐn jiǎo bìxū shì zì jié duìqí" +#: ports/esp32s2/common-hal/displayio/ParallelBus.c +msgid "Data 0 pin must be byte aligned." +msgstr "" + #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Shùjù kuài bìxū zūnxún fmt qū kuài" @@ -1607,7 +1612,6 @@ msgid "" "PWM frequency not writable when variable_frequency is False on construction." msgstr "Dāng biànliàng_pínlǜ shì False zài jiànzhú shí PWM pínlǜ bùkě xiě." -#: ports/esp32s2/common-hal/displayio/ParallelBus.c #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" @@ -2525,7 +2529,8 @@ msgstr "wúfǎ cóng shǒudòng zìduàn guīgé qiēhuàn dào zìdòng zìduà #: extmod/ulab/code/ndarray_operators.c msgid "cannot cast output with casting rule" -msgstr "wú fǎ shǐ yòng qiáng zhì zhuǎn huàn guī zé qiáng zhì zhuǎn huàn shū chū" +msgstr "" +"wú fǎ shǐ yòng qiáng zhì zhuǎn huàn guī zé qiáng zhì zhuǎn huàn shū chū" #: py/objtype.c msgid "cannot create '%q' instances" From 189ec2fc60f8dbfb5b054174f0062b9baeb27ca3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 26 Jan 2021 15:05:24 -0600 Subject: [PATCH 37/53] Disallow tile=0 --- locale/circuitpython.pot | 2 +- shared-bindings/rgbmatrix/RGBMatrix.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 4d8aceb85e..81ee31e1ec 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -3711,7 +3711,7 @@ msgid "threshold must be in the range 0-65536" msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c -msgid "tile must be greater than or equal to zero" +msgid "tile must be greater than zero" msgstr "" #: shared-bindings/time/__init__.c diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 3b2039e4d1..2a81bb53c2 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -214,9 +214,9 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n int tile = args[ARG_tile].u_int; - if (tile < 0) { + if (tile <= 0) { mp_raise_ValueError_varg( - translate("tile must be greater than or equal to zero")); + translate("tile must be greater than zero")); } int computed_height = (rgb_count / 3) * (1 << (addr_count)) * tile; From 2918b73828ea68e6a9765923173021fe95b7d808 Mon Sep 17 00:00:00 2001 From: Maciej Stankiewicz Date: Tue, 26 Jan 2021 21:16:01 +0000 Subject: [PATCH 38/53] Translated using Weblate (Polish) Currently translated at 67.7% (626 of 924 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pl/ --- locale/pl.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/locale/pl.po b/locale/pl.po index a6bb1c2165..66758b36aa 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-01-20 02:40+0000\n" +"PO-Revision-Date: 2021-01-27 01:31+0000\n" "Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" "Language: pl\n" @@ -3138,7 +3138,7 @@ msgstr "" #: py/parse.c msgid "malformed f-string" -msgstr "" +msgstr "źle sformatowany f-string" #: shared-bindings/_stage/Layer.c msgid "map buffer too small" @@ -3407,11 +3407,11 @@ msgstr "offset poza zakresem" #: ports/nrf/common-hal/audiobusio/PDMIn.c msgid "only bit_depth=16 is supported" -msgstr "" +msgstr "obsługiwane jest tylko bit_depth=16" #: ports/nrf/common-hal/audiobusio/PDMIn.c msgid "only sample_rate=16000 is supported" -msgstr "" +msgstr "obsługiwane jest tylko sample_rate=16000" #: py/objarray.c py/objstr.c py/objstrunicode.c py/objtuple.c #: shared-bindings/alarm/SleepMemory.c shared-bindings/nvm/ByteArray.c From c1b1ddd724dd77594954ab995e3389ffd7603944 Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Wed, 27 Jan 2021 02:31:39 +0100 Subject: [PATCH 39/53] 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 | 13 ++++++++++--- locale/cs.po | 13 ++++++++++--- locale/de_DE.po | 14 +++++++++++--- locale/el.po | 8 ++++++-- locale/es.po | 13 ++++++++++--- locale/fil.po | 8 ++++++-- locale/fr.po | 15 +++++++++++---- locale/hi.po | 8 ++++++-- locale/it_IT.po | 8 ++++++-- locale/ja.po | 8 ++++++-- locale/ko.po | 8 ++++++-- locale/nl.po | 13 ++++++++++--- locale/pl.po | 8 ++++++-- locale/pt_BR.po | 14 +++++++++++--- locale/sv.po | 13 ++++++++++--- locale/zh_Latn_pinyin.po | 14 +++++++++++--- 16 files changed, 136 insertions(+), 42 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index b4385c7418..e111233982 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -63,8 +63,9 @@ msgstr "%%c harus int atau char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" -msgstr "pin alamat %d dan pin rgb %d menunjukkan tinggi %d, bukan %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" +msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -523,7 +524,6 @@ msgstr "Panjang buffer harus kelipatan 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Penyangga harus memiliki panjang setidaknya 1" @@ -3766,6 +3766,10 @@ msgstr "sintaksis error pada pendeskripsi uctypes" msgid "threshold must be in the range 0-65536" msgstr "" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" @@ -4055,6 +4059,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "pin alamat %d dan pin rgb %d menunjukkan tinggi %d, bukan %d" + #~ msgid "" #~ "\n" #~ "Code done running. Waiting for reload.\n" diff --git a/locale/cs.po b/locale/cs.po index 8e187440f3..9181d1f709 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -61,8 +61,9 @@ msgstr "%%c vyžaduje int nebo char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" -msgstr "%d adresní piny a %d rgb piny označují výšku %d, nikoli %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" +msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -519,7 +520,6 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -3717,6 +3717,10 @@ msgstr "" msgid "threshold must be in the range 0-65536" msgstr "" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" @@ -4005,6 +4009,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "%d adresní piny a %d rgb piny označují výšku %d, nikoli %d" + #~ msgid "" #~ "\n" #~ "Code done running. Waiting for reload.\n" diff --git a/locale/de_DE.po b/locale/de_DE.po index c6c8e14ad4..8d8f2d5210 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -62,8 +62,9 @@ msgstr "%%c erwartet int oder char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" -msgstr "%d Adress-Pins und %d rgb-Pins zeigen eine Höhe von %d, nicht von %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" +msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -524,7 +525,6 @@ msgstr "Die Pufferlänge muss ein vielfaches von 512 sein" msgid "Buffer must be a multiple of 512 bytes" msgstr "Der Puffer muss ein vielfaches von 512 bytes sein" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" @@ -3800,6 +3800,10 @@ msgstr "Syntaxfehler in uctypes Deskriptor" msgid "threshold must be in the range 0-65536" msgstr "threshold muss im Intervall 0-65536 liegen" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() nimmt eine 9-Sequenz an" @@ -4092,6 +4096,10 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "" +#~ "%d Adress-Pins und %d rgb-Pins zeigen eine Höhe von %d, nicht von %d" + #~ msgid "input argument must be an integer or a 2-tuple" #~ msgstr "Das Eingabeargument muss eine Ganzzahl oder ein 2-Tupel sein" diff --git a/locale/el.po b/locale/el.po index cf1ae7cffb..04b63261ea 100644 --- a/locale/el.po +++ b/locale/el.po @@ -58,7 +58,8 @@ msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -516,7 +517,6 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -3714,6 +3714,10 @@ msgstr "" msgid "threshold must be in the range 0-65536" msgstr "" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" diff --git a/locale/es.po b/locale/es.po index 6c24698401..29b238768a 100644 --- a/locale/es.po +++ b/locale/es.po @@ -63,9 +63,9 @@ msgstr "%%c requiere int o char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" -"%d pines de dirección y %d pines rgb indican una altura de %d, no de %d" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -528,7 +528,6 @@ msgstr "El tamaño del búfer debe ser múltiplo de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Búfer deber ser un múltiplo de 512 bytes" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer debe ser de longitud 1 como minimo" @@ -3790,6 +3789,10 @@ msgstr "error de sintaxis en el descriptor uctypes" msgid "threshold must be in the range 0-65536" msgstr "limite debe ser en el rango 0-65536" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() toma un sequencio 9" @@ -4079,6 +4082,10 @@ 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 "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "" +#~ "%d pines de dirección y %d pines rgb indican una altura de %d, no de %d" + #~ msgid "Unknown failure" #~ msgstr "Fallo desconocido" diff --git a/locale/fil.po b/locale/fil.po index f277c784c5..2fdcd2f048 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -57,7 +57,8 @@ msgstr "%%c nangangailangan ng int o char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -521,7 +522,6 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer dapat ay hindi baba sa 1 na haba" @@ -3766,6 +3766,10 @@ msgstr "may pagkakamali sa sintaks sa uctypes descriptor" msgid "threshold must be in the range 0-65536" msgstr "ang threshold ay dapat sa range 0-65536" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() kumukuha ng 9-sequence" diff --git a/locale/fr.po b/locale/fr.po index 979fb201b3..1842d6d3e5 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -67,10 +67,9 @@ msgstr "%%c nécessite un chiffre entier 'int' ou un caractère 'char'" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" -"Les broches d'adresse %d et les broches RVB %d indiquent une hauteur de %d, " -"pas %d" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -533,7 +532,6 @@ msgstr "La longueur de la mémoire tampon doit être un multiple de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "La mémoire tampon doit être un multiple de 512" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Le tampon doit être de longueur au moins 1" @@ -3827,6 +3825,10 @@ msgstr "erreur de syntaxe dans le descripteur d'uctypes" msgid "threshold must be in the range 0-65536" msgstr "le seuil doit être dans la portée 0-65536" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() prend une séquence de longueur 9" @@ -4115,6 +4117,11 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "" +#~ "Les broches d'adresse %d et les broches RVB %d indiquent une hauteur de " +#~ "%d, pas %d" + #~ msgid "Unknown failure" #~ msgstr "Echec inconnu" diff --git a/locale/hi.po b/locale/hi.po index 902cd25564..88c82d4b80 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -58,7 +58,8 @@ msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -516,7 +517,6 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -3714,6 +3714,10 @@ msgstr "" msgid "threshold must be in the range 0-65536" msgstr "" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 58784a0631..b380b2fae1 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -57,7 +57,8 @@ msgstr "%%c necessita di int o char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -521,7 +522,6 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Il buffer deve essere lungo almeno 1" @@ -3774,6 +3774,10 @@ msgstr "errore di sintassi nel descrittore uctypes" msgid "threshold must be in the range 0-65536" msgstr "la soglia deve essere nell'intervallo 0-65536" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index 4169131d40..bae5704a12 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -63,7 +63,8 @@ msgstr "%%c にはintまたはcharが必要" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -523,7 +524,6 @@ msgstr "バッファ長は512の倍数でなければなりません" msgid "Buffer must be a multiple of 512 bytes" msgstr "バッファは512の倍数でなければなりません" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "バッファ長は少なくとも1以上でなければなりません" @@ -3745,6 +3745,10 @@ msgstr "uctypedディスクリプタの構文エラー" msgid "threshold must be in the range 0-65536" msgstr "threshouldは0から65536まで" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time()は9要素のシーケンスを受け取ります" diff --git a/locale/ko.po b/locale/ko.po index 13a1ea5d16..c284971af2 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -59,7 +59,8 @@ msgstr "%%c 전수(int)또는 캐릭터(char)필요합니다" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -519,7 +520,6 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "잘못된 크기의 버퍼. >1 여야합니다" @@ -3718,6 +3718,10 @@ msgstr "" msgid "threshold must be in the range 0-65536" msgstr "" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index c1c0eef266..2829bd9e89 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -61,8 +61,9 @@ msgstr "%%c vereist een int of char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" -msgstr "%d adres pins en %d RGB pins geven een hoogte van %d aan, niet %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" +msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -521,7 +522,6 @@ msgstr "Buffer lengte moet een veelvoud van 512 zijn" msgid "Buffer must be a multiple of 512 bytes" msgstr "Buffer moet een veelvoud van 512 bytes zijn" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer moet op zijn minst lengte 1 zijn" @@ -3778,6 +3778,10 @@ msgstr "syntaxisfout in uctypes aanduiding" msgid "threshold must be in the range 0-65536" msgstr "drempelwaarde moet in het bereik 0-65536 liggen" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() accepteert een 9-rij" @@ -4066,6 +4070,9 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "%d adres pins en %d RGB pins geven een hoogte van %d aan, niet %d" + #~ msgid "Unknown failure" #~ msgstr "Onbekende fout" diff --git a/locale/pl.po b/locale/pl.po index 66758b36aa..0c03a0ee0a 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -63,7 +63,8 @@ msgstr "%%c wymaga int lub char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -523,7 +524,6 @@ msgstr "Długość bufora musi być wielokrotnością 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Bufor musi być wielokrotnością 512 bajtów" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufor musi mieć długość 1 lub więcej" @@ -3737,6 +3737,10 @@ msgstr "błąd składni w deskryptorze uctypes" msgid "threshold must be in the range 0-65536" msgstr "threshold musi być w zakresie 0-65536" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() wymaga 9-elementowej sekwencji" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 84b3f55e54..3e397a0ed4 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -65,8 +65,9 @@ msgstr "%%c requer int ou char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" -msgstr "%d endereços dos pinos e %d pinos rgb indicam uma altura do %d, não %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" +msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -533,7 +534,6 @@ msgstr "O comprimento do Buffer deve ser um múltiplo de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "O buffer deve ser um múltiplo de 512 bytes" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "O comprimento do buffer deve ter pelo menos 1" @@ -3813,6 +3813,10 @@ msgstr "houve um erro de sintaxe no descritor uctypes" msgid "threshold must be in the range 0-65536" msgstr "Limite deve estar no alcance de 0-65536" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() leva uma sequência com 9" @@ -4101,6 +4105,10 @@ 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 "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "" +#~ "%d endereços dos pinos e %d pinos rgb indicam uma altura do %d, não %d" + #~ msgid "Unknown failure" #~ msgstr "Falha desconhecida" diff --git a/locale/sv.po b/locale/sv.po index f7d7c0108f..3aa0dcc1e7 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -65,8 +65,9 @@ msgstr "%%c kräver int eller char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" -msgstr "%d adresspinnar och %d RGB-pinnar indikerar en höjd av %d, inte %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" +msgstr "" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -525,7 +526,6 @@ msgstr "Buffertlängd måste vara en multipel av 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Bufferten måste vara en multipel av 512 byte" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufferten måste ha minst längd 1" @@ -3778,6 +3778,10 @@ msgstr "syntaxfel i uctypes deskriptor" msgid "threshold must be in the range 0-65536" msgstr "tröskelvärdet måste ligga i intervallet 0-65536" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() kräver en 9-sekvens" @@ -4066,6 +4070,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 "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "%d adresspinnar och %d RGB-pinnar indikerar en höjd av %d, inte %d" + #~ msgid "Unknown failure" #~ msgstr "Okänt fel" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 1bfa43b8d6..07e461bf89 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -66,9 +66,9 @@ msgstr "%%c xūyào zhěngshù huò char" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format -msgid "%d address pins and %d rgb pins indicate a height of %d, not %d" +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" -"%d dìzhǐ yǐn jiǎo hé %d rgb yǐn jiǎo jiāng gāodù biǎoshì wèi %d, ér bùshì %d" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -527,7 +527,6 @@ msgstr "Huǎn chōng qū cháng dù bì xū wéi 512 de bèi shù" msgid "Buffer must be a multiple of 512 bytes" msgstr "Huǎn chōng qū bì xū shì 512 zì jié de bèi shù" -#: shared-bindings/adafruit_bus_device/I2CDevice.c #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" @@ -3770,6 +3769,10 @@ msgstr "uctypes miáoshù fú zhōng de yǔfǎ cuòwù" msgid "threshold must be in the range 0-65536" msgstr "yùzhí bìxū zài fànwéi 0-65536" +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + #: shared-bindings/time/__init__.c msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() xūyào 9 xùliè" @@ -4058,6 +4061,11 @@ 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 "%d address pins and %d rgb pins indicate a height of %d, not %d" +#~ msgstr "" +#~ "%d dìzhǐ yǐn jiǎo hé %d rgb yǐn jiǎo jiāng gāodù biǎoshì wèi %d, ér bùshì " +#~ "%d" + #~ msgid "Unknown failure" #~ msgstr "Wèizhī gùzhàng" From 9325509b54c46a0e22f4b093b8b145ede8bf5161 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 27 Jan 2021 14:07:14 -0800 Subject: [PATCH 40/53] Fix blinka release PR language list --- tools/build_board_info.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 7b556ee5d2..70d5e2bc7a 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -271,6 +271,7 @@ def generate_download_info(): info = current_info[board] for version in info["versions"]: previous_releases.add(version["version"]) + previous_languages.update(version["languages"]) if version["stable"] == new_stable or ( new_stable and version["version"].startswith(this_version) ): From a54b57ea40739c53dc56ea5904da1931f71c71e7 Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 28 Jan 2021 15:15:15 +0530 Subject: [PATCH 41/53] watchdog implementation for rp2040 --- .../common-hal/microcontroller/__init__.c | 11 +++ .../common-hal/watchdog/WatchDogMode.c | 1 + .../common-hal/watchdog/WatchDogTimer.c | 83 +++++++++++++++++++ .../common-hal/watchdog/WatchDogTimer.h | 43 ++++++++++ .../common-hal/watchdog/__init__.c | 1 + ports/raspberrypi/mpconfigport.mk | 1 + 6 files changed, 140 insertions(+) create mode 100644 ports/raspberrypi/common-hal/watchdog/WatchDogMode.c create mode 100644 ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c create mode 100644 ports/raspberrypi/common-hal/watchdog/WatchDogTimer.h create mode 100644 ports/raspberrypi/common-hal/watchdog/__init__.c diff --git a/ports/raspberrypi/common-hal/microcontroller/__init__.c b/ports/raspberrypi/common-hal/microcontroller/__init__.c index e454ffa1b7..774e313bb4 100644 --- a/ports/raspberrypi/common-hal/microcontroller/__init__.c +++ b/ports/raspberrypi/common-hal/microcontroller/__init__.c @@ -112,6 +112,17 @@ const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = { }; #endif +#if CIRCUITPY_WATCHDOG +// The singleton watchdog.WatchDogTimer object. +watchdog_watchdogtimer_obj_t common_hal_mcu_watchdogtimer_obj = { + .base = { + .type = &watchdog_watchdogtimer_type, + }, + .timeout = 0.0f, + .mode = WATCHDOGMODE_NONE, +}; +#endif + // This maps MCU pin names to pin objects. const mp_rom_map_elem_t mcu_pin_global_dict_table[TOTAL_GPIO_COUNT] = { { MP_ROM_QSTR(MP_QSTR_GPIO0), MP_ROM_PTR(&pin_GPIO0) }, diff --git a/ports/raspberrypi/common-hal/watchdog/WatchDogMode.c b/ports/raspberrypi/common-hal/watchdog/WatchDogMode.c new file mode 100644 index 0000000000..fc4e0e008c --- /dev/null +++ b/ports/raspberrypi/common-hal/watchdog/WatchDogMode.c @@ -0,0 +1 @@ +// No watchdog module functions. diff --git a/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c b/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c new file mode 100644 index 0000000000..9184d1561a --- /dev/null +++ b/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c @@ -0,0 +1,83 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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/runtime.h" +#include "common-hal/watchdog/WatchDogTimer.h" + +#include "shared-bindings/watchdog/__init__.h" +#include "shared-bindings/microcontroller/__init__.h" + +#include "hardware/watchdog.h" + +void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { + watchdog_update(); +} + +void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) { + if (self->mode == WATCHDOGMODE_RESET) { + mp_raise_RuntimeError(translate("WatchDogTimer cannot be deinitialized once mode is set to RESET")); + } else { + self->mode = WATCHDOGMODE_NONE; + } +} + +/* +void watchdog_reset(void) { + common_hal_watchdog_deinit(&common_hal_mcu_watchdogtimer_obj); +} +*/ + +mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) { + return self->timeout; +} + +void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_float_t new_timeout) { + // max timeout is 8.388607 sec + // this is rounded down to 8.388 sec + uint64_t timeout = new_timeout * 1000; + if (timeout > 8388) { + mp_raise_ValueError(translate("timeout duration exceeded the maximum supported value")); + } + if ((uint16_t)self->timeout != timeout) { + watchdog_enable(timeout, false); + self->timeout = new_timeout; + } +} + +watchdog_watchdogmode_t common_hal_watchdog_get_mode(watchdog_watchdogtimer_obj_t *self) { + return self->mode; +} + +void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_watchdogmode_t new_mode) { + if (self->mode != new_mode) { + if (new_mode == WATCHDOGMODE_RAISE) { + mp_raise_NotImplementedError(translate("RAISE mode is not implemented")); + } else if (new_mode == WATCHDOGMODE_NONE) { + common_hal_watchdog_deinit(self); + } + self->mode = new_mode; + } +} diff --git a/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.h b/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.h new file mode 100644 index 0000000000..ec1e2f6592 --- /dev/null +++ b/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H +#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H + +#include "py/obj.h" +#include "shared-bindings/watchdog/WatchDogMode.h" +#include "shared-bindings/watchdog/WatchDogTimer.h" + +struct _watchdog_watchdogtimer_obj_t { + mp_obj_base_t base; + mp_float_t timeout; + watchdog_watchdogmode_t mode; +}; + +// This needs to be called in order to disable the watchdog +// void watchdog_reset(void); + +#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H diff --git a/ports/raspberrypi/common-hal/watchdog/__init__.c b/ports/raspberrypi/common-hal/watchdog/__init__.c new file mode 100644 index 0000000000..fc4e0e008c --- /dev/null +++ b/ports/raspberrypi/common-hal/watchdog/__init__.c @@ -0,0 +1 @@ +// No watchdog module functions. diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index 138896d41c..5c930d7cc8 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -36,6 +36,7 @@ CIRCUITPY_NVM = 0 CIRCUITPY_PULSEIO = 0 # Use PIO interally CIRCUITPY_ROTARYIO = 0 # Use PIO interally CIRCUITPY_RTC = 0 +CIRCUITPY_WATCHDOG = 1 # Things that are unsupported by the hardware. CIRCUITPY_AUDIOIO = 0 From 76256821ec2486b43a2eb405dcef10024a1fda4b Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Thu, 28 Jan 2021 20:02:00 +0530 Subject: [PATCH 42/53] add translations for raspberrypi port --- Makefile | 9 +-- locale/circuitpython.pot | 152 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 152 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 845997beb2..5857299c51 100644 --- a/Makefile +++ b/Makefile @@ -40,17 +40,18 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(BASEOPTS) # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(BASEOPTS) -TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/cxd56 ports/esp32s2 ports/mimxrt10xx ports/nrf ports/stm py shared-bindings shared-module supervisor +TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/cxd56 ports/esp32s2 ports/mimxrt10xx ports/nrf ports/raspberrypi ports/stm py shared-bindings shared-module supervisor # Paths to exclude from TRANSLATE_SOURCES # Each must be preceded by "-path"; if any wildcards, enclose in quotes. # Separate by "-o" (Find's "or" operand) TRANSLATE_SOURCES_EXC = -path "ports/*/build-*" \ -o -path "ports/*/build" \ - -o -path ports/esp32s2/esp-idf \ - -o -path ports/cxd56/spresense-exported-sdk \ - -o -path ports/stm/st_driver \ -o -path ports/atmel-samd/asf4 \ + -o -path ports/cxd56/spresense-exported-sdk \ + -o -path ports/esp32s2/esp-idf \ -o -path ports/mimxrt10xx/sdk \ + -o -path ports/raspberrypi/sdk \ + -o -path ports/stm/st_driver \ -o -path lib/tinyusb \ -o -path lib/lwip \ diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index de902f62fc..0220063353 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -339,6 +339,10 @@ msgstr "" msgid "All event channels in use" msgstr "" +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "All state machines in use" +msgstr "" + #: ports/atmel-samd/audio_dma.c ports/atmel-samd/common-hal/audiobusio/PDMIn.c msgid "All sync event channels in use" msgstr "" @@ -387,6 +391,7 @@ msgstr "" #: ports/cxd56/common-hal/analogio/AnalogOut.c #: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c #: ports/nrf/common-hal/analogio/AnalogOut.c +#: ports/raspberrypi/common-hal/analogio/AnalogOut.c msgid "AnalogOut functionality not supported" msgstr "" @@ -586,6 +591,7 @@ msgstr "" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c #: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c +#: ports/raspberrypi/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" msgstr "" @@ -863,7 +869,8 @@ msgstr "" msgid "Error: Failure to bind" msgstr "" -#: py/enum.c shared-bindings/_bleio/__init__.c shared-bindings/aesio/aes.c +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c py/enum.c +#: shared-bindings/_bleio/__init__.c shared-bindings/aesio/aes.c #: shared-bindings/busio/SPI.c shared-bindings/microcontroller/Pin.c #: shared-bindings/neopixel_write/__init__.c #: shared-bindings/terminalio/Terminal.c @@ -1045,6 +1052,10 @@ msgstr "" msgid "I2C Init Error" msgstr "" +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "I2C peripheral in use" +msgstr "" + #: shared-bindings/audiobusio/I2SOut.c msgid "I2SOut not available" msgstr "" @@ -1068,6 +1079,10 @@ msgstr "" msgid "Incorrect buffer size" msgstr "" +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Init program size invalid" +msgstr "" + #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" msgstr "" @@ -1080,6 +1095,31 @@ msgstr "" msgid "Input/output error" msgstr "" +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d jumps on pin" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d shifts in more bits than pin count" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d shifts out more bits than pin count" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d uses extra pin" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d waits on input outside of count" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c msgid "Insufficient authentication" msgstr "" @@ -1131,7 +1171,7 @@ msgstr "" #: ports/atmel-samd/common-hal/pwmio/PWMOut.c #: ports/cxd56/common-hal/pwmio/PWMOut.c ports/nrf/common-hal/pwmio/PWMOut.c -#: shared-bindings/pwmio/PWMOut.c +#: ports/raspberrypi/common-hal/pwmio/PWMOut.c shared-bindings/pwmio/PWMOut.c msgid "Invalid PWM frequency" msgstr "" @@ -1225,6 +1265,8 @@ msgstr "" #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/SPI.c msgid "Invalid pins" msgstr "" @@ -1346,6 +1388,36 @@ msgstr "" msgid "Missing MISO or MOSI Pin" msgstr "" +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_in_pin. Instruction %d reads pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_in_pin. Instruction %d shifts in from pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_in_pin. Instruction %d waits based on pin" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_out_pin. Instruction %d shifts out to pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_out_pin. Instruction %d writes pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_set_pin. Instruction %d sets pin(s)" +msgstr "" + #: shared-bindings/displayio/Group.c msgid "Must be a %q subclass." msgstr "" @@ -1399,14 +1471,14 @@ msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c -#: ports/stm/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "No RX pin" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/esp32s2/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c -#: ports/stm/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "No TX pin" msgstr "" @@ -1463,6 +1535,10 @@ msgstr "" msgid "No network with that ssid" msgstr "" +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "No out in program" +msgstr "" + #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" msgstr "" @@ -1518,6 +1594,10 @@ msgstr "" msgid "Only 8 or 16 bit mono with " msgstr "" +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Only IN/OUT of up to 8 supported" +msgstr "" + #: ports/esp32s2/common-hal/wifi/__init__.c msgid "Only IPv4 addresses supported" msgstr "" @@ -1590,6 +1670,7 @@ msgid "" msgstr "" #: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c +#: ports/raspberrypi/common-hal/displayio/ParallelBus.c #: ports/stm/common-hal/displayio/ParallelBus.c msgid "ParallelBus not yet supported" msgstr "" @@ -1602,11 +1683,20 @@ msgstr "" msgid "Permission denied" msgstr "" +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Pin count must be at least 1" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Pin count too large" +msgstr "" + #: ports/atmel-samd/common-hal/analogio/AnalogIn.c #: ports/cxd56/common-hal/analogio/AnalogIn.c #: ports/esp32s2/common-hal/analogio/AnalogIn.c #: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c #: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/raspberrypi/common-hal/analogio/AnalogIn.c #: ports/stm/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" msgstr "" @@ -1667,10 +1757,34 @@ msgstr "" msgid "Pretending to deep sleep until alarm, CTRL-C or file write.\n" msgstr "" +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Program does IN without loading ISR" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Program does OUT without loading OSR" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Program must contain at least one 16-bit instruction." +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Program size invalid" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Program too large" +msgstr "" + #: shared-bindings/digitalio/DigitalInOut.c msgid "Pull not used when direction is output." msgstr "" +#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c +msgid "RAISE mode is not implemented" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -1753,6 +1867,7 @@ msgstr "" #: ports/atmel-samd/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c msgid "SDA or SCL needs a pull up" msgstr "" @@ -1774,6 +1889,10 @@ msgstr "" msgid "SPI Re-initialization error" msgstr "" +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "SPI peripheral in use" +msgstr "" + #: shared-bindings/audiomixer/Mixer.c msgid "Sample rate must be positive" msgstr "" @@ -1804,6 +1923,14 @@ msgstr "" msgid "Server side context cannot have hostname" msgstr "" +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Set pin count must be between 1 and 5" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Side set pin count must be between 1 and 5" +msgstr "" + #: ports/cxd56/common-hal/camera/Camera.c msgid "Size not supported" msgstr "" @@ -1968,6 +2095,10 @@ msgstr "" msgid "UART Re-init error" msgstr "" +#: ports/raspberrypi/common-hal/busio/UART.c +msgid "UART not yet supported" +msgstr "" + #: ports/stm/common-hal/busio/UART.c msgid "UART write error" msgstr "" @@ -2072,7 +2203,8 @@ msgid "" msgstr "" #: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c -#: ports/esp32s2/common-hal/busio/UART.c ports/stm/common-hal/busio/I2C.c +#: ports/esp32s2/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/I2C.c ports/stm/common-hal/busio/I2C.c msgid "Unsupported baudrate" msgstr "" @@ -2123,6 +2255,7 @@ msgid "WARNING: Your code filename has two extensions\n" msgstr "" #: ports/nrf/common-hal/watchdog/WatchDogTimer.c +#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" msgstr "" @@ -3521,6 +3654,14 @@ msgstr "" msgid "pressing both buttons at start up.\n" msgstr "" +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "pull_threshold must be between 1 and 32" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "push_threshold must be between 1 and 32" +msgstr "" + #: extmod/modutimeq.c msgid "queue overflow" msgstr "" @@ -3724,6 +3865,7 @@ msgstr "" #: ports/esp32s2/common-hal/watchdog/WatchDogTimer.c #: ports/nrf/common-hal/watchdog/WatchDogTimer.c +#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "timeout duration exceeded the maximum supported value" msgstr "" From 0098909757c80e4e924b400b7b6f35319e0458a9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 28 Jan 2021 11:42:19 -0600 Subject: [PATCH 43/53] RGBMatrix: change default to serpentine=True The "serpentine" display order leads to much better wiring (shorter ribbon cables) and is preferred. Change the default accordingly. --- shared-bindings/rgbmatrix/RGBMatrix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 2a81bb53c2..30b72dffd6 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -132,7 +132,7 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ } } -//| def __init__(self, *, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: Sequence[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0, tile: int = 1, serpentine: bool = False) -> None: +//| def __init__(self, *, width: int, bit_depth: int, rgb_pins: Sequence[digitalio.DigitalInOut], addr_pins: Sequence[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0, tile: int = 1, serpentine: bool = True) -> None: //| """Create a RGBMatrix object with the given attributes. The height of //| the display is determined by the number of rgb and address pins and the number of tiles: //| ``len(rgb_pins) // 3 * 2 ** len(address_pins) * abs(tile)``. With 6 RGB pins, 4 @@ -185,7 +185,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_framebuffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, { MP_QSTR_height, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0 } }, { MP_QSTR_tile, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 1 } }, - { MP_QSTR_serpentine, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, + { MP_QSTR_serpentine, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = true } }, }; 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); From 65a883a74c0d423cd36ff392a9d02d7869470556 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 28 Jan 2021 13:01:11 -0600 Subject: [PATCH 44/53] bump esp-idf cache tag .. we are seeing failures that we have previously diagnosed as a bad cache. The github ui provides no way to update or delete a cache, so this is our workaround. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0dbccdf4dd..60244dae64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -467,7 +467,7 @@ jobs: id: idf-cache with: path: ${{ github.workspace }}/.idf_tools - key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210122 + key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210128 - name: Clone IDF submodules run: | (cd $IDF_PATH && git submodule update --init) From 689fba764a364a9284e80b59aa4b5dcc9e23c38c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 29 Jan 2021 09:45:00 -0600 Subject: [PATCH 45/53] ulab: update to 1.7.2 Closes #4086 --- extmod/ulab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extmod/ulab b/extmod/ulab index 8b804f3bcd..743d86487c 160000 --- a/extmod/ulab +++ b/extmod/ulab @@ -1 +1 @@ -Subproject commit 8b804f3bcd8c5a3ac1b3e09e0ff7faf8270751de +Subproject commit 743d86487c83e42024ed508ed50499ad0a527d5d From 66e0f2dcff75cebefa6a8cdc85169d21682b0032 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 29 Jan 2021 11:36:27 -0600 Subject: [PATCH 46/53] workflows: use actions/cache@v2 --- .github/workflows/build.yml | 2 +- .github/workflows/pre-commit.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60244dae64..644c67c69c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -462,7 +462,7 @@ jobs: - run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/* - name: CircuitPython version run: git describe --dirty --tags - - uses: actions/cache@v1 + - uses: actions/cache@v2 name: Fetch IDF tool cache id: idf-cache with: diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index af62072c89..76bfd7786b 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -21,7 +21,7 @@ jobs: run: git submodule update --init extmod/ulab - name: set PY run: echo >>$GITHUB_ENV PY="$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" - - uses: actions/cache@v1 + - uses: actions/cache@v2 with: path: ~/.cache/pre-commit key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} From 067f42b4f869b34a108ccd9bf6de049f928b10b5 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 29 Jan 2021 12:25:59 -0800 Subject: [PATCH 47/53] Add Gameduino 3X Dazzler support on raspberry_pi_pico Tested with hardware. Looks good. Follow on from #4054 --- ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk b/ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk index 69ff56fef8..54c1306606 100644 --- a/ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk +++ b/ports/raspberrypi/boards/raspberry_pi_pico/mpconfigboard.mk @@ -7,3 +7,5 @@ CHIP_VARIANT = RP2040 CHIP_FAMILY = rp2 INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY__EVE = 1 From acbf66dacc198588323d1887e2599acb5d71cf12 Mon Sep 17 00:00:00 2001 From: James Bowman Date: Fri, 29 Jan 2021 12:33:37 -0800 Subject: [PATCH 48/53] Make sys.platform "RP2040" on raspberrypi [#4091] --- ports/raspberrypi/mpconfigport.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/raspberrypi/mpconfigport.h b/ports/raspberrypi/mpconfigport.h index 7431519317..77d1ff0805 100644 --- a/ports/raspberrypi/mpconfigport.h +++ b/ports/raspberrypi/mpconfigport.h @@ -27,6 +27,8 @@ #ifndef __INCLUDED_MPCONFIGPORT_H #define __INCLUDED_MPCONFIGPORT_H +#define MICROPY_PY_SYS_PLATFORM "RP2040" + #define CIRCUITPY_INTERNAL_NVM_SIZE 0 #define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024) From 34fe152fcff402a71482e5866a0f840021b44eaa Mon Sep 17 00:00:00 2001 From: microDev <70126934+microDev1@users.noreply.github.com> Date: Sat, 30 Jan 2021 14:00:14 +0530 Subject: [PATCH 49/53] extend include path --- ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c b/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c index 9184d1561a..f23ccda777 100644 --- a/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c +++ b/ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c @@ -30,7 +30,7 @@ #include "shared-bindings/watchdog/__init__.h" #include "shared-bindings/microcontroller/__init__.h" -#include "hardware/watchdog.h" +#include "src/rp2_common/hardware_watchdog/include/hardware/watchdog.h" void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { watchdog_update(); From ddd516a6833aba684fa37a099da7e8646e2d375d Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 29 Jan 2021 16:40:49 -0500 Subject: [PATCH 50/53] Fix default timeout --- ports/esp32s2/common-hal/socketpool/Socket.c | 6 +++--- ports/esp32s2/common-hal/socketpool/SocketPool.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index 69ef41c6ec..fc50ca3ab2 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -135,7 +135,7 @@ socketpool_socket_obj_t* common_hal_socketpool_socket_accept(socketpool_socket_o while (newsoc == -1 && !timed_out && !mp_hal_is_interrupted()) { - if (self->timeout_ms != (uint)-1) { + if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) { timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; } RUN_BACKGROUND_TASKS; @@ -251,7 +251,7 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, while (received == -1 && !timed_out && !mp_hal_is_interrupted()) { - if (self->timeout_ms != (uint)-1) { + if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) { timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; } RUN_BACKGROUND_TASKS; @@ -362,7 +362,7 @@ mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* se while (received == -1 && !timed_out && !mp_hal_is_interrupted()) { - if (self->timeout_ms != (uint)-1) { + if (self->timeout_ms != (uint)-1 && self->timeout_ms != 0) { timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; } RUN_BACKGROUND_TASKS; diff --git a/ports/esp32s2/common-hal/socketpool/SocketPool.c b/ports/esp32s2/common-hal/socketpool/SocketPool.c index 5821728ce5..70a8b4eca5 100644 --- a/ports/esp32s2/common-hal/socketpool/SocketPool.c +++ b/ports/esp32s2/common-hal/socketpool/SocketPool.c @@ -77,6 +77,7 @@ socketpool_socket_obj_t* common_hal_socketpool_socket(socketpool_socketpool_obj_ sock->type = socket_type; sock->family = addr_family; sock->ipproto = ipproto; + sock->timeout_ms = (uint)-1; sock->tls = NULL; sock->ssl_context = NULL; From 0dbd3293a94e6f7ca6f0ad095c6834d801d726eb Mon Sep 17 00:00:00 2001 From: Patrick Van Oosterwijck Date: Sat, 30 Jan 2021 18:35:35 -0700 Subject: [PATCH 51/53] Add board Silicognition LLC M4-Shim --- .../boards/silicognition-m4-shim/board.c | 38 +++++++++++++ .../silicognition-m4-shim/mpconfigboard.h | 33 ++++++++++++ .../silicognition-m4-shim/mpconfigboard.mk | 14 +++++ .../boards/silicognition-m4-shim/pins.c | 54 +++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 ports/atmel-samd/boards/silicognition-m4-shim/board.c create mode 100644 ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/silicognition-m4-shim/pins.c diff --git a/ports/atmel-samd/boards/silicognition-m4-shim/board.c b/ports/atmel-samd/boards/silicognition-m4-shim/board.c new file mode 100644 index 0000000000..5fca974e9e --- /dev/null +++ b/ports/atmel-samd/boards/silicognition-m4-shim/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 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" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.h b/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.h new file mode 100644 index 0000000000..5028679edc --- /dev/null +++ b/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.h @@ -0,0 +1,33 @@ +#define MICROPY_HW_BOARD_NAME "Silicognition LLC M4-Shim" +#define MICROPY_HW_MCU_NAME "samd51j19" + +#define CIRCUITPY_MCU_FAMILY samd51 + +// Rev E + +#define MICROPY_HW_LED_STATUS (&pin_PA23) +#define MICROPY_HW_NEOPIXEL (&pin_PB03) + +// These are pins not to reset. +// QSPI Data pins +#define MICROPY_PORT_A (PORT_PA08 | PORT_PA09 | PORT_PA10 | PORT_PA11) +// QSPI CS, QSPI SCK and NeoPixel pin +#define MICROPY_PORT_B (PORT_PB03 | PORT_PB10 | PORT_PB11) +#define MICROPY_PORT_C (0) +#define MICROPY_PORT_D (0) + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_PA13) +#define DEFAULT_I2C_BUS_SDA (&pin_PA12) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA17) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB23) +#define DEFAULT_SPI_BUS_MISO (&pin_PB22) + +#define DEFAULT_UART_BUS_RX (&pin_PB17) +#define DEFAULT_UART_BUS_TX (&pin_PB16) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk b/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk new file mode 100644 index 0000000000..bf88cd52d0 --- /dev/null +++ b/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk @@ -0,0 +1,14 @@ +USB_VID = 0x1209 +USB_PID = 0xF500 +USB_PRODUCT = "M4-Shim" +USB_MANUFACTURER = "Silicognition LLC" + +CHIP_VARIANT = SAMD51J19A +CHIP_FAMILY = samd51 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICE_COUNT = 1 +EXTERNAL_FLASH_DEVICES = GD25Q16C +LONGINT_IMPL = MPZ + +CIRCUITPY_VECTORIO = 1 diff --git a/ports/atmel-samd/boards/silicognition-m4-shim/pins.c b/ports/atmel-samd/boards/silicognition-m4-shim/pins.c new file mode 100644 index 0000000000..b7afd044e9 --- /dev/null +++ b/ports/atmel-samd/boards/silicognition-m4-shim/pins.c @@ -0,0 +1,54 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PA02) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PA05) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_PB08) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_PB09) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_PA04) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_PA06) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_PA17) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB23) }, + { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_PB23) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_PB22) }, + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB17) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB17) }, + + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB16) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB16) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA16) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA18) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA19) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA20) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA21) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PB03) }, + + { 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_global_dict_table); From 414db718e45f3ee59083e211428da7aa0002faa9 Mon Sep 17 00:00:00 2001 From: Patrick Van Oosterwijck Date: Sat, 30 Jan 2021 19:17:20 -0700 Subject: [PATCH 52/53] Add board to github workflow --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 644c67c69c..b0f1dd1607 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -304,6 +304,7 @@ jobs: - "seeeduino_xiao" - "serpente" - "shirtty" + - "silicognition-m4-shim" - "simmel" - "snekboard" - "sparkfun_lumidrive" From 6dba7a146d806f09d90b1d3ceec4af699603605e Mon Sep 17 00:00:00 2001 From: Aditya Date: Wed, 6 Jan 2021 22:58:30 +0100 Subject: [PATCH 53/53] Add support for Lilygo TTGO T8 ESP32-S2 --- .github/workflows/build.yml | 1 + locale/circuitpython.pot | 1 + .../boards/lilygo_ttgo_t8_s2_st7789/board.c | 52 ++++++++++++++++++ .../lilygo_ttgo_t8_s2_st7789/mpconfigboard.h | 36 ++++++++++++ .../lilygo_ttgo_t8_s2_st7789/mpconfigboard.mk | 18 ++++++ .../boards/lilygo_ttgo_t8_s2_st7789/pins.c | 55 +++++++++++++++++++ .../boards/lilygo_ttgo_t8_s2_st7789/sdkconfig | 31 +++++++++++ 7 files changed, 194 insertions(+) create mode 100644 ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/board.c create mode 100644 ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h create mode 100644 ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.mk create mode 100644 ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/pins.c create mode 100644 ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/sdkconfig diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 644c67c69c..adf76f7aa9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -443,6 +443,7 @@ jobs: - "espressif_kaluga_1" - "espressif_saola_1_wroom" - "espressif_saola_1_wrover" + - "lilygo_ttgo_t8_s2_st7789" - "microdev_micro_s2" - "muselab_nanoesp32_s2" - "targett_module_clip_wroom" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index de902f62fc..c0aa893279 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -3504,6 +3504,7 @@ msgstr "" #: ports/esp32s2/boards/espressif_kaluga_1/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.h #: ports/esp32s2/boards/espressif_saola_1_wrover/mpconfigboard.h +#: ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/esp32s2/boards/microdev_micro_s2/mpconfigboard.h #: ports/esp32s2/boards/muselab_nanoesp32_s2/mpconfigboard.h #: ports/esp32s2/boards/targett_module_clip_wroom/mpconfigboard.h diff --git a/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/board.c b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/board.c new file mode 100644 index 0000000000..aaef97c7d1 --- /dev/null +++ b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/board.c @@ -0,0 +1,52 @@ +/* + * 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/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h new file mode 100644 index 0000000000..c9020c2002 --- /dev/null +++ b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h @@ -0,0 +1,36 @@ +/* + * 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 "LILYGO TTGO T8 ESP32-S2 w/Display" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#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 diff --git a/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.mk b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.mk new file mode 100644 index 0000000000..38a7ed1fb7 --- /dev/null +++ b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.mk @@ -0,0 +1,18 @@ +USB_VID = 0x303a +USB_PID = 0x8007 +USB_PRODUCT = "TTGO T8 ESP32-S2" +USB_MANUFACTURER = "LILYGO" +USB_DEVICES = "CDC,MSC,HID" + +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/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/pins.c b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/pins.c new file mode 100644 index 0000000000..bda0fd227a --- /dev/null +++ b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/pins.c @@ -0,0 +1,55 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_GPIO18) }, + + // SD Card + { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SD_CLK), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO10) }, + + // 1.14 inch LCD ST7789 + { MP_ROM_QSTR(MP_QSTR_LCD_MISO), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_LCD_BCKL), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_LCD_D_C), MP_ROM_PTR(&pin_GPIO37) }, + + // Peripheral Power control + { MP_ROM_QSTR(MP_QSTR_PE_POWER), MP_ROM_PTR(&pin_GPIO14) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/sdkconfig b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/sdkconfig new file mode 100644 index 0000000000..ce6fe832bf --- /dev/null +++ b/ports/esp32s2/boards/lilygo_ttgo_t8_s2_st7789/sdkconfig @@ -0,0 +1,31 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# 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_SPIWP_SD3_PIN=28 +CONFIG_SPIRAM_SPEED_40M=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +CONFIG_SPIRAM_USE_MALLOC=y +CONFIG_SPIRAM_MEMTEST=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="TTGO-T8-ESP32-S2" +CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y +# end of LWIP