Digital package provides drivers for GPIO expanders.
GPIOPort interface provides functions to use digital I/O.
Returns the digital channel count.
REST API : GET /devices/name/count
Returns the value of the given digital channel.
REST API : GET /devices/name/channel/value
Returns a list containing all digital channels value.
REST API : GET /devices/name/*
/value
Write the value of the given digital channel.
REST API : POST /devices/name/channel/value/digit
Returns an integer composed of all digital bits.
REST API : POST /devices/name/*
/integer
Write on all digital channels with an integer composed of all bits.
REST API : POST
/devices/name/*
/integer/value
Returns the current fonction of the given digital channel.
REST API : Use getFunctionString instead.
Returns the current fonction of the given digital channel.
REST API : GET /devices/name/channel/function
Setup the given digital channel with the given function
REST API : Use setFunctionString instead.
Setup the given digital channel.
REST API : GET /devices/name/channel/function/func
Returns a list containing the current value and function of all digital channels.
REST API : GET /devices/name/*
form webiopi.devices.digital import MCP23008
mcp = MCP23008(...) # setup a MCP23008 I2C GPIO expander
# or
from webiopi import deviceInstance
mcp = deviceInstance("mcp") # retrieve device named "mcp" in configuration file
mcp.getFunction(0) # get current MCP digital channel 0 setup
mcp.setFunction(0, GPIO.OUT) # setup MCP digital channel 0 as output
mcp.setFunction(1, GPIO.OUT) # setup MCP digital channel 1 as output
mcp.setFunction(2, GPIO.OUT) # setup MCP digital channel 2 as output
mcp.setFunction(3, GPIO.OUT) # setup MCP digital channel 3 as output
mcp.digitalRead(4) # read MCP digital channel 0
mcp.digitalWrite(4, GPIO.HIGH) # write MCP digital channel 4 as HIGH
mcp.portWrite(0x0F) # write channels 0-3 as HIGH
mcp.portRead() # read all MCP digital channels in a single integer
HTTP GET /devices/mcp/0/function # retrieve "mcp" channel 0 setup
HTTP GET /devices/mcp/0/value # retrieve "mcp" channel 0 digital value
HTTP POST /devices/mcp/0/function/out # set "mcp" channel 0 as output
HTTP POST /devices/mcp/0/value/1 # set "mcp" channel 0 as digital HIGH