6155点阵插件完成。
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user