Skip to content

Commit

Permalink
AP_Relay: allow hwdef to provide more then 6 relays
Browse files Browse the repository at this point in the history
  • Loading branch information
WickedShell authored and IamPete1 committed Jan 3, 2024
1 parent 6fe7a14 commit f9fdd15
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
72 changes: 72 additions & 0 deletions libraries/AP_Relay/AP_Relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,95 @@ const AP_Param::GroupInfo AP_Relay::var_info[] = {
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[0], "1_", 7, AP_Relay, AP_Relay_Params),

#if AP_RELAY_NUM_RELAYS > 1
// @Group: 2_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[1], "2_", 8, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 2
// @Group: 3_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[2], "3_", 9, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 3
// @Group: 4_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[3], "4_", 10, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 4
// @Group: 5_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[4], "5_", 11, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 5
// @Group: 6_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[5], "6_", 12, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 6
// @Group: 7_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[6], "7_", 13, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 7
// @Group: 8_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[7], "8_", 14, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 8
// @Group: 9_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[8], "9_", 15, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 9
// @Group: 10_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[9], "10_", 16, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 10
// @Group: 11_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[10], "11_", 17, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 11
// @Group: 12_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[11], "12_", 18, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 12
// @Group: 13_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[12], "13_", 19, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 13
// @Group: 14_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[13], "14_", 20, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 14
// @Group: 15_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[14], "15_", 21, AP_Relay, AP_Relay_Params),
#endif

#if AP_RELAY_NUM_RELAYS > 15
// @Group: 16_
// @Path: AP_Relay_Params.cpp
AP_SUBGROUPINFO(_params[15], "16_", 22, AP_Relay, AP_Relay_Params),
#endif

AP_GROUPEND
};
Expand Down Expand Up @@ -402,6 +472,8 @@ bool AP_Relay::enabled(AP_Relay_Params::FUNCTION function) const
// supplied link for the message.
bool AP_Relay::send_relay_status(const GCS_MAVLINK &link) const
{
static_assert(AP_RELAY_NUM_RELAYS <= 16, "Too many relays for MAVLink status reporting to work.");

if (!HAVE_PAYLOAD_SPACE(link.get_chan(), RELAY_STATUS)) {
return false;
}
Expand Down
8 changes: 7 additions & 1 deletion libraries/AP_Relay/AP_Relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
#include <AP_Relay/AP_Relay_Params.h>
#include <AP_Common/Bitmask.h>

#define AP_RELAY_NUM_RELAYS 6
#ifndef AP_RELAY_NUM_RELAYS
#define AP_RELAY_NUM_RELAYS 6
#endif

#if AP_RELAY_NUM_RELAYS < 1
#error There must be at least one relay instance if using AP_Relay
#endif

/// @class AP_Relay
/// @brief Class to manage the ArduPilot relay
Expand Down

0 comments on commit f9fdd15

Please sign in to comment.