Optimized polling keybolard reading

Dependents:   design_project

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Keypad3x4polling.h Source File

Keypad3x4polling.h

00001 #ifndef KEYPAD3x4POLLING_H
00002 #define KEYPAD3x4POLLING_H
00003 
00004 #include "BusOut.h"
00005 #include "BusIn.h"
00006 
00007 #define NO_PRESS 10
00008 
00009 namespace mbed
00010 {                  
00011     class Keypad
00012     {    
00013         public:
00014             Keypad(PinName col1,PinName col2,PinName col3,PinName row1,PinName row2,PinName row3,PinName row4);
00015             char read();
00016         protected:
00017             BusIn _cols;    
00018             BusOut _rows;
00019     };
00020 }
00021 #endif
00022 
00023 /*SIMPLE EXAMPLE
00024 
00025 #include "mbed.h"
00026 #include "Keypad3x4polling.h"
00027 
00028 Serial pc(USBTX,USBRX);
00029 
00030 Keypad Keyboard(p17,p16,p15,p10,p9,p8,p7);
00031 
00032 int main() 
00033 {       
00034     char button;  
00035     pc.printf("Premi un tasto:");
00036     while(1)
00037     {
00038         button = Keyboard.read();
00039         if(button != NO_PRESS)
00040             pc.putc(button);  
00041         wait(0.2);             
00042     }    
00043 }
00044 
00045 */