Skip to content

Commit

Permalink
Merge pull request #21 from sourcebots/kch-support
Browse files Browse the repository at this point in the history
Add support for KCH boot progress leds
  • Loading branch information
WillB97 authored Jul 9, 2024
2 parents a788994 + 3059350 commit 2092ccc
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
8 changes: 8 additions & 0 deletions parts/files/leds/boot_40.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Boot Progress 40%
[Service]
Type=simple
ExecStart=/usr/bin/set-led 5 1

[Install]
WantedBy=basic.target
10 changes: 10 additions & 0 deletions parts/files/leds/boot_60.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Boot Progress 60%
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/set-led 12 1

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions parts/files/leds/boot_80.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Boot Progress 80%
BindsTo=runusb.service
After=runusb.service

[Service]
Type=forking
ExecStart=/usr/bin/set-led 6 1
ExecStop=/usr/bin/set-led 6 0
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
9 changes: 9 additions & 0 deletions parts/files/leds/set-led
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -ex

led_num="$1"
led_level="$2"

echo "$led_num" > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${led_num}/direction
echo "$led_level" > /sys/class/gpio/gpio5/value
echo "$led_num" > /sys/class/gpio/unexport
10 changes: 9 additions & 1 deletion parts/robot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ systemctl enable runusb.service
group=plugdev

# Remove a buggy udev package that breaks the USB tree if FTDI chips are plugged into too many USB hubs
# See https://github.com/raspberrypi/linux/issues/3779#issuecomment-709481662
# See https://github.com/raspberrypi/linux/issues/3779#issuecomment-709481662
# and https://groups.google.com/g/linux.debian.bugs.dist/c/5jI9dDZgfUU
apt-get remove -y rpi.gpio-common

Expand All @@ -53,3 +53,11 @@ SUBSYSTEM=="tty", DRIVERS=="ftdi_sio", ATTRS{interface}=="MCV4B", GROUP="$group"
# SR servo board v4
SUBSYSTEM=="usb", ATTRS{idVendor}=="1bda", ATTRS{idProduct}=="0011", GROUP="$group", MODE="0666"
EOF

# Setup KCH leds triggered by systemd
cp /tmp/packer-files/leds/set-led /usr/bin/
chmod +x /usr/bin/set-led
cp /tmp/packer-files/leds/*.service /lib/systemd/system/
systemctl enable boot_40.service
systemctl enable boot_60.service
systemctl enable boot_80.service

0 comments on commit 2092ccc

Please sign in to comment.