Skip to content

Let the flashlight respect on_expander and expose LEDC channels#38

Merged
pascalzauberzeug merged 6 commits intomainfrom
fix_flashlights
Apr 27, 2026
Merged

Let the flashlight respect on_expander and expose LEDC channels#38
pascalzauberzeug merged 6 commits intomainfrom
fix_flashlights

Conversation

@pascalzauberzeug
Copy link
Copy Markdown
Contributor

@pascalzauberzeug pascalzauberzeug commented Apr 26, 2026

Motivation

FlashlightHardware ignored on_expander and prefixed the Lizard PwmOutput with the expander name whenever an expander was passed, regardless of the flag.
It also hard-coded the LEDC channel allocation, which can collide with other PwmOutputs on the same chip — see #33.

Implementation

  • Respect on_expander: the expander prefix is only applied when both an expander is present and config.on_expander is true.
  • Make LEDC allocation explicit: expose ledc_timer, front_ledc_channel, back_ledc_channel on FlashlightConfiguration and pass them as the second/third argument to PwmOutput(...).
    Defaults match the previous implicit allocation (timer 0, channels 0/1).
  • Make brightness configurable via duty_cycle (0.0–1.0), converted to the 8-bit Lizard duty value; previous behavior (full brightness) is preserved as the default.

A docstring note reminds users that the LEDC channels must not collide with other PwmOutputs on the same chip.

Progress

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • I chose meaningful labels (if GitHub allows me to so).
  • I documented breaking changes and set the 'breaking change' label if needed
  • The implementation is complete.
  • Tests with a real hardware have been successful (or are not necessary).
  • Pytests have been added (or are not necessary).
  • Documentation has been added (or is not necessary).

@pascalzauberzeug pascalzauberzeug added this to the 0.2.0 milestone Apr 26, 2026
@pascalzauberzeug pascalzauberzeug added the enhancement New feature or request label Apr 26, 2026
@pascalzauberzeug pascalzauberzeug changed the title fix flashlight class Let the flashlight respect on_expander and expose LEDC channels Apr 26, 2026
@pascalzauberzeug pascalzauberzeug marked this pull request as ready for review April 26, 2026 16:36
@pascalzauberzeug pascalzauberzeug merged commit 0cca5c0 into main Apr 27, 2026
6 checks passed
@pascalzauberzeug pascalzauberzeug deleted the fix_flashlights branch April 27, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants