Home  Contents

Change GPIO State

Gpio Core4 Lua Event System

SYNOPSIS

#include <lua/gpio.lh>
  1. gpio.out([group, ]nr, state)
  2. gpio.pulse([group, ]nr, ms)
  3. gpio.pulseOn([group, ]nr, ms)
  4. gpio.pulseOff([group, ]nr, ms)
  5. gpio.blink([group, ]nr, pattern)

DESCRIPTION

These commands modify the state of an output. In the simplest form, the parameter nr indicates the output number of an output on the controller itself.

gpio.out() Sets output to state, interpreted as a boolean. This call will stop any pulse or blinking running on the output.
gpio.pulse() Pulse the output to on for ms milliseconds, the turn it off. Pulse timer will stop when gpio.out() or gpio.blink() is called on that output.
gpio.pulseOn() Same as above, aliased for clarity.
gpio.pulseOff() Same as above, but output turns off at the start of the pulse and turns on at the end. This is currently only supported for outputs in the group GPGRP_GPIO.
gpio.blink() Blink the output with pattern. The pattern is an unsigned 32bit value which is rotated right every 125ms. On each rotate, bit 0 is placed onto the output. Blinking will stop when gpio.out() or gpio.pulse() is called on that output. (Note: uBus nodes only support an 8bit blink pattern.)

NOTES

Please see Lua Reference Manual on how Lua interprets booleans: Only the explicit values nil and false flag as false, anything else, including the number 0, flag as true. Sorry for the inconvenience.

EXAMPLE

Blinking with decreasing speeds:

gpio.blink(1, 0xAAAAAAAA)
gpio.blink(1, 0x33333333)
gpio.blink(1, 0x00FF00FF)

Flash of 0.5s every 3.5s.

gpio.blink(1, 0x0000000F)

SEE ALSO