maxim ds3502 i2c电位仪的circuitpython库
adafruit-circuitpython-ds3502的Python项目详细描述
依赖关系
此驱动程序取决于:
请确保circuitpython文件系统上的所有依赖项都可用。 这很容易通过下载来实现 the Adafruit library and driver bundle。
从pypi安装
在支持的gnu/linux系统(如raspberry pi)上,可以在本地安装驱动程序from PyPI。为当前用户安装:
pip3 install adafruit-circuitpython-ds3502
要在系统范围内安装(在某些情况下可能需要安装):
sudo pip3 install adafruit-circuitpython-ds3502
在当前项目的虚拟环境中安装:
mkdir project-name &&cd project-name python3 -m venv .env source .env/bin/activate pip3 install adafruit-circuitpython-ds3502
用法示例
fromtimeimportsleepimportboardimportadafruit_ds3502fromanalogioimportAnalogIn####### NOTE ################# this example will not work with Blinka/rasberry Pi due to the lack of analog pins.# Blinka and Raspberry Pi users should run the "ds3502_blinka_simpletest.py" examplei2c=board.I2C()ds3502=adafruit_ds3502.DS3502(i2c)wiper_output=AnalogIn(board.A0)whileTrue:ds3502.wiper=127print("Wiper set to %d"%ds3502.wiper)voltage=wiper_output.valuevoltage*=3.3voltage/=65535print("Wiper voltage: %.2f"%voltage)print("")sleep(1.0)ds3502.wiper=0print("Wiper set to %d"%ds3502.wiper)voltage=wiper_output.valuevoltage*=3.3voltage/=65535print("Wiper voltage: %.2f"%voltage)print("")sleep(1.0)ds3502.wiper=63print("Wiper set to %d"%ds3502.wiper)voltage=wiper_output.valuevoltage*=3.3voltage/=65535print("Wiper voltage: %.2f"%voltage)print("")sleep(1.0)
贡献
欢迎投稿!请阅读我们的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-ds3502 --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)错误的任何警告,像特拉维斯将。这是个很好的方法 本地验证它将通过。