Keypad that has 12 keys for input

Dependents:   Input_Keypad MARISOL Final_Project

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers KeyPad.h Source File

KeyPad.h

00001 #ifndef MBED_KEYPAD_H
00002 #define MBED_KEYPAD_H
00003 
00004 #include "mbed.h"
00005 #include <vector>
00006 #include <algorithm>
00007 #include <time.h>
00008 
00009 //Keypad class.  A 4x3 keypad class.  Documentation is available on wiki @ ___________
00010 //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)
00011 //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)
00012 
00013 /*  Keypad      Representations
00014     1 2 3       1   2  3 
00015     4 5 6   ->  4   5  6 
00016     7 8 9       7   8  9
00017     * 0 #       10  11 12
00018     
00019 */
00020 class KeyPad2{
00021     public:
00022       
00023         KeyPad2(PinName pin3, PinName pin1 ,PinName pin5 ,PinName pin2, PinName pin7,PinName pin6, PinName pin4);
00024         
00025         void setswitchrate(double switchrate);
00026         
00027         // sets function to be called when any button is pressed 
00028         // function should take in one parameter which will represent the button pressed (int)
00029         void setinterrupthandler(const void* func);     
00030         
00031         ~KeyPad2();
00032         
00033         
00034         // takes roughly 3x switchrate + processing time
00035         std::vector<int> getkey();
00036         
00037     private:
00038     
00039         // the time in milliseconds which each power will be powered for before switching to the next 
00040         // default = 10 milliseconds           
00041         double switchrate;   
00042        
00043           
00044         DigitalOut* columnoneout;      // pin 3 on keypad 
00045         DigitalOut* columntwoout;      // pin 1 on keypad
00046         DigitalOut* columnthreeout;    // pin 5 on keypad
00047 
00048     
00049         DigitalIn* rowonein;           // pin 2 on keypad 
00050         DigitalIn* rowtwoin;           // pin 7 on keypad
00051         DigitalIn* rowthreein;         // pin 6 on keypad
00052         DigitalIn* rowfourin;          // pin 4 on keypard  
00053         
00054        
00055         
00056         
00057         
00058     
00059 };
00060 #endif