Add PCA9685 LED killer

sondehub
Mark Jessop 2023-04-23 15:23:29 +09:30
rodzic 7090ad2b05
commit da638dd61e
1 zmienionych plików z 40 dodań i 0 usunięć

40
tx/kill_leds.py 100644
Wyświetl plik

@ -0,0 +1,40 @@
#!/usr/bin/env python3
#
# PCA9685 LED Kill
#
# Shutdown all LEDs on a particular daughterboard in use in some Wenet Payloads
# that has 3x LEDs that are always powered up on boot...
#
# LEDs are attached to PCA9685 LED pins 0-8
#
# Dependencies:
# sudo pip3 install adafruit-circuitpython-pca9685
# Then enable I2C in raspi-config
#
# Add to /etc/rc.local to run on boot.
# python3 /home/pi/wenet/tx/kill_leds.py
from board import SCL, SDA
import busio
# Import the PCA9685 module.
from adafruit_pca9685 import PCA9685
ADDRESS = 0x55
LED_NUMBERS = [0,1,2,3,4,5,6,7,8]
LED_SETTING = 0xFFFF
# Create the I2C bus interface.
i2c_bus = busio.I2C(SCL, SDA)
# Create a simple PCA9685 class instance.
pca = PCA9685(i2c_bus,address=ADDRESS)
# Set the PWM frequency to 60hz.
pca.frequency = 60
# LEDs are low-side switched, to set to 0xFFFF to turn off completely.
for _led in LED_NUMBERS:
pca.channels[_led].duty_cycle = LED_SETTING
print("LEDs disabled.")