oDebounce Object
An Object that provides logic-state debouncing functions.
Description:
 

A Processing Object that stabilizes an input by ignoring its changes for a period of time after going to a logical High state.

Operation:
 

An oDebounce Object takes the Flag property to which the Input property points and extends it by the amount of time specified by the Period property.

The Operate property determines if operation is active and the Result property is updated. Each time the Result property is updated, its value is also copied to the Flag property of the Object to which the Output property points. If the InvertOut property is set to 1, then the value of the Result property is inverted before it is copied.

Storage size & Availability:
 

The following table lists the size and availability of the oDebounce Object and its variations:

ObjectSizeVersion
oDebounce5 BytesA.1.0 and greater
Properties:
 

The following table lists the Properties of the oDebounce Object:

PropertyDescription
Address

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

Data-Type: Address, Read-Only

Data-Range: 0 - 127

Input

A pointer to an Object's Flag property which will be used as the value to debounce.

Data-Type: Flag-Pointer

Data-Range: Any Object's Flag property

InvertIn

A value that specifies if the Input Flag is inverted before it is used in the debounce operation.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table list the values of the InvertIn Property:
InvertInConstantDescription
0cvFalse

When the value of the Flag property pointed to by the Input property is set to 1, the Result property is set to 1 after an amount of time specified by the Period property has passed.

1cvTrue

When the value of the Flag property pointed to by the Input property is set to 0, the Result property is set to 1 after the amount of time specified by the Period property has elapsed.

InvertOut

A value that specifies if the Boolean &Result of the debounce operation is inverted before it is stored into the &Output Flag.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table list the values of the InvertOut Property.
InvertOutConstantDescription
0cvFalse

The value of the Result property is copied to the Flag value linked to by the Output property.

1cvTrue

The value of the Result property is inverted before it is copied to the Flag value linked to by the Output property.

Operate

A value that specifies whether or not the Repeat property is updated.

Data-Type: Bit, Flag, Default

Data-Range: 0 - 1

The following table list the values of the Operate Property:
OperateConstantDescription
0cvFalse

The value of the Result property is copied to the Flag property linked to by the Output property.

1cvTrue

The value of the Result property is inverted before it is copied to the Flag property linked to by the Output property.

Output

A pointer to an Object's Flag property that will be updated with the debounced value.

Data-Type: Flag-Pointer

Data-Range: Any Object's Flag property

Period

The amount of time in 1/60th of a second increments that the debounce operation ignores the Input Objects value after it has changed to a logical High state.

Data-Type: Byte

Data-Range: 0 - 127

Result

The Boolean result of the debounce evaluation. Indicates debounced value of the &Input Object.

Data-Type: Bit, Flag

Data-Range: 0 - 1

The following table list the values of the Result Property.
ResultConstantDescription
0 

The Input value has not gone to a Logical High state.

1 

The Input value has gone to a logical High state.

Example:
 In the following example, a Virtual Circuit is created that uses the oDebounce Object to monitor a push button switch on I/O line 8.  When the button is pressed, it turns on I/O line 9 for 1 second longer than the button is pressed, if the button is released and then repressed within that 1 second, then the oDebounce will ignore the change and I/O line 9 will stay on while the button was released.
Dim R As New oDebounce
Dim S As New oDio1
Dim L As New oDio1

Sub Main()
  OOPic.PullUp = 1
  S.IOLine = 8
  S.Direction = cvInput
  L.IOLine = 9
  L.Direction = cvOutput
  L.Value = 0
  R.Input.Link(S)
  R.InvertIn = cvTrue
  R.Output.Link(L)
  R.Period = 60
  R.Operate = 1
End Sub
See Also:
 

oRepeat - The oRepeat Object provides an auto-repeat function for devices such as push buttons.