在Pimoroni LED垫片上显示各种效果。
ledshimdemo的Python项目详细描述
LED垫片演示
对覆盆子piled-shim显示多种效果的应用程序 来自皮莫罗尼。
这些效果是基于library中给出的示例加上一些 从我的fork添加。
- 二进制时钟-显示小时、分钟和秒。
- 蜡烛-闪烁的蜡烛。
- 与CheerLights“物联网”项目同步。
- 彩灯-简单的彩灯像圣诞灯。
- 数字雨降价格矩阵效应。
- 梯度图-由正弦波高度决定的移动颜色梯度。
- 彩虹-缓慢移动的彩虹效果。
- 随机闪烁-一些随机闪烁。
- 纯色-一种基本的效果,只显示一系列纯色。
安装
在Raspbian上安装,使用:
sudo pip3 install ledshimdemo
或使用更新:
sudo pip3 install -U ledshimdemo
运行
$ ledshimdemo --help
Usage: ledshimdemo [OPTIONS] [EFFECTS_SELECTED]...
Show various effects on a Pimoroni LED shim.
To limit the effects shown use the effect-list option to list the effects
available then add them to the command line as required. Otherwise all
effects will be shown.
Options:
--version Show the version and exit.
-l, --effect-list List the effects available and exit.
-d, --effect-display [CYCLE|RANDOM]
How the effects are displayed. [default:
CYCLE]
-u, --effect-duration INTEGER RANGE
How long to display each effect for, in
seconds (1-180). [default: 10]
-r, --repeat-run INTEGER RANGE How many times to run the effects before
stopping (1-240). [default: 1
-b, --brightness INTEGER RANGE How bright the effects will be (1-10).
[default: 8]
-i, --invert Change the display orientation.
-o, --log-level [DEBUG|VERBOSE|INFO|WARNING]
Show additional logging information.
[default: INFO]
--help Show this message and exit.
带有默认选项的示例输出:
$ ledshimdemo
2019-08-23 17:15:37,130 - INFO - Logging level enabled!
2019-08-23 17:15:37,131 - INFO - Active Options(effect-display=CYCLE, effect-duration=10 secs, repeat-run=1, brightness=8, invert=False, log-level=INFO, effects_selected=ALL)
2019-08-23 17:15:37,132 - INFO - Effect: BinaryClock - Shows hours, minutes and seconds. Update Frequency: 1 secs
2019-08-23 17:15:47,454 - INFO - Effect: Candle - A flickering candle. Update Frequency: 0.01 secs
2019-08-23 17:15:57,474 - INFO - Effect: CheerLights - Synchronize with the CheerLights "Internet of Things" project. Update Frequency: 5 secs
2019-08-23 17:16:08,044 - INFO - Effect: ColouredLights - Simple coloured lights like Xmas lights. Update Frequency: 0.5 secs
2019-08-23 17:16:18,104 - INFO - Effect: DigitalRain - Cut price Matrix effect. Update Frequency: 0.02 secs
2019-08-23 17:16:28,111 - INFO - Effect: GradientGraph - Sine wave colour gradient effect. Update Frequency: 0.01 secs
2019-08-23 17:16:38,141 - INFO - Effect: Rainbow - A slowly moving rainbow. Update Frequency: 0.01 secs
2019-08-23 17:16:48,158 - INFO - Effect: RandomBlink - Some random blinking. Update Frequency: 0.05 secs
2019-08-23 17:16:58,213 - INFO - Effect: SolidColours - A sequence of solid colours. Update Frequency: 0.5 secs
故障排除
如果在运行ledshimdemo
时出现任何问题,那么将是numpy,它由
演示。numpy包包含在raspbian的大多数构建中,但是与apt-get
一起安装,这将导致问题
如果有人试图用pip3
安装不同的版本。因此ledshimdemo
被设置为使用raspbian
默认版本(请参见setup.py)以尝试避免使用pip3
安装不同版本。但是,如果你得到一个
运行时错误,指示numpy已损坏,您可以首先尝试卸载它的任何本地pip3
版本,以查看
有帮助。
pip3 uninstall numpy
附录
这个项目对它的实际功能有些过度设计,因为它被用作一个学习练习。
应用程序内置了许多输出日志级别,包括自定义详细级别,以显示 内部运作。这只是因为。
使用松散地基于 thispython3工厂模式示例。
这个项目的代码覆盖率是一个很好的例子,说明了为什么度量单元测试覆盖率会成为一个误导性的指标 质量。虽然它确实有很多单元测试,但那些效果测试大多是简单的烟雾测试,这表明 代码将运行。他们并没有确认这些效果是否产生了预期的效果。
此项目的开发工作是在Intel x64计算机上使用PyCharm完成的,如 项目被设计为运行在一个基于arm的树莓pi上,只有一个源发行版被上传到pypi。然而, 在raspbian下安装时,应该从PiWheels安装臂轮 使安装速度更快。有关更多信息,请参见PiWheels FAQ 信息。
顶部显示了主分支和开发分支的构建状态和代码覆盖范围。这是 一个简单的解决方案,试图使这个文件特定于它所在的分支。