Skip to content

Commit 42d9ddc

Browse files
committed
https://github.com/neu-rah/ArduinoMenu/issues/148
keypad test and example
1 parent 3a28064 commit 42d9ddc

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

examples/keypad/keypad/keypad.ino

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@
1010
using namespace Menu;
1111

1212
//define your keyboard ------------------------------------
13-
const byte ROWS = 1; //four rows
13+
const byte ROWS = 4; //four rows
1414
const byte COLS = 4; //four columns
1515
//define the cymbols on the buttons of the keypads
16-
char hexaKeys[ROWS][COLS] = {{'+','-','*','/'}};
17-
byte rowPins[ROWS] = {2}; //connect to the row pinouts of the keypad
18-
byte colPins[COLS] = {3,4,5,6}; //connect to the column pinouts of the keypad
16+
char hexaKeys[ROWS][COLS] = {
17+
{'1','2','3','A'},
18+
{'4','5','6','B'},
19+
{'7','8','9','-'},
20+
{'/','0','*','+'},
21+
};
22+
byte rowPins[ROWS] = {6,7,8,9}; //connect to the row pinouts of the keypad
23+
byte colPins[COLS] = {2,3,4,5}; //connect to the column pinouts of the keypad
1924

2025
//initialize an instance of class NewKeypad
21-
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
26+
Keypad customKeypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
2227

2328
//define a menu -----------------------------------------------------
2429
char* constMEM hexDigit MEMMODE="0123456789ABCDEF";
@@ -59,4 +64,5 @@ void setup() {
5964

6065
void loop() {
6166
nav.poll();
67+
delay(100);
6268
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoMenu library
2-
version=4.6.2
2+
version=4.6.3
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=Generic menu/interactivity system

src/menuIO/keypadIn.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,15 @@ using
2121
char key=0;
2222
Keypad& in;
2323
keypadIn(Keypad& in):in(in) {}
24-
int available(void) {return peek()!=0;}
25-
int peek(void) {
26-
int ret;
27-
28-
if (key) {
29-
return key;
30-
} else {
31-
key = (int)in.getKey();
32-
if (key) {
33-
return key;
34-
} else {
35-
return -1;
36-
}
37-
}
38-
}
24+
int available(void) {return peek()!=-1;}
25+
int peek(void) {return key?key:(key=in.getKey())?key:-1;}
3926
int read() {
4027
if (key) {
4128
char k=key;
4229
key=0;
4330
return k;
4431
}
45-
return peek();
32+
return available()?read():-1;
4633
}
4734
void flush() {}
4835
size_t write(uint8_t v) {return 0;}

0 commit comments

Comments
 (0)