mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
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>