ソースを参照

feature:修改蓝牙传输的大小

zeng.chen 7 ヶ月 前
コミット
d2b511a396
1 ファイル変更9 行追加4 行削除
  1. 9 4
      pages/piano/cropper/cropper.js

+ 9 - 4
pages/piano/cropper/cropper.js

@@ -249,7 +249,7 @@ Page({
     });
   },
   async startImage(imageBuffer) {
-    this.sliceDataIntoChunks(imageBuffer, 32);
+    this.sliceDataIntoChunks(imageBuffer, 128);
 
     BtHelper.sendCallBack(BtCmd.wallPaper(1), function (res) {
       if (!res) {
@@ -276,12 +276,17 @@ Page({
     let _this = this
 
     wx.hideLoading()
-    let chunks = this.data._chunks
+    let chunks = _this.data._chunks
     let next = 0;
-    let total = this.data._imageBufferLength;
+    let total = _this.data._imageBufferLength;
     let btHelper = BtHelper.getInstance();
     let i = 0;
-    this._timer = setInterval(async () => {
+    _this.data._timer = setInterval(async () => {
+      if (i >= chunks.length) {
+        clearInterval(_this.data._timer);
+        console.log("发送图片数据完成:", i, total)
+        return;
+      }
       const chunk = chunks[i];
       i++;
       next += chunk.byteLength;