控制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使用McClickListener单击了什么元素   Java时间戳在Oracle时间戳中不同情况下存储12 PM的奇怪行为   java无法使用事件总线对运行在不同机器上的垂直体进行通信   java Mockserver:收到请求后进行回调   java无法将Json字符串转换为Map<string,Object>   java如何按升序排列输出?   java视图行,带有oracle键。jbo。在SrCategoryParentIterator中找不到键[300100120394155]   javafxmysql连接示例   java正在等待加载完成   java是否可以将同一个有状态会话bean实例注入多个其他会话bean?   java无法让万向节检测离开或进入区域   使用JavaCV和OpenCV的java提供了dyld:lazy符号绑定失败:找不到符号:__sincos_stret   xml解析无法使用Java读取xml文档   java无法更改工具栏的颜色   javaapachesshd和JSCH   java无法在firebase存储中检索图像url   java问题与executeUpdate   同一应用程序中不同活动之间的java SharedReference