Class: POESLInput

POESLInput

Provides properties and methods for accessing one digital input.

Members


<readonly> Edge :object

Values for edges that can be counted.

Type:
  • object
Properties:
Name Type Description
Rising number

1

Falling number

2

Since:
  • 0.1 (WAT 2.0)
See:

edgeMask :number

Gets/sets which edge(s) is/are counted when using edgeDetected

Type:
  • number
Since:
  • 0.1 (WAT 2.0)
See:

holdoff :number

The holdoff value for the input, in 10 millisecond increments. This is the time that the input must remain stable before it is considered changed. Can be used to debounce. This affects the state as well as edgeDetected

Type:
  • number
Since:
  • 0.1 (WAT 2.0)
Default Value:
  • 3

<readonly> state :bool

The state of the input.

Type:
  • bool
Since:
  • 0.1 (WAT 2.0)

threshold :number

The threshold value for the input detection. The range is [0-255], which maps from 0 to full scale on the input (e.g. [0-24V] for 24V input configurations). So, a value of 0 for the threshold would cause the input to always appear on, while a value of 255 would cause the input to always appear off.

Type:
  • number
Since:
  • 0.1 (WAT 2.0)
Default Value:
  • 128

Events


edgeDetected

Indicates that an edge has been detected. The edges that will cause this event to fire are specified in edgeMask. If edges are counted faster than this event can be handled, the count is accumulated between events and passed as an argument to the event. Note that holdoff would need to be changed from the default in order to count fast events.

Parameters:
Name Type Description
count number

number of edge(s) counted since the last time this event fired

Since:
  • 0.1 (WAT 2.0)
Example
function myInput(hw, num)
{
   this.num = num;
   var input = hw.digInputs[num];
   input.holdoff = 0;
   input.edgeMask = input.Edge.Rising | input.Edge.Falling;
   input.edgeDetected.connect(this, this.onEdge);
}

myInput.prototype =
{
   onEdge: function(count)
   {
      console.log('Got ' + count + ' edge(s) on input ' + this.num + ' since last time');
   }
}

fallingEdge

Indicates that a falling edge has occurred.

Since:
  • 0.1 (WAT 2.0)

risingEdge

Indicates that a rising edge has occurred.

Since:
  • 0.1 (WAT 2.0)

stateChanged

Indicates that the state of the input has changed.

Parameters:
Name Type Description
state bool

new state of the input

Since:
  • 0.1 (WAT 2.0)
Example
function myInput(hw, num)
{
   this.num = num;
   hw.digInputs[num].stateChanged.connect(this, this.onChange);
}

myInput.prototype =
{
   onChange: function(state)
   {
      console.log('Input ' + this.num + ' is now ' + state);
   }
}