Skip to content

Move signal inversion to HAL - #183

Merged
jandelgado merged 14 commits into
masterfrom
move_signal_inversion_to_hal
Aug 3, 2026
Merged

Move signal inversion to HAL#183
jandelgado merged 14 commits into
masterfrom
move_signal_inversion_to_hal

Conversation

@jandelgado

Copy link
Copy Markdown
Owner

Signal inversion is currently handled by TJLed. But TJLeds main job is management of the state machine to play the effects. By moving the inversion logic to the HAL we also open the door to use hardware inversion on platforms, where this is possible (e.g. Raspberry PI Pico or ESP32). On other platforms, inversion is done in software (as before).

@coveralls

coveralls commented Aug 1, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 96.727% (-1.0%) from 97.722% — move_signal_inversion_to_hal into master

@jandelgado jandelgado mentioned this pull request Aug 1, 2026
28 tasks
@jandelgado
jandelgado force-pushed the move_signal_inversion_to_hal branch 5 times, most recently from 075747c to e9fef89 Compare August 2, 2026 16:34
…fallback

ESP32 LEDC's output_invert flag requires a full ledc_channel_config() re-init to
toggle (duty read-back, hpoint, timer_sel), which is heavier and glitchier than
a plain software subtraction, so ESP32 wraps Esp32Hal in InvertableHal like
every other platform instead of touching hardware polarity.
TJLed::LowActive() calls hal_.SetLowActive() directly instead of dispatching
through SFINAE-detected optionality. InvertableHal provides a no-op default
for HALs without a hardware polarity register.
…ion test, correct CHANGELOG wording

Esp32Hal::SetLowActive() now reads back the LEDC driver's own current
duty/hpoint via ledc_get_duty()/ledc_get_hpoint() and preserves them
across the polarity flip, instead of always forcing full on/off. This
avoids glitching the display when polarity is toggled mid-effect,
without caching any extra state in Esp32Hal.
@jandelgado
jandelgado force-pushed the move_signal_inversion_to_hal branch from e9fef89 to 7f64f68 Compare August 3, 2026 12:36
Allows toggling low-active polarity off again via LowActive(false)
without a separate API. Existing LowActive() calls are unaffected.
Always carry the current duty/hpoint through unchanged, instead of
special-casing duty==0 to force full-on. Matches PicoHal's simpler
behavior. Wrap in InvertableHal for a software fallback if the native
LEDC invert misbehaves at some duty value.
@jandelgado
jandelgado force-pushed the move_signal_inversion_to_hal branch from 7f64f68 to 7961ad3 Compare August 3, 2026 14:27
@jandelgado
jandelgado marked this pull request as ready for review August 3, 2026 14:36
@jandelgado
jandelgado merged commit 1ed69de into master Aug 3, 2026
9 checks passed
@jandelgado jandelgado added this to the 5.0.0 milestone Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants