### Command: StartGame (0x10) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Starts an embedded game on the LED Matrix. ```APIDOC ## POST /command/startgame ### Description Starts an embedded game on the LED Matrix (L). ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **game_id** (byte) - The ID of the game to start. ### Request Example ```json { "command_id": 0x10, "parameters": [1] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Install and Use inputmodule Python Library CLI Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Instructions for installing the `inputmodule` Python library using pip and common command-line interface (CLI) commands for controlling LED matrix devices. These commands allow listing devices, setting brightness, displaying percentages, patterns, images, and checking firmware versions. ```bash # Install the library pip install inputmodule # CLI commands ledmatrixctl --list # List devices ledmatrixctl --brightness 128 # Set brightness ledmatrixctl --percentage 50 # Display percentage ledmatrixctl --pattern "All LEDs on" # Display pattern ledmatrixctl --image stripe.png # Display image ledmatrixctl --clock # Show time ledmatrixctl --version # Firmware version # Launch GUI ledmatrixctl --gui ledmatrixgui ``` -------------------------------- ### Install inputmodule Python library Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Installs the 'inputmodule' Python library using pip. Requires Python with pip to be pre-installed. ```shell python3 -m pip install inputmodule ``` -------------------------------- ### Build and Run Input Module Control Software Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/README.md Builds and runs the input module control software, displaying the tool version. This command assumes Cargo Make is installed and configured. ```shell > cargo make --cwd inputmodule-control run -- --version ``` -------------------------------- ### Launch Input Module Components Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Provides commands to launch the graphical user interface (GUI) or the command-line interface (CLI) of the input module after the virtual environment is activated. It also shows how to start a Python REPL and import the library to interact with it programmatically. ```bash # In every new shell, source the virtual environment source venv/bin/activate # Launch GUI or commandline ledmatrixgui ledmatrixctl # Launch Python REPL and import the library # As example, launch the GUI > python3 >>> from inputmodule import cli >>> cli.main_gui() ``` -------------------------------- ### Start Game of Life with Patterns (Command Line) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/ledmatrix/README.md Initiate Conway's Game of Life using the inputmodule-control command. You can start with the current matrix pattern or a predefined 'glider' pattern. ```sh # Start from the currently displayed pattern inputmodule-control led-matrix --start-game game-of-life --game-param current-matrix # Show two gliders that move forever inputmodule-control led-matrix --start-game game-of-life --game-param glider ``` -------------------------------- ### Install Python development dependencies on Ubuntu Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Installs necessary Python 3 and Tkinter dependencies for developing with the input module on Ubuntu systems. ```shell # Install dependencies on Ubuntu sudo apt install python3 python3-tk ``` -------------------------------- ### Control C1 Minimal RGB LED (Python) Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Allows control of the C1 Minimal module's RGB LED using Python functions. Includes setting colors, getting current color, and adjusting brightness. Requires finding the C1 Minimal device via serial ports. ```python from inputmodule.inputmodule.c1minimal import ( set_color, get_color, RGB_COLORS ) from inputmodule.inputmodule import brightness, get_brightness from serial.tools import list_ports # Find C1 Minimal device (PID 0x22) ports = list_ports.comports() dev = [p for p in ports if p.vid == 0x32AC and p.pid == 0x22][0] # Available colors print(RGB_COLORS) # ['white', 'black', 'red', 'green', 'blue', 'cyan', 'yellow', 'purple'] # Set LED color set_color(dev, "red") set_color(dev, "green") set_color(dev, "blue") set_color(dev, "yellow") set_color(dev, "cyan") set_color(dev, "purple") set_color(dev, "white") set_color(dev, "black") # LED off # Get current color as RGB tuple red, green, blue = get_color(dev) print(f"Current color: RGB({red}, {green}, {blue})") # Control brightnessrightness(dev, 255) # Full brightnessrightness(dev, 128) # Half brightnessrightness(dev, 0) # Off current = get_brightness(dev) print(f"Current brightness: {current}") ``` -------------------------------- ### Install Python development dependencies on Fedora Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Installs necessary Python 3 and Tkinter dependencies for developing with the input module on Fedora systems. ```shell # Install dependencies on Fedora sudo dnf install python3 python3-tkinter ``` -------------------------------- ### Run Snake and Pong Games (Python) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/ledmatrix/README.md Execute the Python script to start the Snake game or attempt to run the Pong game. Note that Pong may be non-functional. ```sh # Snake ./ledmatrix_control.py --snake # Pong (Seems broken at the moment) ./ledmatrix_control.py --pong-embedded ``` -------------------------------- ### Configure udev rules for Linux Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Copies the udev rule file to the system directory and reloads udev rules to ensure proper access to the input module's port on Linux systems. This is a one-time setup for Linux development. ```shell sudo cp release/50-framework-inputmodule.rules /etc/udev/rules.d/ sudo udevadm control --reload && sudo udevadm trigger ``` -------------------------------- ### Install Input Module in Editable Mode Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Installs the input module package in editable mode within the activated virtual environment. This allows for immediate reflection of code changes without reinstallation. ```bash python3 -m pip install -e . ``` -------------------------------- ### Control RGB LED Color and Brightness via Command Line Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/c1minimal/README.md This snippet demonstrates how to control the RGB LED on the C1 Minimal Input Module using the `ledmatrix_control.py` script. It shows commands for setting brightness, getting current brightness, setting color by name, and retrieving the current color in RGB format. No external dependencies are required beyond the script itself. ```sh > ./ledmatrix_control.py --brightness 255 > ./ledmatrix_control.py --get-brightness Current brightness: 255 > ./ledmatrix_control.py --set-color yellow > ./ledmatrix_control.py --get-color Current color: RGB:(255, 255, 0) ``` -------------------------------- ### Get LED Matrix firmware version Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Retrieves and displays the current firmware version of the LED Matrix device. This is useful for checking compatibility or debugging. ```shell > ledmatrixctl --version Device Version: 0.1.7 ``` -------------------------------- ### Get Firmware Version Response Format Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md This describes the byte format for the firmware version response from the input modules. It breaks down each byte to represent the major, minor, patch, and pre-release status of the firmware. ```text Byte 0: USB bcdDevice MSB Byte 1: USB bcdDevice LSB Byte 2: 1 if pre-release version, 0 otherwise +-- Major version | +-- Minor version | | +-- Patch version | | | +-- 1 if is pre-release, | | | | 0 otherwise MMMMMMMM mmmmPPPP 0000000p ``` -------------------------------- ### Build and Flash Firmware (Bash) Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Instructions for building and flashing firmware for RP2040-based input modules using the Rust toolchain. This is a command-line operation. ```bash # Build firmware # cargo build --release # Flash firmware (example using picotool) # picotool copy build/thumbv7m-none-eabi/release/inputmodule-rs output.uf2 ``` -------------------------------- ### Command: Bootloader (0x02) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Jumps to the bootloader on LED Matrix, B1 Display, or C1 Minimal Module. ```APIDOC ## POST /command/bootloader ### Description Causes the device (LED Matrix, B1 Display, or C1 Minimal Module) to jump to its bootloader. ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "command_id": 0x02, "parameters": [] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Enter Bootloader Mode (Hardware Steps) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/ledmatrix/README.md Instructions to enter bootloader mode for firmware updates. This involves manipulating a DIP switch and copying a firmware file. ```text 1. Unplug module and flip the switch to ON 2. Plug module back in, it will appear as a flash drive with the name `RPI-RP2` 3. Copy the firmware `.uf2` file onto that drive, it will automatically flash and reappear as a flash drive 4. To exit bootloader mode, unplug the module to flip the switch back, and plug it back in 5. Now the new firmware should be running ``` -------------------------------- ### Control c1-minimal Module Settings via CLI Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Command-line interface commands for the C1 Minimal module, focusing on controlling its RGB LED. This includes setting predefined colors, adjusting brightness, and entering the bootloader. No external dependencies are needed. ```bash # Set LED color (predefined colors) inputmodule-control c1-minimal --set-color red inputmodule-control c1-minimal --set-color green inputmodule-control c1-minimal --set-color blue inputmodule-control c1-minimal --set-color yellow inputmodule-control c1-minimal --set-color cyan inputmodule-control c1-minimal --set-color purple inputmodule-control c1-minimal --set-color white # Get current color inputmodule-control c1-minimal --get-color # Set brightness (0-255) inputmodule-control c1-minimal --brightness 128 # Get current brightness inputmodule-control c1-minimal --get-brightness # Enter bootloader inputmodule-control c1-minimal --bootloader ``` -------------------------------- ### Basic Input Module Control with Python Library Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Demonstrates basic usage of the `inputmodule` Python library for discovering connected devices and controlling fundamental module functionalities. It requires the `pyserial` library and the `inputmodule` library. Functions include finding devices, setting/getting brightness, retrieving firmware version, sending sleep commands, and initiating bootloader mode. ```python from serial.tools import list_ports from inputmodule.inputmodule import ( send_command, CommandVals, brightness, get_brightness, get_version, bootloader_jump, FWK_VID, INPUTMODULE_PIDS ) # Find connected input modules def find_devices(): ports = list_ports.comports() return [p for p in ports if p.vid == FWK_VID and p.pid in INPUTMODULE_PIDS] devices = find_devices() for dev in devices: print(f"Found: {dev.device} - {dev.product}") # Use the first device dev = devices[0] # Set and get brightnessrightness(dev, 128) current = get_brightness(dev) print(f"Brightness: {current}") # Get firmware version version = get_version(dev) print(f"Version: {version}") # Send sleep command send_command(dev, CommandVals.Sleep, [True]) # Check sleep state response = send_command(dev, CommandVals.Sleep, with_response=True) print(f"Sleeping: {bool(response[0])}") # Jump to bootloader for firmware update bootloader_jump(dev) ``` -------------------------------- ### Input Equalizer Visualization Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/ledmatrix/README.md Visualize audio input on the LED matrix using the `--input-eq` command. This requires compiling the `inputmodule-control` binary with the `audio-visualization` feature enabled. It leverages the cpal crate for audio input. ```bash # Compile with audio visualization feature cargo build --features audio-visualizations --target x86_64-unknown-linux-gnu -p inputmodule-control # Use the input equalizer inputmodule-control led-matrix --input-eq ``` -------------------------------- ### Check Device Firmware Version via Command Line Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/README.md Checks the firmware version of the input module device using the 'led-matrix --version' command. This is an in-band method for querying the device's current firmware. ```shell > inputmodule-control led-matrix --version Device Version: 0.2.0 ``` -------------------------------- ### List available LED Matrix devices Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Command to list all connected LED Matrix input modules. It shows device details like VID, PID, and Serial Number (SN). Useful when multiple devices are connected. ```shell > ledmatrixctl More than 1 compatible device found. Please choose with --serial-dev ... Example on Windows: --serial-dev COM3 Example on Linux: --serial-dev /dev/ttyACM0 /dev/ttyACM1 VID: 0x32AC PID: 0x0020 SN: FRAKDEBZ0100000000 Product: LED Matrix Input Module /dev/ttyACM0 VID: 0x32AC PID: 0x0020 SN: FRAKDEBZ0100000000 Product: LED Matrix Input Module ``` -------------------------------- ### Send Command to Input Module (Python) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md This Python function demonstrates how to send commands to input modules via a USB CDC-ACM serial port. It handles writing magic bytes, command ID, and parameters, with an option to receive a response. The example shows how to send a command to put the module to sleep and then check its sleep status. ```python import serial def send_command(command_id, parameters, with_response=False): with serial.Serial("/dev/ttyACM0", 115200) as s: s.write([0x32, 0xAC, command_id] + parameters) if with_response: res = s.read(32) return res # Go to sleep and check the status send_command(0x03, [True]) res = send_command(0x03, [], with_response=True) print(f"Is currently sleeping: {bool(res[0])}") ``` -------------------------------- ### Run Games and Animations on LED Matrix (Python) Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Enables running various games and animations on the LED Matrix module using Python. Includes functions for games like Snake and Pong, and animations like clock and equalizer. Requires finding the LED Matrix device via serial ports. ```python from inputmodule.games import ( snake, snake_embedded, pong_embedded, game_of_life_embedded, wpm_demo ) from inputmodule.gui.ledmatrix import random_eq, clock, blinking from inputmodule.inputmodule.ledmatrix import breathing from inputmodule.inputmodule import ( send_command, CommandVals, GameOfLifeStartParam, GameControlVal ) from serial.tools import list_ports # Find LED Matrix device ports = list_ports.comports() dev = [p for p in ports if p.vid == 0x32AC and p.pid == 0x20][0] # Play Snake game (host-side rendering) # snake(dev) # Uses keyboard input, blocks until game ends # Play Snake on the module (embedded) snake_embedded(dev) # Play Pong on the module pong_embedded(dev) # Play Game of Life with different starting patterns game_of_life_embedded(dev, GameOfLifeStartParam.Glider) game_of_life_embedded(dev, GameOfLifeStartParam.Blinker) game_of_life_embedded(dev, GameOfLifeStartParam.Beacon) game_of_life_embedded(dev, GameOfLifeStartParam.Currentmatrix) # Quit embedded game send_command(dev, CommandVals.GameControl, [GameControlVal.Quit]) # Game controls (for embedded games) send_command(dev, CommandVals.GameControl, [GameControlVal.Up]) send_command(dev, CommandVals.GameControl, [GameControlVal.Down]) send_command(dev, CommandVals.GameControl, [GameControlVal.Left]) send_command(dev, CommandVals.GameControl, [GameControlVal.Right]) # Animations and demos (run continuously until interrupted) # random_eq(dev) # Random equalizer animation # clock(dev) # Display current time, updates every second # blinking(dev) # Blink current pattern # breathing(dev) # Breathing brightness animation # wpm_demo(dev) # Words per minute typing demo ``` -------------------------------- ### Command: Version (0x20) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Retrieves the firmware version of the device. ```APIDOC ## GET /command/version ### Description Retrieves the firmware version of the LED Matrix, B1 Display, or C1 Minimal Module. ### Method Serial Read ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python res = send_command(0x20, [], with_response=True) # Process response based on version format ``` ### Response #### Success Response (200) - **firmware_version** (string) - The firmware version string, formatted as `MMMMMMMM.mmmm.PPPP-p` where: - `MMMMMMMM`: Major version - `mmmm`: Minor version - `PPPP`: Patch version - `p`: 1 if pre-release, 0 otherwise. #### Response Example ```json { "firmware_version": "1.2.3-0" } ``` ``` -------------------------------- ### Python Library Functions for LED Matrix Control Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Advanced usage of the `inputmodule` Python library for controlling LED matrix displays. This includes displaying percentages, various patterns, custom images (black/white and grayscale), text, symbols, equalizer visualizations, animations, and lighting specific LEDs. Requires `pyserial` and `inputmodule` libraries. Assumes a specific device VID/PID (0x32AC/0x20) for demonstration. ```python from inputmodule.inputmodule.ledmatrix import ( percentage, pattern, animate, get_animate, image_bl, image_greyscale, eq, breathing, show_string, show_symbols, all_brightnesses, render_matrix, light_leds ) # Find and use the first LED Matrix device from serial.tools import list_ports ports = list_ports.comports() dev = [p for p in ports if p.vid == 0x32AC and p.pid == 0x20][0] # Display percentage (0-100, fills from bottom) percentage(dev, 75) # Display built-in patterns pattern(dev, "All LEDs on") pattern(dev, "Gradient (0-13% Brightness)") pattern(dev, "Zigzag") pattern(dev, '"LOTUS" sideways') pattern(dev, "Checkerboard") # Display a black/white image (9x34 pixels) with open("image.png", "rb") as f: image_bl(dev, f) # Display a grayscale image with open("grayscale.gif", "rb") as f: image_greyscale(dev, f) # Display text (max 5 characters) show_string(dev, "HELLO") show_string(dev, "12345") # Display symbols with special characters show_symbols(dev, ["0", "degC", " ", "snow", ":)"]) show_symbols(dev, ["sun", "cloud", "rain"]) # Equalizer display (9 values, 0-34 each) eq(dev, [5, 10, 15, 20, 34, 20, 15, 10, 5]) # Control animation animate(dev, True) # Start scrolling animate(dev, False) # Stop scrolling is_animating = get_animate(dev) # Display all brightness levels (debug/demo) all_brightnesses(dev) # Light specific number of LEDs (0-306) light_leds(dev, 150) # Render custom matrix (9x34 grid, 0=off, non-zero=on) matrix = [[0 for _ in range(34)] for _ in range(9)] # Example: light_leds(dev, 150) would be equivalent to rendering a matrix # render_matrix(dev, matrix) # This function is not fully detailed in the provided text but is listed. ``` -------------------------------- ### Control B1 Display Module via CLI (Bash) Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt This command-line interface allows control over the B1 Display module, a 300x400 mono-color screen. It supports displaying images, setting screen patterns, and inverting screen colors. No specific dependencies beyond the `inputmodule-control` executable. ```bash # Display an image (300x400 pixels, PNG or GIF) inputmodule-control b1-display --image b1display.png # Set display pattern inputmodule-control b1-display --pattern white inputmodule-control b1-display --pattern black # Invert screen colors (dark mode) inputmodule-control b1-display --invert-screen true inputmodule-control b1-display --invert-screen false # Check inversion status inputmodule-control b1-display --invert-screen ``` -------------------------------- ### Launch LED Matrix graphical application Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Launches the graphical user interface for controlling the LED Matrix. This can be done either through the 'ledmatrixctl --gui' command or by running the standalone 'ledmatrixgui' application. ```shell # Either via the commandline ledmatrixctl --gui # Or using the standanlone application ledmatrixgui ``` -------------------------------- ### Control LED Matrix Module via CLI (Bash) Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt This command-line interface allows control over the LED Matrix module, supporting various display modes like patterns, images, animations, and games. It can also be used to retrieve module information and enter bootloader mode. No specific dependencies beyond the `inputmodule-control` executable. ```bash # List all connected input modules inputmodule-control --list # Set LED brightness (0-255) inputmodule-control led-matrix --brightness 128 # Get current brightness inputmodule-control led-matrix --brightness # Display a built-in pattern inputmodule-control led-matrix --pattern gradient inputmodule-control led-matrix --pattern zigzag inputmodule-control led-matrix --pattern all-on inputmodule-control led-matrix --pattern lotus-sideways # Display a percentage (progress indicator, 0-100) inputmodule-control led-matrix --percentage 75 # Display a custom string (max 5 chars, uppercase A-Z, 0-9) inputmodule-control led-matrix --string "HELLO" # Display symbols with special characters inputmodule-control led-matrix --symbols 0 degC ' ' snow ':)' # Display a black/white image (9x34 pixels, PNG or GIF) inputmodule-control led-matrix --image-bw stripe.gif # Display a grayscale image inputmodule-control led-matrix --image-gray grayscale.gif # Start vertical scrolling animation inputmodule-control led-matrix --animate true # Display random equalizer visualization inputmodule-control led-matrix --random-eq # Display custom equalizer (9 values) inputmodule-control led-matrix --eq 5 10 20 30 34 30 20 10 5 # Show current time (updates continuously) inputmodule-control led-matrix --clock # Start embedded games inputmodule-control led-matrix --start-game snake inputmodule-control led-matrix --start-game pong inputmodule-control led-matrix --start-game game-of-life --game-param glider inputmodule-control led-matrix --stop-game # Get firmware version inputmodule-control led-matrix --version # Enter bootloader for firmware update inputmodule-control led-matrix --bootloader # Target a specific device inputmodule-control --serial-dev /dev/ttyACM0 led-matrix --brightness 200 inputmodule-control --serial-dev COM5 led-matrix --pattern zigzag ``` -------------------------------- ### Command: Sleep/Wake (0x03) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Puts the device into or wakes it from sleep mode. ```APIDOC ## POST /command/sleep ### Description Controls the sleep state of the LED Matrix, B1 Display, or C1 Minimal Module. ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **sleep_state** (boolean) - `True` to enter sleep mode, `False` to wake up. ### Request Example ```json { "command_id": 0x03, "parameters": [true] } ``` ### Response #### Success Response (200) No response is typically returned when setting the sleep state. #### Response Example None ``` -------------------------------- ### Command: Brightness (0x00) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Sets the brightness of the LED Matrix or C1 Minimal Module. ```APIDOC ## POST /command/brightness ### Description Sets the brightness for the LED Matrix (L) or C1 Minimal Module (M). ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **brightness** (byte) - The desired brightness level (0-255). ### Request Example ```json { "command_id": 0x00, "parameters": [128] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Command: Pattern (0x01) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Displays a pattern on the LED Matrix. ```APIDOC ## POST /command/pattern ### Description Displays a predefined pattern on the LED Matrix (L). ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pattern_id** (byte) - The ID of the pattern to display. - `0x00`: Percentage (requires an additional parameter for percentage value) - `0x01`: Gradient (top to bottom) - `0x02`: DoubleGradient (middle to top and bottom) - `0x03`: DisplayLotusHorizontal - `0x04`: ZigZag - `0x05`: FullBrightness - `0x06`: DisplayPanic - `0x07`: DisplayLotusVertical - **pattern_parameter** (byte array) - Optional parameter for pattern 0x00 (percentage value). ### Request Example ```json { "command_id": 0x01, "parameters": [0x01] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Display image on LED Matrix Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Displays a PNG or GIF image on the LED Matrix. The command supports both static images and animated GIFs. Note that images are displayed in black and white or greyscale. ```shell # Draw PNG or GIF ledmatrixctl --image stripe.gif ledmatrixctl --image stripe.png ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md This snippet demonstrates how to create a Python virtual environment named 'venv' and activate it in the current shell. This is a standard practice for isolating project dependencies. ```bash python3 -m venv venv source venv/bin/activate ``` -------------------------------- ### Enter LED Matrix bootloader mode Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Puts the LED Matrix module into bootloader mode, allowing for firmware updates. This can be triggered by a DIP switch or by running the 'ledmatrixctl --bootloader' command. ```shell > ledmatrixctl --bootloader ``` -------------------------------- ### Control B1 Display via Command Line Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/b1display/README.md The `inputmodule-control` command-line tool allows for direct control of the B1 display. It supports various options to manage display status, sleep mode, bootloader access, and image display. Ensure the `inputmodule-control` binary is accessible in your system's PATH. ```bash > ./inputmodule-control b1-display B1 Display Usage: ipc b1-display [OPTIONS] Options: --sleeping [] Set sleep status or get, if no value provided [possible values: true, false] --bootloader Jump to the bootloader --panic Crash the firmware (TESTING ONLY!) -v, --version Get the device version --display-on [] Turn display on/off [possible values: true, false] --pattern Display a simple pattern [possible values: white, black] --invert-screen [] Invert screen on/off [possible values: true, false] --screen-saver [] Screensaver on/off [possible values: true, false] --fps [] Set/get FPS [possible values: quarter, half, one, two, four, eight, sixteen, thirty-two] --power-mode [] Set/get power mode [possible values: low, high] --animation-fps [] Set/get animation FPS --image Display a black&white image (300x400px) --animated-gif Display an animated black&white GIF (300x400px) --clear-ram Clear display RAM -h, --help Print help ``` -------------------------------- ### Control b1-display Module Settings via CLI Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Command-line interface commands to control the b1-display module. These commands manage display power, screen saver, FPS, power modes, and sleep states. They do not require external dependencies beyond the `inputmodule-control` tool. ```bash inputmodule-control b1-display --display-on true inputmodule-control b1-display --display-on false inputmodule-control b1-display --screen-saver true inputmodule-control b1-display --screen-saver false inputmodule-control b1-display --fps quarter # 0.25 FPS inputmodule-control b1-display --fps one # 1 FPS inputmodule-control b1-display --fps sixteen # 16 FPS inputmodule-control b1-display --power-mode low inputmodule-control b1-display --power-mode high inputmodule-control b1-display --sleeping true inputmodule-control b1-display --sleeping false inputmodule-control b1-display --version inputmodule-control b1-display --bootloader ``` -------------------------------- ### Command: GameStatus (0x12) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Checks the status of the current game on the LED Matrix. Marked as WIP. ```APIDOC ## GET /command/gamestatus ### Description Checks the status of the currently running game on the LED Matrix (L). This command is marked as Work In Progress (WIP) and its response format may change. ### Method Serial Read ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python res = send_command(0x12, [], with_response=True) # Process response based on WIP documentation ``` ### Response #### Success Response (200) - **status** (WIP) - The status of the game. The exact format is under development. #### Response Example (Example response format is not yet defined due to WIP status) ``` -------------------------------- ### Control B1 Display Functions (Python) Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Provides Python functions to control the B1 Display (300x400 mono display), including image display, power modes, screen settings, and text output. Requires finding the B1 Display device via serial ports. ```python from inputmodule.inputmodule.b1display import ( b1image_bl, display_on_cmd, invert_screen_cmd, screen_saver_cmd, set_fps_cmd, set_power_mode_cmd, get_fps_cmd, get_power_mode_cmd, display_string ) from serial.tools import list_ports # Find B1 Display device (PID 0x21) ports = list_ports.comports() dev = [p for p in ports if p.vid == 0x32AC and p.pid == 0x21][0] # Display a black/white image (300x400 pixels) with open("display_image.png", "rb") as f: b1image_bl(dev, f) # Control display power display_on_cmd(dev, True) # Turn on display_on_cmd(dev, False) # Turn off # Invert screen colors (dark mode) invert_screen_cmd(dev, True) # Invert on invert_screen_cmd(dev, False) # Invert off # Control screen saver screen_saver_cmd(dev, True) # Enable screen_saver_cmd(dev, False) # Disable # Set FPS (affects power consumption) set_fps_cmd(dev, "quarter") # 0.25 FPS (lowest power) set_fps_cmd(dev, "half") # 0.5 FPS set_fps_cmd(dev, "one") # 1 FPS (recommended) set_fps_cmd(dev, "two") # 2 FPS set_fps_cmd(dev, "four") # 4 FPS set_fps_cmd(dev, "eight") # 8 FPS set_fps_cmd(dev, "sixteen") # 16 FPS set_fps_cmd(dev, "thirtytwo") # 32 FPS (highest) # Set power mode set_power_mode_cmd(dev, "low") # Low power set_power_mode_cmd(dev, "high") # High power (for >8 FPS) # Get current settings get_fps_cmd(dev) # Prints current FPS get_power_mode_cmd(dev) # Prints current power mode # Display text on screen display_string(dev, "Hello World!") ``` -------------------------------- ### Control a specific LED Matrix device Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Applies a command, such as setting brightness percentage, to a specific LED Matrix device. Requires specifying the device using the --serial-dev option, which differs between Linux and Windows. ```shell # Example on Linux > ledmatrixctl --serial-dev /dev/ttyACM0 --percentage 33 # Example on Windows > ledmatrixctl --serial-dev COM5 --percentage 33 ``` -------------------------------- ### Command: Panic (0x05) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Causes a firmware panic/crash on the device. ```APIDOC ## POST /command/panic ### Description Intentionally causes a firmware panic/crash on the LED Matrix, B1 Display, or C1 Minimal Module for testing purposes. ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "command_id": 0x05, "parameters": [] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Command: DisplayOn (0x14) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Turns the B1 Display on or off. ```APIDOC ## POST /command/displayon ### Description Turns the B1 Display (D) on or off. ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **display_state** (boolean) - `True` to turn the display on, `False` to turn it off. ### Request Example ```json { "command_id": 0x14, "parameters": [true] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Command: GetAnimate (0x04) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Checks if the current pattern is animating on the LED Matrix. ```APIDOC ## GET /command/animate ### Description Queries whether the current pattern on the LED Matrix (L) is set to animate. ### Method Serial Read ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python res = send_command(0x04, [], with_response=True) print(f"Is animating: {bool(res[0])}") ``` ### Response #### Success Response (200) - **is_animating** (boolean) - `True` if animation is enabled, `False` otherwise. #### Response Example ```json { "is_animating": true } ``` ``` -------------------------------- ### General Command Structure Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Commands are sent by writing two magic bytes (0x32, 0xAC), the command ID, and any necessary parameters to the serial port. Some commands support responses. ```APIDOC ## General Command Structure ### Description Commands are sent via the USB CDC-ACM serial port. The structure of a command is: `[magic_byte_1, magic_byte_2, command_id, ...parameters]`. ### Method Serial Write ### Endpoint `/dev/ttyACM0` (example serial port) ### Parameters #### Magic Bytes - **0x32** (byte) - First magic byte - **0xAC** (byte) - Second magic byte #### Command ID - **command_id** (byte) - The ID of the command to execute. #### Parameters - **parameters** (byte array) - Optional parameters specific to each command. ### Request Example (Python) ```python import serial def send_command(command_id, parameters, with_response=False): with serial.Serial("/dev/ttyACM0", 115200) as s: s.write([0x32, 0xAC, command_id] + parameters) if with_response: res = s.read(32) return res ``` ### Response Some commands may return data. The format of the response depends on the specific command. ``` -------------------------------- ### Control LED Matrix via Commandline Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/ledmatrix/README.md The `inputmodule-control led-matrix` command provides a comprehensive interface for controlling the LED matrix. It allows setting brightness, sleep mode, displaying patterns, images, strings, and even running games. ```bash inputmodule-control led-matrix --percentage 30 inputmodule-control led-matrix --image-bw stripe.gif inputmodule-control led-matrix --image-gray grayscale.gif inputmodule-control led-matrix --random-eq inputmodule-control led-matrix --eq 1 2 3 4 5 4 3 2 1 inputmodule-control led-matrix --string "LOTUS" inputmodule-control led-matrix --symbols 0 degC ' ' snow ':)' ``` -------------------------------- ### Command: StageCol (0x07) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Sends a greyscale column to the LED Matrix. ```APIDOC ## POST /command/stagecol ### Description Sends a greyscale column to the LED Matrix (L). This command is marked as TODO in the documentation. ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **column_data** (byte array) - 1 + 34 bytes representing the greyscale column data. ### Request Example ```json { "command_id": 0x07, "parameters": [ ... 1 + 34 bytes of column data ... ] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Command: DrawBW (0x06) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Draws a black and white image on the LED Matrix. ```APIDOC ## POST /command/drawbw ### Description Draws a black and white image on the LED Matrix (L). This command is marked as TODO in the documentation, indicating potential for further clarification or changes. ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **image_data** (byte array) - 39 bytes representing the black and white image data. ### Request Example ```json { "command_id": 0x06, "parameters": [ ... 39 bytes of image data ... ] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Command: SetPxCol (0x16) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Sends a column of pixels to the B1 Display. Marked as TODO. ```APIDOC ## POST /command/setpxcol ### Description Sends a column of pixels to the B1 Display (D). This command is marked as TODO in the documentation. ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pixel_data** (byte array) - 50 bytes representing the pixel data for a column. ### Request Example ```json { "command_id": 0x16, "parameters": [ ... 50 bytes of pixel data ... ] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Display current time on LED Matrix Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Continuously displays the current time on the LED Matrix. This command keeps updating the display with the time. ```shell # Show current time and keep updating it ledmatrixctl --clock ``` -------------------------------- ### Draw Diagonal Line on LED Matrix Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Draws a diagonal line on the LED matrix by setting specific pixels to a color value. Requires a 'matrix' object and a 'render_matrix' function. ```python for i in range(9): matrix[i][i * 3] = 0xFF render_matrix(dev, matrix) ``` -------------------------------- ### Breathing Brightness Animation for LED Matrix Source: https://context7.com/frameworkcomputer/inputmodule-rs/llms.txt Initiates a breathing brightness animation on the LED Matrix. This function typically blocks until interrupted. ```python from inputmodule.inputmodule.ledmatrix import breathing # Find LED Matrix device from serial.tools import list_ports ports = list_ports.comports() dev = [p for p in ports if p.vid == 0x32AC and p.pid == 0x20][0] # Breathing brightness animation (runs continuously) breathing(dev) # Blocks until interrupted ``` -------------------------------- ### Command: SetColor (0x13) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Sets the color of the LED on the C1 Minimal Module. ```APIDOC ## POST /command/setcolor ### Description Sets the color of the LED on the C1 Minimal Module (M). ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **rgb_color** (byte array) - 3 bytes representing the RGB color (R, G, B). ### Request Example ```json { "command_id": 0x13, "parameters": [255, 0, 0] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Check firmware version via USB descriptor (Linux) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/python/README.md Checks the firmware version of the LED Matrix by inspecting its USB descriptor on Linux systems. It filters the output of 'lsusb -v' to show the device ID and the 'bcdDevice' field, which represents the firmware version. ```shell > lsusb -d 32ac: -v 2> /dev/null | grep -P 'ID 32ac|bcdDevice' Bus 003 Device 078: ID 32ac:0020 Framework Computer Inc LED Matrix Input Module bcdDevice 0.17 ``` -------------------------------- ### Command: FlushCols (0x08) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Flushes all columns to draw them on the LED Matrix. ```APIDOC ## POST /command/flushcols ### Description Flushes all previously staged columns to render them on the LED Matrix (L). ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "command_id": 0x08, "parameters": [] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Command: GameCtrl (0x11) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Sends a control command to an active game on the LED Matrix. ```APIDOC ## POST /command/gamectrl ### Description Sends a control command to the currently running game on the LED Matrix (L). ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **control_code** (byte) - The control code for the game. ### Request Example ```json { "command_id": 0x11, "parameters": [1] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Command: SetText (0x09) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Sets text on the B1 Display. Marked for removal. ```APIDOC ## POST /command/settext ### Description Sets text to be displayed on the B1 Display (D). This command is marked for removal and may not be functional or supported in future versions. ### Method Serial Write ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text_data** (byte array) - Data representing the text to display. ### Request Example ```json { "command_id": 0x09, "parameters": [ ... text data ... ] } ``` ### Response #### Success Response (200) No response is typically returned for this command. #### Response Example None ``` -------------------------------- ### Command: GetSleep (0x03) Source: https://github.com/frameworkcomputer/inputmodule-rs/blob/main/commands.md Checks the current sleep status of the device. ```APIDOC ## GET /command/sleep ### Description Queries the current sleep status of the LED Matrix, B1 Display, or C1 Minimal Module. ### Method Serial Read ### Endpoint `/dev/ttyACM0` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python res = send_command(0x03, [], with_response=True) print(f"Is currently sleeping: {bool(res[0])}") ``` ### Response #### Success Response (200) - **is_sleeping** (boolean) - `True` if the device is sleeping, `False` otherwise. #### Response Example ```json { "is_sleeping": true } ``` ```