Who had heard of it before?
And who used it before?
For something serious?
For something that is running right now?
MicroPython is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller.
Mainly due to RAM usage. Examples:
>>> print('Hello world!')
Hello world!
>>> with open('pygrunn.txt') as f:
>>> f.write('Hello PyGrunn!')
>>> try:
>>> 1/0
>>> except ZeroDivisionError as e:
>>> print("Oh, you!")
Oh, you!
>>> import functools
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'functools'
>>> import this
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: no module named 'this'
Specific ports provides specific hooks, REPL and custom modules
async def ping_pygrunn():
return await ping_server('pygrunn.org')
128kb ROM / 8kb RAM (after subtracting other software)
Around 280kb flash
Written in Python
$ micropython -m upip install micropython-functools
$ ./micropython
MicroPython v1.7-116-g8dd704b on 2016-04-19; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import functools
>>> dir(functools)
['__name__', 'reduce', 'partial', 'update_wrapper', '__file__', 'wraps']
https://github.com/micropython/micropython-lib
A tagged pointer is a pointer (concretely a memory address) with additional data associated with it
@micropython.asm_thumb
def led_on():
movwt(r0, stm.GPIOA)
movw(r1, 1 << 13)
strh(r1, [r0, stm.GPIO_BSRRL])
@micropython.native
def foo(self, arg):
# code
Roughly twice as fast, but larger binary
@micropython.viper
def foo(self, arg: int) -> int:
# code
Now actually called Zerynth and kind of confusing
Accerelometer, RTC, 4 LEDs, 2 switches, 30 GPIO
16kb RAM, 256kb flash, Cortex M0 @ 16 MHz
Supplied to 1 million school children
256kb RAM, 2Mb flash, 25 GPIO, Cortex M4 @ 80 MHz
“Small and light to fit in any cavity”
LoRa + Python
It depends on your board
But it's amazing for prototyping!
Or for embedding in games and apps
We have Python on microcontrollers.
And it works!
Questions?