WiringPi / WiringPi-Node

Node.js bindings to wiringPi
334 stars 94 forks source link

Update to libWiringPi 2.15 #5

Closed nekuz0r closed 10 years ago

nekuz0r commented 10 years ago

npm install

The libWiringPi static library is no longer in the wiring-pi repository, but instead is compiled at installation time.

The libWiringPi is compiled across my libWiringPi repository @ Github. https://github.com/nekuz0r/wiringpi/

Official libWiringPi patchs are merged into this repository, but it offers some fixes and new functionalities.

List of modifications

wpi.pinMode(pin, wpi.SOFT_PWM_OUTPUT);
wpi.softPwmStop(pin);

softToneStop

wpi.pinMode(pin, wpi.SOFT_TONE_OUTPUT);
wpi.softToneStop(pin);

piBoardId

piBoardId in wiring-pi (nodejs) returns an object

{
    "model": Number,
    "rev": Number,
    "mem": Number,
    "marker": String
};

if (boardId.model === wpi.PI_MODEL_A) {
    console.log('No network :(');
}

piModelNames

piModelNames is available as an array named PI_MODEL_NAMES

var boardId = wpi.piBoardId();
var modelName = wpi.PI_MODEL_NAMES[boardId.model];

piRevisionNames

piRevisionNames is available as an array names PI_REVISION_NAMES

var boardId = wpi.piBoardId();
var revisionName = wpi.PI_MODEL_NAMES[boardId.rev];

pulseIn

wpi.pinMode(pin, wpi.INPUT);
var microseconds = wpi.pulseIn(pin, wpi.HIGH);

PCA9685

wpi.pca9685Setup(pinBase, i2cAddress, pwmFrequency) // (pwmFrequency: 40Hz - 1000Hz);
wpi.pwmWrite(pin, value) // (value: 0 - 4096)

To calcule the pwm value from microseconds use the following formula:

Math.round((4096 / (1000000 / PWM_FREQ)) * microseconds)

delay, delayMicroseconds, millis, micros

wpi.delay(ms);
wpi.delayMicroseconds(us);
var ms = wpi.millis();
var us = wpi.micros();
nekuz0r commented 10 years ago

Is everything ok ? Can i merge this update ?

eugeneware commented 10 years ago

LGTM. Merge away! :-) Sorry for the delay.

eugeneware commented 10 years ago

What's your npm username? I'll give you npm publish permissions as well.

eugeneware commented 10 years ago

I think I found you. I've given npm owner rights to the npm user leandregohy. Feel free to do an npm publish with the appropriate semver bump too.

nekuz0r commented 10 years ago

It's me, thank you :)