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
28
class
MockButtonInput
:
public
InputInterface
{
29
public
:
30
MOCK_METHOD
(
void
,
begin
, (), (
override
));
31
32
void
check
()
override
{
33
InputAction
action =
_debounceOrHeld
(
_rawAction
);
34
if
(action !=
InputAction::PRESS_NONE
&&
_callback
!=
nullptr
) {
35
_callback
->
onInputAction
(action);
36
}
37
}
38
39
void
setRawAction
(
InputAction
action) {
_rawAction
= action; }
40
41
void
setIsCalibrating
(
bool
isCalibrating
) {
_isCalibrating
=
isCalibrating
; }
42
43
void
setNeedsDisplay
(
int
displayId) {
_needsDisplay
= displayId; }
44
45
private
:
46
InputAction
_rawAction
;
47
};
48
49
#endif
// MOCKBUTTONINPUT_H
CallbackInterface.h
InputAction
InputAction
Input action to be returned from the user interface to control screens and displays.
Definition
InputActions.h:22
PRESS_NONE
@ PRESS_NONE
Definition
InputActions.h:23
InputInterface.h
CallbackInterface::onInputAction
virtual void onInputAction(InputAction action)=0
Method to implement to respond to an input action.
InputInterface
Class to abstract away all physical input implementatio to enable multiple input types Default return...
Definition
InputInterface.h:28
InputInterface::begin
virtual void begin()=0
Perform any initial once off setup or configuration here and call only once.
InputInterface::_isCalibrating
bool _isCalibrating
Flag if the input interface is undergoing calibration - needed for touch screens.
Definition
InputInterface.h:79
InputInterface::_needsDisplay
int _needsDisplay
Display ID if this input interface requires a display instance - needed for TFT_eSPI as it shares the...
Definition
InputInterface.h:82
InputInterface::_callback
CallbackInterface * _callback
Pointer to the instance for callbacks Must implement updateScreen() and onInputAction() methods.
Definition
InputInterface.h:75
InputInterface::isCalibrating
bool isCalibrating()
Test if this InputInterface is undergoing calibration as required by touch screens.
Definition
InputInterface.cpp:24
InputInterface::_debounceOrHeld
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
MockButtonInput
Mock button input class using debounce and hold methods Use setRawAction() to simulate what a button ...
Definition
MockButtonInput.h:28
MockButtonInput::setIsCalibrating
void setIsCalibrating(bool isCalibrating)
Definition
MockButtonInput.h:41
MockButtonInput::setRawAction
void setRawAction(InputAction action)
Definition
MockButtonInput.h:39
MockButtonInput::_rawAction
InputAction _rawAction
Definition
MockButtonInput.h:46
MockButtonInput::MOCK_METHOD
MOCK_METHOD(void, begin,(),(override))
MockButtonInput::setNeedsDisplay
void setNeedsDisplay(int displayId)
Definition
MockButtonInput.h:43
MockButtonInput::check
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
test
mocks
MockButtonInput.h
Generated by
1.9.8