DIO
api.AnalogReadPin(pin)
- Overview
- Arguments
- Return
- Example
Read analog value on defined pin.
Disabled by defaul, FW & HW changes required.
- pin (integer) - defined analog pin
- voltage (integer) - measured voltage value
AnalogChannel=1
mV = api.AnalogReadPin(AnalogChannel)
print("Raw value: " .. tostring(mV) .. " mV")
api.DIOwaitForEvent(pin, event, sync, timeout)
- Overview
- Arguments
- Return
Waits for specified event on defined pin. If event occurs, device wakes up and calls onWake() function.
- pin (integer) - Pin number (1 to 4)
- event (integer) - Event to wait for: 0 - unregister, 1 - rising, 2 - falling, 3 - both
- sync (integer) - If 1, sync event is requested (OPTIONAL)
- timeout (integer) - Time in milliseconds to wait (OPTIONAL)
- status (integer) - Positive for success, negative for failure, zero means that event has been unregistered from pin.
api.DIOreadPin(pin)
- Overview
- Arguments
- Return
Read DIO pin state.
- pin (integer) - Pin number (1 to 4)
- state (integer) - 1 if pin is set, 0 if not.
api.DIOwritePin(pin, state)
- Overview
- Arguments
- Return
- Example
Writes DIO pin state.
- pin (integer, optional) - Pin number (1 to 4)
- state (integer, optional) - Pin state: -2 - analog; -1 - high impedance; 0 - low; 1 - high
- status (integer) - Zero 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))