Keypad Library

The mikroC PRO for FT90x provides a library for working with 4x4 keypad. The library routines can also be used with 4x1, 4x2, or 4x3 keypad. For connections explanation see schematic at the bottom of this page.

External dependencies of Keypad Library

The following variable must be defined in all projects using Keypad Library: Description : Example :
extern sfr unsigned short keypadPort; Keypad Port. unsigned short keypadPort at GPIO_PORT_48_55;

Library Routines

Keypad_Init

Prototype

void Keypad_Init();

Description

Initializes given port for working with keypad.

Parameters

None.

Returns

Nothing.

Requires

External dependencies of the library from the top of the page must be defined before using this function.

Example
// Keypad module connections
unsigned short keypadPort at GPIO_PORT_48_55;
// End Keypad module connections
...
Keypad_Init();                           // Initialize Keypad 
Notes

None.

Keypad_Key_Press

Prototype

unsigned Keypad_Key_Press();

Description

Reads the key from keypad when key gets pressed.

Parameters

None.

Returns

The code of a pressed key (1..16).

If no key is pressed, returns 0.

Requires

Port needs to be initialized for working with the Keypad library, see Keypad_Init.

Example
unsigned kp;
...
kp = Keypad_Key_Press();
Notes

None.

Keypad_Key_Click

Prototype

unsigned Keypad_Key_Click();

Description

Call to Keypad_Key_Click is a blocking call: the function waits until some key is pressed and released. When released, the function returns 1 to 16, depending on the key. If more than one key is pressed simultaneously the function will wait until all pressed keys are released. After that the function will return the code of the first pressed key.

Parameters

None.

Returns

The code of a clicked key (1..16).

If no key is clicked, returns 0.

Requires

Port needs to be initialized for working with the Keypad library, see Keypad_Init.

Example
kp = Keypad_Key_Click();
Notes

None.

Copyright (c) 2002-2015 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code