Skip to content

Commit 2bff13d

Browse files
committed
bricks/stm32: require import from pybricks package
Previously, we were automatically importing classes from some modules to save space. However, this is too implicit and inconsistent with EV3 MicroPython. This brings in a MicroPython patch that fakes importing from the Pybricks package. This allows the first users to have a consistent experience until a real solution is implemented or until we revert to frozen .py dummy files to provide the package structure.
1 parent a3dd872 commit 2bff13d

File tree

2 files changed

+1
-32
lines changed

2 files changed

+1
-32
lines changed

bricks/stm32/main.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -190,28 +190,6 @@ static uint32_t get_user_program(uint8_t **buf, uint32_t *free_len) {
190190
return len;
191191
}
192192

193-
static void import_modules() {
194-
// Import hubs module
195-
pb_from_module_import_all(MP_QSTR_hubs);
196-
197-
// Import other modules if enabled
198-
#if PYBRICKS_PY_IODEVICES
199-
pb_from_module_import_all(MP_QSTR_iodevices);
200-
#endif
201-
#if PYBRICKS_PY_PUPDEVICES
202-
pb_from_module_import_all(MP_QSTR_pupdevices);
203-
#endif
204-
#if PYBRICKS_PY_PARAMETERS
205-
pb_from_module_import_all(MP_QSTR_parameters);
206-
#endif
207-
#if PYBRICKS_PY_TOOLS
208-
pb_from_module_import_all(MP_QSTR_tools);
209-
#endif
210-
#if PYBRICKS_PY_ROBOTICS
211-
pb_from_module_import_all(MP_QSTR_robotics);
212-
#endif
213-
}
214-
215193
static void run_user_program(uint32_t len, uint8_t *buf, uint32_t free_len) {
216194

217195
if (len == 0) {
@@ -221,14 +199,6 @@ static void run_user_program(uint32_t len, uint8_t *buf, uint32_t free_len) {
221199

222200
if (len == REPL_LEN) {
223201
#if MICROPY_ENABLE_COMPILER
224-
nlr_buf_t nlr;
225-
if (nlr_push(&nlr) == 0) {
226-
import_modules();
227-
nlr_pop();
228-
} else {
229-
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
230-
return;
231-
}
232202
pyexec_friendly_repl();
233203
#else
234204
mp_print_str(&mp_plat_print, "REPL not supported!\n");
@@ -254,7 +224,6 @@ static void run_user_program(uint32_t len, uint8_t *buf, uint32_t free_len) {
254224
mp_reader_new_mem(&reader, buf, len, free_len);
255225
mp_raw_code_t *raw_code = mp_raw_code_load(&reader);
256226
mp_obj_t module_fun = mp_make_function_from_raw_code(raw_code, MP_OBJ_NULL, MP_OBJ_NULL);
257-
import_modules();
258227
mp_call_function_0(module_fun);
259228
nlr_pop();
260229
} else {

micropython

0 commit comments

Comments
 (0)