-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremote.h
62 lines (44 loc) · 1.15 KB
/
remote.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
60
61
62
/*
*******************************************************
LED fountain
Randomly turns on different 4 LEDs and adjusts PWM
for a percentage, representing the pump.
*******************************************************
*/
#ifndef remote_lib
#define remote_lib
#include "Arduino.h"
class Button {
int pin;
int lastread;
#if !defined(__AVR_ATmega2560__)
// This isn't specific to Uno but rather my test board doesn't have a latching switch
int fakelatch;
#endif
public:
Button(){};
Button(int pin_num);
void init(int pin_num);
int getState(); // Consumes the state change.
int peekState(); // simply reads state without clearing change state.s
boolean pressed(); // doesn't consume press.
boolean hasChanged(); // consumes the button press.
};
#if defined(__AVR_ATmega2560__)
#define NUM_BUTTONS 4
#else
#define NUM_BUTTONS 1
#endif
class Remote {
public:
Button button[4];
Remote(){};
void init(int pin_a, int pin_b, int pin_c, int pin_d);
void init(int firstpin);
Button* getButton(int button_ndx);
boolean pressed();
int getState();
boolean pause(int msec);
void clear();
};
#endif