adafruit-circuitpython-ble-magic-light


Nameadafruit-circuitpython-ble-magic-light JSON
Version 0.9.20 PyPI version JSON
download
home_page
SummaryBLE service for Magic Light BLE RGB bulbs
upload_time2023-12-09 17:43:28
maintainer
docs_urlNone
author
requires_python
licenseMIT
keywords adafruit blinka circuitpython micropython ble_magic_light ble rgb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Introduction
============

.. image:: https://readthedocs.org/projects/adafruit-circuitpython-ble_magic_light/badge/?version=latest
    :target: https://docs.circuitpython.org/projects/ble_magic_light/en/latest/
    :alt: Documentation Status

.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg
    :target: https://adafru.it/discord
    :alt: Discord

.. image:: https://github.com/adafruit/Adafruit_CircuitPython_BLE_Magic_Light/workflows/Build%20CI/badge.svg
    :target: https://github.com/adafruit/Adafruit_CircuitPython_BLE_Magic_Light/actions
    :alt: Build Status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: Code Style: Black

BLE service for Magic Light BLE RGB bulbs. Available from Amazon
`here <https://www.amazon.com/gp/product/B073S1KV4F>`_.


Dependencies
=============
This driver depends on:

* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_

Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_.

Installing from PyPI
=====================
.. note:: This library is not available on PyPI yet. Install documentation is included
   as a standard element. Stay tuned for PyPI availability!

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/adafruit-circuitpython-ble_magic_light/>`_. To install for current user:

.. code-block:: shell

    pip3 install adafruit-circuitpython-ble-magic-light

To install system-wide (this may be required in some cases):

.. code-block:: shell

    sudo pip3 install adafruit-circuitpython-ble-magic-light

To install in a virtual environment in your current project:

.. code-block:: shell

    mkdir project-name && cd project-name
    python3 -m venv .venv
    source .venv/bin/activate
    pip3 install adafruit-circuitpython-ble-magic-light

Usage Example
=============

.. code:: python

    """This demo connects to a magic light and has it do a colorwheel."""
    import adafruit_ble
    import _bleio

    from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
    from adafruit_ble_magic_light import MagicLightService

    # CircuitPython <6 uses its own ConnectionError type. So, is it if available. Otherwise,
    # the built in ConnectionError is used.
    connection_error = ConnectionError
    if hasattr(_bleio, "ConnectionError"):
        connection_error = _bleio.ConnectionError

    def find_connection():
        for connection in radio.connections:
            if MagicLightService not in connection:
                continue
            return connection, connection[MagicLightService]
        return None, None

    # Start advertising before messing with the display so that we can connect immediately.
    radio = adafruit_ble.BLERadio()

    active_connection, pixels = find_connection()
    current_notification = None
    app_icon_file = None
    while True:
        if not active_connection:
            print("Scanning for Magic Light")
            for scan in radio.start_scan(ProvideServicesAdvertisement):
                if MagicLightService in scan.services:
                    active_connection = radio.connect(scan)
                    try:
                        pixels = active_connection[MagicLightService]
                    except connection_error:
                        print("disconnected")
                        continue
                    break
            radio.stop_scan()

        i = 0
        while active_connection.connected:
            pixels[0] = colorwheel(i % 256)
            i += 1

        active_connection = None

Documentation
=============

API documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/ble_magic_light/en/latest/>`_.

For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.

