1
0
forked from dyf/APP

6155点阵插件完成。

This commit is contained in:
liub
2025-08-07 08:48:02 +08:00
parent b3c0b74628
commit ca844723fa
4 changed files with 270 additions and 287 deletions

View File

@ -146,8 +146,21 @@ class BleHelper {
});
}
}
//移除发现新设备的回调
removeDeviceFound() {
let key = this.getCurrentPagePath();
if (key) {
let f = this.cfg.onDeviceFound.findIndex((v) => {
return v.key == key;
});
if (f > -1) {
this.cfg.onDeviceFound.splice(f, 1);
}
}
}
//设置接收到数据的回调
//添加接收到数据的回调
addReceiveCallback(callback) {
let key = this.getCurrentPagePath();
if (key) {
@ -165,18 +178,7 @@ class BleHelper {
}
}
//设置发现新设备的回调
removeDeviceFound() {
let key = this.getCurrentPagePath();
if (key) {
let f = this.cfg.onDeviceFound.findIndex((v) => {
return v.key == key;
});
if (f > -1) {
this.cfg.onDeviceFound.splice(f, 1);
}
}
}
//设置接收到数据的回调
removeReceiveCallback() {
@ -192,6 +194,8 @@ class BleHelper {
}
}
getError(ex) {
let code = ex.code;
@ -939,7 +943,8 @@ class BleHelper {
////console.log("无已连接设备");
}
}
//向蓝牙设备发送数据,如果没连接将自动连接后再发
sendData(deviceid, buffer, writeServiceId, wirteCharactId, ms) {
console.log("deviceid=" + deviceid + ",writeServiceId=" + writeServiceId + ",wirteCharactId=" +
@ -1051,7 +1056,24 @@ class BleHelper {
}
//将点阵数据转换成RGB565
convertToRGB565(pixels) {
const result = new Uint16Array(pixels.length/4);
let index = 0;
console.log("pixels.length=" + pixels.length);
for (let i = 0; i < pixels.length; i += 4) {
const r = pixels[i];
const g = pixels[i + 1];
const b = pixels[i + 2];
// 转换为RGB565 (R:5bit, G:6bit, B:5bit)
const rgb565 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
result[index++] = rgb565;
}
return result;
}
}
let instance = null;