mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_Relay: Add singleton
This commit is contained in:
parent
1b48ce57f0
commit
062bca6361
@ -98,12 +98,20 @@ const AP_Param::GroupInfo AP_Relay::var_info[] = {
|
||||
AP_GROUPEND
|
||||
};
|
||||
|
||||
AP_Relay *AP_Relay::singleton;
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
AP_Relay::AP_Relay(void)
|
||||
{
|
||||
AP_Param::setup_object_defaults(this, var_info);
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||
if (singleton != nullptr) {
|
||||
AP_HAL::panic("AP_Relay must be singleton");
|
||||
}
|
||||
#endif
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,9 +38,13 @@ public:
|
||||
// toggle the relay status
|
||||
void toggle(uint8_t relay);
|
||||
|
||||
static AP_Relay *get_singleton(void) {return singleton; }
|
||||
|
||||
static const struct AP_Param::GroupInfo var_info[];
|
||||
|
||||
private:
|
||||
static AP_Relay *singleton;
|
||||
|
||||
AP_Int8 _pin[AP_RELAY_NUM_RELAYS];
|
||||
AP_Int8 _default;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user