Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Igor Soarez
committed
Dec 19, 2012
0 parents
commit e3f7846
Showing
9 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "deps/wiringPi"] | ||
path = deps/wiringPi | ||
url = git://git.drogon.net/wiringPi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Bindings to wiringPi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
'targets': [ | ||
{ | ||
'target_name': 'wiringPi', | ||
'sources': [ | ||
'src/bindings.cc', | ||
'deps/wiringPi/wiringPi/libwiringPi.a' | ||
], | ||
'include_dirs': [ | ||
'deps/wiringPi/wiringPi' | ||
], | ||
'actions': [ | ||
{ | ||
'action_name': 'MOIKA', | ||
'inputs': [ | ||
], | ||
'outputs': [ | ||
'deps/wiringPi/wiringPi/libwiringPi.a' | ||
], | ||
'action': ['echo', '"EXPERIMENT OUTFILE" > deps/wiringPi/wiringPi/libwiringPi.a'] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
PWD="`pwd`" | ||
|
||
cd `dirname $0`/deps/wiringPi/wiringPi | ||
make | ||
cd "$pwd" | ||
|
||
node-gyp rebuild |
Submodule wiringPi
added at
25e4ec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function merge(obj, tgt) { | ||
for(var p in obj) | ||
if (obj.hasOwnProperty(p)) | ||
tgt[p] = obj[p]; | ||
} | ||
|
||
var c = require('../build/Release/wpi'); | ||
|
||
exports = { | ||
VERSION: require('../package').version | ||
}; | ||
|
||
merge(c, exports); | ||
|
||
module.exports = exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "wiringPi", | ||
"version": "0.1.0", | ||
"description": "Bindings to wiringPi", | ||
"main": "lib/exports.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"install": "./build.sh" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "/Users/Soarez/src/soarez/node-wiring-pi.git" | ||
}, | ||
"keywords": [ | ||
"wiringPi", | ||
"gpio", | ||
"raspberry", | ||
"pi", | ||
"raspberrypi", | ||
"bcm2835" | ||
], | ||
"author": "Igor Soarez <igorsoarez@gmail.com>", | ||
"license": "BSD" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include <node.h> | ||
#include <v8.h> | ||
|
||
#include <wiringPi.h> | ||
|
||
using namespace v8; | ||
|
||
#define DECLARE(name) \ | ||
static Handle<Value> name(const Arguments& args) | ||
#define IMPLEMENT(name) \ | ||
Handle<Value> wpi::name(const Arguments& args) | ||
#define EXPORT(name) \ | ||
target->Set(String::NewSymbol("name"), \ | ||
FunctionTemplate::New(wpi::name)->GetFunction()) | ||
|
||
namespace wpi { | ||
DECLARE(wiringPiSetup); | ||
DECLARE(pinMode); | ||
DECLARE(digitalWrite); | ||
} | ||
|
||
IMPLEMENT(wiringPiSetup) { | ||
HandleScope scope; | ||
int res; | ||
|
||
if (args.Length() != 0) { | ||
ThrowException(Exception::TypeError( | ||
String::New("Wrong number of arguments."))); | ||
return scope.Close(Undefined()); | ||
} | ||
|
||
res = ::wiringPiSetup() | ||
|
||
return scope.Close(Int32::New(res)); | ||
} | ||
|
||
IMPLEMENT(pinMode) { | ||
HandleScope scope; | ||
int res; | ||
|
||
if (args.Length() != 2) { | ||
ThrowException(Exception::TypeError( | ||
String::New("Wrong number of arguments."))); | ||
return scope.Close(Undefined()); | ||
} | ||
|
||
if (!args[0]->IsNumber() || !args[1]->IsNumber()) { | ||
ThrowException(Exception::TypeError( | ||
String::New("Incorrect argument types. Numbers expected."))); | ||
return scope.Close(Undefined()); | ||
} | ||
|
||
res = ::pinMode(args[0]->NumberValue(), args[1]->NumberValue()); | ||
|
||
return scope.Close(Int32::New(res)); | ||
} | ||
|
||
IMPLEMENT(digitalWrite) { | ||
HandleScope scope; | ||
int res; | ||
|
||
if (args.Length() != 2) { | ||
ThrowException(Exception::TypeError( | ||
String::New("Wrong number of arguments."))); | ||
return scope.Close(Undefined()); | ||
} | ||
|
||
if (!args[0]->IsNumber() || !args[1]->IsNumber()) { | ||
ThrowException(Exception::TypeError( | ||
String::New("Incorrect argument types. Numbers expected."))); | ||
return scope.Close(Undefined()); | ||
} | ||
|
||
res = ::digitalWrite(args[0]->NumberValue(), args[1]->NumberValue()); | ||
|
||
return scope.Close(Int32::New(res)); | ||
} | ||
|
||
void init(Handle<Object> target) { | ||
EXPORT(wiringPiSetup); | ||
EXPORT(pinMode); | ||
EXPORT(digitalWrite); | ||
} | ||
NODE_MODULE(wiringPi, init) |