Skip to content

Tiny GPIO control library for single board computers

License

Notifications You must be signed in to change notification settings

ozanselte/dgpio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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();

About

Tiny GPIO control library for single board computers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages