mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
84 lines
2.8 KiB
Python
84 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Isolate the exact LED command on G29
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import time
|
|
import fcntl
|
|
|
|
HIDIOCSFEATURE = lambda length: 0xC0004806 | (length << 16)
|
|
dev = '/dev/hidraw2'
|
|
|
|
def make_cmd(mask):
|
|
return bytes([0xF8, 0x12, mask, 0x00, 0x00, 0x00, 0x00])
|
|
|
|
candidates = {
|
|
# Key: (name, function(fd, mask))
|
|
"P1": ("P1: Raw 7 bytes on EP OUT (hidraw strip 0x00)",
|
|
lambda fd, m: os.write(fd, bytes([0x00]) + make_cmd(m))),
|
|
|
|
"P2": ("P2: 8 bytes avec 1-byte offset 0x00 (GIMX format)",
|
|
lambda fd, m: os.write(fd, bytes([0x00, 0x00]) + make_cmd(m))),
|
|
|
|
"P3": ("P3: Output Report 0x05 standard (32 octets)",
|
|
lambda fd, m: os.write(fd, bytes([0x05]) + make_cmd(m) + bytes([0x00]*24))),
|
|
|
|
"P4": ("P4: Output Report 0x05 avec offset 0x00 (32 octets)",
|
|
lambda fd, m: os.write(fd, bytes([0x05, 0x00]) + make_cmd(m) + bytes([0x00]*23))),
|
|
|
|
"P5": ("P5: Output Report 0x05 paddé à 64 octets",
|
|
lambda fd, m: os.write(fd, bytes([0x05]) + make_cmd(m) + bytes([0x00]*56))),
|
|
|
|
"P6": ("P6: Feature Report 0xF3 (7 octets payload)",
|
|
lambda fd, m: fcntl.ioctl(fd, HIDIOCSFEATURE(8), bytearray([0xF3]) + bytearray(make_cmd(m)))),
|
|
|
|
"P7": ("P7: Feature Report 0xF3 (offset 0x00)",
|
|
lambda fd, m: fcntl.ioctl(fd, HIDIOCSFEATURE(9), bytearray([0xF3, 0x00]) + bytearray(make_cmd(m)))),
|
|
|
|
"P8": ("P8: Feature Report 0xF0 (63 octets payload)",
|
|
lambda fd, m: fcntl.ioctl(fd, HIDIOCSFEATURE(64), bytearray([0xF0]) + bytearray(make_cmd(m)) + bytearray([0x00]*56))),
|
|
|
|
"P10": ("P10: Report 0x30 (64 octets)",
|
|
lambda fd, m: os.write(fd, bytes([0x30]) + make_cmd(m) + bytes([0x00]*56))),
|
|
}
|
|
|
|
if __name__ == '__main__':
|
|
if len(sys.argv) < 3:
|
|
print("Usage: python3 isolate_led.py <candidate P1..P10> <on|off|blink|chase>")
|
|
sys.exit(1)
|
|
|
|
cid = sys.argv[1].upper()
|
|
action = sys.argv[2].lower()
|
|
|
|
if cid not in candidates:
|
|
print(f"Candidat inconnu: {cid}. Choisis parmi {list(candidates.keys())}")
|
|
sys.exit(1)
|
|
|
|
name, func = candidates[cid]
|
|
print(f"Test de {name} -> Action: {action}")
|
|
fd = os.open(dev, os.O_RDWR)
|
|
|
|
if action == 'off':
|
|
func(fd, 0x00)
|
|
print("Envoyé: ÉTEINT (0x00)")
|
|
elif action == 'on':
|
|
func(fd, 0x1F)
|
|
print("Envoyé: TOUT ALLUMÉ (0x1F)")
|
|
elif action == 'blink':
|
|
print("Clignotement 3 fois...")
|
|
for _ in range(3):
|
|
func(fd, 0x1F)
|
|
time.sleep(0.3)
|
|
func(fd, 0x00)
|
|
time.sleep(0.3)
|
|
elif action == 'chase':
|
|
print("Chenillard (1 par 1)...")
|
|
# 0x01 (2 vertes), 0x03 (4 vertes), 0x07 (2 jaunes), 0x0F (4 jaunes), 0x1F (rouge)
|
|
for m in [0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00]:
|
|
func(fd, m)
|
|
time.sleep(0.15)
|
|
|
|
os.close(fd)
|