Build HAT Python库
项目描述
Build HAT
Python Build HAT库支持Raspberry Pi Build HAT,这是Raspberry Pi计算机的附加板,可控制SPIKE™组合中的最多四个LEGO® TECHNIC™电机和传感器。
硬件
Build HAT提供了四个用于SPIKE™组合中LEGO® Technic™电机和传感器的连接器。可用的传感器包括距离传感器、颜色传感器和多功能力传感器。角型电机有多种尺寸,并集成了可以查询以确定其位置的编码器。
Build HAT适用于所有具有40针GPIO端头的Raspberry Pi计算机,包括Raspberry Pi 400(通过添加扁平电缆或其他扩展设备)。可以通过Python轻松控制连接的LEGO® Technic™设备,同时使用标准Raspberry Pi附件,如摄像头模块。
文档
库文档: https://buildhat.readthedocs.io
硬件文档: https://www.raspberrypi.com/documentation/accessories/build-hat.html
项目和灵感: https://projects.raspberrypi.org/en/pathways/lego-intro
安装
要安装Build HAT库,请在终端中输入以下命令
pip3 install buildhat
用法
请参阅详细文档,了解可用的Python对象。
import time
from signal import pause
from buildhat import Motor
motor = Motor('A')
motor.set_default_speed(30)
print("Position", motor.get_aposition())
def handle_motor(speed, pos, apos):
print("Motor", speed, pos, apos)
motor.when_rotated = handle_motor
print("Run for degrees")
motor.run_for_degrees(360)
print("Run for seconds")
motor.run_for_seconds(5)
print("Run for rotations")
motor.run_for_rotations(2)
print("Start motor")
motor.start()
time.sleep(3)
print("Stop motor")
motor.stop()
pause()
本地构建
使用asdf
asdf install
然后
pip3 install . --user
构建文档
在docs/README.md
中可以找到重新生成文档的说明。简而言之,假设您已安装适当的Python模块
$ (cd docs; make html)
将重新构建文档。文档树从docs/build/html/index.html
开始
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分布
buildhat-0.7.0.tar.gz (160.7 kB 查看哈希值)
构建分布
buildhat-0.7.0-py3-none-any.whl (61.5 kB 查看哈希值)