pwmled


Namepwmled JSON
Version 1.6.11 PyPI version JSON
download
home_pagehttps://github.com/soldag/python-pwmled
SummaryControl LEDs connected to a micro controller using pwm.
upload_time2023-10-12 23:07:19
maintainer
docs_urlNone
authorsoldag
requires_python>=3.6,<4.0
licenseMIT
keywords pwm light gpio pca9685
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-pwmled [![PyPI version](https://badge.fury.io/py/pwmled.svg)](https://badge.fury.io/py/pwmled)

`python-pwmled` controls LEDs connected to a micro controller using pulse-width modulation. It supports one-color, RGB and RGBW leds driven by GPIOs of an Raspberry Pi or a PCA9685 controller.

# Installation
`python-pwmled` requires Python 3. It can be installed using pip:
```bash
pip install pwmled
```

When directly controlling the GPIOs of a Raspberry Pi using the `GpioDriver`(see [below](#configuration)), the [pigpio C library](https://github.com/joan2937/pigpio) is required. It can be installed with the following commands:
```bash
wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
sudo make install
```
Besides the library, the `pigpiod` utility is installed, which starts `pigpio` as daemon. The daemon must be running when using the `GpioDriver`.
```bash
sudo pigpiod
```

# Usage
### Configuration
`python-pwmled` supports several possibilities for connecting LEDs to your micro controller:
- GPIO: LEDs can be connected directly to the GPIOs of a Raspberry Pi.
- PCA9885: A [PCA9685](https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf) can be used as I2C-bus PWM controller.

```python
from pwmled.driver.gpio import GpioDriver
from pwmled.driver.pca9685 import Pca9685Driver

# GPIO driver, which controls pins 17, 22, 23
driver = GpioDriver([17, 22, 23])
driver = GpioDriver([17, 22, 23], freq=200)
# To control the pigpio on a other machine use the host and port parameter
driver = GpioDriver([17, 22, 23], host='other.host', port=8889)

# PCA9685 driver which controls pins 1, 2, 3
driver = Pca9685Driver([1, 2, 3])
driver = Pca9685Driver([1, 2, 3], freq=200, address=0x40)
```

### Control
Each LED needs a separated driver, which controls the corresponding pins. The number and order of pins depends on the led type:
- One-color: 1 pin
- RGB: 3 pins (`[R, G, B]`)
- RGBW: 4 pins (`[R, G, B, W]`)

The supported operations are shown in the following example:

```python
from pwmled import Color
from pwmled.led import SimpleLed
from pwmled.led.rgb import RgbLed
from pwmled.led.rgbw import RgbwLed
from pwmled.driver.gpio import GpioDriver

# One-color led
driver = GpioDriver([C])
led = SimpleLed(driver)
led.on()
led.brightness = 0.5
led.transition(5, brightness=0)
led.off()

# RGB led
driver = GpioDriver([R, G, B])
led = RgbLed(driver)
led.on()
led.color = Color(255, 0, 0)
led.set(color=Color(0, 255, 0), brightness=0.5) # set two properties simultaneously
led.transition(5, color=Color(0, 0, 255), brightness=1)
led.off()

# RGBW led
driver = GpioDriver([R, G, B, W])
led = RgbwLed(driver)
# RgbwLed has same interface as RgbLed
```

# Contributions
Pull-requests are welcome, especially for adding new drivers or led types.

# License
This library is provided under [MIT license](https://raw.githubusercontent.com/soldag/python-pwmled/master/LICENSE.md).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/soldag/python-pwmled",
    "name": "pwmled",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "",
    "keywords": "pwm,light,gpio,pca9685",
    "author": "soldag",
    "author_email": "soren.oldag@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3a/da/dd986404679b04e60be72ee5aaf2f05f42a3827068eecf689306e7e4aaf6/pwmled-1.6.11.tar.gz",
    "platform": null,
    "description": "# python-pwmled [![PyPI version](https://badge.fury.io/py/pwmled.svg)](https://badge.fury.io/py/pwmled)\n\n`python-pwmled` controls LEDs connected to a micro controller using pulse-width modulation. It supports one-color, RGB and RGBW leds driven by GPIOs of an Raspberry Pi or a PCA9685 controller.\n\n# Installation\n`python-pwmled` requires Python 3. It can be installed using pip:\n```bash\npip install pwmled\n```\n\nWhen directly controlling the GPIOs of a Raspberry Pi using the `GpioDriver`(see [below](#configuration)), the [pigpio C library](https://github.com/joan2937/pigpio) is required. It can be installed with the following commands:\n```bash\nwget abyz.co.uk/rpi/pigpio/pigpio.zip\nunzip pigpio.zip\ncd PIGPIO\nmake\nsudo make install\n```\nBesides the library, the `pigpiod` utility is installed, which starts `pigpio` as daemon. The daemon must be running when using the `GpioDriver`.\n```bash\nsudo pigpiod\n```\n\n# Usage\n### Configuration\n`python-pwmled` supports several possibilities for connecting LEDs to your micro controller:\n- GPIO: LEDs can be connected directly to the GPIOs of a Raspberry Pi.\n- PCA9885: A [PCA9685](https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf) can be used as I2C-bus PWM controller.\n\n```python\nfrom pwmled.driver.gpio import GpioDriver\nfrom pwmled.driver.pca9685 import Pca9685Driver\n\n# GPIO driver, which controls pins 17, 22, 23\ndriver = GpioDriver([17, 22, 23])\ndriver = GpioDriver([17, 22, 23], freq=200)\n# To control the pigpio on a other machine use the host and port parameter\ndriver = GpioDriver([17, 22, 23], host='other.host', port=8889)\n\n# PCA9685 driver which controls pins 1, 2, 3\ndriver = Pca9685Driver([1, 2, 3])\ndriver = Pca9685Driver([1, 2, 3], freq=200, address=0x40)\n```\n\n### Control\nEach LED needs a separated driver, which controls the corresponding pins. The number and order of pins depends on the led type:\n- One-color: 1 pin\n- RGB: 3 pins (`[R, G, B]`)\n- RGBW: 4 pins (`[R, G, B, W]`)\n\nThe supported operations are shown in the following example:\n\n```python\nfrom pwmled import Color\nfrom pwmled.led import SimpleLed\nfrom pwmled.led.rgb import RgbLed\nfrom pwmled.led.rgbw import RgbwLed\nfrom pwmled.driver.gpio import GpioDriver\n\n# One-color led\ndriver = GpioDriver([C])\nled = SimpleLed(driver)\nled.on()\nled.brightness = 0.5\nled.transition(5, brightness=0)\nled.off()\n\n# RGB led\ndriver = GpioDriver([R, G, B])\nled = RgbLed(driver)\nled.on()\nled.color = Color(255, 0, 0)\nled.set(color=Color(0, 255, 0), brightness=0.5) # set two properties simultaneously\nled.transition(5, color=Color(0, 0, 255), brightness=1)\nled.off()\n\n# RGBW led\ndriver = GpioDriver([R, G, B, W])\nled = RgbwLed(driver)\n# RgbwLed has same interface as RgbLed\n```\n\n# Contributions\nPull-requests are welcome, especially for adding new drivers or led types.\n\n# License\nThis library is provided under [MIT license](https://raw.githubusercontent.com/soldag/python-pwmled/master/LICENSE.md).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Control LEDs connected to a micro controller using pwm.",
    "version": "1.6.11",
    "project_urls": {
        "Homepage": "https://github.com/soldag/python-pwmled",
        "Repository": "https://github.com/soldag/python-pwmled"
    },
    "split_keywords": [
        "pwm",
        "light",
        "gpio",
        "pca9685"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "906d4a31fdb40680a88a59196aef4536277de87ecdf74a44f2f83b1905c9bef5",
                "md5": "feda89c90f9272ede506945fafa2b31d",
                "sha256": "aa481b60bb84cf81e8198e3ec52c938b824f96e57141bd49bca7bd9dddabf58d"
            },
            "downloads": -1,
            "filename": "pwmled-1.6.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "feda89c90f9272ede506945fafa2b31d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 12044,
            "upload_time": "2023-10-12T23:07:18",
            "upload_time_iso_8601": "2023-10-12T23:07:18.349848Z",
            "url": "https://files.pythonhosted.org/packages/90/6d/4a31fdb40680a88a59196aef4536277de87ecdf74a44f2f83b1905c9bef5/pwmled-1.6.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3adadd986404679b04e60be72ee5aaf2f05f42a3827068eecf689306e7e4aaf6",
                "md5": "cebec6bd71c91c51017d24d029fca4bb",
                "sha256": "634b242688613ee5b73c2dfa4d514f8116b7479578e94dfda2ca7965815d4398"
            },
            "downloads": -1,
            "filename": "pwmled-1.6.11.tar.gz",
            "has_sig": false,
            "md5_digest": "cebec6bd71c91c51017d24d029fca4bb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 8891,
            "upload_time": "2023-10-12T23:07:19",
            "upload_time_iso_8601": "2023-10-12T23:07:19.499316Z",
            "url": "https://files.pythonhosted.org/packages/3a/da/dd986404679b04e60be72ee5aaf2f05f42a3827068eecf689306e7e4aaf6/pwmled-1.6.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-12 23:07:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "soldag",
    "github_project": "python-pwmled",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pwmled"
}
        
Elapsed time: 2.52005s