supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
control
sequence_button.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
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef SRC_SUPLA_CONTROL_SEQUENCE_BUTTON_H_
20
#define SRC_SUPLA_CONTROL_SEQUENCE_BUTTON_H_
21
22
#include <stdint.h>
23
24
#include "simple_button.h"
25
26
namespace
Supla {
27
namespace
Io {
28
class
Base
;
29
}
// namespace Io
30
31
namespace
Control {
32
33
#define SEQUENCE_MAX_SIZE 30
34
35
struct
ClickSequence
{
36
uint16_t data[SEQUENCE_MAX_SIZE];
37
};
38
39
class
SequenceButton :
public
SimpleButton {
40
public
:
41
explicit
SequenceButton(
Supla::Io::IoPin
inputPin);
42
explicit
SequenceButton(
Supla::Io::Base
*io,
43
int
pin,
44
bool
pullUp =
false
,
45
bool
invertLogic =
false
);
46
explicit
SequenceButton(
int
pin,
47
bool
pullUp =
false
,
48
bool
invertLogic =
false
);
49
50
void
onTimer
();
51
52
void
setSequence(uint16_t *sequence);
53
void
setMargin(
float
);
54
void
getLastRecordedSequence(uint16_t *sequence)
const
;
55
56
protected
:
57
unsigned
int
calculateMargin(
unsigned
int
);
58
59
uint32_t lastStateChangeMs = 0;
60
uint16_t longestSequenceTimeDeltaWithMargin = 800;
61
uint8_t clickCounter = 0;
62
bool
sequenceDetectecion =
true
;
63
float
margin = 0.3;
64
65
ClickSequence
currentSequence = {};
66
ClickSequence
matchSequence = {};
67
};
68
69
}
// namespace Control
70
}
// namespace Supla
71
72
#endif
// SRC_SUPLA_CONTROL_SEQUENCE_BUTTON_H_
Supla::Control::SequenceButton::onTimer
void onTimer()
Method called on timer interupt.
Definition
sequence_button.cpp:42
Supla::Io::Base
Definition
io.h:36
Supla::Control::ClickSequence
Definition
sequence_button.h:35
Supla::Io::IoPin
Definition
io_pin.h:28
Generated by
1.17.0