Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MP_REGISTER_MODULE with displayio, terminalio, and fontio #5221

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions py/circuitpy_mpconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,27 +412,18 @@ extern const struct _mp_obj_module_t digitalio_module;
#define DIGITALIO_MODULE
#endif

// CIRCUITPY_DISPLAYIO uses MP_REGISTER_MODULE
// CIRCUITPY_TERMINALIO uses MP_REGISTER_MODULE
// CIRCUITPY_FONTIO uses MP_REGISTER_MODULE

#if CIRCUITPY_DISPLAYIO
extern const struct _mp_obj_module_t displayio_module;
extern const struct _mp_obj_module_t fontio_module;
extern const struct _mp_obj_module_t terminalio_module;
#define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module },
#ifndef CIRCUITPY_DISPLAY_LIMIT
#define CIRCUITPY_DISPLAY_LIMIT (1)
#endif
#else
#define DISPLAYIO_MODULE
#define CIRCUITPY_DISPLAY_LIMIT (0)
#endif

#if CIRCUITPY_DISPLAYIO && CIRCUITPY_TERMINALIO
#define FONTIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_fontio), (mp_obj_t)&fontio_module },
#define TERMINALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_terminalio), (mp_obj_t)&terminalio_module },
#else
#define FONTIO_MODULE
#define TERMINALIO_MODULE
#endif

#if CIRCUITPY_DUALBANK
extern const struct _mp_obj_module_t dualbank_module;
#define DUALBANK_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_dualbank), (mp_obj_t)&dualbank_module },
Expand Down Expand Up @@ -886,7 +877,7 @@ extern const struct _mp_obj_module_t msgpack_module;
TIME_MODULE_ALT_NAME \

// This is an inclusive list that should correspond to the CIRCUITPY_XXX list above,
// including dependencies such as TERMINALIO depending on DISPLAYIO (shown by indentation).
// including dependencies (shown by indentation).
capellini marked this conversation as resolved.
Show resolved Hide resolved
// Some of these definitions will be blank depending on what is turned on and off.
// Some are omitted because they're in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS above.
#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \
Expand All @@ -912,10 +903,7 @@ extern const struct _mp_obj_module_t msgpack_module;
CANIO_MODULE \
COUNTIO_MODULE \
DIGITALIO_MODULE \
DISPLAYIO_MODULE \
DUALBANK_MODULE \
FONTIO_MODULE \
TERMINALIO_MODULE \
VECTORIO_MODULE \
ERRNO_MODULE \
ESPIDF_MODULE \
Expand Down
2 changes: 2 additions & 0 deletions shared-bindings/displayio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ const mp_obj_module_t displayio_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&displayio_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module, CIRCUITPY_DISPLAYIO);
2 changes: 2 additions & 0 deletions shared-bindings/fontio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ const mp_obj_module_t fontio_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&fontio_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_fontio, fontio_module, CIRCUITPY_DISPLAYIO && CIRCUITPY_TERMINALIO);
2 changes: 2 additions & 0 deletions shared-bindings/terminalio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ const mp_obj_module_t terminalio_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t *)&terminalio_module_globals,
};

MP_REGISTER_MODULE(MP_QSTR_terminalio, terminalio_module, CIRCUITPY_DISPLAYIO && CIRCUITPY_TERMINALIO);