Keypad that has 12 keys for input

Dependents:   Input_Keypad MARISOL Final_Project

Committer:
anevil14
Date:
Thu Mar 12 17:45:35 2015 +0000
Revision:
2:795c6863bbc2
Parent:
0:34c3354147cf
12 Input Keypad from Sparkfun

Who changed what in which revision?

UserRevisionLine numberNew contents of line
anevil14 0:34c3354147cf 1 #ifndef MBED_KEYPAD_H
anevil14 0:34c3354147cf 2 #define MBED_KEYPAD_H
anevil14 0:34c3354147cf 3
anevil14 0:34c3354147cf 4 #include "mbed.h"
anevil14 0:34c3354147cf 5 #include <vector>
anevil14 0:34c3354147cf 6 #include <algorithm>
anevil14 0:34c3354147cf 7 #include <time.h>
anevil14 0:34c3354147cf 8
anevil14 0:34c3354147cf 9 //Keypad class. A 4x3 keypad class. Documentation is available on wiki @ ___________
anevil14 0:34c3354147cf 10 //Usage: Instantiate object, and use getkey method to retrieve keys pressed. Might want to play around with switchrate to get better responsiveness (decides how fast we switch powering columns)
anevil14 0:34c3354147cf 11 //Important note: Can only reliably detect a keypress in a single row at any given time, although multiple key detection in different rows is supported (eg 1 and 4 is detected simulataneously, 1 and 3 will just detect one of those)
anevil14 0:34c3354147cf 12
anevil14 0:34c3354147cf 13 /* Keypad Representations
anevil14 0:34c3354147cf 14 1 2 3 1 2 3
anevil14 0:34c3354147cf 15 4 5 6 -> 4 5 6
anevil14 0:34c3354147cf 16 7 8 9 7 8 9
anevil14 0:34c3354147cf 17 * 0 # 10 11 12
anevil14 0:34c3354147cf 18
anevil14 0:34c3354147cf 19 */
anevil14 0:34c3354147cf 20 class KeyPad2{
anevil14 0:34c3354147cf 21 public:
anevil14 0:34c3354147cf 22
anevil14 0:34c3354147cf 23 KeyPad2(PinName pin3, PinName pin1 ,PinName pin5 ,PinName pin2, PinName pin7,PinName pin6, PinName pin4);
anevil14 0:34c3354147cf 24
anevil14 0:34c3354147cf 25 void setswitchrate(double switchrate);
anevil14 0:34c3354147cf 26
anevil14 0:34c3354147cf 27 // sets function to be called when any button is pressed
anevil14 0:34c3354147cf 28 // function should take in one parameter which will represent the button pressed (int)
anevil14 0:34c3354147cf 29 void setinterrupthandler(const void* func);
anevil14 0:34c3354147cf 30
anevil14 0:34c3354147cf 31 ~KeyPad2();
anevil14 0:34c3354147cf 32
anevil14 0:34c3354147cf 33
anevil14 0:34c3354147cf 34 // takes roughly 3x switchrate + processing time
anevil14 0:34c3354147cf 35 std::vector<int> getkey();
anevil14 0:34c3354147cf 36
anevil14 0:34c3354147cf 37 private:
anevil14 0:34c3354147cf 38
anevil14 0:34c3354147cf 39 // the time in milliseconds which each power will be powered for before switching to the next
anevil14 0:34c3354147cf 40 // default = 10 milliseconds
anevil14 0:34c3354147cf 41 double switchrate;
anevil14 0:34c3354147cf 42
anevil14 0:34c3354147cf 43
anevil14 0:34c3354147cf 44 DigitalOut* columnoneout; // pin 3 on keypad
anevil14 0:34c3354147cf 45 DigitalOut* columntwoout; // pin 1 on keypad
anevil14 0:34c3354147cf 46 DigitalOut* columnthreeout; // pin 5 on keypad
anevil14 0:34c3354147cf 47
anevil14 0:34c3354147cf 48
anevil14 0:34c3354147cf 49 DigitalIn* rowonein; // pin 2 on keypad
anevil14 0:34c3354147cf 50 DigitalIn* rowtwoin; // pin 7 on keypad
anevil14 0:34c3354147cf 51 DigitalIn* rowthreein; // pin 6 on keypad
anevil14 0:34c3354147cf 52 DigitalIn* rowfourin; // pin 4 on keypard
anevil14 0:34c3354147cf 53
anevil14 0:34c3354147cf 54
anevil14 0:34c3354147cf 55
anevil14 0:34c3354147cf 56
anevil14 0:34c3354147cf 57
anevil14 0:34c3354147cf 58
anevil14 0:34c3354147cf 59 };
anevil14 0:34c3354147cf 60 #endif