增加稳定包数配置,增加设置mtu120

This commit is contained in:
liuwu 2023-11-03 18:15:01 +08:00
parent d114d3a7b8
commit 6725c6a12d
5 changed files with 1235 additions and 3 deletions

1090
html/collection.html Normal file

File diff suppressed because it is too large Load Diff

View File

@ -102,6 +102,12 @@
<button class="mui-btn-inline mui-btn-success" style="font-size: large;" onclick="initpage()">保存
</button>
</div>
<div class="mui-row form flex1">
<button class="mui-btn-inline mui-btn-info" style="font-size: large;" type='button'>跳转数据包数</button>
<input id='weightSize' style="font-size: large;" value="" type="number" placeholder="请输入数字"/>
<button class="mui-btn-inline mui-btn-success" style="font-size: large;" onclick="weightSizeSave()">保存
</button>
</div>
</div>
<div class="mui-col-sm-4">
@ -283,6 +289,17 @@
mui.alert('默认页面"' + name + '"设置成功');
}
}
function weightSizeSave(){
var value = document.getElementById('weightSize').value;
if (value) {
api.setPrefs({
key: 'weightSize',
value: value
});
mui.alert('自动跳转数据包"' + value + '"成功');
}
}
</script>
</body>
</html>

114
html/index.html Normal file
View File

@ -0,0 +1,114 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>Document</title>
<link rel="stylesheet" href="../css/mui_min.css">
<link href="../css/mui_picker_min.css" rel="stylesheet"/>
<link href="../css/mui_poppicker_css" rel="stylesheet"/>
<script src="../script/api.js"></script>
<script src="../script/mui.min.js"></script>
<script src="../script/mui.picker.min.js"></script>
<script src="../script/mui.poppicker.js"></script>
</head>
<style>
.content {
width: 100%;
height: 100vh;
box-sizing: border-box;
border: 1px solid #a3caef;
}
.flex{
/*flex 布局*/
display: flex;
background-color: #007aff;
/*实现垂直居中*/
align-items: center;
/*实现水平居中*/
justify-content: center;
text-align: justify;
/* width:33%; */
height: 100vh;
/*
margin: 5px 5px;
padding: 5px 5px; */
}
</style>
<body>
<div class="mui-row content">
<div class="mui-col-sm-3 flex">
<button class="mui-btn-success " style="font-size: 100px;font-weight: 900;border-radius: 50px;color: black;" onclick="startLoad()">装料</button>
</div>
<div class="mui-col-sm-6 flex">
<button class="mui-btn-success " style="font-size: 100px;font-weight: 900;border-radius: 50px;color: black;" onclick="startRemain()">剩料收集</button>
</div>
<div class="mui-col-sm-3 flex">
<button id="config" class="mui-btn-success " style="font-size: 100px;font-weight: 900;border-radius: 50px;color: black;" onclick="config()">设置</button>
</div>
</div>
<script>
var btnArray = ['取消', '<b style="font-weight:900">确认</b>'];
var apiready = function apiready() {
var initpage = api.getPrefs({sync: true,key: 'initpage'})
if(initpage){
switch (initpage){
case "index":
break;
case "index1":
setTimeout(function(){
startLoad()
},1000)
break;
case "collection":
setTimeout(function(){
startRemain()
},1000)
break;
case "config":
setTimeout(function(){
config()
},1000)
break;
}
}
api.addEventListener({
name: 'keyback'
}, function (ret, err) {
mui.confirm('确认关闭TMR饲喂系统', '提示', btnArray, function (e) {
if (e.index == 0) {} else {
api.closeWidget({
id: api.appId, //应用ID
retData: { name: 'closeWidget' },
silent: true
});
}
});
});
}
function startLoad(){
api.openWin({
name: 'index1',
reload:true,
url:'../html/index1.html'
})
}
function startRemain(){
api.openWin({
name: 'collection',
reload:true,
url:'../html/collection.html'
})
}
function config(){
api.openWin({
name: 'config',
reload:true,
url:'../html/config.html'
})
}
</script>
</body>
</html>

View File

@ -249,7 +249,15 @@
30: "㉚"
}
var ble;
var weightSize = 40;
var apiready = function apiready() {
var size = api.getPrefs({sync: true,key: 'weightSize'})
if (size && !isNaN(size)){
weightSize = size
console.log(weightSize)
}
ble = api.require('ble');
zfk = api.require("moduleDemo");
clearInterval(resultInterval);

View File

@ -133,7 +133,7 @@ function connect(param) {
console.log('主机端连接成功')
ble.setMtu({
peripheralUUID: param.peripheralUUID,
mtu:50
mtu:120
},function(ret){
if(ret.status){
initWeight();
@ -388,7 +388,7 @@ function discoverService(param) {
// 重量稳定计数
var filteredValue = weightDataFilter.filter(nowWeight);
// 重量稳定自动跳转
if (weightDataFilter.dataBuffer.length === 40) {
if (weightDataFilter.dataBuffer.length === weightSize) {
console.log("重量稳定", currTimeFn(new Date()));
weightDataFilter.dataBuffer = []
document.getElementById('submitData').click();
@ -577,6 +577,9 @@ function strToHex(str,length){
}
return append+hex;
}
var weightSize = 40;
/*初始化重量图表*/
function initWeight() {
api.showProgress({
@ -584,7 +587,7 @@ function initWeight() {
modal: true
});
weightStatus = true;
weightDataFilter = new WeightDataFilter(40, _weightSum);
weightDataFilter = new WeightDataFilter(weightSize, _weightSum);
renderUnload();
renderLoad();
feedMyChart.setOption({