forked from halherta/RaspberryPi-GPIOClass-v2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
GPIOClass.h
40 lines (36 loc) · 771 Bytes
/
GPIOClass.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <string>
#include <iostream>
#include <sstream>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <exception>
using namespace std;
/* GPIO Class
* Purpose: Each object instatiated from this class will control a GPIO pin
* The GPIO pin number must be passed to the overloaded class constructor
*/
class GPIOClass
{
public:
GPIOClass();
GPIOClass(string gnum);
~GPIOClass();
int setdir_gpio(string dir);
int setval_gpio(string val);
int getval_gpio(string& val);
string get_gpionum();
private:
int export_gpio();
int unexport_gpio();
int valuefd;
int directionfd;
int exportfd;
int unexportfd;
string gpionum;
};