adafruit-circuitpython-ble-magic-light


Nameadafruit-circuitpython-ble-magic-light JSON
Version 0.9.22 PyPI version JSON
download
home_pageNone
SummaryBLE service for Magic Light BLE RGB bulbs
upload_time2025-01-16 19:31:31
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseMIT
keywords adafruit blinka circuitpython micropython ble_magic_light ble rgb
VCS
bugtrack_url
requirements Adafruit-Blinka adafruit-circuitpython-ble
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": null,
    "name": "adafruit-circuitpython-ble-magic-light",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "adafruit, blinka, circuitpython, micropython, ble_magic_light, ble, rgb",
    "author": null,
    "author_email": "Adafruit Industries <circuitpython@adafruit.com>",
    "download_url": "https://files.pythonhosted.org/packages/15/c2/b28cb10b7a8699f83f178ffe13163f89928e7e16239cdb4cdf040a0006c7/adafruit_circuitpython_ble_magic_light-0.9.22.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.22",
    "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": "21f44a7a1d93268de9c4e78d61893795b85777910a5869e0ecabf84a88816e5c",
                "md5": "14f23f2b6319d10de119c95b09726f9b",
                "sha256": "5fe99b4563c031cc053ee2ae5d6ff2813a62267c8c17955565914d562059a222"
            },
            "downloads": -1,
            "filename": "adafruit_circuitpython_ble_magic_light-0.9.22-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "14f23f2b6319d10de119c95b09726f9b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5186,
            "upload_time": "2025-01-16T19:31:29",
            "upload_time_iso_8601": "2025-01-16T19:31:29.042923Z",
            "url": "https://files.pythonhosted.org/packages/21/f4/4a7a1d93268de9c4e78d61893795b85777910a5869e0ecabf84a88816e5c/adafruit_circuitpython_ble_magic_light-0.9.22-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15c2b28cb10b7a8699f83f178ffe13163f89928e7e16239cdb4cdf040a0006c7",
                "md5": "dbbf98d7feb042aa1bac05e1aa0dfbed",
                "sha256": "9132855ac47eb80b52e3eee5e61aebc9d9fc1a137071668f89ac6639e47a6b85"
            },
            "downloads": -1,
            "filename": "adafruit_circuitpython_ble_magic_light-0.9.22.tar.gz",
            "has_sig": false,
            "md5_digest": "dbbf98d7feb042aa1bac05e1aa0dfbed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 26498,
            "upload_time": "2025-01-16T19:31:31",
            "upload_time_iso_8601": "2025-01-16T19:31:31.821512Z",
            "url": "https://files.pythonhosted.org/packages/15/c2/b28cb10b7a8699f83f178ffe13163f89928e7e16239cdb4cdf040a0006c7/adafruit_circuitpython_ble_magic_light-0.9.22.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-16 19:31:31",
    "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": [
        {
            "name": "Adafruit-Blinka",
            "specs": []
        },
        {
            "name": "adafruit-circuitpython-ble",
            "specs": []
        }
    ],
    "lcname": "adafruit-circuitpython-ble-magic-light"
}
        
Elapsed time: 0.73912s