6155添加强泛光指令

This commit is contained in:
fengerli
2025-11-26 15:57:52 +08:00
parent e247acdd5e
commit 362b752087

View File

@ -108,15 +108,15 @@
<view class="item">
<text class="lbl">单位</text>
<input class="value" v-model="formData.textLines[0]" placeholder="请输入单位" placeholder-class="usrplace" />
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" placeholder-class="usrplace" />
</view>
<view class="item">
<text class="lbl">部门</text>
<input class="value" v-model="formData.textLines[1]" placeholder="请输入姓名" placeholder-class="usrplace" />
<input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名" placeholder-class="usrplace" />
</view>
<view class="item">
<text class="lbl">姓名</text>
<input class="value" v-model="formData.textLines[2]" placeholder="请输入职位" placeholder-class="usrplace" />
<input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位" placeholder-class="usrplace" />
</view>
</view>
@ -1293,9 +1293,14 @@
case "fu":
title = '辅灯模式';
items = [{
text: '泛光',
icon: '/static/images/6155/DeviceDetail/fan.png'
}];
text: '泛光',
icon: '/static/images/6155/DeviceDetail/fan.png'
},
{
text: '强+泛光',
icon: '/static/images/6155/DeviceDetail/fan.png'
},
];
break;
}
@ -1330,29 +1335,22 @@
},
setMode(mode, type) {
let dataValue = 0;
switch (mode) {
case 0:
if (type == 'main') {
dataValue = 0x01;
} else if (type == 'fu') {
dataValue = 0x04;
}
break;
case 1:
dataValue = 0x02;
if (type == 'main') {
dataValue = 0x02;
} else if (type == 'fu') {
dataValue = 0x0A; //强泛光
}
break;
// case 2:
// dataValue = 0x02;
// break;
case 2:
dataValue = 0x03;
break;
@ -1361,7 +1359,7 @@
break;
}
// console.log("dataValue=", dataValue)
console.log("dataValue=", dataValue)
// 构建数据包
var buffer = new ArrayBuffer(6);
var dataView = new DataView(buffer);
@ -1535,7 +1533,7 @@
if (!allPixels) {
throw new Error("无法生成像素数据");
}
// 2. 将所有像素数据合并到一个大数组中
let combinedData = [];
for (let i = 0; i < 3; i++) {
@ -1548,47 +1546,47 @@
}
combinedData = combinedData.concat(linePixels.slice(0, 256));
}
// 3. 构建完整的逻辑大包
const logicalPacketSize = 4 + combinedData.length + 1; // Header + Data + Footer
const logicalBuffer = new ArrayBuffer(logicalPacketSize);
const logicalDataView = new DataView(logicalBuffer);
// 写入头部
logicalDataView.setUint8(0, 0xFA);
logicalDataView.setUint8(1, 0x06);
logicalDataView.setUint8(2, 0x03);
logicalDataView.setUint8(3, 0x00);
// 写入数据
for (let i = 0; i < combinedData.length; i++) {
logicalDataView.setUint8(4 + i, combinedData[i]);
}
// 写入尾部
logicalDataView.setUint8(logicalPacketSize - 1, 0xFF);
// 4. 将逻辑大包分包发送
const CHUNK_SIZE = 20; // 每个物理包的大小
const totalChunks = Math.ceil(logicalPacketSize / CHUNK_SIZE);
updateLoading(these, {
text: `准备发送,共 ${totalChunks} 个数据包...`
});
for (let i = 0; i < totalChunks; i++) {
const start = i * CHUNK_SIZE;
const end = Math.min(start + CHUNK_SIZE, logicalPacketSize);
const chunk = logicalBuffer.slice(start, end);
updateLoading(these, {
text: `正在发送 ${i + 1} / ${totalChunks}`
});
await ble.sendData(f.deviceId, chunk, f.writeServiceId, f.wirteCharactId, 50);
await new Promise(resolve => setTimeout(resolve, 50)); // 包之间延迟
}
// 5. 发送成功处理
hideLoading(these);
this.showPop({
@ -1597,7 +1595,7 @@
borderColor: '#BBE600',
buttonBgColor: '#BBE600'
});
let json = {
deviceId: these.device.id,
name: these.formData.textLines[1],
@ -1606,7 +1604,7 @@
code: ""
};
usrApi.sendUsr(json);
} catch (ex) {
hideLoading(these);
this.showPop({