APM:Libraries
AP_Relay.h
Go to the documentation of this file.
1 /*
2  * AP_Relay.h
3  *
4  * Created on: Oct 2, 2011
5  * Author: Amilcar Lucas
6  */
7 
10 #pragma once
11 
12 #include <AP_Param/AP_Param.h>
13 
14 #define AP_RELAY_NUM_RELAYS 4
15 
18 class AP_Relay {
19 public:
20  AP_Relay();
21 
22  /* Do not allow copies */
23  AP_Relay(const AP_Relay &other) = delete;
24  AP_Relay &operator=(const AP_Relay&) = delete;
25 
26  // setup the relay pin
27  void init();
28 
29  // activate the relay
30  void on(uint8_t relay);
31 
32  // de-activate the relay
33  void off(uint8_t relay);
34 
35  // see if the relay is enabled
36  bool enabled(uint8_t relay) { return relay < AP_RELAY_NUM_RELAYS && _pin[relay] != -1; }
37 
38  // toggle the relay status
39  void toggle(uint8_t relay);
40 
41  static const struct AP_Param::GroupInfo var_info[];
42 
43 private:
45  AP_Int8 _default;
46 };
AP_Relay()
Definition: AP_Relay.cpp:94
AP_Relay & operator=(const AP_Relay &)=delete
static AP_Relay relay
bool enabled(uint8_t relay)
Definition: AP_Relay.h:36
void off(uint8_t relay)
Definition: AP_Relay.cpp:127
void init()
Definition: AP_Relay.cpp:100
void on(uint8_t relay)
Definition: AP_Relay.cpp:118
A system for managing and storing variables that are of general interest to the system.
void toggle(uint8_t relay)
Definition: AP_Relay.cpp:136
AP_Int8 _pin[AP_RELAY_NUM_RELAYS]
Definition: AP_Relay.h:44
AP_Int8 _default
Definition: AP_Relay.h:45
Class to manage the ArduPilot relay.
Definition: AP_Relay.h:18
#define AP_RELAY_NUM_RELAYS
Definition: AP_Relay.h:14
static const struct AP_Param::GroupInfo var_info[]
Definition: AP_Relay.h:41