Move signal inversion to HAL - #183
Merged
Merged
Conversation
jandelgado
force-pushed
the
move_signal_inversion_to_hal
branch
5 times, most recently
from
August 2, 2026 16:34
075747c to
e9fef89
Compare
…Write(val, invert)
…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
force-pushed
the
move_signal_inversion_to_hal
branch
from
August 3, 2026 12:36
e9fef89 to
7f64f68
Compare
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
force-pushed
the
move_signal_inversion_to_hal
branch
from
August 3, 2026 14:27
7f64f68 to
7961ad3
Compare
jandelgado
marked this pull request as ready for review
August 3, 2026 14:36
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.
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).