notrix/gpio-bundle

树莓派GPIO模块

安装次数: 22

依赖者: 0

建议者: 0

安全性: 0

星标: 2

关注者: 2

分支: 1

开放问题: 1

类型:symfony-bundle

dev-master / 0.x-dev 2014-06-05 20:44 UTC

This package is not auto-updated.

Last update: 2024-09-28 16:05:08 UTC


README

一个用于操作树莓派GPIO引脚的Symfony2模块

功能包括

  • 简单的IO引脚配置(用人类化的别名代替数字)
  • 命令从配置设置引脚到树莓派文件系统
  • 监听命令以监听输入状态变化
  • 命令读取输入引脚状态并设置输出引脚状态
  • 配置Symfony事件在输入引脚状态变化时触发

安装

GpioBundle可在Packagist(notrix/gpio-bundle)上找到,并且可以通过Composer进行安装。

php composer.phar require notrix/gpio-bundle 'dev-master'

配置

以下列出了可能的配置选项

# app/config/config.yml
notrix_gpio:
    sudo: true # Run commands with sudo permissions for raspberry
    development: false # true will use fake raspberry lib to imitate getting and setting pin statuses
    watcher_interval: 0.35 # how often poll input files for status changes
    in: # here you can configure input pins
        18: # this is rasperry's internal pin number 
            slug: pir_sensor1 # your custom slug to identify pin
            event: { on: pir_sensor_on, off: pir_sensor_off } # symfony event names. You can attach an event listeners to them
        23:
            slug: pir_sensor2
            event: [ pir_sensor_triggered ] # one event on both statuses on and off
    out: # here you can configure output pins
        17:
            slug: blue_led # slug to identify current pin
        22:
            slug: red_led

注意:由于此模块依赖于ronanguilloux/php-gpio开发库版本,因此您的项目最小稳定性必须是'dev'或包含此供应商作为项目依赖项,并使用@dev稳定性标志

用法

您应该始终使用管理服务'notrix_gpio.pin_manager'来控制您的引脚。

为输入引脚编写事件监听器

运行'php app/console notrix:gpio:setup'以初始化引脚

运行'php app/console notrix:gpio:watch -vv'以查看symfony如何对引脚状态变化做出反应,没有'-vv'以静默运行并执行监听器的任务。

关于

GpioBundle是NoTriX的倡议。如果您想成为贡献者列表中的一员,请随意fork、更新、扩展并PR您的更改。谢谢。