Skip to content
@skiffyard/gpiosysfs

gpiosysfs cheatsheet

Every export of @skiffyard/gpiosysfs. The pin numbering and the sysfs root are in the introduction.

jennifer
import "@skiffyard/gpiosysfs/" as gpiosysfs;

Pins

FunctionReturnsDoes
gpiosysfs.setup(pin as int, direction as string)nullExport pin (unless exported) and set its direction; an output starts low
gpiosysfs.write(pin as int, value as int)nullSet an output pin to 0 or 1
gpiosysfs.read(pin as int)intThe pin's value, 0 or 1
gpiosysfs.release(pin as int)nullUnexport pin
gpiosysfs.useChip(label as string)nullSelect the chip pin numbers refer to: AUTO, GLOBAL or a chip label

Constants

NameValueMeaning
IN"in"Direction input, for setup
OUT"out"Direction output, for setup
AUTO""useChip: the Raspberry Pi header chip, by label (the default)
GLOBAL"global"useChip: pin numbers are sysfs global numbers

Environment

VariableDefaultMeaning
JENNIFER_GPIO_BASE/sys/class/gpioThe sysfs GPIO root
JENNIFER_GPIO_CHIP_LABELempty (AUTO)The chip selection useChip writes