eugeneware/wiring-pi — pull request #5 by nekuz0r (2014-06-26 09:21:41+00:00)
Title: Update to libWiringPi 2.15

# 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
* int pulseIn(pin, state) (reading PWM signal on a digital pin, same as arduino pulseIn (http://arduino.cc/en/Reference/pulseIn))
* Add support for pca9685 (led/servo driver)
* Fix mcp3422 support
* Remove some compilation warnings (cast to pointer from integer of different size)

# New in libWiringPi 2.15
* piBoardId(int* model, int* rev, int* mem, char** marker)
* void softPwmStop(int pin)
* void softToneStop(int pin)
* SOFT_PWM_OUTPUT, SOFT_TONE_OUTPUT (pinMode)
* PI_MODEL_A, PI_MODEL_B, PI_MODEL_COMPUTE (piBoardId model id)
* const char* piModelNames[] (indexed by piBoardId model id)
* const char* piRevisionNames[] (indexed by piBoardId revision id)
* const char* piComputeRevisionNames[]

# New in wiring-pi 1.1.0
* Add piBoardId support
* Add softPwmStop support
* Add softToneStop support
* Add pulseIn function
* Add delay function
* Add delayMicroseconds function
* Add millis function
* Add micros function
* Add pca9685 support
* Remove precompiled dependencies (compiled at installation time)

# How is it implemented in wiring-pi ?

## softPwmStop
```javascript
wpi.pinMode(pin, wpi.SOFT_PWM_OUTPUT);
wpi.softPwmStop(pin);
```

## softToneStop
```javascript
wpi.pinMode(pin, wpi.SOFT_TONE_OUTPUT);
wpi.softToneStop(pin);
```

## piBoardId
piBoardId in wiring-pi (nodejs) returns an object
```javascript
{
"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
```javascript
var boardId = wpi.piBoardId();
var modelName = wpi.PI_MODEL_NAMES[boardId.model];
```

## piRevisionNames
piRevisionNames is available as an array names PI_REVISION_NAMES
```javascript
var boardId = wpi.piBoardId();
var revisionName = wpi.PI_MODEL_NAMES[boardId.rev];
```

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

## PCA9685
```javascript
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:
```javascript
Math.round((4096 / (1000000 / PWM_FREQ)) * microseconds)
```

## delay, delayMicroseconds, millis, micros
```javascript
wpi.delay(ms);
wpi.delayMicroseconds(us);
var ms = wpi.millis();
var us = wpi.micros();
```