物件:
orangepi一套(电源,网线,orangepiPC)110元
nokia 5110 lcd 接线8跟 15块
展示:
使用python操作orangepi_PC 的gpio需要安装 https://github.com/duxingkei33/orangepi_PC_gpio_pyH3
想在orangepi_PC中驱动 nokia5110 需要 编译 cd8544_rpi https://github.com/nopnop2002/pcd8544_rpi
安装方法
git clone https://github.com/nopnop2002/pcd8544_rpi
cd pcd8544_rpi/
cc -o nokia nokia.c fontx.c pcd8544.c -lwiringPi -lpthread
bash ./test.sh
简单使用说明。
> 最大支持6行,4X8一行可以显示个字符20 6X8一行可以可显示12左右吧
GPIO接口(按示意图连接OrangePi gpio口和 nokia5110)
NOKIA5110
---
RPi/OPi
物理针脚编号
1 RST
---
GPIO23
(Pin#16)
2 CE
---
SPI CE0
(Pin#24)
3 DC
---
GPIO24
(PIn#18)
4 DIN
---
SPI MOSI
(Pin#19)
5 CLK
---
SPI SCLK
(Pin#23)
6 VCC
---
3.3V
7 BL
---
3.3V/GND(*)
8 GND
---
GND
nokia5110的第7pin(背光) 可以选择接地(灭背光)或3.3v(亮背光)。
连接导线时注意第一个针脚旁边有小白色三角标志
使用supervisord 管理frpc 和 状态刷新程序。
supervisord的配置文件
directory = /tmp
command = /usr/bin/frpc -c /etc/frp/frpc.ini
autostart = true
startsecs = 10
autorestart = true
startretries = 3
user = root
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /tmp/frac.log
[program:orangePiStatus]
directory = /root/pcd8544_rpinew/
command = /usr/bin/python /root/pcd8544_rpinew/status.py
autostart = true
startsecs = 10
autorestart = true
startretries = 3
user = root
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /tmp/orangepiStatus.log
frpc.ini
server_addr = serverip
server_port = 9000
token= 20192019
[orangepi_ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6223
https://github.com/fatedier/frp
操作屏幕的python脚本(status.py)
#!coding:utf-8
# by:lvusyy
#
import commands
import os
import time
SLEEPTIME=10 #every 10s
times=0
WANIP=commands.getstatusoutput("curl -s http://members.3322.org/dyndns/getip")[1]
def getdatas():
line0='UpTime:{}'
line1='TP:{}.PC:{}'
line2='LD:{}'
line3='Frpc:{}'#running stop
line4='WANIP:'
line5='Net:{}'
uptime= commands.getstatusoutput("uptime|awk '{print $3$4}'")[1][0:-1]
temp= commands.getstatusoutput("cat /sys/class/thermal/thermal_zone0/temp")[1]
psCount= commands.getstatusoutput("ps aux|wc -l")[1].replace(' ','')
load = commands.getstatusoutput("uptime|awk -Faverage: '{print $2}'")[1].replace(' ','')
global times
if times>=60:
wanip=commands.getstatusoutput("curl -s http://members.3322.org/dyndns/getip")[1]
global WANIP
WANIP=wanip
times=0
else:
wanip=WANIP
times += 1
network= commands.getstatusoutput("ping baidu.com -c 1 2>/dev/null|grep -q time && echo Online ||echo *offline*")[1]
if network.find('offline')!=-1:
times=60
frpc= commands.getstatusoutput("ps aux|grep -q frpc && echo Running ||echo Stoped")[1]
return [line0.format(uptime),line1.format(temp,psCount),line2.format(load),line3.format(frpc),line5.format(network),wanip if wanip else "**Offline**"]
def show():
''
os.system('./nokia r')
line=0
a=['a','b','3','d','e','6']
for i in getdatas():
# print("nokia {} {}".format(line,i))
os.system("./nokia +{} {}".format(a[line],i))
line += 1
os.system('./nokia c 60')
os.system('./nokia s')
def loop():
''
while True:
time.sleep(SLEEPTIME)
show()
def main():
loop()
if __name__=="__main__":
main()
之后可以设置个开机脚本来启动supervisord
即可。 也可以用systemctl
管理.
之后在外网也可轻松管理orangepi了。
【后续,有必要再补充!】
手机扫一扫
移动阅读更方便
你可能感兴趣的文章