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