I/O通信库

ahio的Python项目详细描述


ahio

ahio是一个通信库,其目标是 是抽象与各种i/o硬件的接口,以便 只要修改最少的代码,硬件就成为可能。这是我想要的 已经与I/O硬件一起工作的应用程序只需要pin 重新映射并可能对初始设置进行更改以使用其他硬件,而不是 整个代码重写。

它与安装在ahio.drivers包中的驱动程序一起工作。每 驱动程序必须实现ahio.abstract_driver包中描述的api。 如果您计划使用此库或开发驱动程序,请阅读文档 在那里。

安装

最简单的方法是使用pip:pip3 install ahio 或者,您可以签出此存储库并运行 python3 setup.py install

基本用法

# Import the package:importahio# You can see what drivers are available in this platform by callingprint(ahio.list_available_drivers())# Instantiate the desired driverwithahio.new_driver('Arduino')asarduino:# The driver can have a driver-specific setup function. Call it as/if needed.arduino.setup('/dev/tty.usbmodem1421')# Map the pins. From now on, when you use 1 in the API, it will have effects# on pin D3 in the Arduino. If you change hardware in the future, just change# the mapping.arduino.map_pin(1,arduino.Pins.D3)arduino.map_pin(2,arduino.Pins.D13)arduino.map_pin(3,arduino.Pins.A1)# Change a pin direction (Input or Output)arduino.set_pin_direction([1,2],ahio.Direction.Output)arduino.set_pin_direction(3,ahio.Direction.Input)# Set the output of a pinarduino.write([1,2],ahio.LogicValue.High)arduino.write(1,0.4,pwm=True)# Read the input of a pinprint(arduino.read(3))

文档

文档位于GitHub

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java需要64位jdk 1.5 for windows   eclipse运算符+对于参数类型java是未定义的。双,爪哇。双人   未下载文件扩展名为的java文件   java不支持带有POST的媒体类型   从动态创建的多个EditText读取文本时发生java错误   java无法为同一xpath单击多个按钮   如何在Java中动态格式化字符串   java Android Clear Middle活动   多线程Java内存模型volatile和x86   git在Java中通过Jgit忽略文件或文件夹   java“决策无法区分输入的备选方案1、2…”   子类的javajpa继承   java需要弄清楚如何操作mutator来弄清楚一个类,教授说,我对如何操作感到困惑   java如何使用JDBC将数据从文件复制到PostgreSQL?