Skip to main content

ACEMAGIC P9/P9 Plus (CH340) LED controller and pattern hacks

Project description

ACEMAGIC T9 Mini Computer LED Control

Rumor has it that when you don't immediately nuke the Windows off one of the ACEMAGIC mini computers, you have a utility to control all the flashy and colourful fadenlights. Smart and friendly people have looked at the serial stream and posted the command sequences, so luckily we don't need that bit of Windows bloatware to switch the LEDs off (athough with my box and I assume with most others, just unplugging the module would be no hassle either) -- but if you want to set it to rainbow at a certain speed or even make some dynamic use of the modes, then this should probably work with any ACEMAGIC box which has LED lighting that is connected over a CH340 or CH340 bridge, or probably any other UART interface.

Functionality

You get a CLI tool with commands

  • ledctl off
  • ledctl setmode {cycle,rainbow,breathing} [OPTIONS] (built-in LED controls)
  • ledctl setpattern {stillred,stillblue,breathered,alarm} [OPTIONS] (some hacks to add a few more, like red breathing of various speeds, and an alarm more. Be creative and add mode)
  • ledctl wiz (a small TUI menu to select or switch between modes quickly to test them)

I wonder why there are no plain colours built in, but at least we can simulate a still red light by restarting the cycle mode with 50 Hz, or the rainbow mode gives us a half blue / half purple light in this way, kind of pretty. The built-ins are mostly too colourful and too agitated, so I think these and the breathing red at different intensities are quite a plus if you want any LED at all. I would have just just switched them off, but I want to use this box for rsyslogging among other things, so I have a nice visual status indicator now. Some daemon fails somewhere in my LAN and the Ace informs me of the gravity of recent incidents by a series of increasingly irritating visual cues. Neat, eh?


Compatibility & Installation

The tool talks to the LED microcontroller over a USB-to-UART bridge. On ACEMAGIC T9 variants this is usually a WCH CH340/CH341. Could work on any similar device with some tweaks. Check compatibilty, then veify you have the right device, then if necessary change UART byte sequence -- but with any ACEMAGIC box with a similar kind of LED module, expect this to Just Work™.

  1. Install
pip install "acemagic-ledctl[ui]"   # or: pip install acemagic-ledctl
  1. (Once) ensure access
#### pick the group your distro uses; one of these is typical
sudo usermod -aG dialout "$USER"   # Debian/Ubuntu
#### or
sudo usermod -aG uucp "$USER"      # Arch/Slackware
newgrp dialout || newgrp uucp      # start a new shell with the group
  1. Run a command and try auto-detect
ledctl setmode rainbow
#### or
python -m ledctl setmode rainbow

If the LEDs change: you’re done.

  1. If auto-detect fails, select the port explicitly
#### Find a stable path:
ls -l /dev/serial/by-id/
#### Pick the entry that mentions WCH/USB-Serial/CH340 etc.

ledctl setmode cycle -b 1 -s 3 \
  --port /dev/serial/by-id/usb-... \
  --baud 10000 --dtr --no-rts --delay 0.005
  1. (Optional) make a stable alias /dev/ledctl
sudo tee /etc/udev/rules.d/99-ledctl.rules >/dev/null <<'RULE'
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="ledctl", GROUP="dialout", MODE="0660"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="5523", SYMLINK+="ledctl", GROUP="dialout", MODE="0660"
RULE
sudo udevadm control --reload
sudo udevadm trigger
#### then:
ledctl setmode breathing -p /dev/ledctl -B 10000 -t -R -d 0.005

How the tool picks a port

  • Tries known CH34x VID/PIDs first.
  • Falls back to the first /dev/ttyUSB*//dev/ttyACM*.
  • You can always override with --port. Prefer /dev/serial/by-id/... over /dev/ttyUSB0.

When you’ll need --port

  • You have multiple USB-UART adapters.
  • Your unit uses CP210x/FTDI/ACM instead of CH34x.
  • Hot-plug order changes across boots (tty index shifts).

Minimal verification (optional)

lsusb | grep -Ei '(1a86:7523|1a86:5523|wch|ch34)'   # CH340/CH341 present?
dmesg | grep -i ch341                                # driver attached? (ttyUSBn)

Tuning flags you might touch

  • -B/--baud10000 (device default here)
  • -t/--dtr and -R/--no-rts → defaults are DTR asserted, RTS deasserted
  • -d/--delay → inter-byte delay (default 0.005 s). If it’s sluggish, try 0.002; if unreliable, raise to 0.006–0.010.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acemagic_ledctl-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acemagic_ledctl-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file acemagic_ledctl-0.1.0.tar.gz.

File metadata

  • Download URL: acemagic_ledctl-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for acemagic_ledctl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 512c2cdfdd81dd3743b3628b54cb04d2fe2f02f29d8ae265a80e8e07573cf29b
MD5 844ada709ff609942adda177688945ea
BLAKE2b-256 c3fd12cf9d14d9b1441cb9dac8516274fa5cf89c8652a4d88e9bc5427ac1cd5f

See more details on using hashes here.

File details

Details for the file acemagic_ledctl-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for acemagic_ledctl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 113d50869a2f8feb2ef908f0d99dcd5a0e1ec45a25678f59880a261f9999cd00
MD5 87dadfa259d67ac494a33a3d38b4f872
BLAKE2b-256 e69ae9eed4dd9d282baf7d7b0a510cef30c2135858f8dff98d339062a33732f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page