2011-10-01 19:55:41 -03:00
|
|
|
/*
|
|
|
|
* AP_Relay.h
|
|
|
|
*
|
|
|
|
* Created on: Oct 2, 2011
|
|
|
|
* Author: Amilcar Lucas
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// @file AP_Relay.h
|
|
|
|
/// @brief APM relay control class
|
2016-02-17 21:25:46 -04:00
|
|
|
#pragma once
|
2011-10-01 19:55:41 -03:00
|
|
|
|
2015-08-11 03:28:45 -03:00
|
|
|
#include <AP_Param/AP_Param.h>
|
2013-06-24 09:39:18 -03:00
|
|
|
|
2018-10-03 10:03:49 -03:00
|
|
|
#define AP_RELAY_NUM_RELAYS 6
|
2014-01-19 21:59:21 -04:00
|
|
|
|
2011-10-01 19:55:41 -03:00
|
|
|
/// @class AP_Relay
|
2017-08-29 15:08:41 -03:00
|
|
|
/// @brief Class to manage the ArduPilot relay
|
2012-08-17 03:21:08 -03:00
|
|
|
class AP_Relay {
|
2011-10-01 19:55:41 -03:00
|
|
|
public:
|
2017-12-12 21:06:14 -04:00
|
|
|
AP_Relay();
|
2017-08-29 15:08:41 -03:00
|
|
|
|
|
|
|
/* Do not allow copies */
|
|
|
|
AP_Relay(const AP_Relay &other) = delete;
|
|
|
|
AP_Relay &operator=(const AP_Relay&) = delete;
|
2013-06-24 09:39:18 -03:00
|
|
|
|
2012-12-04 19:26:30 -04:00
|
|
|
// setup the relay pin
|
|
|
|
void init();
|
|
|
|
|
2012-08-17 03:21:08 -03:00
|
|
|
// activate the relay
|
2014-01-19 21:59:21 -04:00
|
|
|
void on(uint8_t relay);
|
2011-10-01 19:55:41 -03:00
|
|
|
|
2012-08-17 03:21:08 -03:00
|
|
|
// de-activate the relay
|
2014-01-19 21:59:21 -04:00
|
|
|
void off(uint8_t relay);
|
2011-10-01 19:55:41 -03:00
|
|
|
|
2014-01-20 00:35:38 -04:00
|
|
|
// see if the relay is enabled
|
|
|
|
bool enabled(uint8_t relay) { return relay < AP_RELAY_NUM_RELAYS && _pin[relay] != -1; }
|
|
|
|
|
2012-08-17 03:21:08 -03:00
|
|
|
// toggle the relay status
|
2014-01-19 21:59:21 -04:00
|
|
|
void toggle(uint8_t relay);
|
2011-10-01 19:55:41 -03:00
|
|
|
|
2019-04-22 20:12:56 -03:00
|
|
|
static AP_Relay *get_singleton(void) {return singleton; }
|
|
|
|
|
2013-06-24 09:39:18 -03:00
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
2011-10-01 19:55:41 -03:00
|
|
|
|
2013-06-24 09:39:18 -03:00
|
|
|
private:
|
2019-04-22 20:12:56 -03:00
|
|
|
static AP_Relay *singleton;
|
|
|
|
|
2014-01-19 21:59:21 -04:00
|
|
|
AP_Int8 _pin[AP_RELAY_NUM_RELAYS];
|
2014-09-04 03:45:45 -03:00
|
|
|
AP_Int8 _default;
|
2011-10-01 19:55:41 -03:00
|
|
|
};
|
2019-06-27 04:22:21 -03:00
|
|
|
|
|
|
|
namespace AP {
|
|
|
|
AP_Relay *relay();
|
|
|
|
};
|