circuitpython helper类与adafruit bluefruit le spi friend一起工作。

adafruit-circuitpython-bluefruitspi的Python项目详细描述


简介

Documentation StatusDiscordBuild Status

帮助类与adafruit bluefruit le spi friend一起工作。

依赖关系

此驱动程序取决于:

请确保circuitpython文件系统上的所有依赖项都可用。 这很容易通过下载来实现 the Adafruit library and driver bundle

从pypi安装

在支持的gnu/linux系统(如raspberry pi)上,可以在本地安装驱动程序from PyPI。为当前用户安装:

pip3 install adafruit-circuitpython-bluefruitspi

要在系统范围内安装(在某些情况下可能需要安装):

sudo pip3 install adafruit-circuitpython-bluefruitspi

在当前项目的虚拟环境中安装:

mkdir project-name &&cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-bluefruitspi

用法示例

# A simple echo test for the Feather M0 Bluefruit# Sets the name, then echo's all RX'd data with a reversed packetimporttimeimportbusioimportboardfromdigitalioimportDigitalInOutfromadafruit_bluefruitspiimportBluefruitSPIspi_bus=busio.SPI(board.SCK,MOSI=board.MOSI,MISO=board.MISO)cs=DigitalInOut(board.D8)irq=DigitalInOut(board.D7)rst=DigitalInOut(board.D4)bluefruit=BluefruitSPI(spi_bus,cs,irq,rst,debug=False)# Initialize the device and perform a factory resetprint("Initializing the Bluefruit LE SPI Friend module")bluefruit.init()bluefruit.command_check_OK(b'AT+FACTORYRESET',delay=1)# Print the response to 'ATI' (info request) as a stringprint(str(bluefruit.command_check_OK(b'ATI'),'utf-8'))# Change advertised namebluefruit.command_check_OK(b'AT+GAPDEVNAME=BlinkaBLE')whileTrue:print("Waiting for a connection to Bluefruit LE Connect ...")# Wait for a connection ...dotcount=0whilenotbluefruit.connected:print(".",end="")dotcount=(dotcount+1)%80ifdotcount==79:print("")time.sleep(0.5)# Once connected, check for incoming BLE UART dataprint("\n *Connected!*")connection_timestamp=time.monotonic()whileTrue:# Check our connection status every 3 secondsiftime.monotonic()-connection_timestamp>3:connection_timestamp=time.monotonic()ifnotbluefruit.connected:break# OK we're still connected, see if we have any data waitingresp=bluefruit.uart_rx()ifnotresp:continue# nothin'print("Read %d bytes: %s"%(len(resp),resp))# Now write it!print("Writing reverse...")send=[]foriinrange(len(resp),0,-1):send.append(resp[i-1])print(bytes(send))bluefruit.uart_tx(bytes(send))print("Connection lost.")

贡献

欢迎投稿!请阅读我们的Code of Conduct 在帮助这个项目保持热情之前。

本地建筑

压缩发布文件

要在本地构建此库,您需要安装 circuitpython-build-tools包装。

python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools

安装后,请确保您处于虚拟环境中:

source .env/bin/activate

然后运行生成:

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-bluefruitspi --library_location .

斯芬克斯文件

sphinx用于根据代码中的rst文件和注释构建文档。第一, 安装依赖项(请随意重用上面的虚拟环境):

python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme

现在,激活虚拟环境后:

cd docs
sphinx-build -E -W -b html . _build/html

这将把文档输出到docs/_build/html。在浏览器中打开index.html以 查看它们。它还将(由于-w)错误的任何警告,像特拉维斯将。这是个很好的方法 本地验证它将通过。

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

推荐PyPI第三方库


热门话题
JavaHTTP。请求侦听器   java Selenium webdriver遍历行并仅检索某些列   JavaSpring批处理在启动运行方法之前启动SimpleZoblancher运行方法   maven如何使用Maven2从javadoc生成java源代码?   java为什么我的Unicodont(Slick2D)不画画?   java取消对未使用对象的引用是否会提高冗长方法的性能?   java可执行Jar的画布比使用Eclipse Runner的小   为什么我的for循环在Android studio中与eclipse(java)产生不同的结果   java代码段字节数组到端口号   java在DynamoDB范围键中插入项   java 安卓。看法WindowManager$BadTokenException:无法添加窗口,您的活动正在运行吗?   java我想要两个列表视图同时滚动   java测试数据分离   java Saxon:每次重新部署后都需要重新启动Glassfish