btsmart-0.1.8
توضیحات
A package providing convenient access to the Fischertechnik BT-Smart Controller
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | btsmart-0.1.8 |
| نام | btsmart |
| نسخه کتابخانه | 0.1.8 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Rainer Neumann |
| ایمیل نویسنده | Rainer Neumann <rainer.neumann@h-ka.de> |
| آدرس صفحه اصلی | https://github.com/rneumann/btsmart |
| آدرس اینترنتی | https://pypi.org/project/btsmart/ |
| مجوز | MIT |
========
BT-Smart
========
:Authors:
Prof. Dr. Rainer Neumann
:Version: 0.1.10 of 2023/02/07
A small library that helps to build simple projects based on the Fischertechnik BT-Smart Controller
using Bluetooth LE.
The library uses the bleak libray to handle the BLE protocol and asyncio to access device features.
Installation
------------
pip install btsmart
Getting Started
---------------
Assume we have attached a Button to the first input of the Controller, as simple lamp to output 1 and a motor element to output 2.
Then we can use the library like this
.. code-block:: python
import asyncio
from btsmart import discover_controller, BTSmartController
from btsmart import Button, Dimmer, MotorXS
btn = Button()
dim = Dimmer()
motor = MotorXS()
async def button_pressed():
print("Button pressed")
await asyncio.gather(
dim.set_level(100),
motor.run(level=100, time=0.5)
)
async def button_released():
print("Button released")
await dim.set_level(0)
btn.on_press(button_pressed)
btn.on_release(button_released)
async def main():
btSmart: BTSmartController = None
try:
btSmart = await discover_controller()
except Exception:
print("No controller found - please press the connect button on the device")
return
btn.attach(btSmart, 1)
dim.attach(btSmart, 1)
motor.attach(btSmart, 2)
await btSmart.connect()
await asyncio.sleep(20)
await btSmart.disconnect()
asyncio.run(main())
نیازمندی
| مقدار | نام |
|---|---|
| - | bleak |
| - | pyftdi |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl btsmart-0.1.8:
pip install btsmart-0.1.8.whl
نصب پکیج tar.gz btsmart-0.1.8:
pip install btsmart-0.1.8.tar.gz