Created
November 12, 2025 01:04
-
-
Save twstokes/ca7761263df8466fd0bbcabfc5b1cad5 to your computer and use it in GitHub Desktop.
Juicy Crumb DockLite G4 Brightness Setter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # set_brightness.py | |
| # requires pyusb module | |
| # Usage: | |
| # python set_brightness.py 800 | |
| # python set_brightness.py 0x320 | |
| import sys, struct, usb.core, usb.util | |
| VID, PID = 0x4A43, 0x1D8A | |
| IFACE = 0 | |
| EP_OUT, EP_IN = 0x01, 0x82 | |
| TIMEOUT_MS = 500 | |
| def open_dev(): | |
| d = usb.core.find(idVendor=VID, idProduct=PID) | |
| if not d: | |
| sys.exit("Device 4a43:1d8a not found") | |
| try: | |
| if d.is_kernel_driver_active(IFACE): | |
| d.detach_kernel_driver(IFACE) | |
| except Exception: | |
| pass | |
| usb.util.claim_interface(d, IFACE) | |
| return d | |
| def main(): | |
| if len(sys.argv) != 2: | |
| print("Usage: python set_brightness.py <value>\n(e.g., 800 or 0x320)") | |
| sys.exit(1) | |
| value = int(sys.argv[1], 0) | |
| if not (0 <= value <= 0xFFFFFFFF): | |
| sys.exit("Value must be 0..0xFFFFFFFF") | |
| # Build the 5-byte payload: 0x07 + little-endian u32 | |
| payload = b"\x07" + struct.pack("<I", value) | |
| dev = open_dev() | |
| try: | |
| written = dev.write(EP_OUT, payload, TIMEOUT_MS) | |
| if written != len(payload): | |
| sys.exit(f"Short write: {written}/{len(payload)} bytes") | |
| # Optional: try to read an ACK; ignore timeout/errors | |
| try: | |
| _ = bytes(dev.read(EP_IN, 64, TIMEOUT_MS)) | |
| except Exception: | |
| pass | |
| print(f"Sent brightness: {value} -> {payload.hex()}") | |
| finally: | |
| try: usb.util.release_interface(dev, IFACE) | |
| except Exception: pass | |
| usb.util.dispose_resources(dev) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment