LED Matrix Modules

I have the LED Matrix modules but am struggling to get them to work. I’ve downloaded a project from github but I can’t get it to work. The python script that is I think official is really bad. I don’t know exactly what I want to do with them, but it would be nice to at least have them on! Thanks

I tried this one: GitHub - FrameworkComputer/inputmodule-rs: Framework Laptop 16 Input Module SW/FW

I’ve been using this to make use of my Matrix modules. I rather like the at-a-glance for my system status.

It’s all written in python, so you can tweak and modify it as you see fit. It’s also robust enough that, with it running as a system service all the time, you can remove and reinstall the modules whenever (I sometimes swap in my numpad when working) and they begin reporting again properly right away.

A script to display battery percentage, quick and dirty:

#!/usr/bin/env python

import time
import serial

bat_dir = '/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:4b/PNP0C0A:00/power_supply/BAT1'
W = 9
H = 34

def send_command(command_id, parameters, with_response=False):
    with serial.Serial('/dev/ttyACM1', 115200 * 8) as s:
        s.write([0x32, 0xAC, command_id] + parameters)

        if with_response:
            res = s.read(32)
            return res

def read_i(name):
    try:
        with open(name) as f:
            return int(f.read())
    except:
        return 0

def read_als() -> int:
    with open('/sys/bus/platform/drivers/hid_sensor_als/HID-SENSOR-200041.11.auto/iio:device0/in_illuminance_raw') as f:
        return int(f.read())

class Bitmap:
    def __init__(self):
        self.bitmap = [0] * 39

    def clear(self):
        self.bitmap = [0] * 39

    def set_pixel(self, x, y):
        i = x + W * y
        self.bitmap[i//8] |= 1 << (i % 8)

i = 0
while 1:
    batt_c_now = read_i(bat_dir + '/charge_now') / 1000000
    batt_c_full = read_i(bat_dir + '/charge_full') / 1000000
    v = batt_c_now / batt_c_full
    b = Bitmap()
    for x in range(W):
        for y in range(H):
            if (x  + y * W) <= v * H * W:
                b.set_pixel(x, y)


    als = read_als()
    brightness = min(30, max(1, int(als/10)))
    if v < 0.1:
        brightness = 100 if i % 2 else 1

    print(als, brightness, v)
    send_command(0x00, [brightness])
    send_command(0x06, b.bitmap)
    time.sleep(2)
    i += 1