libreria teclado

Dependents:   Tarea3_Teclado Tarea3_Teclado_Mejoras Tarea3_Teclado_sonido IngresoHORA ... more

Fork of keypad by Leonardo Restrepo

Embed: (wiki syntax)

« Back to documentation index

Keypad Class Reference

Keypad Class Reference

An interrupt-based interface to 4x4 keypad. More...

#include <keypad.h>

Public Member Functions

 Keypad (PinName row3, PinName row2, PinName row1, PinName row0, PinName col3, PinName col2, PinName col1, PinName col0, int debounce_ms=20)
 Create a Keypad interface.
void Start (void)
 Start the keypad interrupt routines.
void Stop (void)
 Stop the keypad interrupt routines.
void CallAfterInput (uint32_t(*fptr)(uint32_t))
 User-defined function that to be called when a key is pressed.

Detailed Description

An interrupt-based interface to 4x4 keypad.

On each key pressed on a keypad, the index of the key is passed to a user-defined function. User is free to define what to be done with the input.

This library makes use of

See also:
http://mbed.org/cookbook/FPointer by Andy Kirkham

Example:

 #include "mbed.h"
 #include "keypad.h"
 
 // Define your own keypad values
 char Keytable[] = { '1', '2', '3', 'A',
                     '4', '5', '6', 'B',
                     '7', '8', '9', 'C',
                     '*', '0', '#', 'D'
                   };
 
 uint32_t cbAfterInput(uint32_t index) {
     printf("Index:%d => Key:%c\n", key, Keytable[index]);
     return 0;
 }
 
 int main() {
     Keypad keypad(p25, p26, p27, p28, p21, p22, p23, p24);
     keypad.CallAfterInput(&cbAfterInput);
     keypad.Start();
 
     while (1) {
         wait_ms(100);
     }
 }

Definition at line 67 of file keypad.h.


Constructor & Destructor Documentation

Keypad ( PinName  row3,
PinName  row2,
PinName  row1,
PinName  row0,
PinName  col3,
PinName  col2,
PinName  col1,
PinName  col0,
int  debounce_ms = 20 
)

Create a Keypad interface.

Parameters:
row<3..0>Row data lines
col<3..0>Column data lines
debounce_msDebounce in ms (Default to 20ms)

Definition at line 3 of file keypad.cpp.


Member Function Documentation

void CallAfterInput ( uint32_t(*)(uint32_t)  fptr )

User-defined function that to be called when a key is pressed.

Parameters:
fptrA function pointer takes a uint32_t and returns uint32_t
void Start ( void   )

Start the keypad interrupt routines.

Definition at line 12 of file keypad.cpp.

void Stop ( void   )

Stop the keypad interrupt routines.

Definition at line 16 of file keypad.cpp.