一个简单的物理控制器,用于更改和查看当前踏板

PedalPi-Raspberry-P0的Python项目详细描述


Build StatusCode HealthCodacy Badge

一个简单的物理控制器,用于更改和查看当前踏板 带有2个按钮和7个两段显示

╔═══════════════════════════════════════════╗
║              P e d a l   P i           P0 ║
║                 ┌ ⎯  ⎯  ┐                 ║
║                 |⎥⎯⎜⎥ ⎜ |                 ║
║                 |⎥  ⎥⎯⎜.|                 ║
║                 └-------┘                 ║
║---------------------┬---------------------╢
║ ..=.............=.. | .........=......... ║
║ ....=.........=.... | ......=.....=...... ║
║ ......=.....=...... | ....=.........=.... ║
║ .........=......... | ..=.............=.. ║
╚═══════════════════════════════════════════╝
文档:
https://github.com/PedalPi/Raspberry-P0#raspberry-p0
代码:
https://github.com/PedalPi/Raspberry-P0
python包索引:
https://pypi.org/project/PedalPi-Raspberry-P0
许可证:
Apache License 2.0

元素列表:

  • A seven segments displays component2七段显示;
  • A push button component2个踏板更换按钮。

安装

pedalpi组件支持Pedal Pi - Application的扩展。 通过他们,提供开放服务。组件列表可以在Components repository中找到。

使用pip安装pedalpi-raspberry-p0

pip3 install PedalPi-Raspberry-P0

创建program.py

下面的示例演示踏板pi的基本设置- 覆盆子P0。如果要添加其他组件,请检查component list

importsysfromsignalimportpausefromapplication.applicationimportApplicationfromraspberry_p0.raspberry_p0importRaspberryP0application=Application(path_data="data/",address='localhost')application.register(RaspberryP0(application))application.start()try:pause()exceptKeyboardInterrupt:application.stop()

开始

python3 program.py

示意图

下图显示了组件与覆盆子pi之间的连接 默认配置。如果您想更换管脚,请参阅 Configuration File

P0 in the Fritzing

引脚

七段显示器的管脚彼此共享。那个 是,显示器1的pin_a与显示器的pin_a短接 显示器1的pin_b与显示器2的pin_b短接,依此类推 打开。但是,此规则不适用于common_pin,其中 显示器必须有自己的控制管脚。

使用的管脚是:

Config identifierPin¹TypeFunction
pin_a^{tt7}$integerSeven segments - Pin A
pin_b^{tt8}$integerSeven segments - Pin B
pin_c^{tt9}$integerSeven segments - Pin C
pin_d^{tt10}$integerSeven segments - Pin D
pin_e^{tt11}$integerSeven segments - Pin E
pin_f^{tt12}$integerSeven segments - Pin F
pin_g^{tt13}$integerSeven segments - Pin G
pin_dp^{tt14}$integerSeven segments - Dot point pin
common_pins^{tt15}$integer listSeven segments - Common pins
common_anode^{tt16}$bool^{tt16}$ if the displays are anode. ^{tt18}$ if are cathode.
next_pedalboard^{tt19}$integerButton - Set to next Pedalboard
before_pedalboard^{tt20}$integerButton - Set to before Pedalboard
momentary_footswitch^{tt18}$bool^{tt16}$ if buttons are momentary. ^{tt18}$ if buttons are two state

尼亚BCM pin numeration

配置文件

可以使用配置文件更改管脚。编号 引脚的数量对应于bcm。不需要通知所有人 配置。未通知的元素将与 默认值。

树莓皮皮诺示意图见 pinout.xyz

config_文件具有以下结构:

[display]
pin_a = 13
pin_b = 6
pin_c = 16
pin_d = 20
pin_e = 21
pin_f = 19
pin_g = 26
pin_dp = 0

common_pins = [5, 1]
common_anode = True

[pedalboard]
next_pedalboard = 14
before_pedalboard = 15

momentary_footswitch = True

[test]
test = False

要使p0加载新配置,请引用 RaspberryP0构造函数。

# The config file has named as 'path/my_awersome_config.ini'.application.register(RaspberryP0(application,configuration_file='my_awersome_config.ini'))

A seven segments displays component[display]七段显示

七段显示器由八个针组成,对应于 led(pin_apin_gpin_dp)和两个公共管脚(它们 短路)。

有两种类型的七段显示器:阴极和阳极。 common_anode通知显示器是阳极还是阴极。

Circuits Today获得的图像 说明引脚与LED的对应关系。

LED引脚

若要保存项目所需的管脚数量,则 七段显示器相互共享。这样,别针 对应于引脚led(pin_apin_gpin_dp) 必须分别对显示器短路。也就是说, ^显示器1的{tt2}$与显示器的pin_a短路 2,显示器1的pin_b与显示器的pin_b短路 2等等。

Config identifierDefault valueTypeFunction
^{tt2}$^{tt7}$integerPin A
^{tt4}$^{tt8}$integerPin B
^{tt41}$^{tt9}$integerPin C
^{tt43}$^{tt10}$integerPin D
^{tt45}$^{tt11}$integerPin E
^{tt47}$^{tt12}$integerPin F
^{tt27}$^{tt13}$integerPin G
^{tt28}$^{tt14}$integerDot point pin

公共管脚

为了描述显示器的common_pin,一个整数列表是 使用,其中数字的重要性遵循升序: tens对应于列表的第一个元素和units 到列表的第二个元素。

Config identifierDefault valueTypeFunction
^{tt54}$^{tt15}$integer listPin that controls the display view
^{tt29}$^{tt16}$bool^{tt16}$ if the displays are anode. ^{tt18}$ if are cathode.

Quora there is a tutorial中 如何识别显示器是阴极还是阳极。

A push button component[pedalboard]按钮

简单的按钮被用来改变当前的踏板。供使用 建议使用脚踏开关(如临时的 下图中的脚踏开关)。系统的两种按钮 支持临时按钮和两个状态按钮(开-关)。

Temporary footswitch
Config identifierDefault valueTypeFunction
next_pedalboard^{tt19}$integerSet the current pedalboard for the next
before_pedalboard^{tt20}$integerSet the current pedalboard for the before
momentary_footswitch^{tt18}$bool^{tt16}$ if buttons are momentary. ^{tt18}$ if buttons are two state

[test]测试

Config identifierDefault valueTypeFunction
^{tt67}$^{tt18}$boolDisable GPIOZero for development tests

常见问题

FAQs on the wiki

示例

P0 in a protoboard

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

推荐PyPI第三方库


热门话题
swing Java按钮/网格布局   java列出Google日历中的所有事件   java无效:单击API publisher test按钮后连接到后端时出错   带有内部赋值的java While循环导致checkstyle错误   java为什么trimToSize/ensureCapacity方法提供“公共”级访问?   文件输出流的java问题   ListIterator和并发修改异常的java问题   java如何使用两个URL映射   无法识别使用“./../”构造的字符串java相对路径,为什么?   首次写入remotelyclosedsocket不会触发异常,对吗?JAVA   java OneDrive REST API为文件上载提供了400个无效谓词   Java泛型、集合接口和对象类的问题   OpenSSL Java安全提供程序   jmeter java运行jmx禁用操作