CircuitPython控制Crickit机器人板件的库。
项目描述
简介
这个便捷库让为Crickit机器人板件编写代码变得更加简单和快捷。
依赖关系
此驱动程序依赖于
请确保所有依赖项都可在CircuitPython文件系统中使用。这可以通过下载Adafruit库和驱动程序包轻松实现。
从PyPI安装
在支持的GNU/Linux系统(如Raspberry Pi)上,您可以从PyPI本地安装驱动程序。从PyPI安装。要安装当前用户
pip3 install adafruit-circuitpython-crickit
要全局安装(在某些情况下可能需要)
sudo pip3 install adafruit-circuitpython-crickit
在您当前项目的虚拟环境中安装
mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-crickit
使用示例
此示例展示了如何控制库支持的设备。在大多数情况下,您只需要几个导入。
# This is a mock example showing typical usage of the library for each kind of device.
from adafruit_crickit import crickit
# Add this import if using stepper motors.
# It will expose constants saying how to step: stepper.FORWARD, stepper.BACKWARD, etc.
from adafruit_motor import stepper
# Set servo 1 to 90 degrees
crickit.servo_1.angle = 90
# Change servo settings.
crickit.servo_1.actuation_range = 135
crickit.servo_1.set_pulse_width_range(min_pulse=850, max_pulse=2100)
# You can assign a device to a variable to get a shorter name.
servo_2 = crickit.servo_2
servo_2.throttle = 0
# Run a continous servo on Servo 2 backwards at half speed.
crickit.continuous_servo_2.throttle = -0.5
# Run the motor on Motor 1 terminals at half speed.
crickit.dc_motor_1.throttle = 0.5
# Set Drive 1 terminal to 3/4 strength.
crickit.drive_1.fraction = 0.75
if crickit.touch_1.value:
print("Touched terminal Touch 1")
# A single stepper motor uses up all the motor terminals.
crickit.stepper_motor.onestep(direction=stepper.FORWARD)
# You can also use the Drive terminals for a stepper motor
crickit.drive_stepper_motor.onestep(direction=stepper.BACKWARD)
# Note: On CPX Crickit, NeoPixel pin is normally connected to A1, not to seesaw,
# so this part of the demo cannot control the NeoPixel terminal.
# Strip or ring of 8 NeoPixels
crickit.init_neopixel(8)
crickit.neopixel.fill((100, 100, 100))
# Set the Crickit's on-board NeoPixel to a dim purple.
crickit.onboard_pixel.brightness = 0.01
crickit.onboard_pixel[0] = (255, 24, 255)
# or
crickit.onboard_pixel.fill((255, 24, 255))
文档
该库的API文档可以在Read the Docs上找到。
有关构建库文档的信息,请参阅本指南。
贡献
欢迎贡献!在为此项目做出贡献之前,请阅读我们的行为准则,以帮助保持项目的友好性。
项目详情
关闭
adafruit-circuitpython-crickit-2.3.17.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ba7d3cc477402d908469683e7318f14966583185f5174c5e6a40283050c45e37 |
|
MD5 | 8c631e69323f69baff098066c13d41c8 |
|
BLAKE2b-256 | 1650a5e7116e2bd8de84835bdca3c72b7fcea02c7d6b08b47c456f9fc60bbcbe |
关闭
adafruit_circuitpython_crickit-2.3.17-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 900e02cca7b230a1a77971c900d995e2a5fa5c048e9f7e040c43a1cc94c37d93 |
|
MD5 | 211fc2e0aa573ebb0f1d29024df24553 |
|
BLAKE2b-256 | 487a02b694b91235ede886114d2563e5a99f6c547a85879341ae94ef8d7a3279 |