supla-device
Loading...
Searching...
No Matches
sequence_button.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_CONTROL_SEQUENCE_BUTTON_H_
5#define SRC_SUPLA_CONTROL_SEQUENCE_BUTTON_H_
6
7#include <stdint.h>
8
9#include "simple_button.h"
10
11namespace Supla {
12namespace Io {
13class Base;
14} // namespace Io
15
16namespace Control {
17
18#define SEQUENCE_MAX_SIZE 30
19
21 uint16_t data[SEQUENCE_MAX_SIZE];
22};
23
25 public:
26 explicit SequenceButton(Supla::Io::IoPin inputPin);
28 int pin,
29 bool pullUp = false,
30 bool invertLogic = false);
31 explicit SequenceButton(int pin,
32 bool pullUp = false,
33 bool invertLogic = false);
34
35 void onTimer();
36
37 void setSequence(uint16_t *sequence);
38 void setMargin(float);
39 void getLastRecordedSequence(uint16_t *sequence) const;
40
41 protected:
42 unsigned int calculateMargin(unsigned int);
43
44 uint32_t lastStateChangeMs = 0;
45 uint16_t longestSequenceTimeDeltaWithMargin = 800;
46 uint8_t clickCounter = 0;
47 bool sequenceDetectecion = true;
48 float margin = 0.3;
49
50 ClickSequence currentSequence = {};
51 ClickSequence matchSequence = {};
52};
53
54} // namespace Control
55} // namespace Supla
56
57#endif // SRC_SUPLA_CONTROL_SEQUENCE_BUTTON_H_
Definition sequence_button.h:24
void onTimer()
Method called on timer interupt.
Definition sequence_button.cpp:27
Definition simple_button.h:47
Definition io.h:23
Definition sequence_button.h:20
Definition io_pin.h:14