一个简单的物理控制器,用于更改和查看当前踏板
PedalPi-Raspberry-P0的Python项目详细描述
一个简单的物理控制器,用于更改和查看当前踏板 带有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
元素列表:
- 2七段显示;
- 2个踏板更换按钮。
安装
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。
引脚
七段显示器的管脚彼此共享。那个 是,显示器1的pin_a与显示器的pin_a短接 显示器1的pin_b与显示器2的pin_b短接,依此类推 打开。但是,此规则不适用于common_pin,其中 显示器必须有自己的控制管脚。
使用的管脚是:
Config identifier | Pin¹ | Type | Function |
---|---|---|---|
pin_a | ^{tt7}$ | integer | Seven segments - Pin A |
pin_b | ^{tt8}$ | integer | Seven segments - Pin B |
pin_c | ^{tt9}$ | integer | Seven segments - Pin C |
pin_d | ^{tt10}$ | integer | Seven segments - Pin D |
pin_e | ^{tt11}$ | integer | Seven segments - Pin E |
pin_f | ^{tt12}$ | integer | Seven segments - Pin F |
pin_g | ^{tt13}$ | integer | Seven segments - Pin G |
pin_dp | ^{tt14}$ | integer | Seven segments - Dot point pin |
common_pins | ^{tt15}$ | integer list | Seven segments - Common pins |
common_anode | ^{tt16}$ | bool | ^{tt16}$ if the displays are anode. ^{tt18}$ if are cathode. |
next_pedalboard | ^{tt19}$ | integer | Button - Set to next Pedalboard |
before_pedalboard | ^{tt20}$ | integer | Button - Set to before Pedalboard |
momentary_footswitch | ^{tt18}$ | bool | ^{tt16}$ if buttons are momentary. ^{tt18}$ if buttons are two state |
配置文件
可以使用配置文件更改管脚。编号 引脚的数量对应于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'))
[display]七段显示
七段显示器由八个针组成,对应于 led(pin_a到pin_g和pin_dp)和两个公共管脚(它们 短路)。
有两种类型的七段显示器:阴极和阳极。 common_anode通知显示器是阳极还是阴极。
从Circuits Today获得的图像 说明引脚与LED的对应关系。
LED引脚
若要保存项目所需的管脚数量,则 七段显示器相互共享。这样,别针 对应于引脚led(pin_a到pin_g和pin_dp) 必须分别对显示器短路。也就是说, ^显示器1的{tt2}$与显示器的pin_a短路 2,显示器1的pin_b与显示器的pin_b短路 2等等。
Config identifier | Default value | Type | Function |
---|---|---|---|
^{tt2}$ | ^{tt7}$ | integer | Pin A |
^{tt4}$ | ^{tt8}$ | integer | Pin B |
^{tt41}$ | ^{tt9}$ | integer | Pin C |
^{tt43}$ | ^{tt10}$ | integer | Pin D |
^{tt45}$ | ^{tt11}$ | integer | Pin E |
^{tt47}$ | ^{tt12}$ | integer | Pin F |
^{tt27}$ | ^{tt13}$ | integer | Pin G |
^{tt28}$ | ^{tt14}$ | integer | Dot point pin |
公共管脚
为了描述显示器的common_pin,一个整数列表是 使用,其中数字的重要性遵循升序: tens对应于列表的第一个元素和units 到列表的第二个元素。
Config identifier | Default value | Type | Function |
---|---|---|---|
^{tt54}$ | ^{tt15}$ | integer list | Pin that controls the display view |
^{tt29}$ | ^{tt16}$ | bool | ^{tt16}$ if the displays are anode. ^{tt18}$ if are cathode. |
在Quora there is a tutorial中 如何识别显示器是阴极还是阳极。
[test]测试
Config identifier | Default value | Type | Function |
---|---|---|---|
^{tt67}$ | ^{tt18}$ | bool | Disable GPIOZero for development tests |