Skip to content

Commit

Permalink
Update Readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronplanell committed Apr 5, 2016
1 parent 1fb3ed0 commit 270cdd2
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 100 deletions.
61 changes: 59 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
# express-pi-controller
This is a very simple application for controlling GPIO sensors on a Raspberry Pi. It uses NodeJs, Express and the OnOff package.
Use at your own risk.

This is a very simple application for controlling GPIO sensors on a [Raspberry Pi](https://www.raspberrypi.org/). It uses [node](http://nodejs.org), [Express](http://expressjs.com/) and the [OnOff](https://www.npmjs.com/package/onoff) package.
Use at your own risk.


## Installation

```bash
$ npm install express-pi-controller
```


## Features

* Controls any GPIO you have connected
* Config file to enable/disable every GPIO
* Button On/Off to enable/disable the app
* Status Led that shows if the app is enabled
* A web service API based on JSON


## Quick start

```bash
cd node_modules/express-pi-controller
sudo npm start
```
Then go to the http://127.0.0.1 in a web browser


## Configure

Edit the file model\bcms.json

## Default values

* BCM 17: Led
* BCM 18: Led
* BCM 24: Status Led
* BCM 25: Button


## Use of the JSON API

* "/:type(led|button|status_led)" -> Return JSON of enabled items
* "/:type(led|button|status_led)/:item(\\d+) -> Return JSON of an specific item
* "/:type(led)/:item(\\d+)/on" -> Switch on a led (obviously, only for leds).
* "/:type(led)/:item(\\d+)/off" -> Switch off a led (obviously, only for leds).
* "/:type(led)/:item(\\d+)/switch" -> Switch a led (obviously, only for leds).


## People

The author of this module is [Aaron Planell](mailto:aaronplanell@gmail.com)


## License

[GNU](LICENSE)
18 changes: 0 additions & 18 deletions controllers/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,21 +261,3 @@ exports.status = function (req, res, next) {
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(curMessage));
};

// Get a button of the led
exports.button = function (req, res, next) {
disableErrors();
var result = false;
var bcm = getGpio(parseInt(req.params.item));
if( bcm!== null) {
if (sStatusLed) {
bcm.GPIO.writeSync(Math.abs(1-bcm.status));
bcm.status = bcm.GPIO.readSync();
console.log(colors.red("The item " + bcm.id + " has this value: " + parseInt(bcm.status)));
}
res.render('button', { title: 'Button ' + bcm.id, sStatusLed: sStatusLed, bcm: bcm });
} else {
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(result));
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "express-pi-controller",
"version": "0.0.0",
"private": true,
"private": false,
"scripts": {
"start": "node ./bin/www"
},
Expand Down
3 changes: 0 additions & 3 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,4 @@ router.get("/:type(led)/:item(\\d+)/switch", controller.switch);
// Get the status of a led
router.get("/:type(led)/:item(\\d+)/status", controller.status);

// Get a button of the led
router.get("/:type(led)/:item(\\d+)/button", controller.button);

module.exports = router;
22 changes: 0 additions & 22 deletions views/button.ejs

This file was deleted.

54 changes: 0 additions & 54 deletions views/index.ejs.bkp

This file was deleted.

0 comments on commit 270cdd2

Please sign in to comment.