{"id":15487782,"url":"https://github.com/werediver/xmas-rs","last_synced_at":"2025-03-28T16:15:49.119Z","repository":{"id":69241789,"uuid":"584379482","full_name":"werediver/xmas-rs","owner":"werediver","description":"A single-channel PWM xmas lights controller based on Pico (RP2040).","archived":false,"fork":false,"pushed_at":"2023-01-02T13:03:52.000Z","size":2328,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-19T07:54:54.395Z","etag":null,"topics":["hardware"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/werediver.png","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-02T12:00:27.000Z","updated_at":"2023-02-23T12:04:59.000Z","dependencies_parsed_at":"2023-05-23T09:15:26.667Z","dependency_job_id":null,"html_url":"https://github.com/werediver/xmas-rs","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"263ccc5b7b0f81b953b42818e6c8ce57845f09c9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werediver%2Fxmas-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werediver%2Fxmas-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werediver%2Fxmas-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/werediver%2Fxmas-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/werediver","download_url":"https://codeload.github.com/werediver/xmas-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246059336,"owners_count":20717085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hardware"],"created_at":"2024-10-02T06:41:43.250Z","updated_at":"2025-03-28T16:15:49.100Z","avatar_url":"https://github.com/werediver.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xmas-rs\n\nA simple single-channel PWM Christmas lights controller based on a Raspberry Pi Pico (RP2040) board.\n\n![Assembly](images/01%20Assembly.jpeg)\n\n## Hardware\n\nThe original configuration is as follows:\n\n- the LED assembly is powered from three AA batteries connected in series through a 2.6Ω resistor\n- the load current is about 400 mA\n- the voltage drop on the LED assembly is 3.06 V\n- the batteries get depleted in a few hours, the brightness drops over time\n\nThe modified configuration is as follows:\n\n- the LEDs are powered from the switching mode voltage converter on the Pico board (1.8–5.5 V in, 3.3 V out)\n- a P-channel MOSFET TSM2301A is used to commutate the load\n- electrolytic capacitors 2x 22 uF are added after the converter to back the pulsed load\n- slow \"breathing\" effect is implemented through PWM modulation\n- the LED brightness stays the same till the battery is completely depleted\n\nThe Pico board is mounted on the exterior of the original battery case. The MOSFET and capacitors are mounted inside the case.\n\n## Perceived brightness\n\nNote that the relation between PWM duty cycle and the perceived brightness is non-linear. Human eyes distinguish minor brightness changes in dim light and only much larger changes in bright light. Notice how in [this recording](https://odysee.com/@werediver:d/xmas-lights:9) the linear change in PWM duty cycle (active low) is translated into the (perceived) brightness level.\n\nThe correction used in this project is as follows:\n\n$$k(b) = {10^b - 1 \\over 9}$$\n\nwhere\n\n- $b \\in [0, 1]$ is the desired perceived brightness as a fraction of the maximum brightness\n- $k(b) \\in [0, 1]$ is the duty cycle\n\nThis comes from the (arguably more straightforward) inverse relation:\n\n$$B \\propto log(L)$$\n\nwhere\n\n- $L$ is the (objective) luminous power\n- $B$ is the perceived brightness level\n\nI didn't spend enough time to find a research paper to back this. My source is an [SE answer](https://electronics.stackexchange.com/a/550434).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerediver%2Fxmas-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwerediver%2Fxmas-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwerediver%2Fxmas-rs/lists"}