python3模块和cli工具控制cleware红绿灯
cleware-traffic-light的Python项目详细描述
Cleware红绿灯
cleware红绿灯一个用python3编写的易于使用的cli工具,用于控制cleware usb traffic light。 它支持多个红绿灯控制,并在您自己的python应用程序中用作模块。
用法
模块
fromtraffic_lightimportClewareTrafficLight,Color,StateClewareTrafficLight().red_on()ClewareTrafficLight().yellow_off()# with address for specific lightClewareTrafficLight(21).green_on()
cli
ctl --red on
ctl -r on
ctl --red on --green off
ctl --red off --green on --address 19
安装
使用pip安装cleware红绿灯
sudo pip3 install cleware-traffic-light
Linux
要将cli用作用户,首先必须创建usb规则
# go to directorycd /etc/udev/rules.d/ # create file with the rule vi 99-clewareampel.rules
内容
SUBSYSTEM=="usb", ATTR{idVendor}=="0d50", ATTR{idProduct}=="0008", MODE="666"
帮助
usage: ctl [-h][-r {on,off}][-y {on,off}][-g {on,off}][-a ADDRESS] Turns the led of the cleware traffic light on or off optional arguments: -h, --help show this help message and exit -r {on,off}, --red {on,off} Controlls the red led -y {on,off}, --yellow {on,off} Controlls the yellow led -g {on,off}, --green {on,off} Controlls the green led -a ADDRESS, --address ADDRESS Specifies which traffic light should be used