Download the PHP package chickentikkamasala/gpio without Composer
On this page you can find all versions of the php package chickentikkamasala/gpio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package gpio
GPIO manager
requires testing
The GPIO manager is designed to house your hardware environment setup and allow you to manager and interact with the hardware.
The GPIO manager comes with a Laravel bridged service provider for easy integration with Laravel.
The GPIO class requires gpio to be installed
Installing into laravel
Add the package to your application via composer
Add the event listener to your Event Service Provider
The above is for recaching the GPIO manager after a request to prevent redeclaration of the manager and resetting everything to their default value.
If you run your application and alter your environment setup, you may want to run
php artisan cache:clear
to clear the cached setup.
Publish the vendor to get the config files
Example setup
Testing with the command line
Turn the redled on pin 1 on full
List all GPIO pin input from your setup
This will output an array of all the GPIOs setup with the manager
Creating a new connection
Alternatively to config setup you can call the create function to add new connections.
The manager maps your named connections as parameters as shown above. When reading pins we can use the same method with the parameters to get the result
Mapping also applies to the values 'OFF' and 'ON' where PWM expects 1023 as max and write expect 1. 'OFF' will equal to 0.
Custom GPIO Classes/Modes
You can however add your own GPIO modes/classes in 2 ways.
First being
Another method is to use the registerMode function to register the mode type for the manager so you can do something like this
Our GPIO config array in app/gpio.php
Terminal functions
gpio:set redled 500
=> set red LED to 500gpio:get sensor
=> print the sensor readinggpio:list
=> list all connectionsgpio:function redled increment 1023 1000
=> call the increment function with the options (options needs implementing)gpio:listen sensor --onChange
=> prints the state of the sensor (onChange option to only print if value has changed else consistently print incoming value)
Available default modes
- PWM => for incrementing the voltage between 0 and max
- Awrite
- ARead
- Write => for writing to pins either OFF or ON (0v or max voltage)
- Read => for reading pins either OFF or ON
Value conversions
You may remember seeing (if you've ever used an arduino) values being set as HIGH or LOW. You can do this with the GPIO and depending on it's mode it will automatically fix your maximum value.
Getting the GPIO class out of the manager
You can get the class out of the manager if you wish using
PWM functions
In PWM GPIO I have added 2 function for incrementing and decrementing for incrementing/decrementing to a value within an interval.
GPIO Options
If you see http://wiringpi.com/the-gpio-utility/ there is a usage section. These options are available to pass to the GPIOManager like so (example to use BCM pins):
An extremely handy pin map https://pinout.xyz/
Default GPIO value
Coming soon
- Symfony bridge
- mapping values from 'low' to 'high' (for ESCs for example a pwm value of 60 is 0. For servos we may want to map 0 - 1023 to something like 0 - 180 degrees where a 'high' of 1023 = 180 degrees)
- exceptions for command errors