oKeypad Object

Main Index
Object List
Back to top of page Description:
 

The oKeypad Object is a Hardware Object that scans a hexadecimal keypad with a 4 row by 4 matrix of buttons.

A Hexadecimal keypad has the numbers 0 to 3 on the first row and C to F on the last row.  For keypads that are arranged like the keypad on a telephone, use the oKeypadP Object.

 The following table lists the size and availability of the oKeypad Object.
 ObjectSizeDescriptionA1A2B1B2C1
oKeypad4 BytesReads a 4 x 4 Keypad matrix.xxxxx
Back to top of page Operation:
 

An oKeypad Object uses I/O Group 1 to read a 4 x 4 matrix of buttons.  4 of the I/O Lines are used for the keypad's 4 columns and 4 I/O Lines are used for the keypad's 4 rows.  The keypad switch matrix requires no isolation diodes or pull up resistors for operation.

When the Operate property is set to 1 the 4 x 4 matrix of keys is scanned. If any switch is pressed, the Key property is updated with the value of the switch and the Pressed property is set to 1. Note that the value of the Key property is not necessarily the number printed on the key.  Instead, the value of the switch is calculated by (((Row - 1) * 4) + (Column-1)). If two switches are pressed simultaneously the switch with the highest value will be used.

The Pressed property will remain at 1 so long as at least 1 switch is depressed.  If a second key is pressed before the originally pressed key is released, the Key and Pressed property will remain unchanged from the values set at the time of the depression of the first key.  Once all keys are released, the Key property is cleared to 0.

When the Operate property is set to 0 the switch matrix scanning is suspended until the Operate property is set back to 1.

The FeedBack property is an instance of the oFeedBack4 Object which is created when the oKeypad Object is.  The oKeypad Object uses the oFeedBack4 Object to do the actual scanning of the keypad.  (see oFeedBack4 Object for more detail on how the keypad is scanned.)

Back to top of page Properties:
 

The following table lists the properties of the oKeypad Object:

Property

Description

Key
A value that indicates the switch number of the last key that was pressed.
Object Class: oNib Value Range: 0 - 15
Data Type: Numeric (Read-Only) Default Value: 0
The value is equal to (((Row - 1) * 4) + (Column-1)) where Row = the row the pressed key is in and where Column = the column the pressed key is in.
Pressed
A value that indicates that a new key has been pressed.
Object Class: oLogic Value Range: 0 - 1
Data Type: Numeric Default Value: 0
PressedDescription
0No key is pressed.
1Any one or more keys are pressed.
Operate
A value that selects whether or not the keypad is being read.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOff

The keypad is not being read.

1cvOn

The keypad is being read.

FeedBack
The I/O function object used to read the keypad.
Object Class: oFeedBack4 Value Range: 0 - 15
Data Type: Numeric Default Value: 0
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of page Methods:
 

The following table lists the methods:
MethodDescription
Init

Initializes the object's properties.

The Init method has 1 argument.
ArgumentPropertyDescription
iOperateOperateSelects if the keypad is being read.

Back to top of page Examples:
 In the following example, the oKeypad Object is used.
Visual Basic SyntaxC and Java Syntax
'This program reads a 4x4 oKeypad and
'outputs the value to I/O lines 8 - 15.

Dim A As New oKeypad
Dim D As New oDIO1
Dim C As New oDIO8

Sub Main()
  C.IOGroup = 3
  C.Direction = cvOutput
  D.IOLine = 7
  D.Direction = cvOutput
  A.Operate = 1
  Do
    C = A.Key
    D = A.Pressed
  Loop
End Sub
// This program reads a 4x4 oKeypad and
// outputs the value to I/O lines 8 - 15.

oKeypad A = New oKeypad;
oDIO1 D = New oDIO1;
oDIO8 C = New oDIO8;

Void Main(Void){
  C.IOGroup = 3;
  C.Direction = cvOutput;
  D.IOLine = 7;
  D.Direction = cvOutput;
  A.Operate = 1;
  Do{
    C = A.Key;
    D = A.Pressed;
  } While (1);
}
Basic Syntax 
'This program reads a 4x4 oKeypad and
'outputs the value to I/O lines 8 - 15.

A As oKeypad(cvOn)
D As oDIO1(7,cvOutput)
C As oDIO8(3,cvOutput)

Do
  C = A.Key
  D = A.Pressed
Loop
 
Also See: Application Note #1: Using the oKeypad Object to read a Matrix Keypad.
Back to top of pageConnections:
 The hex keypad switch matrix requires no isolation diodes or pull up resistors for operation since the IOLines 8-15 already have internal pull-ups on them.  Connect the first set 4 wires of IOGroup 1 to C1 to C4 and the second set of 4 wires of IOGroup 1 to R1 to R8.

Schematic of the keypad

Back to top of page Related Items:

 The following table lists objects with related functions
 ObjectDescriptionA1A2B1B2C1
oKeypad2Reads a Keypad matrix of up to 8 x 8.xx
oKeypadPReads a Telephone Keypad.xxxxx
Back to top of page Version History and Bug List:
 Firmware Ver A1: Introduced.

Bugs: No known bugs.