Add PWM-controlled headlights hardware module#33
Merged
pascalzauberzeug merged 9 commits intomainfrom Apr 27, 2026
Merged
Conversation
aa8ddbd to
034278b
Compare
7 tasks
PWM at 1 kHz caused visible flicker on the installed LED modules (likely interaction with their internal driver's control loop). Dimming is not a product requirement, so drop the duty-cycle API entirely and drive the headlights as plain on/off outputs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The flashlight's front and back PwmOutputs both claimed timer 0 / channel 0 (the Lizard defaults), so only the last-configured pin was actually driven in hardware. Assign back to channel 1, and reserve timer 1 / channels 2+3 for the headlights so both subsystems can coexist without reconfiguring each other's LEDC timer. Also restore PWM on the headlights (needed for LED module compatibility) and promote duty_cycle to a FlashlightConfiguration field, matching the headlights' pattern. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
25567bb to
291f09e
Compare
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
felixwrz
approved these changes
Apr 27, 2026
pascalzauberzeug
added a commit
that referenced
this pull request
Apr 27, 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 `PwmOutput`s 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 `PwmOutput`s on the same chip. ### Progress - [x] I chose a meaningful title that completes the sentence: "If applied, this PR will..." - [x] I chose meaningful labels (if GitHub allows me to so). - [x] I documented breaking changes and set the 'breaking change' label if needed - [x] The implementation is complete. - [x] Tests with a real hardware have been successful (or are not necessary). - [x] Pytests have been added (or are not necessary). - [x] Documentation has been added (or is not necessary). --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Add PWM-controlled headlights as a new hardware module so Feldfreund robots can independently control left and right headlights with adjustable brightness.
Implementation
Follows the existing flashlight pattern: a
Headlightsbase class withHeadlightsHardwareandHeadlightsSimulationwith two independently PWM controlled lights.Includes a developer UI with on/off buttons and per-side duty cycle sliders.
Progress
Noneor do all robots from now on will have these lights? -> Breaking change