oKeypad Object
An Object that reads a 4 x 4 Keypad matrix.
Description:
 

A Hardware Object that scans a 4 row by 4 column set of switches and determines which switch is pressed.

Operation:
 

An oKeypad Object splits I/O Group 1 (I/O lines 8 - 15) into 2 sets of 4 I/O lines. The least significant 4 I/O Lines are used for the keypad's 4 columns and the most significant 4 I/O Lines are used for the keypad's 4 rows. The 4 row lines are individually and sequentially set low (0-Volts) while the 4 column lines are used to read which switch is pressed within that row. A switch-press is detected when any one of the 4 column lines is shorted to any one of the row lines. The oKeypad Object handles all the required I/O logic. The keypad switch matrix requires no isolation diodes or pull up resistors for operation.

When the Operate property is set to 1 the internal pull-up resistors on I/O lines 8 - 15 are activated and the keypad switch matrix is scanned for a switch-press. If any switch is pressed, the Value property is updated with the value of the switch and the Received property is set to 1. 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 Received 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 Value and Received property will remain unchanged from the values set at the time of the depression of the first key. Once all keys are released, the Received property will be cleared to 0.

If the Mode property is set to 1, the Value of the switches is converted to a Phone-Pad style numbering system.  In this mode, the value will reflect that actual numbers of the Phone-Pad.

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

Storage size & Availability:
 

The following table lists the size and availability of the oKeypad Object:

ObjectSizeVersion
oKeypad 4 Bytes A.1.0 and greater
Properties:
 

The following table lists the Properties of the oKeypad Object:
Property Description
Address

Returns a pointer to the address of the oKeypad Object instance.

Data-Type: Number-Pointer, Read-Only

Data-Range: 0 - 127

Mode

A value that specifies whether or not the keypad is in a Hex-Pad arrangement or in a Phone-Pad arrangement.

Data-Type: Bit

Data-Range: 0 - 1

Availability: The Mode property was added in Firmware Version A.2.0

The following table lists the values of the Operate Property:
Operate Constant Description
0  

The keypad is in Hex-Pad arrangement.

1  

The keypad is in Phone-Pad arrangement.

Operate

A value that specifies whether or not the Object is operating and updating its properties.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table lists the values of the Operate Property:
Operate Constant Description
0 cvFalse

The Value property is not updated.

1 cvTrue

The Value property is updated.

Received

A value that indicates that a new key-value has been received and that the Value property was updated with new information.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table lists the values of the Received Property:
Received Constant Description
0 cvFalse

The Value property has not been updated with new data.

1 cvTrue

The Value property has been updated with new data.

String

The Value property represented as a string.

Note: The String property is available in OOPic Basic Version 2

Data-Type: String, Read-Only

Value

A value that is set to the switch number of the last switch that was pressed.

Data-Type: Nibble, Read-Only, Default

Data-Range: 0 - 15

Example:
  In the following example, the oKeypad Object is used.
'This program reads a 4x4 keypad 
'configured in a phone pad style 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 = 23
  D.Direction = cvOutput
  A.Mode = 1
  A.Operate = 1
  Do
    C = A.Value
    D = A.Received
  Loop
end sub
Also See:
 

oKeyPadX - A Hardware Object that scans up to an 8 by 8 matrix of switches and determines which switch is pressed.