Skip to content

AP_Relay: add hwdef-level RELAYn_DEFAULT compiled default for boot state - #33896

Open
Hwurzburg wants to merge 1 commit into
ArduPilot:masterfrom
Hwurzburg:add-relay-hwdef-default-state
Open

AP_Relay: add hwdef-level RELAYn_DEFAULT compiled default for boot state#33896
Hwurzburg wants to merge 1 commit into
ArduPilot:masterfrom
Hwurzburg:add-relay-hwdef-default-state

Conversation

@Hwurzburg

Copy link
Copy Markdown
Contributor

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)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

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>

@andyp1per andyp1per left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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