Python App
The Python app provides an interactive Python REPL (Read-Eval-Print Loop) environment directly on your Mystrix device. This allows you to write and execute Python code in real-time, control LEDs, respond to keypresses, and access all MatrixOS APIs through the PikaPython interpreter.
To exit the Python app, hold down the Function Key (center key) for 3 seconds to return to the home screen. This emergency exit method works system-wide across all applications.
Featuresβ
- Interactive Python REPL: Write and execute Python code line by line
- MatrixOS API Access: Control LEDs, read keypads, send MIDI, use HID functions
- Persistent Session: Variables and functions remain in memory during your session
- Real-time Feedback: See immediate results from your code on the device
- Educational Tool: Perfect for learning Python and exploring MatrixOS capabilities
Getting Startedβ
Connecting via Serial Terminalβ
To use the Python REPL, you'll need a serial terminal application:
Windows Users:
- Download PuTTY: Get PuTTY from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
macOS/Linux Users:
Use the built-in screen
command or other terminal applications like minicom
2. Configure Connection:
- Connection type: Serial
- Serial line: Your device's COM port (e.g., COM3)
- Speed: 115200
- Important Terminal Settings:
- Go to Terminal β check "Implicit CR in every LF" - This is required for proper line endings
- Connect: Click "Open" to establish the connection
Basic Usageβ
- Enter the Python App: Select Python from the application launcher on your device
- Start Coding: The REPL will appear in your PuTTY terminal, ready to accept Python commands
- Execute Code: Type Python statements and press Enter to see immediate results
- Exit: Use python function
exit()
to return to application launcher, or hold the center key for 3 seconds to force exit
Quick Examplesβ
LED Controlβ
# Turn on an LED at position (3, 3) with red color
MatrixOS.LED.SetColor(Point(3, 3), Color(255, 0, 0), 255)
MatrixOS.LED.Update(255)
# Fill all LEDs with blue
MatrixOS.LED.Fill(Color(0, 0, 255), 255)
MatrixOS.LED.Update(255)
# Clear all LEDs
MatrixOS.LED.Fill(Color(0, 0, 0), 0)
MatrixOS.LED.Update(0)
Keypad Inputβ
while True:
event = MatrixOS.KeyPad.Get()
if event != None and event.State() == MatrixOS.KeyState.PRESSED:
print(f"Key pressed at ({event.xy.x}, {event.xy.y})")
Available APIsβ
For detailed documentation on all available Python APIs, see Python Application Development.
Comments