AP_Relay: add hwdef-level RELAYn_DEFAULT compiled default for boot state - #33896
Open
Hwurzburg wants to merge 1 commit into
Open
AP_Relay: add hwdef-level RELAYn_DEFAULT compiled default for boot state#33896Hwurzburg wants to merge 1 commit into
Hwurzburg wants to merge 1 commit into
Conversation
RELAYn_PIN_DEFAULT already lets a board's hwdef.dat set the relay pin at compile time, but the relay's ON/OFF boot state had no equivalent - it was hardcoded to DefaultState::OFF, with the only override being a RELAYn_DEFAULT parm line in defaults.parm. Several board hwdefs (and open board-support PRs) assumed a hwdef-level default already existed and either documented a boot state defaults.parm never delivered, or carried an already-written but silently dead RELAYn_DEFAULT hwdef define. Add optional RELAY1_DEFAULT..RELAY6_DEFAULT macros, following the same pattern as the existing pin defaults, applied in set_defaults() before init() configures the GPIO. Verified in SITL with --define=RELAY2_DEFAULT=1 that the compiled default reaches the live parameter (RELAY2_DEFAULT reads back as 1 with a fresh eeprom, RELAY1_DEFAULT remains the hardcoded 0 fallback when unspecified). Co-Authored-By: Claude Sonnet 5 <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.
RELAYn_PIN_DEFAULT already lets a board's hwdef.dat set the relay pin at compile time, but the relay's ON/OFF boot state had no equivalent - it was hardcoded to DefaultState::OFF, with the only override being a RELAYn_DEFAULT parm line in defaults.parm. Several board hwdefs (and open board-support PRs) assumed a hwdef-level default already existed and either documented a boot state defaults.parm never delivered, or carried an already-written but silently dead RELAYn_DEFAULT hwdef define.
Add optional RELAY1_DEFAULT..RELAY6_DEFAULT macros, following the same pattern as the existing pin defaults, applied in set_defaults() before init() configures the GPIO. Verified in SITL with --define=RELAY2_DEFAULT=1 that the compiled default reaches the live parameter (RELAY2_DEFAULT reads back as 1 with a fresh eeprom, RELAY1_DEFAULT remains the hardcoded 0 fallback when unspecified).
Summary
This allows Relays setup in hwdef to actually force the VTX power, etc on after boot...Currently , if not added in defaults.parm, the VTX will revert to OFF after boot in those cases where its desired that it be on wihtout user intervention.
Classification & Testing (check all that apply and add your own)