supla-device
Loading...
Searching...
No Matches
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
26namespace Supla {
27namespace Control {
28
29#define SEQUENCE_MAX_SIZE 30
30
32 uint16_t data[SEQUENCE_MAX_SIZE];
33};
34
35class SequenceButton : public SimpleButton {
36 public:
37 explicit SequenceButton(Supla::Io *io,
38 int pin,
39 bool pullUp = false,
40 bool invertLogic = false);
41 explicit SequenceButton(int pin,
42 bool pullUp = false,
43 bool invertLogic = false);
44
45 void onTimer();
46
47 void setSequence(uint16_t *sequence);
48 void setMargin(float);
49 void getLastRecordedSequence(uint16_t *sequence) const;
50
51 protected:
52 unsigned int calculateMargin(unsigned int);
53
54 uint32_t lastStateChangeMs = 0;
55 uint16_t longestSequenceTimeDeltaWithMargin = 800;
56 uint8_t clickCounter = 0;
57 bool sequenceDetectecion = true;
58 float margin = 0.3;
59
60 ClickSequence currentSequence = {};
61 ClickSequence matchSequence = {};
62};
63
64} // namespace Control
65} // namespace Supla
66
67#endif // SRC_SUPLA_CONTROL_SEQUENCE_BUTTON_H_
void onTimer()
Method called on timer interupt.
Definition sequence_button.cpp:38
Definition io.h:33
Definition sequence_button.h:31