diff --git a/README.md b/README.md index 18b0812..f1f2707 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/docs/reading-pwm-signals.md b/docs/reading-pwm-signals.md index 0cd509d..b3c7ac2 100644 --- a/docs/reading-pwm-signals.md +++ b/docs/reading-pwm-signals.md @@ -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 @@ -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 +```` \ No newline at end of file