Code your application (Python)
Python support and Matrix OS API is in preview release for OS 3.0. We welcome community to play when them and report back any issue they see with them.
Writing Python Apps
There are two ways to use Python for MatrixOS:
Method 1: Python REPL - Testing & experimenting
Use the Python app in the application launcher to access a Python REPL through USB serial. This is great for testing and rapid prototyping.
Method 2: Standalone Application - For saving and sharing
Create a standalone Python application by placing your files in the device storage. This is great for saving your work and share with others.
A Micro SD card must be installed in your device to use standalone Python applications. See Install Micro SD Card for installation instructions.
Creating a Standalone Application
File Structure
Place your application files in the device storage:
/MatrixOS/Applications/<appname>/
Your application folder must contain:
- Your Python script files (
.py) - An
AppInfo.jsonconfiguration file
AppInfo.json
The AppInfo.json file defines your application's metadata:
{
"name": "Hello World",
"author": "203 System",
"color": [255, 0, 0],
"version": 1,
"osMinimalVer": [3, 0, 0],
"appMainFile": "HelloWorld.py"
}
Required fields:
name: Your application's display nameauthor: Your name or organizationcolor: RGB color array [R, G, B] for the app icon (0-255)version: Application version numberosMinimalVer: Minimum MatrixOS version required [major, minor, patch]appMainFile: The main Python file to execute (can be.pyfor source code or.py.afor compiled Python code)
Clear Compiled Byte Code
Matrix OS will auto pick compiled bytecode over raw .py files. So if you updated the .py file, make sure to delete the /MatrixOS/Applications/<appname>/pikapython-api folder to force recompile.
Example Applications
For App examples, see: https://github.com/203-Systems/Matrix-OS-Python-App-Examples
Comments