增加读数校准功能

This commit is contained in:
lxbpxylps@126.com 2021-11-03 23:41:54 +08:00
parent cf1c9012d9
commit cf77281abb
5 changed files with 35 additions and 8 deletions

22
config.json Normal file
View File

@ -0,0 +1,22 @@
{
"node2": {
"humi": 0.8,
"temp": 0,
"light": 0
},
"node3": {
"humi": 0,
"temp": -0.2,
"light": 0
},
"node4": {
"humi": -2,
"temp": 0.4,
"light": 0
},
"node5": {
"humi": 0.6,
"temp": 0,
"light": 0
}
}

View File

@ -1 +1 @@
{"time": "2021-10-31 14:13:45", "node2": {"humi": 46.4, "temp": 25.6, "light": 80.8}, "node3": {"humi": 47.6, "temp": 26.3, "light": 73.3}, "node4": {"humi": 47.3, "temp": 26.4, "light": 124.2}, "node5": {"humi": 47.4, "temp": 25.7, "light": 130.8}}
{"time": "2021-11-02 14:47:42", "node2": {"humi": 52.6, "temp": 27.7, "light": 180.8}, "node3": {"humi": 51.7, "temp": 27.6, "light": 165.8}, "node4": {"humi": 50.4, "temp": 27.9, "light": 170.8}, "node5": {"humi": 52.3, "temp": 27.8, "light": 173.3}}

View File

@ -32,13 +32,6 @@ class MainWindow(QMainWindow):
menubar_file = menubar.addMenu('文件')
menubar_file.addAction(exit_action)
# 菜单栏-校准
adjust_action = QAction('&校准菜单', self)
adjust_action.triggered.connect(lambda: sys.exit())
menubar_adjust = menubar.addMenu('校准')
menubar_adjust.addAction(adjust_action)
# 菜单栏-曲线
draw_node2_action = QAction('&节点2', self)
draw_node3_action = QAction('&节点3', self)

View File

@ -53,6 +53,17 @@ class SerialHandler(QThread):
print('数据不合理!')
continue
# 修正读数
config = json.loads(
open('./config.json', 'r', encoding='utf-8').read())
humi += config['node' + str(seq)]['humi']
temp += config['node' + str(seq)]['temp']
light += config['node' + str(seq)]['light']
humi = round(humi, 2)
temp = round(temp, 2)
light = round(light, 2)
print(f"节点:{seq} 湿度:{humi}% 温度:{temp}°C 光照度:{light}lx")
# 写入 json 文件

1
start.bat Normal file
View File

@ -0,0 +1 @@
python main.py