定制 laxamar/gpiosysv 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

laxamar/gpiosysv

Composer 安装命令:

composer require laxamar/gpiosysv

包简介

A library for accessing the GPIO pins on a Raspberry Pi without root for clients using SysV message queue and client/server

README 文档

README

License Total Downloads

A userland (non-root) library for low level access to the GPIO pins on a Raspberry Pi. These pins can be used to control outputs (LEDs, motors, valves, pumps) or read inputs (sensors).

Adapted by laxamar (Twitter)

From AndrewCarterUK (Twitter)

Installing

This release has two components. A server that can be installed via git or composer. A client that uses composer to install and run.

Client (with server as a service with manual installation)

Using composer:

composer require laxamar/gpiosysv

Or:

php composer.phar require laxamar/gpiosysv

The server code is installed in the vendors/laxamar/gpiosysv directory of composer under the service directory and can be installed as below

Server

The server can be downloaded as by git sudo install_systemd.sh will install the necessary files in /usr/local/GPIOSysV and install the systemd service

Examples

Setting Output Pins

use Amar\GPIOSysV\GPIOSysVClt;

// Create a GPIO object
$gpio_obj = GPIOSysVClt::getInstance();

// Set the value of the pin high (turn it on)
$success = $gpio_obj->setPinHigh(18);

$success = $gpio_obj->setPinLow(18);

// Set a series on PINs using BCD
$gpio->setPinsBinary($board, CS_PINs);
for ($dec = 0; $dec < 8; $dec++) {
    // echo "Decimal $dec";
    $gpio->strobeBinary($dec, LED_PINs, FLASH_PIN, 1, 0, $frequency, true, $error);
}

Input Pin

use Amar\GPIOSysV\GPIOSysVClt;

// Create a GPIO object
$gpio_obj = GPIOSysVClt::getInstance();

// Set the value of the pin high (turn it on)
$value = $gpio_obj->getPin(4);

Further Reading

SitePoint published a tutorial about powering Raspberry Pi projects with PHP which used this library and shows a push button example with a wiring diagram.

More Resources

PiPHP maintains a resource directory for PHP programming on the Raspberry Pi.

统计信息

  • 总下载量: 68
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 41
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固