VLCB
Toggle main menu visibility
Loading...
Searching...
No Matches
Switch.h
Go to the documentation of this file.
1
// Copyright (C) Sven Rosvall (sven@rosvall.ie)
2
// This file is part of VLCB-Arduino project on https://github.com/SvenRosvall/VLCB-Arduino
3
// Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
4
// The full licence can be found at: http://creativecommons.org/licenses/by-nc-sa/4.0/
5
6
#pragma once
7
8
#ifndef DEBUG_SERIAL
9
#define DEBUG_SERIAL Serial
10
#endif
11
12
#include <Arduino.h>
// for definition of byte datatype
13
14
namespace
VLCB
15
{
16
17
// non-blocking switch class
18
19
class
Switch
20
{
21
public
:
22
explicit
Switch
(
byte
pin,
byte
pressedState = LOW);
23
Switch
();
24
void
setPin
(
byte
pin,
byte
mode);
25
void
run
();
26
void
reset
();
27
bool
stateChanged
();
28
bool
getState
();
29
bool
isPressed
();
30
unsigned
long
getCurrentStateDuration
();
31
unsigned
long
getLastStateDuration
();
32
unsigned
long
getLastStateChangeTime
();
33
void
resetCurrentDuration
();
34
35
protected
:
36
byte
readPin
();
37
byte
_pin
;
38
byte
_pressedState
;
39
byte
_currentState
;
40
byte
_lastState
;
41
byte
_stateChanged
;
42
unsigned
long
_lastStateChangeTime
;
43
unsigned
long
_lastStateDuration
;
44
unsigned
long
_prevReleaseTime
;
45
unsigned
long
_prevStateDuration
;
46
};
47
48
}
VLCB::Switch::stateChanged
bool stateChanged()
Definition
Switch.cpp:105
VLCB::Switch::_lastStateChangeTime
unsigned long _lastStateChangeTime
Definition
Switch.h:42
VLCB::Switch::getCurrentStateDuration
unsigned long getCurrentStateDuration()
Definition
Switch.cpp:126
VLCB::Switch::setPin
void setPin(byte pin, byte mode)
Definition
Switch.cpp:31
VLCB::Switch::_lastStateDuration
unsigned long _lastStateDuration
Definition
Switch.h:43
VLCB::Switch::Switch
Switch()
a class to encapsulate a physical pushbutton switch, with non-blocking processing
Definition
Switch.cpp:15
VLCB::Switch::run
void run()
Definition
Switch.cpp:60
VLCB::Switch::_pressedState
byte _pressedState
Definition
Switch.h:38
VLCB::Switch::resetCurrentDuration
void resetCurrentDuration()
Definition
Switch.cpp:147
VLCB::Switch::isPressed
bool isPressed()
Definition
Switch.cpp:119
VLCB::Switch::_lastState
byte _lastState
Definition
Switch.h:40
VLCB::Switch::getState
bool getState()
Definition
Switch.cpp:112
VLCB::Switch::Switch
Switch(byte pin, byte pressedState=LOW)
Definition
Switch.cpp:19
VLCB::Switch::_stateChanged
byte _stateChanged
Definition
Switch.h:41
VLCB::Switch::_prevStateDuration
unsigned long _prevStateDuration
Definition
Switch.h:45
VLCB::Switch::_pin
byte _pin
Definition
Switch.h:37
VLCB::Switch::getLastStateDuration
unsigned long getLastStateDuration()
Definition
Switch.cpp:133
VLCB::Switch::_currentState
byte _currentState
Definition
Switch.h:39
VLCB::Switch::getLastStateChangeTime
unsigned long getLastStateChangeTime()
Definition
Switch.cpp:140
VLCB::Switch::readPin
byte readPin()
Definition
Switch.cpp:55
VLCB::Switch::_prevReleaseTime
unsigned long _prevReleaseTime
Definition
Switch.h:44
VLCB::Switch::reset
void reset()
Definition
Switch.cpp:45
VLCB
Definition
AbstractEventTeachingService.cpp:13
src
Switch.h
Generated by
1.18.0