用led在树莓pi上可视化metar数据。
rpi-metar的Python项目详细描述
关于
受一些DIY项目的启发,这个脚本允许您快速识别 通过改变LED的颜色来反映当前的天气状况 元信息。你需要一个覆盆子PI,一些WS281X发光二极管,和 你感兴趣的机场的四个字母的标志。
此代码假定您已连接到gpio 18(pwm0)并已添加 blacklist snd_bcm2835到/etc/modprobe.d/snd-blacklist.conf 文件。
不想自己动手做吗?这是驱动Aviation Weather Maps产品的代码。享受一份早餐 产品,还是继续阅读和快乐修补!
安装
sudo su apt install python3-venv python3 -m venv /opt/rpi_metar source /opt/rpi_metar/bin/activate pip install rpi_metar
配置
您需要告诉rpi_metar哪些LED对应于哪些机场。 您可以通过创建/etc/rpi_metar.conf文件来完成此操作。一定有 是机场代码分配给的[airports]部分 发光二极管。例如:
[airports] KDEN = 0 KBOS = 1
LED索引可以跳过,不需要连续。如果你 没有与机场相关联的LED,不需要 进入。
程序的行为可以通过包含^{tt6}来调整$ 配置文件中的节。这些配置值可以是 设置:
Option | Default | Description |
---|---|---|
brightness | 128 | An integer (from 0 to 255) controlling the intensity of the LEDs appear. In a well lit room, 75 or 85 are recommended. In a bright room, try 128. |
disable_gamma | False | A boolean that will allow you to disable the gamma correction. You may need this if using LEDs from different manufacturers / batches in a single run. |
do_fade | True | A boolean controlling whether or not stations will fade into their new color during a transition. If ^{tt7}$, they will just abruptly change colors. |
lightning | True | A boolean that controls if thunderstorm conditions should be visually indicated. They will appear as short blinks of white before going back to the station’s original color. |
lightning_dura tion | 1.0 | A float controlling how long a station blinks white before returning to its original color. |
max_wind | 30 | An integer that sets the threshold for max wind speed in knots. Any steady or gusting winds above this value will result in yellow blinking lights. |
metar_refresh_rate | 5 | An integer that controls how frequently (in minutes) the METAR information is polled. |
papertrail | True | A boolean controlling if logs are sent to a centralized system. Only METAR information and processing results are logged. |
wind | True | A boolean that controls if high wind speeds should be visually indicated. They will appear as short blinks of yellow before going back to the station’s original color. |
wind_duration | 1.0 | A float controlling how long a station blinks yellow before returning to its original color. |
unknown_off | True | A boolean that controls whether or not stations that are not reporting data will just turn off. If set to ^{tt7}$, after three attempts (during which time they appear as yellow), they will instead turn to orange. |
例如,要降低LED的亮度:
[settings] brightness = 85
自动启动
使用创建/etc/systemd/system/rpi_metar.service文件 以下内容:
[Unit] Description=METAR Display [Service] ExecStart=/opt/rpi_metar/bin/rpi_metar User=root Group=root Restart=always [Install] WantedBy=multi-user.target
使systemd知道这些更改:
systemctl daemon-reload
确保设置为在启动时运行:
systemctl enable rpi_metar
启动服务:
systemctl start rpi_metar