From e225a060cb0166f74fff0b784615fcf639ecf31a Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Thu, 5 Dec 2024 11:04:45 +0100 Subject: [PATCH 1/2] bricks/mpconfigport: Rename EXTRA_MOD to LEVEL1. Allows for additional features to be grouped as LEVEL2 on hubs with more space. --- bricks/_common/mpconfigport.h | 46 ++++++++++++++--------------- bricks/cityhub/mpconfigport.h | 3 +- bricks/debug/mpconfigport.h | 3 +- bricks/essentialhub/mpconfigport.h | 3 +- bricks/ev3/mpconfigport.h | 3 +- bricks/ev3rt/mpconfigport.h | 3 +- bricks/movehub/mpconfigport.h | 3 +- bricks/nxt/mpconfigport.h | 3 +- bricks/primehub/mpconfigport.h | 3 +- bricks/technichub/mpconfigport.h | 3 +- bricks/virtualhub/mpconfigvariant.h | 3 +- 11 files changed, 43 insertions(+), 33 deletions(-) diff --git a/bricks/_common/mpconfigport.h b/bricks/_common/mpconfigport.h index f4745042c..d345f4df3 100644 --- a/bricks/_common/mpconfigport.h +++ b/bricks/_common/mpconfigport.h @@ -15,15 +15,15 @@ #define MICROPY_ENABLE_COMPILER (PYBRICKS_OPT_COMPILER) // Enabled modules -#define MICROPY_PY_IO (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_IO (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_MATH (PYBRICKS_OPT_FLOAT) -#define MICROPY_PY_MICROPYTHON (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_STRUCT (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_SYS (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_MICROPYTHON (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_STRUCT (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_SYS (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_UERRNO (1) -#define MICROPY_PY_UJSON (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_URANDOM (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_USELECT (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_UJSON (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_URANDOM (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_USELECT (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_UERRNO_LIST \ X(EPERM) \ @@ -67,33 +67,33 @@ #define MICROPY_PY_ASYNC_AWAIT (1) #define MICROPY_MULTIPLE_INHERITANCE (0) #define MICROPY_PY_ARRAY (0) -#define MICROPY_PY_BUILTINS_BYTEARRAY (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_BUILTINS_BYTEARRAY (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_BUILTINS_MEMORYVIEW (0) -#define MICROPY_PY_BUILTINS_ENUMERATE (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_BUILTINS_ENUMERATE (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_BUILTINS_FILTER (0) #define MICROPY_PY_BUILTINS_FROZENSET (0) -#define MICROPY_PY_BUILTINS_HELP (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_BUILTINS_HELP_MODULES (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_BUILTINS_INPUT (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_BUILTINS_REVERSED (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_BUILTINS_SET (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_BUILTINS_SLICE (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_BUILTINS_HELP (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_BUILTINS_HELP_MODULES (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_BUILTINS_INPUT (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_BUILTINS_REVERSED (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_BUILTINS_SET (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_BUILTINS_SLICE (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_BUILTINS_PROPERTY (0) #define MICROPY_PY_BUILTINS_MIN_MAX (1) #define MICROPY_PY___FILE__ (0) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) -#define MICROPY_PY_GC (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_GC (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_ATTRTUPLE (0) #define MICROPY_PY_COLLECTIONS (0) #define MICROPY_PY_CMATH (0) -#define MICROPY_PY_ALL_SPECIAL_METHODS (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_ALL_SPECIAL_METHODS (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_SYS_EXIT (0) #define MICROPY_PY_SYS_MODULES (0) -#define MICROPY_PY_SYS_STDFILES (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_SYS_STDIO_BUFFER (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_SYS_STDIO_FLUSH (PYBRICKS_OPT_EXTRA_MOD) -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_PY_SYS_STDFILES (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_SYS_STDIO_BUFFER (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_SYS_STDIO_FLUSH (PYBRICKS_OPT_EXTRA_LEVEL1) +#define MICROPY_PY_URANDOM_EXTRA_FUNCS (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_URANDOM_SEED_INIT_FUNC ({ extern uint32_t pbdrv_clock_get_us(void); pbdrv_clock_get_us(); }) #define MICROPY_PY_UTIME_MP_HAL (0) #define MICROPY_MODULE_BUILTIN_INIT (1) @@ -110,7 +110,7 @@ #define MICROPY_ENABLE_SCHEDULER (0) #define MICROPY_PY_INSTANCE_ATTRS (1) -#define MICROPY_MODULE_ATTR_DELEGATION (PYBRICKS_OPT_EXTRA_MOD) +#define MICROPY_MODULE_ATTR_DELEGATION (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PERSISTENT_CODE_LOAD (1) #define MICROPY_ENABLE_EXTERNAL_IMPORT (0) #define MICROPY_HAS_FILE_READER (0) diff --git a/bricks/cityhub/mpconfigport.h b/bricks/cityhub/mpconfigport.h index 32b00c0c7..43296917c 100644 --- a/bricks/cityhub/mpconfigport.h +++ b/bricks/cityhub/mpconfigport.h @@ -52,7 +52,8 @@ #define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) -#define PYBRICKS_OPT_EXTRA_MOD (1) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (1) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (0) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) diff --git a/bricks/debug/mpconfigport.h b/bricks/debug/mpconfigport.h index 6a8cdf768..060f747bd 100644 --- a/bricks/debug/mpconfigport.h +++ b/bricks/debug/mpconfigport.h @@ -45,7 +45,8 @@ #define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (0) #define PYBRICKS_OPT_TERSE_ERR (1) -#define PYBRICKS_OPT_EXTRA_MOD (0) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (0) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (0) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) diff --git a/bricks/essentialhub/mpconfigport.h b/bricks/essentialhub/mpconfigport.h index b232c29bd..5708460d6 100644 --- a/bricks/essentialhub/mpconfigport.h +++ b/bricks/essentialhub/mpconfigport.h @@ -53,7 +53,8 @@ #define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) -#define PYBRICKS_OPT_EXTRA_MOD (1) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (1) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (1) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) diff --git a/bricks/ev3/mpconfigport.h b/bricks/ev3/mpconfigport.h index 5cb9075f2..58328517c 100644 --- a/bricks/ev3/mpconfigport.h +++ b/bricks/ev3/mpconfigport.h @@ -48,7 +48,8 @@ #define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (0) #define PYBRICKS_OPT_TERSE_ERR (0) -#define PYBRICKS_OPT_EXTRA_MOD (1) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (1) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (1) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) diff --git a/bricks/ev3rt/mpconfigport.h b/bricks/ev3rt/mpconfigport.h index fd2ddaded..28062b23c 100644 --- a/bricks/ev3rt/mpconfigport.h +++ b/bricks/ev3rt/mpconfigport.h @@ -52,7 +52,8 @@ #define PYBRICKS_OPT_RAW_REPL (1) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) -#define PYBRICKS_OPT_EXTRA_MOD (1) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (1) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (0) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (1) diff --git a/bricks/movehub/mpconfigport.h b/bricks/movehub/mpconfigport.h index 32a75ccfc..8deb45d0b 100644 --- a/bricks/movehub/mpconfigport.h +++ b/bricks/movehub/mpconfigport.h @@ -48,7 +48,8 @@ #define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (0) #define PYBRICKS_OPT_TERSE_ERR (1) -#define PYBRICKS_OPT_EXTRA_MOD (0) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (0) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (0) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) diff --git a/bricks/nxt/mpconfigport.h b/bricks/nxt/mpconfigport.h index 289b1adcf..2030ea5cf 100644 --- a/bricks/nxt/mpconfigport.h +++ b/bricks/nxt/mpconfigport.h @@ -51,7 +51,8 @@ #define PYBRICKS_OPT_RAW_REPL (1) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) -#define PYBRICKS_OPT_EXTRA_MOD (1) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (1) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (0) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) diff --git a/bricks/primehub/mpconfigport.h b/bricks/primehub/mpconfigport.h index 6ca0c5acb..3a7dd34c3 100644 --- a/bricks/primehub/mpconfigport.h +++ b/bricks/primehub/mpconfigport.h @@ -54,7 +54,8 @@ #define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) -#define PYBRICKS_OPT_EXTRA_MOD (1) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (1) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (1) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (1) diff --git a/bricks/technichub/mpconfigport.h b/bricks/technichub/mpconfigport.h index 4e8870081..0037196ff 100644 --- a/bricks/technichub/mpconfigport.h +++ b/bricks/technichub/mpconfigport.h @@ -52,7 +52,8 @@ #define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) -#define PYBRICKS_OPT_EXTRA_MOD (1) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (1) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (0) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) #define PYBRICKS_OPT_NATIVE_MOD (0) diff --git a/bricks/virtualhub/mpconfigvariant.h b/bricks/virtualhub/mpconfigvariant.h index f39bc50f9..954157c14 100644 --- a/bricks/virtualhub/mpconfigvariant.h +++ b/bricks/virtualhub/mpconfigvariant.h @@ -46,7 +46,8 @@ #define PYBRICKS_OPT_RAW_REPL (0) #define PYBRICKS_OPT_FLOAT (1) #define PYBRICKS_OPT_TERSE_ERR (0) -#define PYBRICKS_OPT_EXTRA_MOD (1) +#define PYBRICKS_OPT_EXTRA_LEVEL1 (1) +#define PYBRICKS_OPT_EXTRA_LEVEL2 (0) #define PYBRICKS_OPT_CUSTOM_IMPORT (1) // Upstream MicroPython options From 8137ff5e30545e998192af8247f568a8c096e8ca Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sun, 27 Oct 2024 15:20:19 -0500 Subject: [PATCH 2/2] bricks/_common/mpconfigport: Enable unicode. Enable MICROPY_PY_BUILTINS_STR_UNICODE on hubs with PYBRICKS_OPT_EXTRA_LEVEL2. Without this, there is not any difference between str and bytes, which can make it hard to work with multi-byte characters. --- CHANGELOG.md | 2 +- bricks/_common/mpconfigport.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 049ae0ce6..f906899b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ state. ### Changed - +- Enabled UTF-8 support for `str` objects. - The method `DriveBase.angle()` now returns a float ([support#1844]). This makes it properly equivalent to `hub.imu.heading`. - Re-implemented tilt using the gyro data by default. Pure accelerometer tilt diff --git a/bricks/_common/mpconfigport.h b/bricks/_common/mpconfigport.h index d345f4df3..4deebdc7f 100644 --- a/bricks/_common/mpconfigport.h +++ b/bricks/_common/mpconfigport.h @@ -80,6 +80,7 @@ #define MICROPY_PY_BUILTINS_SLICE (PYBRICKS_OPT_EXTRA_LEVEL1) #define MICROPY_PY_BUILTINS_PROPERTY (0) #define MICROPY_PY_BUILTINS_MIN_MAX (1) +#define MICROPY_PY_BUILTINS_STR_UNICODE (PYBRICKS_OPT_EXTRA_LEVEL2) #define MICROPY_PY___FILE__ (0) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_GC (PYBRICKS_OPT_EXTRA_LEVEL1)