Skip to content

Latest commit

 

History

History
58 lines (51 loc) · 932 Bytes

README.md

File metadata and controls

58 lines (51 loc) · 932 Bytes

dgpio

dgpio is a tiny GPIO control library for all linux single board computers in D language.

Install

If dub is installed

git clone https://github.com/ozanselte/dgpio.git
cd dgpio

# with dub
sudo dub

# with dmd
cd sources
dmd -lib dgpio.d -oflibdgpio.a

# with gdc
cd sources
gdc -c -o dgpio.o dgpio.d
ar rsc libdgpio.a dgpio.o

Usage

Import library

import dgpio;

Create new GPIO class

GPIO gpio = new GPIO(17);

Read value from GPIO pin

gpio.setInput();
bool gpioHigh = gpio.isHigh();
bool gpioLow = gpio.isLow();
assert(gpio.isHigh() != gpio.isLow());

Write digital value

gpio.setOutput();
gpio.setHigh();
assert(gpio.isHigh() == true);
gpio.setLow();
assert(gpio.isHigh() == false);

Check GPIO pin

ubyte gpioPin = gpio.gpio;
bool isInput = gpio.isInput();
bool isOutput = gpio.isOutput();

Close GPIO pin

gpio.deactivate();