-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AP_Relay: Refactor to support RELAYx_FUNCTION #25108
Merged
peterbarker
merged 16 commits into
ArduPilot:master
from
WickedShell:wickedshell/relay_function
Dec 18, 2023
+559
−161
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e30e8bc
AP_Relay: Refactor to support RELAYx_FUNCTION
WickedShell 09a26ef
Copter: Fix AP_Relay param naming
WickedShell 490068d
Plane: Fix AP_Relay param naming
WickedShell 8dbaede
Sub: Fix AP_Relay param naming
WickedShell 09a8c2c
Rover: Fix AP_Relay param naming
WickedShell 159b8ed
autotest: Update tests for relay
WickedShell 849d964
AP_LandingGear: remove unneeded relay include
IamPete1 3873f1b
AP_Camera: move to new relay functions
IamPete1 a224468
AP_ICEngine: move to new relay functions
IamPete1 8cba2f9
AP_Relay: add enabled method by function
IamPete1 d8be26d
AP_Parachute: move to new relay functions
IamPete1 7b9c702
AP_Relay: param conversion from ICE, chute and camera
IamPete1 c8720c5
AR_Motors: Move to new relay functions
IamPete1 227113f
AP_Relay: add rover motor reverse functions
IamPete1 b177be2
AP_Relay: capitalize function enum
IamPete1 ce2f4ff
AP_Relay: move from using AP_RELAY_NUM_RELAYS to ARRAY_SIZE(_params)
IamPete1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,14 +165,8 @@ const AP_Param::GroupInfo AP_ICEngine::var_info[] = { | |
AP_GROUPINFO("REDLINE_RPM", 17, AP_ICEngine, redline_rpm, 0), | ||
#endif | ||
|
||
#if AP_RELAY_ENABLED | ||
// @Param: IGNITION_RLY | ||
// @DisplayName: Ignition relay channel | ||
// @Description: This is a a relay channel to use for ignition control | ||
// @User: Standard | ||
// @Values: 0:None,1:Relay1,2:Relay2,3:Relay3,4:Relay4,5:Relay5,6:Relay6 | ||
AP_GROUPINFO("IGNITION_RLY", 18, AP_ICEngine, ignition_relay, 0), | ||
#endif | ||
// 18 was IGNITION_RLY | ||
|
||
|
||
AP_GROUPEND | ||
}; | ||
|
@@ -608,15 +602,14 @@ void AP_ICEngine::update_idle_governor(int8_t &min_throttle) | |
void AP_ICEngine::set_ignition(bool on) | ||
{ | ||
SRV_Channels::set_output_pwm(SRV_Channel::k_ignition, on? pwm_ignition_on : pwm_ignition_off); | ||
|
||
#if AP_RELAY_ENABLED | ||
// optionally use a relay as well | ||
if (ignition_relay > 0) { | ||
auto *relay = AP::relay(); | ||
if (relay != nullptr) { | ||
relay->set(ignition_relay-1, on); | ||
} | ||
AP_Relay *relay = AP::relay(); | ||
if (relay != nullptr) { | ||
relay->set(AP_Relay_Params::FUNCTION::IGNITION, on); | ||
} | ||
#endif // AP_RELAY_ENABLED | ||
|
||
} | ||
|
||
/* | ||
|
@@ -638,6 +631,19 @@ bool AP_ICEngine::allow_throttle_while_disarmed() const | |
hal.util->safety_switch_state() != AP_HAL::Util::SAFETY_DISARMED; | ||
} | ||
|
||
#if AP_RELAY_ENABLED | ||
bool AP_ICEngine::get_legacy_ignition_relay_index(int8_t &num) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a case that we could just skip the param conversion here, the relay index param has only been in master for a few weeks. |
||
{ | ||
// PARAMETER_CONVERSION - Added: Dec-2023 | ||
if (!enable || !AP_Param::get_param_by_index(this, 18, AP_PARAM_INT8, &num)) { | ||
return false; | ||
} | ||
// convert to zero indexed | ||
num -= 1; | ||
return true; | ||
} | ||
#endif | ||
|
||
// singleton instance. Should only ever be set in the constructor. | ||
AP_ICEngine *AP_ICEngine::_singleton; | ||
namespace AP { | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern precludes us having two relay cameras, it seems. You might be in the second camera backend here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your right, but this is the current behavior. We certainly could add a second camera relay function in the future.