控制USB连接的LED灯,就像人一样。

busylight-for-humans的Python项目详细描述


BusyLight Project Logo

Python 3.7 TestPython 3.8 TestPython 3.9 Test

BusyLight for Humans™使您可以控制USB连接的LED 各种各样的小贩送来的灯。灯光可以通过 命令行,使用httpapi或直接导入到自己的命令行中 python项目。需要一盏灯让你知道什么时候有个主人,或者 什么时候狗想出去?一盏指示“请勿打扰”的灯怎么样?在

这种可能性是无限的。在

All Supported Lights

从后到前,从左到右
BlyncLight、BlyncLight Plus、Busylight
闪烁(1)、标志、闪烁棒

特点

  • 通过Command-Line控制灯
  • 通过Web API控制灯
  • 支持来自五家供应商的光源
    • 敏捷创新
    • Embrava Blynclight公司
    • 宽多商务灯
    • 卢萨福旗
    • ThingM闪烁1
  • 支持MacOS,Linux,可能还有Windows和BSD!在
  • 广泛测试树莓皮3b+,零W和4

基本安装

$ python3 -m pip install busylight-for-humans 

Web API安装

除了busylight,还安装uvicorn和{}:

^{pr2}$

Linux安装后活动

Linux通过udev子系统控制对USB设备的访问,默认情况下拒绝非root用户访问它无法识别的设备。我掩护你!在

配置udev规则时需要具有root权限:

$ busylight udev-rules -o 99-busylights.rules
$ sudo cp 99-busylights.rules /etc/udev/rules.d
$ sudo udevadm control -R
$# unplug/plug your light$ busylight on

命令行示例

$ busylight on               # light turns on green$ busylight on red           # now it's shining a friendly red$ busylight on 0xff0000      # still red$ busylight on #00ff00       # now it's blue!$ busylight blink            # it's slowly blinking on and off with a red color$ busylight blink green fast # blinking faster green and off$ busylight --all on         # turn all lights on green$ busylight --all off        # turn all lights off

HTTP API示例

首先启动busylightAPI服务器:

$ busylight serve
INFO:     Started server process [20189]INFO:     Waiting for application startup.INFO:     Application startup complete.INFO:     Uvicorn running on http://0.0.0.0:8888 (Press CTRL+C to quit)

API已经有了完整的文档并且可以在@

现在,您可以使用返回JSON有效负载的web API端点:

  $ curl http://localhost:8888/1/lights
  $ curl http://localhost:8888/1/lights/on
  $ curl http://localhost:8888/1/lights/off
  $ curl http://localhost:8888/1/light/0/on/purple
  $ curl http://localhost:8888/1/light/0/off
  $ curl http://localhost:8888/1/lights/on
  $ curl http://localhost:8888/1/lights/off
  $ curl http://localhost:8888/1/lights/rainbow

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java从JSP或HTML向servlet发送多个参数   java方法来查看字符是否在字符数组中   使用带有java的MAC地址连接到设备   java如何将csv文件中的数据打印到secondactivity?   java如何从netbean 7.0.1连接到数据库   java考虑所有可能的类值,用于输出测试分割的预测值。   java我的actionListener调用有什么问题   swing在Java中实现粒子过滤器最有效的方法是什么?   java运行。getFontFamily()为返回null。使用apachepoi的docx文件   一个事务中的java领域循环与每个步骤循环中的一个事务   java日期格式与Spring Boot不兼容   java类冲突。处理   java GridBagLayout不工作   java将图像发送到另一个应用程序