Framework Laptop 16 Input Module Firmware and Control Software
repository·main·Indexed 43 days ago
https://github.com/frameworkcomputer/inputmodule-rsFirmware 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.
What's inside Framework Input Module
- The C1 Minimal Input Module is a highly stripped-down input module designed for extensibility. It features exposed GPIO pins suitable for soldering headers and includes dedicated pads for a WS2812/Neopixel compatible RGB LED. Upon boot, the onboard LED defaults to a green color.
Overview of the B1 Display
mainThe 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.
Understand LED Matrix sleep behavior
mainSleep 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.
- Hardware/OS: The
Understand the Flash Layout for Input Modules
mainThe 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
Start End Size Name 0x000000Dynamic ~40K Firmware TBD 0x0FF000TBD Persistent Storage 0x0FF0000x1000004K Serial Number QMK Keyboard Layout
Start End Size Name 0x000000Dynamic ~60K Firmware 0xef0000x0FF00016K Persistent Storage 0x0FF0000x1000004K Serial Number Reference the QT PY RP2040 hardware capabilities
mainThe QT PY RP2040 reference firmware provides the following hardware interfaces:
- GPIO: General Purpose Input/Output pins.
- WS2812/Neopixel RGB LED: An addressable RGB LED that can be controlled via software commands.
Configure udev rules for Linux
mainTo ensure the
inputmodule-controlapplication and other tools can access the input module's serial port on Linux, you must install the providedudevrules and reload the daemon.sudo cp release/50-framework-inputmodule.rules /etc/udev/rules.d/ sudo udevadm control --reload && sudo udevadm triggerBuild the inputmodule-control application
mainThe
inputmodule-controlapplication can be built usingcargo make. This requirespkg-configandlibudevto 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 -- --versionUpdate LED Matrix firmware
mainTo 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 --bootloaderOnce in bootloader mode, the module will appear as a USB mass storage device (like a thumb drive). Copy your
.uf2firmware file onto the device; it will flash and reset automatically.Control the C1 Minimal LED Matrix
mainYou can control the color and brightness of the onboard WS2812/Neopixel RGB LED using the
ledmatrix_control.pyutility.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-colorDisplay System Status using lotus-smart-screen-python
mainYou can display system statistics on the B1 Display using a fork of the Turing Smart Screen software called
lotus-smart-screen-python.Setup:
- Install Python and the required dependencies.
- Run
main.pyfrom the repository. - The
config.yamlis pre-configured to auto-detect the display on Windows or Linux.
Themes:
B1Terminal: Pre-configured with various system statistics.B1Blank: Renders text fromfile1.txtonto 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.pyUse DIP switches for Bootloader and Debugging
mainHardware versions since DVT2 (Sept 2023) include a two-switch DIP block.
DIP2: Bootloader Mode
To flash new firmware:
- Unplug the module.
- Flip DIP2 to ON.
- Plug the module back in; it will appear as a
RPI-RP2flash drive. - Copy the
.uf2firmware file onto the drive. The device will flash and reappear as a drive. - 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 theSLEEP#pin.USB: Triggered by USB Suspend.CMD: Triggered by a software command.
- The module will not sleep based on the idle timer.
Launch the Graphical Application
mainYou can use the LED Matrix via a GUI in two ways:
- Via CLI: Run
ledmatrixctl --gui. - Standalone: Run the
ledmatrixguicommand directly.
ledmatrixctl --gui # OR ledmatrixgui- Via CLI: Run