Skip to content

Latest commit

 

History

History
89 lines (61 loc) · 2.07 KB

README-CN.md

File metadata and controls

89 lines (61 loc) · 2.07 KB

English | 简体中文

notepad_core

连接并操作智能手写本的Flutter插件

功能

  • 扫描设备
  • 连接设备
  • 接收实时笔迹

扫描设备

Web

let device = notepadConnector.requestDevice();
console.log(`requestDevice ${device}`);

Mini-program on Wechat

let scanResultReceiver = function (scanResult) {
  console.log(`onScanResult ${scanResult}`);
};
notepadConnector.onScanResult(scanResultReceiver);

notepadConnector.startScan();
// ...
notepadConnector.stopScan();

notepadConnector.offScanResult(scanResultReceiver);

连接设备

连接从notepadConnector.requestDevice()中获取的device

或从notepadConnector.scanResultStream中扫描到的result

let connectionChangeHandler = function (notepadClient, connectionState) {
  console.log(`onConnectionChange ${notepadClient}, ${connectionState}`);
};
notepadConnector.onConnectionChange(connectionChangeHandler);

notepadConnector.connect(obj); // obj = device/scanResult
// ...
notepadConnector.disconnect();

notepadConnector.offConnectionChange(connectionChangeHandler);

接收实时笔迹

NotepadClient#setMode

  • NotepadMode.Common

    设备仅保存压力>0的NotePenPointer(含时间戳)到离线字迹

  • NotepadMode.Sync

    设备发送所有NotePenPointer(无时间戳)到连接的手机/Pad

设备默认为NotepadMode.Common(连接/未连接),只有连接后setMode才会更改

await _notepadClient.setMode(NotepadMode.Sync);
console.log("setMode complete");

NotepadClient#onSyncPointerReceive

NotepadMode.Sync时,接收NotePenPointer

let syncPointerReceiver = function (pointers) {
  console.log(`onSyncPointerReceive ${pointers.length}`);
};

_notepadClient.onSyncPointerReceive(syncPointerReceiver);
// ...
_notepadClient.offSyncPointerReceive(syncPointerReceiver);