EX-Display
EX-Display
Loading...
Searching...
No Matches
MockButtonInput.h
Go to the documentation of this file.
1/*
2 * © 2024 Peter Cole
3 *
4 * This is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * It 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 code. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef MOCKBUTTONINPUT_H
19#define MOCKBUTTONINPUT_H
20
21#include "CallbackInterface.h"
22#include "InputInterface.h"
23#include <gmock/gmock.h>
24
29public:
30 MOCK_METHOD(void, begin, (), (override));
31
32 void check() override {
34 if (action != InputAction::PRESS_NONE && _callback != nullptr) {
35 _callback->onInputAction(action);
36 }
37 }
38
39 void setRawAction(InputAction action) { _rawAction = action; }
40
42
43 void setNeedsDisplay(int displayId) { _needsDisplay = displayId; }
44
45private:
47};
48
49#endif // MOCKBUTTONINPUT_H
InputAction
Input action to be returned from the user interface to control screens and displays.
Definition InputActions.h:22
@ PRESS_NONE
Definition InputActions.h:23
virtual void onInputAction(InputAction action)=0
Method to implement to respond to an input action.
Class to abstract away all physical input implementatio to enable multiple input types Default return...
Definition InputInterface.h:28
virtual void begin()=0
Perform any initial once off setup or configuration here and call only once.
bool _isCalibrating
Flag if the input interface is undergoing calibration - needed for touch screens.
Definition InputInterface.h:79
int _needsDisplay
Display ID if this input interface requires a display instance - needed for TFT_eSPI as it shares the...
Definition InputInterface.h:82
CallbackInterface * _callback
Pointer to the instance for callbacks Must implement updateScreen() and onInputAction() methods.
Definition InputInterface.h:75
bool isCalibrating()
Test if this InputInterface is undergoing calibration as required by touch screens.
Definition InputInterface.cpp:24
InputAction _debounceOrHeld(InputAction currentAction)
Call this from the derived class' check() method to debounce and detect if the input is a hold vs....
Definition InputInterface.cpp:42
Mock button input class using debounce and hold methods Use setRawAction() to simulate what a button ...
Definition MockButtonInput.h:28
void setIsCalibrating(bool isCalibrating)
Definition MockButtonInput.h:41
void setRawAction(InputAction action)
Definition MockButtonInput.h:39
InputAction _rawAction
Definition MockButtonInput.h:46
MOCK_METHOD(void, begin,(),(override))
void setNeedsDisplay(int displayId)
Definition MockButtonInput.h:43
void check() override
Call this method at least once per main loop to monitor for input actions Any actions should call the...
Definition MockButtonInput.h:32