modelImports
The main script imports a helper module placed next to it (addScriptDirToPath) and a module of a shared library in a separate folder (libraryPath)
Extends from Modelica.Icons.Example (Icon for runnable examples).
Information
Verification scenario 10 (see requirements.md): the main script import_demo.py imports two helper modules — companion.py, placed next to it in Resources/Scripts/MCU/ (made importable by addScriptDirToPath, enabled by default on MCU), and shared_helper.py, in the separate subfolder Resources/Scripts/MCU/lib/ (made importable through the libraryPath parameter of mcu, which points to it explicitly). If either import failed, the script would raise an uncaught ImportError and the simulation would stop with an error. led0/led1 confirm visually that both imports succeeded. Pins GP2-GP7, unused by this scenario, are left unconnected.
Components
| Type | Name | Default | Description |
|---|---|---|---|
| MCU | mcu | scriptPath = Resources/Scripts/MCU/import_demo.py, libraryPath = Resources/Scripts/MCU/lib/shared_helper.py (addScriptDirToPath keeps its default value, true) | |
| Modelica.Electrical.Analog.Basic.Ground | ground | ||
| Modelica.Electrical.Analog.Basic.Resistor | r0 | limits the current of led0 (GP0: import companion, same folder as the script) | |
| MicroPythonMCU.Peripherals.LED | led0 | GP0: import companion (addScriptDirToPath) | |
| Modelica.Electrical.Analog.Basic.Resistor | r1 | limits the current of led1 (GP1: import shared_helper, shared library) | |
| MicroPythonMCU.Peripherals.LED | led1 | GP1: import shared_helper (libraryPath) |