翻出买了几年的AX206,重新改了下脚本继续用
本帖最后由 wxws 于 2019-4-2 12:08 编辑改了几项:
1:从darksky.net 取天气,需要去注册个帐号,然后才能使用http api
2: 从darksky取的天气有个中文 天气简语,再写了个TXT2PIC 转成png图片了.go写的,文件有3M左右.压缩包有各cpu程序,自行取用.
3:取空气质量 脚本改了下
还要自行安装个jq ,linux下json解析工具.
这玩意买不着了, 想着是否能自己做个,当然lcd4linux还是很强大的,不想再做上位机,看是否能用STM32仿个AX206出来.
链接:https://pan.baidu.com/s/1WHJg4UDtxGVq4yRsy1A7ZA
提取码:hdaz
本帖最后由 wxws 于 2019-4-2 12:47 编辑
天气脚本:
#!/bin/sh
#请自行云darksky.net注意一个帐号取得一个key,将下面的kkkkkk 替换掉 还有gps地址,进网站后就明白了.
wget -O /tmp/weather 'https://api.darksky.net/forecast/kkkkkkkk/31.9093,120.263?&lang=zh&units=si'
if [ $? = 0 ]; then
outfile='/usr/share/lcd4linux/240X320/data/weather'
# touch $outfile
rm -rf $outfile
echo darksky >> $outfile
# 现在的天气大图标 140*84
#echo 32 >> $outfile
cat /tmp/weather | jq -r '.currently.icon' |awk -F "," '{ \
ii = $1 ; icon="44";\
if (ii=="clear-day") {icon="32"} \
else if (ii=="clear-night") {icon="32"} \
else if (ii=="rain") {icon="8"} \
else if (ii=="snow") {icon="15"} \
else if (ii=="sleet") {icon="41"} \
else if (ii=="wind") {icon="23"} \
else if (ii=="fog") {icon="6"} \
else if (ii=="cloudy") {icon="27"} \
else if (ii=="partly-cloudy-day") {icon="33"} \
else if (ii=="partly-cloudy-night") {icon="33"} \
print icon \
}'>> $outfile
cat /tmp/weather | jq '.currently."temperature"' | awk -F "." '{ L3 = sprintf("%.0f", $0); L3=L3"c";while (length(L3) < 4) {L3="n"L3};print L3}' >> $outfile
echo 0 >> $outfile
#cat /tmp/weather | jq '.daily.data | ."temperatureLow",."temperatureMax"' | awk 'END{print $0;print $1}'
Llow=`cat /tmp/weather | jq '.daily.data.temperatureMin'`
Lhigh=`cat /tmp/weather | jq '.daily.data.temperatureMax'`
echo $Llow,$Lhigh |awk -F "," '{ \
L51 = sprintf("%.0f", $1); L52 = sprintf("%.0f", $2);\
L5=L51"cdu"L52"c";while (length(L5) < 10) {L5="n"L5};\
print L5 \
}'>> $outfile
#明天的天气小图标60x36
#echo 0 >> $outfile
cat /tmp/weather | jq -r '.daily.data.icon' |awk -F "," '{ \
ii = $1 ; icon="44";\
if (ii=="clear-day") {icon="32"} \
else if (ii=="clear-night") {icon="32"} \
else if (ii=="rain") {icon="8"} \
else if (ii=="snow") {icon="15"} \
else if (ii=="sleet") {icon="41"} \
else if (ii=="wind") {icon="23"} \
else if (ii=="fog") {icon="6"} \
else if (ii=="cloudy") {icon="27"} \
else if (ii=="partly-cloudy-day") {icon="33"} \
else if (ii=="partly-cloudy-night") {icon="33"} \
print icon \
}'>> $outfile
#明天7
Llow=`cat /tmp/weather | jq '.daily.data.temperatureMin'`
Lhigh=`cat /tmp/weather | jq '.daily.data.temperatureMax'`
echo $Llow,$Lhigh |awk -F "," '{ \
L51 = sprintf("%.0f", $1); L52 = sprintf("%.0f", $2);\
L5=L51"cdu"L52"c";while (length(L5) < 10) {L5="n"L5};\
print L5 \
}'>> $outfile
cat /tmp/weather | jq '.currently.windSpeed' >> $outfile
cd /usr/share/lcd4linux/240X320/scripts
cat /tmp/weather | jq -r ".currently.summary" | ./txt2pic
else
exit $?
fi
exit 0
注意上面的目录地址.
空气质量脚本:
#!/bin/sh
display_aqidata="jiangyin"
#获取AQI数据和数据绘图。http://www.aqicn.org
rm -f /tmp/aqicn
wget -c -O /tmp/aqicn "http://feed.aqicn.org/feed/$display_aqidata/en/feed.v1.json" --continue --no-check-certificate
#pm25
#cat /tmp/aqicn | awk -F '"val":' '{print $2}' | awk -F "," '{print $1}' >> /tmp/aqi
#cat /tmp/aqicn | awk -F '"val":' '{print $2}' | awk -F "," '{ \
cat /tmp/aqicn | jq -r '.aqi.val' | awk -F " " '{\
cAQI=$1; \
if (cAQI<50) {aLevel=1} \
else if (cAQI<100) {aLevel=2} \
else if (cAQI<150) {aLevel=3} \
else if (cAQI<200) {aLevel=4} \
else if (cAQI<300) {aLevel=5} \
else {aLevel=6}; \
print "pm25";print cAQI;print aLevel \
}' > /usr/share/lcd4linux/240X320/data/aqi
exit 0
支持一下大牛,赞 这个玩意真实的强大 用到软路由了,不会改天气
喜欢一块交流的可以加群:801173246 支持一下大牛,赞 楼主,你有那个相框的刷机软件吗?能否发一份?niuniu2999@163.com API key只有14天试用,用和风的API是否可以?显示位置要调整吧? stm32仿制成功有需要的闲鱼 怎么联系可以加我微信13588031861
页:
[1]