[Microbit-Python] User modules?

Joe Glancy joe.t.glancy at gmail.com
Fri Feb 26 05:58:05 EST 2016


You can make your own modules in C/C++ using one of the existing modules as
guidance. It's (almost) as simple as creating a couple of files and adding
your module to a few files.

On Fri, 26 Feb 2016 9:37 am M.-A. Lemburg <mal at egenix.com> wrote:

> On 25.02.2016 20:33, Christopher Arndt wrote:
> > Is there any possibility to modularize MicroPython code for the
> micro:bit?
> >
> > Since there isn't a flash file system, I guess there's no way to store
> > user modules. Or is there a way to embed additional modules into the
> > firmware?
>
> We had discussed this a few weeks ago. It should be possible
> to the uflash tool to combine several modules into one and
> then playing a few tricks to get the namespaces right.
>
> MicroPython appears to be using classes for the module namespaces,
> so putting the code into a class wrapper appears to be a good
> solution for the namespaces:
>
> >>> import music
> >>> type(music)
> <class 'module'>
>
> All that said, I don't know how much flash memory is available
> for Python scripts, and of course, the memory constraints don't
> allow for many code objects to exist anyway. The 32kB retail
> version of the MB should reduce the latter problem a bit.
>
> Perhaps Cython could be used to compile Python modules into
> C and then have those added to the firmware when flashing the
> MB. That should reduce the code object overhead.
>
> --
> Marc-Andre Lemburg
> eGenix.com
>
> Professional Python Services directly from the Experts (#1, Feb 26 2016)
> >>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
> >>> Python Database Interfaces ...           http://products.egenix.com/
> >>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/
> ________________________________________________________________________
> 2016-02-19: Released eGenix PyRun 2.1.2 ...       http://egenix.com/go88
>
> ::: We implement business ideas - efficiently in both time and costs :::
>
>    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
>     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>            Registered at Amtsgericht Duesseldorf: HRB 46611
>                http://www.egenix.com/company/contact/
>                       http://www.malemburg.com/
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20160226/5863319e/attachment.html>


More information about the Microbit mailing list