2011-10-01 19:55:41 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AP_Relay.h
|
|
|
|
*
|
|
|
|
* Created on: Oct 2, 2011
|
|
|
|
* Author: Amilcar Lucas
|
|
|
|
*/
|
|
|
|
|
|
|
|
/// @file AP_Relay.h
|
|
|
|
/// @brief APM relay control class
|
|
|
|
|
2012-11-30 21:47:32 -04:00
|
|
|
#ifndef __AP_RELAY_H__
|
|
|
|
#define __AP_RELAY_H__
|
2011-10-01 19:55:41 -03:00
|
|
|
|
2013-06-24 09:39:18 -03:00
|
|
|
#include <AP_Param.h>
|
|
|
|
|
2014-01-19 21:59:21 -04:00
|
|
|
#define AP_RELAY_NUM_RELAYS 4
|
|
|
|
|
2011-10-01 19:55:41 -03:00
|
|
|
/// @class AP_Relay
|
|
|
|
/// @brief Class to manage the APM relay
|
2012-08-17 03:21:08 -03:00
|
|
|
class AP_Relay {
|
2011-10-01 19:55:41 -03:00
|
|
|
public:
|
2013-06-24 09:39:18 -03:00
|
|
|
AP_Relay();
|
|
|
|
|
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
|
|
|
|
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:
|
2014-01-19 21:59:21 -04:00
|
|
|
AP_Int8 _pin[AP_RELAY_NUM_RELAYS];
|
2011-10-01 19:55:41 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* AP_RELAY_H_ */
|