AceButton  1.0.0
An Adjustable Compact Event-driven (ACE) button library for Arduino.
TestableButtonConfig.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 TESTABLE_BUTTON_CONFIG_H
18 #define TESTABLE_BUTTON_CONFIG_H
19 
20 #include "ButtonConfig.h"
21 
22 namespace ace_button {
23 namespace testing {
24 
31  public:
33  mMillis(0),
34  mButtonState(HIGH) {}
35 
43  virtual void init() override {
45  mMillis = 0;
46  mButtonState = HIGH;
47  }
48 
50  virtual unsigned long getClock() override { return mMillis; }
51 
53  virtual int readButton(uint8_t pin) override { return mButtonState; }
54 
56  void setClock(unsigned long millis) { mMillis = millis; }
57 
59  void setButtonState(int buttonState) { mButtonState = buttonState; }
60 
61  private:
62  // Disable copy-constructor and assignment operator
64  TestableButtonConfig& operator=(const TestableButtonConfig&) = delete;
65 
66  unsigned long mMillis;
67  int mButtonState;
68 };
69 
70 }
71 }
72 #endif
virtual unsigned long getClock() override
Read the time of the fake clock.
Definition: TestableButtonConfig.h:50
virtual void init()
Initialize to its pristine state, except for the EventHandler which is unchanged. ...
Definition: ButtonConfig.h:259
A subclass of ButtonConfig which overrides getClock() and readButton() so that their values can be co...
Definition: TestableButtonConfig.h:30
void setClock(unsigned long millis)
Set the time of the fake clock.
Definition: TestableButtonConfig.h:56
Definition: AceButton.h:23
Class that defines the timing parameters and event handler of an AceButton or a group of AceButton in...
Definition: ButtonConfig.h:60
virtual int readButton(uint8_t pin) override
Read the fake physical button.
Definition: TestableButtonConfig.h:53
void setButtonState(int buttonState)
Set the state of the fake physical button.
Definition: TestableButtonConfig.h:59
virtual void init() override
Initialize to its pristine state.
Definition: TestableButtonConfig.h:43