USB controller for my monitor LED strip.
- Warm/Cool/Brightness control
- Persistent storage in flash
- Timed protection from extended high power use
- Control via a USB HID device
- Mbed 6.x
- STM32F3
- Light and Gesture Sensor: APDS 9960
- LED warmth control based on time of day.
- Match LEDs to PC Sleep and Inactivity states.
- Tray Icon & Flyout
- WinUI 3 XAML UI
- Windows App SDK Packaged App
# Setup permissions
sudo tee /etc/udev/rules.d/60-leds.rules <<'STOP'
# HID for LEDs (not used in container)
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05df", \
TAG+="uaccess"
# STLink v2
# From https://github.com/stlink-org/stlink/blob/master/config/udev/rules.d/49-stlinkv2-1.rules
# Used in container, no acl (uaccess)
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374a", \
MODE:="0666", \
SYMLINK+="stlinkv2-1_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \
MODE:="0666", \
SYMLINK+="stlinkv2-1_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3752", \
MODE:="0666", \
SYMLINK+="stlinkv2-1_%n"
STOP
# Reload
sudo udevadm control --reload-rules && sudo udevadm trigger
sudo tee /etc/systemd/system/leds-on.service <<'STOP'
[Unit]
Description=LEDs on
After=suspend.target
After=hibernate.target
[Service]
Type=oneshot
StandardOutput=journal
ExecStart=/usr/bin/python3 /home/haves/Projects/LEDs/led_controller/misc/usb_test.py on
[Install]
WantedBy=multi-user.target
WantedBy=suspend.target
WantedBy=hibernate.target
STOP
sudo tee /etc/systemd/system/leds-off.service <<'STOP'
[Unit]
Description=LEDs off
Before=suspend.target
Before=hibernate.target
Before=poweroff.target
DefaultDependencies=no
[Service]
Type=oneshot
StandardOutput=journal
ExecStart=/usr/bin/python3 /home/haves/Projects/LEDs/led_controller/misc/usb_test.py off
[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=poweroff.target
STOP
sudo systemctl enable --now leds-on
sudo systemctl enable leds-off
# Turn on
hidapitester --vidpid 16C0/05DF --open \
-l 17 --send-output 0,1,0x90,0x12,0xE7,0x66,0x00,0x00,0x00,0x00,1,0,1,0xFF,0xFF,0xFF,0xFF \
-l 16 --read-input 0
# Get
hidapitester --vidpid 16C0/05DF --open \
-l 17 --send-output 0,0,0x90,0x12,0xE7,0x66,0x00,0x00,0x00,0x00,1,0,1,0xFF,0xFF,0xFF,0xFF \
-l 16 --read-input 0
# Notifications
hidapitester --vidpid 16C0/05DF --open \
-l 16 -t 10000 --read-input 0
# Set Light Sensor Range
hidapitester --vidpid 16C0/05DF --open \
-l 17 --send-output 0,2,0x00,0x80,0x00,0x40,0,0,0,0,0,0,0,0,0,0,0 \
-l 16 --read-input 0
Launch and build directly from vscode.
- Jumpers in normal position:
- JP1 removed.
- ST-LINK both populated.
- JP5 populated in 2-3 (E5V).
- Connect main USB port & power supply.
- LD3 solid, LD1 blinking.
- Connect USB debug CN1.
- Device reset and LD1 solid.
Use cmake flash-leds target, or copy to storage device.
screen /dev/ttyACM0 115200
Leave a Reply