AceButton  1.0.6
An Adjustable Compact Event-driven (ACE) button library for Arduino.
AdjustableButtonConfig.h
1 /*
2  Copyright 2018 Brian T. Park
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef ADJUSTABLE_BUTTON_CONFIG_H
18 #define ADJUSTABLE_BUTTON_CONFIG_H
19 
20 #include "ButtonConfig.h"
21 
22 namespace ace_button {
23 
32  public:
34  initInternal();
35  }
36 
37  virtual void init() override {
39  initInternal();
40  }
41 
42  virtual uint16_t getDebounceDelay() override {
43  return mDebounceDelay;
44  }
45 
46  virtual uint16_t getClickDelay() override {
47  return mClickDelay;
48  }
49 
50  virtual uint16_t getDoubleClickDelay() override {
51  return mDoubleClickDelay;
52  }
53 
54  virtual uint16_t getLongPressDelay() override {
55  return mLongPressDelay;
56  }
57 
58  virtual uint16_t getRepeatPressDelay() override {
59  return mRepeatPressDelay;
60  }
61 
62  virtual uint16_t getRepeatPressInterval() override {
63  return mRepeatPressInterval;
64  }
65 
67  void setDebounceDelay(uint16_t debounceDelay) {
68  mDebounceDelay = debounceDelay;
69  }
70 
72  void setClickDelay(uint16_t clickDelay) {
73  mClickDelay = clickDelay;
74  }
75 
77  void setDoubleClickDelay(uint16_t doubleClickDelay) {
78  mDoubleClickDelay = doubleClickDelay;
79  }
80 
82  void setLongPressDelay(uint16_t longPressDelay) {
83  mLongPressDelay = longPressDelay;
84  }
85 
87  void setRepeatPressDelay(uint16_t repeatPressDelay) {
88  mRepeatPressDelay = repeatPressDelay;
89  }
90 
92  void setRepeatPressInterval(uint16_t repeatPressInterval) {
93  mRepeatPressInterval = repeatPressInterval;
94  }
95 
96  private:
97  // Disable copy-constructor and assignment operator
99  AdjustableButtonConfig& operator=(const AdjustableButtonConfig&) = delete;
100 
101  // This method must remain non-virtual so that it can be called safely from
102  // the constructor.
103  void initInternal() {
104  mDebounceDelay = kDebounceDelay;
105  mClickDelay = kClickDelay;
106  mDoubleClickDelay = kDoubleClickDelay;
107  mLongPressDelay = kLongPressDelay;
108  mRepeatPressDelay = kRepeatPressDelay;
109  mRepeatPressInterval = kRepeatPressInterval;
110  }
111 
112  uint16_t mDebounceDelay;
113  uint16_t mClickDelay;
114  uint16_t mDoubleClickDelay;
115  uint16_t mLongPressDelay;
116  uint16_t mRepeatPressDelay;
117  uint16_t mRepeatPressInterval;
118 };
119 
120 }
121 #endif
static const uint16_t kRepeatPressInterval
Default value returned by getRepeatPressInterval().
Definition: ButtonConfig.h:92
virtual uint16_t getRepeatPressDelay() override
Milliseconds that a button needs to be Pressed down before the start of the sequence of RepeatPressed...
static const uint16_t kDebounceDelay
Default value returned by getDebounceDelay().
Definition: ButtonConfig.h:77
virtual void init() override
Initialize to its pristine state, except for the EventHandler which is unchanged. ...
virtual void init()
Initialize to its pristine state, except for the EventHandler which is unchanged. ...
Definition: ButtonConfig.h:275
void setRepeatPressInterval(uint16_t repeatPressInterval)
Set the repeatPressInterval.
void setLongPressDelay(uint16_t longPressDelay)
Set the longPressDelay.
A subclass of ButtonConfig which allows the user to override the varous timing parameters of ButtonCo...
virtual uint16_t getRepeatPressInterval() override
Milliseconds between two successive RepeatPressed events.
void setDebounceDelay(uint16_t debounceDelay)
Set the debounceDelay.
virtual uint16_t getDoubleClickDelay() override
Milliseconds between the first and second click to register as a double-click.
Class that defines the timing parameters and event handler of an AceButton or a group of AceButton in...
Definition: ButtonConfig.h:60
virtual uint16_t getLongPressDelay() override
Milliseconds for a long press event.
virtual uint16_t getClickDelay() override
Milliseconds to wait for a possible click.
virtual uint16_t getDebounceDelay() override
Milliseconds to wait for debouncing.
static const uint16_t kDoubleClickDelay
Default value returned by getDoubleClickDelay().
Definition: ButtonConfig.h:83
static const uint16_t kClickDelay
Default value returned by getClickDelay().
Definition: ButtonConfig.h:80
static const uint16_t kRepeatPressDelay
Default value returned by getRepeatPressDelay().
Definition: ButtonConfig.h:89
void setClickDelay(uint16_t clickDelay)
Set the clickDelay.
static const uint16_t kLongPressDelay
Default value returned by getLongPressDelay().
Definition: ButtonConfig.h:86
void setRepeatPressDelay(uint16_t repeatPressDelay)
Set the repeatPressDelay.
void setDoubleClickDelay(uint16_t doubleClickDelay)
Set the doubleClickDelay.