DIO
This category contains functions, that enable pulse devices to use DIO (digital input/output).
- Overview
- Arguments
- Return
- Example
Reads analog value on defined pin.
warning
Disabled by default, FW & HW changes required.
- pin (integer) - Defined analog pin
- voltage (integer) - Measured voltage value
-- Read analog value on pin 1
mV = api.AnalogReadPin(1)
print("Raw value: " .. tostring(mV) .. " mV")
- Overview
- Arguments
- Return
- Example
Waits for specified event on defined pin.
info
If event occurs, device wakes up and calls onWake() function.
api.DIOwaitForEvent(pin, event, sync, timeout)
- pin (integer) - Pin number,
1
to4
- event (integer) - Event to wait for:
0
- unregister,1
- rising,2
- falling,3
- both - sync (integer, optional) - If
1
, sync event is requested - timeout (integer, optional) - Time in milliseconds to wait
- status (integer) - Positive for success, negative for failure,
0
means that event has been unregistered from pin.
-- Wait for rising edge on pin 1
api.DIOwaitForEvent(1, 1)
- Overview
- Arguments
- Return
- Example
Reads DIO pin state.
- pin (integer) - Pin number,
1
to4
- state (integer) -
1
if pin is set,0
if not.
-- read state of pin 1
state = api.DIOreadPin(1)
- Overview
- Arguments
- Return
- Example
Writes DIO pin state.
api.DIOwritePin(pin, state)
- pin (integer) - Pin number,
1
to4
- state (integer, optional) - Pin state:
-2
- analog,-1
- high impedance,0
- low,1
- high, default is-2
- status (integer) -
0
for success, negative for failure
-- set logical 1 to pins 2 and 3, and logical 0 to pins 1 and 4
api.DIOwritePin(1, 0)
api.DIOwritePin(2, 1)
api.DIOwritePin(3, 1)
api.DIOwritePin(4, 0)
-- read state of pins 1 to 4
print("pin 1 set to:", api.DIOreadPin(1))
print("pin 2 set to:", api.DIOreadPin(2))
print("pin 3 set to:", api.DIOreadPin(3))
print("pin 4 set to:", api.DIOreadPin(4))