Framework Laptop 16 Input Module Firmware and Control Software

repository·main·Indexed 43 days ago

https://github.com/frameworkcomputer/inputmodule-rs

Firmware and control tools for Framework Laptop 16 input modules, including the B1 Display (4.2-inch mono-color screen), the C1 Minimal Input Module, and the LED Matrix (9x34 pixels). Provides the inputmodule-control CLI, a Python library, and bare-metal Rust firmware for RP2040-based modules to manage brightness, display patterns, images, and system statistics.

Tokens
20.1K
Snippets
72
Records
106
Agent score
55%

What's inside Framework Input Module

  1. Overview of the B1 Display

    main

    The B1 Display is a 4.2-inch, portrait-oriented, transmissive mono-color (black/white) screen with a resolution of 300x400px.

    Key Characteristics:

    • Framerate: Optimized for power at 1 FPS, but supports up to 32 FPS.
    • Image Retention: The panel is susceptible to image retention. To mitigate this, the display starts with a screensaver. Sending a command to draw content will exit the screensaver, but it will not automatically reappear after a timeout; it only reappears on power-on or after waking from sleep.
  2. Understand LED Matrix sleep behavior

    main

    Sleep mode turns off the LEDs and the LED controller. Transitions (turning on/off) are handled via slow fades.

    Triggers

    • Hardware/OS: The SLEEP# pin or USB Suspend. If USB suspends, the matrix turns off; if it resumes, the matrix wakes up.
    • Software/Firmware: Sending a sleep/wake command via USB Serial or the internal idle timer (default 60 seconds).

    Important Notes

    • Any command sent to the device will wake it up.
    • The sleep/wake command via USB cannot be received while the USB is suspended.
    • The idle timer is reset whenever the device wakes up or receives a new command.
  3. Understand the Flash Layout for Input Modules

    main

    The flash memory is 1MB in size, divided into 256 4K blocks. The layout varies depending on whether the module is an LED Matrix or a QMK Keyboard. The final 4K block is reserved for the Serial Number.

    LED Matrix Layout

    StartEndSizeName
    0x000000Dynamic~40KFirmware
    TBD0x0FF000TBDPersistent Storage
    0x0FF0000x1000004KSerial Number

    QMK Keyboard Layout

    StartEndSizeName
    0x000000Dynamic~60KFirmware
    0xef0000x0FF00016KPersistent Storage
    0x0FF0000x1000004KSerial Number
  4. Configure udev rules for Linux

    main

    To ensure the inputmodule-control application and other tools can access the input module's serial port on Linux, you must install the provided udev rules and reload the daemon.

    sudo cp release/50-framework-inputmodule.rules /etc/udev/rules.d/
    sudo udevadm control --reload && sudo udevadm trigger
  5. Build the inputmodule-control application

    main

    The inputmodule-control application can be built using cargo make. This requires pkg-config and libudev to be installed on your system.

    # Install build helper
    cargo install cargo-make --locked
    
    # Build the application
    cargo make --cwd inputmodule-control
    
    # Build and run to check version
    cargo make --cwd inputmodule-control run -- --version
  6. Update LED Matrix firmware

    main

    To update the firmware, you must first put the module into bootloader mode. You can do this by flipping DIP switch #2 on the hardware or by running:

    ledmatrixctl --bootloader

    Once in bootloader mode, the module will appear as a USB mass storage device (like a thumb drive). Copy your .uf2 firmware file onto the device; it will flash and reset automatically.

  7. Control the C1 Minimal LED Matrix

    main

    You can control the color and brightness of the onboard WS2812/Neopixel RGB LED using the ledmatrix_control.py utility.

    Available operations include:

    • Setting brightness (0-255).
    • Getting the current brightness.
    • Setting the color using standard color names (e.g., yellow).
    • Getting the current color in RGB:(R, G, B) format.
    # Set brightness to 255
    ./ledmatrix_control.py --brightness 255
    
    # Get current brightness
    ./ledmatrix_control.py --get-brightness
    
    # Set color to yellow
    ./ledmatrix_control.py --set-color yellow
    
    # Get current color
    ./ledmatrix_control.py --get-color
  8. Display System Status using lotus-smart-screen-python

    main

    You can display system statistics on the B1 Display using a fork of the Turing Smart Screen software called lotus-smart-screen-python.

    Setup:

    1. Install Python and the required dependencies.
    2. Run main.py from the repository.
    3. The config.yaml is pre-configured to auto-detect the display on Windows or Linux.

    Themes:

    • B1Terminal: Pre-configured with various system statistics.
    • B1Blank: Renders text from file1.txt onto the screen.

    Customization:

    • Change the background image in res/themes/{B1Blank,B1Terminal}/background.png.
    • Customize displayed statistics in res/themes/{B1Blank,B1Terminal}/theme.yaml.
    python main.py
  9. Use DIP switches for Bootloader and Debugging

    main

    Hardware versions since DVT2 (Sept 2023) include a two-switch DIP block.

    DIP2: Bootloader Mode

    To flash new firmware:

    1. Unplug the module.
    2. Flip DIP2 to ON.
    3. Plug the module back in; it will appear as a RPI-RP2 flash drive.
    4. Copy the .uf2 firmware file onto the drive. The device will flash and reappear as a drive.
    5. Unplug the module, flip DIP2 back to OFF, and plug it back in to run the new firmware.

    DIP1: Debug Mode

    When DIP1 is enabled, the module enters Debug Mode. In this mode:

    • The module will not turn off LEDs during sleep to save power.
    • Instead, it will display the reason for sleeping on the matrix:
      • SLP#: Triggered by the SLEEP# pin.
      • USB: Triggered by USB Suspend.
      • CMD: Triggered by a software command.
    • The module will not sleep based on the idle timer.