跳转到主要内容

CircuitPython控制Crickit机器人板件的库。

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

这个便捷库让为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 (29.8 kB 查看哈希值)

上传时间

构建分发

adafruit_circuitpython_crickit-2.3.17-py3-none-any.whl (7.5 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面