Skip to content

Commit b6eb889

Browse files
author
Vladimir Kozlov
committed
Basic support for pcf8574 i2c keypad
1 parent ab7b4f9 commit b6eb889

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/menuIO/I2CkeypadIn.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* -*- C++ -*- */
2+
/**************
3+
Jan. 2018 Rui Azevedo - ruihfazevedo(@rrob@)gmail.com
4+
5+
I2C keypad driver
6+
using
7+
https://github.com/whatnick/i2ckeypad
8+
9+
Note: you may be need to adjust keypad-to-pcf8574 pin mappings and keymap in i2ckeypad.cpp for your specific keypad.
10+
11+
***/
12+
13+
#ifndef RSITE_I2CKEYPAD_DEF_H
14+
#define RSITE_I2CKEYPAD_DEF_H
15+
#include "../menuDefs.h"
16+
17+
#include <i2ckeypad.h>
18+
namespace Menu {
19+
20+
class I2CkeypadIn:public menuIn {
21+
public:
22+
char key=0;
23+
i2ckeypad * in;
24+
I2CkeypadIn(i2ckeypad * in):in(in) {}
25+
int available(void) {
26+
return peek()!=0;
27+
}
28+
int peek(void) {
29+
return key != 0 ? key : (key=in->get_key()) ?key : 0;
30+
}
31+
int read() {
32+
if (key != 0) {
33+
char k=key;
34+
key=0;
35+
return k;
36+
}
37+
return available()?read():0;
38+
}
39+
void flush() {}
40+
size_t write(uint8_t v) {return 0;}
41+
};
42+
};
43+
#endif

0 commit comments

Comments
 (0)