Skip to content

Add PWM-controlled headlights hardware module#33

Merged
pascalzauberzeug merged 9 commits intomainfrom
headlights
Apr 27, 2026
Merged

Add PWM-controlled headlights hardware module#33
pascalzauberzeug merged 9 commits intomainfrom
headlights

Conversation

@pascalzauberzeug
Copy link
Copy Markdown
Contributor

@pascalzauberzeug pascalzauberzeug commented Apr 8, 2026

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 Headlights base class with HeadlightsHardware and HeadlightsSimulation with two independently PWM controlled lights.

Includes a developer UI with on/off buttons and per-side duty cycle sliders.

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).
    • Tested with F26
  • 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 8, 2026
@pascalzauberzeug pascalzauberzeug added the enhancement New feature or request label Apr 8, 2026
@pascalzauberzeug pascalzauberzeug changed the title first spike Add PWM-controlled headlights hardware module Apr 8, 2026
@pascalzauberzeug pascalzauberzeug changed the base branch from main to AG-137-mittendrin-bei-recorded-tracks-anfangen-konnen April 26, 2026 15:13
@pascalzauberzeug pascalzauberzeug changed the base branch from AG-137-mittendrin-bei-recorded-tracks-anfangen-konnen to add-innotronic-track-hardware April 26, 2026 15:13
@pascalzauberzeug pascalzauberzeug marked this pull request as ready for review April 26, 2026 16:38
Base automatically changed from add-innotronic-track-hardware to main April 27, 2026 05:29
pascalzauberzeug and others added 8 commits April 27, 2026 08:29
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>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pascalzauberzeug pascalzauberzeug merged commit 78c694e into main Apr 27, 2026
6 checks passed
@pascalzauberzeug pascalzauberzeug deleted the headlights branch April 27, 2026 07:07
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>
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