-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLCDKeyPadArq.cpp
73 lines (61 loc) · 1.4 KB
/
LCDKeyPadArq.cpp
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
63
64
65
66
67
68
69
70
71
72
73
/*
* LCDKeyPadArq.cpp
*
* Created on: 16 abr. 2017
* Author: Sergio
*/
#include "LCDKeyPadArq.h"
LCDKeyPadArq::LCDKeyPadArq()
: LiquidCrystal (LCD_RS, LCD_ENA, LCD_D4, LCD_D5, LCD_D6, LCD_D7)
{
// TODO Auto-generated constructor stub
}
LCDKeyPadArq::~LCDKeyPadArq() {
// TODO Auto-generated destructor stub
}
int LCDKeyPadArq::getButtonPressed () {
int state = KP_NO_BTN;
int x = analogRead (0);
//Check analog values from LCD Keypad Shield
if (x < 100) {
//Right
state = KP_BTN_RIGHT;
} else if (x < 200) {
//Up
state = KP_BTN_UP;
} else if (x < 400){
//Down
state = KP_BTN_DOWN;
} else if (x < 600){
//left
state = KP_BTN_LEFT;
} else if (x < 800){
//Select
state = KP_BTN_SELECT;
}
return state;
}
void LCDKeyPadArq::printLine(const char str[]) {
setCursor(0,0);
print (str);
}
void LCDKeyPadArq::HMILightDelay(long mSec) {
_DelayLight=true;
_DelayLightStart = millis();
_DelayLightTime = mSec;
}
bool LCDKeyPadArq::HMILightTimer () {
// returns true if timer is ON and still RUNNING
// returns false if timer is OFF or is ON but arrived to the limit TIME
if ((_DelayLight==true) and ((millis() -_DelayLightStart) < _DelayLightTime)) {
return true;}
return false;
}
void LCDKeyPadArq::turnLight(bool Status) {
digitalWrite(LCD_LIGHT, Status);
if (Status == ON) {
HMILightDelay(LIGHTTIME);
} else {
_DelayLight=false;
}
}