supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
control
bistable_relay.h
1
/*
2
Copyright (C) AC SOFTWARE SP. Z O.O.
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
*/
16
17
/* BistableRelay
18
* This class can be used to controll bistable relay.
19
* Supla device will send short impulses (<0.5 s) on GPIO to toggle bistable
20
* relay state.
21
* Device does not have knowledge about the status of bistable relay, so it
22
* has to be read on a different GPIO (statusPin)
23
* This class can work without statusPin information, but Supla will lose
24
* information about status of bistable relay.
25
*/
26
27
#ifndef SRC_SUPLA_CONTROL_BISTABLE_RELAY_H_
28
#define SRC_SUPLA_CONTROL_BISTABLE_RELAY_H_
29
30
#include <supla-common/proto.h>
31
#include <stdint.h>
32
33
#include "../io.h"
34
#include "relay.h"
35
36
namespace
Supla {
37
namespace
Io {
38
struct
IoPin
;
39
}
40
41
namespace
Control {
42
class
BistableRelay
:
public
Relay {
43
public
:
58
BistableRelay
(
int
pin,
59
int
statusPin = -1,
60
bool
statusPullUp =
true
,
61
bool
statusHighIsOn =
true
,
62
bool
highIsOn =
true
,
63
_supla_int_t functions =
64
(0xFF ^ SUPLA_BIT_FUNC_CONTROLLINGTHEROLLERSHUTTER));
65
66
BistableRelay
(
Supla::Io::IoPin
outputPin,
67
Supla::Io::IoPin
statusPin = {},
68
_supla_int_t functions =
69
(0xFF ^ SUPLA_BIT_FUNC_CONTROLLINGTHEROLLERSHUTTER));
70
83
BistableRelay
(
Supla::Io::Base
*io,
84
int
pin,
85
int
statusPin = -1,
86
bool
statusPullUp =
true
,
87
bool
statusHighIsOn =
true
,
88
bool
highIsOn =
true
,
89
_supla_int_t functions =
90
(0xFF ^ SUPLA_BIT_FUNC_CONTROLLINGTHEROLLERSHUTTER));
91
105
BistableRelay
(
Supla::Io::Base
*ioOut,
106
Supla::Io::Base
*ioState,
107
int
pin,
108
int
statusPin = -1,
109
bool
statusPullUp =
true
,
110
bool
statusHighIsOn =
true
,
111
bool
highIsOn =
true
,
112
_supla_int_t functions =
113
(0xFF ^ SUPLA_BIT_FUNC_CONTROLLINGTHEROLLERSHUTTER));
114
115
void
onInit
()
override
;
116
void
iterateAlways
()
override
;
117
int32_t
handleNewValueFromServer
(
TSD_SuplaChannelNewValue
*newValue)
override
;
118
void
turnOn(_supla_int_t duration = 0)
override
;
119
void
turnOff(_supla_int_t duration = 0)
override
;
120
void
toggle(_supla_int_t duration = 0)
override
;
121
122
bool
isOn()
override
;
123
bool
isStatusUnknown();
124
125
protected
:
126
void
internalToggle();
127
128
uint32_t disarmTimeMs = 0;
129
uint32_t lastReadTime = 0;
130
131
Supla::Io::IoPin
statusInputPin;
132
bool
busy =
false
;
133
bool
lastCommandTurnOn =
false
;
134
};
135
136
};
// namespace Control
137
};
// namespace Supla
138
139
#endif
// SRC_SUPLA_CONTROL_BISTABLE_RELAY_H_
Supla::Control::BistableRelay::iterateAlways
void iterateAlways() override
Method called on each SuplaDevice iteration.
Definition
bistable_relay.cpp:134
Supla::Control::BistableRelay::onInit
void onInit() override
Third method called on element in SuplaDevice.begin().
Definition
bistable_relay.cpp:114
Supla::Control::BistableRelay::BistableRelay
BistableRelay(int pin, int statusPin=-1, bool statusPullUp=true, bool statusHighIsOn=true, bool highIsOn=true, _supla_int_t functions=(0xFF ^ SUPLA_BIT_FUNC_CONTROLLINGTHEROLLERSHUTTER))
BistableRelay constructor which works on ESP's GPIO (with defaul Supla::Io).
Definition
bistable_relay.cpp:84
Supla::Control::BistableRelay::handleNewValueFromServer
int32_t handleNewValueFromServer(TSD_SuplaChannelNewValue *newValue) override
Handles "new value" request from server.
Definition
bistable_relay.cpp:159
Supla::Io::Base
Definition
io.h:36
Supla::Io::IoPin
Definition
io_pin.h:28
TSD_SuplaChannelNewValue
Definition
proto.h:1224
Generated by
1.17.0