Contributing
============

Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/Adafruit_CircuitPython_BLE_Magic_Light/blob/main/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "adafruit-circuitpython-ble-magic-light",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "adafruit,blinka,circuitpython,micropython,ble_magic_light,ble,rgb",
    "author": "",
    "author_email": "Adafruit Industries <circuitpython@adafruit.com>",
    "download_url": "https://files.pythonhosted.org/packages/ff/e6/6232bae049fcf40cfbe9f90eed2dd630f4564966cf74229bc6e244f4a0bf/adafruit-circuitpython-ble-magic-light-0.9.20.tar.gz",
    "platform": null,
    "description": "Introduction\n============\n\n.. image:: https://readthedocs.org/projects/adafruit-circuitpython-ble_magic_light/badge/?version=latest\n    :target: https://docs.circuitpython.org/projects/ble_magic_light/en/latest/\n    :alt: Documentation Status\n\n.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg\n    :target: https://adafru.it/discord\n    :alt: Discord\n\n.. image:: https://github.com/adafruit/Adafruit_CircuitPython_BLE_Magic_Light/workflows/Build%20CI/badge.svg\n    :target: https://github.com/adafruit/Adafruit_CircuitPython_BLE_Magic_Light/actions\n    :alt: Build Status\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: Code Style: Black\n\nBLE service for Magic Light BLE RGB bulbs. Available from Amazon\n`here <https://www.amazon.com/gp/product/B073S1KV4F>`_.\n\n\nDependencies\n=============\nThis driver depends on:\n\n* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_\n\nPlease ensure all dependencies are available on the CircuitPython filesystem.\nThis is easily achieved by downloading\n`the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_.\n\nInstalling from PyPI\n=====================\n.. note:: This library is not available on PyPI yet. Install documentation is included\n   as a standard element. Stay tuned for PyPI availability!\n\nOn supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from\nPyPI <https://pypi.org/project/adafruit-circuitpython-ble_magic_light/>`_. To install for current user:\n\n.. code-block:: shell\n\n    pip3 install adafruit-circuitpython-ble-magic-light\n\nTo install system-wide (this may be required in some cases):\n\n.. code-block:: shell\n\n    sudo pip3 install adafruit-circuitpython-ble-magic-light\n\nTo install in a virtual environment in your current project:\n\n.. code-block:: shell\n\n    mkdir project-name && cd project-name\n    python3 -m venv .venv\n    source .venv/bin/activate\n    pip3 install adafruit-circuitpython-ble-magic-light\n\nUsage Example\n=============\n\n.. code:: python\n\n    \"\"\"This demo connects to a magic light and has it do a colorwheel.\"\"\"\n    import adafruit_ble\n    import _bleio\n\n    from adafruit_ble.advertising.standard import ProvideServicesAdvertisement\n    from adafruit_ble_magic_light import MagicLightService\n\n    # CircuitPython <6 uses its own ConnectionError type. So, is it if available. Otherwise,\n    # the built in ConnectionError is used.\n    connection_error = ConnectionError\n    if hasattr(_bleio, \"ConnectionError\"):\n        connection_error = _bleio.ConnectionError\n\n    def find_connection():\n        for connection in radio.connections:\n            if MagicLightService not in connection:\n                continue\n            return connection, connection[MagicLightService]\n        return None, None\n\n    # Start advertising before messing with the display so that we can connect immediately.\n    radio = adafruit_ble.BLERadio()\n\n    active_connection, pixels = find_connection()\n    current_notification = None\n    app_icon_file = None\n    while True:\n        if not active_connection:\n            print(\"Scanning for Magic Light\")\n            for scan in radio.start_scan(ProvideServicesAdvertisement):\n                if MagicLightService in scan.services:\n                    active_connection = radio.connect(scan)\n                    try:\n                        pixels = active_connection[MagicLightService]\n                    except connection_error:\n                        print(\"disconnected\")\n                        continue\n                    break\n            radio.stop_scan()\n\n        i = 0\n        while active_connection.connected:\n            pixels[0] = colorwheel(i % 256)\n            i += 1\n\n        active_connection = None\n\nDocumentation\n=============\n\nAPI documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/ble_magic_light/en/latest/>`_.\n\nFor information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.\n\nContributing\n============\n\nContributions are welcome! Please read our `Code of Conduct\n<https://github.com/adafruit/Adafruit_CircuitPython_BLE_Magic_Light/blob/main/CODE_OF_CONDUCT.md>`_\nbefore contributing to help this project stay welcoming.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "BLE service for Magic Light BLE RGB bulbs",
    "version": "0.9.20",
    "project_urls": {
        "Homepage": "https://github.com/adafruit/Adafruit_CircuitPython_BLE_Magic_Light"
    },
    "split_keywords": [
        "adafruit",
        "blinka",
        "circuitpython",
        "micropython",
        "ble_magic_light",
        "ble",
        "rgb"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68901d1ebb63684201dbb6ceb7b2159323c925fc059a7a5a9ab521160fa9f245",
                "md5": "67021d595a9da57a5d22db113f5f6540",
                "sha256": "b53f516f0687b47dc0f41aca445034deeb442da59cbb2f41a7c9b6130a6650b5"
            },
            "downloads": -1,
            "filename": "adafruit_circuitpython_ble_magic_light-0.9.20-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "67021d595a9da57a5d22db113f5f6540",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5182,
            "upload_time": "2023-12-09T17:43:27",
            "upload_time_iso_8601": "2023-12-09T17:43:27.487384Z",
            "url": "https://files.pythonhosted.org/packages/68/90/1d1ebb63684201dbb6ceb7b2159323c925fc059a7a5a9ab521160fa9f245/adafruit_circuitpython_ble_magic_light-0.9.20-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ffe66232bae049fcf40cfbe9f90eed2dd630f4564966cf74229bc6e244f4a0bf",
                "md5": "5b1829e8e9f859fe19d878945d7bac95",
                "sha256": "b8f54df574910145e38d508ce47d792208292b33536c5574a12126eb3c1495f8"
            },
            "downloads": -1,
            "filename": "adafruit-circuitpython-ble-magic-light-0.9.20.tar.gz",
            "has_sig": false,
            "md5_digest": "5b1829e8e9f859fe19d878945d7bac95",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 26489,
            "upload_time": "2023-12-09T17:43:28",
            "upload_time_iso_8601": "2023-12-09T17:43:28.684567Z",
            "url": "https://files.pythonhosted.org/packages/ff/e6/6232bae049fcf40cfbe9f90eed2dd630f4564966cf74229bc6e244f4a0bf/adafruit-circuitpython-ble-magic-light-0.9.20.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-09 17:43:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "adafruit",
    "github_project": "Adafruit_CircuitPython_BLE_Magic_Light",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "adafruit-circuitpython-ble-magic-light"
}
        
Elapsed time: 0.88819s