SimpleRelay
Toggle main menu visibility
Main Page
Related Pages
Classes
Class List
Class Index
Class Members
All
Functions
Files
File List
Examples
•
All
Classes
Files
Functions
Pages
Loading...
Searching...
No Matches
SimpleRelay.cpp
Go to the documentation of this file.
1
23
#include "
SimpleRelay.h
"
24
32
SimpleRelay::SimpleRelay
(uint8_t pin,
bool
isInverted) {
33
m_pin = pin;
34
m_relayOnLogicLevel = isInverted ? LOW : HIGH;
35
pinMode(m_pin, OUTPUT);
36
off
();
37
}
32
SimpleRelay::SimpleRelay
(uint8_t pin,
bool
isInverted) {
…
}
38
42
SimpleRelay::~SimpleRelay
() {
43
// set pin to high impedance
44
pinMode(m_pin, INPUT);
45
}
42
SimpleRelay::~SimpleRelay
() {
…
}
46
50
void
SimpleRelay::on
(
void
) {
51
m_state = State::RELAY_ON;
52
digitalWrite(m_pin, m_relayOnLogicLevel);
53
}
50
void
SimpleRelay::on
(
void
) {
…
}
54
58
void
SimpleRelay::off
(
void
) {
59
m_state = State::RELAY_OFF;
60
digitalWrite(m_pin, m_relayOnLogicLevel == HIGH ? LOW : HIGH);
61
}
58
void
SimpleRelay::off
(
void
) {
…
}
62
66
void
SimpleRelay::toggle
(
void
) {
67
if
(m_state == State::RELAY_ON) {
68
off
();
69
}
else
{
70
on
();
71
}
72
}
66
void
SimpleRelay::toggle
(
void
) {
…
}
73
78
bool
SimpleRelay::isRelayOn
(
void
) {
79
return
m_state == State::RELAY_ON;
80
}
78
bool
SimpleRelay::isRelayOn
(
void
) {
…
}
SimpleRelay.h
Relay library for Arduino.
SimpleRelay::~SimpleRelay
~SimpleRelay()
Destructor for the class.
Definition
SimpleRelay.cpp:42
SimpleRelay::isRelayOn
bool isRelayOn(void)
Get information if a relay is currently ON.
Definition
SimpleRelay.cpp:78
SimpleRelay::off
void off(void)
Set relay to OFF state.
Definition
SimpleRelay.cpp:58
SimpleRelay::on
void on(void)
Set relay to ON state.
Definition
SimpleRelay.cpp:50
SimpleRelay::toggle
void toggle(void)
Toggle relay state.
Definition
SimpleRelay.cpp:66
SimpleRelay::SimpleRelay
SimpleRelay(uint8_t pin, bool isInverted=false)
Constructor for the class.
Definition
SimpleRelay.cpp:32
src
SimpleRelay.cpp
Generated by
1.9.8