修改动态配置称数据接受和LED屏幕发送比率

This commit is contained in:
liuwu 2023-12-20 17:15:05 +08:00
parent e186cc353e
commit 7c57c53048
3 changed files with 81 additions and 3 deletions

View File

@ -128,6 +128,15 @@
<button id='weightSize' class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;" >请选择</button>
</div>
<div class="mui-col-xs-4" style="display:flex;justify-content: flex-end;">
<!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="weightSizeSave()">保存</button>-->
</div>
</div>
<div class="mui-row form">
<div class="mui-col-xs-8" style="display:flex;justify-content: flex-start;">
<text class="flex1" style="font-size: x-large;margin-left:15px;font-weight: 900;">称LED比</text>
<button id='btl' class="flex1 mui-btn-inline mui-btn-info" style="font-size: large;color: seagreen !important;" >请选择</button>
</div>
<div class="mui-col-xs-4" style="display:flex;justify-content: flex-end;">
<!-- <button class="save mui-btn-inline mui-btn-primary" style="font-size: large;" onclick="weightSizeSave()">保存</button>-->
</div>
</div>
@ -147,15 +156,18 @@
var pageListener = null;
var fixListener = null;
var weiListener = null;
var btlListener = null;
var userPicker;
var pagePicker;
var fixPicker;
var weiPicker;
var btlPicker;
var pickData = [];
var btnArray = ['取消', '<b style="font-weight:900">确认</b>'];
var pageData = []
var fixData = []
var weiData = []
var btlData = []
fixData.push({value: 0, text: "需要"})
fixData.push({value: 1, text: "不需要"})
@ -172,6 +184,17 @@
weiData.push({value: "70", text: "70"})
weiData.push({value: "80", text: "80"})
btlData.push({value: "1", text: "1"})
btlData.push({value: "2", text: "2"})
btlData.push({value: "3", text: "3"})
btlData.push({value: "4", text: "4"})
btlData.push({value: "5", text: "5"})
btlData.push({value: "6", text: "6"})
btlData.push({value: "7", text: "7"})
btlData.push({value: "8", text: "8"})
btlData.push({value: "9", text: "9"})
btlData.push({value: "10", text: "10"})
var apiready = function apiready() {
initSbList()
}
@ -252,6 +275,7 @@
muiInitPage()
muiInitFix()
muiInitWeightSize()
muiInitBtl()
var indexPage = api.getPrefs({
sync: true,
key: 'initpage'
@ -289,6 +313,19 @@
}
})
}
var btl = api.getPrefs({
sync: true,
key: 'btl'
});
if (btl) {
btlData.forEach(p => {
if (btl === p.value) {
document.getElementById('btl').innerHTML = p.text
}
})
}
setTimeout(function () {
api.hideProgress();
}, 1000);
@ -431,6 +468,32 @@
})(mui, document);
}
function muiInitBtl() {
(function ($, doc) {
$.init();
$.ready(function () {
var _getParam = function _getParam(obj, param) {
return obj[param] || '';
};
if (btlPicker) {
} else {
btlPicker = new $.PopPicker();
var showBtlPickerButton = doc.getElementById('btl');
btlListener = null;
btlListener = showBtlPickerButton.addEventListener('tap', function (event) {
btlPicker.show(function (items) {
showBtlPickerButton.innerHTML = items[0].text;
if (items[0].text){
btlSave()
}
});
}, false);
}
btlPicker.setData(btlData);
});
})(mui, document);
}
function initsb() {
// var value = document.getElementById('initsb').value;
var value = document.getElementById('initsb').innerHTML
@ -462,7 +525,17 @@
key: 'weightSize',
value: value
});
mui.alert('自动跳转数据包"' + value + '"成功');
mui.alert('自动跳转数据包"' + value + '"设置成功');
}
}
function btlSave(){
var value = document.getElementById('btl').innerHTML;
if (value) {
api.setPrefs({
key: 'btl',
value: value
});
mui.alert('称LED接收发送比"' + value + '"设置成功');
}
}
function fixbeforeload(){

View File

@ -257,6 +257,7 @@
var db;
var weightSize = 40;
var shujubao = 1;
var apiready = function apiready() {
// 获取db连接
@ -273,7 +274,6 @@
var size = api.getPrefs({sync: true,key: 'weightSize'})
if (size && !isNaN(size)){
weightSize = Number(size)
console.log(weightSize)
}
var fixbeforeload = api.getPrefs({
sync: true,
@ -282,6 +282,10 @@
if (fixbeforeload){
weightBeforefix = fixbeforeload;
}
var btl = api.getPrefs({sync: true,key: 'btl'})
if (btl && !isNaN(btl)){
shujubao = Number(btl)
}
console.log("weightBeforefix"+weightBeforefix)
ble = api.require('ble');
zfk = api.require("moduleDemo");

View File

@ -555,7 +555,8 @@ function getMess(param, callback) {
param.value = "FF0500" + num.toString(16) + str;
countLED ++;
// 称重量数据3包取1包
if (countLED >= 3){
// console.log(shujubao)
if (countLED >= shujubao){
msgList.push(param.value);
// var ms = strToHex(sbId,4)+strToHex(classCode,2)+strToHex(trainNumber,2)+strToHex(feedIndex,2)+strToHex(_planSum,4)+strToHex(_feedNum,4)+strToHex(nowWeight,4);
// var num1 = ms.length / 2;