-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Convert all circuitpython modules to use MP_REGISTER_MODULE #5183
Comments
@jepler I'd like to help with this. I've been experimenting with this using displayio and my pybadge. |
Convert from using MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS to using MP_REGISTER_MODULE for displayio, terminalio, and fontio modules. Related to adafruit#5183.
Convert adafruit_bus_device, adafruit_pixelbuf, analogio, atexit, audiobusio, audiocore, audioio, audiomixer, and audiomp3 modules to use MP_REGISTER_MODULE. Related to adafruit#5183.
I'm starting with the modules that are available on my pybadge, using the test procedure outlined here. I'm keeping track of the modules as I go. Once I'm done with the pybadge, I'll move to my adafruit funhouse, which has a few more (e.g. wifi, ipaddress). |
@jepler Quick question about the bitmaptools module. I'm used to seeing the globals table for each module define a circuitpython/shared-bindings/bitbangio/__init__.c Lines 72 to 79 in fa63a41
However, I don't see that in the bitmaptools globals table: circuitpython/shared-bindings/bitmaptools/__init__.c Lines 580 to 587 in fa63a41
Also, on the TTY terminal, an >>> import bitmaptools
>>> bitmaptools.__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute '__name__' Should I include: { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bitmaptools) }, in the |
I also noticed the |
I think I also found some code duplication: circuitpython/py/circuitpy_mpconfig.h Lines 440 to 446 in 41168c8
and circuitpython/py/circuitpy_mpconfig.h Lines 504 to 510 in 41168c8
It's safe to remove one of these, correct? |
I believe so, yes. |
…lio, framebufferio, frequencyio, gamepadshift, getpass, keypad, math, microcontroller, and msgpack modules to use MP_REGISTER_MODULE. Related to adafruit#5183.
Convert bitbangio, bitmaptools, _bleio, board, busio, countio, digitalio, framebufferio, frequencyio, gamepadshift, getpass, keypad, math, microcontroller, and msgpack modules to use MP_REGISTER_MODULE. Related to adafruit#5183.
Convert neopixel_write, onewireio, ps2io, pulseio, pwmio, rainbowio, random, rgbmatrix, rotaryio, rtc, sdcardio, sharpdisplay, _stage, storage, struct, supervisor, synthio, touchio, traceback, usb_cdc, usb_hid, usb_midi, and vectorio modules to use MP_REGISTER_MODULE. Related to adafruit#5183.
Convert _eve, _pew, aesio, alarm, audiopwmio, bitops, camera, canio, dualbank, gnss, i2cperipheral, imagecapture, ipaddress, memorymonitor, sdioio, socketpool, ssl, uheap, ustack, watchdog, and wifi modules to use MP_REGISTER_MODULE. Related to adafruit#5183.
Convert _eve, _pew, aesio, alarm, audiopwmio, bitops, camera, canio, dualbank, gnss, i2cperipheral, imagecapture, ipaddress, memorymonitor, sdioio, socketpool, ssl, uheap, ustack, watchdog, and wifi modules to use MP_REGISTER_MODULE. Related to adafruit#5183.
I think that I've now converted all modules in shared bindings that have a
There are seven more modules defined in
I started to register these with |
@capellini I'm "out of the office" so I can't look into it in detail right now. If you want to try to PR just one of those changes, perhaps someone else can review it and give useful feedback. @tannewt do you know why those modules are different, or if we need to handle the situation differently? |
The other four are micropython modules that we reorganized into shared-bindings. I'm not sure
|
This can reduce the amount of boilerplate required. Instead of introducing a macro such as
QRIO_MODULE
dependent onCIRCUITPY_QRIO
and then adding an expansion of it inMICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS
, one simply writes in the bindings__init__.c
file:where the first item is the module name as a qstr, the second item is the module's globals, and the third is the preprocessor macro that expands to (1) when enabled.
This can be done on a piecemail basis, and this bug would be closed once the last one is completed. I didn't prepare a checklist here, but basically everything in shared-bindings should be done unless a reason not to is identified.
Besides reducing boilerplate slightly, it also eases including modules with no hardware dependency in the "unix" build, which enables them to be testable. In time, such testability could be applied to bitmaptools and atexit, to name just two examples.
The text was updated successfully, but these errors were encountered: