MicroPython wrapper for Nim using the official embedding API
This module provides a clean, idiomatic Nim interface to MicroPython using the official embedding API from micropython/examples/embedding.
Basic usage:
import burrito/mpy var py = newMicroPython() defer: py.close() echo py.eval("print(2 + 3)") # Output: 5 echo py.eval("'Hello ' + 'World!'") # Output: Hello World!
REPL usage:
import burrito/mpy var py = newMicroPython() defer: py.close() echo "🌯 Burrito - MicroPython wrapper" py.startRepl() # Interactive REPL
Types
MicroPython = ref object
- Source Edit
Procs
proc close(py: MicroPython) {....raises: [], tags: [], forbids: [].}
- Clean up the MicroPython instance Source Edit
proc eval(py: MicroPython; code: string): string {....raises: [ValueError], tags: [], forbids: [].}
- Evaluate Python code and return any printed output Source Edit
proc evalBytecode(py: MicroPython; bytecode: openArray[uint8]): string {. ...raises: [ValueError], tags: [], forbids: [].}
- Execute pre-compiled MicroPython bytecode Source Edit
proc newMicroPython(heapSize: int = DEFAULT_HEAP_SIZE): MicroPython {. ...raises: [], tags: [], forbids: [].}
- Create a new MicroPython instance with the specified heap size Source Edit
proc nimStringToMP(py: MicroPython; s: string): pointer {....raises: [], tags: [], forbids: [].}
- Convert Nim string to MicroPython value (placeholder) Source Edit
proc startRepl(py: MicroPython) {....raises: [ValueError], tags: [WriteIOEffect, ReadIOEffect], forbids: [].}
- Start an interactive MicroPython REPL Source Edit
proc toNimString(py: MicroPython; val: pointer): string {....raises: [], tags: [], forbids: [].}
- Convert MicroPython value to Nim string (placeholder) Source Edit