Skip to main content

用于控制负鼠振动控制器以及读取灵猫和爪印传感器的 Python 库

Project description

DGLAB-controller-python

DG-LAB 蓝牙设备的 Python SDK,基于 bleak。 支持同时连接多个设备、异步事件处理,并通过 async with 自动管理连接。


支持的设备

灵猫边缘控制传感器(47L124000)

负鼠振动控制器 (47L127000)

爪印无线按钮传感器 (47L120300)


安装

pip install DGLAB-controller-python

要求 Python 3.10+ 且 bleak ≥ 0.21。


快速开始

灵猫 – 气压上报

import asyncio
from dg_lab_devices import Civec

async def main():
    async with Civec() as civec:
        @civec.on_pressure
        def on_pressure(kpa: float):
            print(f"气压: {kpa:.2f} kPa")

        await civec.start_pressure_report(color=0x02)
        await asyncio.sleep(30)

asyncio.run(main())

负鼠 – 按键与强度

from dg_lab_devices import Controller

async def main():
    async with Controller() as ctrl:
        @ctrl.on_button
        async def on_button(seq, buttons):
            if buttons.get("A"):
                await ctrl.set_strength(a=160)

        await ctrl.set_led_and_report(enable_button_report=True)
        await asyncio.sleep(60)

asyncio.run(main())

爪印 – 触发模式

from dg_lab_devices import PawPrints

async def main():
    async with PawPrints() as pp:
        @pp.on_trigger
        def on_trigger(color, event_id, param):
            print(f"触发事件 {event_id},参数={param}")

        await pp.set_random_trigger(
            color=0x01, event_id=5,
            green_min=30, green_max=50,
            reaction_time=10,
            param_inc=20, param_speed=40,
            param_dec=50, param_dec_speed=40
        )
        await asyncio.sleep(300)

asyncio.run(main())

主要特性

· 异步事件驱动 – 装饰器订阅设备通知

· 自动连接管理 – async with 自动连接/断开

· 多设备并发 – 同一事件循环同时运行多个设备

· 完整协议支持 – 实现所有 BLE 指令与回调


开源许可

本项目使用 MIT 许可证。


联系作者

. QQ群:870333220 有香香软软的小南娘和技术大佬


相关链接

. 参考文档

· PyPI

· API文档

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dglab_controller_python-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dglab_controller_python-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file dglab_controller_python-0.1.0.tar.gz.

File metadata

  • Download URL: dglab_controller_python-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for dglab_controller_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5fe3b93abd61e5a843995b0ef83c6f676abb0c325ab0762714622a3fcc3a56b
MD5 c507321aee768e49114073dd4070ed1c
BLAKE2b-256 faf168f97f73ac220eec6e4df7f338f123f105dc724345b9f5be70c5ca357e05

See more details on using hashes here.

File details

Details for the file dglab_controller_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dglab_controller_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 480815b3ae3ecb517079497207d49e0ee77e309eed6bb526390941df0498f901
MD5 f324def54c32018de66f752194f1ccb8
BLAKE2b-256 192181c19ad7401510d4d567312ea291793a78631367e7eb6a810b969aac043c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page