<commit_before># RaspberryPiGPIO

RaspberryPi GPIO reader, writer, setinterrupter.

## Goals

RaspberryPiGPIO is provide a complete GPIO handler in a small code base.

## Getting Started

Log in your RaspberryPi and fetch the latest version of RaspberryPiGPIO using git.

```
$ git clone https://github.com/hiroeorz/RaspberryPiGPIO.git
$ cd RaspberryPiGPIO
$ make
```

## Running

check [default setting of gpio](https://github.com/hiroeorz/RaspberryPiGPIO/blob/master/src/rgpio.app.src).

In default setting, under gpio22 is input pin, other is output pin.

You can change pin setting by modifing above file, if you need.

### Start application.

```
$ ./start-dev
```
 
```erl-sh
1> rgpio:start().
```

### Read gpio

```erl-sh
1> rgpio:read(18).
0
```

### Write

```erl-sh
1> rgpio:write(18, 1).
ok
2> rgpio:read(18).
1

3> rgpio:write(18, 0).
ok
4> rgpio:read(18).
0<commit_msg>add 'run as root' to README<commit_after># RaspberryPiGPIO

RaspberryPi GPIO reader, writer, setinterrupter.

## Goals

RaspberryPiGPIO is provide a complete GPIO handler in a small code base.

## Getting Started

Log in your RaspberryPi and fetch the latest version of RaspberryPiGPIO using git.

```
$ git clone https://github.com/hiroeorz/RaspberryPiGPIO.git
$ cd RaspberryPiGPIO
$ make
```

Or add deps line to your app's rebar.conf.

```erlang
{rgpio, ".*", {git, "https://github.com/hiroeorz/RaspberryPiGPIO.git",
   {branch, "master"}}},

```

and get deps

```
$ ./rebar get-deps
```

## Running

check [default setting of gpio](https://github.com/hiroeorz/RaspberryPiGPIO/blob/master/src/rgpio.app.src).

In default setting, under gpio22 is input pin, other is output pin.

You can change pin setting by modifing above file, if you need.

### Start application.

You must run rgpio as root. Because rgpio access to /dev/mem. /dev/mem is allowed writable access from root only.

```
$ sudo ./start-dev
```

```erl-sh
1> rgpio:start().
```

### Read gpio value

```erl-sh
1> rgpio:read(18).
0
```

### Write value to gpio

```erl-sh
1> rgpio:write(18, 1).
ok
2> rgpio:read(18).
1

3> rgpio:write(18, 0).
ok
4> rgpio:read(18).
0
{'fraction_non_alphanumeric': 0.14218233349078885, 'fraction_numerical': 0.02172886159659896, 'mean_word_length': 4.054892601431981, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2511138', 'n_tokens_mistral': 833, 'n_tokens_neox': 765, 'n_words': 245}