-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathButton.h
61 lines (52 loc) · 1.54 KB
/
Button.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
||
|| @file Button.h
|| @version 1.6
|| @author Alexander Brevig
|| @contact [email protected]
||
|| @description
|| | Provide an easy way of making buttons
|| #
||
|| @license
|| | Copyright (c) 2009 Alexander Brevig. All rights reserved.
|| | This code is subject to AlphaLicence.txt
|| | alphabeta.alexanderbrevig.com/AlphaLicense.txt
|| #
||
*/
#ifndef BUTTON_H
#define BUTTON_H
#include <Arduino.h>
#define PULLUP HIGH
#define PULLDOWN LOW
#define CURRENT 0
#define PREVIOUS 1
#define CHANGED 2
class Button{
public:
Button(uint8_t buttonPin, uint8_t buttonMode = PULLDOWN);
void pullup();
void pulldown();
bool isPressed();
bool wasPressed();
bool stateChanged();
bool uniquePress();
private:
uint8_t pin;
uint8_t mode;
uint8_t state;
};
#endif
/*
0|| @changelog
|| | 1.6 2009-05-05 - Alexander Brevig : Added uniquePress, it returns true if the state has changed AND the button is pressed
|| | 1.5 2009-04-24 - Alexander Brevig : Added stateChanged, @contribution http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=viewprofile;username=klickadiklick
|| | 1.4 2009-04-24 - Alexander Brevig : Added wasPressed, @contribution http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=viewprofile;username=klickadiklick
|| | 1.3 2009-04-12 - Alexander Brevig : Added constructor with one parameter Button(uint8_t buttonPin)
|| | 1.2 2009-04-10 - Alexander Brevig : Namechange from Switch to Button
|| | 1.1 2009-04-07 - Alexander Brevig : Altered API
|| | 1.0 2008-10-23 - Alexander Brevig : Initial Release
|| #
*/