{"id":13802320,"url":"https://gitlab.com/WiLED-Project/upwmcontroller","last_synced_at":"2025-05-13T13:30:47.062Z","repository":{"id":63146190,"uuid":"10435213","full_name":"WiLED-Project/upwmcontroller","owner":"WiLED-Project","description":"A MicroPython library for controlling PWM outputs in an asyncio loop, with features including fading and blinking","archived":false,"fork":false,"pushed_at":null,"size":null,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":null,"default_branch":"master","last_synced_at":"2024-08-05T00:07:10.382Z","etag":null,"topics":["PWM","async","asyncio","embedded","fade","led","microcontroller","microprocessor","micropython","uasyncio"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":null,"metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-19T03:51:37.977Z","updated_at":"2019-02-02T04:54:09.653Z","dependencies_parsed_at":"2022-11-13T22:00:16.899Z","dependency_job_id":null,"html_url":"https://gitlab.com/WiLED-Project/upwmcontroller","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/WiLED-Project%2Fupwmcontroller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/WiLED-Project%2Fupwmcontroller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/WiLED-Project%2Fupwmcontroller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/WiLED-Project%2Fupwmcontroller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/owners/WiLED-Project","download_url":"https://gitlab.com/WiLED-Project/upwmcontroller/-/archive/master/upwmcontroller-master.zip","host":{"name":"gitlab.com","url":"https://gitlab.com","kind":"gitlab","repositories_count":4515906,"owners_count":6543,"icon_url":"https://github.com/gitlab.png","version":null,"created_at":"2022-05-30T11:31:42.605Z","updated_at":"2024-07-18T11:24:13.055Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/owners"}},"keywords":["PWM","async","asyncio","embedded","fade","led","microcontroller","microprocessor","micropython","uasyncio"],"created_at":"2024-08-04T00:01:41.987Z","updated_at":"2024-11-18T17:31:19.228Z","avatar_url":null,"language":null,"readme":"# uPWMController\n\nA MicroPython library for controlling PWM outputs using an asyncio loop.\n\n\n## Installation\n\nInstalling is easy - just copy the `upwmcontroller.py` file to your MicroPython board. It can live either in the root, or in a `/lib` folder. \n\nThe file is only a few kilobytes, but for more efficiency it can be frozen into a MicroPython binary image - just place the file inside the `ports/\u003cboard\u003e/modules` folder when building MicroPython from source, then flash to the board as usual. \n\n\n## Usage\n\nUsage is fairly simple, although some knowledge and experience with MicroPython's `uasyncio` library will be helpful. \n\nCreate an instance of `uPWMController` like so:\n\n```python\nled = uPWMController(machine.PWM(machine.Pin(17), duty=0))\n```\n\nThen when setting up the event loop, add the `run()` coroutine as a task:\n\n```python\n# Get a reference to the event loop\nloop = uasyncio.get_event_loop()\n# Create an instance of the background coroutine\nled_coro = uasyncio.coroutine(led.run())\n# Schedule the coroutine to run ASAP\nloop.create_task(led_coro)\n```\n\nThen start the loop as required for the rest of your code, probably with `run_forever()`. \n\nWhen the event loop is running, the `set_duty()` function is used to start fading the PWM output, for example:\n\n```python\nled.set_duty(1023, fadetime=1000)\n```\n\nThe maximum duty value will depend on the resolution of the PWM module for your particular board, on an ESP32 the maximum is 1023 (i.e. 10 bits). \n\nSee the example in [`examples/main.py`](./example/main.py) for a demo of controlling two LEDs and running an event loop for a short period of time. \n\n\n## License\n\nuPWMController, A MicroPython library for controlling PWM outputs\n\nCopyright (C) 2019, Sean Lanigan\n\nuPWMController is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nuPWMController is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License along with uPWMController.  If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n\nSee [LICENSE](./LICENSE) for the full text. \n","funding_links":[],"categories":["Libraries"],"sub_categories":["IO"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/gitlab.com%2FWiLED-Project%2Fupwmcontroller","html_url":"https://awesome.ecosyste.ms/projects/gitlab.com%2FWiLED-Project%2Fupwmcontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/gitlab.com%2FWiLED-Project%2Fupwmcontroller/lists"}