Skip to main content

A package providing convenient access to the Fischertechnik BT-Smart Controller

Project description

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

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())

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

btsmart-0.1.10.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

btsmart-0.1.10-py2.py3-none-any.whl (59.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file btsmart-0.1.10.tar.gz.

File metadata

  • Download URL: btsmart-0.1.10.tar.gz
  • Upload date:
  • Size: 33.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for btsmart-0.1.10.tar.gz
Algorithm Hash digest
SHA256 8c00326a81f7ead83d5b217569d830f7f24ab7e9c0183b5a144ee7f782120c2e
MD5 51ff01566ada1ea34a6a43ae7476f289
BLAKE2b-256 5e02e4158c999e478354ee600ca57d395ab3cd60cce1ea285cfc29213fb0863f

See more details on using hashes here.

File details

Details for the file btsmart-0.1.10-py2.py3-none-any.whl.

File metadata

  • Download URL: btsmart-0.1.10-py2.py3-none-any.whl
  • Upload date:
  • Size: 59.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for btsmart-0.1.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 349a29836a8cedcaa7e65ed4719e70daa82bca1292a19b48564ce77bd97c617d
MD5 80bf4f1742936ff25d378e40339e04e1
BLAKE2b-256 bb72e6d351078823adbbcacc67ed6970d703c40d4180c8a61ddb945bc1a5cbb8

See more details on using hashes here.

Supported by

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