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 74 75 76 77 78 79 80 81 82 83 84 85
|
#include <DirectIO.h>
#include <Keypad.h>
template< byte* row, int NUMROWS, byte* col, int NUMCOLS>
class MyKeypad : public Keypad {
public:
Output<14> pin14;
Output<15> pin15;
Output<16> pin16;
Output<17> pin17;
Output<59> pin59;
Output<60> pin60;
Output<61> pin61;
MyKeypad(char *buttons ): Keypad( makeKeymap(buttons), row, col, NUMROWS, NUMCOLS){
};
virtual void pin_write(byte pinNum, boolean level) //14,15,16,17
{
//digitalWrite(pinNum, level);
switch (pinNum) {
case 14:
pin14=level;
break;
case 15:
pin15=level;
break;
case 16:
pin16=level;
break;
case 17:
pin17=level;
break;
}
}
virtual int pin_read(byte pinNum) //59 60 61
{
switch (pinNum) {
case 59:
return pin59.read();
break;
case 60:
return pin60.read();
break;
case 61:
return pin61.read();
break;
}
}
virtual void pin_mode(byte pinNum, byte mode) {
//Serial.println(mode);
pinMode(pinNum, mode);
}
};
//MATRIX
//A5 A6 A7
//14 15 16 17
#define NUMROWS 3
#define NUMCOLS 4
const uint8_t buttons[NUMROWS][NUMCOLS] = {
{'A', 'B', 'C', 'D'},
{'E', 'F', 'G', 'H'},
{'I', 'J', 'K', 'L'}
};
byte rowPins[NUMROWS] = {A5,A6,A7};
byte colPins[NUMCOLS] = {14,15,16,17};
MyKeypad<rowPins, NUMROWS, colPins, NUMCOLS> buttbx( makeKeymap(buttons));
void activate_keypad() {
//buttbx.setHoldTime(500);
buttbx.setDebounceTime(100);
}
|