Skip to content

Commit

Permalink
Fixed some typos + linked feature
Browse files Browse the repository at this point in the history
  • Loading branch information
marius-meissner committed Mar 16, 2018
1 parent 4eaa574 commit 87c2e1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ composer require volantus/php-pigpio
Currently the following features are fully implemented.
If your desired Pigpio feature is not fully supported, you may use [raw requests](https://github.com/Volantus/php-pigpio/blob/master/docs/raw-requests.md).

| Feature | Status |
|-----------------------------------------------------------------------------------------------------------|------------------------------------|
| [Notifications](https://github.com/Volantus/php-pigpio/blob/master/docs/notifications.md) | :heavy_check_mark: Fully supported |
| [Raw requests/response handling](https://github.com/Volantus/php-pigpio/blob/master/docs/raw-requests.md) | :heavy_check_mark: Fully supported |
| Feature | Status | Version |
|---------------------------------------------------------------------------------------------------------------|------------------------------------|---------|
| [Notifications (e.g. GPIO changes)](https://github.com/Volantus/php-pigpio/blob/master/docs/notifications.md) | :heavy_check_mark: Fully supported | 0.1.1 |
| [Reading PWM signals](https://github.com/Volantus/php-pigpio/blob/master/docs/reading-pwm-signals.md) | :heavy_check_mark: Fully supported | 0.1.2 |
| [Raw requests/response handling](https://github.com/Volantus/php-pigpio/blob/master/docs/raw-requests.md) | :heavy_check_mark: Fully supported | 0.1.1 |

## Basic usage
This library is interacting with Pigpio by using sockets. The core communication is handled by the Client class:
Expand Down
14 changes: 8 additions & 6 deletions docs/reading-pwm-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
php-pigpio supports reading [PWM signals](https://en.wikipedia.org/wiki/Pulse-width_modulation). This feature is based on [notifications](https://github.com/Volantus/php-pigpio/blob/master/docs/notifications.md).

## Setup
Reading/Calculation is handled by PWM receiver class, which requires a dedicated Notifier instance.
Reading/calculation is handled by class `PwmReceiver`, which requires a dedicated `Notifier` instance.

Every time a signal is retrieved callback is called with an PwmSignal object as parameter.
Every time a signal is retrieved callback is called with an `PwmSignal` object as parameter.

Reading PWM signals on GPIO pin 21:
````php
Expand All @@ -14,30 +14,32 @@ use Volantus\Pigpio\PWM\PwmSignal;

$notifier = new Notifier();
$receiver = new PwmReceiver($notifier);

$receiver->start([21], function (PwmSignal $signal) {
echo $signal->getPulseWidth(); // e.g. 1500
});
````
## Ticks
To retrieve signals `$notifier->tick()` needs to be called.
Every time `$notifier->tick()` is called, it will trigger your callback with all signals measured since last call to `$notifier->tick()`.
Every time `$notifier->tick()` is called, it will trigger the given callback with all signals measured since last call to `$notifier->tick()`.

Either blocking or non-blocking mode is supported. More details: [Notification: Ticks](https://github.com/Volantus/php-pigpio/blob/master/docs/notifications.md#ticks)

## Multiple signals
Reading multiple signals in parallel on different GPIO pins is supported.

Simply specify all GPIO pins as first parameter of start method:
First parameter is accepting an array of GPIO pins with incoming signals:
````php
$notifier = new Notifier();
$receiver = new PwmReceiver($notifier);

$receiver->start([8, 16, 8], function (PwmSignal $signal) {
echo $signal->getGpioPin() . ': ' . $signal->getPulseWidth();
});
````
Example output:
```
> 8: 1264
> 16: 1679
> 18: 1800
````

0 comments on commit 87c2e1d

Please sign in to comment.